Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[mdt-papyrus.dev] Can not show new diagram in Papyrus

Dear all,
  
I found the great upate for wiki of ommgh installer for UML papryus, appreiate the speed of updating.

I follow the tutorail: How to create a new papyrus UML diagram. After strugling with lots of change such as path and method privilige. It can use Papyrus NewDiagm in Category Example. But it does not show in Papyrus Wizard.

The main files show as follows:

Plugin.xml
   <extension
         point="org.eclipse.papyrus.infra.core.papyrusDiagram">
      <editorDiagram
            actionBarContributorId="org.eclipse.papyrus.diagram.common.part.UMLDiagramActionBarContributor"
            factoryClass="org.eclipse.papyrus.diagram.newdiagram.DiagramEditorFactory"
            icon="icons/obj16/UMLDiagramFile.gif">
      </editorDiagram>
      <creationCommand
            creationCommandClass="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
            icon="icons/obj16/UMLDiagramFile.gif"
            id="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
            label="UML Turorial Diagram"
            language="uml">
      </creationCommand>
   </extension>
   <extension
         point="org.eclipse.ui.commands">
      <command
            categoryId="org.eclipse.papyrus.editor.category"
            defaultHandler="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
            description="Create a Tutorial Diagram"
            id="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
            name="Create a Tutorial Diagram">
      </command>
   </extension>
   <extension
         point="org.eclipse.ui.handlers">
      <handler
            class="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand"
            commandId="org.eclipse.papyrus.diagram.newdiagram.CreateDiagramCommand">
      </handler>
   </extension>

There java files:
package org.eclipse.papyrus.diagram.newdiagram;

import org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint;
import org.eclipse.papyrus.diagram.newdiagram.edit.parts.ModelEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.AbstractPapyrusGmfCreateDiagramCommandHandler;

public class CreateDiagramCommand extends AbstractPapyrusGmfCreateDiagramCommandHandler {

 @Override
 protected String getDefaultDiagramName() {
  return openDiagramNameDialog("NewDiagram");
 }

 /**
  * {@inheritDoc}
  */
 @Override
 protected String getDiagramNotationID() {
  return ModelEditPart.MODEL_ID;
 }

 /**
  * {@inheritDoc}
  */
 @Override
 protected PreferencesHint getPreferenceHint() {
  return org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorPlugin.DIAGRAM_PREFERENCES_HINT;
 }
}

package org.eclipse.papyrus.diagram.newdiagram;

import org.eclipse.papyrus.diagram.newdiagram.edit.parts.ModelEditPart;
import org.eclipse.papyrus.infra.gmfdiag.common.GmfEditorFactory;
 

public class DiagramEditorFactory extends GmfEditorFactory{
 
 public DiagramEditorFactory() {
  super(UmlDiagramForMultiEditor.class, ModelEditPart.MODEL_ID);
 }
}

package org.eclipse.papyrus.diagram.newdiagram;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.emf.common.ui.URIEditorInput;
import org.eclipse.emf.ecore.util.EcoreUtil;
import org.eclipse.gmf.runtime.notation.Diagram;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditor;
import org.eclipse.papyrus.diagram.newdiagram.part.UMLDiagramEditorPlugin;
import org.eclipse.papyrus.infra.core.editor.BackboneException;
import org.eclipse.papyrus.infra.core.services.ServiceException;
import org.eclipse.papyrus.infra.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.PartInitException;

public class UmlDiagramForMultiEditor extends UMLDiagramEditor {
 /**
  * The location of diagram icon in the plug-in
  */
 private static final String DIAG_IMG_PATH = "icons/obj16/newDiagramFile.gif";

 /**
  * The image descriptor of the diagram icon
  */
 private static final ImageDescriptor DIAG_IMG_DESC = UMLDiagramEditorPlugin.getBundledImageDescriptor(UmlDiagramForMultiEditor.DIAG_IMG_PATH);

 /** The editor splitter. */
 private Composite splitter;

 /**
  * Constructor for SashSystem v2. Context and required objects are retrieved from the
  * ServiceRegistry.
  *
  * @throws BackboneException
  * @throws ServiceException
  *
  */
 public UmlDiagramForMultiEditor(ServicesRegistry servicesRegistry, Diagram diagram) throws BackboneException, ServiceException {
 
 }

 @Override
 public void setInput(IEditorInput input) {
  try {
   // Provide an URI with fragment in order to reuse the same Resource
   // and set the diagram to the fragment.
   URIEditorInput uriInput = new URIEditorInput(EcoreUtil.getURI(getDiagram()));
   doSetInput(uriInput, true);
  } catch (CoreException x) {
   String title = "Problem opening";
   String msg = "Cannot open input element:";
   Shell shell = getSite().getShell();
   ErrorDialog.openError(shell, title, msg, x.getStatus());
  }
 }

 @Override
 public void init(IEditorSite site, IEditorInput input)
   throws PartInitException {
  // TODO Auto-generated method stub
  super.init(site, input);
  setPartName(getDiagram().getName());
  setTitleImage(DIAG_IMG_DESC.createImage());
 }

 @Override
 protected String getEditingDomainID() {
  // TODO Auto-generated method stub
  return "org.eclipse.papyrus.diagram.newdiagram.EditingDomain";
 }

 @Override
 public void setFocus() {
  splitter.setFocus();
  super.setFocus();
 }

 @Override
 protected void createGraphicalViewer(Composite parent) {
  splitter = parent;
  super.createGraphicalViewer(parent);
 }
}



Back to the top