Author: scabanovich
Date: 2007-10-10 11:03:43 -0400 (Wed, 10 Oct 2007)
New Revision: 4097
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XLinkHelper.java
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XActionProvider.java
Log:
JBIDE-1064
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2007-10-10 15:02:43
UTC (rev 4096)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/META-INF/MANIFEST.MF 2007-10-10 15:03:43
UTC (rev 4097)
@@ -40,6 +40,7 @@
org.eclipse.jface,
org.eclipse.ui,
org.eclipse.ui.navigator,
+ org.eclipse.ui.navigator.resources,
org.eclipse.jst.j2ee.navigator.ui,
org.eclipse.help,
org.eclipse.jdt.launching,
Modified: trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml
===================================================================
--- trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2007-10-10 15:02:43 UTC (rev
4096)
+++ trunk/jst/plugins/org.jboss.tools.jst.web.ui/plugin.xml 2007-10-10 15:03:43 UTC (rev
4097)
@@ -370,6 +370,7 @@
<includes>
<contentExtension
pattern="org.jboss.tools.jst.web.ui.navigator.fileContent" />
<contentExtension
pattern="org.jboss.tools.jst.web.ui.navigator.projectContent" />
+ <contentExtension
pattern="org.jboss.tools.jst.web.ui.navigator.XLinkHelper"/>
</includes>
</viewerContentBinding>
</extension>
@@ -446,6 +447,25 @@
</navigatorContent>
</extension>
+ <extension
+ point="org.eclipse.ui.navigator.linkHelper">
+ <linkHelper
+ class="org.jboss.tools.jst.web.ui.navigator.XLinkHelper"
+ id="org.jboss.tools.jst.web.ui.navigator.XLinkHelper">
+ <selectionEnablement>
+ <or>
+ <instanceof
value="org.jboss.tools.common.model.XModelObject"/>
+ </or>
+ </selectionEnablement>
+ <editorInputEnablement>
+ <or>
+ <instanceof value="org.eclipse.ui.IFileEditorInput"/>
+ <instanceof
value="org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput"/>
+ </or>
+ </editorInputEnablement>
+ </linkHelper>
+ </extension>
+
<extension point="org.jboss.tools.common.model.classes">
<xclass id="org.jboss.tools.jst.web.ui.WebUiPlugin"
class="org.jboss.tools.jst.web.ui.WebUiPlugin"/>
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XActionProvider.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XActionProvider.java 2007-10-10
15:02:43 UTC (rev 4096)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XActionProvider.java 2007-10-10
15:03:43 UTC (rev 4097)
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.jface.action.IMenuManager;
@@ -26,12 +27,14 @@
import org.eclipse.ui.actions.ActionContext;
import org.eclipse.ui.actions.ActionFactory;
import org.eclipse.ui.navigator.CommonActionProvider;
+import org.eclipse.ui.navigator.ICommonActionConstants;
import org.jboss.tools.common.meta.action.XAction;
import org.jboss.tools.common.meta.action.XActionList;
import org.jboss.tools.common.model.XModelObject;
import org.jboss.tools.common.model.ui.action.XModelObjectAction;
import org.jboss.tools.common.model.ui.action.XModelObjectActionList;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.FindObjectHelper;
public class XActionProvider extends CommonActionProvider {
@@ -50,6 +53,7 @@
registerAction(actionBars, o, "CopyActions.Copy",
ActionFactory.COPY.getId());
registerAction(actionBars, o, "CopyActions.Paste",
ActionFactory.PASTE.getId());
registerAction(actionBars, o, "CopyActions.Cut",
ActionFactory.CUT.getId());
+ actionBars.setGlobalActionHandler(ICommonActionConstants.OPEN, new XOpenAction(o));
}
}
@@ -137,3 +141,17 @@
}
}
+class XOpenAction extends Action {
+ XModelObject o;
+
+ public XOpenAction(XModelObject o) {
+ this.o = o;
+ }
+
+ public void run() {
+ if(o != null) {
+ FindObjectHelper.findModelObject(o, FindObjectHelper.IN_EDITOR_ONLY);
+ }
+ }
+
+}
Added:
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XLinkHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XLinkHelper.java
(rev 0)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.ui/src/org/jboss/tools/jst/web/ui/navigator/XLinkHelper.java 2007-10-10
15:03:43 UTC (rev 4097)
@@ -0,0 +1,47 @@
+package org.jboss.tools.jst.web.ui.navigator;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.navigator.ILinkHelper;
+import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.ui.editor.IModelObjectEditorInput;
+import org.jboss.tools.common.model.util.EclipseResourceUtil;
+import org.jboss.tools.common.model.util.FindObjectHelper;
+
+public class XLinkHelper implements ILinkHelper {
+
+ public XLinkHelper() {}
+
+ public void activateEditor(IWorkbenchPage page,
+ IStructuredSelection selection) {
+ if(selection == null || selection.isEmpty() || !(selection instanceof
IStructuredSelection)) {
+ return;
+ }
+ IStructuredSelection s = (IStructuredSelection)selection;
+ Object object = s.getFirstElement();
+ if(object instanceof XModelObject) {
+ XModelObject o = (XModelObject)object;
+ FindObjectHelper.findModelObject(o, FindObjectHelper.IN_EDITOR_ONLY);
+ }
+ }
+
+ public IStructuredSelection findSelection(IEditorInput input) {
+ if(input instanceof IModelObjectEditorInput) {
+ IModelObjectEditorInput mi = (IModelObjectEditorInput)input;
+ XModelObject o = mi.getXModelObject();
+ return new StructuredSelection(o);
+ } else if(input instanceof IFileEditorInput) {
+ IFile file = ResourceUtil.getFile(input);
+ if(file == null) return null;
+ XModelObject o = EclipseResourceUtil.getObjectByResource(file);
+ if(o != null) return new StructuredSelection(o);
+ }
+ return null;
+ }
+
+}
Show replies by date