Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2013-06-03 02:47:39 -0400
committerUwe Stieber2013-06-03 02:47:39 -0400
commit470ac849399b5a1d41a198a2ad4b2bdeb292e199 (patch)
tree539f66500de95eea726e7256d58ffb51e960f120
parentee3ebecac70cc9ffbabdd64a4fe9777c9619bafc (diff)
downloadorg.eclipse.tcf-470ac849399b5a1d41a198a2ad4b2bdeb292e199.tar.gz
org.eclipse.tcf-470ac849399b5a1d41a198a2ad4b2bdeb292e199.tar.xz
org.eclipse.tcf-470ac849399b5a1d41a198a2ad4b2bdeb292e199.zip
Target Explorer: Make the Process Monitor UI adaptable to connection type specifics
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java160
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF3
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorMessageProviderDelegate.java37
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java23
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java422
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessSearchable.java79
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java18
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java28
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/GeneralSearchable.java)410
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/NameValidator.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/NameValidator.java)84
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessBaseSearchable.java)159
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessNodeGeneralMatcher.java)2
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java147
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessStateSearchable.java)15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java (renamed from target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessUserSearchable.java)12
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java1374
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseDialogSelectionControl.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseEditBrowseTextControl.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/HexValidator.java17
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java11
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java20
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/dialogs/NameValuePairDialog.java4
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java240
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java255
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java434
32 files changed, 2185 insertions, 1898 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
index f3eefe9d7..eb451aebf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/search/FSTreeNodeSearchable.java
@@ -1,80 +1,80 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
-
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
-import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
-
-/**
- * The ISearchable adapter for a FSTreeNode which creates a UI for the user to
- * input the matching condition and returns a matcher to do the matching.
- */
-public class FSTreeNodeSearchable extends CompositeSearchable {
-
- /**
- * Create an instance with the specified node.
- *
- * @param node The directory node.
- */
- public FSTreeNodeSearchable(FSTreeNode node) {
- super(new FSGeneralSearchable(node), new FSModifiedSearchable(), new FSSizeSearchable());
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle()
- */
- @Override
- public String getSearchTitle() {
- return Messages.FSTreeNodeSearchable_FindFilesAndFolders;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
- */
- @Override
- public String getSearchMessage(Object rootElement) {
- String message = Messages.FSTreeNodeSearchable_FindMessage;
- FSTreeNode rootNode = (FSTreeNode) rootElement;
- String rootName = getElementName(rootElement);
- if (rootNode != null && !rootNode.isSystemRoot()) rootName = "\"" + rootName + "\""; //$NON-NLS-1$//$NON-NLS-2$
- message = NLS.bind(message, rootName);
- return message;
- }
-
- /**
- * Get a name representation for each file node.
- *
- * @param rootElement The root element whose name is being retrieved.
- * @return The node's name or an expression for the file system.
- */
- private String getElementName(Object rootElement) {
- if(rootElement == null) {
- return Messages.FSTreeNodeSearchable_SelectedFileSystem;
- }
- FSTreeNode rootNode = (FSTreeNode) rootElement;
- if(rootNode.isSystemRoot()) {
- return Messages.FSTreeNodeSearchable_SelectedFileSystem;
- }
- return rootNode.name;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
- */
- @Override
- public String getElementText(Object element) {
- return getElementName(element);
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.search;
+
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
+
+/**
+ * The ISearchable adapter for a FSTreeNode which creates a UI for the user to
+ * input the matching condition and returns a matcher to do the matching.
+ */
+public class FSTreeNodeSearchable extends CompositeSearchable {
+
+ /**
+ * Create an instance with the specified node.
+ *
+ * @param node The directory node.
+ */
+ public FSTreeNodeSearchable(FSTreeNode node) {
+ super();
+ setSearchables(new FSGeneralSearchable(node), new FSModifiedSearchable(), new FSSizeSearchable());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle(java.lang.Object)
+ */
+ @Override
+ public String getSearchTitle(Object rootElement) {
+ return Messages.FSTreeNodeSearchable_FindFilesAndFolders;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
+ */
+ @Override
+ public String getSearchMessage(Object rootElement) {
+ String message = Messages.FSTreeNodeSearchable_FindMessage;
+ FSTreeNode rootNode = (FSTreeNode) rootElement;
+ String rootName = getElementName(rootElement);
+ if (rootNode != null && !rootNode.isSystemRoot()) rootName = "\"" + rootName + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ message = NLS.bind(message, rootName);
+ return message;
+ }
+
+ /**
+ * Get a name representation for each file node.
+ *
+ * @param rootElement The root element whose name is being retrieved.
+ * @return The node's name or an expression for the file system.
+ */
+ private String getElementName(Object rootElement) {
+ if(rootElement == null) {
+ return Messages.FSTreeNodeSearchable_SelectedFileSystem;
+ }
+ FSTreeNode rootNode = (FSTreeNode) rootElement;
+ if(rootNode.isSystemRoot()) {
+ return Messages.FSTreeNodeSearchable_SelectedFileSystem;
+ }
+ return rootNode.name;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
+ */
+ @Override
+ public String getElementText(Object element) {
+ return getElementName(element);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
index 50dcb0588..6292ab343 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/META-INF/MANIFEST.MF
@@ -36,14 +36,15 @@ Export-Package: org.eclipse.tcf.te.tcf.processes.ui.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.filters,
org.eclipse.tcf.te.tcf.processes.ui.handler,
org.eclipse.tcf.te.tcf.processes.ui.help,
+ org.eclipse.tcf.te.tcf.processes.ui.interfaces,
org.eclipse.tcf.te.tcf.processes.ui.internal;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.adapters;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.preferences;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.properties;x-internal:=true,
- org.eclipse.tcf.te.tcf.processes.ui.internal.search;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.internal.tabbed;x-internal:=true,
org.eclipse.tcf.te.tcf.processes.ui.navigator.events,
org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime,
org.eclipse.tcf.te.tcf.processes.ui.nls;x-internal:=true,
+ org.eclipse.tcf.te.tcf.processes.ui.search,
org.eclipse.tcf.te.tcf.processes.ui.services
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
index a0aece3e5..ab238ebfe 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.properties
@@ -28,7 +28,7 @@ column.name.state = State
column.name.user = User
column.name.cmdline = Command Line
-navigatorContent.name = Processes
+navigatorContent.name = System Monitor
command.refreshviewer.label = Refresh Process List
command.refreshviewer.tooltip = Refresh Process List
@@ -50,9 +50,7 @@ command.attach.tooltip=Attach to the selected Context
command.detach.label=D&etach
command.detach.tooltip=Detach from the selected Context
-page.process.name = Process Monitor
-
-singlethreadfilter.description = For single thread processes the thread child is hidden.
+page.process.namesinglethreadfilter.description = For single thread processes the thread child is hidden.
singlethreadfilter.name = Single Thread Filter
commonFilter.singlethread.name = Single Thread Filter
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java
index d19ca7535..d004a8e57 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/editor/ProcessMonitorEditorPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 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
@@ -24,6 +24,7 @@ import org.eclipse.tcf.te.tcf.processes.ui.navigator.events.TreeViewerListener;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.ui.trees.TreeControl;
import org.eclipse.tcf.te.ui.views.editor.pages.TreeViewerExplorerEditorPage;
+import org.eclipse.ui.IEditorInput;
/**
* The editor page for Process Monitor.
@@ -61,7 +62,16 @@ public class ProcessMonitorEditorPage extends TreeViewerExplorerEditorPage {
*/
@Override
protected String getFormTitle() {
- return Messages.ProcessMonitorEditorPage_PageTitle;
+ String formTitle = Messages.getStringDelegated(getEditorInputNode(), "ProcessMonitorEditorPage_PageTitle"); //$NON-NLS-1$
+ return formTitle != null ? formTitle : Messages.ProcessMonitorEditorPage_PageTitle;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.views.editor.pages.AbstractEditorPage#setInput(org.eclipse.ui.IEditorInput)
+ */
+ @Override
+ protected void setInput(IEditorInput input) {
+ super.setInput(input);
}
/* (non-Javadoc)
@@ -73,6 +83,15 @@ public class ProcessMonitorEditorPage extends TreeViewerExplorerEditorPage {
}
/* (non-Javadoc)
+ * @see org.eclipse.ui.part.WorkbenchPart#getPartName()
+ */
+ @Override
+ public String getPartName() {
+ String partName = Messages.getStringDelegated(getEditorInputNode(), "ProcessMonitorEditorPage_PartName"); //$NON-NLS-1$
+ return partName != null ? partName : super.getPartName();
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.views.editor.pages.TreeViewerExplorerEditorPage#getTitleBarDecorator()
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java
index a4edd3cda..36b0285ee 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/ConfigRefreshIntervalHandler.java
@@ -36,7 +36,7 @@ public class ConfigRefreshIntervalHandler extends AbstractHandler {
IPeerModel peer = (IPeerModel) editorInput.getAdapter(IPeerModel.class);
if (peer != null) {
Shell parent = HandlerUtil.getActiveShellChecked(event);
- IntervalConfigDialog dialog = new IntervalConfigDialog(parent);
+ IntervalConfigDialog dialog = new IntervalConfigDialog(peer, parent);
IRuntimeModel model = ModelManager.getRuntimeModel(peer);
int interval = model.getAutoRefreshInterval();
dialog.setResult(interval);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
index 69a767a62..cda8238ad 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/RefreshProcessListHandler.java
@@ -9,22 +9,32 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.handler;
+import java.util.Map;
+
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Assert;
import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel;
import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelRefreshService;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.processes.core.model.ModelManager;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorMessageProviderDelegate;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.UIElement;
/**
* The handler to refresh the process list.
*/
-public class RefreshProcessListHandler extends AbstractHandler {
+public class RefreshProcessListHandler extends AbstractHandler implements IElementUpdater {
/* (non-Javadoc)
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
@@ -46,4 +56,30 @@ public class RefreshProcessListHandler extends AbstractHandler {
}
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map)
+ */
+ @Override
+ public void updateElement(UIElement element, Map parameters) {
+ IWorkbenchPartSite site = (IWorkbenchPartSite)parameters.get("org.eclipse.ui.part.IWorkbenchPartSite"); //$NON-NLS-1$
+ if (site != null) {
+ IWorkbenchPart part = site.getPart();
+ if (part instanceof IEditorPart) {
+ IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
+ IPeerModel node = editorInput != null ? (IPeerModel) editorInput.getAdapter(IPeerModel.class) : null;
+
+ IUIService service = ServiceManager.getInstance().getService(node, IUIService.class);
+ IProcessMonitorMessageProviderDelegate delegate = service != null ? service.getDelegate(node, IProcessMonitorMessageProviderDelegate.class) : null;
+
+ if (delegate != null) {
+ String text = delegate.getMessage("RefreshProcessListHandler_updateElement_text"); //$NON-NLS-1$
+ if (text != null) element.setText(text);
+
+ String tooltip = delegate.getMessage("RefreshProcessListHandler_updateElement_tooltip"); //$NON-NLS-1$
+ if (tooltip != null) element.setTooltip(tooltip);
+ }
+ }
+ }
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java
index c1d27cca1..b2be1aac7 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/TerminateHandler.java
@@ -10,6 +10,7 @@
package org.eclipse.tcf.te.tcf.processes.ui.handler;
import java.util.Iterator;
+import java.util.Map;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
@@ -21,19 +22,29 @@ import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.osgi.util.NLS;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.callback.Callback;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
import org.eclipse.tcf.te.runtime.statushandler.StatusHandlerUtil;
import org.eclipse.tcf.te.tcf.core.model.interfaces.IModel;
import org.eclipse.tcf.te.tcf.core.model.interfaces.services.IModelUpdateService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.steps.TerminateStep;
import org.eclipse.tcf.te.tcf.processes.ui.help.IContextHelpIds;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorMessageProviderDelegate;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.eclipse.ui.commands.IElementUpdater;
import org.eclipse.ui.handlers.HandlerUtil;
+import org.eclipse.ui.menus.UIElement;
/**
* The handler to terminate the selected process.
*/
-public class TerminateHandler extends AbstractHandler {
+public class TerminateHandler extends AbstractHandler implements IElementUpdater {
/* (non-Javadoc)
* @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
@@ -76,4 +87,29 @@ public class TerminateHandler extends AbstractHandler {
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.commands.IElementUpdater#updateElement(org.eclipse.ui.menus.UIElement, java.util.Map)
+ */
+ @Override
+ public void updateElement(UIElement element, Map parameters) {
+ IWorkbenchPartSite site = (IWorkbenchPartSite)parameters.get("org.eclipse.ui.part.IWorkbenchPartSite"); //$NON-NLS-1$
+ if (site != null) {
+ IWorkbenchPart part = site.getPart();
+ if (part instanceof IEditorPart) {
+ IEditorInput editorInput = ((IEditorPart)part).getEditorInput();
+ IPeerModel node = editorInput != null ? (IPeerModel) editorInput.getAdapter(IPeerModel.class) : null;
+
+ IUIService service = ServiceManager.getInstance().getService(node, IUIService.class);
+ IProcessMonitorMessageProviderDelegate delegate = service != null ? service.getDelegate(node, IProcessMonitorMessageProviderDelegate.class) : null;
+
+ if (delegate != null) {
+ String text = delegate.getMessage("TerminateHandler_updateElement_text"); //$NON-NLS-1$
+ if (text != null) element.setText(text);
+
+ String tooltip = delegate.getMessage("TerminateHandler_updateElement_tooltip"); //$NON-NLS-1$
+ if (tooltip != null) element.setTooltip(tooltip);
+ }
+ }
+ }
+ }
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorMessageProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorMessageProviderDelegate.java
new file mode 100644
index 000000000..803e41644
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/interfaces/IProcessMonitorMessageProviderDelegate.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.interfaces;
+
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+
+
+/**
+ * Process monitor message provider delegate.
+ */
+public interface IProcessMonitorMessageProviderDelegate {
+
+ /**
+ * Returns the message for the given key.
+ *
+ * @param key The message key. Must not be <code>null</code>.
+ * @return The message or <code>null</code>.
+ */
+ public String getMessage(String key);
+
+ /**
+ * Returns the list of searchables to use to find processes in the
+ * process monitor.
+ *
+ * @param node The peer model node context. Must not be <code>null</code>.
+ * @return The list of searchables to use or <code>null</code>.
+ */
+ public ISearchable[] getSearchables(IPeerModel node);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java
index 6fcad1f17..e26b1cc9c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/adapters/AdapterFactory.java
@@ -9,13 +9,16 @@
*******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.internal.adapters;
+import java.util.concurrent.atomic.AtomicReference;
+
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
-import org.eclipse.tcf.te.tcf.processes.ui.internal.search.ProcessSearchable;
import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.search.ProcessSearchable;
import org.eclipse.tcf.te.ui.interfaces.ISearchable;
/**
@@ -35,7 +38,7 @@ public class AdapterFactory implements IAdapterFactory {
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
*/
@Override
- public Object getAdapter(Object adaptableObject, Class adapterType) {
+ public Object getAdapter(final Object adaptableObject, final Class adapterType) {
if (adaptableObject instanceof IProcessContextNode) {
if (ILabelProvider.class.equals(adapterType)) {
return labelProvider;
@@ -44,13 +47,25 @@ public class AdapterFactory implements IAdapterFactory {
return ((IProcessContextNode) adaptableObject).getAdapter(adapterType);
}
if (ISearchable.class.equals(adapterType)) {
- return new ProcessSearchable();
+ return new ProcessSearchable((IPeerModel)((IProcessContextNode)adaptableObject).getAdapter(IPeerModel.class));
}
}
if (adaptableObject instanceof IRuntimeModel) {
if (ISearchable.class.equals(adapterType)) {
- return new ProcessSearchable();
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ node.set(((IRuntimeModel)adaptableObject).getPeerModel());
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ return new ProcessSearchable(node.get());
}
}
return null;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java
index 398324080..bfa30f2d4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/dialogs/IntervalConfigDialog.java
@@ -1,207 +1,215 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.dialogs.StatusDialog;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin;
-import org.eclipse.tcf.te.tcf.processes.ui.internal.preferences.IPreferenceConsts;
-import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
-
-/**
- * The dialog to configure the refreshing interval of the process list.
- */
-public class IntervalConfigDialog extends StatusDialog implements ModifyListener, IPreferenceConsts {
- // The text field to enter the interval value.
- private Text text;
- // The entered result
- private int result;
-
- /**
- * Constructor
- */
- public IntervalConfigDialog(Shell parent) {
- super(parent);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.StatusDialog#configureShell(org.eclipse.swt.widgets.Shell)
- */
- @Override
- protected void configureShell(Shell shell) {
- shell.setText(Messages.IntervalConfigDialog_DialogTitle);
- super.configureShell(shell);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- @Override
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
-
- Composite comp1 = new Composite(composite, SWT.NONE);
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
- comp1.setLayoutData(data);
- GridLayout layout = new GridLayout(3, false);
- layout.horizontalSpacing = 0;
- comp1.setLayout(layout);
-
- Label label = new Label(comp1, SWT.RADIO);
- label.setText(Messages.IntervalConfigDialog_ChoiceOneLabel);
-
- text = new Text(comp1, SWT.SINGLE | SWT.BORDER);
- text.setTextLimit(Text.LIMIT);
- data = new GridData();
- data.widthHint = 70;
- text.setLayoutData(data);
- text.setText(""+result); //$NON-NLS-1$
- text.selectAll();
- text.setFocus();
- text.addModifyListener(this);
-
- label = new Label(comp1, SWT.NONE);
- label.setText(Messages.IntervalConfigDialog_SECONDS);
-
- return composite;
- }
-
- /**
- * Check if the current input is valid and return an IStatus object to return
- * the checking result, containing the message and the validating code.
- *
- * @return A status to indicate if the input is valid.
- */
- private IStatus isInputValid() {
- String pluginId = UIPlugin.getUniqueIdentifier();
- String txt = SWTControlUtil.getText(text);
- if (txt == null || txt.trim().length() == 0) {
- return new Status(IStatus.ERROR, pluginId, null);
- }
- try {
- int interval = Integer.parseInt(txt.trim());
- if (interval < 0) return new Status(IStatus.ERROR, pluginId, Messages.IntervalConfigDialog_BiggerThanZero);
- if(interval == 0) return new Status(IStatus.WARNING, pluginId, Messages.IntervalConfigDialog_ZeroWarning);
- }
- catch (NumberFormatException e) {
- return new Status(IStatus.ERROR, pluginId, Messages.IntervalConfigDialog_InvalidNumber);
- }
- return Status.OK_STATUS;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- @Override
- protected void okPressed() {
- String txt = SWTControlUtil.getText(text).trim();
- result = Integer.parseInt(txt);
- super.okPressed();
- }
-
- /**
- * Get the input result, a time interval.
- *
- * @return The input result.
- */
- public int getResult() {
- return result;
- }
-
- /**
- * Validate the current input and update the button and the error message.
- */
- private void validateInput() {
- IStatus status = isInputValid();
- updateStatus(status);
- }
-
- /**
- * The label provider used to display the speed grades in the combo viewer.
- */
- static class GradeLabelProvider extends LabelProvider {
- @Override
- public String getText(Object element) {
- if(element instanceof IntervalGrade) {
- IntervalGrade grade = (IntervalGrade) element;
- return grade.getName() + " ("+grade.getValue()+" "+Messages.IntervalConfigDialog_SECOND_ABBR+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- return super.getText(element);
- }
- }
-
- /**
- * Get the current the speed grades in an array of Grade.
- *
- * @return The current speed grades.
- */
- IntervalGrade[] getGrades(){
- List<IntervalGrade> gradeList = new ArrayList<IntervalGrade>();
- IPreferenceStore prefStore = UIPlugin.getDefault().getPreferenceStore();
- String grades = prefStore.getString(PREF_INTERVAL_GRADES);
- Assert.isNotNull(grades);
- StringTokenizer st = new StringTokenizer(grades, "|"); //$NON-NLS-1$
- while(st.hasMoreTokens()) {
- String token = st.nextToken();
- StringTokenizer st2 = new StringTokenizer(token, ":"); //$NON-NLS-1$
- String name = st2.nextToken();
- String value = st2.nextToken();
- try{
- int seconds = Integer.parseInt(value);
- if(seconds > 0) {
- gradeList.add(new IntervalGrade(name, seconds));
- }
- }
- catch (NumberFormatException nfe) {
- }
- }
- return gradeList.toArray(new IntervalGrade[gradeList.size()]);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
- */
- @Override
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
-
- /**
- * Set the current interval to the text field.
- *
- * @param interval The current interval.
- */
- public void setResult(int interval) {
- this.result = interval;
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.internal.dialogs;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.StatusDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin;
+import org.eclipse.tcf.te.tcf.processes.ui.internal.preferences.IPreferenceConsts;
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.swt.SWTControlUtil;
+
+/**
+ * The dialog to configure the refreshing interval of the process list.
+ */
+public class IntervalConfigDialog extends StatusDialog implements ModifyListener, IPreferenceConsts {
+ // The text field to enter the interval value.
+ private Text text;
+ // The entered result
+ private int result;
+ // The parent element
+ private final IPeerModel node;
+
+ /**
+ * Constructor
+ *
+ * @param node The parent peer model node. Must not be <code>null</code>.
+ * @param parent The parent shell or <code>null</code>.
+ */
+ public IntervalConfigDialog(IPeerModel node, Shell parent) {
+ super(parent);
+ Assert.isNotNull(node);
+ this.node = node;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.StatusDialog#configureShell(org.eclipse.swt.widgets.Shell)
+ */
+ @Override
+ protected void configureShell(Shell shell) {
+ shell.setText(Messages.IntervalConfigDialog_DialogTitle);
+ super.configureShell(shell);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ protected Control createDialogArea(Composite parent) {
+ Composite composite = (Composite) super.createDialogArea(parent);
+
+ Composite comp1 = new Composite(composite, SWT.NONE);
+ GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false);
+ comp1.setLayoutData(data);
+ comp1.setLayout(new GridLayout(3, false));
+
+ String labelTxt = Messages.getStringDelegated(node, "IntervalConfigDialog_ChoiceOneLabel"); //$NON-NLS-1$
+
+ Label label = new Label(comp1, SWT.RADIO);
+ label.setText(labelTxt != null ? labelTxt : Messages.IntervalConfigDialog_ChoiceOneLabel);
+
+ text = new Text(comp1, SWT.SINGLE | SWT.BORDER);
+ text.setTextLimit(Text.LIMIT);
+ data = new GridData();
+ data.widthHint = 70;
+ text.setLayoutData(data);
+ text.setText(""+result); //$NON-NLS-1$
+ text.selectAll();
+ text.setFocus();
+ text.addModifyListener(this);
+
+ label = new Label(comp1, SWT.NONE);
+ label.setText(Messages.IntervalConfigDialog_SECONDS);
+
+ return composite;
+ }
+
+ /**
+ * Check if the current input is valid and return an IStatus object to return
+ * the checking result, containing the message and the validating code.
+ *
+ * @return A status to indicate if the input is valid.
+ */
+ private IStatus isInputValid() {
+ String pluginId = UIPlugin.getUniqueIdentifier();
+ String txt = SWTControlUtil.getText(text);
+ if (txt == null || txt.trim().length() == 0) {
+ return new Status(IStatus.ERROR, pluginId, null);
+ }
+ try {
+ int interval = Integer.parseInt(txt.trim());
+ if (interval < 0) return new Status(IStatus.ERROR, pluginId, Messages.IntervalConfigDialog_BiggerThanZero);
+ if(interval == 0) return new Status(IStatus.WARNING, pluginId, Messages.IntervalConfigDialog_ZeroWarning);
+ }
+ catch (NumberFormatException e) {
+ return new Status(IStatus.ERROR, pluginId, Messages.IntervalConfigDialog_InvalidNumber);
+ }
+ return Status.OK_STATUS;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.dialogs.Dialog#okPressed()
+ */
+ @Override
+ protected void okPressed() {
+ String txt = SWTControlUtil.getText(text).trim();
+ result = Integer.parseInt(txt);
+ super.okPressed();
+ }
+
+ /**
+ * Get the input result, a time interval.
+ *
+ * @return The input result.
+ */
+ public int getResult() {
+ return result;
+ }
+
+ /**
+ * Validate the current input and update the button and the error message.
+ */
+ private void validateInput() {
+ IStatus status = isInputValid();
+ updateStatus(status);
+ }
+
+ /**
+ * The label provider used to display the speed grades in the combo viewer.
+ */
+ static class GradeLabelProvider extends LabelProvider {
+ @Override
+ public String getText(Object element) {
+ if(element instanceof IntervalGrade) {
+ IntervalGrade grade = (IntervalGrade) element;
+ return grade.getName() + " ("+grade.getValue()+" "+Messages.IntervalConfigDialog_SECOND_ABBR+")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ return super.getText(element);
+ }
+ }
+
+ /**
+ * Get the current the speed grades in an array of Grade.
+ *
+ * @return The current speed grades.
+ */
+ IntervalGrade[] getGrades(){
+ List<IntervalGrade> gradeList = new ArrayList<IntervalGrade>();
+ IPreferenceStore prefStore = UIPlugin.getDefault().getPreferenceStore();
+ String grades = prefStore.getString(PREF_INTERVAL_GRADES);
+ Assert.isNotNull(grades);
+ StringTokenizer st = new StringTokenizer(grades, "|"); //$NON-NLS-1$
+ while(st.hasMoreTokens()) {
+ String token = st.nextToken();
+ StringTokenizer st2 = new StringTokenizer(token, ":"); //$NON-NLS-1$
+ String name = st2.nextToken();
+ String value = st2.nextToken();
+ try{
+ int seconds = Integer.parseInt(value);
+ if(seconds > 0) {
+ gradeList.add(new IntervalGrade(name, seconds));
+ }
+ }
+ catch (NumberFormatException nfe) {
+ }
+ }
+ return gradeList.toArray(new IntervalGrade[gradeList.size()]);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
+ */
+ @Override
+ public void modifyText(ModifyEvent e) {
+ validateInput();
+ }
+
+ /**
+ * Set the current interval to the text field.
+ *
+ * @param interval The current interval.
+ */
+ public void setResult(int interval) {
+ this.result = interval;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessSearchable.java
deleted file mode 100644
index 1e536af0e..000000000
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessSearchable.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
-
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
-import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.LabelProviderDelegate;
-import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
-
-/**
- * The ISearchable adapter for a ProcessTreeNode which creates a UI for the user to
- * input the matching condition and returns a matcher to do the matching.
- */
-public class ProcessSearchable extends CompositeSearchable {
- // The label provider used to get a text for a process.
- ILabelProvider labelProvider = new LabelProviderDelegate();
-
- /**
- * Constructor
- */
- public ProcessSearchable() {
- super(new GeneralSearchable(), new ProcessUserSearchable(), new ProcessStateSearchable());
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle()
- */
- @Override
- public String getSearchTitle() {
- return Messages.ProcessSearchable_SearchTitle;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
- */
- @Override
- public String getSearchMessage(Object rootElement) {
- if (rootElement == null || rootElement instanceof IRuntimeModel) {
- return Messages.ProcessSearchable_PromptFindInProcessList;
- }
- String message = Messages.ProcessSearchable_PromptFindUnderProcess;
- String rootName = "\"" + getElementName(rootElement) + "\""; //$NON-NLS-1$//$NON-NLS-2$
- message = NLS.bind(message, rootName);
- return message;
- }
-
- /**
- * Get a name representation for each process node.
- *
- * @param rootElement The root element whose name is being retrieved.
- * @return The node's name.
- */
- private String getElementName(Object rootElement) {
- if(rootElement == null || rootElement instanceof IRuntimeModel) {
- return Messages.ProcessSearchable_ProcessList;
- }
- return labelProvider.getText(rootElement);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
- */
- @Override
- public String getElementText(Object element) {
- return getElementName(element);
- }
-}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
index 2ca86ced4..3380b5209 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/navigator/runtime/LabelProviderDelegate.java
@@ -18,6 +18,7 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.tcf.protocol.Protocol;
import org.eclipse.tcf.te.runtime.model.interfaces.IModelNode;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
import org.eclipse.tcf.te.tcf.processes.ui.activator.UIPlugin;
@@ -34,9 +35,22 @@ public class LabelProviderDelegate extends LabelProvider implements ILabelDecora
* @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
*/
@Override
- public String getText(Object element) {
+ public String getText(final Object element) {
if (element instanceof IRuntimeModel) {
- return Messages.ProcessLabelProvider_RootNodeLabel;
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ node.set(((IRuntimeModel)element).getPeerModel());
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ String label = Messages.getStringDelegated(node.get(), "ProcessLabelProvider_RootNodeLabel"); //$NON-NLS-1$
+ return label != null ? label : Messages.ProcessLabelProvider_RootNodeLabel;
} else if (element instanceof IProcessContextNode) {
final IProcessContextNode node = (IProcessContextNode)element;
final AtomicReference<String> name = new AtomicReference<String>();
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
index 7215f5889..0bffb5577 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2011, 2012 Wind River Systems, Inc. and others. All rights reserved.
+ * Copyright (c) 2011, 2013 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
@@ -10,6 +10,9 @@
package org.eclipse.tcf.te.tcf.processes.ui.nls;
import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorMessageProviderDelegate;
/**
* Target Explorer TCF processes extensions UI plug-in externalized strings management.
@@ -28,6 +31,26 @@ public class Messages extends NLS {
NLS.initializeMessages(BUNDLE_NAME, Messages.class);
}
+
+ /**
+ * Returns the corresponding string for the given externalized strings key via
+ * the {@link IProcessMonitorMessageProviderDelegate}.
+ *
+ * @param context The context or <code>null</code>.
+ * @param key The externalized strings key or <code>null</code>.
+ *
+ * @return The corresponding string or <code>null</code>.
+ */
+ public static String getStringDelegated(Object context, String key) {
+ if (key != null) {
+ IUIService service = ServiceManager.getInstance().getService(context, IUIService.class);
+ IProcessMonitorMessageProviderDelegate delegate = service != null ? service.getDelegate(context, IProcessMonitorMessageProviderDelegate.class) : null;
+ return delegate != null ? delegate.getMessage(key) : null;
+ }
+
+ return null;
+ }
+
// **** Declare externalized string id's down here *****
public static String PossibleCause;
@@ -118,14 +141,11 @@ public class Messages extends NLS {
public static String IntervalConfigDialog_BiggerThanZero;
public static String IntervalConfigDialog_ChoiceOneLabel;
- public static String IntervalConfigDialog_ChoiceTwoLabel;
public static String IntervalConfigDialog_DialogTitle;
public static String IntervalConfigDialog_InvalidNumber;
public static String IntervalConfigDialog_NonEmpty;
public static String IntervalConfigDialog_SECOND_ABBR;
public static String IntervalConfigDialog_SECONDS;
- public static String IntervalConfigDialog_SelectSpeed;
- public static String IntervalConfigDialog_SPEED;
public static String IntervalConfigDialog_ZeroWarning;
public static String MemorySection_PSize;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
index e1c85cd04..fd929166c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/nls/Messages.properties
@@ -95,14 +95,11 @@ IDSection_Title=Process IDs
IntervalConfigDialog_BiggerThanZero=The number must be greater than or equal to zero\!
IntervalConfigDialog_ChoiceOneLabel=Refresh the process list every
-IntervalConfigDialog_ChoiceTwoLabel=Refresh the process list at a
IntervalConfigDialog_DialogTitle=Configure Refreshing
IntervalConfigDialog_InvalidNumber=Invalid number format\!
IntervalConfigDialog_NonEmpty=Please enter a number\!
IntervalConfigDialog_SECOND_ABBR=s
-IntervalConfigDialog_SECONDS=\ seconds.
-IntervalConfigDialog_SelectSpeed=Please select a speed.
-IntervalConfigDialog_SPEED=\ speed.
+IntervalConfigDialog_SECONDS=seconds.
IntervalConfigDialog_ZeroWarning=Setting to zero will turn off the auto refresh.
MemorySection_PSize=Pages:
@@ -154,6 +151,7 @@ ProcessStateSearchable_StateSleeping=Sleeping
ProcessStateSearchable_StateTraced=Traced
ProcessStateSearchable_StateWaiting=Waiting
ProcessStateSearchable_StateZombie=Zombie
+
ProcessUserSearchable_DontRemember=Don't remember
ProcessUserSearchable_Myself=I myself
ProcessUserSearchable_SpecifyUser=Specify a user:
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/GeneralSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java
index 9ce00e60d..f2e86f850 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/GeneralSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/GeneralSearchable.java
@@ -1,205 +1,205 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
-import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
-import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
-
-/**
- * The searchable that provides a UI to collect and test
- * the general operations of a process search.
- */
-public class GeneralSearchable extends AbstractSearchable {
- // The keys to access the options stored in the dialog settings.
- private static final String TARGET_NAME = "PM.TargetName"; //$NON-NLS-1$
- private static final String MATCH_PRECISE = "PM.MatchPrecise"; //$NON-NLS-1$
- private static final String CASE_SENSITIVE = "PM.CaseSensitive"; //$NON-NLS-1$
- // The case sensitive check box.
- private Button fBtnCase;
- // The matching rule check box.
- private Button fBtnMatch;
- // The input field for searching conditions.
- private BaseEditBrowseTextControl fSearchField;
- // The current target names.
- private String fTargetName;
- // Whether it is case sensitive
- private boolean fCaseSensitive;
- // Whether it is precise matching.
- private boolean fMatchPrecise;
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createCommonPart(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- GridLayout glayout = new GridLayout(3, false);
- glayout.marginHeight = 0;
- glayout.marginWidth = 0;
- composite.setLayout(glayout);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Searching field.
- Label label = new Label(composite, SWT.NONE);
- label.setText(Messages.GeneralSearchable_FindLabel);
-
- fSearchField = new BaseEditBrowseTextControl(null);
- fSearchField.setIsGroup(false);
- fSearchField.setHasHistory(false);
- fSearchField.setHideBrowseButton(true);
- fSearchField.setParentControlIsInnerPanel(true);
- fSearchField.setupPanel(composite);
- fSearchField.setEditFieldValidator(new NameValidator());
- //fSearchField.setEditFieldValidator(new FolderValidator(this));
- Text text = (Text) fSearchField.getEditFieldControl();
- text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
- text.addModifyListener(new ModifyListener() {
- @Override
- public void modifyText(ModifyEvent e) {
- searchTextModified();
- }
- });
-
- SelectionListener l = new SelectionAdapter() {
- @Override
- public void widgetSelected(SelectionEvent e) {
- optionChecked(e);
- }
- };
-
- Group group = new Group(parent, SWT.NONE);
- group.setText(Messages.GeneralSearchable_GeneralOptions);
- group.setLayout(new GridLayout(2, true));
- group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Case sensitive
- fBtnCase = new Button(group, SWT.CHECK);
- fBtnCase.setText(Messages.GeneralSearchable_CaseSensitive);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnCase.setLayoutData(data);
- fBtnCase.addSelectionListener(l);
-
- // Matching precisely
- fBtnMatch = new Button(group, SWT.CHECK);
- fBtnMatch.setText(Messages.GeneralSearchable_PreciseMatching);
- data = new GridData(GridData.FILL_HORIZONTAL);
- fBtnMatch.setLayoutData(data);
- fBtnMatch.addSelectionListener(l);
- }
-
- /**
- * The text for searching is modified.
- */
- protected void searchTextModified() {
- fireOptionChanged();
- fTargetName = fSearchField.getEditFieldControlText().trim();
- }
-
- /**
- * Handling the event that a button is selected and checked.
- *
- * @param e The selection event.
- */
- protected void optionChecked(SelectionEvent e) {
- Object src = e.getSource();
- if (src == fBtnCase) {
- fCaseSensitive = fBtnCase.getSelection();
- }
- else if (src == fBtnMatch) {
- fMatchPrecise = fBtnMatch.getSelection();
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- return fSearchField.isValid();
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void restoreValues(IDialogSettings settings) {
- if(settings != null) {
- fCaseSensitive = settings.getBoolean(CASE_SENSITIVE);
- fBtnCase.setSelection(fCaseSensitive);
- fMatchPrecise = settings.getBoolean(MATCH_PRECISE);
- fBtnMatch.setSelection(fMatchPrecise);
- fTargetName = settings.get(TARGET_NAME);
- if (fTargetName != null) {
- fSearchField.setEditFieldControlText(fTargetName);
- }
- }
- else {
- fCaseSensitive = false;
- fMatchPrecise = false;
- fTargetName = null;
- }
- fBtnCase.setSelection(fCaseSensitive);
- fBtnMatch.setSelection(fMatchPrecise);
- if (fTargetName != null) {
- fSearchField.setEditFieldControlText(fTargetName);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void persistValues(IDialogSettings settings) {
- if(settings != null) {
- settings.put(CASE_SENSITIVE, fCaseSensitive);
- settings.put(MATCH_PRECISE, fMatchPrecise);
- settings.put(TARGET_NAME, fTargetName);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
- */
- @Override
- public ISearchMatcher getMatcher() {
- return new ProcessNodeGeneralMatcher(fCaseSensitive, fMatchPrecise, fTargetName);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#getPreferredSize()
- */
- @Override
- public Point getPreferredSize() {
- return new Point(360, 130);
- }
-}
-
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.search;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.BaseEditBrowseTextControl;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
+
+/**
+ * The searchable that provides a UI to collect and test
+ * the general operations of a process search.
+ */
+public class GeneralSearchable extends AbstractSearchable {
+ // The keys to access the options stored in the dialog settings.
+ private static final String TARGET_NAME = "PM.TargetName"; //$NON-NLS-1$
+ private static final String MATCH_PRECISE = "PM.MatchPrecise"; //$NON-NLS-1$
+ private static final String CASE_SENSITIVE = "PM.CaseSensitive"; //$NON-NLS-1$
+ // The case sensitive check box.
+ private Button fBtnCase;
+ // The matching rule check box.
+ private Button fBtnMatch;
+ // The input field for searching conditions.
+ private BaseEditBrowseTextControl fSearchField;
+ // The current target names.
+ private String fTargetName;
+ // Whether it is case sensitive
+ private boolean fCaseSensitive;
+ // Whether it is precise matching.
+ private boolean fMatchPrecise;
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createCommonPart(Composite parent) {
+ Composite composite = new Composite(parent, SWT.NONE);
+ GridLayout glayout = new GridLayout(3, false);
+ glayout.marginHeight = 0;
+ glayout.marginWidth = 0;
+ composite.setLayout(glayout);
+ composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Searching field.
+ Label label = new Label(composite, SWT.NONE);
+ label.setText(Messages.GeneralSearchable_FindLabel);
+
+ fSearchField = new BaseEditBrowseTextControl(null);
+ fSearchField.setIsGroup(false);
+ fSearchField.setHasHistory(false);
+ fSearchField.setHideBrowseButton(true);
+ fSearchField.setParentControlIsInnerPanel(true);
+ fSearchField.setupPanel(composite);
+ fSearchField.setEditFieldValidator(new NameValidator());
+ //fSearchField.setEditFieldValidator(new FolderValidator(this));
+ Text text = (Text) fSearchField.getEditFieldControl();
+ text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
+ text.addModifyListener(new ModifyListener() {
+ @Override
+ public void modifyText(ModifyEvent e) {
+ searchTextModified();
+ }
+ });
+
+ SelectionListener l = new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ optionChecked(e);
+ }
+ };
+
+ Group group = new Group(parent, SWT.NONE);
+ group.setText(Messages.GeneralSearchable_GeneralOptions);
+ group.setLayout(new GridLayout(2, true));
+ group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+
+ // Case sensitive
+ fBtnCase = new Button(group, SWT.CHECK);
+ fBtnCase.setText(Messages.GeneralSearchable_CaseSensitive);
+ GridData data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnCase.setLayoutData(data);
+ fBtnCase.addSelectionListener(l);
+
+ // Matching precisely
+ fBtnMatch = new Button(group, SWT.CHECK);
+ fBtnMatch.setText(Messages.GeneralSearchable_PreciseMatching);
+ data = new GridData(GridData.FILL_HORIZONTAL);
+ fBtnMatch.setLayoutData(data);
+ fBtnMatch.addSelectionListener(l);
+ }
+
+ /**
+ * The text for searching is modified.
+ */
+ protected void searchTextModified() {
+ fireOptionChanged();
+ fTargetName = fSearchField.getEditFieldControlText().trim();
+ }
+
+ /**
+ * Handling the event that a button is selected and checked.
+ *
+ * @param e The selection event.
+ */
+ protected void optionChecked(SelectionEvent e) {
+ Object src = e.getSource();
+ if (src == fBtnCase) {
+ fCaseSensitive = fBtnCase.getSelection();
+ }
+ else if (src == fBtnMatch) {
+ fMatchPrecise = fBtnMatch.getSelection();
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ return fSearchField.isValid();
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void restoreValues(IDialogSettings settings) {
+ if(settings != null) {
+ fCaseSensitive = settings.getBoolean(CASE_SENSITIVE);
+ fBtnCase.setSelection(fCaseSensitive);
+ fMatchPrecise = settings.getBoolean(MATCH_PRECISE);
+ fBtnMatch.setSelection(fMatchPrecise);
+ fTargetName = settings.get(TARGET_NAME);
+ if (fTargetName != null) {
+ fSearchField.setEditFieldControlText(fTargetName);
+ }
+ }
+ else {
+ fCaseSensitive = false;
+ fMatchPrecise = false;
+ fTargetName = null;
+ }
+ fBtnCase.setSelection(fCaseSensitive);
+ fBtnMatch.setSelection(fMatchPrecise);
+ if (fTargetName != null) {
+ fSearchField.setEditFieldControlText(fTargetName);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void persistValues(IDialogSettings settings) {
+ if(settings != null) {
+ settings.put(CASE_SENSITIVE, fCaseSensitive);
+ settings.put(MATCH_PRECISE, fMatchPrecise);
+ settings.put(TARGET_NAME, fTargetName);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
+ */
+ @Override
+ public ISearchMatcher getMatcher() {
+ return new ProcessNodeGeneralMatcher(fCaseSensitive, fMatchPrecise, fTargetName);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#getPreferredSize()
+ */
+ @Override
+ public Point getPreferredSize() {
+ return new Point(360, 130);
+ }
+}
+
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/NameValidator.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/NameValidator.java
index 000157821..cca22b9fd 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/NameValidator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/NameValidator.java
@@ -1,42 +1,42 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
-
-import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
-import org.eclipse.tcf.te.ui.controls.validator.Validator;
-
-/**
- * The validator used to validate the name entered in the search dialog.
- */
-public class NameValidator extends Validator {
-
- /**
- * Constructor
- */
- public NameValidator() {
- super(ATTR_MANDATORY);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.controls.validator.Validator#isValid(java.lang.String)
- */
- @Override
- public boolean isValid(String newText) {
- init();
- boolean valid = newText != null && newText.trim().length() > 0;
- if(!valid) {
- if (isAttribute(ATTR_MANDATORY)) {
- setMessage(Messages.NameValidator_InfoPrompt, INFORMATION);
- }
- }
- return valid;
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.search;
+
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.controls.validator.Validator;
+
+/**
+ * The validator used to validate the name entered in the search dialog.
+ */
+public class NameValidator extends Validator {
+
+ /**
+ * Constructor
+ */
+ public NameValidator() {
+ super(ATTR_MANDATORY);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.controls.validator.Validator#isValid(java.lang.String)
+ */
+ @Override
+ public boolean isValid(String newText) {
+ init();
+ boolean valid = newText != null && newText.trim().length() > 0;
+ if(!valid) {
+ if (isAttribute(ATTR_MANDATORY)) {
+ setMessage(Messages.NameValidator_InfoPrompt, INFORMATION);
+ }
+ }
+ return valid;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessBaseSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java
index fefdbf272..be97aa345 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessBaseSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessBaseSearchable.java
@@ -1,77 +1,82 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
-import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
-import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.IExpansionListener;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * The base searchable that provides common methods for its subclasses.
- *
- * @see ProcessStateSearchable
- * @see ProcessUserSearchable
- */
-public abstract class ProcessBaseSearchable extends AbstractSearchable implements ISearchMatcher {
-
- /**
- * Create a collapseable section with the specified title and return the
- * content composite.
- *
- * @param parent The parent where the section is to be created.
- * @param title The title of the section.
- * @return The content composite.
- */
- protected Composite createSection(Composite parent, String title) {
- Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- section.setText(title);
- section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
- GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
- section.setLayoutData(layoutData);
-
- final Composite client = new Composite(section, SWT.NONE);
- client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- client.setBackground(section.getBackground());
- section.setClient(client);
-
- section.addExpansionListener(new IExpansionListener(){
- @Override
- public void expansionStateChanging(ExpansionEvent e) {
- }
- @Override
- public void expansionStateChanged(ExpansionEvent e) {
- Shell shell = client.getShell();
- boolean state = e.getState();
- int client_height = client.getSize().y;
- Point p = shell.getSize();
- p.y = state ? p.y + client_height : p.y - client_height;
- shell.setSize(p.x, p.y);
- }});
- return client;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
- */
- @Override
- public ISearchMatcher getMatcher() {
- return this;
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.search;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * The base searchable that provides common methods for its subclasses.
+ *
+ * @see ProcessStateSearchable
+ * @see ProcessUserSearchable
+ */
+public abstract class ProcessBaseSearchable extends AbstractSearchable implements ISearchMatcher {
+
+ /**
+ * Create a collapseable section with the specified title and return the
+ * content composite.
+ *
+ * @param parent The parent where the section is to be created.
+ * @return The content composite.
+ */
+ protected Composite createSection(Composite parent) {
+ Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
+ section.setText(getSectionTitle());
+ section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ section.setLayoutData(layoutData);
+
+ final Composite client = new Composite(section, SWT.NONE);
+ client.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ client.setBackground(section.getBackground());
+ section.setClient(client);
+
+ section.addExpansionListener(new IExpansionListener(){
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ }
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ Shell shell = client.getShell();
+ boolean state = e.getState();
+ int client_height = client.getSize().y;
+ Point p = shell.getSize();
+ p.y = state ? p.y + client_height : p.y - client_height;
+ shell.setSize(p.x, p.y);
+ }});
+ return client;
+ }
+
+ /**
+ * Returns the section title.
+ *
+ * @return The section title.
+ */
+ protected abstract String getSectionTitle();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
+ */
+ @Override
+ public ISearchMatcher getMatcher() {
+ return this;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessNodeGeneralMatcher.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java
index 1d768bcba..da7db2a43 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessNodeGeneralMatcher.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessNodeGeneralMatcher.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
+package org.eclipse.tcf.te.tcf.processes.ui.search;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java
new file mode 100644
index 000000000..35f6e185f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessSearchable.java
@@ -0,0 +1,147 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tcf.processes.ui.search;
+
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.tcf.protocol.Protocol;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel;
+import org.eclipse.tcf.te.tcf.processes.ui.interfaces.IProcessMonitorMessageProviderDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.navigator.runtime.LabelProviderDelegate;
+import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
+
+/**
+ * The ISearchable adapter for a ProcessTreeNode which creates a UI for the user to
+ * input the matching condition and returns a matcher to do the matching.
+ */
+public class ProcessSearchable extends CompositeSearchable {
+ // The label provider used to get a text for a process.
+ ILabelProvider labelProvider = new LabelProviderDelegate();
+
+ /**
+ * Constructor
+ *
+ * @param node The peer model node context. Must not be <code>null</code>.
+ */
+ public ProcessSearchable(IPeerModel node) {
+ super();
+
+ IUIService service = ServiceManager.getInstance().getService(node, IUIService.class);
+ IProcessMonitorMessageProviderDelegate delegate = service != null ? service.getDelegate(node, IProcessMonitorMessageProviderDelegate.class) : null;
+ ISearchable[] searchables = delegate != null ? delegate.getSearchables(node) : null;
+ if (searchables == null) {
+ searchables = new ISearchable[] { new GeneralSearchable(), new ProcessUserSearchable(), new ProcessStateSearchable() };
+ }
+ setSearchables(searchables);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle(java.lang.Object)
+ */
+ @Override
+ public String getSearchTitle(final Object rootElement) {
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ if (rootElement instanceof IRuntimeModel) {
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ if (rootElement instanceof IRuntimeModel) {
+ node.set(((IRuntimeModel)rootElement).getPeerModel());
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+ }
+ else if (rootElement != null) {
+ node.set(rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class));
+ }
+
+ String label = Messages.getStringDelegated(node.get(), "ProcessSearchable_SearchTitle"); //$NON-NLS-1$
+ return label != null ? label : Messages.ProcessSearchable_SearchTitle;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
+ */
+ @Override
+ public String getSearchMessage(final Object rootElement) {
+ if (rootElement == null || rootElement instanceof IRuntimeModel) {
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ if (rootElement instanceof IRuntimeModel) {
+ node.set(((IRuntimeModel)rootElement).getPeerModel());
+ }
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ String label = Messages.getStringDelegated(node.get(), "ProcessSearchable_PromptFindInProcessList"); //$NON-NLS-1$
+ return label != null ? label : Messages.ProcessSearchable_PromptFindInProcessList;
+ }
+
+ IPeerModel node = rootElement instanceof IAdaptable ? (IPeerModel)((IAdaptable)rootElement).getAdapter(IPeerModel.class) : (IPeerModel)Platform.getAdapterManager().getAdapter(rootElement, IPeerModel.class);
+ String label = Messages.getStringDelegated(node, "ProcessSearchable_PromptFindUnderProcess"); //$NON-NLS-1$
+ String message = label != null ? label : Messages.ProcessSearchable_PromptFindUnderProcess;
+ String rootName = "\"" + getElementName(rootElement) + "\""; //$NON-NLS-1$//$NON-NLS-2$
+ message = NLS.bind(message, rootName);
+ return message;
+ }
+
+ /**
+ * Get a name representation for each process node.
+ *
+ * @param rootElement The root element whose name is being retrieved.
+ * @return The node's name.
+ */
+ private String getElementName(final Object rootElement) {
+ if (rootElement == null || rootElement instanceof IRuntimeModel) {
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ node.set(((IRuntimeModel)rootElement).getPeerModel());
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ String label = Messages.getStringDelegated(node.get(), "ProcessSearchable_ProcessList"); //$NON-NLS-1$
+ return label != null ? label : Messages.ProcessSearchable_ProcessList;
+ }
+ return labelProvider.getText(rootElement);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
+ */
+ @Override
+ public String getElementText(Object element) {
+ return getElementName(element);
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessStateSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java
index 7d810bf74..285a37b6e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessStateSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessStateSearchable.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
+package org.eclipse.tcf.te.tcf.processes.ui.search;
import java.util.concurrent.atomic.AtomicReference;
@@ -76,7 +76,7 @@ public class ProcessStateSearchable extends ProcessBaseSearchable {
optionChecked(e);
}
};
- Composite stateComposite = createSection(parent, Messages.ProcessStateSearchable_SectionChooseState);
+ Composite stateComposite = createSection(parent);
stateComposite.setLayout(new GridLayout());
fBtnNotRem = new Button(stateComposite, SWT.RADIO);
@@ -142,8 +142,15 @@ public class ProcessStateSearchable extends ProcessBaseSearchable {
fBtnW.addSelectionListener(l);
}
- /*
- * (non-Javadoc)
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.processes.ui.search.ProcessBaseSearchable#getSectionTitle()
+ */
+ @Override
+ protected String getSectionTitle() {
+ return Messages.ProcessStateSearchable_SectionChooseState;
+ }
+
+ /* (non-Javadoc)
* @see org.eclipse.tcf.te.ui.utils.AbstractSearchable#isInputValid()
*/
@Override
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessUserSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java
index cd2a93d65..cef67fcd2 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/internal/search/ProcessUserSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/search/ProcessUserSearchable.java
@@ -7,7 +7,7 @@
* Contributors:
* Wind River Systems - initial API and implementation
*******************************************************************************/
-package org.eclipse.tcf.te.tcf.processes.ui.internal.search;
+package org.eclipse.tcf.te.tcf.processes.ui.search;
import java.util.concurrent.atomic.AtomicReference;
@@ -61,7 +61,7 @@ public class ProcessUserSearchable extends ProcessBaseSearchable {
optionChecked(e);
}
};
- Composite modifiedComp = createSection(parent, Messages.ProcessUserSearchable_WhoStarted);
+ Composite modifiedComp = createSection(parent);
modifiedComp.setLayout(new GridLayout(2, false));
fBtnUserNotRem = new Button(modifiedComp, SWT.RADIO);
@@ -111,6 +111,14 @@ public class ProcessUserSearchable extends ProcessBaseSearchable {
});
}
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.tcf.processes.ui.search.ProcessBaseSearchable#getSectionTitle()
+ */
+ @Override
+ protected String getSectionTitle() {
+ return Messages.ProcessUserSearchable_WhoStarted;
+ }
+
/**
* The modified event of the user fields.
*/
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java
index 677459f54..a2c0ae106 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tests/src/org/eclipse/tcf/te/tests/CoreTestCase.java
@@ -1,688 +1,686 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.tests;
-
-import java.io.IOException;
-import java.lang.reflect.Field;
-import java.net.URL;
-import java.text.DateFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.Properties;
-
-import junit.framework.AssertionFailedError;
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestListener;
-import junit.framework.TestResult;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.core.runtime.FileLocator;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
-import org.eclipse.tcf.te.runtime.utils.Host;
-import org.eclipse.tcf.te.tests.activator.UIPlugin;
-import org.eclipse.tcf.te.tests.interfaces.IConfigurationProperties;
-import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IViewReference;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.WorkbenchException;
-import org.osgi.framework.Bundle;
-
-/**
- * Core test case implementation.
- */
-public class CoreTestCase extends TestCase {
- // Internal property id to store if or if not the views zoom state
- // got changed before executing the test case.
- private final static String VIEW_ZOOM_STATE_CHANGED = "viewZoomStateChanged"; //$NON-NLS-1$
-
- // The test configuration
- private final Properties configuration = new Properties();
-
- // The internal test listener.
- private final TestListener listener = new InternalTestListener();
-
- /**
- * Listens to the test executions and logs the failures.
- */
- private class InternalTestListener implements TestListener {
-
- /**
- * Constructor.
- */
- public InternalTestListener() {
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestListener#startTest(junit.framework.Test)
- */
- @Override
- public void startTest(Test test) {
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
- */
- @Override
- public synchronized void addError(Test test, Throwable error) {
- if (test != null && error != null) {
- // Log the error to the error log.
- IStatus status = new Status(IStatus.ERROR,
- UIPlugin.getUniqueIdentifier(),
- 1,
- "Test case '" + test + "' failed with error. Possible cause: " + error.getLocalizedMessage(), //$NON-NLS-1$ //$NON-NLS-2$
- error
- );
- UIPlugin.getDefault().getLog().log(status);
- }
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
- */
- @Override
- public synchronized void addFailure(Test test, AssertionFailedError failure) {
- if (test != null && failure != null) {
- // Log the failure to the error log.
- IStatus status = new Status(IStatus.ERROR,
- UIPlugin.getUniqueIdentifier(),
- 1,
- "Test case '" + test + "' failed. Failure: " + failure.getLocalizedMessage(), //$NON-NLS-1$ //$NON-NLS-2$
- failure
- );
- UIPlugin.getDefault().getLog().log(status);
- }
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestListener#endTest(junit.framework.Test)
- */
- @Override
- public void endTest(Test test) {
- // nothing to do on end test
- }
- }
-
- /**
- * Constructor.
- */
- public CoreTestCase() {
- this(null);
- }
-
- /**
- * Constructor.
- *
- * @param name The test name.
- */
- public CoreTestCase(String name) {
- super(name);
-
- // Setup the test case configuration. Clear out the old configuration.
- configuration.clear();
- initialize();
- }
-
- /**
- * Initialize the test configuration.
- * <p>
- * Clients may overwrite this method to modify the base configuration.
- */
- protected void initialize() {
- Assert.isNotNull(configuration);
-
- setProperty(VIEW_ZOOM_STATE_CHANGED, false);
- setProperty(IConfigurationProperties.MAXIMIZE_VIEW, false);
-
- setProperty(IConfigurationProperties.TARGET_PERSPECTIVE, "org.eclipse.tcf.te.ui.perspective"); //$NON-NLS-1$
- setProperty(IConfigurationProperties.TARGET_VIEW, IUIConstants.ID_EXPLORER);
- }
-
- /**
- * Sets a boolean configuration property.
- *
- * @param key The property key. Must not be <code>null</code>!
- * @param value The property value.
- */
- protected final void setProperty(String key, boolean value) {
- Assert.isNotNull(key);
- setProperty(key, value ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
- }
-
- /**
- * Checks if a boolean configuration property has been set to the
- * given property value.
- *
- * @param key The property key. Must not be <code>null</code>!
- * @param value The property value.
- *
- * @return <code>True</code> if the property values match, <code>false</code> if not.
- */
- protected final boolean isProperty(String key, boolean value) {
- Assert.isNotNull(key);
- return (value ? Boolean.TRUE : Boolean.FALSE).equals(Boolean.valueOf(configuration.getProperty(key, "false"))); //$NON-NLS-1$
- }
-
- /**
- * Sets a string configuration property.
- * <p>
- * If the value is <code>null</code>, the configuration property
- * will be removed.
- *
- * @param key The property key. Must not be <code>null</code>!
- * @param value The property value.
- */
- protected final void setProperty(String key, String value) {
- Assert.isNotNull(key);
- if (value != null) configuration.setProperty(key, value);
- else configuration.remove(key);
- }
-
- /**
- * Checks if a string configuration property has been set to the given property
- * value (case insensitive).
- * <p>
- * If the value is <code>null</code>, the method returns <code>true</code> if
- * the configuration property cannot be found.
- *
- * @param key The property key. Must not be <code>null</code>!
- * @param value The property value.
- *
- * @return <code>True</code> if the property values match, <code>false</code> if not.
- */
- protected final boolean isProperty(String key, String value) {
- Assert.isNotNull(key);
- return value != null ? value.equalsIgnoreCase(configuration.getProperty(key)) : !configuration.containsKey(key);
- }
-
- /**
- * Returns the value of a string configuration property.
- *
- * @param key The property key. Must not be <code>null</code>!
- * @return The property value or <code>null</code> if not set.
- */
- protected final String getProperty(String key) {
- Assert.isNotNull(key);
- return configuration.getProperty(key, null);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#run(junit.framework.TestResult)
- */
- @Override
- public void run(TestResult result) {
- if (result != null) result.addListener(listener);
- super.run(result);
- if (result != null) result.removeListener(listener);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#runBare()
- */
- @Override
- public void runBare() throws Throwable {
- long start = printStart(getName());
-
- boolean toggleInteractiveMode = Host.isInteractive();
- if (toggleInteractiveMode) {
- System.setProperty("NOINTERACTIVE", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- Field f = Host.class.getDeclaredField("isInteractive"); //$NON-NLS-1$
- f.setAccessible(true);
- f.set(null, null);
- }
- catch (Exception e) { /* ignored on purpose */ }
- }
-
- try {
- super.runBare();
- } finally {
- if (toggleInteractiveMode) {
- System.setProperty("NOINTERACTIVE", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- Field f = Host.class.getDeclaredField("isInteractive"); //$NON-NLS-1$
- f.setAccessible(true);
- f.set(null, null);
- }
- catch (Exception e) { /* ignored on purpose */ }
- }
-
- printEnd(getName(), start);
- }
- }
-
- // Local date format presenting long date and time format.
- private final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault());
-
- /**
- * Prints out the test start time.
- *
- * @param name The name. Must not be <code>null</code>.
- * @return The start time in milliseconds.
- */
- protected long printStart(String name) {
- Assert.isNotNull(name);
- long startTime = System.currentTimeMillis();
- System.out.println("\n=== " + name + " started at: " + DATE_FORMAT.format(new Date(startTime))); //$NON-NLS-1$ //$NON-NLS-2$
- return startTime;
- }
-
- /**
- * Prints out the test end time together with the test duration in milliseconds.
- *
- * @param name The name. Must not be <code>null</code>.
- * @param startTime The start time in milliseconds.
- */
- protected void printEnd(String name, long startTime) {
- Assert.isNotNull(name);
- long endTime = System.currentTimeMillis();
- long duration = endTime - startTime;
- System.out.println("=== " + name + " finished at: " + DATE_FORMAT.format(new Date(endTime)) + " (duration: " + duration + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
-
- /**
- * Prints out the given message.
- *
- * @param message The message. Must not be <code>null</code>.
- */
- protected void printMessage(String message) {
- Assert.isNotNull(message);
- System.out.println(message);
- }
-
- /**
- * Prints out the given debug message.
- * <p>
- * Debug messages are printed only if the platform is in debug mode.
- *
- * @param message The message. Must not be <code>null</code>.
- */
- protected void printDebugMessage(String message) {
- Assert.isNotNull(message);
- if (Platform.inDebugMode()) System.out.println(message);
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#setUp()
- */
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
- // View handling must run in the UI thread
- if (Display.findDisplay(Thread.currentThread()) == null) {
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- maximizeView();
- }
- });
- } else {
- maximizeView();
- }
- }
-
- /* (non-Javadoc)
- * @see junit.framework.TestCase#tearDown()
- */
- @Override
- protected void tearDown() throws Exception {
- // View handling must run in the UI thread
- if (Display.findDisplay(Thread.currentThread()) == null) {
- PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
- @Override
- public void run() {
- restoreView();
- }
- });
- } else {
- restoreView();
- }
-
- flushEventQueue();
- super.tearDown();
- }
-
- /**
- * Flush the display event queue.
- * <p>
- * Unhandled exceptions in the event loop event are caught as follows:
- * In case multiple events from the event loop throw exceptions these are printed
- * to stdout. The first exception found in the event loop is thrown to the caller.
- *
- * @throws Exception in case an unhandled event loop exception was found.
- */
- protected void flushEventQueue() throws Exception {
- Display display = Display.getCurrent();
- if (display!=null) {
- //on the dispatch thread already
- Exception eventLoopException = null;
- while(!display.isDisposed()) {
- //loop until event queue is flushed
- try {
- if (!display.readAndDispatch()) {
- break;
- }
- } catch(Exception e) {
- if (eventLoopException==null) {
- eventLoopException = e;
- } else {
- System.out.println("Multiple unhandled event loop exceptions:"); //$NON-NLS-1$
- e.printStackTrace();
- }
- }
- }
- if (eventLoopException!=null) {
- throw eventLoopException;
- }
- } else {
- //calling from background thread
- final Exception[] ex = new Exception[1];
- display = Display.getDefault();
- display.syncExec(new Runnable() {
- @Override
- public void run() {
- try {
- flushEventQueue();
- } catch(Exception e) {
- ex[0] = e;
- }
- }
- });
- if (ex[0]!=null) throw ex[0];
- }
- }
-
- /**
- * Bring the main view to front.
- * <p>
- * If the property {@link IConfigurationProperties#MAXIMIZE_VIEW} is set, the
- * view will be maximized.
- * <p>
- * A possibly open Eclipse Intro View will be hidden automatically.
- */
- protected void maximizeView() {
- Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
-
- final String perspectiveId = getProperty(IConfigurationProperties.TARGET_PERSPECTIVE);
- assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
- final String viewId = getProperty(IConfigurationProperties.TARGET_VIEW);
- assertNotNull("Invalid null-value for test case view id!", perspectiveId); //$NON-NLS-1$
-
- // Find the Eclipse Intro page and hide it.
- hideView("org.eclipse.ui.internal.introview", perspectiveId); //$NON-NLS-1$
-
- // Show the main view
- setProperty(VIEW_ZOOM_STATE_CHANGED, false);
- IViewPart part = showView(viewId, perspectiveId);
- assertNotNull("Main view is not available!", part); //$NON-NLS-1$
-
- // Get the view reference for setting the maximized state
- IViewReference reference = findView(viewId, perspectiveId);
- assertNotNull("Failed to lookup view reference for main view!", reference); //$NON-NLS-1$
- if (reference.getPage().getPartState(reference) != IWorkbenchPage.STATE_MAXIMIZED
- && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, true)) {
- reference.getPage().toggleZoom(reference);
- setProperty(VIEW_ZOOM_STATE_CHANGED, true);
- } else if (reference.getPage().getPartState(reference) == IWorkbenchPage.STATE_MAXIMIZED
- && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, false)) {
- reference.getPage().toggleZoom(reference);
- setProperty(VIEW_ZOOM_STATE_CHANGED, true);
- }
-
- // Give the UI a chance to repaint if the view zoom state changed
- if (isProperty(VIEW_ZOOM_STATE_CHANGED, true)) {
- waitAndDispatch(1000);
- }
- }
-
- /**
- * Restore the main view state.
- */
- protected void restoreView() {
- Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
-
- // restore the original view zoom state
- if (isProperty(VIEW_ZOOM_STATE_CHANGED, true)) {
- final String perspectiveId = getProperty(IConfigurationProperties.TARGET_PERSPECTIVE);
- assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
- final String viewId = getProperty(IConfigurationProperties.TARGET_VIEW);
- assertNotNull("Invalid null-value for test case view id!", perspectiveId); //$NON-NLS-1$
-
- IViewReference reference = findView(viewId, perspectiveId);
- assertNotNull("Failed to lookup view reference for RSE Remote Systems View!", reference); //$NON-NLS-1$
- if (reference.getPage().getPartState(reference) == IWorkbenchPage.STATE_MAXIMIZED
- && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, true)) {
- reference.getPage().toggleZoom(reference);
- } else if (reference.getPage().getPartState(reference) != IWorkbenchPage.STATE_MAXIMIZED
- && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, false)) {
- reference.getPage().toggleZoom(reference);
- }
- setProperty(VIEW_ZOOM_STATE_CHANGED, false);
- }
- }
-
- /**
- * Lookup the view reference for the given view and perspective id's.
- *
- * @param viewId The view id. Must not be <code>null</code>.
- * @param perspectiveId The perspective id. Must not be <code>null</code>.
- *
- * @return The view reference instance to the view or <code>null</code> if not available.
- */
- public final IViewReference findView(String viewId, String perspectiveId) {
- Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- Assert.isNotNull(perspectiveId);
-
- IWorkbench workbench = PlatformUI.getWorkbench();
- assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$
-
- try {
- workbench.showPerspective(perspectiveId, window);
- } catch (WorkbenchException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
- "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
- UIPlugin.getDefault().getLog().log(status);
- }
-
- IWorkbenchPage page = window.getActivePage();
- assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$
-
- return page.findViewReference(viewId);
- }
-
- /**
- * Shows the view.
- *
- * @param viewId The view id. Must not be <code>null</code>.
- * @param perspectiveId The perspective id. Must not be <code>null</code>.
- *
- * @return The view part instance to the view or <code>null</code> if it cannot be shown.
- */
- public final IViewPart showView(String viewId, String perspectiveId) {
- Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- Assert.isNotNull(perspectiveId);
-
- IWorkbench workbench = PlatformUI.getWorkbench();
- assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$
-
- try {
- workbench.showPerspective(perspectiveId, window);
- } catch (WorkbenchException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
- "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
- UIPlugin.getDefault().getLog().log(status);
- }
-
- IWorkbenchPage page = window.getActivePage();
- assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$
-
- IViewPart part = null;
- try {
- part = page.showView(viewId);
- } catch (PartInitException e) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
- "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
- UIPlugin.getDefault().getLog().log(status);
- }
-
- return part;
- }
-
- /**
- * Hides the view.
- *
- * @param viewId The view id. Must not be <code>null</code>.
- * @param perspectiveId The perspective id. Must not be <code>null</code>.
- */
- public final void hideView(String viewId, String perspectiveId) {
- Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
- Assert.isNotNull(viewId);
- Assert.isNotNull(perspectiveId);
-
- IViewReference viewReference = findView(viewId, perspectiveId);
- if (viewReference != null) {
- PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(viewReference);
- waitAndDispatch(1000);
- }
- }
-
- /**
- * Convenience method to call {@link #waitAndDispatch(long, null)}.
- *
- * @param timeout The timeout in milliseconds. Must be larger than 0.
- *
- * @return <code>True</code> if the method returned because of the timeout, <code>false</code> if the
- * method returned because of the condition became true.
- */
- public boolean waitAndDispatch(long timeout) {
- Assert.isTrue(timeout > 0);
- return waitAndDispatch(timeout, null);
- }
-
- /**
- * Method does not return until either the timeout has been exceeded or
- * the interrupt condition is fulfilled. If the method called in a UI thread,
- * the method keeps the UI thread dispatching running. If called in a
- * non-UI thread, the method uses {@link Thread#sleep(long)}.
- * <p>
- * If a timeout of 0 milliseconds is specified, the method waits until the
- * given interrupt condition is fulfilled.
- *
- * @param timeout The timeout in milliseconds. Must be larger or equals than 0.
- * @param condition The condition to test. Must not be <code>null</code> if the timeout is 0.
- *
- * @return <code>True</code> if the method returned because of the timeout, <code>false</code> if the
- * method returned because of the condition became true.
- */
- public boolean waitAndDispatch(long timeout, IConditionTester condition) {
- Assert.isTrue(timeout >= 0);
- if (timeout == 0) Assert.isNotNull(condition);
-
- boolean isTimedOut= false;
- if (timeout >= 0) {
- long start = System.currentTimeMillis();
- final Display display = Display.findDisplay(Thread.currentThread());
- if (display != null) {
- long current = System.currentTimeMillis();
- while (timeout == 0 || (current - start) < timeout && !display.isDisposed()) {
- if (condition != null && condition.isConditionFulfilled()) break;
- if (!display.readAndDispatch()) display.sleep();
- current = System.currentTimeMillis();
- }
- isTimedOut = (current - start) >= timeout && timeout > 0;
- } else {
- long current = System.currentTimeMillis();
- while (timeout == 0 || (current - start) < timeout) {
- if (condition != null && condition.isConditionFulfilled()) break;
- try { Thread.sleep(50); } catch (InterruptedException e) { /* ignored on purpose */ }
- current = System.currentTimeMillis();
- }
- isTimedOut = (current - start) >= timeout && timeout > 0;
- }
- }
- if (condition != null) condition.cleanup();
-
- return isTimedOut;
- }
-
- /**
- * Calculates the absolute path to load additional data from.
- * <p>
- * The returned path is calculated as follow:<br>
- * <ul>
- * <li>Add org.eclipse.tcf.te.tests bundle location</li>
- * <li>Add &quot;data&quot;</li>
- * <li>Add the given relative path</li>
- * <li>If &quot;hostSpecific&quot; is true, add &quot;Platform.getOS()&quot;</li>
- * <li>If &quot;archSpecific&quot; is true, add &quot;Platform.getOSArch()&quot;</li>
- * </ul>
- * <p>
- * The calculated path must be a readable directory, otherwise the method will
- * return <code>null</code>.
- *
- * @param path The relative path segment to append. Must not be <code>null</code>.
- * @param hostSpecific Specify <code>true</code> to include {@link Platform#getOS()}, <code>false</code> if not.
- * @param archSpecific Specify <code>true</code> to include {@link Platform#getOSArch()}, <code>false</code> if not.
- *
- * @return The absolute path to the data location or <code>null</code>.
- */
- protected final IPath getDataLocation(String path, boolean hostSpecific, boolean archSpecific) {
- Assert.isNotNull(path);
- IPath root = null;
-
- if (path != null) {
- Bundle bundle = getTestBundle();
- if (bundle != null) {
- IPath relative = new Path ("data").append(path); //$NON-NLS-1$
- if (hostSpecific) relative = relative.append(Platform.getOS());
- if (archSpecific) relative = relative.append(Platform.getOSArch());
-
- URL url = FileLocator.find(bundle, relative, null);
- if (url != null) {
- try {
- root = new Path(FileLocator.resolve(url).getFile());
- if (!root.toFile().isDirectory() || !root.toFile().canRead()) {
- root = null;
- }
- } catch (IOException e) { /* ignored on purpose */ }
- }
- }
- }
-
- return root;
- }
-
- /**
- * Returns the test bundle.
- *
- * @return The test bundle.
- */
- protected Bundle getTestBundle() {
- return UIPlugin.getDefault().getBundle();
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.tests;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.net.URL;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Locale;
+import java.util.Properties;
+
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestListener;
+import junit.framework.TestResult;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.tcf.te.runtime.interfaces.IConditionTester;
+import org.eclipse.tcf.te.runtime.utils.Host;
+import org.eclipse.tcf.te.tests.activator.UIPlugin;
+import org.eclipse.tcf.te.tests.interfaces.IConfigurationProperties;
+import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
+import org.eclipse.ui.IViewPart;
+import org.eclipse.ui.IViewReference;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.WorkbenchException;
+import org.osgi.framework.Bundle;
+
+/**
+ * Core test case implementation.
+ */
+public class CoreTestCase extends TestCase {
+ // Internal property id to store if or if not the views zoom state
+ // got changed before executing the test case.
+ private final static String VIEW_ZOOM_STATE_CHANGED = "viewZoomStateChanged"; //$NON-NLS-1$
+
+ // The test configuration
+ private final Properties configuration = new Properties();
+
+ // The internal test listener.
+ private final TestListener listener = new InternalTestListener();
+
+ /**
+ * Listens to the test executions and logs the failures.
+ */
+ private class InternalTestListener implements TestListener {
+
+ /**
+ * Constructor.
+ */
+ public InternalTestListener() {
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestListener#startTest(junit.framework.Test)
+ */
+ @Override
+ public void startTest(Test test) {
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestListener#addError(junit.framework.Test, java.lang.Throwable)
+ */
+ @Override
+ public synchronized void addError(Test test, Throwable error) {
+ if (test != null && error != null) {
+ // Log the error to the error log.
+ IStatus status = new Status(IStatus.ERROR,
+ UIPlugin.getUniqueIdentifier(),
+ 1,
+ "Test case '" + test + "' failed with error. Possible cause: " + error.getLocalizedMessage(), //$NON-NLS-1$ //$NON-NLS-2$
+ error
+ );
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestListener#addFailure(junit.framework.Test, junit.framework.AssertionFailedError)
+ */
+ @Override
+ public synchronized void addFailure(Test test, AssertionFailedError failure) {
+ if (test != null && failure != null) {
+ // Log the failure to the error log.
+ IStatus status = new Status(IStatus.ERROR,
+ UIPlugin.getUniqueIdentifier(),
+ 1,
+ "Test case '" + test + "' failed. Failure: " + failure.getLocalizedMessage(), //$NON-NLS-1$ //$NON-NLS-2$
+ failure
+ );
+ UIPlugin.getDefault().getLog().log(status);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestListener#endTest(junit.framework.Test)
+ */
+ @Override
+ public void endTest(Test test) {
+ // nothing to do on end test
+ }
+ }
+
+ /**
+ * Constructor.
+ */
+ public CoreTestCase() {
+ this(null);
+ }
+
+ /**
+ * Constructor.
+ *
+ * @param name The test name.
+ */
+ public CoreTestCase(String name) {
+ super(name);
+
+ // Setup the test case configuration. Clear out the old configuration.
+ configuration.clear();
+ initialize();
+ }
+
+ /**
+ * Initialize the test configuration.
+ * <p>
+ * Clients may overwrite this method to modify the base configuration.
+ */
+ protected void initialize() {
+ Assert.isNotNull(configuration);
+
+ setProperty(VIEW_ZOOM_STATE_CHANGED, false);
+ setProperty(IConfigurationProperties.MAXIMIZE_VIEW, false);
+
+ setProperty(IConfigurationProperties.TARGET_PERSPECTIVE, "org.eclipse.tcf.te.ui.perspective"); //$NON-NLS-1$
+ setProperty(IConfigurationProperties.TARGET_VIEW, IUIConstants.ID_EXPLORER);
+ }
+
+ /**
+ * Sets a boolean configuration property.
+ *
+ * @param key The property key. Must not be <code>null</code>!
+ * @param value The property value.
+ */
+ protected final void setProperty(String key, boolean value) {
+ Assert.isNotNull(key);
+ setProperty(key, value ? Boolean.TRUE.toString() : Boolean.FALSE.toString());
+ }
+
+ /**
+ * Checks if a boolean configuration property has been set to the
+ * given property value.
+ *
+ * @param key The property key. Must not be <code>null</code>!
+ * @param value The property value.
+ *
+ * @return <code>True</code> if the property values match, <code>false</code> if not.
+ */
+ protected final boolean isProperty(String key, boolean value) {
+ Assert.isNotNull(key);
+ return (value ? Boolean.TRUE : Boolean.FALSE).equals(Boolean.valueOf(configuration.getProperty(key, "false"))); //$NON-NLS-1$
+ }
+
+ /**
+ * Sets a string configuration property.
+ * <p>
+ * If the value is <code>null</code>, the configuration property
+ * will be removed.
+ *
+ * @param key The property key. Must not be <code>null</code>!
+ * @param value The property value.
+ */
+ protected final void setProperty(String key, String value) {
+ Assert.isNotNull(key);
+ if (value != null) configuration.setProperty(key, value);
+ else configuration.remove(key);
+ }
+
+ /**
+ * Checks if a string configuration property has been set to the given property
+ * value (case insensitive).
+ * <p>
+ * If the value is <code>null</code>, the method returns <code>true</code> if
+ * the configuration property cannot be found.
+ *
+ * @param key The property key. Must not be <code>null</code>!
+ * @param value The property value.
+ *
+ * @return <code>True</code> if the property values match, <code>false</code> if not.
+ */
+ protected final boolean isProperty(String key, String value) {
+ Assert.isNotNull(key);
+ return value != null ? value.equalsIgnoreCase(configuration.getProperty(key)) : !configuration.containsKey(key);
+ }
+
+ /**
+ * Returns the value of a string configuration property.
+ *
+ * @param key The property key. Must not be <code>null</code>!
+ * @return The property value or <code>null</code> if not set.
+ */
+ protected final String getProperty(String key) {
+ Assert.isNotNull(key);
+ return configuration.getProperty(key, null);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#run(junit.framework.TestResult)
+ */
+ @Override
+ public void run(TestResult result) {
+ if (result != null) result.addListener(listener);
+ super.run(result);
+ if (result != null) result.removeListener(listener);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#runBare()
+ */
+ @Override
+ public void runBare() throws Throwable {
+ long start = printStart(getName());
+
+ boolean toggleInteractiveMode = Host.isInteractive();
+ if (toggleInteractiveMode) {
+ System.setProperty("NOINTERACTIVE", "true"); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ Field f = Host.class.getDeclaredField("isInteractive"); //$NON-NLS-1$
+ f.setAccessible(true);
+ f.set(null, null);
+ }
+ catch (Exception e) { /* ignored on purpose */ }
+ }
+
+ try {
+ super.runBare();
+ } finally {
+ if (toggleInteractiveMode) {
+ System.setProperty("NOINTERACTIVE", "false"); //$NON-NLS-1$ //$NON-NLS-2$
+ try {
+ Field f = Host.class.getDeclaredField("isInteractive"); //$NON-NLS-1$
+ f.setAccessible(true);
+ f.set(null, null);
+ }
+ catch (Exception e) { /* ignored on purpose */ }
+ }
+
+ printEnd(getName(), start);
+ }
+ }
+
+ // Local date format presenting long date and time format.
+ private final DateFormat DATE_FORMAT = DateFormat.getDateTimeInstance(DateFormat.LONG, DateFormat.LONG, Locale.getDefault());
+
+ /**
+ * Prints out the test start time.
+ *
+ * @param name The name. Must not be <code>null</code>.
+ * @return The start time in milliseconds.
+ */
+ protected long printStart(String name) {
+ Assert.isNotNull(name);
+ long startTime = System.currentTimeMillis();
+ System.out.println("\n=== " + name + " started at: " + DATE_FORMAT.format(new Date(startTime))); //$NON-NLS-1$ //$NON-NLS-2$
+ return startTime;
+ }
+
+ /**
+ * Prints out the test end time together with the test duration in milliseconds.
+ *
+ * @param name The name. Must not be <code>null</code>.
+ * @param startTime The start time in milliseconds.
+ */
+ protected void printEnd(String name, long startTime) {
+ Assert.isNotNull(name);
+ long endTime = System.currentTimeMillis();
+ long duration = endTime - startTime;
+ System.out.println("=== " + name + " finished at: " + DATE_FORMAT.format(new Date(endTime)) + " (duration: " + duration + " ms)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ }
+
+ /**
+ * Prints out the given message.
+ *
+ * @param message The message. Must not be <code>null</code>.
+ */
+ protected void printMessage(String message) {
+ Assert.isNotNull(message);
+ System.out.println(message);
+ }
+
+ /**
+ * Prints out the given debug message.
+ * <p>
+ * Debug messages are printed only if the platform is in debug mode.
+ *
+ * @param message The message. Must not be <code>null</code>.
+ */
+ protected void printDebugMessage(String message) {
+ Assert.isNotNull(message);
+ if (Platform.inDebugMode()) System.out.println(message);
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#setUp()
+ */
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ // View handling must run in the UI thread
+ if (Display.findDisplay(Thread.currentThread()) == null) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ maximizeView();
+ }
+ });
+ } else {
+ maximizeView();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see junit.framework.TestCase#tearDown()
+ */
+ @Override
+ protected void tearDown() throws Exception {
+ // View handling must run in the UI thread
+ if (Display.findDisplay(Thread.currentThread()) == null) {
+ PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
+ @Override
+ public void run() {
+ restoreView();
+ }
+ });
+ } else {
+ restoreView();
+ }
+
+ flushEventQueue();
+ super.tearDown();
+ }
+
+ /**
+ * Flush the display event queue.
+ * <p>
+ * Unhandled exceptions in the event loop event are caught as follows:
+ * In case multiple events from the event loop throw exceptions these are printed
+ * to stdout. The first exception found in the event loop is thrown to the caller.
+ *
+ * @throws Exception in case an unhandled event loop exception was found.
+ */
+ protected void flushEventQueue() throws Exception {
+ Display display = Display.getCurrent();
+ if (display!=null) {
+ //on the dispatch thread already
+ Exception eventLoopException = null;
+ while(!display.isDisposed()) {
+ //loop until event queue is flushed
+ try {
+ if (!display.readAndDispatch()) {
+ break;
+ }
+ } catch(Exception e) {
+ if (eventLoopException==null) {
+ eventLoopException = e;
+ } else {
+ System.out.println("Multiple unhandled event loop exceptions:"); //$NON-NLS-1$
+ e.printStackTrace();
+ }
+ }
+ }
+ if (eventLoopException!=null) {
+ throw eventLoopException;
+ }
+ } else {
+ //calling from background thread
+ final Exception[] ex = new Exception[1];
+ display = Display.getDefault();
+ display.syncExec(new Runnable() {
+ @Override
+ public void run() {
+ try {
+ flushEventQueue();
+ } catch(Exception e) {
+ ex[0] = e;
+ }
+ }
+ });
+ if (ex[0]!=null) throw ex[0];
+ }
+ }
+
+ /**
+ * Bring the main view to front.
+ * <p>
+ * If the property {@link IConfigurationProperties#MAXIMIZE_VIEW} is set, the
+ * view will be maximized.
+ * <p>
+ * A possibly open Eclipse Intro View will be hidden automatically.
+ */
+ protected void maximizeView() {
+ Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
+
+ final String perspectiveId = getProperty(IConfigurationProperties.TARGET_PERSPECTIVE);
+ assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
+ final String viewId = getProperty(IConfigurationProperties.TARGET_VIEW);
+ assertNotNull("Invalid null-value for test case view id!", perspectiveId); //$NON-NLS-1$
+
+ // Find the Eclipse Intro page and hide it.
+ hideView("org.eclipse.ui.internal.introview", perspectiveId); //$NON-NLS-1$
+
+ // Show the main view
+ setProperty(VIEW_ZOOM_STATE_CHANGED, false);
+ IViewPart part = showView(viewId, perspectiveId);
+ assertNotNull("Main view is not available!", part); //$NON-NLS-1$
+
+ // Get the view reference for setting the maximized state
+ IViewReference reference = findView(viewId, perspectiveId);
+ assertNotNull("Failed to lookup view reference for main view!", reference); //$NON-NLS-1$
+ if (reference.getPage().getPartState(reference) != IWorkbenchPage.STATE_MAXIMIZED
+ && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, true)) {
+ reference.getPage().toggleZoom(reference);
+ setProperty(VIEW_ZOOM_STATE_CHANGED, true);
+ } else if (reference.getPage().getPartState(reference) == IWorkbenchPage.STATE_MAXIMIZED
+ && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, false)) {
+ reference.getPage().toggleZoom(reference);
+ setProperty(VIEW_ZOOM_STATE_CHANGED, true);
+ }
+
+ // Give the UI a chance to repaint if the view zoom state changed
+ if (isProperty(VIEW_ZOOM_STATE_CHANGED, true)) {
+ waitAndDispatch(1000);
+ }
+ }
+
+ /**
+ * Restore the main view state.
+ */
+ protected void restoreView() {
+ Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
+
+ // restore the original view zoom state
+ if (isProperty(VIEW_ZOOM_STATE_CHANGED, true)) {
+ final String perspectiveId = getProperty(IConfigurationProperties.TARGET_PERSPECTIVE);
+ assertNotNull("Invalid null-value for test case perspective id!", perspectiveId); //$NON-NLS-1$
+ final String viewId = getProperty(IConfigurationProperties.TARGET_VIEW);
+ assertNotNull("Invalid null-value for test case view id!", perspectiveId); //$NON-NLS-1$
+
+ IViewReference reference = findView(viewId, perspectiveId);
+ assertNotNull("Failed to lookup view reference for RSE Remote Systems View!", reference); //$NON-NLS-1$
+ if (reference.getPage().getPartState(reference) == IWorkbenchPage.STATE_MAXIMIZED
+ && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, true)) {
+ reference.getPage().toggleZoom(reference);
+ } else if (reference.getPage().getPartState(reference) != IWorkbenchPage.STATE_MAXIMIZED
+ && isProperty(IConfigurationProperties.MAXIMIZE_VIEW, false)) {
+ reference.getPage().toggleZoom(reference);
+ }
+ setProperty(VIEW_ZOOM_STATE_CHANGED, false);
+ }
+ }
+
+ /**
+ * Lookup the view reference for the given view and perspective id's.
+ *
+ * @param viewId The view id. Must not be <code>null</code>.
+ * @param perspectiveId The perspective id. Must not be <code>null</code>.
+ *
+ * @return The view reference instance to the view or <code>null</code> if not available.
+ */
+ public final IViewReference findView(String viewId, String perspectiveId) {
+ Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(viewId);
+ Assert.isNotNull(perspectiveId);
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$
+ IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
+ assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$
+
+ try {
+ workbench.showPerspective(perspectiveId, window);
+ } catch (WorkbenchException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
+ UIPlugin.getDefault().getLog().log(status);
+ }
+
+ IWorkbenchPage page = window.getActivePage();
+ assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$
+
+ return page.findViewReference(viewId);
+ }
+
+ /**
+ * Shows the view.
+ *
+ * @param viewId The view id. Must not be <code>null</code>.
+ * @param perspectiveId The perspective id. Must not be <code>null</code>.
+ *
+ * @return The view part instance to the view or <code>null</code> if it cannot be shown.
+ */
+ public final IViewPart showView(String viewId, String perspectiveId) {
+ Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(viewId);
+ Assert.isNotNull(perspectiveId);
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ assertNotNull("Failed to query current workbench instance!", workbench); //$NON-NLS-1$
+ IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ assertNotNull("Failed to query currently active workbench window!", window); //$NON-NLS-1$
+
+ try {
+ workbench.showPerspective(perspectiveId, window);
+ } catch (WorkbenchException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
+ UIPlugin.getDefault().getLog().log(status);
+ }
+
+ IWorkbenchPage page = window.getActivePage();
+ assertNotNull("Failed to query currently active workbench page!", page); //$NON-NLS-1$
+
+ IViewPart part = null;
+ try {
+ part = page.showView(viewId);
+ } catch (PartInitException e) {
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ "Failed to switch to requested perspective (id = " + perspectiveId + ")!", e); //$NON-NLS-1$ //$NON-NLS-2$
+ UIPlugin.getDefault().getLog().log(status);
+ }
+
+ return part;
+ }
+
+ /**
+ * Hides the view.
+ *
+ * @param viewId The view id. Must not be <code>null</code>.
+ * @param perspectiveId The perspective id. Must not be <code>null</code>.
+ */
+ public final void hideView(String viewId, String perspectiveId) {
+ Assert.isNotNull(Display.findDisplay(Thread.currentThread()), "Illegal Thread Access"); //$NON-NLS-1$
+ Assert.isNotNull(viewId);
+ Assert.isNotNull(perspectiveId);
+
+ IViewReference viewReference = findView(viewId, perspectiveId);
+ if (viewReference != null) {
+ PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(viewReference);
+ waitAndDispatch(1000);
+ }
+ }
+
+ /**
+ * Convenience method to call {@link #waitAndDispatch(long, null)}.
+ *
+ * @param timeout The timeout in milliseconds. Must be larger than 0.
+ *
+ * @return <code>True</code> if the method returned because of the timeout, <code>false</code> if the
+ * method returned because of the condition became true.
+ */
+ public boolean waitAndDispatch(long timeout) {
+ Assert.isTrue(timeout > 0);
+ return waitAndDispatch(timeout, null);
+ }
+
+ /**
+ * Method does not return until either the timeout has been exceeded or
+ * the interrupt condition is fulfilled. If the method called in a UI thread,
+ * the method keeps the UI thread dispatching running. If called in a
+ * non-UI thread, the method uses {@link Thread#sleep(long)}.
+ * <p>
+ * If a timeout of 0 milliseconds is specified, the method waits until the
+ * given interrupt condition is fulfilled.
+ *
+ * @param timeout The timeout in milliseconds. Must be larger or equals than 0.
+ * @param condition The condition to test. Must not be <code>null</code> if the timeout is 0.
+ *
+ * @return <code>True</code> if the method returned because of the timeout, <code>false</code> if the
+ * method returned because of the condition became true.
+ */
+ public boolean waitAndDispatch(long timeout, IConditionTester condition) {
+ Assert.isTrue(timeout >= 0);
+ if (timeout == 0) Assert.isNotNull(condition);
+
+ boolean isTimedOut= false;
+ if (timeout >= 0) {
+ long start = System.currentTimeMillis();
+ final Display display = Display.findDisplay(Thread.currentThread());
+ if (display != null) {
+ long current = System.currentTimeMillis();
+ while (timeout == 0 || (current - start) < timeout && !display.isDisposed()) {
+ if (condition != null && condition.isConditionFulfilled()) break;
+ if (!display.readAndDispatch()) display.sleep();
+ current = System.currentTimeMillis();
+ }
+ isTimedOut = (current - start) >= timeout && timeout > 0;
+ } else {
+ long current = System.currentTimeMillis();
+ while (timeout == 0 || (current - start) < timeout) {
+ if (condition != null && condition.isConditionFulfilled()) break;
+ try { Thread.sleep(50); } catch (InterruptedException e) { /* ignored on purpose */ }
+ current = System.currentTimeMillis();
+ }
+ isTimedOut = (current - start) >= timeout && timeout > 0;
+ }
+ }
+ if (condition != null) condition.cleanup();
+
+ return isTimedOut;
+ }
+
+ /**
+ * Calculates the absolute path to load additional data from.
+ * <p>
+ * The returned path is calculated as follow:<br>
+ * <ul>
+ * <li>Add org.eclipse.tcf.te.tests bundle location</li>
+ * <li>Add &quot;data&quot;</li>
+ * <li>Add the given relative path</li>
+ * <li>If &quot;hostSpecific&quot; is true, add &quot;Platform.getOS()&quot;</li>
+ * <li>If &quot;archSpecific&quot; is true, add &quot;Platform.getOSArch()&quot;</li>
+ * </ul>
+ * <p>
+ * The calculated path must be a readable directory, otherwise the method will
+ * return <code>null</code>.
+ *
+ * @param path The relative path segment to append. Must not be <code>null</code>.
+ * @param hostSpecific Specify <code>true</code> to include {@link Platform#getOS()}, <code>false</code> if not.
+ * @param archSpecific Specify <code>true</code> to include {@link Platform#getOSArch()}, <code>false</code> if not.
+ *
+ * @return The absolute path to the data location or <code>null</code>.
+ */
+ protected final IPath getDataLocation(String path, boolean hostSpecific, boolean archSpecific) {
+ Assert.isNotNull(path);
+ IPath root = null;
+
+ Bundle bundle = getTestBundle();
+ if (bundle != null) {
+ IPath relative = new Path ("data").append(path); //$NON-NLS-1$
+ if (hostSpecific) relative = relative.append(Platform.getOS());
+ if (archSpecific) relative = relative.append(Platform.getOSArch());
+
+ URL url = FileLocator.find(bundle, relative, null);
+ if (url != null) {
+ try {
+ root = new Path(FileLocator.resolve(url).getFile());
+ if (!root.toFile().isDirectory() || !root.toFile().canRead()) {
+ root = null;
+ }
+ } catch (IOException e) { /* ignored on purpose */ }
+ }
+ }
+
+ return root;
+ }
+
+ /**
+ * Returns the test bundle.
+ *
+ * @return The test bundle.
+ */
+ protected Bundle getTestBundle() {
+ return UIPlugin.getDefault().getBundle();
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseDialogSelectionControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseDialogSelectionControl.java
index ba9d880b5..9869c1ba4 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseDialogSelectionControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseDialogSelectionControl.java
@@ -96,9 +96,7 @@ public class BaseDialogSelectionControl extends BaseEditBrowseTextControl {
*/
protected void configureDialogControl(Dialog dialog) {
Assert.isNotNull(dialog);
- if (dialog != null) {
- dialog.setText(getDialogTitle());
- }
+ dialog.setText(getDialogTitle());
}
/**
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseEditBrowseTextControl.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseEditBrowseTextControl.java
index 93cd7383d..7920a7f7c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseEditBrowseTextControl.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/BaseEditBrowseTextControl.java
@@ -1380,7 +1380,7 @@ public class BaseEditBrowseTextControl extends AbstractDecoratedDialogPageContro
*/
protected String[] getHistory(IDialogSettings settings, String idPrefix) {
Assert.isNotNull(settings);
- if (settings != null && getDialogSettingsSlotId(idPrefix) != null) {
+ if (getDialogSettingsSlotId(idPrefix) != null) {
return DialogSettingsUtil.getSettingsArraySafe(settings, getDialogSettingsSlotId(idPrefix));
}
@@ -1393,7 +1393,7 @@ public class BaseEditBrowseTextControl extends AbstractDecoratedDialogPageContro
@Override
public void doSaveWidgetValues(IDialogSettings settings, String idPrefix) {
Assert.isNotNull(settings);
- if (settings != null && getDialogSettingsSlotId(idPrefix) != null) {
+ if (getDialogSettingsSlotId(idPrefix) != null) {
String[] historyEntries = DialogSettingsUtil.getSettingsArraySafe(settings, getDialogSettingsSlotId(idPrefix));
historyEntries = DialogSettingsUtil.addToHistory(historyEntries, getEditFieldControlText());
settings.put(getDialogSettingsSlotId(idPrefix), historyEntries);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/HexValidator.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/HexValidator.java
index 062c8b83b..76b177139 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/HexValidator.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.controls/src/org/eclipse/tcf/te/ui/controls/validator/HexValidator.java
@@ -160,16 +160,15 @@ public class HexValidator extends RegexValidator {
public final static BigInteger decode(String value) {
Assert.isNotNull(value);
BigInteger result = null;
- if (value != null) {
- try {
- if (value.trim().toUpperCase().startsWith("0X")) { //$NON-NLS-1$
- // we have to cut away the leading 0x.
- result = new BigInteger(value.substring(2), 16);
- } else {
- result = new BigInteger(value, 10);
- }
- } catch (NumberFormatException e) { /* ignored on purpose */
+
+ try {
+ if (value.trim().toUpperCase().startsWith("0X")) { //$NON-NLS-1$
+ // we have to cut away the leading 0x.
+ result = new BigInteger(value.substring(2), 16);
+ } else {
+ result = new BigInteger(value, 10);
}
+ } catch (NumberFormatException e) { /* ignored on purpose */
}
return result;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
index 1c7922127..7a45a6e9d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java
@@ -303,6 +303,17 @@ public final class Editor extends FormEditor implements IPersistableEditor, ITab
}
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#configurePage(int, org.eclipse.ui.forms.editor.IFormPage)
+ */
+ @Override
+ protected void configurePage(int index, IFormPage page) throws PartInitException {
+ super.configurePage(index, page);
+ // Update the page text as it may have changed after initializing
+ // the editor input
+ setPageText(index, page.getTitle());
+ }
+
/**
* Returns the index of the page with the given id.
*
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
index 68ee47651..dcbfaf7b1 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/pages/AbstractEditorPage.java
@@ -68,8 +68,8 @@ public abstract class AbstractEditorPage extends FormPage implements IEditorPage
// Throws an exception if the id is empty or null.
id = config.getAttribute("id"); //$NON-NLS-1$
if (id == null || id.trim().length() == 0) {
- IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(), NLS
- .bind(Messages.Extension_error_missingRequiredAttribute, "id", config.getContributor().getName())); //$NON-NLS-1$
+ IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
+ NLS.bind(Messages.Extension_error_missingRequiredAttribute, "id", config.getContributor().getName())); //$NON-NLS-1$
UIPlugin.getDefault().getLog().log(status);
}
}
@@ -120,8 +120,9 @@ public abstract class AbstractEditorPage extends FormPage implements IEditorPage
if (getManagedForm() != null) {
getManagedForm().setInput(getEditorInputNode());
}
- getSite().getSelectionProvider()
- .setSelection(input != null ? new StructuredSelection(getEditorInputNode()) : null);
+ getSite().getSelectionProvider().setSelection(input != null ? new StructuredSelection(getEditorInputNode()) : null);
+ // The part name may change if the input changes
+ setPartName(getPartName());
}
/*
@@ -135,8 +136,9 @@ public abstract class AbstractEditorPage extends FormPage implements IEditorPage
if (getManagedForm() != null) {
getManagedForm().setInput(getEditorInputNode());
}
- getSite().getSelectionProvider()
- .setSelection(input != null ? new StructuredSelection(getEditorInputNode()) : null);
+ getSite().getSelectionProvider().setSelection(input != null ? new StructuredSelection(getEditorInputNode()) : null);
+ // The part name may change if the input changes
+ setPartName(getPartName());
}
/*
@@ -150,10 +152,8 @@ public abstract class AbstractEditorPage extends FormPage implements IEditorPage
ISelection selection = getEditorInput() != null ? new StructuredSelection(getEditorInputNode()) : null;
getSite().getSelectionProvider().setSelection(selection);
if (getSite().getSelectionProvider() instanceof MultiPageSelectionProvider) {
- SelectionChangedEvent changedEvent = new SelectionChangedEvent(getSite()
- .getSelectionProvider(), selection);
- ((MultiPageSelectionProvider) getSite().getSelectionProvider())
- .firePostSelectionChanged(changedEvent);
+ SelectionChangedEvent changedEvent = new SelectionChangedEvent(getSite().getSelectionProvider(), selection);
+ ((MultiPageSelectionProvider) getSite().getSelectionProvider()).firePostSelectionChanged(changedEvent);
}
}
}
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 da32cece1..d68a074d9 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
@@ -72,8 +72,8 @@ public class NameValuePairDialog extends CustomTitleAreaDialog {
this.dialogTitle = dialogTitle;
this.title = title;
this.message = message;
- this.fieldLabels = fieldLabels != null ? Arrays.copyOf(fieldLabels, fieldLabels.length) : null;
- this.initialValues = initialValues != null ? Arrays.copyOf(initialValues, initialValues.length) : null;
+ this.fieldLabels = Arrays.copyOf(fieldLabels, fieldLabels.length);
+ this.initialValues = Arrays.copyOf(initialValues, initialValues.length);
this.usedNames = usedNames;
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
index c9009350e..b93852256 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/ISearchable.java
@@ -1,119 +1,121 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.interfaces;
-
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
-
-/**
- * This interface should be implemented or adapted by the tree nodes which
- * should provide find function. Subclass is encouraged to inherit AbstractSearchable
- * which provides basic implementation methods, or CompositeSearchable which combines
- * several simple searchable implementations into a complexed implementation.
- *
- * @see AbstractSearchable
- * @see CompositeSearchable
- */
-public interface ISearchable {
- /**
- * Get the title text of the searching dialog for
- * this element.
- *
- * @return A title of the search dialog
- */
- public String getSearchTitle();
-
- /**
- * Get the description message that will be displayed
- * in the title area of the searching dialog with
- * the given root element.
- *
- * @param rootElement The root element where the search is started.
- * @return The message to describe the searching.
- */
- public String getSearchMessage(Object rootElement);
-
- /**
- * Get a text to be used during searching process.
- *
- * @param element The element to searched.
- * @return A description text used in searching.
- */
- public String getElementText(Object element);
-
- /**
- * Create the part in the searching dialog where the user
- * enters the common matching rule used in searching.
- *
- * @param parent The parent composite of this option part.
- */
- public void createCommonPart(Composite parent);
-
- /**
- * Create the part in the searching dialog where the user
- * enters the advanced matching rule used in searching.
- *
- * @param parent The parent composite of this option part.
- */
- public void createAdvancedPart(Composite parent);
-
- /**
- * Get a searching matcher object to test if a tree node matches
- * the current conditions entered by the user.
- *
- * @return The matcher object which implements ISearchMatcher for matching.
- */
- public ISearchMatcher getMatcher();
-
- /**
- * If the current input from the user is valid for a searching process.
- *
- * @return true if the input is valid or else false.
- */
- public boolean isInputValid();
-
- /**
- * Add an option listener that handles the option changed event.
- *
- * @param listener The listener to be added.
- */
- public void addOptionListener(IOptionListener listener);
-
- /**
- * Remove an option listener
- *
- * @param listener The listener to be removed.
- */
- public void removeOptionListener(IOptionListener listener);
-
- /**
- * Restore the part's values from its parent settings.
- *
- * @param settings The dialog settings.
- */
- public void restoreValues(IDialogSettings settings);
-
- /**
- * Persist the part's values to its parent settings.
- * Called when the searching dialog is closed.
- *
- * @param settings The dialog settings.
- */
- public void persistValues(IDialogSettings settings);
-
- /**
- * Get the preferred size of the part.
- *
- * @return The preferred size or null.
- */
- public Point getPreferredSize();
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.interfaces;
+
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.utils.AbstractSearchable;
+import org.eclipse.tcf.te.ui.utils.CompositeSearchable;
+
+/**
+ * This interface should be implemented or adapted by the tree nodes which
+ * should provide find function. Subclass is encouraged to inherit AbstractSearchable
+ * which provides basic implementation methods, or CompositeSearchable which combines
+ * several simple searchable implementations into a complexed implementation.
+ *
+ * @see AbstractSearchable
+ * @see CompositeSearchable
+ */
+public interface ISearchable {
+ /**
+ * Get the title text of the searching dialog for
+ * this element.
+ *
+ * @param rootElement The root element where the search is started.
+ * @return A title of the search dialog
+ */
+ public String getSearchTitle(Object rootElement);
+
+ /**
+ * Get the description message that will be displayed
+ * in the title area of the searching dialog with
+ * the given root element.
+ *
+ * @param rootElement The root element where the search is started.
+ * @return The message to describe the searching.
+ */
+ public String getSearchMessage(Object rootElement);
+
+ /**
+ * Get a text to be used during searching process.
+ *
+ * @param element The element to searched.
+ * @return A description text used in searching.
+ */
+ public String getElementText(Object element);
+
+ /**
+ * Create the part in the searching dialog where the user
+ * enters the common matching rule used in searching.
+ *
+ * @param parent The parent composite of this option part.
+ */
+ public void createCommonPart(Composite parent);
+
+ /**
+ * Create the part in the searching dialog where the user
+ * enters the advanced matching rule used in searching.
+ *
+ * @param parent The parent composite of this option part.
+ */
+ public void createAdvancedPart(Composite parent);
+
+ /**
+ * Get a searching matcher object to test if a tree node matches
+ * the current conditions entered by the user.
+ *
+ * @return The matcher object which implements ISearchMatcher for matching.
+ */
+ public ISearchMatcher getMatcher();
+
+ /**
+ * If the current input from the user is valid for a searching process.
+ *
+ * @return true if the input is valid or else false.
+ */
+ public boolean isInputValid();
+
+ /**
+ * Add an option listener that handles the option changed event.
+ *
+ * @param listener The listener to be added.
+ */
+ public void addOptionListener(IOptionListener listener);
+
+ /**
+ * Remove an option listener
+ *
+ * @param listener The listener to be removed.
+ */
+ public void removeOptionListener(IOptionListener listener);
+
+ /**
+ * Restore the part's values from its parent settings.
+ *
+ * @param settings The dialog settings.
+ */
+ public void restoreValues(IDialogSettings settings);
+
+ /**
+ * Persist the part's values to its parent settings.
+ * Called when the searching dialog is closed.
+ *
+ * @param settings The dialog settings.
+ */
+ public void persistValues(IDialogSettings settings);
+
+ /**
+ * Get the preferred size of the part.
+ *
+ * @return The preferred size or null.
+ */
+ public Point getPreferredSize();
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java
index f789ee909..40fe55858 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/internal/utils/TreeViewerSearchDialog.java
@@ -65,6 +65,8 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
TreeViewer fViewer;
// The searchable of the currently selected element.
ISearchable fSearchable;
+ // The root element
+ private Object rootElement;
/**
* Create a searching dialog using the default algorithm and
@@ -82,8 +84,8 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
Assert.isNotNull(fSearchable);
fSearcher = new SearchEngine(fViewer, isDepthFirst(), fSearchable, rootPath);
fSearchable.addOptionListener(this);
- Object element = rootPath.getLastSegment();
- String text = fSearchable.getSearchMessage(element);
+ rootElement = rootPath.getLastSegment();
+ String text = fSearchable.getSearchMessage(rootElement);
if (text != null) {
setDefaultMessage(text, NONE);
}
@@ -199,7 +201,7 @@ public class TreeViewerSearchDialog extends CustomTitleAreaDialog implements ISe
fPmPart.setLayoutData(data);
fPmPart.setVisible(false);
- String title = fSearchable.getSearchTitle();
+ String title = fSearchable.getSearchTitle(rootElement);
getShell().setText(title);
this.setTitle(title);
}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
index 38e4620e0..7381d8631 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/AbstractSearchable.java
@@ -1,128 +1,127 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.utils;
-
-import org.eclipse.core.commands.common.EventManager;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
-import org.eclipse.tcf.te.ui.interfaces.ISearchable;
-
-/**
- * The base class that implements ISearchable and provide basic implementation method
- * for adding and removing listeners.
- */
-public abstract class AbstractSearchable extends EventManager implements ISearchable {
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#addOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
- */
- @Override
- public void addOptionListener(IOptionListener listener) {
- super.addListenerObject(listener);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#removeOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
- */
- @Override
- public void removeOptionListener(IOptionListener listener) {
- super.removeListenerObject(listener);
- }
-
- /**
- * Fire an option changed event to the listeners to notify
- * the current option input has changed.
- */
- protected void fireOptionChanged() {
- Object[] listeners = super.getListeners();
- for(Object listener : listeners) {
- ((IOptionListener)listener).optionChanged(null);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createCommonPart(Composite parent) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createAdvancedPart(Composite parent) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle()
- */
- @Override
- public String getSearchTitle() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
- */
- @Override
- public String getSearchMessage(Object rootElement) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void restoreValues(IDialogSettings settings) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void persistValues(IDialogSettings settings) {
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
- */
- @Override
- public String getElementText(Object element) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getPreferredSize()
- */
- @Override
- public Point getPreferredSize() {
- return null;
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.utils;
+
+import org.eclipse.core.commands.common.EventManager;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+
+/**
+ * The base class that implements ISearchable and provide basic implementation method
+ * for adding and removing listeners.
+ */
+public abstract class AbstractSearchable extends EventManager implements ISearchable {
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#addOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
+ */
+ @Override
+ public void addOptionListener(IOptionListener listener) {
+ super.addListenerObject(listener);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#removeOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
+ */
+ @Override
+ public void removeOptionListener(IOptionListener listener) {
+ super.removeListenerObject(listener);
+ }
+
+ /**
+ * Fire an option changed event to the listeners to notify
+ * the current option input has changed.
+ */
+ protected void fireOptionChanged() {
+ Object[] listeners = super.getListeners();
+ for(Object listener : listeners) {
+ ((IOptionListener)listener).optionChanged(null);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createCommonPart(Composite parent) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createAdvancedPart(Composite parent) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ return true;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchTitle(java.lang.Object)
+ */
+ @Override
+ public String getSearchTitle(Object rootElement) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getSearchMessage(java.lang.Object)
+ */
+ @Override
+ public String getSearchMessage(Object rootElement) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void restoreValues(IDialogSettings settings) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void persistValues(IDialogSettings settings) {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getElementText(java.lang.Object)
+ */
+ @Override
+ public String getElementText(Object element) {
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getPreferredSize()
+ */
+ @Override
+ public Point getPreferredSize() {
+ return null;
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
index 0280059b5..abd8dd34c 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/utils/CompositeSearchable.java
@@ -1,213 +1,221 @@
-/*******************************************************************************
- * 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
- *
- * Contributors:
- * Wind River Systems - initial API and implementation
- *******************************************************************************/
-package org.eclipse.tcf.te.ui.utils;
-
-import org.eclipse.core.runtime.Assert;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
-import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
-import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
-import org.eclipse.tcf.te.ui.interfaces.ISearchable;
-import org.eclipse.tcf.te.ui.nls.Messages;
-import org.eclipse.ui.forms.events.ExpansionEvent;
-import org.eclipse.ui.forms.events.IExpansionListener;
-import org.eclipse.ui.forms.widgets.ExpandableComposite;
-import org.eclipse.ui.forms.widgets.Section;
-
-/**
- * A utility searchable class that could combine several searchable objects and thus
- * divide a complex searchable into several simple ones.
- */
-public abstract class CompositeSearchable implements ISearchable {
- // The delegating searchables
- private ISearchable[] searchables;
-
- /**
- * Constructor with several delegating searchables.
- *
- * @param searchables Delegating searchable objects.
- */
- public CompositeSearchable(ISearchable... searchables) {
- Assert.isNotNull(searchables);
- this.searchables = searchables;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createCommonPart(Composite parent) {
- for(ISearchable searchable : searchables) {
- searchable.createCommonPart(parent);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
- */
- @Override
- public void createAdvancedPart(Composite parent) {
- Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
- section.setText(Messages.TreeViewerSearchDialog_AdvancedOptions);
- section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
- GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
- section.setLayoutData(layoutData);
-
- final Composite advancedPart = new Composite(section, SWT.NONE);
- advancedPart.setLayout(new GridLayout());
- advancedPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- advancedPart.setBackground(section.getBackground());
- section.setClient(advancedPart);
-
- section.addExpansionListener(new IExpansionListener(){
- @Override
- public void expansionStateChanging(ExpansionEvent e) {
- }
-
- @Override
- public void expansionStateChanged(ExpansionEvent e) {
- boolean state = e.getState();
- int client_height = advancedPart.getSize().y;
- Shell shell = advancedPart.getShell();
- Point p = shell.getSize();
- p.y = state ? p.y + client_height : p.y - client_height;
- shell.setSize(p.x, p.y);
- }});
- for(ISearchable searchable : searchables) {
- searchable.createAdvancedPart(advancedPart);
- }
- }
-
- /**
- * A composite matcher that could combine several simple matchers
- * into a complex matcher object.
- */
- static class CompositeMatcher implements ISearchMatcher {
- // The delegating matchers.
- private ISearchMatcher[] matchers;
- /**
- * The constructors.
- */
- public CompositeMatcher(ISearchMatcher[] matchers) {
- Assert.isNotNull(matchers);
- this.matchers = matchers;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
- */
- @Override
- public boolean match(Object element) {
- for(ISearchMatcher matcher : matchers) {
- if(!matcher.match(element)) {
- return false;
- }
- }
- return true;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
- */
- @Override
- public ISearchMatcher getMatcher() {
- ISearchMatcher[] matchers = new ISearchMatcher[searchables.length];
- for (int i = 0; i < searchables.length; i++) {
- matchers[i] = searchables[i].getMatcher();
- }
- return new CompositeMatcher(matchers);
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#isInputValid()
- */
- @Override
- public boolean isInputValid() {
- boolean valid = true;
- for(ISearchable searchable : searchables) {
- valid &= searchable.isInputValid();
- }
- return valid;
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#addOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
- */
- @Override
- public void addOptionListener(IOptionListener listener) {
- for(ISearchable searchable : searchables) {
- searchable.addOptionListener(listener);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void restoreValues(IDialogSettings settings) {
- for(ISearchable searchable : searchables) {
- searchable.restoreValues(settings);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
- */
- @Override
- public void persistValues(IDialogSettings settings) {
- for(ISearchable searchable : searchables) {
- searchable.persistValues(settings);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#removeOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
- */
- @Override
- public void removeOptionListener(IOptionListener listener) {
- for(ISearchable searchable : searchables) {
- searchable.removeOptionListener(listener);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getPreferredSize()
- */
- @Override
- public Point getPreferredSize() {
- Point size = null;
- for(ISearchable searchable : searchables) {
- Point prefSize = searchable.getPreferredSize();
- if(prefSize != null) {
- if(size == null)
- size = new Point(0, 0);
- size.x = Math.max(size.x, prefSize.x);
- size.y = size.y + prefSize.y;
- }
- }
- return size;
- }
-}
+/*******************************************************************************
+ * 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
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.tcf.te.ui.utils;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.tcf.te.ui.forms.FormLayoutFactory;
+import org.eclipse.tcf.te.ui.interfaces.IOptionListener;
+import org.eclipse.tcf.te.ui.interfaces.ISearchMatcher;
+import org.eclipse.tcf.te.ui.interfaces.ISearchable;
+import org.eclipse.tcf.te.ui.nls.Messages;
+import org.eclipse.ui.forms.events.ExpansionEvent;
+import org.eclipse.ui.forms.events.IExpansionListener;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * A utility searchable class that could combine several searchable objects and thus
+ * divide a complex searchable into several simple ones.
+ */
+public abstract class CompositeSearchable implements ISearchable {
+ // The delegating searchables
+ private ISearchable[] searchables;
+
+ /**
+ * Constructor.
+ */
+ public CompositeSearchable() {
+ super();
+ }
+
+ /**
+ * Set the delegating searchable objects.
+ * <p>
+ * This method needs to be called before {@link #createCommonPart(Composite)} is called!
+ *
+ * @param searchables Delegating searchable objects.
+ */
+ public void setSearchables(ISearchable... searchables) {
+ Assert.isNotNull(searchables);
+ this.searchables = searchables;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createCommonPart(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createCommonPart(Composite parent) {
+ Assert.isNotNull(searchables, "setSearchables must be called before!"); //$NON-NLS-1$
+ for (ISearchable searchable : searchables) {
+ searchable.createCommonPart(parent);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#createAdvancedPart(org.eclipse.swt.widgets.Composite)
+ */
+ @Override
+ public void createAdvancedPart(Composite parent) {
+ Section section = new Section(parent, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT);
+ section.setText(Messages.TreeViewerSearchDialog_AdvancedOptions);
+ section.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
+ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ section.setLayoutData(layoutData);
+
+ final Composite advancedPart = new Composite(section, SWT.NONE);
+ advancedPart.setLayout(new GridLayout());
+ advancedPart.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ advancedPart.setBackground(section.getBackground());
+ section.setClient(advancedPart);
+
+ section.addExpansionListener(new IExpansionListener(){
+ @Override
+ public void expansionStateChanging(ExpansionEvent e) {
+ }
+
+ @Override
+ public void expansionStateChanged(ExpansionEvent e) {
+ boolean state = e.getState();
+ int client_height = advancedPart.getSize().y;
+ Shell shell = advancedPart.getShell();
+ Point p = shell.getSize();
+ p.y = state ? p.y + client_height : p.y - client_height;
+ shell.setSize(p.x, p.y);
+ }});
+ for(ISearchable searchable : searchables) {
+ searchable.createAdvancedPart(advancedPart);
+ }
+ }
+
+ /**
+ * A composite matcher that could combine several simple matchers
+ * into a complex matcher object.
+ */
+ static class CompositeMatcher implements ISearchMatcher {
+ // The delegating matchers.
+ private ISearchMatcher[] matchers;
+ /**
+ * The constructors.
+ */
+ public CompositeMatcher(ISearchMatcher[] matchers) {
+ Assert.isNotNull(matchers);
+ this.matchers = matchers;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchMatcher#match(java.lang.Object)
+ */
+ @Override
+ public boolean match(Object element) {
+ for(ISearchMatcher matcher : matchers) {
+ if(!matcher.match(element)) {
+ return false;
+ }
+ }
+ return true;
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getMatcher()
+ */
+ @Override
+ public ISearchMatcher getMatcher() {
+ ISearchMatcher[] matchers = new ISearchMatcher[searchables.length];
+ for (int i = 0; i < searchables.length; i++) {
+ matchers[i] = searchables[i].getMatcher();
+ }
+ return new CompositeMatcher(matchers);
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#isInputValid()
+ */
+ @Override
+ public boolean isInputValid() {
+ boolean valid = true;
+ for(ISearchable searchable : searchables) {
+ valid &= searchable.isInputValid();
+ }
+ return valid;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#addOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
+ */
+ @Override
+ public void addOptionListener(IOptionListener listener) {
+ for(ISearchable searchable : searchables) {
+ searchable.addOptionListener(listener);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#restoreValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void restoreValues(IDialogSettings settings) {
+ for(ISearchable searchable : searchables) {
+ searchable.restoreValues(settings);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#persistValues(org.eclipse.jface.dialogs.IDialogSettings)
+ */
+ @Override
+ public void persistValues(IDialogSettings settings) {
+ for(ISearchable searchable : searchables) {
+ searchable.persistValues(settings);
+ }
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#removeOptionListener(org.eclipse.tcf.te.ui.interfaces.IOptionListener)
+ */
+ @Override
+ public void removeOptionListener(IOptionListener listener) {
+ for(ISearchable searchable : searchables) {
+ searchable.removeOptionListener(listener);
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.ISearchable#getPreferredSize()
+ */
+ @Override
+ public Point getPreferredSize() {
+ Point size = null;
+ for(ISearchable searchable : searchables) {
+ Point prefSize = searchable.getPreferredSize();
+ if(prefSize != null) {
+ if(size == null)
+ size = new Point(0, 0);
+ size.x = Math.max(size.x, prefSize.x);
+ size.y = size.y + prefSize.y;
+ }
+ }
+ return size;
+ }
+}

Back to the top