Skip to content

Commit a3ca975

Browse files
eclipse-platform-botlaeubi
authored andcommitted
Perform clean code of terminal/bundles/org.eclipse.terminal.connector.telnet
1 parent 56b485a commit a3ca975

File tree

9 files changed

+52
-28
lines changed

9 files changed

+52
-28
lines changed

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/NetworkPortMap.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,18 @@ public String getDefaultNetworkPort() {
3838

3939
public String findPortName(String strPort) {
4040
for (int i = 0; i < fPortMap.length; i++) {
41-
if (fPortMap[i][1].equals(strPort))
41+
if (fPortMap[i][1].equals(strPort)) {
4242
return fPortMap[i][0];
43+
}
4344
}
4445
return null;
4546
}
4647

4748
public String findPort(String strPortName) {
4849
for (int i = 0; i < fPortMap.length; i++) {
49-
if (fPortMap[i][0].equals(strPortName))
50+
if (fPortMap[i][0].equals(strPortName)) {
5051
return fPortMap[i][1];
52+
}
5153
}
5254
return null;
5355
}

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/TelnetConnectWorker.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,12 @@ public void run() {
5050

5151
while (remaining >= 0) {
5252
// Pause before we re-try if the remaining tries are less than the initial value
53-
if (remaining < 10)
53+
if (remaining < 10) {
5454
try {
5555
Thread.sleep(500);
5656
} catch (InterruptedException e) {
5757
/* ignored on purpose */ }
58+
}
5859

5960
try {
6061
int nTimeout = fConn.getTelnetSettings().getTimeout() * 1000;

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/TelnetConnection.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,12 +261,14 @@ public boolean isRemoteTelnetServer() {
261261
*/
262262
public void setTerminalSize(int newWidth, int newHeight) {
263263
Logger.log("Setting new size: width = " + newWidth + ", height = " + newHeight); //$NON-NLS-1$ //$NON-NLS-2$
264-
if (!isConnected() || !isRemoteTelnetServer())
264+
if (!isConnected() || !isRemoteTelnetServer()) {
265265
return;
266+
}
266267
boolean sizeChanged = false;
267268

268-
if (newWidth != width || newHeight != height)
269+
if (newWidth != width || newHeight != height) {
269270
sizeChanged = true;
271+
}
270272

271273
width = newWidth;
272274
height = newHeight;
@@ -543,8 +545,9 @@ protected int processTelnetProtocol(int count) {
543545

544546
// First, zero out the array of received subnegotiation butes.
545547

546-
for (int i = 0; i < receivedSubnegotiation.length; ++i)
548+
for (int i = 0; i < receivedSubnegotiation.length; ++i) {
547549
receivedSubnegotiation[i] = 0;
550+
}
548551

549552
// Forget about any previous subnegotiation errors.
550553

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/TelnetConnector.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,20 @@ static final class TelnetOutputStream extends FilterOutputStream {
4747

4848
public TelnetOutputStream(OutputStream outputStream, String endOfLine) {
4949
super(outputStream);
50-
if (ITelnetSettings.EOL_CRLF.equals(endOfLine))
50+
if (ITelnetSettings.EOL_CRLF.equals(endOfLine)) {
5151
EOL = CRLF;
52-
else
52+
} else {
5353
EOL = CRNUL;
54+
}
5455
}
5556

5657
@Override
5758
public void write(int b) throws IOException {
58-
if (b == CR)
59+
if (b == CR) {
5960
out.write(EOL);
60-
else
61+
} else {
6162
out.write(b);
63+
}
6264
}
6365
}
6466

@@ -119,8 +121,9 @@ public void doDisconnect() {
119121

120122
@Override
121123
public boolean isLocalEcho() {
122-
if (fTelnetConnection == null)
124+
if (fTelnetConnection == null) {
123125
return false;
126+
}
124127
return fTelnetConnection.localEcho();
125128
}
126129

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/TelnetOption.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,10 @@ public boolean isDesired() {
312312
* we desire this option to be disabled.
313313
*/
314314
public void setDesired(boolean newValue) {
315-
if (newValue)
315+
if (newValue) {
316316
Logger.log("Setting " + (local ? "local" : "remote") + " option " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
317317
optionName() + " as desired."); //$NON-NLS-1$
318+
}
318319

319320
desired = newValue;
320321
}

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/connector/TelnetSettingsPage.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,17 @@ public void loadSettings() {
6868
}
6969

7070
private void setHost(String strHost) {
71-
if (strHost == null)
71+
if (strHost == null) {
7272
strHost = ""; //$NON-NLS-1$
73+
}
7374
fHostText.setText(strHost);
7475

7576
}
7677

7778
private void setTimeout(String timeout) {
78-
if (timeout == null || timeout.length() == 0)
79+
if (timeout == null || timeout.length() == 0) {
7980
timeout = "5"; //$NON-NLS-1$
81+
}
8082
fTimeout.setText(timeout);
8183

8284
}

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/controls/TelnetWizardConfigurationPanel.java

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public void setupPanel(Composite parent) {
5555
panel.setLayoutData(data);
5656

5757
// Create the host selection combo
58-
if (isWithoutSelection())
58+
if (isWithoutSelection()) {
5959
createHostsUI(panel, true);
60+
}
6061

6162
TelnetConnector conn = new TelnetConnector();
6263
telnetSettings = (TelnetSettings) conn.getTelnetSettings();
@@ -72,8 +73,9 @@ public void setupPanel(Composite parent) {
7273

7374
// Add the listener to the settings page
7475
telnetSettingsPage.addListener(control -> {
75-
if (getContainer() != null)
76+
if (getContainer() != null) {
7677
getContainer().validate();
78+
}
7779
});
7880

7981
// Create the encoding selection combo
@@ -84,39 +86,46 @@ public void setupPanel(Composite parent) {
8486

8587
@Override
8688
public void setupData(Map<String, Object> data) {
87-
if (data == null || telnetSettings == null || telnetSettingsPage == null)
89+
if (data == null || telnetSettings == null || telnetSettingsPage == null) {
8890
return;
91+
}
8992

9093
String value = (String) data.get(ITerminalsConnectorConstants.PROP_IP_HOST);
91-
if (value != null)
94+
if (value != null) {
9295
telnetSettings.setHost(value);
96+
}
9397

9498
Object v = data.get(ITerminalsConnectorConstants.PROP_IP_PORT);
9599
value = v != null ? v.toString() : null;
96-
if (value != null)
100+
if (value != null) {
97101
telnetSettings.setNetworkPort(value);
102+
}
98103

99104
v = data.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
100105
value = v != null ? v.toString() : null;
101-
if (value != null)
106+
if (value != null) {
102107
telnetSettings.setTimeout(value);
108+
}
103109

104110
v = data.get(ITerminalsConnectorConstants.PROP_TELNET_EOL);
105111
value = v != null ? v.toString() : null;
106-
if (value != null)
112+
if (value != null) {
107113
telnetSettings.setEndOfLine(value);
114+
}
108115

109116
value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
110-
if (value != null)
117+
if (value != null) {
111118
setEncoding(value);
119+
}
112120

113121
telnetSettingsPage.loadSettings();
114122
}
115123

116124
@Override
117125
public void extractData(Map<String, Object> data) {
118-
if (data == null)
126+
if (data == null) {
119127
return;
128+
}
120129

121130
// set the terminal connector id for ssh
122131
data.put(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID,

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/launcher/TelnetLauncherDelegate.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
8585
private String getTerminalTitle(Map<String, Object> properties) {
8686
// Try to see if the user set a title explicitly via the properties map.
8787
String title = getDefaultTerminalTitle(properties);
88-
if (title != null)
88+
if (title != null) {
8989
return title;
90+
}
9091

9192
//No title,try to calculate the title
9293
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
@@ -114,8 +115,9 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
114115

115116
// Check for the terminal connector id
116117
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
117-
if (connectorId == null)
118+
if (connectorId == null) {
118119
connectorId = "org.eclipse.terminal.connector.telnet.TelnetConnector"; //$NON-NLS-1$
120+
}
119121

120122
// Extract the telnet properties
121123
String host = (String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST);
@@ -128,8 +130,9 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
128130
int portOffset = 0;
129131
if (properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET) instanceof Integer) {
130132
portOffset = ((Integer) properties.get(ITerminalsConnectorConstants.PROP_IP_PORT_OFFSET)).intValue();
131-
if (portOffset < 0)
133+
if (portOffset < 0) {
132134
portOffset = 0;
135+
}
133136
}
134137

135138
// The real port to connect to is port + portOffset

terminal/bundles/org.eclipse.terminal.connector.telnet/src/org/eclipse/terminal/connector/telnet/launcher/TelnetMementoHandler.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ public void saveState(IMemento memento, Map<String, Object> properties) {
3434
(String) properties.get(ITerminalsConnectorConstants.PROP_IP_HOST));
3535
Object value = properties.get(ITerminalsConnectorConstants.PROP_IP_PORT);
3636
memento.putInteger(ITerminalsConnectorConstants.PROP_IP_PORT,
37-
value instanceof Integer ? ((Integer) value).intValue() : -1);
37+
value instanceof Integer i ? i.intValue() : -1);
3838
value = properties.get(ITerminalsConnectorConstants.PROP_TIMEOUT);
3939
memento.putInteger(ITerminalsConnectorConstants.PROP_TIMEOUT,
40-
value instanceof Integer ? ((Integer) value).intValue() : -1);
40+
value instanceof Integer i ? i.intValue() : -1);
4141
memento.putString(ITerminalsConnectorConstants.PROP_ENCODING,
4242
(String) properties.get(ITerminalsConnectorConstants.PROP_ENCODING));
4343
}

0 commit comments

Comments
 (0)