Skip to content

Commit 27a5e95

Browse files
committed
Context menu in "Git Repositories" window shows only "show in" entry
with EasyShell installed #195 Signed-off-by: Andre Bossert <[email protected]>
1 parent ad8142c commit 27a5e95

File tree

13 files changed

+80
-22
lines changed

13 files changed

+80
-22
lines changed

plugin/src/de/anbos/eclipse/easyshell/plugin/misc/ResourceUtils.java

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ private static ISelection getSelectionFromText(Resource partFile, String text) {
101101
return selection;
102102
}
103103

104-
static public Resource getResource(Object myObj) {
104+
static private Resource getResourceInternal(Object myObj) {
105105
Object object = null;
106106

107107
// handle IEditorPart
@@ -165,15 +165,24 @@ static public Resource getResource(Object myObj) {
165165
// optional org.eclipse.jdt.core
166166
Bundle bundle = Platform.getBundle("org.eclipse.jdt.core");
167167
if (bundle != null) {
168-
Resource res = ResourceUtilsJDT.getResource(adaptable);
168+
Resource res = ResourceUtilsJDTCore.getResource(adaptable);
169169
if (res != null) {
170170
return res;
171171
}
172172
}
173173
// optional org.eclipse.cdt.core
174174
bundle = Platform.getBundle("org.eclipse.cdt.core");
175175
if (bundle != null) {
176-
Resource res = ResourceUtilsCDT.getResource(adaptable);
176+
Resource res = null;
177+
// optional org.eclipse.cdt.ui
178+
bundle = Platform.getBundle("org.eclipse.cdt.ui");
179+
if (bundle != null) {
180+
res = ResourceUtilsCDTUI.getResource(adaptable);
181+
}
182+
if (res != null) {
183+
return res;
184+
}
185+
res = ResourceUtilsCDTCore.getResource(adaptable);
177186
if (res != null) {
178187
return res;
179188
}
@@ -187,17 +196,26 @@ static public Resource getResource(Object myObj) {
187196
return null;
188197
}
189198

199+
static public Resource getResource(Object myObj) {
200+
try {
201+
return getResourceInternal(myObj);
202+
} catch(Exception e) {
203+
// no op
204+
}
205+
return null;
206+
}
207+
190208
static public String getFullQualifiedName(IResource resource) {
191209
Bundle bundle = Platform.getBundle("org.eclipse.jdt.core");
192210
if (bundle != null) {
193-
String res = ResourceUtilsJDT.getFullQualifiedName(resource);
211+
String res = ResourceUtilsJDTCore.getFullQualifiedName(resource);
194212
if (res != null) {
195213
return res;
196214
}
197215
}
198216
bundle = Platform.getBundle("org.eclipse.cdt.core");
199217
if (bundle != null) {
200-
String res = ResourceUtilsCDT.getFullQualifiedName(resource);
218+
String res = ResourceUtilsCDTCore.getFullQualifiedName(resource);
201219
if (res != null) {
202220
return res;
203221
}

plugin/src/de/anbos/eclipse/easyshell/plugin/misc/ResourceUtilsCDT.java renamed to plugin/src/de/anbos/eclipse/easyshell/plugin/misc/ResourceUtilsCDTCore.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,25 @@
1313

1414
package de.anbos.eclipse.easyshell.plugin.misc;
1515

16-
import org.eclipse.cdt.core.model.IIncludeReference;
17-
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
18-
import org.eclipse.cdt.internal.core.model.IncludeReference;
19-
import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
20-
import org.eclipse.cdt.internal.ui.includebrowser.IBNode;
2116
import org.eclipse.core.resources.IResource;
2217
import org.eclipse.core.runtime.IAdaptable;
2318
import org.eclipse.core.runtime.IPath;
19+
import org.eclipse.cdt.core.model.IIncludeReference;
20+
import org.eclipse.cdt.internal.core.model.ExternalTranslationUnit;
21+
import org.eclipse.cdt.internal.core.model.IncludeReference;
2422

2523
import de.anbos.eclipse.easyshell.plugin.types.Resource;
2624

2725
@SuppressWarnings("restriction")
28-
public class ResourceUtilsCDT {
26+
public class ResourceUtilsCDTCore {
2927

3028
static public Resource getResource(IAdaptable adaptable) {
3129
IPath path = null;
32-
if (adaptable instanceof IncludeReferenceProxy) {
33-
IIncludeReference includeRef = ((IncludeReferenceProxy) adaptable).getReference();
34-
path = includeRef.getPath();
35-
} else if (adaptable instanceof IncludeReference) {
30+
if (adaptable instanceof IncludeReference) {
3631
IIncludeReference includeRef = ((IncludeReference) adaptable);
3732
path = includeRef.getPath();
3833
} else if (adaptable instanceof ExternalTranslationUnit) {
3934
path = ((ExternalTranslationUnit) adaptable).getLocation();
40-
} else if (adaptable instanceof IBNode) {
41-
path = ((IBNode) adaptable).getRepresentedPath();
4235
}
4336
if (path != null) {
4437
return new Resource(path.toFile());
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Copyright (c) 2014-2021 Andre Bossert <[email protected]>.
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information regarding copyright ownership.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
14+
package de.anbos.eclipse.easyshell.plugin.misc;
15+
16+
import org.eclipse.core.runtime.IAdaptable;
17+
import org.eclipse.core.runtime.IPath;
18+
import org.eclipse.cdt.core.model.IIncludeReference;
19+
import org.eclipse.cdt.internal.ui.cview.IncludeReferenceProxy;
20+
import org.eclipse.cdt.internal.ui.includebrowser.IBNode;
21+
22+
import de.anbos.eclipse.easyshell.plugin.types.Resource;
23+
24+
@SuppressWarnings("restriction")
25+
public class ResourceUtilsCDTUI {
26+
27+
static public Resource getResource(IAdaptable adaptable) {
28+
IPath path = null;
29+
if (adaptable instanceof IncludeReferenceProxy) {
30+
IIncludeReference includeRef = ((IncludeReferenceProxy) adaptable).getReference();
31+
path = includeRef.getPath();
32+
} else if (adaptable instanceof IBNode) {
33+
path = ((IBNode) adaptable).getRepresentedPath();
34+
}
35+
if (path != null) {
36+
return new Resource(path.toFile());
37+
}
38+
return null;
39+
}
40+
41+
}

plugin/src/de/anbos/eclipse/easyshell/plugin/misc/ResourceUtilsJDT.java renamed to plugin/src/de/anbos/eclipse/easyshell/plugin/misc/ResourceUtilsJDTCore.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import de.anbos.eclipse.easyshell.plugin.types.Resource;
2929

3030
@SuppressWarnings("restriction")
31-
public class ResourceUtilsJDT {
31+
public class ResourceUtilsJDTCore {
3232

3333
static private File getJarFile(IAdaptable adaptable) {
3434
JarPackageFragmentRoot jpfr = (JarPackageFragmentRoot) adaptable;
913 Bytes
Binary file not shown.
848 Bytes
Binary file not shown.
10.6 KB
Binary file not shown.
8.57 KB
Binary file not shown.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#Mon Jun 07 17:25:47 CEST 2021
2+
artifact.repository.factory.order=artifacts.xml.xz,artifacts.xml,\!
3+
version=1
4+
metadata.repository.factory.order=content.xml.xz,content.xml,\!

0 commit comments

Comments
 (0)