Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--admin/findbugs-exclude.xml7
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java9
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java41
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/statushandler/DefaultStatusHandler.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/tables/properties/NodePropertiesTableControl.java14
9 files changed, 73 insertions, 54 deletions
diff --git a/admin/findbugs-exclude.xml b/admin/findbugs-exclude.xml
index e26eec892..ef0f856b6 100644
--- a/admin/findbugs-exclude.xml
+++ b/admin/findbugs-exclude.xml
@@ -99,10 +99,13 @@
</And>
</Match>
- <!-- Ignore URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD in AbstractFileTransferSection -->
+ <!-- Ignore URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD -->
<Match>
<Bug pattern="URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD"/>
- <Class name="org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection"/>
+ <Or>
+ <Class name="org.eclipse.tcf.te.launch.ui.tabs.filetransfers.AbstractFileTransferSection"/>
+ <Class name="org.eclipse.tcf.te.ui.tables.properties.NodePropertiesTableTableNode"/>
+ </Or>
</Match>
<!-- Ignore UW_UNCOND_WAIT in InputStreamMonitor -->
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java
index 614b29be7..8964b9f86 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/activator/UIPlugin.java
@@ -11,6 +11,7 @@ package org.eclipse.tcf.te.ui.activator;
import java.io.InputStream;
import java.net.URL;
+import java.util.Arrays;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.SafeRunner;
@@ -37,7 +38,7 @@ public class UIPlugin extends AbstractUIPlugin {
// The trace handler instance
private static volatile TraceHandler traceHandler;
// The pending images used to display the animation.
- Image[] pendingImages;
+ /* default */ Image[] pendingImages;
/**
* The constructor
@@ -139,9 +140,14 @@ public class UIPlugin extends AbstractUIPlugin {
traceHandler = null;
super.stop(context);
}
-
- public Image[] getPendingImages() {
- return pendingImages;
+
+ /**
+ * Returns the image list used to animate the pending state.
+ *
+ * @return A image list or <code>null</code>.
+ */
+ public final Image[] getPendingImages() {
+ return pendingImages != null ? Arrays.copyOf(pendingImages, pendingImages.length) : null;
}
/* (non-Javadoc)
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
index d1fb88108..1952fc104 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/FilteredCheckedListDialog.java
@@ -9,6 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.dialogs;
+import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -51,6 +52,7 @@ import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.te.ui.activator.UIPlugin;
import org.eclipse.tcf.te.ui.internal.utils.TablePatternFilter;
import org.eclipse.tcf.te.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
import org.eclipse.ui.dialogs.SelectionStatusDialog;
import org.eclipse.ui.navigator.IDescriptionProvider;
@@ -112,7 +114,7 @@ public class FilteredCheckedListDialog extends SelectionStatusDialog implements
* @param elements The elements.
*/
public void setElements(Object[] elements) {
- this.elements = elements;
+ this.elements = elements != null ? Arrays.copyOf(elements, elements.length) : null;
}
/*
@@ -123,7 +125,7 @@ public class FilteredCheckedListDialog extends SelectionStatusDialog implements
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection structuredSelection = (IStructuredSelection) event.getSelection();
Object element = structuredSelection.getFirstElement();
- String description = labelProvider instanceof IDescriptionProvider ? ((IDescriptionProvider)labelProvider).getDescription(element) : null;
+ String description = labelProvider != null && labelProvider instanceof IDescriptionProvider ? ((IDescriptionProvider)labelProvider).getDescription(element) : null;
if (description == null) description = element == null ? "" : "Enable "+labelProvider.getText(element)+"."; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
updateStatus(new Status(IStatus.OK, UIPlugin.getUniqueIdentifier(), description));
}
@@ -173,7 +175,7 @@ public class FilteredCheckedListDialog extends SelectionStatusDialog implements
* @param e The focus event.
*/
protected void filterTextFocusGained(FocusEvent e) {
- if (filter.equals(filterText.getText().trim())) {
+ if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
filterText.selectAll();
}
}
@@ -184,7 +186,7 @@ public class FilteredCheckedListDialog extends SelectionStatusDialog implements
* @param e The mouse up event.
*/
protected void filterTextMouseUp(MouseEvent e) {
- if (filter.equals(filterText.getText().trim())) {
+ if (filter != null && filter.equals(SWTControlUtil.getText(filterText).trim())) {
filterText.selectAll();
}
}
@@ -215,7 +217,7 @@ public class FilteredCheckedListDialog extends SelectionStatusDialog implements
else {
// if the initial filter text hasn't changed, do not try to match
boolean hasFocus = tableViewer.getTable().setFocus();
- boolean textChanged = !filter.equals(filterText.getText().trim());
+ boolean textChanged = filter != null && !filter.equals(SWTControlUtil.getText(filterText).trim());
if (hasFocus && textChanged && filterText.getText().trim().length() > 0) {
TableItem[] items = tableViewer.getTable().getItems();
for (TableItem item : items) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java
index 8620c26ed..be9ec4c23 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
* This program and the accompanying materials are made available under the terms
* of the Eclipse Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/epl-v10.html
@@ -9,6 +9,7 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.dialogs;
+import java.util.Arrays;
import java.util.Set;
import org.eclipse.core.runtime.Assert;
@@ -26,8 +27,8 @@ import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Text;
import org.eclipse.tcf.te.ui.interfaces.IContextHelpIds;
-import org.eclipse.tcf.te.ui.nls.Messages;
import org.eclipse.tcf.te.ui.jface.dialogs.CustomTitleAreaDialog;
+import org.eclipse.tcf.te.ui.nls.Messages;
import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
/**
@@ -72,8 +73,8 @@ public class NameValuePairDialog extends CustomTitleAreaDialog {
this.dialogTitle = dialogTitle;
this.title = title;
this.message = message;
- this.fieldLabels = fieldLabels;
- this.initialValues = initialValues;
+ this.fieldLabels = fieldLabels != null ? Arrays.copyOf(fieldLabels, fieldLabels.length) : null;
+ this.initialValues = initialValues != null ? Arrays.copyOf(initialValues, initialValues.length) : null;
this.usedNames = usedNames;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java
index 1c2347db2..aa17c1078 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/AbstractSearcher.java
@@ -10,6 +10,8 @@
package org.eclipse.tcf.te.ui.internal.utils;
import java.lang.reflect.Method;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -32,7 +34,7 @@ import org.eclipse.ui.PlatformUI;
*/
public abstract class AbstractSearcher implements ITreeSearcher {
// The method to access AbstractTreeViewer#getSortedChildren in order to the children visually on the tree.
- static Method methodGetSortedChildren;
+ static volatile Method methodGetSortedChildren;
static {
SafeRunner.run(new ISafeRunnable(){
@Override
@@ -42,22 +44,28 @@ public abstract class AbstractSearcher implements ITreeSearcher {
@Override
public void run() throws Exception {
// Initialize the method object.
- methodGetSortedChildren = AbstractTreeViewer.class.
- getDeclaredMethod("getSortedChildren", new Class[]{Object.class}); //$NON-NLS-1$
+ methodGetSortedChildren = AbstractTreeViewer.class.getDeclaredMethod("getSortedChildren", new Class[]{Object.class}); //$NON-NLS-1$
// Because "getSortedChildren" is a protected method, we need to make it accessible.
- methodGetSortedChildren.setAccessible(true);
- }});
+ AccessController.doPrivileged(new PrivilegedAction<Object>() {
+ @Override
+ public Object run() {
+ methodGetSortedChildren.setAccessible(true);
+ return null;
+ }
+ });
+ }
+ });
}
// The tree viewer to be searched.
protected TreeViewer fViewer;
// The label provider of the tree viewer.
protected ILabelProvider fLabelProvider;
- // The matcher used to match eacho tree nodes.
+ // The matcher used to match echo tree nodes.
protected ISearchMatcher fMatcher;
-
+
/**
* Create a searcher with the specified viewer and matcher.
- *
+ *
* @param viewer The tree viewer to be searched.
* @param matcher The matcher used to match tree nodes.
*/
@@ -66,12 +74,12 @@ public abstract class AbstractSearcher implements ITreeSearcher {
fLabelProvider = (ILabelProvider) fViewer.getLabelProvider();
fMatcher = matcher;
}
-
+
/**
* Get the text representation of a element using the label provider
- * of the tree viewer.
+ * of the tree viewer.
* Note: this method could be called at any thread.
- *
+ *
* @param element The element.
* @return The text representation.
*/
@@ -94,10 +102,10 @@ public abstract class AbstractSearcher implements ITreeSearcher {
}
/**
- * Update the children of the specified parent. If the data of the parent
+ * Update the children of the specified parent. If the data of the parent
* is lazily loaded and not loaded yet, then load the data first, before getting
* the children.
- *
+ *
* @param parent The parent node to get the updated children from.
* @param monitor The progress monitor used while loading data.
* @return The updated children of the parent node.
@@ -124,7 +132,7 @@ public abstract class AbstractSearcher implements ITreeSearcher {
/**
* Get the current visible/sorted children under the specified parent element or path
* by invoking the reflective method. This method is UI thread-safe.
- *
+ *
* @param parentElementOrTreePath The parent element or path.
* @return The current visible/sorted children of the parent path/element.
*/
@@ -132,8 +140,7 @@ public abstract class AbstractSearcher implements ITreeSearcher {
if (Display.getCurrent() != null) {
try {
if (methodGetSortedChildren != null) {
- return (Object[]) methodGetSortedChildren
- .invoke(fViewer, parentElementOrTreePath);
+ return (Object[]) methodGetSortedChildren.invoke(fViewer, parentElementOrTreePath);
}
}
catch (Exception e) {
@@ -153,7 +160,7 @@ public abstract class AbstractSearcher implements ITreeSearcher {
/**
* Get a lazy loader from the specified element if it could be
* adapted to a lazy loader.
- *
+ *
* @param element The element to get the lazy loader from.
* @return A lazy loader or null if it is not adapted to a lazy loader.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java
index f304b5d5a..eb67362ae 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/BreadthFirstSearcher.java
@@ -13,6 +13,7 @@ import java.lang.reflect.InvocationTargetException;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.TreeViewer;
@@ -25,11 +26,11 @@ import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
public class BreadthFirstSearcher extends AbstractSearcher{
// The queue to pre-populate the nodes to be matched
private Queue<TreePath> queue;
-
+
/**
* Create a breadth-first searcher with the specified viewer and a
* matcher.
- *
+ *
* @param viewer The tree viewer.
* @param matcher The search matcher used match a single tree node.
*/
@@ -44,18 +45,19 @@ public class BreadthFirstSearcher extends AbstractSearcher{
@Override
public void setStartPath(TreePath path) {
this.queue = new ConcurrentLinkedQueue<TreePath>();
- this.queue.offer(path);
+ Assert.isTrue(this.queue.offer(path));
}
/**
* Search the tree using a matcher using BFS algorithm.
- *
+ *
* @param monitor The monitor reporting the progress.
* @return The tree path whose leaf node satisfies the searching rule.
*/
@Override
public TreePath searchNext(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException{
TreePath result = null;
+ Assert.isNotNull(queue);
while(!queue.isEmpty() && result == null && !monitor.isCanceled()) {
TreePath path = queue.poll();
Object element = path.getLastSegment();
@@ -63,7 +65,7 @@ public class BreadthFirstSearcher extends AbstractSearcher{
if(children != null && children.length > 0) {
for(Object child : children) {
TreePath childPath = path.createChildPath(child);
- queue.offer(childPath);
+ Assert.isTrue(queue.offer(childPath));
}
}
String elementText = getElementText(element);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java
index c2684faeb..904743d11 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/SearchMatcher.java
@@ -31,7 +31,7 @@ public class SearchMatcher implements ISearchMatcher {
/**
* Create a search matcher with the tree viewer.
- *
+ *
* @param viewer The tree viewer to create a matcher for.
*/
public SearchMatcher(TreeViewer viewer) {
@@ -50,7 +50,7 @@ public class SearchMatcher implements ISearchMatcher {
String target = fSearchTarget;
if (!fCaseSensitive) {
text = text.toLowerCase();
- target = fSearchTarget.toLowerCase();
+ target = fSearchTarget != null ? fSearchTarget.toLowerCase() : null;
}
if (fMatchPrecise) return text.equals(target);
return text.indexOf(target) != -1;
@@ -59,13 +59,13 @@ public class SearchMatcher implements ISearchMatcher {
/**
* Get the text representation of a element using the label provider of the tree viewer. Note:
* this method could be called at any thread.
- *
+ *
* @param element The element.
* @return The text representation.
*/
public String getElementText(final Object element) {
if (Display.getCurrent() != null) {
- if (element == fViewer.getInput()) return null;
+ if (element == fViewer.getInput()) return null;
ILabelProvider labelProvider = (ILabelProvider) fViewer.getLabelProvider();
if (labelProvider != null) {
return labelProvider.getText(element);
@@ -84,7 +84,7 @@ public class SearchMatcher implements ISearchMatcher {
/**
* Set the searching target.
- *
+ *
* @param target The target node's matching string.
*/
public void setMatchTarget(String target) {
@@ -93,7 +93,7 @@ public class SearchMatcher implements ISearchMatcher {
/**
* Set if the searching is case-sensitive.
- *
+ *
* @param caseSensitive
*/
public void setCaseSensitive(boolean caseSensitive) {
@@ -102,7 +102,7 @@ public class SearchMatcher implements ISearchMatcher {
/**
* Set if the searching is to match precisely.
- *
+ *
* @param matchPrecise
*/
public void setMatchPrecise(boolean matchPrecise) {
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/statushandler/DefaultStatusHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/statushandler/DefaultStatusHandler.java
index 9ed85eb0d..1a547eabe 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/statushandler/DefaultStatusHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/statushandler/DefaultStatusHandler.java
@@ -280,10 +280,10 @@ public class DefaultStatusHandler extends AbstractStatusHandler {
switch (severity) {
case IStatusHandlerConstants.QUESTION:
- result = new Boolean(OptionalMessageDialog.openYesNoDialog(shell, title, message, buttonLabel, keyDontAskAgain, helpContextId) == IDialogConstants.YES_ID);
+ result = Boolean.valueOf(OptionalMessageDialog.openYesNoDialog(shell, title, message, buttonLabel, keyDontAskAgain, helpContextId) == IDialogConstants.YES_ID);
break;
case IStatusHandlerConstants.YES_NO_CANCEL:
- result = new Integer(OptionalMessageDialog.openYesNoCancelDialog(shell, title, message, buttonLabel, keyDontAskAgain, helpContextId));
+ result = Integer.valueOf(OptionalMessageDialog.openYesNoCancelDialog(shell, title, message, buttonLabel, keyDontAskAgain, helpContextId));
break;
case IStatus.WARNING:
OptionalMessageDialog.openWarningDialog(shell, title, message, buttonLabel, keyDontAskAgain, helpContextId);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/tables/properties/NodePropertiesTableControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/tables/properties/NodePropertiesTableControl.java
index 1de64c627..ee2cfbf7d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/tables/properties/NodePropertiesTableControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/tables/properties/NodePropertiesTableControl.java
@@ -39,9 +39,9 @@ import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.tcf.te.ui.WorkbenchPartControl;
+import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
import org.eclipse.tcf.te.ui.interfaces.IUIConstants;
import org.eclipse.tcf.te.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.IWorkbenchActionConstants;
import org.eclipse.ui.IWorkbenchPart;
@@ -348,6 +348,9 @@ public abstract class NodePropertiesTableControl extends WorkbenchPartControl {
return;
}
+ // At this point of time, the parent must be of type Section
+ Assert.isTrue(parent instanceof Section);
+
// Create the toolbar control
ToolBar toolbar = new ToolBar(parent, SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT);
@@ -364,13 +367,8 @@ public abstract class NodePropertiesTableControl extends WorkbenchPartControl {
}
});
- // If the parent composite is a forms section, set the toolbar
- // as text client to the section header
- if (parent instanceof Section) {
- Section section = (Section)parent;
- // Set the toolbar as text client
- section.setTextClient(toolbar);
- }
+ // Set the toolbar as text client to the section header
+ ((Section)parent).setTextClient(toolbar);
// create the toolbar items
createToolBarItems(toolbar);

Back to the top