Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Bryzak2016-05-18 11:02:03 +0000
committerVictor Rubezhny2016-05-19 23:49:23 +0000
commit4de6e2d8e180a83f157e85bbf013a6e729e68016 (patch)
tree96d0f666952e807f10a3d93b9719b28020ae4da4
parentc81e38183401f84123ce927ad26b8d89d9d88b4e (diff)
downloadwebtools.jsdt-4de6e2d8e180a83f157e85bbf013a6e729e68016.tar.gz
webtools.jsdt-4de6e2d8e180a83f157e85bbf013a6e729e68016.tar.xz
webtools.jsdt-4de6e2d8e180a83f157e85bbf013a6e729e68016.zip
Bug 491480 Chromium Debug context menus enabled for everything
Change-Id: Ie624b629e54a429f238d18bbbcbafa8b722367e7 Signed-off-by: Shane Bryzak <sbryzak@redhat.com>
-rwxr-xr-xbundles/org.eclipse.wst.jsdt.chromium.debug.ui/plugin.xml14
-rw-r--r--bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapter.java68
-rw-r--r--bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapterFactory.java40
3 files changed, 122 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/plugin.xml b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/plugin.xml
index a5b7b6aad..34b1603cd 100755
--- a/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/plugin.xml
+++ b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/plugin.xml
@@ -200,6 +200,15 @@
commandId="org.eclipse.wst.jsdt.chromium.debug.ui.commands.Inspect"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>
</extension>
+
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.core.resources.mapping.ResourceMapping"
+ class="org.eclipse.wst.jsdt.chromium.debug.ui.actions.FileExtensionFilterAdapterFactory">
+ <adapter
+ type="org.eclipse.ui.IActionFilter"/>
+ </factory>
+ </extension>
<extension point="org.eclipse.ui.popupMenus">
<viewerContribution
@@ -317,6 +326,11 @@
objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
adaptable="true"
id="org.eclipse.wst.jsdt.chromium.debug.ui.ChromiumSourceFileActionsId">
+
+ <visibility>
+ <objectState name="fileExtension" value="js"/>
+ </visibility>
+
<menu id="org.eclipse.wst.jsdt.chromium.debug.ui.ChromiumSourceFileActionsId.MenuId"
label="%ChromiumSourceFileActionsId.menu.label"
>
diff --git a/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapter.java b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapter.java
new file mode 100644
index 000000000..75266e582
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapter.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat, Inc.
+ * 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:
+ * Red Hat Inc. - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+package org.eclipse.wst.jsdt.chromium.debug.ui.actions;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.ui.IActionFilter;
+
+/**
+ * This action filter is used to test the file extension for ResourceMapping objects. To use it you
+ * must first declare it in your plugin.xml:
+ *
+ * <extension point="org.eclipse.core.runtime.adapters">
+ * <factory
+ * adaptableType="org.eclipse.core.resources.mapping.ResourceMapping"
+ * class="org.eclipse.wst.jsdt.chromium.debug.ui.actions.FileExtensionFilterAdapterFactory">
+ * <adapter
+ * type="org.eclipse.ui.IActionFilter"/>
+ * </factory>
+ * </extension>
+ *
+ * Once that's done it may be used to filter as per the <visibility> element in the following example:
+ *
+ * <objectContribution
+ * objectClass="org.eclipse.core.resources.mapping.ResourceMapping"
+ * adaptable="true"
+ * id="org.eclipse.wst.jsdt.chromium.debug.ui.ExampleActionId">
+ *
+ * <visibility>
+ * <objectState name="fileExtension" value="js"/>
+ * </visibility>
+ *
+ * @author Shane Bryzak
+ */
+public class FileExtensionFilterAdapter implements IActionFilter {
+
+ private static final Object FILE_EXTENSION = "fileExtension";
+
+ private static FileExtensionFilterAdapter INSTANCE = new FileExtensionFilterAdapter();
+
+ private FileExtensionFilterAdapter() {}
+
+ @Override
+ public boolean testAttribute(Object target, String name, String value) {
+ if (target instanceof ResourceMapping) {
+ ResourceMapping obj = (ResourceMapping) target;
+
+ if (FILE_EXTENSION.equals(name) && obj.getModelObject() instanceof IFile) {
+ return value != null && value.toLowerCase().equals(((IFile) obj.getModelObject()).getFileExtension().toLowerCase());
+ }
+ }
+
+ return false;
+ }
+
+ public static FileExtensionFilterAdapter getInstance() {
+ return INSTANCE;
+ }
+}
diff --git a/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapterFactory.java b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapterFactory.java
new file mode 100644
index 000000000..67f21d50e
--- /dev/null
+++ b/bundles/org.eclipse.wst.jsdt.chromium.debug.ui/src/org/eclipse/wst/jsdt/chromium/debug/ui/actions/FileExtensionFilterAdapterFactory.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2016 Red Hat, Inc.
+ * 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:
+ * Red Hat Inc. - initial API and implementation and/or initial documentation
+ *******************************************************************************/
+
+/**
+ * An Adapter factory for providing a FileExtensionFilterAdapter instance.
+ *
+ * @author Shane Bryzak
+ */
+package org.eclipse.wst.jsdt.chromium.debug.ui.actions;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.ui.IActionFilter;
+
+public class FileExtensionFilterAdapterFactory implements IAdapterFactory {
+
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Object getAdapter(Object adaptableObject, Class adapterType) {
+ if (adapterType == IActionFilter.class)
+ return FileExtensionFilterAdapter.getInstance();
+
+ return null;
+ }
+
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ @Override
+ public Class[] getAdapterList() {
+ return new Class[] { IActionFilter.class };
+ }
+
+}

Back to the top