Skip to content

Commit b4bddeb

Browse files
author
jantje
committed
replaced EMPTY_STRING by new String()
1 parent 9645d8b commit b4bddeb

File tree

1 file changed

+80
-81
lines changed

1 file changed

+80
-81
lines changed

io.sloeber.ui/src/io/sloeber/ui/PasswordDialog.java

Lines changed: 80 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -17,85 +17,84 @@
1717
import org.eclipse.swt.widgets.Text;
1818

1919
public class PasswordDialog extends Dialog {
20-
private static String EMPTY_STRING = ""; //$NON-NLS-1$
21-
private Text txtUser;
22-
private Text txtPassword;
23-
private String myUser = EMPTY_STRING;
24-
private String myPassword = EMPTY_STRING;
25-
private String myHost = Messages.error_no_host_name;
26-
27-
public PasswordDialog(Shell parentShell) {
28-
super(parentShell);
29-
}
30-
31-
@Override
32-
protected Control createDialogArea(Composite parent) {
33-
parent.getShell().setText(Messages.ui_sec_login_and_password + this.myHost);
34-
Composite container = (Composite) super.createDialogArea(parent);
35-
GridLayout layout = new GridLayout(2, false);
36-
layout.marginRight = 5;
37-
layout.marginLeft = 10;
38-
container.setLayout(layout);
39-
40-
Label lblUser = new Label(container, SWT.NONE);
41-
lblUser.setText(Messages.ui_sec_login + ':');
42-
43-
this.txtUser = new Text(container, SWT.BORDER);
44-
this.txtUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
45-
this.txtUser.setText(this.myUser);
46-
47-
Label lblPassword = new Label(container, SWT.NONE);
48-
GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
49-
gd_lblNewLabel.horizontalIndent = 1;
50-
lblPassword.setLayoutData(gd_lblNewLabel);
51-
lblPassword.setText(Messages.ui_sec_password + ':');
52-
53-
this.txtPassword = new Text(container, SWT.BORDER);
54-
this.txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
55-
this.txtPassword.setText(this.myPassword);
56-
57-
return container;
58-
}
59-
60-
// override method to use "Login" as label for the OK button
61-
@Override
62-
protected void createButtonsForButtonBar(Composite parent) {
63-
createButton(parent, IDialogConstants.OK_ID, Messages.ui_sec_login, true);
64-
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
65-
}
66-
67-
@Override
68-
protected Point getInitialSize() {
69-
return new Point(450, 300);
70-
}
71-
72-
@Override
73-
protected void okPressed() {
74-
// Copy data from SWT widgets into fields on button press.
75-
// Reading data from the widgets later will cause an SWT
76-
// widget disposed exception.
77-
this.myUser = this.txtUser.getText();
78-
this.myPassword = this.txtPassword.getText();
79-
super.okPressed();
80-
}
81-
82-
public String getUser() {
83-
return this.myUser;
84-
}
85-
86-
public void setUser(String user) {
87-
this.myUser = user;
88-
}
89-
90-
public String getPassword() {
91-
return this.myPassword;
92-
}
93-
94-
public void setPassword(String password) {
95-
this.myPassword = password;
96-
}
97-
98-
public void sethost(String host) {
99-
this.myHost = host;
100-
}
20+
private Text txtUser;
21+
private Text txtPassword;
22+
private String myUser = new String();
23+
private String myPassword = new String();
24+
private String myHost = Messages.error_no_host_name;
25+
26+
public PasswordDialog(Shell parentShell) {
27+
super(parentShell);
28+
}
29+
30+
@Override
31+
protected Control createDialogArea(Composite parent) {
32+
parent.getShell().setText(Messages.ui_sec_login_and_password + this.myHost);
33+
Composite container = (Composite) super.createDialogArea(parent);
34+
GridLayout layout = new GridLayout(2, false);
35+
layout.marginRight = 5;
36+
layout.marginLeft = 10;
37+
container.setLayout(layout);
38+
39+
Label lblUser = new Label(container, SWT.NONE);
40+
lblUser.setText(Messages.ui_sec_login + ':');
41+
42+
this.txtUser = new Text(container, SWT.BORDER);
43+
this.txtUser.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
44+
this.txtUser.setText(this.myUser);
45+
46+
Label lblPassword = new Label(container, SWT.NONE);
47+
GridData gd_lblNewLabel = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
48+
gd_lblNewLabel.horizontalIndent = 1;
49+
lblPassword.setLayoutData(gd_lblNewLabel);
50+
lblPassword.setText(Messages.ui_sec_password + ':');
51+
52+
this.txtPassword = new Text(container, SWT.BORDER);
53+
this.txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
54+
this.txtPassword.setText(this.myPassword);
55+
56+
return container;
57+
}
58+
59+
// override method to use "Login" as label for the OK button
60+
@Override
61+
protected void createButtonsForButtonBar(Composite parent) {
62+
createButton(parent, IDialogConstants.OK_ID, Messages.ui_sec_login, true);
63+
createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
64+
}
65+
66+
@Override
67+
protected Point getInitialSize() {
68+
return new Point(450, 300);
69+
}
70+
71+
@Override
72+
protected void okPressed() {
73+
// Copy data from SWT widgets into fields on button press.
74+
// Reading data from the widgets later will cause an SWT
75+
// widget disposed exception.
76+
this.myUser = this.txtUser.getText();
77+
this.myPassword = this.txtPassword.getText();
78+
super.okPressed();
79+
}
80+
81+
public String getUser() {
82+
return this.myUser;
83+
}
84+
85+
public void setUser(String user) {
86+
this.myUser = user;
87+
}
88+
89+
public String getPassword() {
90+
return this.myPassword;
91+
}
92+
93+
public void setPassword(String password) {
94+
this.myPassword = password;
95+
}
96+
97+
public void sethost(String host) {
98+
this.myHost = host;
99+
}
101100
}

0 commit comments

Comments
 (0)