Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrian de Alwis2012-01-26 15:14:47 -0500
committerBrian de Alwis2012-01-26 15:14:47 -0500
commit6596f726fee162692eeb74043b74257512696579 (patch)
treef25bc0cf0a9126dc6c88d6967d4c00be9306883f
parent4ee216e9c34fd9723532d4fb3e7feb4ce52d1c0b (diff)
downloadorg.eclipse.e4.tools-6596f726fee162692eeb74043b74257512696579.tar.gz
org.eclipse.e4.tools-6596f726fee162692eeb74043b74257512696579.tar.xz
org.eclipse.e4.tools-6596f726fee162692eeb74043b74257512696579.zip
Update class-open actions for new bundleclass URIv20120126-2014
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java84
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java14
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java84
3 files changed, 94 insertions, 88 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java
index a37f1242..023ecb2b 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java
@@ -84,47 +84,49 @@ public class AddonContributionEditor implements IContributionClassCreator {
}
}
} else {
- URI uri = URI.createURI(contribution.getContributionURI());
- if (uri.segmentCount() == 3) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(uri.segment(1));
-
- if( ! p.exists() ) {
- for( IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects() ) {
- String name = Util.getBundleSymbolicName(check);
- if( uri.segment(1).equals(name) ) {
- p = check;
- break;
- }
- }
- }
-
- // TODO If this is not a WS-Resource we need to open differently
- if (p != null) {
- IJavaProject jp = JavaCore.create(p);
- try {
- IType t = jp.findType(uri.segment(2));
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
- createOpen(contribution, domain, project, shell, true);
- }
- }
- } catch (JavaModelException e) {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (PartInitException e) {
- MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- } else {
- MessageDialog.openError(shell, "Invalid URL",
- "The current url is invalid");
- }
+ URI uri = URI.createURI(contribution.getContributionURI());
+ if (uri.hasAuthority() && uri.segmentCount() == 1) {
+ String symbolicName = uri.authority();
+ String fullyQualified = uri.segment(0);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(symbolicName);
+
+ if( ! p.exists() ) {
+ for( IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects() ) {
+ String name = Util.getBundleSymbolicName(check);
+ if( symbolicName.equals(name) ) {
+ p = check;
+ break;
+ }
+ }
+ }
+
+ // TODO If this is not a WS-Resource we need to open differently
+ if (p != null) {
+ IJavaProject jp = JavaCore.create(p);
+ try {
+ IType t = jp.findType(fullyQualified);
+ if( t != null ) {
+ JavaUI.openInEditor(t);
+ } else {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ }
+ } catch (JavaModelException e) {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ } catch (PartInitException e) {
+ MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ MessageDialog.openError(shell, "Invalid URL",
+ "The current url is invalid");
+ }
}
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java
index d1be445e..36bc0c2e 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java
@@ -75,14 +75,16 @@ public class HandlerContributionEditor implements IContributionClassCreator {
}
} else {
URI uri = URI.createURI(contribution.getContributionURI());
- if (uri.segmentCount() == 3) {
+ if (uri.hasAuthority() && uri.segmentCount() == 1) {
+ String symbolicName = uri.authority();
+ String fullyQualified = uri.segment(0);
IProject p = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(uri.segment(1));
+ .getProject(symbolicName);
if( ! p.exists() ) {
for( IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects() ) {
String name = Util.getBundleSymbolicName(check);
- if( uri.segment(1).equals(name) ) {
+ if( symbolicName.equals(name) ) {
p = check;
break;
}
@@ -93,16 +95,16 @@ public class HandlerContributionEditor implements IContributionClassCreator {
if (p != null) {
IJavaProject jp = JavaCore.create(p);
try {
- IType t = jp.findType(uri.segment(2));
+ IType t = jp.findType(fullyQualified);
if( t != null ) {
JavaUI.openInEditor(t);
} else {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
createOpen(contribution, domain, project, shell, true);
}
}
} catch (JavaModelException e) {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
createOpen(contribution, domain, project, shell, true);
}
} catch (PartInitException e) {
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java
index 7383e50f..83eadf22 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java
@@ -76,47 +76,49 @@ public class PartContributionEditor implements IContributionClassCreator {
}
}
} else {
- URI uri = URI.createURI(contribution.getContributionURI());
- if (uri.segmentCount() == 3) {
- IProject p = ResourcesPlugin.getWorkspace().getRoot()
- .getProject(uri.segment(1));
-
- if( ! p.exists() ) {
- for( IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects() ) {
- String name = Util.getBundleSymbolicName(check);
- if( uri.segment(1).equals(name) ) {
- p = check;
- break;
- }
- }
- }
-
- // TODO If this is not a WS-Resource we need to open differently
- if (p != null) {
- IJavaProject jp = JavaCore.create(p);
- try {
- IType t = jp.findType(uri.segment(2));
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
- createOpen(contribution, domain, project, shell, true);
- }
- }
- } catch (JavaModelException e) {
- if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+uri.segment(2)+"' was not found. Would you like to start the class creation wizard?") ) {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (PartInitException e) {
- MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- } else {
- MessageDialog.openError(shell, "Invalid URL",
- "The current url is invalid");
- }
+ URI uri = URI.createURI(contribution.getContributionURI());
+ if (uri.hasAuthority() && uri.segmentCount() == 1) {
+ String symbolicName = uri.authority();
+ String fullyQualified = uri.segment(0);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(symbolicName);
+
+ if( ! p.exists() ) {
+ for( IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects() ) {
+ String name = Util.getBundleSymbolicName(check);
+ if( symbolicName.equals(name) ) {
+ p = check;
+ break;
+ }
+ }
+ }
+
+ // TODO If this is not a WS-Resource we need to open differently
+ if (p != null) {
+ IJavaProject jp = JavaCore.create(p);
+ try {
+ IType t = jp.findType(fullyQualified);
+ if( t != null ) {
+ JavaUI.openInEditor(t);
+ } else {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ }
+ } catch (JavaModelException e) {
+ if( MessageDialog.openQuestion(shell, "Class not found", "The class '"+fullyQualified+"' was not found. Would you like to start the class creation wizard?") ) {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ } catch (PartInitException e) {
+ MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ MessageDialog.openError(shell, "Invalid URL",
+ "The current url is invalid");
+ }
}
}

Back to the top