Examples of DiagramPresentation


Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

 
  @Override
  public void buildContextMenu( final IMenuManager menuManager )
  {
    final ISapphirePart part;
    final DiagramPresentation presentation;
        final GraphicalEditPart editPart;
        final String context;

        final List<GraphicalEditPart> selection = this.editor.getSelectedEditParts();
       
        List<ISapphirePart> emptySelection = new ArrayList<ISapphirePart>();
   
    if( selection.size() == 1 )
    {
      editPart = selection.get( 0 );
     
      if( editPart instanceof SapphireDiagramEditorPageEditPart )
      {
        context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR;
        presentation = this.editor.getDiagramPresentation();
      }
      else if( editPart instanceof DiagramNodeEditPart )
      {
        DiagramNodeEditPart nodePart = (DiagramNodeEditPart)editPart;
        if (isMouseOnEditPart(nodePart))
        {
          context = SapphireActionSystem.CONTEXT_DIAGRAM_NODE;
          presentation = ((DiagramNodeEditPart)editPart).getPresentation();
        }
        else
        {
          this.editor.selectParts(emptySelection);
          context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR;
          presentation = this.editor.getDiagramPresentation();
        }
      }
      else if (editPart instanceof ShapeEditPart)
      {
        DiagramNodeEditPart nodePart = ((ShapeEditPart)editPart).getNodeEditPart();
        if (isMouseOnEditPart(nodePart))
        {
          context = SapphireActionSystem.CONTEXT_DIAGRAM_NODE_SHAPE;
          presentation = ((ShapeEditPart)editPart).getShapePresentation();
        }
        else
        {
          this.editor.selectParts(emptySelection);
          context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR;
          presentation = this.editor.getDiagramPresentation();
        }
      }
      else if( editPart instanceof DiagramConnectionEditPart )
      {
        if (isMouseOnEditPart(editPart))
        {
          context = SapphireActionSystem.CONTEXT_DIAGRAM_CONNECTION;
          presentation = ((DiagramConnectionEditPart)editPart).getPresentation();
        }
        else
        {
          this.editor.selectParts(emptySelection);
          context = SapphireActionSystem.CONTEXT_DIAGRAM_EDITOR;
          presentation = this.editor.getDiagramPresentation();
        }
       
      }
      else if( editPart instanceof DiagramConnectionLabelEditPart )
      {
          return;
      }
      else
      {
          throw new IllegalStateException();
      }
     
      part = presentation.part();
    }
    else if( selection.size() > 1 )
    {
      if (isMouseOnEditParts(selection))
      {
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

    return null;
  }
 
  protected ContainerShapePresentation getParentContainer(ShapePresentation shapePresentation)
  {
    DiagramPresentation parentPresentation = shapePresentation.parent();
    while (!(parentPresentation instanceof ContainerShapePresentation) && parentPresentation != null)
    {
      parentPresentation = parentPresentation.parent();
    }
    return (ContainerShapePresentation)parentPresentation;
  }
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

public class HorizontalGraphLayoutActionHandler extends SapphireActionHandler
{
  @Override
  protected Object run( final Presentation context )
  {
    DiagramPresentation diagramPresentation = (DiagramPresentation)context;
    SapphireDiagramEditor diagramEditor = diagramPresentation.getConfigurationManager().getDiagramEditor();
    new HorizontalGraphLayout().layout(diagramEditor);
   
    return null;
  }
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

{

  @Override
  protected Object run( final Presentation context )
  {
    DiagramPresentation presentation = (DiagramPresentation)context;
    SapphireDiagramEditor diagramEditor = presentation.getConfigurationManager().getDiagramEditor();
    if (diagramEditor != null)
    {
      List<ISapphirePart> parts = diagramEditor.getSelectedParts();
      DiagramModel model = diagramEditor.getDiagramModel();
      if (parts.size() == 1)
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

public class VerticalGraphLayoutActionHandler extends SapphireActionHandler
{
  @Override
  protected Object run( final Presentation context )
  {
    DiagramPresentation diagramPresentation = (DiagramPresentation)context;
    SapphireDiagramEditor diagramEditor = diagramPresentation.getConfigurationManager().getDiagramEditor();
    new VerticalGraphLayout().layout(diagramEditor);
   
    return null;
  }
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

    }

    @Override
    protected Object run( final Presentation context )
    {
        DiagramPresentation diagramPresentation = (DiagramPresentation)context;
        SapphireDiagramEditor diagramEditor = diagramPresentation.getConfigurationManager().getDiagramEditor();

        if( diagramEditor != null )
        {
            final FileDialog dialog = new FileDialog( diagramEditor.getSite().getShell(), SWT.SAVE );
            final IEditorInput editorInput = diagramEditor.getPart().adapt( IEditorInput.class );
            final StringBuilder initialFileName = new StringBuilder();
           
            if( editorInput == null )
            {
                initialFileName.append( defaultFileName.text() );
            }
            else
            {
                if( editorInput instanceof IFileEditorInput )
                {
                    dialog.setFilterPath( ( (IFileEditorInput) editorInput ).getFile().getParent().getLocation().toOSString() );
                }
               
                final String editorInputName = editorInput.getName();
                final int editorInputLastDot = editorInputName.lastIndexOf( '.' );
               
                if( editorInputLastDot == -1 )
                {
                    initialFileName.append( editorInputName );
                }
                else
                {
                    initialFileName.append( editorInputName.substring( 0, editorInputLastDot ) );
                }
            }
           
            initialFileName.append( ".png" );

            dialog.setFileName( initialFileName.toString() );

            dialog.setFilterExtensions( new String[] { "*.png" } );

            dialog.setText( saveAsImageMessage.text() );

            dialog.setOverwrite( true );

            String filePath = dialog.open();

            if( filePath == null )
            {
                return null;
            }

            GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor.getAdapter( GraphicalViewer.class );

            ScalableFreeformRootEditPart rootEditPart
                = (ScalableFreeformRootEditPart) graphicalViewer.getRootEditPart();

            IFigure figure = rootEditPart.getLayer( LayerConstants.PRINTABLE_LAYERS );

            Rectangle rectangle = figure.getBounds();

            Image image = new Image( diagramPresentation.display(), rectangle.width, rectangle.height );

            FileOutputStream output = null;
            GC gc = null;
            SWTGraphics graphics = null;
            try
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

public final class PrintDiagramActionHandler extends SapphireActionHandler
{
    @Override
    protected Object run( final Presentation context )
    {
        final DiagramPresentation diagramPresentation = (DiagramPresentation) context;
        final SapphireDiagramEditor diagramEditor = diagramPresentation.getConfigurationManager().getDiagramEditor();

        ( new PrintAction( diagramEditor ) ).run();

        return null;
    }
View Full Code Here

Examples of org.eclipse.sapphire.ui.swt.gef.presentation.DiagramPresentation

  private void executeActionHandler(SapphireActionHandler handler)
  {
    List<GraphicalEditPart> editParts = this.contextButtonPad.getEditParts();
    for (GraphicalEditPart editPart : editParts)
    {
      DiagramPresentation presentation;
      if( editPart instanceof SapphireDiagramEditorPageEditPart )
      {
        presentation = ((SapphireDiagramEditorPageEditPart)editPart).getPresentation();
      }
      else if( editPart instanceof DiagramNodeEditPart )
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.