Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Sawicki2011-12-01 22:47:41 +0000
committerKevin Sawicki2011-12-05 18:29:05 +0000
commitbe2b32a9c9e4d2cc58f2aece44242b2b7bb03834 (patch)
tree5ac3e5aa1d44854257c5314bb830762e9a9398f5
parent3df733fcd54a8fcfd3c3341fff823d3fc17ede3d (diff)
downloadegit-github-be2b32a9c9e4d2cc58f2aece44242b2b7bb03834.tar.gz
egit-github-be2b32a9c9e4d2cc58f2aece44242b2b7bb03834.tar.xz
egit-github-be2b32a9c9e4d2cc58f2aece44242b2b7bb03834.zip
Support creating Gist from files selected in Package Explorer
This required updating the 'visibleWhen' to check for a selection that adapts to IResource but not to IContainer as a check for IFile does not match selected compilation units Change-Id: I26c5393ec23adb6108004510c640d5cd123663ce
-rw-r--r--org.eclipse.mylyn.github.ui/plugin.xml49
-rw-r--r--org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/CreateGistHandler.java19
2 files changed, 44 insertions, 24 deletions
diff --git a/org.eclipse.mylyn.github.ui/plugin.xml b/org.eclipse.mylyn.github.ui/plugin.xml
index 85796a37..2dd024ea 100644
--- a/org.eclipse.mylyn.github.ui/plugin.xml
+++ b/org.eclipse.mylyn.github.ui/plugin.xml
@@ -115,7 +115,6 @@
</menu>
</menuContribution>
<menuContribution
- allPopups="false"
locationURI="popup:org.eclipse.ui.popup.any?after=additions">
<menu
icon="icons/obj16/github.png"
@@ -127,15 +126,23 @@
style="push">
<visibleWhen
checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <and>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ </adapt>
+ <not>
+ <adapt
+ type="org.eclipse.core.resources.IContainer">
+ </adapt>
+ </not>
+ </and>
</iterate>
- </with>
+ </and>
</visibleWhen>
<parameter
name="publicGist"
@@ -149,15 +156,23 @@
style="push">
<visibleWhen
checkEnabled="false">
- <with
- variable="activeMenuSelection">
- <iterate
- ifEmpty="false">
- <adapt
- type="org.eclipse.core.resources.IFile">
- </adapt>
+ <and>
+ <count
+ value="1">
+ </count>
+ <iterate>
+ <and>
+ <adapt
+ type="org.eclipse.core.resources.IResource">
+ </adapt>
+ <not>
+ <adapt
+ type="org.eclipse.core.resources.IContainer">
+ </adapt>
+ </not>
+ </and>
</iterate>
- </with>
+ </and>
</visibleWhen>
<parameter
name="publicGist"
diff --git a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/CreateGistHandler.java b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/CreateGistHandler.java
index 5b4c937a..836d0a56 100644
--- a/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/CreateGistHandler.java
+++ b/org.eclipse.mylyn.github.ui/src/org/eclipse/mylyn/internal/github/ui/gist/CreateGistHandler.java
@@ -21,6 +21,7 @@ import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
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.IPath;
@@ -143,13 +144,17 @@ public class CreateGistHandler extends AbstractHandler {
} else if (selection instanceof IStructuredSelection) {
IStructuredSelection structuredSelection = (IStructuredSelection) selection;
Object obj = structuredSelection.getFirstElement();
- IFile file = null;
- if (obj instanceof IFile)
- file = (IFile) obj;
- else if (obj instanceof IAdaptable)
- file = (IFile) ((IAdaptable) obj).getAdapter(IFile.class);
- if (file != null)
- createGistJob(event, file, isPublic);
+ IResource file = null;
+ if (obj instanceof IResource)
+ file = (IResource) obj;
+ else if (obj instanceof IAdaptable) {
+ file = (IResource) ((IAdaptable) obj)
+ .getAdapter(IResource.class);
+ if (file == null)
+ file = (IFile) ((IAdaptable) obj).getAdapter(IFile.class);
+ }
+ if (file instanceof IFile)
+ createGistJob(event, (IFile) file, isPublic);
}
return null;
}

Back to the top