Skip to content

Commit 50c2b0d

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of team/bundles/org.eclipse.jsch.ui
1 parent ddda586 commit 50c2b0d

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

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

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,11 @@ public void promptForUserInfo(final IJSchLocation location,
7878
}
7979
location.setPassword(result[1]);
8080
if(location.getPasswordStore()!=null){
81-
if(allowCaching[0])
81+
if(allowCaching[0]) {
8282
location.getPasswordStore().update(location);
83-
else
83+
} else {
8484
location.getPasswordStore().clear(location);
85+
}
8586
}
8687
}
8788
}
@@ -143,10 +144,11 @@ public String[] promptForKeyboradInteractive(
143144
prompt!=null && prompt.length==1 && prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
144145
location.setPassword(result[0][0]);
145146
if(location.getPasswordStore()!=null){
146-
if(allowCaching[0])
147+
if(allowCaching[0]) {
147148
location.getPasswordStore().update(location);
148-
else
149+
} else {
149150
location.getPasswordStore().clear(location);
151+
}
150152
}
151153
}
152154
return result[0];
@@ -163,8 +165,9 @@ protected String[] _promptForUserInteractive(
163165
dialog.setUsernameMutable(false);
164166
dialog.open();
165167
String[] _result=dialog.getResult();
166-
if(_result!=null)
168+
if(_result!=null) {
167169
allowCaching[0]=dialog.getAllowCaching();
170+
}
168171
return _result;
169172
}
170173

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -228,11 +228,13 @@ public void widgetSelected(SelectionEvent e){
228228
if(!new File(home).exists()){
229229
while(true){
230230
int foo=home.lastIndexOf(java.io.File.separator, home.length());
231-
if(foo==-1)
231+
if(foo==-1) {
232232
break;
233+
}
233234
home=home.substring(0, foo);
234-
if(new File(home).exists())
235+
if(new File(home).exists()) {
235236
break;
237+
}
236238
}
237239
}
238240

@@ -268,8 +270,9 @@ public void widgetSelected(SelectionEvent e){
268270
}
269271

270272
for (String foo : files) {
271-
if(keys.length()!=0)
273+
if(keys.length()!=0) {
272274
keys=keys+","; //$NON-NLS-1$
275+
}
273276
keys=keys+dir+foo;
274277
}
275278
privateKeyText.setText(keys);
@@ -353,8 +356,9 @@ private Control createKeyManagementPage(Composite parent){
353356
keyCommentText.setLayoutData(gd);
354357

355358
keyCommentText.addModifyListener(e -> {
356-
if(kpair==null)
359+
if(kpair==null) {
357360
return;
361+
}
358362
try{
359363
ByteArrayOutputStream out=new ByteArrayOutputStream();
360364
kpairComment = keyCommentText.getText();
@@ -575,8 +579,9 @@ public void widgetSelected(SelectionEvent e){
575579
}
576580
Display.getDefault().syncExec(prompt);
577581
String passphrase=prompt.getPassphrase();
578-
if(passphrase==null)
582+
if(passphrase==null) {
579583
break;
584+
}
580585
if(_kpair.decrypt(passphrase)){
581586
break;
582587
}
@@ -601,8 +606,9 @@ public void widgetSelected(SelectionEvent e){
601606
byte[] buf=new byte[(int)f.length()];
602607
while(i<buf.length){
603608
int j=fis.read(buf, i, buf.length-i);
604-
if(j<=0)
609+
if(j<=0) {
605610
break;
611+
}
606612
i+=j;
607613
}
608614
String pubkey=new String(buf);
@@ -648,8 +654,9 @@ public void widgetSelected(SelectionEvent e){
648654
keyExport.addSelectionListener(new SelectionAdapter(){
649655
@Override
650656
public void widgetSelected(SelectionEvent e){
651-
if(kpair==null)
657+
if(kpair==null) {
652658
return;
659+
}
653660

654661
setErrorMessage(null);
655662

@@ -717,8 +724,9 @@ public void widgetSelected(SelectionEvent e){
717724
saveKeyPair.addSelectionListener(new SelectionAdapter(){
718725
@Override
719726
public void widgetSelected(SelectionEvent e){
720-
if(kpair==null)
727+
if(kpair==null) {
721728
return;
729+
}
722730

723731
String pass=keyPassphrase1Text.getText();
724732
/*
@@ -800,17 +808,19 @@ public void widgetSelected(SelectionEvent e){
800808
if (!pkey.isAbsolute()) {
801809
pkey = new java.io.File(home, p);
802810
}
803-
if(pkey.equals(mypkey))
811+
if(pkey.equals(mypkey)) {
804812
return;
813+
}
805814
}
806815

807816
if(dir.equals(home)){
808817
dir="";} //$NON-NLS-1$
809818
else{
810819
dir+=java.io.File.separator;
811820
}
812-
if(pkeys.length()>0)
821+
if(pkeys.length()>0) {
813822
pkeys+=","; //$NON-NLS-1$
823+
}
814824
pkeys=pkeys+dir+fd.getFileName();
815825
privateKeyText.setText(pkeys);
816826
}
@@ -918,8 +928,9 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput){
918928

919929
@Override
920930
public Object[] getElements(Object inputElement){
921-
if(inputElement==null)
931+
if(inputElement==null) {
922932
return null;
933+
}
923934
return (Object[])inputElement;
924935
}
925936
});

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

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ public static Group createHFillGroup(Composite parent, String text, int margins,
8989
final Group group= new Group(parent, SWT.NONE);
9090
group.setFont(parent.getFont());
9191
group.setLayoutData(createHFillGridData());
92-
if (text != null)
92+
if (text != null) {
9393
group.setText(text);
94+
}
9495
group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
9596
return group;
9697
}
@@ -103,8 +104,9 @@ public static Group createHVFillGroup(Composite parent, String text, int margins
103104
final Group group= new Group(parent, SWT.NONE);
104105
group.setFont(parent.getFont());
105106
group.setLayoutData(createHVFillGridData());
106-
if (text != null)
107+
if (text != null) {
107108
group.setText(text);
109+
}
108110
group.setLayout(createGridLayout(rows, new PixelConverter(parent), margins));
109111
return group;
110112
}
@@ -164,8 +166,9 @@ public static Label createLabel(Composite parent, String message) {
164166

165167
public static Label createLabel(Composite parent, String message, int span) {
166168
final Label label= new Label(parent, SWT.WRAP);
167-
if (message != null)
169+
if (message != null) {
168170
label.setText(message);
171+
}
169172
label.setLayoutData(createHFillGridData(span));
170173
return label;
171174
}
@@ -232,8 +235,9 @@ public static int calculateControlSize(PixelConverter converter, Control [] cont
232235
int minimum= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
233236
for (int i = start; i <= end; i++) {
234237
final int length= controls[i].computeSize(SWT.DEFAULT, SWT.DEFAULT).x;
235-
if (minimum < length)
238+
if (minimum < length) {
236239
minimum= length;
240+
}
237241
}
238242
return minimum;
239243
}
@@ -256,8 +260,9 @@ public static int getWidthInCharsForLongest(PixelConverter converter, String []
256260
int minimum= 0;
257261
for (String string : strings) {
258262
final int length = converter.convertWidthInCharsToPixels(string.length());
259-
if (minimum < length)
263+
if (minimum < length) {
260264
minimum= length;
265+
}
261266
}
262267
return minimum;
263268
}

team/bundles/org.eclipse.jsch.ui/src/org/eclipse/jsch/ui/UserInfoPrompter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,9 @@ public String[] promptKeyboardInteractive(String destination, String name,
163163
}
164164
String[] result=promptForKeyboradInteractiveInUI(destination, name,
165165
instruction, prompt, echo);
166-
if(result==null)
166+
if(result==null) {
167167
return null; // canceled
168+
}
168169
if(result.length==1&&prompt.length==1
169170
&&prompt[0].trim().equalsIgnoreCase("password:")){ //$NON-NLS-1$
170171
password=result[0];

0 commit comments

Comments
 (0)