Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-05-02 11:03:36 -0400
committerUwe Stieber2012-05-02 11:03:36 -0400
commit15f5337bd147a5f065dfa380b0686fff32741353 (patch)
treed15d3d54444533223a80d5d9001862dfc0888402
parent7475e3f8d57d29a299be6ddc39f85083cb067b6c (diff)
downloadorg.eclipse.tcf-15f5337bd147a5f065dfa380b0686fff32741353.tar.gz
org.eclipse.tcf-15f5337bd147a5f065dfa380b0686fff32741353.tar.xz
org.eclipse.tcf-15f5337bd147a5f065dfa380b0686fff32741353.zip
Target Explorer: Fix findbugs warnings
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/AbstractConsole.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/internal/preferences/PreferencesPage.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/ClearAction.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/OpenAction.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/CustomTransportPanel.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PeerAttributesTablePart.java10
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java22
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractPartWithButtons.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/listener/AbstractCheckBoxCellPaintListener.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/nls/Messages.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java99
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java16
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBinding.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java47
25 files changed, 179 insertions, 156 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java
index feef64996..a5eb4c809 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/properties/BaseTitledSection.java
@@ -224,7 +224,9 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen
*/
@Override
public void refresh() {
- composite.layout();
+ if (composite != null) {
+ composite.layout();
+ }
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/AbstractConsole.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/AbstractConsole.java
index 975bbac13..64877ce59 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/AbstractConsole.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/AbstractConsole.java
@@ -45,8 +45,8 @@ public class AbstractConsole extends MessageConsole implements IConsoleListener,
* Immutable buffered console line.
*/
protected static final class ConsoleBufferLine {
- protected final String message;
- protected final char messageType;
+ public final String message;
+ public final char messageType;
/**
* Constructor.
@@ -342,7 +342,7 @@ public class AbstractConsole extends MessageConsole implements IConsoleListener,
MessageConsoleStream stream = streams.get(streamType);
stream.setColor(newColor);
// Dispose the old color
- oldColor.dispose();
+ if (oldColor != null) oldColor.dispose();
// and update the stream color map
streamColors.put(streamType, newColor);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/internal/preferences/PreferencesPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/internal/preferences/PreferencesPage.java
index 89b916804..f5049a81a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/internal/preferences/PreferencesPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.console/src/org/eclipse/tcf/te/tcf/ui/console/internal/preferences/PreferencesPage.java
@@ -179,8 +179,12 @@ public class PreferencesPage extends FieldEditorPreferencePage implements IWorkb
public void propertyChange(PropertyChangeEvent event) {
super.propertyChange(event);
// Update the enablement
- consoleWidth.setEnabled(fixedConsoleWidth.getBooleanValue(), getFieldEditorParent());
- consoleBufferSize.setEnabled(limitConsoleOutput.getBooleanValue(), getFieldEditorParent());
+ if (consoleWidth != null && fixedConsoleWidth != null) {
+ consoleWidth.setEnabled(fixedConsoleWidth.getBooleanValue(), getFieldEditorParent());
+ }
+ if (consoleBufferSize != null && limitConsoleOutput != null) {
+ consoleBufferSize.setEnabled(limitConsoleOutput.getBooleanValue(), getFieldEditorParent());
+ }
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
index 2224612ba..87a73385c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/ScriptPad.java
@@ -563,7 +563,7 @@ public class ScriptPad extends ViewPart implements ISelectionProvider, Selection
}
text.setText(buffer.toString());
markDirty(false);
- } catch (Exception e) {
+ } catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
NLS.bind(Messages.ScriptPad_error_openFile, file, e.getLocalizedMessage()), e);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/ClearAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/ClearAction.java
index 11e96edfb..773b0f224 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/ClearAction.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/ClearAction.java
@@ -22,8 +22,6 @@ import org.eclipse.ui.IViewPart;
* Clear script action implementation.
*/
public class ClearAction extends Action implements IViewActionDelegate, IActionDelegate2 {
- // Reference to the action proxy
- /* default */ IAction actionProxy;
// Parent view part
/* default */ IViewPart view;
@@ -47,7 +45,6 @@ public class ClearAction extends Action implements IViewActionDelegate, IActionD
*/
@Override
public void init(IAction action) {
- this.actionProxy = action;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/OpenAction.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/OpenAction.java
index 45bacf2ed..9f9e06ae9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/OpenAction.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui.views/src/org/eclipse/tcf/te/tcf/ui/views/scriptpad/actions/OpenAction.java
@@ -24,8 +24,6 @@ import org.eclipse.ui.IViewPart;
* Open script action implementation.
*/
public class OpenAction extends Action implements IViewActionDelegate, IActionDelegate2 {
- // Reference to the action proxy
- /* default */ IAction actionProxy;
// Parent view part
/* default */ IViewPart view;
@@ -52,7 +50,6 @@ public class OpenAction extends Action implements IViewActionDelegate, IActionDe
*/
@Override
public void init(IAction action) {
- this.actionProxy = action;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/CustomTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/CustomTransportPanel.java
index eb8c40bce..eb6713078 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/CustomTransportPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/CustomTransportPanel.java
@@ -157,8 +157,10 @@ public class CustomTransportPanel extends AbstractWizardConfigurationPanel imple
boolean valid = super.isValid();
if (!valid) return false;
- valid = customTransportNameControl.isValid();
- setMessage(customTransportNameControl.getMessage(), customTransportNameControl.getMessageType());
+ if (customTransportNameControl != null) {
+ valid = customTransportNameControl.isValid();
+ setMessage(customTransportNameControl.getMessage(), customTransportNameControl.getMessageType());
+ }
return valid;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PeerAttributesTablePart.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PeerAttributesTablePart.java
index e593c63d3..5209ed872 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PeerAttributesTablePart.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PeerAttributesTablePart.java
@@ -59,7 +59,7 @@ public class PeerAttributesTablePart extends TablePart implements IDisposable {
/* default */ final List<TableNode> nodes = new ArrayList<TableNode>();
// A list of names which are banned from using
- private String[] bannedNames;
+ private List<String> bannedNames;
// A flag to mark the table part "read-only"
/* default */ boolean readOnly;
@@ -266,8 +266,8 @@ public class PeerAttributesTablePart extends TablePart implements IDisposable {
ISelection selection = getTableViewer().getSelection();
if (selection instanceof IStructuredSelection && !selection.isEmpty()) {
Object element = ((IStructuredSelection)selection).getFirstElement();
- if (element instanceof TableNode) {
- banned = Arrays.asList(bannedNames).contains(((TableNode)element).name);
+ if (element instanceof TableNode && bannedNames != null) {
+ banned = bannedNames.contains(((TableNode)element).name);
}
}
}
@@ -433,7 +433,7 @@ public class PeerAttributesTablePart extends TablePart implements IDisposable {
* @param bannedNames The list of banned names or <code>null</code>.
*/
public final void setBannedNames(String[] bannedNames) {
- this.bannedNames = bannedNames;
+ this.bannedNames = bannedNames != null ? Arrays.asList(bannedNames) : null;
}
/**
@@ -442,7 +442,7 @@ public class PeerAttributesTablePart extends TablePart implements IDisposable {
* @return The list of banned names or <code>null</code>.
*/
public final String[] getBannedNames() {
- return bannedNames;
+ return bannedNames != null ? bannedNames.toArray(new String[bannedNames.size()]) : null;
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java
index 2d87cfc07..708e08a4e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/PipeTransportPanel.java
@@ -156,8 +156,10 @@ public class PipeTransportPanel extends AbstractWizardConfigurationPanel impleme
boolean valid = super.isValid();
if (!valid) return false;
- valid = pipeNameControl.isValid();
- setMessage(pipeNameControl.getMessage(), pipeNameControl.getMessageType());
+ if (pipeNameControl != null) {
+ valid = pipeNameControl.isValid();
+ setMessage(pipeNameControl.getMessage(), pipeNameControl.getMessageType());
+ }
return valid;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
index 64848587a..6014e3940 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/controls/TransportTypeControl.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.tcf.ui.controls;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.runtime.Assert;
@@ -26,12 +27,12 @@ import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
*/
public class TransportTypeControl extends BaseEditBrowseTextControl {
- public final static String[] TRANSPORT_TYPES = new String[] {
- ITransportTypes.TRANSPORT_TYPE_TCP,
- ITransportTypes.TRANSPORT_TYPE_SSL,
- ITransportTypes.TRANSPORT_TYPE_PIPE,
- ITransportTypes.TRANSPORT_TYPE_CUSTOM
- };
+ private final static List<String> TRANSPORT_TYPES = Arrays.asList(new String[] {
+ ITransportTypes.TRANSPORT_TYPE_TCP,
+ ITransportTypes.TRANSPORT_TYPE_SSL,
+ ITransportTypes.TRANSPORT_TYPE_PIPE,
+ ITransportTypes.TRANSPORT_TYPE_CUSTOM
+ });
/**
* Constructor.
@@ -48,6 +49,15 @@ public class TransportTypeControl extends BaseEditBrowseTextControl {
setAdjustBackgroundColor(parentPage != null);
}
+ /**
+ * Returns the list of transport types supported by this control.
+ *
+ * @return The list of supported transport types.
+ */
+ public String[] getTransportTypes() {
+ return TRANSPORT_TYPES.toArray(new String[TRANSPORT_TYPES.size()]);
+ }
+
/* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl#setupPanel(org.eclipse.swt.widgets.Composite)
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
index c35b9a353..4e6afb6a9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/ServicesSection.java
@@ -155,7 +155,7 @@ public class ServicesSection extends AbstractSection {
Protocol.invokeAndWait(new Runnable() {
@Override
public void run() {
- Map<String, Object> properties = node.getProperties();
+ Map<String, Object> properties = od.getProperties();
odc.setProperties(properties);
}
});
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
index 924ecb0fe..32213bc2b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/editor/sections/TransportSection.java
@@ -41,7 +41,6 @@ import org.eclipse.tcf.te.tcf.locator.nodes.PeerRedirector;
import org.eclipse.tcf.te.tcf.ui.controls.CustomTransportPanel;
import org.eclipse.tcf.te.tcf.ui.controls.PipeTransportPanel;
import org.eclipse.tcf.te.tcf.ui.controls.TcpTransportPanel;
-import org.eclipse.tcf.te.tcf.ui.controls.TransportTypeControl;
import org.eclipse.tcf.te.tcf.ui.editor.controls.TransportSectionTypeControl;
import org.eclipse.tcf.te.tcf.ui.editor.controls.TransportSectionTypePanelControl;
import org.eclipse.tcf.te.tcf.ui.nls.Messages;
@@ -142,7 +141,7 @@ public class TransportSection extends AbstractSection {
transportTypePanelControl.addConfigurationPanel(ITransportTypes.TRANSPORT_TYPE_CUSTOM, new CustomTransportPanel(transportTypePanelControl));
// Setup the panel control
- transportTypePanelControl.setupPanel(client, TransportTypeControl.TRANSPORT_TYPES, toolkit);
+ transportTypePanelControl.setupPanel(client, transportTypeControl.getTransportTypes(), toolkit);
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.horizontalSpan = 2;
transportTypePanelControl.getPanel().setLayoutData(layoutData);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java
index 3a0c3b174..60905f93f 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSection.java
@@ -90,7 +90,9 @@ public class PeerGeneralSection extends AbstractPropertySection {
*/
@Override
public void refresh() {
- tableControl.getViewer().setInput(peer);
+ if (tableControl != null) {
+ tableControl.getViewer().setInput(peer);
+ }
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java
index 463668f6a..e729af7ee 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/internal/tabbed/PeerGeneralSectionContentProvider.java
@@ -123,7 +123,11 @@ public class PeerGeneralSectionContentProvider implements IStructuredContentProv
if (sectionTitle == null || "".equals(sectionTitle.trim())) sectionTitle = org.eclipse.tcf.te.ui.nls.Messages.NodePropertiesTableControl_section_title_noSelection; //$NON-NLS-1$
// Stretch to a length of 40 characters to make sure the title can be changed
// to hold and show text up to this length
- while (sectionTitle.length() < 40) sectionTitle += " "; //$NON-NLS-1$
+ if (sectionTitle.length() < 40) {
+ StringBuilder buffer = new StringBuilder(sectionTitle);
+ while (buffer.length() < 40) buffer.append(" "); //$NON-NLS-1$
+ sectionTitle = buffer.toString();
+ }
// Find the parent section the node properties tables is embedded in
Control control = viewer.getControl();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
index cf1037dc6..da6ac060b 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/nls/Messages.java
@@ -30,24 +30,6 @@ public class Messages extends NLS {
}
/**
- * Returns if or if not this NLS manager contains a constant for
- * the given externalized strings key.
- *
- * @param key The externalized strings key or <code>null</code>.
- * @return <code>True</code> if a constant for the given key exists, <code>false</code> otherwise.
- */
- public static boolean hasString(String key) {
- if (key != null) {
- try {
- Field field = Messages.class.getDeclaredField(key);
- return field != null;
- } catch (NoSuchFieldException e) { /* ignored on purpose */ }
- }
-
- return false;
- }
-
- /**
* Returns the corresponding string for the given externalized strings
* key or <code>null</code> if the key does not exist.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
index 1939d137d..d336271e9 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/tabbed/BaseTitledSection.java
@@ -216,7 +216,9 @@ public abstract class BaseTitledSection extends AbstractPropertySection implemen
*/
@Override
public void refresh() {
- composite.layout();
+ if (composite != null) {
+ composite.layout();
+ }
}
/*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractPartWithButtons.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractPartWithButtons.java
index 527bfde91..979a690cf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractPartWithButtons.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractPartWithButtons.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.ui.forms.parts;
import java.util.Arrays;
+import java.util.List;
import org.eclipse.core.runtime.Assert;
import org.eclipse.jface.dialogs.IDialogConstants;
@@ -30,7 +31,7 @@ import org.eclipse.ui.forms.widgets.FormToolkit;
*/
public abstract class AbstractPartWithButtons extends AbstractPart {
// The button labels
- private final String[] labels;
+ private final List<String> labels;
// The buttons list
private Button[] buttons = null;
@@ -41,7 +42,8 @@ public abstract class AbstractPartWithButtons extends AbstractPart {
*/
public AbstractPartWithButtons(String[] labels) {
super();
- this.labels = labels;
+ Assert.isNotNull(labels);
+ this.labels = Arrays.asList(labels);
}
/* (non-Javadoc)
@@ -51,7 +53,7 @@ public abstract class AbstractPartWithButtons extends AbstractPart {
public void createControl(Composite parent, int style, int span, FormToolkit toolkit) {
Assert.isNotNull(parent);
createMainLabel(parent, span, toolkit);
- createMainControl(parent, style, span - ((labels != null && labels.length > 0) ? 1 : 0), toolkit);
+ createMainControl(parent, style, span - ((labels != null && labels.size() > 0) ? 1 : 0), toolkit);
createButtonsPanel(parent, toolkit);
}
@@ -85,11 +87,11 @@ public abstract class AbstractPartWithButtons extends AbstractPart {
* @return The buttons panel composite or <code>null</code>.
*/
protected Composite createButtonsPanel(Composite parent, FormToolkit toolkit) {
- if (labels == null || labels.length == 0) {
+ if (labels == null || labels.size() == 0) {
return null;
}
- buttons = new Button[labels.length];
+ buttons = new Button[labels.size()];
Composite panel = createComposite(parent, toolkit);
GridLayout layout = new GridLayout();
@@ -106,13 +108,13 @@ public abstract class AbstractPartWithButtons extends AbstractPart {
}
};
- for (int i = 0; i < labels.length; i++) {
- if (labels[i] != null) {
+ for (int i = 0; i < labels.size(); i++) {
+ if (labels.get(i) != null) {
Button button = toolkit != null ? toolkit.createButton(panel, null, SWT.PUSH) : new Button(panel, SWT.PUSH);
Assert.isNotNull(button);
button.setFont(JFaceResources.getDialogFont());
- button.setText(labels[i]);
+ button.setText(labels.get(i));
button.setData(Integer.valueOf(i));
button.setBackground(panel.getBackground());
button.addSelectionListener(listener);
@@ -178,7 +180,7 @@ public abstract class AbstractPartWithButtons extends AbstractPart {
if (labels == null) {
throw new ArrayIndexOutOfBoundsException();
}
- return getButton(Arrays.asList(labels).indexOf(label));
+ return getButton(labels.indexOf(label));
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
index 24263c38d..f8fd35063 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.forms/src/org/eclipse/tcf/te/ui/forms/parts/AbstractSection.java
@@ -10,6 +10,8 @@
package org.eclipse.tcf.te.ui.forms.parts;
import java.lang.reflect.Field;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IAdaptable;
@@ -188,8 +190,14 @@ public abstract class AbstractSection extends SectionPart implements IAdaptable,
// Plus, refresh() might be overwritten to refresh the widget content
// from the data itself, what will trigger an stack overflow after all.
try {
- Field f = AbstractFormPart.class.getDeclaredField("dirty"); //$NON-NLS-1$
- f.setAccessible(true);
+ final Field f = AbstractFormPart.class.getDeclaredField("dirty"); //$NON-NLS-1$
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ f.setAccessible(true);
+ return null;
+ }
+ });
f.setBoolean(this, dirty);
getManagedForm().dirtyStateChanged();
} catch (Exception e) { /* ignored on purpose */ }
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/listener/AbstractCheckBoxCellPaintListener.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/listener/AbstractCheckBoxCellPaintListener.java
index 4dec98884..3dfafddd1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/listener/AbstractCheckBoxCellPaintListener.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/listener/AbstractCheckBoxCellPaintListener.java
@@ -71,7 +71,7 @@ public abstract class AbstractCheckBoxCellPaintListener extends AbstractCellPain
// Check which image to paint
int state = getCheckBoxState(item.getData(), columnIndex);
if (state >= 0) {
- return SWTControlUtil.getCheckBoxImage((state & CHECKED) > 0, (state & TRISTATE) > 0, (state & ENABLED) > 0);
+ return SWTControlUtil.getCheckBoxImage((state & CHECKED) != 0, (state & TRISTATE) != 0, (state & ENABLED) != 0);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/nls/Messages.java
index a5b418f7e..6f9d3fad0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.swt/src/org/eclipse/tcf/te/ui/swt/nls/Messages.java
@@ -30,24 +30,6 @@ public class Messages extends NLS {
}
/**
- * Returns if or if not this NLS manager contains a constant for
- * the given externalized strings key.
- *
- * @param key The externalized strings key or <code>null</code>.
- * @return <code>True</code> if a constant for the given key exists, <code>false</code> otherwise.
- */
- public static boolean hasString(String key) {
- if (key != null) {
- try {
- Field field = Messages.class.getDeclaredField(key);
- return field != null;
- } catch (NoSuchFieldException e) { /* ignored on purpose */ }
- }
-
- return false;
- }
-
- /**
* Returns the corresponding string for the given externalized strings
* key or <code>null</code> if the key does not exist.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
index 49cb7fc80..f00ca80ee 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.process/src/org/eclipse/tcf/te/ui/terminals/process/ProcessConnector.java
@@ -35,14 +35,14 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.osgi.service.environment.Constants;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
import org.eclipse.tcf.te.ui.terminals.process.activator.UIPlugin;
import org.eclipse.tcf.te.ui.terminals.process.nls.Messages;
+import org.eclipse.tcf.te.ui.terminals.streams.AbstractStreamsConnector;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsPage;
import org.eclipse.tm.internal.terminal.provisional.api.ISettingsStore;
import org.eclipse.tm.internal.terminal.provisional.api.ITerminalControl;
import org.eclipse.tm.internal.terminal.provisional.api.TerminalState;
-import org.eclipse.tcf.te.runtime.services.interfaces.constants.ILineSeparatorConstants;
-import org.eclipse.tcf.te.ui.terminals.streams.AbstractStreamsConnector;
/**
* Process connector implementation.
@@ -179,7 +179,7 @@ public class ProcessConnector extends AbstractStreamsConnector {
// Create the process monitor
monitor = new ProcessMonitor(this);
monitor.startMonitoring();
- } catch (Exception e) {
+ } catch (IOException e) {
IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
NLS.bind(Messages.ProcessConnector_error_creatingProcess, e.getLocalizedMessage()), e);
UIPlugin.getDefault().getLog().log(status);
@@ -364,9 +364,13 @@ public class ProcessConnector extends AbstractStreamsConnector {
// read piped data on Win 95, 98, and ME
Properties p = new Properties();
File file = new File(fileName);
- InputStream stream = new BufferedInputStream(new FileInputStream(file));
- p.load(stream);
- stream.close();
+ InputStream stream = null;
+ try {
+ stream = new BufferedInputStream(new FileInputStream(file));
+ p.load(stream);
+ } finally {
+ if (stream != null) stream.close();
+ }
if (!file.delete()) {
file.deleteOnExit(); // if delete() fails try again on VM close
}
@@ -384,53 +388,58 @@ public class ProcessConnector extends AbstractStreamsConnector {
InputStream stream = process.getInputStream();
InputStreamReader isreader = new InputStreamReader(stream);
BufferedReader reader = new BufferedReader(isreader);
- String line = reader.readLine();
- String key = null;
- String value = null;
- while (line != null) {
- int func = line.indexOf("=()"); //$NON-NLS-1$
- if (func > 0) {
- key = line.substring(0, func);
- // scan until we find the closing '}' with no following chars
- value = line.substring(func + 1);
- while (line != null && !line.equals("}")) { //$NON-NLS-1$
- line = reader.readLine();
- if (line != null) {
- value += line;
+ try {
+ String line = reader.readLine();
+ String key = null;
+ String value = null;
+ while (line != null) {
+ int func = line.indexOf("=()"); //$NON-NLS-1$
+ if (func > 0) {
+ key = line.substring(0, func);
+ // scan until we find the closing '}' with no following chars
+ value = line.substring(func + 1);
+ while (line != null && !line.equals("}")) { //$NON-NLS-1$
+ line = reader.readLine();
+ if (line != null) {
+ value += line;
+ }
}
- }
- line = reader.readLine();
- } else {
- int separator = line.indexOf('=');
- if (separator > 0) {
- key = line.substring(0, separator);
- value = line.substring(separator + 1);
line = reader.readLine();
- if (line != null) {
- // this line has a '=' read ahead to check next line for '=', might be broken on more
- // than one line
- separator = line.indexOf('=');
- while (separator < 0) {
- value += line.trim();
- line = reader.readLine();
- if (line == null) {
- // if next line read is the end of the file quit the loop
- break;
- }
+ } else {
+ int separator = line.indexOf('=');
+ if (separator > 0) {
+ key = line.substring(0, separator);
+ value = line.substring(separator + 1);
+ StringBuilder bufValue = new StringBuilder(value);
+ line = reader.readLine();
+ if (line != null) {
+ // this line has a '=' read ahead to check next line for '=', might be broken on more
+ // than one line
separator = line.indexOf('=');
+ while (separator < 0) {
+ bufValue.append(line.trim());
+ line = reader.readLine();
+ if (line == null) {
+ // if next line read is the end of the file quit the loop
+ break;
+ }
+ separator = line.indexOf('=');
+ }
}
+ value = bufValue.toString();
}
}
+ if (key != null) {
+ cache.put(key, value);
+ key = null;
+ value = null;
+ } else {
+ line = reader.readLine();
+ }
}
- if (key != null) {
- cache.put(key, value);
- key = null;
- value = null;
- } else {
- line = reader.readLine();
- }
+ } finally {
+ reader.close();
}
- reader.close();
}
} catch (IOException e) {
// Native environment-fetching code failed.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
index 114cf41c0..cbe69a23e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.ssh/src/org/eclipse/tcf/te/ui/terminals/ssh/controls/SshWizardConfigurationPanel.java
@@ -62,7 +62,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
panel.setLayoutData(data);
if(isWithoutSelection()){
- createHostsUI(panel);
+ createHostsUI(panel);
}
SshConnector conn = new SshConnector();
@@ -71,7 +71,7 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
sshSettings.setUser(getDefaultUser());
sshSettingsPage = conn.makeSettingsPage();
sshSettingsPage.createControl(panel);
-
+
setControl(panel);
}
@@ -171,9 +171,9 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
if(hostSettingsMap.containsKey(host)){
Map<String, String> hostSettings=hostSettingsMap.get(host);
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
- hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(sshSettings.getPort()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(sshSettings.getTimeout()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, new Integer(sshSettings.getKeepalive()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
if(sshSettings.getPassword()!=null && sshSettings.getPassword().length()!=0){
@@ -182,9 +182,9 @@ public class SshWizardConfigurationPanel extends AbstractConfigurationPanel impl
} else if(add){
Map<String, String> hostSettings=new HashMap<String, String>();
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, sshSettings.getHost());
- hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(sshSettings.getPort()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(sshSettings.getTimeout()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, new Integer(sshSettings.getKeepalive()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(sshSettings.getPort()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(sshSettings.getTimeout()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_KEEP_ALIVE, Integer.toString(sshSettings.getKeepalive()));
hostSettings.put(ITerminalsConnectorConstants.PROP_SSH_USER, sshSettings.getUser());
hostSettingsMap.put(host, hostSettings);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
index 702828289..bba7c3b2a 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.terminals.telnet/src/org/eclipse/tcf/te/ui/terminals/telnet/controls/TelnetWizardConfigurationPanel.java
@@ -59,7 +59,7 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
panel.setLayoutData(data);
if(isWithoutSelection()){
- createHostsUI(panel);
+ createHostsUI(panel);
}
TelnetConnector conn = new TelnetConnector();
@@ -69,7 +69,7 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
telnetSettings.setHost(getSelectionHost());
// MWE otherwise we don't get a valid default selection of the combo
telnetSettings.setNetworkPort(NetworkPortMap.PROP_VALUETELNET);
-
+
setControl(panel);
}
@@ -142,13 +142,13 @@ public class TelnetWizardConfigurationPanel extends AbstractConfigurationPanel i
if(hostSettingsMap.containsKey(host)){
Map<String, String> hostSettings=hostSettingsMap.get(host);
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
- hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(telnetSettings.getNetworkPort()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(telnetSettings.getTimeout()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(telnetSettings.getNetworkPort()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(telnetSettings.getTimeout()));
} else if(add){
Map<String, String> hostSettings=new HashMap<String, String>();
hostSettings.put(ITerminalsConnectorConstants.PROP_IP_HOST, telnetSettings.getHost());
- hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, new Integer(telnetSettings.getNetworkPort()).toString());
- hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, new Integer(telnetSettings.getTimeout()).toString());
+ hostSettings.put(ITerminalsConnectorConstants.PROP_IP_PORT, Integer.toString(telnetSettings.getNetworkPort()));
+ hostSettings.put(ITerminalsConnectorConstants.PROP_TIMEOUT, Integer.toString(telnetSettings.getTimeout()));
hostSettingsMap.put(host, hostSettings);
}
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBinding.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBinding.java
index 11b51c6ea..2418632ec 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBinding.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/extensions/EditorPageBinding.java
@@ -38,7 +38,7 @@ public class EditorPageBinding extends ExecutableExtension {
// Initialize the page id field by reading the <pageId> extension attribute.
// Throws an exception if the id is empty or null.
pageId = config != null ? config.getAttribute("pageId") : null; //$NON-NLS-1$
- if (pageId == null || (pageId != null && "".equals(pageId.trim()))) { //$NON-NLS-1$
+ if (pageId == null || "".equals(pageId.trim())) { //$NON-NLS-1$
throw createMissingMandatoryAttributeException("pageId", config.getContributor().getName()); //$NON-NLS-1$
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
index 4f9b883f6..93f60cbc4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/internal/categories/CategoryManager.java
@@ -57,8 +57,11 @@ public class CategoryManager implements ICategoryManager {
private IPath getRoot() {
try {
File file = UIPlugin.getDefault().getStateLocation().toFile();
- if (!file.exists()) file.mkdirs();
- if (file.canRead() && file.isDirectory()) {
+ boolean exists = file.exists();
+ if (!exists) {
+ exists = file.mkdirs();
+ }
+ if (exists && file.canRead() && file.isDirectory()) {
return new Path(file.toString());
}
} catch (IllegalStateException e) {
@@ -87,9 +90,13 @@ public class CategoryManager implements ICategoryManager {
File file = root.append("cat2id.json").toFile(); //$NON-NLS-1$
try {
cat2id.clear();
- Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- cat2id.putAll(gson.fromJson(reader, Map.class));
- reader.close();
+ Reader reader = null;
+ try {
+ reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
+ cat2id.putAll(gson.fromJson(reader, Map.class));
+ } finally {
+ if (reader != null) reader.close();
+ }
} catch (IOException e) {
/* ignored on purpose */
}
@@ -98,9 +105,13 @@ public class CategoryManager implements ICategoryManager {
file = root.append("id2cat.json").toFile(); //$NON-NLS-1$
try {
id2cat.clear();
- Reader reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
- id2cat.putAll(gson.fromJson(reader, Map.class));
- reader.close();
+ Reader reader = null;
+ try {
+ reader = new InputStreamReader(new FileInputStream(file), "UTF-8"); //$NON-NLS-1$
+ id2cat.putAll(gson.fromJson(reader, Map.class));
+ } finally {
+ if (reader != null) reader.close();
+ }
} catch (IOException e) {
/* ignored on purpose */
}
@@ -120,9 +131,13 @@ public class CategoryManager implements ICategoryManager {
// The first file to write is the category to id list map
File file = root.append("cat2id.json").toFile(); //$NON-NLS-1$
try {
- Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- gson.toJson(cat2id, Map.class, writer);
- writer.close();
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
+ gson.toJson(cat2id, Map.class, writer);
+ } finally {
+ if (writer != null) writer.close();
+ }
} catch (IOException e) {
/* ignored on purpose */
}
@@ -130,9 +145,13 @@ public class CategoryManager implements ICategoryManager {
// The second file to write is the id to category list map
file = root.append("id2cat.json").toFile(); //$NON-NLS-1$
try {
- Writer writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
- gson.toJson(id2cat, Map.class, writer);
- writer.close();
+ Writer writer = null;
+ try {
+ writer = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); //$NON-NLS-1$
+ gson.toJson(id2cat, Map.class, writer);
+ } finally {
+ if (writer != null) writer.close();
+ }
} catch (IOException e) {
/* ignored on purpose */
}

Back to the top