Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjonas2014-10-21 04:25:41 +0000
committerjonas2014-10-23 08:08:17 +0000
commit229563c472b79c6fc9fc4317dd3cd1e6e0fd8e89 (patch)
treefeb41ed2f17c26cbab97cdf0835817164eeda552
parent11b0290ebba1d128c21268793b11fe937e626199 (diff)
downloadorg.eclipse.e4.tools-229563c472b79c6fc9fc4317dd3cd1e6e0fd8e89.tar.gz
org.eclipse.e4.tools-229563c472b79c6fc9fc4317dd3cd1e6e0fd8e89.tar.xz
org.eclipse.e4.tools-229563c472b79c6fc9fc4317dd3cd1e6e0fd8e89.zip
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java27
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/EditorProjectFunction.java6
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/Messages.java3
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java16
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelMoveParticipant.java16
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEClassContributionProvider.java2
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEExtensionLookup.java13
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorModel.java61
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorParticipantDelegate.java10
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/UndoAction.java4
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java14
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/AddonContributionEditor.java144
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/DynamicMenuContributionContributionEditor.java107
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java117
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java142
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/ToolControlContributionEditor.java99
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/messages.properties3
-rw-r--r--bundles/org.eclipse.e4.tools.services/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF2
20 files changed, 419 insertions, 370 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java
index 5502f737..781dd7ed 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x;
@@ -19,23 +19,25 @@ import org.eclipse.ui.actions.ActionFactory;
@SuppressWarnings("restriction")
public class E4WorkbenchModelEditor extends
- DIEditorPart<ApplicationModelEditor> {
+ DIEditorPart<ApplicationModelEditor> {
private UndoAction undoAction;
private RedoAction redoAction;
- private ModelListener listener = new ModelListener() {
+ private final ModelListener listener = new ModelListener() {
+ @Override
public void dirtyChanged() {
firePropertyChange(PROP_DIRTY);
}
+ @Override
public void commandStackChanged() {
}
};
public E4WorkbenchModelEditor() {
- super(ApplicationModelEditor.class, COPY|CUT|PASTE);
+ super(ApplicationModelEditor.class, COPY | CUT | PASTE);
}
@Override
@@ -43,32 +45,35 @@ public class E4WorkbenchModelEditor extends
super.createPartControl(parent);
setPartName(getEditorInput().getName());
}
-
+
@Override
protected void makeActions() {
super.makeActions();
undoAction = new UndoAction(getComponent().getModelProvider());
undoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_UNDO);
-
+
redoAction = new RedoAction(getComponent().getModelProvider());
redoAction.setActionDefinitionId(IWorkbenchCommandConstants.EDIT_REDO);
getEditorSite().getActionBars().setGlobalActionHandler(
- ActionFactory.UNDO.getId(), undoAction);
+ ActionFactory.UNDO.getId(), undoAction);
getEditorSite().getActionBars().setGlobalActionHandler(
- ActionFactory.REDO.getId(), redoAction);
+ ActionFactory.REDO.getId(), redoAction);
}
@Override
public void dispose() {
- if (undoAction != null)
+ if (undoAction != null) {
undoAction.dispose();
+ }
- if (redoAction != null)
+ if (redoAction != null) {
redoAction.dispose();
+ }
- if (listener != null && getComponent() != null && getComponent().getModelProvider() != null)
+ if (listener != null && getComponent() != null && getComponent().getModelProvider() != null) {
getComponent().getModelProvider().removeModelListener(listener);
+ }
super.dispose();
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/EditorProjectFunction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/EditorProjectFunction.java
index 742cb743..70c0970a 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/EditorProjectFunction.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/EditorProjectFunction.java
@@ -8,10 +8,10 @@ import org.eclipse.ui.IFileEditorInput;
public class EditorProjectFunction extends ContextFunction {
@Override
- public Object compute(IEclipseContext context) {
+ public Object compute(IEclipseContext context, String contextKex) {
final IEditorInput input = context.get(IEditorInput.class);
- if( input != null && input instanceof IFileEditorInput ) {
- return ((IFileEditorInput)input).getFile().getProject();
+ if (input != null && input instanceof IFileEditorInput) {
+ return ((IFileEditorInput) input).getFile().getProject();
}
return null;
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/Messages.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/Messages.java
index ba3b7537..3e967532 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/Messages.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/Messages.java
@@ -19,6 +19,9 @@ import org.eclipse.osgi.util.NLS;
*/
public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.e4.tools.emf.editor3x.messages"; //$NON-NLS-1$
+ public static String ContributionEditor_CurrentURLIsInvalid;
+ public static String ContributionEditor_FailedToOpenEditor;
+ public static String ContributionEditor_InvalidURL;
public static String ModelEditorPreferencePage_Color;
public static String ModelEditorPreferencePage_ForcesReadOnlyXMITab;
public static String ModelEditorPreferencePage_FormTab;
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java
index c0b46b87..2b488922 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelExtractor.java
@@ -7,19 +7,19 @@ import org.eclipse.e4.internal.tools.wizards.model.ExtractContributionModelWizar
import org.eclipse.e4.tools.emf.ui.common.IModelExtractor;
import org.eclipse.e4.ui.model.application.MApplicationElement;
import org.eclipse.jface.window.Window;
-import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
-
+
@SuppressWarnings("restriction")
-public class ModelExtractor implements IModelExtractor {
-
+public class ModelExtractor implements IModelExtractor {
+
+ @Override
public boolean extract(Shell shell, IProject project,
- List<MApplicationElement> maes) {
- ExtractContributionModelWizard extractContributionModelWizard = new ExtractContributionModelWizard(maes);
+ List<MApplicationElement> maes) {
+ final ExtractContributionModelWizard extractContributionModelWizard = new ExtractContributionModelWizard(maes);
extractContributionModelWizard.setup(project);
- WizardDialog wizardDialog = new WizardDialog(shell, extractContributionModelWizard);
+ final WizardDialog wizardDialog = new WizardDialog(shell, extractContributionModelWizard);
return wizardDialog.open() == Window.OK;
}
-
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelMoveParticipant.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelMoveParticipant.java
index fbef832d..2b7fbc2f 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelMoveParticipant.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/ModelMoveParticipant.java
@@ -57,7 +57,7 @@ public class ModelMoveParticipant extends MoveParticipant {
@Override
public String getName() {
- return "Workbench Model Contribution Participant";
+ return "Workbench Model Contribution Participant"; //$NON-NLS-1$
}
@Override
@@ -68,9 +68,9 @@ public class ModelMoveParticipant extends MoveParticipant {
@Override
public Change createChange(IProgressMonitor pMonitor) throws CoreException,
- OperationCanceledException {
+ OperationCanceledException {
- pMonitor.beginTask("Creating Change ..", IProgressMonitor.UNKNOWN);
+ pMonitor.beginTask(Messages.ModelMoveParticipant_CreatingChange, IProgressMonitor.UNKNOWN);
Change change = null;
@@ -149,11 +149,11 @@ public class ModelMoveParticipant extends MoveParticipant {
.getElementName() : fragment.getElementName() + "." //$NON-NLS-1$
+ pType.getElementName();
- return RefactorParticipantDelegate.createChange(
- pMonitor,
- fModel.addTextRename("bundleclass://" + fromBundle + "/" //$NON-NLS-1$ //$NON-NLS-2$
- + fromClassname, "bundleclass://" + toBundle + "/" //$NON-NLS-1$ //$NON-NLS-2$
- + toClassName));
+ return RefactorParticipantDelegate.createChange(
+ pMonitor,
+ fModel.addTextRename("bundleclass://" + fromBundle + "/" //$NON-NLS-1$ //$NON-NLS-2$
+ + fromClassname, "bundleclass://" + toBundle + "/" //$NON-NLS-1$ //$NON-NLS-2$
+ + toClassName));
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEClassContributionProvider.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEClassContributionProvider.java
index 29fa40b6..9c42f01d 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEClassContributionProvider.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEClassContributionProvider.java
@@ -34,6 +34,7 @@ import org.eclipse.jdt.core.search.SearchPattern;
import org.eclipse.jdt.core.search.TypeNameRequestor;
import org.eclipse.pde.internal.core.util.PDEJavaHelper;
+@SuppressWarnings("restriction")
public class PDEClassContributionProvider implements IClassContributionProvider {
private final SearchEngine searchEngine;
@@ -42,7 +43,6 @@ public class PDEClassContributionProvider implements IClassContributionProvider
}
@Override
- @SuppressWarnings("restriction")
public void findContribution(final Filter filter, final ContributionResultHandler handler) {
boolean followReferences = true;
if (filter.getSearchScope().contains(ResourceSearchScope.PROJECT)
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEExtensionLookup.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEExtensionLookup.java
index 88c4114e..0bb1ad18 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEExtensionLookup.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/PDEExtensionLookup.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x;
@@ -16,16 +16,17 @@ import org.eclipse.core.runtime.RegistryFactory;
import org.eclipse.e4.tools.emf.ui.common.IExtensionLookup;
import org.eclipse.pde.internal.core.PDEExtensionRegistry;
+@SuppressWarnings("restriction")
public class PDEExtensionLookup implements IExtensionLookup {
+ @Override
public IExtension[] findExtensions(String extensionPointId, boolean liveModel) {
- if( liveModel ) {
- IExtensionRegistry registry = RegistryFactory.getRegistry();
+ if (liveModel) {
+ final IExtensionRegistry registry = RegistryFactory.getRegistry();
return registry.getExtensionPoint(extensionPointId).getExtensions();
- } else {
- PDEExtensionRegistry reg = new PDEExtensionRegistry();
- return reg.findExtensions(extensionPointId, true);
}
+ final PDEExtensionRegistry reg = new PDEExtensionRegistry();
+ return reg.findExtensions(extensionPointId, true);
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorModel.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorModel.java
index 58d71e2e..05cfa68f 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorModel.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorModel.java
@@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Wim Jongman <wim.jongman@remainsoftware.com> - Bug 432892: Eclipse 4 Application does not work after renaming the project name
+ * Wim Jongman <wim.jongman@remainsoftware.com> - Bug 432892: Eclipse 4 Application does not work after renaming the
+ * project name
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x;
@@ -22,7 +23,7 @@ import org.eclipse.ltk.core.refactoring.participants.RefactoringParticipant;
/**
* A temporary data storage for Ecipse 4 model refactoring. Use the static
* methods to get hold of an instance.
- *
+ *
* @author Remain Software - Wim Jongman
*
*/
@@ -39,10 +40,9 @@ public class RefactorModel {
private RefactoringParticipant fParticipant;
/**
- * Factory for an empty model. Use the
- * {@link #addTextRename(String, String)} method to add one or more text
+ * Factory for an empty model. Use the {@link #addTextRename(String, String)} method to add one or more text
* renames.
- *
+ *
* @param pParticipant
* @return the model
*/
@@ -51,27 +51,27 @@ public class RefactorModel {
}
/**
- * Factory for a model with one rename. Use the
- * {@link #addTextRename(String, String)} method to add one or more text
+ * Factory for a model with one rename. Use the {@link #addTextRename(String, String)} method to add one or more
+ * text
* renames.
- *
+ *
* @param pParticipant
* @param pOldText
* @param pNewText
* @return the model.
*/
public static RefactorModel getModel(RefactoringParticipant pParticipant,
- String pOldText, String pNewText) {
+ String pOldText, String pNewText) {
return new RefactorModel().addTextRename(pOldText, pNewText);
}
/**
* Factory for a model with one rename and a project rename. The project
* rename uses the old and new project because the refactoring framework
- * expects the already renamed filenames. Use the
- * {@link #addTextRename(String, String)} method to add one or more text
+ * expects the already renamed filenames. Use the {@link #addTextRename(String, String)} method to add one or more
+ * text
* renames and the old and the new project.
- *
+ *
* @param pParticipant
* @param pOldText
* @param pNewText
@@ -80,18 +80,17 @@ public class RefactorModel {
* @return the model.
*/
public static RefactorModel getModel(RefactoringParticipant pParticipant,
- String pOldText, String pNewText, IProject pOldProject,
- IProject pNewProject) {
+ String pOldText, String pNewText, IProject pOldProject,
+ IProject pNewProject) {
return new RefactorModel().addTextRename(pOldText, pNewText)
- .setProjectRename(pOldProject, pNewProject)
- .setRefactorParticipant(pParticipant);
+ .setProjectRename(pOldProject, pNewProject)
+ .setRefactorParticipant(pParticipant);
}
/**
* Adds a text rename to be processed later. For example, if the project
- * name changes there can be <code>bundlclass://</code> and
- * <code>platform:/plugin</code> changes.
- *
+ * name changes there can be <code>bundlclass://</code> and <code>platform:/plugin</code> changes.
+ *
* @param oldText
* @param newText
* @return the model
@@ -107,7 +106,7 @@ public class RefactorModel {
/**
* When project renaming this returns the new project. This project does not
* necessarily exist yet.
- *
+ *
* @return the new project or null if it was not set
* @see RefactorModel#setProjectRename(IProject, IProject)
*/
@@ -124,7 +123,7 @@ public class RefactorModel {
/**
* When project renaming this returns the old project.
- *
+ *
* @return the new project or null if it was not set
* @see RefactorModel#setProjectRename(IProject, IProject)
*/
@@ -133,7 +132,7 @@ public class RefactorModel {
}
/**
- *
+ *
* @return the old text in the current index.
*/
public String getOldTextCurrentIndex() {
@@ -141,7 +140,7 @@ public class RefactorModel {
}
/**
- * @return
+ * @return the refactoring participant
*/
public RefactoringParticipant getRefactoringParticipant() {
return fParticipant;
@@ -156,7 +155,7 @@ public class RefactorModel {
/**
* Delegates to the same method of the embedded RefactoringParticipant.
- *
+ *
* @param file
* @return a TextChange object
* @see RefactoringParticipant#getTextChange(Object)
@@ -174,26 +173,26 @@ public class RefactorModel {
/**
* Sets the current 0-based index. May not be out of bounds.
- *
+ *
* @param index
* @return the model
*/
public RefactorModel setIndex(int index) {
Assert.isTrue(index >= 0);
Assert.isTrue(index < fOldTexts.size());
- this.fIndex = index;
+ fIndex = index;
return this;
}
/**
* Sets the old and the new project in case of project renaming.
- *
+ *
* @param oldProject
* @param newProject
* @return the model
*/
public RefactorModel setProjectRename(IProject oldProject,
- IProject newProject) {
+ IProject newProject) {
Assert.isNotNull(oldProject);
Assert.isNotNull(newProject);
fOldProject = oldProject;
@@ -203,14 +202,14 @@ public class RefactorModel {
/**
* Sets the RefactoringParticipant.
- *
+ *
* @param pParticipant
* @return the model
* @see RefactoringParticipant
*/
public RefactorModel setRefactorParticipant(
- RefactoringParticipant pParticipant) {
- this.fParticipant = pParticipant;
+ RefactoringParticipant pParticipant) {
+ fParticipant = pParticipant;
return this;
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorParticipantDelegate.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorParticipantDelegate.java
index 802c284d..faab30eb 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorParticipantDelegate.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/RefactorParticipantDelegate.java
@@ -33,6 +33,7 @@ import org.eclipse.text.edits.MultiTextEdit;
import org.eclipse.text.edits.ReplaceEdit;
import org.eclipse.text.edits.TextEditGroup;
+@SuppressWarnings("restriction")
class RefactorParticipantDelegate {
private static final String E4_MODEL_CHANGES = "Eclipse 4 Application Model Changes"; //$NON-NLS-1$
@@ -42,13 +43,8 @@ class RefactorParticipantDelegate {
* adds the changes to the passed {@link CompositeChange}.
*
* @param pProgressMonitor
- * @param pParticipant
- * @param pOldUrl
- * String[] containing the old texts
- * @param pNewUrl
- * String[] containing the new texts
- * @param pNewProject
- * The name of the project if this is a project change else null.
+ * @param pModel
+ *
* @return a set of changes in a {@link CompositeChange}
* @throws CoreException
* @throws OperationCanceledException
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
index d48b3c97..ff99aa5f 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
@@ -16,6 +16,7 @@ import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.pde.internal.core.PDEExtensionRegistry;
+@SuppressWarnings("restriction")
public class TargetElementProviders implements IModelElementProvider {
private static final String APP_E4XMI_DEFAULT = "Application.e4xmi"; //$NON-NLS-1$
private ResourceSet resourceSet;
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/UndoAction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/UndoAction.java
index 4612c913..28eebf0f 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/UndoAction.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/UndoAction.java
@@ -43,9 +43,9 @@ public class UndoAction extends Action {
private void update() {
if (resource.getEditingDomain().getCommandStack().canUndo()) {
- setText(Messages.UndoAction_Undo + " " //$NON-NLS-2$
+ setText(Messages.UndoAction_Undo + " " //$NON-NLS-1$
+ resource.getEditingDomain().getCommandStack()
- .getUndoCommand().getLabel());
+ .getUndoCommand().getLabel());
setEnabled(true);
} else {
setText(Messages.UndoAction_Undo);
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
index 2b64fcb8..8517bca0 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/XMIResourceFunction.java
@@ -12,21 +12,23 @@ import org.eclipse.ui.IEditorInput;
public class XMIResourceFunction extends ContextFunction {
@Override
- public Object compute(final IEclipseContext context) {
+ public Object compute(final IEclipseContext context, String contextKey) {
final IEditorInput input = context.get(IEditorInput.class);
final IDirtyProviderService dirtyProvider = context.get(IDirtyProviderService.class);
-
- if( input != null ) {
- URI resourceURI = EditUIUtil.getURI(input);
+
+ if (input != null) {
+ final URI resourceURI = EditUIUtil.getURI(input);
final XMIModelResource resource = new XMIModelResource(resourceURI);
resource.addModelListener(new ModelListener() {
-
+
+ @Override
public void dirtyChanged() {
dirtyProvider.setDirtyState(resource.isDirty());
}
+ @Override
public void commandStackChanged() {
-
+
}
});
return resource;
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 6b3d9f20..56aa6f1f 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
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- * Sopot Cela <sopotcela@gmail.com>
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Sopot Cela <sopotcela@gmail.com>
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x.extension;
@@ -15,6 +15,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.e4.internal.tools.wizards.classes.NewAddonClassWizard;
+import org.eclipse.e4.tools.emf.editor3x.Messages;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.ui.model.application.MContribution;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
@@ -36,97 +37,104 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
+@SuppressWarnings("restriction")
public class AddonContributionEditor implements IContributionClassCreator {
+ @Override
public boolean isSupported(EClass element) {
return Util.isTypeOrSuper(ApplicationPackageImpl.Literals.ADDON, element);
}
-
+
+ @Override
public void createOpen(MContribution contribution, EditingDomain domain,
- IProject project, Shell shell) {
+ IProject project, Shell shell) {
createOpen(contribution, domain, project, shell, false);
}
private void createOpen(MContribution contribution, EditingDomain domain,
- IProject project, Shell shell, boolean forceNew) {
- if( forceNew || contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 || !contribution.getContributionURI().startsWith("bundleclass:") ) {
- NewAddonClassWizard wizard = new NewAddonClassWizard(contribution.getContributionURI());
- wizard.init( null, new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(shell, wizard);
- if( dialog.open() == Window.OK ) {
- IFile f = wizard.getFile();
- ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ IProject project, Shell shell, boolean forceNew) {
+ if (forceNew || contribution.getContributionURI() == null
+ || contribution.getContributionURI().trim().length() == 0
+ || !contribution.getContributionURI().startsWith("bundleclass:")) { //$NON-NLS-1$
+ final NewAddonClassWizard wizard = new NewAddonClassWizard(contribution.getContributionURI());
+ wizard.init(null, new StructuredSelection(project));
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ final IFile f = wizard.getFile();
+ final ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
try {
String fullyQualified;
- if( el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0 ) {
- String packageName = el.getPackageDeclarations()[0].getElementName();
- String className = wizard.getDomainClass().getName();
- if( packageName.trim().length() > 0 ) {
- fullyQualified = packageName + "." + className;
+ if (el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0) {
+ final String packageName = el.getPackageDeclarations()[0].getElementName();
+ final String className = wizard.getDomainClass().getName();
+ if (packageName.trim().length() > 0) {
+ fullyQualified = packageName + "." + className; //$NON-NLS-1$
} else {
fullyQualified = className;
}
} else {
fullyQualified = wizard.getDomainClass().getName();
}
-
- Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified);
- if( cmd.canExecute() ) {
+
+ final Command cmd = SetCommand.create(domain, contribution,
+ ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI,
+ "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified); //$NON-NLS-1$ //$NON-NLS-2$
+ if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
- } catch (JavaModelException e) {
+ } catch (final JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- 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);
- IType t = null;
- try {
- if (p.exists()){
- t = jp.findType(fullyQualified);
- }
- else
- {
- IJavaProject pprim = JavaCore.create(project);
- t = pprim.findType(fullyQualified);
- }
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (JavaModelException e) {
- 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");
- }
+ final URI uri = URI.createURI(contribution.getContributionURI());
+ if (uri.hasAuthority() && uri.segmentCount() == 1) {
+ final String symbolicName = uri.authority();
+ final String fullyQualified = uri.segment(0);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(symbolicName);
+
+ if (!p.exists()) {
+ for (final IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ final 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) {
+ final IJavaProject jp = JavaCore.create(p);
+ IType t = null;
+ try {
+ if (p.exists()) {
+ t = jp.findType(fullyQualified);
+ }
+ else
+ {
+ final IJavaProject pprim = JavaCore.create(project);
+ t = pprim.findType(fullyQualified);
+ }
+ if (t != null) {
+ JavaUI.openInEditor(t);
+ } else {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ } catch (final JavaModelException e) {
+ createOpen(contribution, domain, project, shell, true);
+ } catch (final PartInitException e) {
+ MessageDialog.openError(shell, Messages.ContributionEditor_FailedToOpenEditor, e.getMessage());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ MessageDialog.openError(shell, Messages.ContributionEditor_InvalidURL,
+ Messages.ContributionEditor_CurrentURLIsInvalid);
+ }
}
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/DynamicMenuContributionContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/DynamicMenuContributionContributionEditor.java
index a147c583..0b441cb3 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/DynamicMenuContributionContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/DynamicMenuContributionContributionEditor.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Marco Descher <marco@descher.at> - initial API and implementation
+ * Marco Descher <marco@descher.at> - initial API and implementation
*******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x.extension;
@@ -14,6 +14,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.e4.internal.tools.wizards.classes.NewDynamicMenuContributionClassWizard;
+import org.eclipse.e4.tools.emf.editor3x.Messages;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.ui.model.application.MContribution;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
@@ -36,96 +37,104 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
+@SuppressWarnings("restriction")
public class DynamicMenuContributionContributionEditor implements
- IContributionClassCreator {
+ IContributionClassCreator {
+ @Override
public void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell) {
createOpen(contribution, domain, project, shell, false);
}
public void createOpen(MContribution contribution, EditingDomain domain,
- IProject project, Shell shell, boolean forceNew) {
- if( forceNew || contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 || !contribution.getContributionURI().startsWith("bundleclass:") ) {
- NewDynamicMenuContributionClassWizard wizard = new NewDynamicMenuContributionClassWizard(contribution.getContributionURI());
- wizard.init( null, new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(shell, wizard);
- if( dialog.open() == Window.OK ) {
- IFile f = wizard.getFile();
- ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ IProject project, Shell shell, boolean forceNew) {
+ if (forceNew || contribution.getContributionURI() == null
+ || contribution.getContributionURI().trim().length() == 0
+ || !contribution.getContributionURI().startsWith("bundleclass:")) { //$NON-NLS-1$
+ final NewDynamicMenuContributionClassWizard wizard = new NewDynamicMenuContributionClassWizard(
+ contribution.getContributionURI());
+ wizard.init(null, new StructuredSelection(project));
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ final IFile f = wizard.getFile();
+ final ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
try {
String fullyQualified;
- if( el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0 ) {
- String packageName = el.getPackageDeclarations()[0].getElementName();
- String className = wizard.getDomainClass().getName();
- if( packageName.trim().length() > 0 ) {
- fullyQualified = packageName + "." + className;
+ if (el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0) {
+ final String packageName = el.getPackageDeclarations()[0].getElementName();
+ final String className = wizard.getDomainClass().getName();
+ if (packageName.trim().length() > 0) {
+ fullyQualified = packageName + "." + className; //$NON-NLS-1$
} else {
fullyQualified = className;
}
} else {
fullyQualified = wizard.getDomainClass().getName();
}
-
- Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified);
- if( cmd.canExecute() ) {
+
+ final Command cmd = SetCommand.create(domain, contribution,
+ ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI,
+ "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified); //$NON-NLS-1$ //$NON-NLS-2$
+ if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
- } catch (JavaModelException e) {
+ } catch (final JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- URI uri = URI.createURI(contribution.getContributionURI());
+ final URI uri = URI.createURI(contribution.getContributionURI());
if (uri.hasAuthority() && uri.segmentCount() == 1) {
- String symbolicName = uri.authority();
- String fullyQualified = uri.segment(0);
+ final String symbolicName = uri.authority();
+ final 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) ) {
+ .getProject(symbolicName);
+
+ if (!p.exists()) {
+ for (final IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ final 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);
+ final IJavaProject jp = JavaCore.create(p);
IType t = null;
- try {
- if (p.exists()){
- t = jp.findType(fullyQualified);
- }
- else
- {
- IJavaProject pprim = JavaCore.create(project);
- t = pprim.findType(fullyQualified);
- }
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (JavaModelException e) {
+ try {
+ if (p.exists()) {
+ t = jp.findType(fullyQualified);
+ }
+ else
+ {
+ final IJavaProject pprim = JavaCore.create(project);
+ t = pprim.findType(fullyQualified);
+ }
+ if (t != null) {
+ JavaUI.openInEditor(t);
+ } else {
createOpen(contribution, domain, project, shell, true);
- } catch (PartInitException e) {
- MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
+ }
+ } catch (final JavaModelException e) {
+ createOpen(contribution, domain, project, shell, true);
+ } catch (final PartInitException e) {
+ MessageDialog.openError(shell, Messages.ContributionEditor_FailedToOpenEditor, e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- MessageDialog.openError(shell, "Invalid URL",
- "The current url is invalid");
+ MessageDialog.openError(shell, Messages.ContributionEditor_InvalidURL,
+ Messages.ContributionEditor_CurrentURLIsInvalid);
}
}
}
+ @Override
public boolean isSupported(EClass element) {
return Util.isTypeOrSuper(MenuPackageImpl.Literals.DYNAMIC_MENU_CONTRIBUTION, element);
}
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 f1379dd0..cb9d5874 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
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- * Sopot Cela <sopotcela@gmail.com>
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Sopot Cela <sopotcela@gmail.com>
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x.extension;
@@ -15,6 +15,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard;
+import org.eclipse.e4.tools.emf.editor3x.Messages;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.ui.model.application.MContribution;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl;
@@ -38,101 +39,107 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
+@SuppressWarnings("restriction")
public class HandlerContributionEditor implements IContributionClassCreator {
+ @Override
public void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell) {
createOpen(contribution, domain, project, shell, false);
}
-
- private void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell, boolean forceNew) {
- if( forceNew || contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 || !contribution.getContributionURI().startsWith("bundleclass:") ) {
- NewHandlerClassWizard wizard = new NewHandlerClassWizard(contribution.getContributionURI());
- wizard.init( null, new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(shell, wizard);
- if( dialog.open() == Window.OK ) {
- IFile f = wizard.getFile();
- ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+
+ private void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell,
+ boolean forceNew) {
+ if (forceNew || contribution.getContributionURI() == null
+ || contribution.getContributionURI().trim().length() == 0
+ || !contribution.getContributionURI().startsWith("bundleclass:")) { //$NON-NLS-1$
+ final NewHandlerClassWizard wizard = new NewHandlerClassWizard(contribution.getContributionURI());
+ wizard.init(null, new StructuredSelection(project));
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ final IFile f = wizard.getFile();
+ final ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
try {
String fullyQualified;
- if( el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0 ) {
- String packageName = el.getPackageDeclarations()[0].getElementName();
- String className = wizard.getDomainClass().getName();
- if( packageName.trim().length() > 0 ) {
- fullyQualified = packageName + "." + className;
+ if (el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0) {
+ final String packageName = el.getPackageDeclarations()[0].getElementName();
+ final String className = wizard.getDomainClass().getName();
+ if (packageName.trim().length() > 0) {
+ fullyQualified = packageName + "." + className; //$NON-NLS-1$
} else {
fullyQualified = className;
}
} else {
fullyQualified = wizard.getDomainClass().getName();
}
-
- Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified);
- if( cmd.canExecute() ) {
+
+ final Command cmd = SetCommand.create(domain, contribution,
+ ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI,
+ "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified); //$NON-NLS-1$//$NON-NLS-2$
+ if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
- } catch (JavaModelException e) {
+ } catch (final JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- URI uri = URI.createURI(contribution.getContributionURI());
+ final URI uri = URI.createURI(contribution.getContributionURI());
if (uri.hasAuthority() && uri.segmentCount() == 1) {
- String symbolicName = uri.authority();
- String fullyQualified = uri.segment(0);
+ final String symbolicName = uri.authority();
+ final 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) ) {
+ .getProject(symbolicName);
+
+ if (!p.exists()) {
+ for (final IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ final 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);
+ final IJavaProject jp = JavaCore.create(p);
IType t = null;
- try {
- if (p.exists()){
- t = jp.findType(fullyQualified);
- }
- else
- {
- IJavaProject pprim = JavaCore.create(project);
- t = pprim.findType(fullyQualified);
- }
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (JavaModelException e) {
+ try {
+ if (p.exists()) {
+ t = jp.findType(fullyQualified);
+ }
+ else
+ {
+ final IJavaProject pprim = JavaCore.create(project);
+ t = pprim.findType(fullyQualified);
+ }
+ if (t != null) {
+ JavaUI.openInEditor(t);
+ } else {
createOpen(contribution, domain, project, shell, true);
- } catch (PartInitException e) {
- MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
+ }
+ } catch (final JavaModelException e) {
+ createOpen(contribution, domain, project, shell, true);
+ } catch (final PartInitException e) {
+ MessageDialog.openError(shell, Messages.ContributionEditor_FailedToOpenEditor, e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- MessageDialog.openError(shell, "Invalid URL",
- "The current url is invalid");
+ MessageDialog.openError(shell, Messages.ContributionEditor_InvalidURL,
+ Messages.ContributionEditor_CurrentURLIsInvalid);
}
}
}
+ @Override
public boolean isSupported(EClass element) {
- return
- Util.isTypeOrSuper(CommandsPackageImpl.Literals.HANDLER,element)
- ||
+ return Util.isTypeOrSuper(CommandsPackageImpl.Literals.HANDLER, element)
+ ||
Util.isTypeOrSuper(MenuPackageImpl.Literals.DIRECT_MENU_ITEM, element)
||
Util.isTypeOrSuper(MenuPackageImpl.Literals.DIRECT_TOOL_ITEM, element);
}
-
-
+
} \ No newline at end of file
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 c1aa9a40..574ada9a 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
@@ -6,8 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- * Sopot Cela <sopotcela@gmail.com>
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Sopot Cela <sopotcela@gmail.com>
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x.extension;
@@ -15,6 +15,7 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.e4.internal.tools.wizards.classes.NewPartClassWizard;
+import org.eclipse.e4.tools.emf.editor3x.Messages;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.ui.model.application.MContribution;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
@@ -37,97 +38,102 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
+@SuppressWarnings("restriction")
public class PartContributionEditor implements IContributionClassCreator {
+ @Override
public void createOpen(MContribution contribution, EditingDomain domain,
- IProject project, Shell shell) {
+ IProject project, Shell shell) {
createOpen(contribution, domain, project, shell, false);
}
-
+
private void createOpen(MContribution contribution, EditingDomain domain,
- IProject project, Shell shell, boolean forceNew) {
- if ( forceNew || contribution.getContributionURI() == null
- || contribution.getContributionURI().trim().length() == 0
- || !contribution.getContributionURI().startsWith("bundleclass:")) {
- NewPartClassWizard wizard = new NewPartClassWizard(contribution.getContributionURI());
+ IProject project, Shell shell, boolean forceNew) {
+ if (forceNew || contribution.getContributionURI() == null
+ || contribution.getContributionURI().trim().length() == 0
+ || !contribution.getContributionURI().startsWith("bundleclass:")) { //$NON-NLS-1$
+ final NewPartClassWizard wizard = new NewPartClassWizard(contribution.getContributionURI());
wizard.init(null, new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(shell, wizard);
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == Window.OK) {
- IFile f = wizard.getFile();
- ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ final IFile f = wizard.getFile();
+ final ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
try {
String fullyQualified;
- if( el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0 ) {
- String packageName = el.getPackageDeclarations()[0].getElementName();
- String className = wizard.getDomainClass().getName();
- if( packageName.trim().length() > 0 ) {
- fullyQualified = packageName + "." + className;
+ if (el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0) {
+ final String packageName = el.getPackageDeclarations()[0].getElementName();
+ final String className = wizard.getDomainClass().getName();
+ if (packageName.trim().length() > 0) {
+ fullyQualified = packageName + "." + className; //$NON-NLS-1$
} else {
fullyQualified = className;
}
} else {
fullyQualified = wizard.getDomainClass().getName();
}
-
- Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified);
- if( cmd.canExecute() ) {
+
+ final Command cmd = SetCommand.create(domain, contribution,
+ ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI,
+ "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified); //$NON-NLS-1$ //$NON-NLS-2$
+ if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
- } catch (JavaModelException e) {
+ } catch (final JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- 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);
- IType t = null;
- try {
- if (p.exists()){
- t = jp.findType(fullyQualified);
- }
- else
- {
- IJavaProject pprim = JavaCore.create(project);
- t = pprim.findType(fullyQualified);
- }
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (JavaModelException e) {
- 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");
- }
+ final URI uri = URI.createURI(contribution.getContributionURI());
+ if (uri.hasAuthority() && uri.segmentCount() == 1) {
+ final String symbolicName = uri.authority();
+ final String fullyQualified = uri.segment(0);
+ IProject p = ResourcesPlugin.getWorkspace().getRoot()
+ .getProject(symbolicName);
+
+ if (!p.exists()) {
+ for (final IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ final 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) {
+ final IJavaProject jp = JavaCore.create(p);
+ IType t = null;
+ try {
+ if (p.exists()) {
+ t = jp.findType(fullyQualified);
+ }
+ else
+ {
+ final IJavaProject pprim = JavaCore.create(project);
+ t = pprim.findType(fullyQualified);
+ }
+ if (t != null) {
+ JavaUI.openInEditor(t);
+ } else {
+ createOpen(contribution, domain, project, shell, true);
+ }
+ } catch (final JavaModelException e) {
+ createOpen(contribution, domain, project, shell, true);
+ } catch (final PartInitException e) {
+ MessageDialog.openError(shell, Messages.ContributionEditor_FailedToOpenEditor, e.getMessage());
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ MessageDialog.openError(shell, Messages.ContributionEditor_InvalidURL,
+ Messages.ContributionEditor_CurrentURLIsInvalid);
+ }
}
}
+ @Override
public boolean isSupported(EClass element) {
return Util.isTypeOrSuper(BasicPackageImpl.Literals.PART, element);
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/ToolControlContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/ToolControlContributionEditor.java
index e5e472e4..4fbc09b8 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/ToolControlContributionEditor.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/ToolControlContributionEditor.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Dmitry Spiridenok <d.spiridenok@gmail.com> - Bug 412672
+ * Dmitry Spiridenok <d.spiridenok@gmail.com> - Bug 412672
******************************************************************************/
package org.eclipse.e4.tools.emf.editor3x.extension;
@@ -14,9 +14,9 @@ import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.e4.internal.tools.wizards.classes.NewToolControlClassWizard;
+import org.eclipse.e4.tools.emf.editor3x.Messages;
import org.eclipse.e4.tools.emf.ui.common.IContributionClassCreator;
import org.eclipse.e4.ui.model.application.MContribution;
-import org.eclipse.e4.ui.model.application.commands.impl.CommandsPackageImpl;
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
import org.eclipse.e4.ui.model.application.ui.menu.impl.MenuPackageImpl;
import org.eclipse.emf.common.command.Command;
@@ -37,26 +37,31 @@ import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.PartInitException;
+@SuppressWarnings("restriction")
public class ToolControlContributionEditor implements IContributionClassCreator {
+ @Override
public void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell) {
createOpen(contribution, domain, project, shell, false);
}
- private void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell, boolean forceNew) {
- if( forceNew || contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 || !contribution.getContributionURI().startsWith("bundleclass:") ) {
- NewToolControlClassWizard wizard = new NewToolControlClassWizard(contribution.getContributionURI());
- wizard.init( null, new StructuredSelection(project));
- WizardDialog dialog = new WizardDialog(shell, wizard);
- if( dialog.open() == Window.OK ) {
- IFile f = wizard.getFile();
- ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ private void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell,
+ boolean forceNew) {
+ if (forceNew || contribution.getContributionURI() == null
+ || contribution.getContributionURI().trim().length() == 0
+ || !contribution.getContributionURI().startsWith("bundleclass:")) { //$NON-NLS-1$
+ final NewToolControlClassWizard wizard = new NewToolControlClassWizard(contribution.getContributionURI());
+ wizard.init(null, new StructuredSelection(project));
+ final WizardDialog dialog = new WizardDialog(shell, wizard);
+ if (dialog.open() == Window.OK) {
+ final IFile f = wizard.getFile();
+ final ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
try {
String fullyQualified;
- if( el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0 ) {
- String packageName = el.getPackageDeclarations()[0].getElementName();
- String className = wizard.getDomainClass().getName();
- if( packageName.trim().length() > 0 ) {
- fullyQualified = packageName + "." + className;
+ if (el.getPackageDeclarations() != null && el.getPackageDeclarations().length > 0) {
+ final String packageName = el.getPackageDeclarations()[0].getElementName();
+ final String className = wizard.getDomainClass().getName();
+ if (packageName.trim().length() > 0) {
+ fullyQualified = packageName + "." + className; //$NON-NLS-1$
} else {
fullyQualified = className;
}
@@ -64,26 +69,28 @@ public class ToolControlContributionEditor implements IContributionClassCreator
fullyQualified = wizard.getDomainClass().getName();
}
- Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified);
- if( cmd.canExecute() ) {
+ final Command cmd = SetCommand.create(domain, contribution,
+ ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI,
+ "bundleclass://" + Util.getBundleSymbolicName(f.getProject()) + "/" + fullyQualified); //$NON-NLS-1$ //$NON-NLS-2$
+ if (cmd.canExecute()) {
domain.getCommandStack().execute(cmd);
}
- } catch (JavaModelException e) {
+ } catch (final JavaModelException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- URI uri = URI.createURI(contribution.getContributionURI());
+ final URI uri = URI.createURI(contribution.getContributionURI());
if (uri.hasAuthority() && uri.segmentCount() == 1) {
- String symbolicName = uri.authority();
- String fullyQualified = uri.segment(0);
+ final String symbolicName = uri.authority();
+ final 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) ) {
+ if (!p.exists()) {
+ for (final IProject check : ResourcesPlugin.getWorkspace().getRoot().getProjects()) {
+ final String name = Util.getBundleSymbolicName(check);
+ if (symbolicName.equals(name)) {
p = check;
break;
}
@@ -92,37 +99,39 @@ public class ToolControlContributionEditor implements IContributionClassCreator
// TODO If this is not a WS-Resource we need to open differently
if (p != null) {
- IJavaProject jp = JavaCore.create(p);
+ final IJavaProject jp = JavaCore.create(p);
IType t = null;
- try {
- if (p.exists()){
- t = jp.findType(fullyQualified);
- }
- else
- {
- IJavaProject pprim = JavaCore.create(project);
- t = pprim.findType(fullyQualified);
- }
- if( t != null ) {
- JavaUI.openInEditor(t);
- } else {
- createOpen(contribution, domain, project, shell, true);
- }
- } catch (JavaModelException e) {
+ try {
+ if (p.exists()) {
+ t = jp.findType(fullyQualified);
+ }
+ else
+ {
+ final IJavaProject pprim = JavaCore.create(project);
+ t = pprim.findType(fullyQualified);
+ }
+ if (t != null) {
+ JavaUI.openInEditor(t);
+ } else {
createOpen(contribution, domain, project, shell, true);
- } catch (PartInitException e) {
- MessageDialog.openError(shell, "Failed to open editor", e.getMessage());
+ }
+ } catch (final JavaModelException e) {
+ createOpen(contribution, domain, project, shell, true);
+ } catch (final PartInitException e) {
+ MessageDialog.openError(shell, Messages.ContributionEditor_FailedToOpenEditor, e.getMessage());
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} else {
- MessageDialog.openError(shell, "Invalid URL", "The current url is invalid");
+ MessageDialog.openError(shell, Messages.ContributionEditor_InvalidURL,
+ Messages.ContributionEditor_CurrentURLIsInvalid);
}
}
}
+ @Override
public boolean isSupported(EClass element) {
- return Util.isTypeOrSuper(MenuPackageImpl.Literals.TOOL_CONTROL,element);
+ return Util.isTypeOrSuper(MenuPackageImpl.Literals.TOOL_CONTROL, element);
}
}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/messages.properties b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/messages.properties
index 9df9660e..c711b366 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/messages.properties
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/messages.properties
@@ -1,3 +1,6 @@
+ContributionEditor_CurrentURLIsInvalid=The current url is invalid
+ContributionEditor_FailedToOpenEditor=Failed to open editor
+ContributionEditor_InvalidURL=Invalid URL
ModelEditorPreferencePage_Color=Color
ModelEditorPreferencePage_ForcesReadOnlyXMITab=(forces read only XMI tab)\n
ModelEditorPreferencePage_FormTab=Form Tab
diff --git a/bundles/org.eclipse.e4.tools.services/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.services/META-INF/MANIFEST.MF
index 7885c035..073063eb 100644
--- a/bundles/org.eclipse.e4.tools.services/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.services/META-INF/MANIFEST.MF
@@ -4,7 +4,7 @@ Bundle-Name: %Bundle-Name
Bundle-SymbolicName: org.eclipse.e4.tools.services
Bundle-Version: 0.12.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
-Export-Package: org.eclipse.e4.tools.services;version="0.12.0.qualifier";x-friends:="org.eclipse.e4.tools.compat",
+Export-Package: org.eclipse.e4.tools.services;version="0.12.0.qualifier";x-friends:="org.eclipse.e4.tools.compat,org.eclipse.e4.tools.emf.editor3x",
org.eclipse.e4.tools.services.impl;version="0.12.0.qualifier";x-friends:="org.eclipse.e4.tools.emf.ui"
Bundle-Vendor: %Bundle-Vendor
Require-Bundle: org.eclipse.swt;bundle-version="3.7.0",
diff --git a/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF
index 7c857749..e8c6bd9e 100644
--- a/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools/META-INF/MANIFEST.MF
@@ -23,7 +23,7 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.e4.internal.tools.ToolsPlugin
Export-Package: org.eclipse.e4.internal.tools;x-internal:=true,
- org.eclipse.e4.internal.tools.wizards.classes;x-internal:=true,
+ org.eclipse.e4.internal.tools.wizards.classes;x-friends:="org.eclipse.e4.tools.emf.editor3x",
org.eclipse.e4.internal.tools.wizards.classes.templates;x-internal:=true,
org.eclipse.e4.internal.tools.wizards.model;x-internal:=true,
org.eclipse.e4.internal.tools.wizards.project;x-internal:=true

Back to the top