From 26ee8ffd496db8b6fec93d39e356be05b5d11b13 Mon Sep 17 00:00:00 2001 From: Laurent Wouters Date: Fri, 4 Apr 2014 16:09:14 +0200 Subject: [clean] Retiring org.eclipse.papyrus.diagram.umltools.clazz Signed-off-by: Laurent Wouters --- .../.classpath | 7 - .../.project | 28 --- .../META-INF/MANIFEST.MF | 12 - .../build.properties | 4 - .../icons/ClassDiagram.gif | Bin 120 -> 0 bytes .../plugin.xml | 72 ------ .../umltools/clazz/ClassDiagramEditorFactory.java | 124 ---------- .../umltools/clazz/ClassDiagramEditorModel.java | 155 ------------ .../umltools/clazz/CreateClassDiagramHandler.java | 259 --------------------- .../clazz/UmlClassDiagramForMultiEditor.java | 161 ------------- 10 files changed, 822 deletions(-) delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.classpath delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.project delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/META-INF/MANIFEST.MF delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/build.properties delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/icons/ClassDiagram.gif delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/plugin.xml delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorFactory.java delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorModel.java delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/CreateClassDiagramHandler.java delete mode 100644 deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/UmlClassDiagramForMultiEditor.java diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.classpath b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.classpath deleted file mode 100644 index 45f024e850e..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.project b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.project deleted file mode 100644 index 62152d80745..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/.project +++ /dev/null @@ -1,28 +0,0 @@ - - - org.eclipse.papyrus.diagram.umltools.clazz - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.eclipse.pde.ManifestBuilder - - - - - org.eclipse.pde.SchemaBuilder - - - - - - org.eclipse.jdt.core.javanature - org.eclipse.pde.PluginNature - - diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/META-INF/MANIFEST.MF b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/META-INF/MANIFEST.MF deleted file mode 100644 index 44c7a0051e4..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/META-INF/MANIFEST.MF +++ /dev/null @@ -1,12 +0,0 @@ -Manifest-Version: 1.0 -Bundle-ManifestVersion: 2 -Bundle-Name: Clazz -Bundle-SymbolicName: org.eclipse.papyrus.diagram.umltools.clazz;singleton:=true -Bundle-Version: 0.7.0.qualifier -Export-Package: org.eclipse.papyrus.diagram.umltools.clazz -Require-Bundle: org.eclipse.uml2.diagram.clazz;bundle-version="0.9.0", - org.eclipse.ui.ide;bundle-version="3.5.1", - org.eclipse.gmf.runtime.diagram.ui.resources.editor;bundle-version="1.2.0", - org.eclipse.emf.common.ui;bundle-version="2.5.0", - org.eclipse.papyrus.core;bundle-version="0.7.0", - org.eclipse.papyrus.core.adaptor.gmf;bundle-version="0.7.0" diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/build.properties b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/build.properties deleted file mode 100644 index 53c8b373787..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/build.properties +++ /dev/null @@ -1,4 +0,0 @@ -source.. = src/ -bin.includes = META-INF/,\ - .,\ - plugin.xml diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/icons/ClassDiagram.gif b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/icons/ClassDiagram.gif deleted file mode 100644 index edf2be7e83d..00000000000 Binary files a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/icons/ClassDiagram.gif and /dev/null differ diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/plugin.xml b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/plugin.xml deleted file mode 100644 index dff8aaf444b..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/plugin.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorFactory.java b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorFactory.java deleted file mode 100644 index ea4e01b9a6c..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorFactory.java +++ /dev/null @@ -1,124 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2008 CEA LIST. - * - * - * 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: - * Cedric Dumoulin Cedric.Dumoulin@lifl.fr - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.diagram.umltools.clazz; - -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptor; -import org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IPageModel; - -/** - * @author dumoulin - * - */ -public class ClassDiagramEditorFactory implements IPluggableEditorFactory { - - /** - * Expected diagram type - */ - private String expectedType; - - /** - * Main service Registry. - * Initialized when the factory is registered to the main editor. - */ - private ServicesRegistry servicesRegistry; - - /** - * Editor Descriptor containing data from the Eclipse extension declaration. - */ - private EditorDescriptor editorDescriptor; - - /** - * @param diagramClass - * @param expectedType - */ - public ClassDiagramEditorFactory() { - expectedType = getDiagramNotationID(); - } - - /** - * Initialize the factory. - * @see org.eclipse.papyrus.core.extension.diagrameditor.IPluggableEditorFactory#init(org.eclipse.papyrus.core.services.ServicesRegistry, org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptor) - * - * @param serviceRegistry - * @param editorDescriptor - */ - public void init(ServicesRegistry serviceRegistry, EditorDescriptor editorDescriptor) { - this.servicesRegistry = serviceRegistry; - this.editorDescriptor = editorDescriptor; - - } - - /** - * Return true if this PageModelFactory can create a PageModel for the specified pageIdentifier. - * The pageIdentifier is an instance of Diagram. - * - * @see org.eclipse.papyrus.core.extension.diagrameditor.IEditorFactory#isPageModelFactoryFor(java.lang.Object) - * @param pageIdentifier - * @return - * - */ - public boolean isPageModelFactoryFor(Object pageIdentifier) { - - if(pageIdentifier instanceof Diagram) { - Diagram diagram = (Diagram)pageIdentifier; - final String type = diagram.getType(); - return getExpectedType().equals(type); - } - // no - return false; - - } - - /** - * Create a new instance of the EditorModel for the specified pageIdentifier. - * @see org.eclipse.papyrus.core.editorsfactory.IEditorFactory#createIPageModel(java.lang.Object) - * - * @param pageIdentifier - * @return - */ - public IPageModel createIPageModel(Object pageIdentifier) { - return new ClassDiagramEditorModel((Diagram)pageIdentifier, servicesRegistry, editorDescriptor); - } - - /** - * @return the diagramClass - */ -// private Class getDiagramClass() { -// return diagramClass; -// } - - - /** - * @return the expectedType - */ - private String getExpectedType() { - return expectedType; - } - - /** - * Get the ID identifying the type of the Diagram. - * {@inheritDoc} - */ - protected String getDiagramNotationID() { - return org.eclipse.uml2.diagram.clazz.edit.parts.PackageEditPart.MODEL_ID; - } - - - - -} diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorModel.java b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorModel.java deleted file mode 100644 index cd6f7df4192..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/ClassDiagramEditorModel.java +++ /dev/null @@ -1,155 +0,0 @@ -package org.eclipse.papyrus.diagram.umltools.clazz; - -import java.lang.reflect.Constructor; - -import org.eclipse.gef.ui.parts.GraphicalEditor; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.extension.diagrameditor.EditorDescriptor; -import org.eclipse.papyrus.core.multidiagram.actionbarcontributor.ActionBarContributorRegistry; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.part.EditorActionBarContributor; - -/** - * IEditorModel used by the SashEditor to create a nested editor. - * Each nested editor instance is associated to one and only one instance of this model. - * - * @author cedric dumoulin - * - */ -class ClassDiagramEditorModel implements IEditorModel { - - /** - * The Diagram object describing the diagram. - */ - private Diagram diagram; - - /** - * The servicesRegistry provided at creation. - */ - private ServicesRegistry servicesRegistry; - - /** - * Editor Descriptor containing data from the Eclipse extension - */ - private EditorDescriptor editorDescriptor; - - /** - * - * Constructor. - * - * @param pageIdentifier - * @param servicesRegistry - * @param editorDescriptor - */ - public ClassDiagramEditorModel(Diagram pageIdentifier, ServicesRegistry servicesRegistry, EditorDescriptor editorDescriptor) { - diagram = pageIdentifier; - this.servicesRegistry = servicesRegistry; - this.editorDescriptor = editorDescriptor; - } - - /** - * Create the IEditor for the diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel#createIEditorPart() - * @return - * @throws PartInitException - * - */ - public IEditorPart createIEditorPart() throws PartInitException { - GraphicalEditor editor; - try { - editor = new UmlClassDiagramForMultiEditor(servicesRegistry, diagram); - } catch (BackboneException e) { - throw new PartInitException("Can't create instance of " + UmlClassDiagramForMultiEditor.class.getName(), e); - } catch (ServiceException e) { - throw new PartInitException("Can't create instance of " + UmlClassDiagramForMultiEditor.class.getName(), e); - } - - return editor; - - } - - /** - * Get the action bar requested by the Editor. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IEditorModel#getActionBarContributor() - * @return - * - */ - public EditorActionBarContributor getActionBarContributor() { - - String actionBarId = editorDescriptor.getActionBarContributorId(); - - // Do nothing if no EditorActionBarContributor is specify. - if(actionBarId == null || actionBarId.length() == 0) { - return null; - } - - // Try to get it. - - // Get ServiceRegistry - // ServicesRegistry serviceRegistry = getServicesRegistry(); - ActionBarContributorRegistry registry; - try { - registry = (ActionBarContributorRegistry)servicesRegistry.getService(ActionBarContributorRegistry.class); - } catch (ServiceException e) { - // Service not found - // TODO Log the error - e.printStackTrace(); - return null; - } - - try { - return registry.getActionBarContributor(actionBarId); - } catch (BackboneException e) { - // TODO Log the error and throw an exception instead - e.printStackTrace(); - return null; - } - } - - /** - * Get the underlying RawModel. Return the Diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getRawModel() - * @return - * - */ - public Object getRawModel() { - return diagram; - } - - /** - * Get the icon to be shown by Tabs - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabIcon() - * @return - * - */ - public Image getTabIcon() { - ImageDescriptor imageDescriptor = editorDescriptor.getIcon(); - if(imageDescriptor == null) - return null; - - return imageDescriptor.createImage(); - } - - /** - * Get the title of the Diagram. - * - * @see org.eclipse.papyrus.sasheditor.contentprovider.IPageModel#getTabTitle() - * @return - * - */ - public String getTabTitle() { - return diagram.getName(); - } - -} diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/CreateClassDiagramHandler.java b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/CreateClassDiagramHandler.java deleted file mode 100644 index 3711c1a54e5..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/CreateClassDiagramHandler.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.diagram.umltools.clazz; - -import java.util.Collections; - -import org.eclipse.core.commands.AbstractHandler; -import org.eclipse.core.commands.ExecutionEvent; -import org.eclipse.core.commands.ExecutionException; -import org.eclipse.core.commands.IHandler; -import org.eclipse.core.commands.operations.OperationHistoryFactory; -import org.eclipse.core.runtime.IAdaptable; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.EditPart; -import org.eclipse.gmf.runtime.common.core.command.CommandResult; -import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint; -import org.eclipse.gmf.runtime.diagram.core.services.ViewService; -import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.gmf.runtime.notation.View; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.papyrus.core.utils.BusinessModelResolver; -import org.eclipse.papyrus.core.utils.EditorUtils; -import org.eclipse.papyrus.sasheditor.contentprovider.di.IPageMngr; -import org.eclipse.ui.PlatformUI; -import org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditorPlugin; -import org.eclipse.uml2.uml.UMLFactory; - - -/** - * A Handler responsible to create the EObject representing a UmlTools class diagram. - * The handler also add the created EObject to the SashContainerProvider. In reaction, the SashEditor - * will instanciate the corresponding Editor. - * - * @author cedric dumoulin - * - */ -public class CreateClassDiagramHandler extends AbstractHandler implements IHandler { - - /** - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * - * @param event - * @return - * @throws ExecutionException - */ - - public Object execute(ExecutionEvent event) throws ExecutionException { - - // Choose one of the two execution mode. - executeAsTransaction(event); -// doExecute(event); - // Return null, as required by the API - return null; - } - - /** - * Execute the handler in a undoable transaction. - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * - * @param event - * @return - * @throws ExecutionException - */ - - public void executeAsTransaction(final ExecutionEvent event) throws ExecutionException { - - TransactionalEditingDomain editingDomain = EditorUtils.getTransactionalEditingDomain(); - - // Create a transactional command. - AbstractTransactionalCommand command = new AbstractTransactionalCommand(editingDomain,"Create Class Diagram", Collections.EMPTY_LIST) { - - @Override - protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info) - throws ExecutionException { - - CommandResult commandResult; - try { - // Call the real implementation - CreateClassDiagramHandler.this.doExecute(event); - commandResult = CommandResult.newOKCommandResult(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - commandResult = CommandResult.newErrorCommandResult("Error during diagram creation"); - } - return commandResult; - } - }; - - // Execute the command - try { - OperationHistoryFactory.getOperationHistory().execute(command, new NullProgressMonitor(), null); - } catch (ExecutionException e) { - e.printStackTrace(); - // TODO log the error - } - } - - /** - * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent) - * - * @param event - * @return - * @throws ExecutionException - */ - - public void doExecute(ExecutionEvent event) throws ExecutionException { - - // First, create the EObject used to represent the Editor. - // This is generally the root object used to instantiate the corresponding editor. - EObject editorRootObject = createEditorRootObject(); - // Then add the root object to the SashContainerProvider - IPageMngr pageMngr = EditorUtils.getIPageMngr(); - pageMngr.openPage(editorRootObject); - } - - /** - * Create the root object used to find the type of the editor to create, and provided to the new instance. - * - * @return - */ - private EObject createEditorRootObject() { - - String diagramName = "newDiagram"; - EObject associatedDomainRoot = getDomainRoot(); - Resource diagramResource = getDiagramResource(); - - Diagram diagram = ViewService.createDiagram(associatedDomainRoot, getDiagramNotationID(), getPreferenceHint()); - if(diagram != null) { - diagram.setName(diagramName); - // TODO : required ?? - diagram.setElement(associatedDomainRoot); - diagramResource.getContents().add(diagram); -// initializeModel(owner); -// initializeDiagram(diagram); - } - - - return diagram; - } - - /** - * Get the domain element that will be associated to the Diagram. - * chack if the selected element can be used as domain element. - * If nothing is found, create a domain element. - * @return The domain element that will be associated to the diagram. - * - */ - private EObject getDomainRoot() { - - EObject domainElement = getSelectedDomainElement(); - if( domainElement != null) - return domainElement; - - // Create one - return createDomainElement(); - } - - /** - * Create the domain element that will be associated to the Diagram. - * @return - */ - protected EObject createDomainElement() { - return UMLFactory.eINSTANCE.createModel(); - - } - - /** - * Get the domain element associated to the current selection. - * @return The domain EObject associated to the current Eclipse selection, or null. - */ - private EObject getSelectedDomainElement() { - EObject eObject = null; - Object selection = getCurrentSelection(); - if(selection != null) { - Object businessObject = getDomainModel(selection); - if(businessObject instanceof EObject) { - eObject = (EObject)businessObject; - } - } - return eObject; - } - - /** - * Get current selection first element. - * - * @return the selected element or null. - */ - private Object getCurrentSelection() { - ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection(); - if(selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection)selection; - return structuredSelection.getFirstElement(); - } - - return null; - } - - /** - * Get the domain object associated to the provided object, if any. - * The provided object is a graphical artifact (EditPart, View, ...) - * This method navigate throw the object if the object is a graphical artifact or a - * diagram artifact. - * - * @param object Graphical artifact associated to a domain object. - * @return Object The domain object associated to the graphical artifact. - */ - private Object getDomainModel(Object object) { - if(object instanceof EditPart) { - // Check model. It can be a GraphNode. - Object model = ((EditPart)object).getModel(); - // Check if it is a notation View - if(model instanceof View) { - return ((View)model).getElement(); - - } else - return model; - - } - else if(object instanceof View) { - return ((View)object).getElement(); - } - else - return object; - - } - - - /** - * Get the resource containing notation.Diagram. - * @return - */ - private Resource getDiagramResource() { - return EditorUtils.getDiResourceSet().getNotationResource(); - } - - /** - * Get the ID identifying the type of the Diagram. - * {@inheritDoc} - */ - protected String getDiagramNotationID() { - return org.eclipse.uml2.diagram.clazz.edit.parts.PackageEditPart.MODEL_ID; - } - - /** - * {@inheritDoc} - */ - protected PreferencesHint getPreferenceHint() { - return UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT; - } - -} diff --git a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/UmlClassDiagramForMultiEditor.java b/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/UmlClassDiagramForMultiEditor.java deleted file mode 100644 index 36c7a2a6d99..00000000000 --- a/deprecated/org.eclipse.papyrus.diagram.umltools.clazz/src/org/eclipse/papyrus/diagram/umltools/clazz/UmlClassDiagramForMultiEditor.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * - */ -package org.eclipse.papyrus.diagram.umltools.clazz; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.emf.common.ui.URIEditorInput; -import org.eclipse.emf.ecore.util.EcoreUtil; -import org.eclipse.emf.transaction.TransactionalEditingDomain; -import org.eclipse.gef.GraphicalViewer; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.document.IDocumentProvider; -import org.eclipse.gmf.runtime.diagram.ui.resources.editor.internal.l10n.EditorMessages; -import org.eclipse.gmf.runtime.notation.Diagram; -import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.papyrus.core.adaptor.gmf.GmfMultiDiagramDocumentProvider; -import org.eclipse.papyrus.core.editor.BackboneException; -import org.eclipse.papyrus.core.services.ServiceException; -import org.eclipse.papyrus.core.services.ServicesRegistry; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IEditorInput; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PartInitException; -import org.eclipse.uml2.diagram.clazz.part.UMLDiagramEditor; - -/** - * An editor to be used in multitabs editor. This editor extends the original UML Activity Diagram. - * - * @author dumoulin - * - */ -public class UmlClassDiagramForMultiEditor extends UMLDiagramEditor { - - /** - * The diagram shown by this editor. - */ - private Diagram diagram; - - /** - * - */ - private ServicesRegistry servicesRegistry; - - /** - * Constructor for SashSystem v2. Context and required objects are retrieved from the - * ServiceRegistry. - * - * @throws BackboneException - * @throws ServiceException - * - */ - public UmlClassDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws BackboneException, ServiceException { - this.servicesRegistry = servicesRegistry; - this.diagram = diagram; - - // Share the same editing provider - TransactionalEditingDomain editingDomain = servicesRegistry.getService(TransactionalEditingDomain.class); - GmfMultiDiagramDocumentProvider documentProvider = new GmfMultiDiagramDocumentProvider(editingDomain); - - // overrides editing domain created by super constructor - setDocumentProvider(documentProvider); - - } - - /** - * @return the diagram - */ - public Diagram getDiagram() { - return diagram; - } - - /** - * @param diagram - * the diagram to set - */ - public void setDiagram(Diagram diagram) { - this.diagram = diagram; - } - - /** - * Change visibility to public. - */ - @Override - public GraphicalViewer getGraphicalViewer() { - return super.getGraphicalViewer(); - } - - /** - * - */ - final protected IDocumentProvider getDocumentProvider(IEditorInput input) { - // System.out.println("getDocumentProvider(IEditorInput input)"); - if (input instanceof IFileEditorInput || input instanceof URIEditorInput) { - throw new UnsupportedOperationException("TODO !!!"); - } - return super.getDocumentProvider(input); - } - - /** - * @generated - */ - protected void setDocumentProvider(IEditorInput input) { - // Already set in the constructor. - } - - /** - * - */ - @Override - public void init(IEditorSite site, IEditorInput input) throws PartInitException { - super.init(site, input); - // Set name after calling super.init() - setPartName(getDiagram().getName()); - } - - /** - * - */ - @Override - public void setInput(IEditorInput input) { - try { - // We are in a nested editor. - // Provide an URI with fragment in order to reuse the same Resource and to - // set the diagram to the fragment. - // First, compute the URI - URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(diagram)); - System.err.println(this.getClass().getSimpleName() + ".setInput(" + uriInput.toString() + ")"); - doSetInput(uriInput, true); - } catch (CoreException x) { - String title = EditorMessages.Editor_error_setinput_title; - String msg = EditorMessages.Editor_error_setinput_message; - Shell shell = getSite().getShell(); - ErrorDialog.openError(shell, title, msg, x.getStatus()); - } - - } - - Composite splitter; - - @Override - protected void createGraphicalViewer(Composite parent) { - System.out.println("store Composite " + parent); - splitter = parent; - super.createGraphicalViewer(parent); - } - - @Override - public void setFocus() { - - // System.out.println("setFocus( " + ((Object)splitter).hashCode() + "):" + splitter.getChildren()); - splitter.setFocus(); - - super.setFocus(); - } - - public String getEditingDomainID() { - return "org.eclipse.uml2.diagram.clazz.EditingDomain"; - } - -} -- cgit v1.2.3