Skip to content

Commit a6d7381

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of terminal/bundles/org.eclipse.terminal.connector.local
1 parent e570744 commit a6d7381

File tree

3 files changed

+32
-18
lines changed

3 files changed

+32
-18
lines changed

terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/controls/LocalWizardConfigurationPanel.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,9 @@ public void setupPanel(Composite parent) {
6666
setEncoding("UTF-8"); //$NON-NLS-1$
6767
} else {
6868
String encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
69-
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
69+
if (encoding != null && !"".equals(encoding)) { //$NON-NLS-1$
7070
setEncoding(encoding);
71+
}
7172
}
7273

7374
// Fill the rest of the panel with a label to be able to
@@ -102,12 +103,14 @@ protected void decorateEncoding(ControlDecoration encodingComboDecorator, String
102103

103104
@Override
104105
public void setupData(Map<String, Object> data) {
105-
if (data == null)
106+
if (data == null) {
106107
return;
108+
}
107109

108110
String value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
109-
if (value != null)
111+
if (value != null) {
110112
setEncoding(value);
113+
}
111114
}
112115

113116
@Override

terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherDelegate.java

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
9595
} else {
9696
encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
9797
}
98-
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
98+
if (encoding != null && !"".equals(encoding)) { //$NON-NLS-1$
9999
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, encoding);
100+
}
100101
}
101102

102103
// For local terminals, force a new terminal tab each time it is launched,
@@ -163,8 +164,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
163164
if ((service != null && service.getSelection() != null)
164165
|| properties.containsKey(ITerminalsConnectorConstants.PROP_SELECTION)) {
165166
ISelection selection = (ISelection) properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
166-
if (selection == null && service != null)
167+
if (selection == null && service != null) {
167168
selection = service.getSelection();
169+
}
168170
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
169171
String dir = null;
170172
Iterator<?> iter = ((IStructuredSelection) selection).iterator();
@@ -176,31 +178,35 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
176178
&& bundle.getState() != Bundle.STOPPING) {
177179
// If the element is not an IResource, try to adapt to IResource
178180
if (!(element instanceof org.eclipse.core.resources.IResource)) {
179-
Object adapted = element instanceof IAdaptable
180-
? ((IAdaptable) element).getAdapter(org.eclipse.core.resources.IResource.class)
181+
Object adapted = element instanceof IAdaptable i
182+
? i.getAdapter(org.eclipse.core.resources.IResource.class)
181183
: null;
182-
if (adapted == null)
184+
if (adapted == null) {
183185
adapted = Platform.getAdapterManager().getAdapter(element,
184186
org.eclipse.core.resources.IResource.class);
185-
if (adapted != null)
187+
}
188+
if (adapted != null) {
186189
element = adapted;
190+
}
187191
}
188192

189193
if (element instanceof org.eclipse.core.resources.IResource
190194
&& ((org.eclipse.core.resources.IResource) element).exists()) {
191195
IPath location = ((org.eclipse.core.resources.IResource) element).getLocation();
192-
if (location == null)
196+
if (location == null) {
193197
continue;
194-
if (location.toFile().isFile())
198+
}
199+
if (location.toFile().isFile()) {
195200
location = location.removeLastSegments(1);
201+
}
196202
if (location.toFile().isDirectory() && location.toFile().canRead()) {
197203
dir = location.toFile().getAbsolutePath();
198204
break;
199205
}
200206
}
201207

202208
if (element instanceof IPath || element instanceof File) {
203-
File f = element instanceof IPath ? ((IPath) element).toFile() : (File) element;
209+
File f = element instanceof IPath i ? i.toFile() : (File) element;
204210
if (f.isDirectory() && f.canRead()) {
205211
dir = f.getAbsolutePath();
206212
break;
@@ -235,8 +241,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
235241
private String getTerminalTitle(Map<String, Object> properties) {
236242
// Try to see if the user set a title explicitly via the properties map.
237243
String title = getDefaultTerminalTitle(properties);
238-
if (title != null)
244+
if (title != null) {
239245
return title;
246+
}
240247

241248
try {
242249
String hostname = InetAddress.getLocalHost().getHostName();
@@ -293,8 +300,9 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
293300

294301
// Check for the terminal connector id
295302
String connectorId = (String) properties.get(ITerminalsConnectorConstants.PROP_TERMINAL_CONNECTOR_ID);
296-
if (connectorId == null)
303+
if (connectorId == null) {
297304
connectorId = "org.eclipse.terminal.connector.local.LocalConnector"; //$NON-NLS-1$
305+
}
298306

299307
// Extract the process properties using defaults
300308
String image;
@@ -357,8 +365,9 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
357365

358366
// Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables
359367
List<String> envpList = new ArrayList<>();
360-
if (envp != null)
368+
if (envp != null) {
361369
envpList.addAll(Arrays.asList(envp));
370+
}
362371

363372
// ECLIPSE_HOME
364373
String eclipseHomeLocation = System.getProperty("eclipse.home.location"); //$NON-NLS-1$
@@ -406,7 +415,7 @@ public ITerminalConnector createTerminalConnector(Map<String, Object> properties
406415
if (properties.containsKey(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT)) {
407416
Object value = properties.get(ITerminalsConnectorConstants.PROP_PROCESS_MERGE_ENVIRONMENT);
408417
processSettings
409-
.setMergeWithNativeEnvironment(value instanceof Boolean ? ((Boolean) value).booleanValue() : false);
418+
.setMergeWithNativeEnvironment(value instanceof Boolean b ? b.booleanValue() : false);
410419
}
411420

412421
// And save the settings to the store

terminal/bundles/org.eclipse.terminal.connector.local/src/org/eclipse/terminal/connector/local/launcher/LocalLauncherHandler.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,12 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
4545
if (input instanceof IPathEditorInput) {
4646
IPath path = ((IPathEditorInput) input).getPath();
4747
if (path != null) {
48-
if (path.toFile().isFile())
48+
if (path.toFile().isFile()) {
4949
path = path.removeLastSegments(1);
50-
if (path.toFile().isDirectory() && path.toFile().canRead())
50+
}
51+
if (path.toFile().isDirectory() && path.toFile().canRead()) {
5152
selection = new StructuredSelection(path);
53+
}
5254
}
5355
}
5456
}

0 commit comments

Comments
 (0)