Skip to content

Commit e41ea17

Browse files
committed
Simplify NLS.bind() invocations in jsch integration
1 parent f35c81b commit e41ea17

File tree

6 files changed

+35
-35
lines changed

6 files changed

+35
-35
lines changed

team/bundles/org.eclipse.jsch.core/src/org/eclipse/jsch/internal/core/ResponsiveSocketFactory.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2019 IBM Corporation and others.
2+
* Copyright (c) 2007, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -13,11 +13,20 @@
1313
*******************************************************************************/
1414
package org.eclipse.jsch.internal.core;
1515

16-
import java.io.*;
17-
import java.lang.reflect.*;
18-
import java.net.*;
16+
import java.io.IOException;
17+
import java.io.InputStream;
18+
import java.io.InterruptedIOException;
19+
import java.io.OutputStream;
20+
import java.lang.reflect.Constructor;
21+
import java.lang.reflect.Field;
22+
import java.lang.reflect.InvocationTargetException;
23+
import java.net.InetSocketAddress;
24+
import java.net.Socket;
25+
import java.net.UnknownHostException;
1926

20-
import org.eclipse.core.runtime.*;
27+
import org.eclipse.core.runtime.IProgressMonitor;
28+
import org.eclipse.core.runtime.IStatus;
29+
import org.eclipse.core.runtime.NullProgressMonitor;
2130
import org.eclipse.osgi.util.NLS;
2231

2332
import com.jcraft.jsch.SocketFactory;
@@ -128,7 +137,7 @@ private Socket createSocket(final String host, final int port, int timeout, IPro
128137
throw (IOException)exception[0];
129138
}
130139
if (socket[0] == null) {
131-
throw new InterruptedIOException(NLS.bind(Messages.Util_timeout, new String[] { host }));
140+
throw new InterruptedIOException(NLS.bind(Messages.Util_timeout, host));
132141
}
133142
return socket[0];
134143
}

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/KeyboardInteractiveDialog.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2008 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -84,7 +84,7 @@ public KeyboardInteractiveDialog(Shell parentShell,
8484
this.prompt=prompt;
8585
this.echo=echo;
8686
if (name!=null && name.length()>0) {
87-
this.message=NLS.bind(Messages.KeyboardInteractiveDialog_0, new String[] { destination, name });
87+
this.message = NLS.bind(Messages.KeyboardInteractiveDialog_0, destination, name);
8888
} else {
8989
this.message=NLS.bind(Messages.KeyboardInteractiveDialog_1, destination);
9090
}

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/KeyboardInteractiveDialog.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2008 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -89,8 +89,7 @@ public KeyboardInteractiveDialog(Shell parentShell, String comment,
8989
this.prompt=prompt;
9090
this.echo=echo;
9191
this.message=NLS.bind(Messages.KeyboradInteractiveDialog_message,
92-
new String[] {destination
93-
+(name!=null&&name.length()>0 ? ": "+name : "")}); //NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
92+
destination + (name != null && name.length() > 0 ? ": " + name : "")); // NON-NLS-1$ //$NON-NLS-1$ //$NON-NLS-2$
9493

9594
if(prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
9695
isPasswordAuth=true;
@@ -165,8 +164,7 @@ protected Control createDialogArea(Composite parent){
165164
if(comment!=null){
166165
Label label=new Label(main, SWT.WRAP);
167166
if(isUsernameMutable){
168-
label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
169-
new String[] {comment}));
167+
label.setText(NLS.bind(Messages.UserValidationDialog_labelUser, comment));
170168
}
171169
else{
172170
label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/UserValidationDialog.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2008 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -147,8 +147,7 @@ protected Control createDialogArea(Composite parent){
147147
if(comment!=null){
148148
Label label=new Label(main, SWT.WRAP);
149149
if(isUsernameMutable){
150-
label.setText(NLS.bind(Messages.UserValidationDialog_labelUser,
151-
new String[] {comment}));
150+
label.setText(NLS.bind(Messages.UserValidationDialog_labelUser, comment));
152151
}
153152
else{
154153
label.setText(NLS.bind(Messages.UserValidationDialog_labelPassword,

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/authenticator/WorkbenchUserAuthenticator.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -218,7 +218,7 @@ public boolean promptForHostKeyChange(final IJSchLocation location){
218218
final boolean[] openConfirm=new boolean[] {false};
219219
final Display display=getStandardDisplay();
220220
display.syncExec(() -> openConfirm[0] = MessageDialog.openConfirm(null, Messages.WorkbenchUserAuthenticator_1,
221-
NLS.bind(Messages.WorkbenchUserAuthenticator_2, new String[] { location.getHost() })));
221+
NLS.bind(Messages.WorkbenchUserAuthenticator_2, location.getHost())));
222222
if(!openConfirm[0]){
223223
throw new OperationCanceledException();
224224
}

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/internal/ui/preference/PreferencePage.java

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2018 IBM Corporation and others.
2+
* Copyright (c) 2000, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -571,8 +571,7 @@ public void widgetSelected(SelectionEvent e){
571571
PassphrasePrompt prompt=null;
572572
while(_kpair.isEncrypted()){
573573
if(prompt==null){
574-
prompt=new PassphrasePrompt(NLS.bind(
575-
Messages.CVSSSH2PreferencePage_126, new String[] {pkey}));
574+
prompt = new PassphrasePrompt(NLS.bind(Messages.CVSSSH2PreferencePage_126, pkey));
576575
}
577576
Display.getDefault().syncExec(prompt);
578577
String passphrase=prompt.getPassphrase();
@@ -581,9 +580,8 @@ public void widgetSelected(SelectionEvent e){
581580
if(_kpair.decrypt(passphrase)){
582581
break;
583582
}
584-
MessageDialog.openError(getShell(),
585-
Messages.CVSSSH2PreferencePage_error, NLS.bind(
586-
Messages.CVSSSH2PreferencePage_129, new String[] {pkey}));
583+
MessageDialog.openError(getShell(), Messages.CVSSSH2PreferencePage_error,
584+
NLS.bind(Messages.CVSSSH2PreferencePage_129, pkey));
587585
}
588586
if(_kpair.isEncrypted()){
589587
return;
@@ -688,8 +686,7 @@ public void widgetSelected(SelectionEvent e){
688686
}
689687

690688
if(user.length()==0||host.length()==0||port==-1){
691-
setErrorMessage(NLS.bind(Messages.CVSSSH2PreferencePage_108,
692-
new String[] {target[0]}));
689+
setErrorMessage(NLS.bind(Messages.CVSSSH2PreferencePage_108, target[0]));
693690
return;
694691
}
695692

@@ -744,9 +741,8 @@ public void widgetSelected(SelectionEvent e){
744741
File _home=new File(home);
745742

746743
if(!_home.exists()){
747-
if(!MessageDialog.openConfirm(getShell(),
748-
Messages.CVSSSH2PreferencePage_confirmation, NLS.bind(
749-
Messages.CVSSSH2PreferencePage_50, new String[] {home}))){
744+
if (!MessageDialog.openConfirm(getShell(), Messages.CVSSSH2PreferencePage_confirmation,
745+
NLS.bind(Messages.CVSSSH2PreferencePage_50, home))) {
750746
return;
751747
}
752748
if(!_home.mkdirs()){
@@ -765,9 +761,8 @@ public void widgetSelected(SelectionEvent e){
765761
}
766762

767763
if(new File(file).exists()){
768-
if(!MessageDialog.openConfirm(getShell(),
769-
Messages.CVSSSH2PreferencePage_confirmation, //
770-
NLS.bind(Messages.CVSSSH2PreferencePage_53, new String[] {file}))){
764+
if (!MessageDialog.openConfirm(getShell(), Messages.CVSSSH2PreferencePage_confirmation, //
765+
NLS.bind(Messages.CVSSSH2PreferencePage_53, file))) {
771766
return;
772767
}
773768
}
@@ -1546,9 +1541,8 @@ public boolean performOk(){
15461541
String home=ssh2HomeText.getText();
15471542
File _home=new File(home);
15481543
if(!_home.exists()){
1549-
if(MessageDialog.openQuestion(getShell(),
1550-
Messages.CVSSSH2PreferencePage_question, NLS.bind(
1551-
Messages.CVSSSH2PreferencePage_99, new String[] {home}))){
1544+
if (MessageDialog.openQuestion(getShell(), Messages.CVSSSH2PreferencePage_question,
1545+
NLS.bind(Messages.CVSSSH2PreferencePage_99, home))) {
15521546
if(!(_home.mkdirs())){
15531547
setErrorMessage(Messages.CVSSSH2PreferencePage_100+home);
15541548
return false;

0 commit comments

Comments
 (0)