Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ public void setupPanel(Composite parent) {
setEncoding("UTF-8"); //$NON-NLS-1$
} else {
String encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
if (encoding != null && !"".equals(encoding)) { //$NON-NLS-1$
setEncoding(encoding);
}
}

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

@Override
public void setupData(Map<String, Object> data) {
if (data == null)
if (data == null) {
return;
}

String value = (String) data.get(ITerminalsConnectorConstants.PROP_ENCODING);
if (value != null)
if (value != null) {
setEncoding(value);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
} else {
encoding = WorkbenchEncoding.getWorkbenchDefaultEncoding();
}
if (encoding != null && !"".equals(encoding)) //$NON-NLS-1$
if (encoding != null && !"".equals(encoding)) { //$NON-NLS-1$
properties.put(ITerminalsConnectorConstants.PROP_ENCODING, encoding);
}
}

// For local terminals, force a new terminal tab each time it is launched,
Expand Down Expand Up @@ -163,8 +164,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
if ((service != null && service.getSelection() != null)
|| properties.containsKey(ITerminalsConnectorConstants.PROP_SELECTION)) {
ISelection selection = (ISelection) properties.get(ITerminalsConnectorConstants.PROP_SELECTION);
if (selection == null && service != null)
if (selection == null && service != null) {
selection = service.getSelection();
}
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
String dir = null;
Iterator<?> iter = ((IStructuredSelection) selection).iterator();
Expand All @@ -176,31 +178,35 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
&& bundle.getState() != Bundle.STOPPING) {
// If the element is not an IResource, try to adapt to IResource
if (!(element instanceof org.eclipse.core.resources.IResource)) {
Object adapted = element instanceof IAdaptable
? ((IAdaptable) element).getAdapter(org.eclipse.core.resources.IResource.class)
Object adapted = element instanceof IAdaptable i
? i.getAdapter(org.eclipse.core.resources.IResource.class)
: null;
if (adapted == null)
if (adapted == null) {
adapted = Platform.getAdapterManager().getAdapter(element,
org.eclipse.core.resources.IResource.class);
if (adapted != null)
}
if (adapted != null) {
element = adapted;
}
}

if (element instanceof org.eclipse.core.resources.IResource
&& ((org.eclipse.core.resources.IResource) element).exists()) {
IPath location = ((org.eclipse.core.resources.IResource) element).getLocation();
if (location == null)
if (location == null) {
continue;
if (location.toFile().isFile())
}
if (location.toFile().isFile()) {
location = location.removeLastSegments(1);
}
if (location.toFile().isDirectory() && location.toFile().canRead()) {
dir = location.toFile().getAbsolutePath();
break;
}
}

if (element instanceof IPath || element instanceof File) {
File f = element instanceof IPath ? ((IPath) element).toFile() : (File) element;
File f = element instanceof IPath i ? i.toFile() : (File) element;
if (f.isDirectory() && f.canRead()) {
dir = f.getAbsolutePath();
break;
Expand Down Expand Up @@ -235,8 +241,9 @@ public void execute(Map<String, Object> properties, ITerminalService.Done done)
private String getTerminalTitle(Map<String, Object> properties) {
// Try to see if the user set a title explicitly via the properties map.
String title = getDefaultTerminalTitle(properties);
if (title != null)
if (title != null) {
return title;
}

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

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

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

// Set the ECLIPSE_HOME and ECLIPSE_WORKSPACE environment variables
List<String> envpList = new ArrayList<>();
if (envp != null)
if (envp != null) {
envpList.addAll(Arrays.asList(envp));
}

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

// And save the settings to the store
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
if (input instanceof IPathEditorInput) {
IPath path = ((IPathEditorInput) input).getPath();
if (path != null) {
if (path.toFile().isFile())
if (path.toFile().isFile()) {
path = path.removeLastSegments(1);
if (path.toFile().isDirectory() && path.toFile().canRead())
}
if (path.toFile().isDirectory() && path.toFile().canRead()) {
selection = new StructuredSelection(path);
}
}
}
}
Expand Down
Loading