Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUwe Stieber2012-10-02 06:31:54 -0400
committerUwe Stieber2012-10-02 06:31:54 -0400
commitb4954feb594b8659a1553f0464bdae866fdbfb3a (patch)
tree2a4b2a9a27530d877bcbb7fb3b1bf00b9ca7fba6 /target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src
parentd56419ae214ef1795a330ae510f7587ccac495f2 (diff)
downloadorg.eclipse.tcf-b4954feb594b8659a1553f0464bdae866fdbfb3a.tar.gz
org.eclipse.tcf-b4954feb594b8659a1553f0464bdae866fdbfb3a.tar.xz
org.eclipse.tcf-b4954feb594b8659a1553f0464bdae866fdbfb3a.zip
Target Explorer: Bug 377506 - [UI] "Show In > Properties" is visible for category nodes
Diffstat (limited to 'target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src')
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IMenuService.java29
-rw-r--r--target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/MenuServicePropertyTester.java42
2 files changed, 71 insertions, 0 deletions
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IMenuService.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IMenuService.java
new file mode 100644
index 000000000..7b8da18c1
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/interfaces/IMenuService.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.runtime.services.interfaces;
+
+/**
+ * Menu services.
+ * <p>
+ * Allows to control specific menu contributions for a selection.
+ */
+public interface IMenuService extends IService {
+
+ /**
+ * Tests if or if not the menu contribution identified by the given id is
+ * visible for the given context.
+ *
+ * @param context The context. Must be not <code>null</code>.
+ * @param contributionID The contribution ID. Must be not <code>null</code>.
+ *
+ * @return <code>True</code> if the contribution is visible, <code>false</code> otherwise.
+ */
+ public boolean isVisible(Object context, String contributionID);
+}
diff --git a/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/MenuServicePropertyTester.java b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/MenuServicePropertyTester.java
new file mode 100644
index 000000000..6c2f9e8f7
--- /dev/null
+++ b/target_explorer/plugins/org.eclipse.tcf.te.runtime.services/src/org/eclipse/tcf/te/runtime/services/internal/MenuServicePropertyTester.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * Copyright (c) 2011 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.runtime.services.internal;
+
+import org.eclipse.tcf.te.runtime.services.ServiceManager;
+import org.eclipse.tcf.te.runtime.services.interfaces.IMenuService;
+
+
+/**
+ * Services plug-in property tester implementation.
+ */
+public class MenuServicePropertyTester extends org.eclipse.core.expressions.PropertyTester {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.core.expressions.IPropertyTester#test(java.lang.Object, java.lang.String, java.lang.Object[], java.lang.Object)
+ */
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ // Get the menu service instance for the given receiver
+ IMenuService service = ServiceManager.getInstance().getService(receiver, IMenuService.class);
+ if (service != null) {
+
+ // "isVisible": Checks if a given menu contribution shall be visible for the given receiver.
+ if ("isVisible".equals(property)) { //$NON-NLS-1$
+ // The menu contribution ID is the first argument
+ String contributionID = args.length > 0 && args[0] instanceof String ? (String)args[0] : null;
+ boolean isVisible = service.isVisible(receiver, contributionID);
+ return expectedValue instanceof Boolean ? ((Boolean)expectedValue).booleanValue() == isVisible : false;
+ }
+ }
+
+ return false;
+ }
+
+}

Back to the top