Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Schwarz2012-11-29 04:05:06 -0500
committerTobias Schwarz2012-11-29 04:06:22 -0500
commita53e72105fa2d1adc6beb9d4a546a224bde8c516 (patch)
tree382e0fa22064920e02fc48ad949eb6eb723978fd
parent230a088674b8c456739baec26486d1a5994c0245 (diff)
downloadorg.eclipse.tcf-a53e72105fa2d1adc6beb9d4a546a224bde8c516.tar.gz
org.eclipse.tcf-a53e72105fa2d1adc6beb9d4a546a224bde8c516.tar.xz
org.eclipse.tcf-a53e72105fa2d1adc6beb9d4a546a224bde8c516.zip
[Taregt Explorer] introduce IPropertiesHandlerDelegate to be able to
switch to correct editor page and set the right selection
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/handler/PropertiesHandlerDelegate.java71
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/services/UIService.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF6
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/PropertiesHandlerDelegate.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml1
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java25
-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.xml15
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/PropertiesHandlerDelegate.java55
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java38
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelPropertiesHandlerDelegate.java36
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/editor/Editor.java8
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java13
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/PropertiesCommandHandler.java14
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/handler/IPropertiesHandlerDelegate.java33
19 files changed, 472 insertions, 8 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
index b74a9985e..5bad8a2cf 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/META-INF/MANIFEST.MF
@@ -45,6 +45,7 @@ Export-Package: org.eclipse.tcf.te.launch.ui.activator;x-internal:=true,
org.eclipse.tcf.te.launch.ui.nls;x-internal:=true,
org.eclipse.tcf.te.launch.ui.properties,
org.eclipse.tcf.te.launch.ui.selection,
+ org.eclipse.tcf.te.launch.ui.services,
org.eclipse.tcf.te.launch.ui.tabs,
org.eclipse.tcf.te.launch.ui.tabs.filetransfers,
org.eclipse.tcf.te.launch.ui.tabs.launchcontext,
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
index df7d82d3c..198bf65c5 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/plugin.xml
@@ -28,6 +28,21 @@
</propertyTester>
</extension>
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ class="org.eclipse.tcf.te.launch.ui.services.UIService"
+ id="org.eclipse.tcf.te.launch.uiservice">
+ <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.IUIService"/>
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchModel"/>
+ <instanceof value="org.eclipse.tcf.te.launch.ui.model.LaunchNode"/>
+ </or>
+ </enablement>
+ </service>
+ </extension>
+
<!-- Editor page contributions -->
<extension point="org.eclipse.tcf.te.ui.views.editorPages">
<editorPage
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/handler/PropertiesHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/handler/PropertiesHandlerDelegate.java
new file mode 100644
index 000000000..d636806b7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/handler/PropertiesHandlerDelegate.java
@@ -0,0 +1,71 @@
+/**
+ * PropertiesHandlerDelegate.java
+ * Created on Jan 25, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.launch.ui.handler;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tcf.te.launch.ui.internal.pages.LaunchExplorerEditorPage;
+import org.eclipse.tcf.te.launch.ui.model.LaunchModel;
+import org.eclipse.tcf.te.launch.ui.model.LaunchNode;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.swt.DisplayUtil;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.tcf.te.ui.views.editor.EditorInput;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * Launch properties command handler implementation.
+ */
+public class PropertiesHandlerDelegate implements IPropertiesHandlerDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate#getEditorInput(java.lang.Object)
+ */
+ @Override
+ public IEditorInput getEditorInput(Object element) {
+ if (element instanceof LaunchModel) {
+ return new EditorInput(((LaunchModel)element).getModelRoot());
+ }
+ if (element instanceof LaunchNode) {
+ return new EditorInput(((LaunchNode)element).getModel().getModelRoot());
+ }
+ return new EditorInput(element);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate#postOpenProperties(org.eclipse.ui.IEditorPart, java.lang.Object)
+ */
+ @Override
+ public void postOpenProperties(IEditorPart editor, final Object element) {
+ if (editor instanceof FormEditor) {
+ final FormEditor formEditor = (FormEditor)editor;
+ DisplayUtil.safeAsyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IFormPage page = formEditor.setActivePage("org.eclipse.tcf.te.launch.ui.LaunchEditorPage"); //$NON-NLS-1$
+ // If the element is a context node, select the node
+ if (page != null && element instanceof LaunchModel || element instanceof LaunchNode) {
+ Viewer viewer = ((LaunchExplorerEditorPage)page).getTreeControl().getViewer();
+ if (viewer != null) {
+ viewer.setSelection(new StructuredSelection(element), true);
+ }
+ }
+ else if (formEditor instanceof Editor) {
+ ((Editor)formEditor).setActivePage(0);
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/services/UIService.java b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/services/UIService.java
new file mode 100644
index 000000000..6b8fb49ba
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.launch.ui/src/org/eclipse/tcf/te/launch/ui/services/UIService.java
@@ -0,0 +1,38 @@
+/**
+ * UIService.java
+ * Created on Nov 15, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.launch.ui.services;
+
+import org.eclipse.tcf.te.launch.ui.handler.PropertiesHandlerDelegate;
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
+
+/**
+ * UI service implementation.
+ */
+public class UIService extends AbstractService implements IUIService {
+ private final IPropertiesHandlerDelegate propertiesHandlerDelegate = new PropertiesHandlerDelegate();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IUIService#getDelegate(java.lang.Object, java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <V> V getDelegate(Object context, Class<? extends V> clazz) {
+
+ if (IPropertiesHandlerDelegate.class.isAssignableFrom(clazz)) {
+ return (V) propertiesHandlerDelegate;
+ }
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
index 0e3b7fb2d..d103a3b1e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/META-INF/MANIFEST.MF
@@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.compare;bundle-version="3.5.300",
org.eclipse.tcf.te.ui.forms;bundle-version="1.1.0",
org.eclipse.tcf.te.ui.swt;bundle-version="1.1.0",
org.eclipse.tcf.te.ui.views;bundle-version="1.1.0",
- org.eclipse.tcf.te.ui.controls;bundle-version="1.1.0"
+ org.eclipse.tcf.te.ui.controls;bundle-version="1.1.0",
+ org.eclipse.tcf.te.runtime.services;bundle-version="1.1.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
@@ -53,4 +54,5 @@ Export-Package: org.eclipse.tcf.te.tcf.filesystem.ui.activator;x-internal:=true,
org.eclipse.tcf.te.tcf.filesystem.ui.internal.tabbed;x-internal:=true,
org.eclipse.tcf.te.tcf.filesystem.ui.internal.testers;x-internal:=true,
org.eclipse.tcf.te.tcf.filesystem.ui.internal.wizards;x-internal:=true,
- org.eclipse.tcf.te.tcf.filesystem.ui.nls;x-internal:=true
+ org.eclipse.tcf.te.tcf.filesystem.ui.nls;x-internal:=true,
+ org.eclipse.tcf.te.tcf.filesystem.ui.services
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
index 05657d42a..bd880dc43 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/plugin.xml
@@ -95,6 +95,21 @@
</commonFilter>
</extension>
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ class="org.eclipse.tcf.te.tcf.filesystem.ui.services.UIService"
+ id="org.eclipse.tcf.te.tcf.filesytsem.uiservice">
+ <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.IUIService"/>
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel"/>
+ </or>
+ </enablement>
+ </service>
+ </extension>
+
<!-- Editor page contributions -->
<extension point="org.eclipse.tcf.te.ui.views.editorPages">
<editorPage
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/PropertiesHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/PropertiesHandlerDelegate.java
new file mode 100644
index 000000000..e8354e74a
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/internal/handlers/PropertiesHandlerDelegate.java
@@ -0,0 +1,55 @@
+/**
+ * PropertiesHandlerDelegate.java
+ * Created on Jan 25, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSModel;
+import org.eclipse.tcf.te.tcf.filesystem.core.model.FSTreeNode;
+import org.eclipse.tcf.te.tcf.filesystem.ui.internal.pages.FSExplorerEditorPage;
+import org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerModelPropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.swt.DisplayUtil;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * Systems context node properties command handler implementation.
+ */
+public class PropertiesHandlerDelegate extends AbstractPeerModelPropertiesHandlerDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate#postOpenProperties(org.eclipse.ui.IEditorPart, java.lang.Object)
+ */
+ @Override
+ public void postOpenProperties(IEditorPart editor, final Object element) {
+ if (editor instanceof FormEditor) {
+ final FormEditor formEditor = (FormEditor)editor;
+ DisplayUtil.safeAsyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IFormPage page = formEditor.setActivePage("org.eclipse.tcf.te.tcf.filesystem.FSExplorerEditorPage"); //$NON-NLS-1$
+ // If the element is a context node, select the node
+ if (page != null && element instanceof FSTreeNode || element instanceof FSModel) {
+ Viewer viewer = ((FSExplorerEditorPage)page).getTreeControl().getViewer();
+ if (viewer != null) {
+ viewer.setSelection(new StructuredSelection(element), true);
+ }
+ }
+ else if (formEditor instanceof Editor) {
+ ((Editor)formEditor).setActivePage(0);
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java
new file mode 100644
index 000000000..5acc565e6
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.filesystem.ui/src/org/eclipse/tcf/te/tcf/filesystem/ui/services/UIService.java
@@ -0,0 +1,38 @@
+/**
+ * UIService.java
+ * Created on Nov 15, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.filesystem.ui.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.filesystem.ui.internal.handlers.PropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
+
+/**
+ * UI service implementation.
+ */
+public class UIService extends AbstractService implements IUIService {
+ private final IPropertiesHandlerDelegate propertiesHandlerDelegate = new PropertiesHandlerDelegate();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IUIService#getDelegate(java.lang.Object, java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <V> V getDelegate(Object context, Class<? extends V> clazz) {
+
+ if (IPropertiesHandlerDelegate.class.isAssignableFrom(clazz)) {
+ return (V) propertiesHandlerDelegate;
+ }
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
index 4fba36f01..00f5fe277 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/plugin.xml
@@ -27,6 +27,7 @@
adaptableType="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModelProvider"
class="org.eclipse.tcf.te.tcf.locator.internal.adapters.AdapterFactory">
<adapter type="org.eclipse.tcf.te.runtime.persistence.interfaces.IPersistableURIProvider"/>
+ <adapter type="org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel"/>
</factory>
</extension>
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
index 2fb8a344a..1f068b73e 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.locator/src/org/eclipse/tcf/te/tcf/locator/internal/adapters/AdapterFactory.java
@@ -32,7 +32,7 @@ public class AdapterFactory implements IAdapterFactory {
private final IPersistableURIProvider peerModelPersistableURIProvider = new PeerPersistableURIProvider();
private static final Class<?>[] CLASSES = new Class[] {
- IPersistableURIProvider.class
+ IPersistableURIProvider.class, IPeerModel.class
};
/* (non-Javadoc)
@@ -49,7 +49,8 @@ public class AdapterFactory implements IAdapterFactory {
if (IPersistableURIProvider.class.equals(adapterType)) {
return peerModelPersistableURIProvider;
}
- if (IPeerModel.class.equals(adapterType) && adaptableObject instanceof IPeer) {
+ if (IPeerModel.class.equals(adapterType)) {
+ if (adaptableObject instanceof IPeer) {
final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
final IPeer peer = (IPeer)adaptableObject;
@@ -72,6 +73,26 @@ public class AdapterFactory implements IAdapterFactory {
else Protocol.invokeAndWait(runnable);
return node.get();
+ }
+ else if (adaptableObject instanceof IPeerModel) {
+ return adaptableObject;
+ }
+ else if (adaptableObject instanceof IPeerModelProvider) {
+ final AtomicReference<IPeerModel> node = new AtomicReference<IPeerModel>();
+ final IPeerModelProvider provider = (IPeerModelProvider)adaptableObject;
+
+ Runnable runnable = new Runnable() {
+ @Override
+ public void run() {
+ node.set(provider.getPeerModel());
+ }
+ };
+
+ if (Protocol.isDispatchThread()) runnable.run();
+ else Protocol.invokeAndWait(runnable);
+
+ return node.get();
+ }
}
}
return null;
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 63b1bd855..50dcb0588 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
@@ -45,4 +45,5 @@ Export-Package: org.eclipse.tcf.te.tcf.processes.ui.activator;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.nls;x-internal:=true,
+ org.eclipse.tcf.te.tcf.processes.ui.services
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
index 06e641f0e..6b133ef1d 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/plugin.xml
@@ -34,6 +34,21 @@
</eventListener>
</extension>
+<!-- Service contributions -->
+ <extension point="org.eclipse.tcf.te.runtime.services.services">
+ <service
+ class="org.eclipse.tcf.te.tcf.processes.ui.services.UIService"
+ id="org.eclipse.tcf.te.tcf.processes.uiservice">
+ <serviceType class="org.eclipse.tcf.te.runtime.services.interfaces.IUIService"/>
+ <enablement>
+ <or>
+ <instanceof value="org.eclipse.tcf.te.tcf.processes.core.model.interfaces.runtime.IRuntimeModel"/>
+ <instanceof value="org.eclipse.tcf.te.tcf.processes.core.model.interfaces.IProcessContextNode"/>
+ </or>
+ </enablement>
+ </service>
+ </extension>
+
<!-- Eclipse core expressions property tester -->
<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/PropertiesHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/PropertiesHandlerDelegate.java
new file mode 100644
index 000000000..784b08334
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/handler/PropertiesHandlerDelegate.java
@@ -0,0 +1,55 @@
+/**
+ * PropertiesHandlerDelegate.java
+ * Created on Jan 25, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.processes.ui.handler;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+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.editor.ProcessMonitorEditorPage;
+import org.eclipse.tcf.te.tcf.ui.handler.AbstractPeerModelPropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.swt.DisplayUtil;
+import org.eclipse.tcf.te.ui.views.editor.Editor;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.editor.IFormPage;
+
+/**
+ * Processes properties command handler implementation.
+ */
+public class PropertiesHandlerDelegate extends AbstractPeerModelPropertiesHandlerDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate#postOpenProperties(org.eclipse.ui.IEditorPart, java.lang.Object)
+ */
+ @Override
+ public void postOpenProperties(IEditorPart editor, final Object element) {
+ if (editor instanceof FormEditor) {
+ final FormEditor formEditor = (FormEditor)editor;
+ DisplayUtil.safeAsyncExec(new Runnable() {
+ @Override
+ public void run() {
+ IFormPage page = formEditor.setActivePage("org.eclipse.tcf.te.tcf.processes.ui.ProcessExplorerEditorPage"); //$NON-NLS-1$
+ // If the element is a context node, select the node
+ if (page != null && (element instanceof IRuntimeModel || element instanceof IProcessContextNode)) {
+ Viewer viewer = ((ProcessMonitorEditorPage)page).getTreeControl().getViewer();
+ if (viewer != null) {
+ viewer.setSelection(new StructuredSelection(element), true);
+ }
+ }
+ else if (formEditor instanceof Editor) {
+ ((Editor)formEditor).setActivePage(0);
+ }
+ }
+ });
+ }
+ }
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java
new file mode 100644
index 000000000..600b5498f
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.processes.ui/src/org/eclipse/tcf/te/tcf/processes/ui/services/UIService.java
@@ -0,0 +1,38 @@
+/**
+ * UIService.java
+ * Created on Nov 15, 2012
+ *
+ * Copyright (c) 2012 Wind River Systems, Inc.
+ *
+ * The right to copy, distribute, modify, or otherwise make use
+ * of this software may be licensed only pursuant to the terms
+ * of an applicable Wind River license agreement.
+ */
+package org.eclipse.tcf.te.tcf.processes.ui.services;
+
+import org.eclipse.tcf.te.runtime.services.AbstractService;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.tcf.processes.ui.handler.PropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
+
+/**
+ * UI service implementation.
+ */
+public class UIService extends AbstractService implements IUIService {
+ private final IPropertiesHandlerDelegate propertiesHandlerDelegate = new PropertiesHandlerDelegate();
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.runtime.services.interfaces.IUIService#getDelegate(java.lang.Object, java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ @Override
+ public <V> V getDelegate(Object context, Class<? extends V> clazz) {
+
+ if (IPropertiesHandlerDelegate.class.isAssignableFrom(clazz)) {
+ return (V) propertiesHandlerDelegate;
+ }
+
+ return null;
+ }
+
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelPropertiesHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelPropertiesHandlerDelegate.java
new file mode 100644
index 000000000..0b87ab572
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.tcf.ui/src/org/eclipse/tcf/te/tcf/ui/handler/AbstractPeerModelPropertiesHandlerDelegate.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 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.ui.handler;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.tcf.te.tcf.locator.interfaces.nodes.IPeerModel;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
+import org.eclipse.tcf.te.ui.views.editor.EditorInput;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * AbstractPeerModelPropertiesHandlerDelegate
+ */
+public abstract class AbstractPeerModelPropertiesHandlerDelegate implements IPropertiesHandlerDelegate {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate#getEditorInput(java.lang.Object)
+ */
+ @Override
+ public IEditorInput getEditorInput(Object element) {
+ IPeerModel model = (IPeerModel)Platform.getAdapterManager().getAdapter(element, IPeerModel.class);
+ if (model == null && element instanceof IAdaptable) {
+ model = (IPeerModel)((IAdaptable)element).getAdapter(IPeerModel.class);
+ }
+ return new EditorInput(model != null ? model : element);
+ }
+}
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 287a94bd7..cabd41bb8 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
@@ -121,6 +121,14 @@ public final class Editor extends FormEditor implements IPersistableEditor, ITab
return null;
}
+ /* (non-Javadoc)
+ * @see org.eclipse.ui.forms.editor.FormEditor#setActivePage(int)
+ */
+ @Override
+ public void setActivePage(int pageIndex) {
+ super.setActivePage(pageIndex);
+ }
+
/**
* Update the editor page list. Pages which are not longer valid
* will be removed and pages now being valid gets added.
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
index f28294022..4373dece0 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/expressions/PropertyTester.java
@@ -9,6 +9,9 @@
*******************************************************************************/
package org.eclipse.tcf.te.ui.views.expressions;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
import org.eclipse.tcf.te.ui.views.editor.EditorInput;
import org.eclipse.tcf.te.ui.views.extensions.EditorPageBindingExtensionPointManager;
import org.eclipse.ui.IEditorInput;
@@ -28,7 +31,15 @@ public class PropertyTester extends org.eclipse.core.expressions.PropertyTester
if ("hasApplicableEditorBindings".equals(property)) { //$NON-NLS-1$
// Create a fake editor input object
IEditorInput input = new EditorInput(receiver);
- return (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0));
+ boolean result = (expectedValue != null ? expectedValue : Boolean.TRUE).equals(Boolean.valueOf(EditorPageBindingExtensionPointManager.getInstance().getApplicableEditorPageBindings(input).length > 0));
+
+ if (!result) {
+ IUIService service = ServiceManager.getInstance().getService(receiver, IUIService.class);
+ IPropertiesHandlerDelegate delegate = service != null ? service.getDelegate(receiver, IPropertiesHandlerDelegate.class) : null;
+ result = delegate != null;
+ }
+
+ return result;
}
return false;
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/PropertiesCommandHandler.java b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/PropertiesCommandHandler.java
index 8ac1f89be..47bb06415 100644
--- a/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/PropertiesCommandHandler.java
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui.views/src/org/eclipse/tcf/te/ui/views/handler/PropertiesCommandHandler.java
@@ -17,11 +17,15 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IUIService;
+import org.eclipse.tcf.te.ui.interfaces.handler.IPropertiesHandlerDelegate;
import org.eclipse.tcf.te.ui.views.activator.UIPlugin;
import org.eclipse.tcf.te.ui.views.editor.EditorInput;
import org.eclipse.tcf.te.ui.views.interfaces.IUIConstants;
import org.eclipse.tcf.te.ui.views.nls.Messages;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
@@ -66,10 +70,16 @@ public class PropertiesCommandHandler extends AbstractHandler {
// Get the active page
IWorkbenchPage page = window.getActivePage();
// Create the editor input object
- IEditorInput input = new EditorInput(element);
+ IUIService service = ServiceManager.getInstance().getService(element, IUIService.class);
+ IPropertiesHandlerDelegate delegate = service != null ? service.getDelegate(element, IPropertiesHandlerDelegate.class) : null;
+ IEditorInput input = delegate != null ? delegate.getEditorInput(element) : new EditorInput(element);
try {
// Opens the Target Explorer properties editor
- page.openEditor(input, IUIConstants.ID_EDITOR);
+ IEditorPart editor = page.openEditor(input, IUIConstants.ID_EDITOR);
+ // Lookup the ui service for post action
+ if (delegate != null) {
+ delegate.postOpenProperties(editor, element);
+ }
} catch (PartInitException e) {
IStatus status = new Status(IStatus.ERROR, UIPlugin.getUniqueIdentifier(),
Messages.PropertiesCommandHandler_error_initPartFailed, e);
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/handler/IPropertiesHandlerDelegate.java b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/handler/IPropertiesHandlerDelegate.java
new file mode 100644
index 000000000..42ef675ad
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.ui/src/org/eclipse/tcf/te/ui/interfaces/handler/IPropertiesHandlerDelegate.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 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.handler;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ * IPropertiesHandlerDelegate
+ */
+public interface IPropertiesHandlerDelegate {
+
+ /**
+ * Get a valid editor input for the given element.
+ * @param element The selected element.
+ * @return The editor input.
+ */
+ public IEditorInput getEditorInput(Object element);
+
+ /**
+ * Action that should be done after the properties were opened.
+ * @param element The selected element.
+ */
+ public void postOpenProperties(IEditorPart editor, Object element);
+}

Back to the top