Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Schindl2010-07-05 12:53:06 +0000
committerThomas Schindl2010-07-05 12:53:06 +0000
commit0bb5c203653e905b9a2c125e3c29f80e0108c178 (patch)
treec77c4e5373506e39b5fe3450fa7ec7be38289221 /bundles/org.eclipse.e4.tools.emf.editor3x
parentce97618cb08abb78a54f069b517e7af94089d9f4 (diff)
downloadorg.eclipse.e4.tools-0bb5c203653e905b9a2c125e3c29f80e0108c178.tar.gz
org.eclipse.e4.tools-0bb5c203653e905b9a2c125e3c29f80e0108c178.tar.xz
org.eclipse.e4.tools-0bb5c203653e905b9a2c125e3c29f80e0108c178.zip
Bug 304584 - [Tooling] Implement Workbench-Model-Tooling
Diffstat (limited to 'bundles/org.eclipse.e4.tools.emf.editor3x')
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF5
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.pngbin591 -> 0 bytes
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml33
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/E4WorkbenchModelEditor.java46
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java101
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java87
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java187
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java27
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java27
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java199
10 files changed, 243 insertions, 469 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
index e69d0595..33eead93 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/META-INF/MANIFEST.MF
@@ -24,7 +24,8 @@ Require-Bundle: org.eclipse.ui;bundle-version="3.6.0",
org.eclipse.emf.edit;bundle-version="2.6.0",
org.eclipse.e4.ui.services;bundle-version="0.9.1",
org.eclipse.e4.tools.compat;bundle-version="1.0.0",
- org.eclipse.e4.tools.services;bundle-version="1.0.0"
+ org.eclipse.e4.tools.services;bundle-version="1.0.0",
+ org.eclipse.e4.tools;bundle-version="0.9.0",
+ org.eclipse.jdt.ui;bundle-version="3.6.0"
Service-Component: OSGI-INF/pdecontributionprovider.xml, OSGI-INF/xmiresourcecontextfunction.xml, OSGI-INF/projectfunction.xml
Bundle-ActivationPolicy: lazy
-Export-Package: org.eclipse.e4.tools.emf.editor3x.wizard;x-internal:=true
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png b/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png
deleted file mode 100644
index 6187b15a..00000000
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/icons/full/obj16/plugin.png
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml
index dc050c95..a6d28c8a 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/plugin.xml
@@ -13,30 +13,13 @@
</editor>
</extension>
<extension
- point="org.eclipse.ui.newWizards">
- <wizard
- canFinishEarly="false"
- category="org.eclipse.e4"
- class="org.eclipse.e4.tools.emf.editor3x.wizard.NewApplicationModelWizard"
- hasPages="true"
- icon="icons/full/obj16/application_view_tile.png"
- id="org.eclipse.e4.tools.emf.editor3x.newappmodel"
- name="New Application Model">
- </wizard>
-
- <wizard
- canFinishEarly="false"
- category="org.eclipse.e4"
- class="org.eclipse.e4.tools.emf.editor3x.wizard.NewContributionModelWizard"
- hasPages="true"
- icon="icons/full/obj16/plugin.png"
- id="org.eclipse.e4.tools.emf.editor3x.newmodelcontribution"
- name="New Model Fragment">
- </wizard>
- <category
- id="org.eclipse.e4"
- name="e4">
- </category>
- </extension>
+ point="org.eclipse.e4.tools.emf.ui.editors">
+ <contributionClassCreator
+ class="org.eclipse.e4.tools.emf.editor3x.extension.HandlerContributionEditor">
+ </contributionClassCreator>
+ <contributionClassCreator
+ class="org.eclipse.e4.tools.emf.editor3x.extension.PartContributionEditor">
+ </contributionClassCreator>
+ </extension>
</plugin>
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 3484bed5..726842fa 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
@@ -11,12 +11,54 @@
package org.eclipse.e4.tools.emf.editor3x;
import org.eclipse.e4.tools.compat.parts.DIEditorPart;
+import org.eclipse.e4.tools.emf.ui.common.IModelResource.ModelListener;
import org.eclipse.e4.tools.emf.ui.internal.wbm.ApplicationModelEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.actions.ActionFactory;
@SuppressWarnings("restriction")
-public class E4WorkbenchModelEditor extends DIEditorPart<ApplicationModelEditor> {
+public class E4WorkbenchModelEditor extends
+ DIEditorPart<ApplicationModelEditor> {
+ private UndoAction undoAction;
+ private RedoAction redoAction;
+
+ private ModelListener listener = new ModelListener() {
+
+ public void dirtyChanged() {
+ firePropertyChange(PROP_DIRTY);
+ }
+
+ public void commandStackChanged() {
+
+ }
+ };
public E4WorkbenchModelEditor() {
- super(ApplicationModelEditor.class);
+ super(ApplicationModelEditor.class, COPY|CUT|PASTE);
+ }
+
+ protected void makeActions() {
+ super.makeActions();
+ undoAction = new UndoAction(getComponent().getModelProvider());
+ redoAction = new RedoAction(getComponent().getModelProvider());
+
+ getEditorSite().getActionBars().setGlobalActionHandler(
+ ActionFactory.UNDO.getId(), undoAction);
+ getEditorSite().getActionBars().setGlobalActionHandler(
+ ActionFactory.REDO.getId(), redoAction);
+ }
+
+ @Override
+ public void dispose() {
+ if (undoAction != null)
+ undoAction.dispose();
+
+ if (redoAction != null)
+ redoAction.dispose();
+
+ if (listener != 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/extension/HandlerContributionEditor.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java
new file mode 100644
index 00000000..b2bc2a31
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/HandlerContributionEditor.java
@@ -0,0 +1,101 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.editor3x.extension;
+
+import java.net.URL;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.e4.internal.tools.wizards.classes.NewHandlerClassWizard;
+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.MHandler;
+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;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.internal.ui.JavaPlugin;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public class HandlerContributionEditor implements IContributionClassCreator {
+
+ public void createOpen(MContribution contribution, EditingDomain domain, IProject project, Shell shell) {
+ if( contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 ) {
+ NewHandlerClassWizard wizard = new NewHandlerClassWizard();
+ wizard.init( null, new StructuredSelection(project));
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ if( dialog.open() == WizardDialog.OK ) {
+ IFile f = wizard.getFile();
+ ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ try {
+ String packageName = el.getPackageDeclarations()[0].getElementName();
+ String className = wizard.getDomainClass().getName();
+ Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "platform:/plugin/" + f.getProject().getName() + "/" + packageName+"."+className);
+ if( cmd.canExecute() ) {
+ domain.getCommandStack().execute(cmd);
+ }
+ el.open(null);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ URI uri = URI.createURI(contribution.getContributionURI());
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(uri.segment(1));
+ //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));
+ JavaUI.openInEditor(t);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public boolean isSupported(EClass element) {
+ return
+ isTypeOrSuper(CommandsPackageImpl.Literals.HANDLER,element)
+ ||
+ isTypeOrSuper(MenuPackageImpl.Literals.DIRECT_MENU_ITEM, element)
+ ||
+ isTypeOrSuper(MenuPackageImpl.Literals.DIRECT_TOOL_ITEM, element);
+ }
+
+ private boolean isTypeOrSuper(EClass eClass, EClass element) {
+ return eClass.equals(element) || element.getEAllSuperTypes().contains(eClass);
+ }
+} \ 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
new file mode 100644
index 00000000..65195eac
--- /dev/null
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/extension/PartContributionEditor.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2010 BestSolution.at and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ ******************************************************************************/
+package org.eclipse.e4.tools.emf.editor3x.extension;
+
+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.ui.common.IContributionClassCreator;
+import org.eclipse.e4.ui.model.application.MContribution;
+import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
+import org.eclipse.e4.ui.model.application.ui.basic.impl.BasicPackageImpl;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.jdt.core.ICompilationUnit;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PartInitException;
+
+public class PartContributionEditor implements IContributionClassCreator {
+
+ public void createOpen(MContribution contribution, EditingDomain domain,
+ IProject project, Shell shell) {
+ if( contribution.getContributionURI() == null || contribution.getContributionURI().trim().length() == 0 ) {
+ NewPartClassWizard wizard = new NewPartClassWizard();
+ wizard.init( null, new StructuredSelection(project));
+ WizardDialog dialog = new WizardDialog(shell, wizard);
+ if( dialog.open() == WizardDialog.OK ) {
+ IFile f = wizard.getFile();
+ ICompilationUnit el = JavaCore.createCompilationUnitFrom(f);
+ try {
+ String packageName = el.getPackageDeclarations()[0].getElementName();
+ String className = wizard.getDomainClass().getName();
+ Command cmd = SetCommand.create(domain, contribution, ApplicationPackageImpl.Literals.CONTRIBUTION__CONTRIBUTION_URI, "platform:/plugin/" + f.getProject().getName() + "/" + packageName+"."+className);
+ if( cmd.canExecute() ) {
+ domain.getCommandStack().execute(cmd);
+ }
+ el.open(null);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ } else {
+ URI uri = URI.createURI(contribution.getContributionURI());
+ IProject p = ResourcesPlugin.getWorkspace().getRoot().getProject(uri.segment(1));
+ //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));
+ JavaUI.openInEditor(t);
+ } catch (JavaModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+
+ public boolean isSupported(EClass element) {
+ return BasicPackageImpl.Literals.PART == element
+ || element.getEAllSuperTypes().contains(
+ BasicPackageImpl.Literals.PART);
+ }
+
+}
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java
deleted file mode 100644
index 27d175bf..00000000
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/BaseApplicationModelWizard.java
+++ /dev/null
@@ -1,187 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- ******************************************************************************/
-package org.eclipse.e4.tools.emf.editor3x.wizard;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.emf.ecore.resource.ResourceSet;
-import org.eclipse.emf.ecore.resource.impl.ResourceSetImpl;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.wizard.Wizard;
-import org.eclipse.ui.INewWizard;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWizard;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.part.ISetSelectionTarget;
-
-public abstract class BaseApplicationModelWizard extends Wizard implements INewWizard {
- private NewModelFilePage page;
- private ISelection selection;
-
- protected IWorkbench workbench;
-
- /**
- * Constructor for NewApplicationModelWizard.
- */
- public BaseApplicationModelWizard() {
- super();
- setNeedsProgressMonitor(true);
- }
-
- /**
- * Adding the page to the wizard.
- */
-
- public void addPages() {
- page = new NewModelFilePage(selection,getDefaultFileName());
- addPage(page);
- }
-
- public abstract String getDefaultFileName();
-
- @Override
- public boolean performFinish() {
- try {
- // Remember the file.
- //
- final IFile modelFile = getModelFile();
-
- // Do the work within an operation.
- //
- WorkspaceModifyOperation operation =
- new WorkspaceModifyOperation() {
- @Override
- protected void execute(IProgressMonitor progressMonitor) {
- try {
- // Create a resource set
- //
- ResourceSet resourceSet = new ResourceSetImpl();
-
- // Get the URI of the model file.
- //
- URI fileURI = URI.createPlatformResourceURI(modelFile.getFullPath().toString(), true);
-
- // Create a resource for this file.
- //
- Resource resource = resourceSet.createResource(fileURI);
-
- // Add the initial model object to the contents.
- //
- EObject rootObject = createInitialModel();
- if (rootObject != null) {
- resource.getContents().add(rootObject);
- }
-
- // Save the contents of the resource to the file system.
- //
- Map<Object, Object> options = new HashMap<Object, Object>();
- resource.save(options);
- }
- catch (Exception exception) {
- throw new RuntimeException(exception);
- }
- finally {
- progressMonitor.done();
- }
- }
- };
-
- getContainer().run(false, false, operation);
-
- // Select the new file resource in the current view.
- //
- IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
- IWorkbenchPage page = workbenchWindow.getActivePage();
- final IWorkbenchPart activePart = page.getActivePart();
- if (activePart instanceof ISetSelectionTarget) {
- final ISelection targetSelection = new StructuredSelection(modelFile);
- getShell().getDisplay().asyncExec
- (new Runnable() {
- public void run() {
- ((ISetSelectionTarget)activePart).selectReveal(targetSelection);
- }
- });
- }
-
- // Open an editor on the new file.
- //
- try {
- page.openEditor
- (new FileEditorInput(modelFile),
- workbench.getEditorRegistry().getDefaultEditor(modelFile.getFullPath().toString()).getId());
- }
- catch (PartInitException exception) {
- MessageDialog.openError(workbenchWindow.getShell(), "Could not init editor", exception.getMessage()); //$NON-NLS-1$
- return false;
- }
-
- return true;
- }
- catch (Exception exception) {
- MessageDialog.openError(getShell(), "Error", exception.getMessage());
- return false;
- }
- }
-
- protected abstract EObject createInitialModel();
-
- private IFile getModelFile() throws CoreException {
- String containerName = page.getContainerName();
- String fileName = page.getFileName();
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IResource resource = root.findMember(new Path(containerName));
- if (!resource.exists() || !(resource instanceof IContainer)) {
- throwCoreException("Container \"" + containerName
- + "\" does not exist.");
- }
- IContainer container = (IContainer) resource;
- return container.getFile(new Path(fileName));
- }
-
- private void throwCoreException(String message) throws CoreException {
- IStatus status = new Status(IStatus.ERROR,
- "org.eclipse.e4.tools.emf.editor3x", IStatus.OK, message, null);
- throw new CoreException(status);
- }
-
- /**
- * We will accept the selection in the workbench to see if we can initialize
- * from it.
- *
- * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection)
- */
- public void init(IWorkbench workbench, IStructuredSelection selection) {
- this.workbench = workbench;
- this.selection = selection;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java
deleted file mode 100644
index ed161a7e..00000000
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewApplicationModelWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- ******************************************************************************/
-package org.eclipse.e4.tools.emf.editor3x.wizard;
-
-import org.eclipse.e4.ui.model.application.MApplicationFactory;
-import org.eclipse.emf.ecore.EObject;
-
-
-public class NewApplicationModelWizard extends BaseApplicationModelWizard {
-
- @Override
- public String getDefaultFileName() {
- return "Application.e4xmi";
- }
-
- protected EObject createInitialModel() {
- return (EObject) MApplicationFactory.INSTANCE.createApplication();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java
deleted file mode 100644
index 20b95dd2..00000000
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewContributionModelWizard.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- ******************************************************************************/
-package org.eclipse.e4.tools.emf.editor3x.wizard;
-
-import org.eclipse.e4.ui.model.fragment.MFragmentFactory;
-import org.eclipse.emf.ecore.EObject;
-
-
-public class NewContributionModelWizard extends BaseApplicationModelWizard {
-
- @Override
- public String getDefaultFileName() {
- return "fragment.e4xmi";
- }
-
- protected EObject createInitialModel() {
- return (EObject) MFragmentFactory.INSTANCE.createModelFragments();
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java
deleted file mode 100644
index 90154bad..00000000
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/wizard/NewModelFilePage.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 BestSolution.at and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
- ******************************************************************************/
-package org.eclipse.e4.tools.emf.editor3x.wizard;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.dialogs.IDialogPage;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.wizard.WizardPage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.dialogs.ContainerSelectionDialog;
-
-/**
- * The "New" wizard page allows setting the container for the new file as well
- * as the file name. The page will only accept file name without the extension
- * OR with the extension that matches the expected one (e4xmi).
- */
-
-public class NewModelFilePage extends WizardPage {
- private Text containerText;
-
- private Text fileText;
-
- private ISelection selection;
-
- private String defaultFilename;
-
- /**
- * Constructor for SampleNewWizardPage.
- *
- * @param pageName
- */
- public NewModelFilePage(ISelection selection, String defaultFilename) {
- super("wizardPage");
- setTitle("Multi-page Editor File");
- setDescription("This wizard creates a new file with *.e4xmi extension that can be opened by a multi-page editor.");
- this.selection = selection;
- this.defaultFilename = defaultFilename;
- }
-
- /**
- * @see IDialogPage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- Composite container = new Composite(parent, SWT.NULL);
- GridLayout layout = new GridLayout();
- container.setLayout(layout);
- layout.numColumns = 3;
- layout.verticalSpacing = 9;
- Label label = new Label(container, SWT.NULL);
- label.setText("&Container:");
-
- containerText = new Text(container, SWT.BORDER | SWT.SINGLE);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- containerText.setLayoutData(gd);
- containerText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- });
-
- Button button = new Button(container, SWT.PUSH);
- button.setText("Browse...");
- button.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleBrowse();
- }
- });
- label = new Label(container, SWT.NULL);
- label.setText("&File name:");
-
- fileText = new Text(container, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- fileText.setLayoutData(gd);
- fileText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- dialogChanged();
- }
- });
- initialize();
- dialogChanged();
- setControl(container);
- }
-
- /**
- * Tests if the current workbench selection is a suitable container to use.
- */
-
- private void initialize() {
- if (selection != null && selection.isEmpty() == false
- && selection instanceof IStructuredSelection) {
- IStructuredSelection ssel = (IStructuredSelection) selection;
- if (ssel.size() > 1)
- return;
- Object obj = ssel.getFirstElement();
- if (obj instanceof IResource) {
- IContainer container;
- if (obj instanceof IContainer)
- container = (IContainer) obj;
- else
- container = ((IResource) obj).getParent();
- containerText.setText(container.getFullPath().toString());
- }
- }
- fileText.setText(defaultFilename);
- }
-
- /**
- * Uses the standard container selection dialog to choose the new value for
- * the container field.
- */
-
- private void handleBrowse() {
- ContainerSelectionDialog dialog = new ContainerSelectionDialog(
- getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
- "Select new file container");
- if (dialog.open() == ContainerSelectionDialog.OK) {
- Object[] result = dialog.getResult();
- if (result.length == 1) {
- containerText.setText(((Path) result[0]).toString());
- }
- }
- }
-
- /**
- * Ensures that both text fields are set.
- */
-
- private void dialogChanged() {
- IResource container = ResourcesPlugin.getWorkspace().getRoot()
- .findMember(new Path(getContainerName()));
- String fileName = getFileName();
-
- if (getContainerName().length() == 0) {
- updateStatus("File container must be specified");
- return;
- }
- if (container == null
- || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) {
- updateStatus("File container must exist");
- return;
- }
- if (!container.isAccessible()) {
- updateStatus("Project must be writable");
- return;
- }
- if (fileName.length() == 0) {
- updateStatus("File name must be specified");
- return;
- }
- if (fileName.replace('\\', '/').indexOf('/', 1) > 0) {
- updateStatus("File name must be valid");
- return;
- }
- int dotLoc = fileName.lastIndexOf('.');
- if (dotLoc != -1) {
- String ext = fileName.substring(dotLoc + 1);
- if (ext.equalsIgnoreCase("e4xmi") == false) {
- updateStatus("File extension must be \"e4xmi\"");
- return;
- }
- }
- updateStatus(null);
- }
-
- private void updateStatus(String message) {
- setErrorMessage(message);
- setPageComplete(message == null);
- }
-
- public String getContainerName() {
- return containerText.getText();
- }
-
- public String getFileName() {
- return fileText.getText();
- }
-} \ No newline at end of file

Back to the top