Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Parker2012-05-08 16:48:52 -0400
committerMiles Parker2012-05-08 16:48:52 -0400
commit5867562cd4bfe5a6ccc2a90636452056b83550fd (patch)
treec128b905a4d5245580812b99a0fcb8e20e2b3cda
parentd001ee0530c14b25e5e70c3976f000380df0c84c (diff)
downloadorg.eclipse.virgo.ide-bug_379157_legacyRemote.tar.gz
org.eclipse.virgo.ide-bug_379157_legacyRemote.tar.xz
org.eclipse.virgo.ide-bug_379157_legacyRemote.zip
RESOLVED - bug 378533: Support opening of files in archives view bug_379157_legacyRemote
https://bugs.eclipse.org/bugs/show_bug.cgi?id=378533
-rw-r--r--org.eclipse.virgo.ide.runtime.core/src/org/eclipse/virgo/ide/runtime/internal/ui/projects/ProjectFileReference.java13
-rw-r--r--org.eclipse.virgo.ide.runtime.ui/plugin.xml22
-rw-r--r--org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/internal/ui/actions/OpenServerProjectFileAction.java63
-rw-r--r--org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/ui/views/ArtefactCommonView.java20
4 files changed, 86 insertions, 32 deletions
diff --git a/org.eclipse.virgo.ide.runtime.core/src/org/eclipse/virgo/ide/runtime/internal/ui/projects/ProjectFileReference.java b/org.eclipse.virgo.ide.runtime.core/src/org/eclipse/virgo/ide/runtime/internal/ui/projects/ProjectFileReference.java
index 702f640..b539c31 100644
--- a/org.eclipse.virgo.ide.runtime.core/src/org/eclipse/virgo/ide/runtime/internal/ui/projects/ProjectFileReference.java
+++ b/org.eclipse.virgo.ide.runtime.core/src/org/eclipse/virgo/ide/runtime/internal/ui/projects/ProjectFileReference.java
@@ -16,6 +16,7 @@ import java.io.File;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Path;
import org.eclipse.virgo.ide.runtime.core.artefacts.ILocalArtefact;
import org.eclipse.virgo.ide.runtime.core.artefacts.LocalArtefactSet;
@@ -23,7 +24,7 @@ import org.eclipse.virgo.ide.runtime.core.artefacts.LocalArtefactSet;
/**
* @author Miles Parker
*/
-public class ProjectFileReference implements IServerProjectArtefact {
+public class ProjectFileReference implements IServerProjectArtefact, IAdaptable {
ProjectFileContainer container;
@@ -72,4 +73,14 @@ public class ProjectFileReference implements IServerProjectArtefact {
public IFile getWorkspaceFile() {
return workspaceFile;
}
+
+ /**
+ * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
+ */
+ public Object getAdapter(Class adapter) {
+ if (adapter == IFile.class) {
+ return workspaceFile;
+ }
+ return null;
+ }
}
diff --git a/org.eclipse.virgo.ide.runtime.ui/plugin.xml b/org.eclipse.virgo.ide.runtime.ui/plugin.xml
index 1f3b1f4..f304179 100644
--- a/org.eclipse.virgo.ide.runtime.ui/plugin.xml
+++ b/org.eclipse.virgo.ide.runtime.ui/plugin.xml
@@ -285,6 +285,9 @@
<contentExtension
pattern="org.eclipse.virgo.ide.runtime.ui.filterBundles">
</contentExtension>
+ <actionExtension
+ pattern="org.eclipse.virgo.ide.runtime.ui.actions">
+ </actionExtension>
</includes>
</viewerContentBinding>
<viewer
@@ -301,6 +304,14 @@
pattern="org.eclipse.virgo.ide.runtime.ui.repositoryPage"/>
</includes>
</viewerContentBinding>
+ <viewerActionBinding
+ viewerId="org.eclipse.virgo.ide.runtime.ui.ArtefactsDetailView">
+ <includes>
+ <actionExtension
+ pattern="org.eclipse.virgo.ide.runtime.ui.actions">
+ </actionExtension>
+ </includes>
+ </viewerActionBinding>
</extension>
<extension
@@ -474,6 +485,17 @@
id="org.eclipse.virgo.ide.runtime.ui.filterBundles"
name="Bundles">
</commonFilter>
+ <actionProvider
+ class="org.eclipse.virgo.ide.runtime.internal.ui.providers.RuntimeActionProvider"
+ id="org.eclipse.virgo.ide.runtime.ui.actions">
+ <enablement>
+ <or>
+ <instanceof
+ value="org.eclipse.virgo.ide.runtime.internal.ui.projects.ProjectFileReference">
+ </instanceof>
+ </or>
+ </enablement>
+ </actionProvider>
</extension>
<extension
point="org.eclipse.core.contenttype.contentTypes">
diff --git a/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/internal/ui/actions/OpenServerProjectFileAction.java b/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/internal/ui/actions/OpenServerProjectFileAction.java
index 48347a6..403e372 100644
--- a/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/internal/ui/actions/OpenServerProjectFileAction.java
+++ b/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/internal/ui/actions/OpenServerProjectFileAction.java
@@ -11,18 +11,21 @@
*******************************************************************************/
package org.eclipse.virgo.ide.runtime.internal.ui.actions;
+import java.util.Iterator;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.util.OpenStrategy;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.ui.IEditorDescriptor;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.OpenSystemEditorAction;
-import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.actions.SelectionListenerAction;
import org.eclipse.ui.internal.ide.DialogUtil;
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.virgo.ide.runtime.internal.ui.projects.ProjectFileReference;
/**
* Standard action for opening an editor on the currently selected file resource(s).
@@ -37,7 +40,7 @@ import org.eclipse.ui.part.FileEditorInput;
* @author Miles Parker
* @noextend This class is not intended to be subclassed by clients.
*/
-public class OpenServerProjectFileAction extends OpenSystemEditorAction {
+public class OpenServerProjectFileAction extends SelectionListenerAction {
/**
* The id of this action.
@@ -71,7 +74,7 @@ public class OpenServerProjectFileAction extends OpenSystemEditorAction {
* the editor descriptor, or <code>null</code> if unspecified
*/
public OpenServerProjectFileAction(IWorkbenchPage page, IEditorDescriptor descriptor) {
- super(page);
+ super("Open Linked File");
this.workbenchPage2 = page;
setText(descriptor == null ? IDEWorkbenchMessages.OpenFileAction_text : descriptor.getLabel());
PlatformUI.getWorkbench().getHelpSystem().setHelp(this, IIDEHelpContextIds.OPEN_FILE_ACTION);
@@ -81,40 +84,38 @@ public class OpenServerProjectFileAction extends OpenSystemEditorAction {
}
/**
- * Ensures that the contents of the given file resource are local.
- *
- * @param file
- * the file resource
- * @return <code>true</code> if the file is local, and <code>false</code> if it could not be made local for some
- * reason
+ * @see org.eclipse.ui.actions.OpenSystemEditorAction#updateSelection(org.eclipse.jface.viewers.IStructuredSelection)
*/
- boolean ensureFileLocal(final IFile file) {
- //Currently fails due to Core PR. Don't do it for now
- //1G5I6PV: ITPCORE:WINNT - IResource.setLocal() attempts to modify immutable tree
- //file.setLocal(true, IResource.DEPTH_ZERO);
- return true;
+ @Override
+ public boolean updateSelection(IStructuredSelection selection) {
+ return selection instanceof StructuredSelection
+ && ((StructuredSelection) selection).getFirstElement() instanceof ProjectFileReference;
}
/**
- * Opens an editor on the given file resource.
- *
- * @param file
- * the file resource
+ * @see org.eclipse.ui.actions.OpenSystemEditorAction#run()
*/
- void openFile(IFile file) {
- try {
- boolean activate = OpenStrategy.activateOnOpen();
- if (editorDescriptor == null) {
- IDE.openEditor(workbenchPage2, file, activate);
- } else {
- if (ensureFileLocal(file)) {
- workbenchPage2.openEditor(new FileEditorInput(file), editorDescriptor.getId(), activate);
- }
+ @Override
+ public void run() {
+ Iterator iterator = getStructuredSelection().iterator();
+ while (iterator.hasNext()) {
+ Object next = iterator.next();
+ if (next instanceof ProjectFileReference) {
+ openFile(((ProjectFileReference) next).getWorkspaceFile());
}
+ }
+ }
+
+ public void openFile(IFile file) {
+ try {
+ IEditorDescriptor defaultEditor = workbenchPage2.getWorkbenchWindow()
+ .getWorkbench()
+ .getEditorRegistry()
+ .getDefaultEditor(file.getName());
+ workbenchPage2.openEditor(new FileEditorInput(file), defaultEditor.getId());
} catch (PartInitException e) {
DialogUtil.openError(workbenchPage2.getWorkbenchWindow().getShell(),
- IDEWorkbenchMessages.OpenFileAction_openFileShellTitle, e.getMessage(), e);
+ IDEWorkbenchMessages.OpenSystemEditorAction_dialogTitle, e.getMessage(), e);
}
}
-
}
diff --git a/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/ui/views/ArtefactCommonView.java b/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/ui/views/ArtefactCommonView.java
index 45e5df4..33e9deb 100644
--- a/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/ui/views/ArtefactCommonView.java
+++ b/org.eclipse.virgo.ide.runtime.ui/src/org/eclipse/virgo/ide/runtime/ui/views/ArtefactCommonView.java
@@ -19,6 +19,8 @@ import java.util.List;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.StructuredSelection;
@@ -41,6 +43,7 @@ import org.eclipse.ui.navigator.INavigatorActivationService;
import org.eclipse.virgo.ide.runtime.core.artefacts.ArtefactSet;
import org.eclipse.virgo.ide.runtime.core.artefacts.IArtefact;
import org.eclipse.virgo.ide.runtime.internal.ui.ServerUiPlugin;
+import org.eclipse.virgo.ide.runtime.internal.ui.actions.OpenServerProjectFileAction;
import org.eclipse.virgo.ide.runtime.internal.ui.editor.VirgoEditorAdapterFactory;
import org.eclipse.virgo.ide.runtime.internal.ui.filters.FilterAction;
import org.eclipse.virgo.ide.runtime.internal.ui.projects.IServerProjectArtefact;
@@ -160,6 +163,23 @@ public class ArtefactCommonView extends CommonNavigator implements ISelectionLis
manager.appendToGroup(FILTER_ACTION_GROUP, action);
}
+ getCommonViewer().addDoubleClickListener(new IDoubleClickListener() {
+
+ public void doubleClick(DoubleClickEvent event) {
+ if (event.getSelection() instanceof StructuredSelection) {
+ final StructuredSelection sel = (StructuredSelection) event.getSelection();
+ OpenServerProjectFileAction fileAction = new OpenServerProjectFileAction(getSite().getPage()) {
+ @Override
+ public org.eclipse.jface.viewers.IStructuredSelection getStructuredSelection() {
+ return sel;
+ }
+ };
+ if (fileAction.updateSelection(sel)) {
+ fileAction.run();
+ }
+ }
+ }
+ });
updateActivations();
}

Back to the top