Package org.eclipse.gef

Examples of org.eclipse.gef.GraphicalViewer


      EObject selectedView = diagramEditorResourceSet.getEObject(
          EcoreUtil.getURI(navigatorView), true);
      if (selectedView == null) {
        return;
      }
      GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor
          .getAdapter(GraphicalViewer.class);
      EditPart selectedEditPart = (EditPart) graphicalViewer
          .getEditPartRegistry().get(selectedView);
      if (selectedEditPart != null) {
        graphicalViewer.select(selectedEditPart);
      }
    }
  }
View Full Code Here


      EObject selectedView = diagramEditorResourceSet.getEObject(
          EcoreUtil.getURI(navigatorView), true);
      if (selectedView == null) {
        return;
      }
      GraphicalViewer graphicalViewer = (GraphicalViewer) diagramEditor
          .getAdapter(GraphicalViewer.class);
      EditPart selectedEditPart = (EditPart) graphicalViewer
          .getEditPartRegistry().get(selectedView);
      if (selectedEditPart != null) {
        graphicalViewer.select(selectedEditPart);
      }
    }
  }
View Full Code Here

  @Override
  protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();

    GraphicalViewer viewer = getGraphicalViewer();
   
    viewer.getControl().addMouseMoveListener(new MouseMoveListener() {
      public void mouseMove(MouseEvent e) {
        setMouseLocation(e.x, e.y);
      }
    });
   
    // set the contents of this editor
    viewer.setContents(diagramModel);
   
    // listen for dropped parts
    viewer.addDropTargetListener(new SapphireTemplateTransferDropTargetListener(this));
    viewer.addDropTargetListener((TransferDropTargetListener) new ObjectsTransferDropTargetListener(viewer));
    postInit();
  }
View Full Code Here

   
  @Override
  protected void configureGraphicalViewer()
  {
    super.configureGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();   
        this.diagramPresentation = new DiagramPagePresentation(this.part, this.configManager, viewer.getControl().getShell());
        this.diagramModel = new DiagramModel(this.diagramPresentation);   
           
    viewer.setEditPartFactory(new SapphireDiagramEditorEditPartFactory(getConfigurationManager()));
   
    viewer.setRootEditPart(new ScalableFreeformRootEditPart()
    {
      @Override
      protected GridLayer createGridLayer()
      {
        return new SapphireDiagramGridLayer(diagramModel);
      }     
    });
   
    // configure the context menu provider
    ContextMenuProvider cmProvider = new DiagramEditorContextMenuProvider(this);
    viewer.setContextMenu(cmProvider);
   
    // Configure grid and guide properties
    boolean isGridVisibleInViewer = false;
    if (viewer.getProperty(SnapToGrid.PROPERTY_GRID_VISIBLE) != null)
    {
      isGridVisibleInViewer = (Boolean) viewer.getProperty(SnapToGrid.PROPERTY_GRID_VISIBLE);
    }
    if (this.part.isGridVisible() != isGridVisibleInViewer)
    {
      viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, this.part.isGridVisible());
      viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, this.part.isGridVisible());
      viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING,
          new Dimension(this.part.getGridUnit(), this.part.getVerticalGridUnit()));
    }
   
    boolean isShowGuidesInViewer = false;
    if (viewer.getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED) != null)
    {
      isShowGuidesInViewer = (Boolean)viewer.getProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED);
    }
    if (this.part.isShowGuides() != isShowGuidesInViewer)
    {
      viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, this.part.isShowGuides());
    }
   
    // Support context help
   
    this.getGraphicalControl().addHelpListener(new HelpListener()
View Full Code Here

 
  public GraphicalEditPart getGraphicalEditPart(ISapphirePart sapphirePart)
  {
    if (sapphirePart instanceof DiagramNodePart || sapphirePart instanceof ShapePart || sapphirePart instanceof DiagramConnectionPart)
    {
      GraphicalViewer viewer = this.getGraphicalViewer();
     
      Object editpartObj = null;
      DiagramNodePart nodePart = null;
      DiagramConnectionPart connPart = null;
      if (sapphirePart instanceof DiagramNodePart)
      {
        nodePart = (DiagramNodePart)sapphirePart;
        DiagramNodeModel nodeModel = this.getDiagramModel().getDiagramNodeModel(nodePart);
        editpartObj = viewer.getEditPartRegistry().get(nodeModel);
      }
      else if (sapphirePart instanceof ShapePart)
      {
        nodePart = sapphirePart.nearest(DiagramNodePart.class);
        DiagramNodeModel nodeModel = this.getDiagramModel().getDiagramNodeModel(nodePart);
        ShapeModel shapeModel = ShapeModelUtil.getChildShapeModel(nodeModel.getShapeModel(), (ShapePart)sapphirePart);
        editpartObj = viewer.getEditPartRegistry().get(shapeModel);
      }
      else if (sapphirePart instanceof DiagramConnectionPart)
      {
        connPart = (DiagramConnectionPart)sapphirePart;
        DiagramConnectionModel connModel = this.getDiagramModel().getDiagramConnectionModel(connPart);
        editpartObj = viewer.getEditPartRegistry().get(connModel);       
      }
      return (GraphicalEditPart)editpartObj;
    }
    return null;
  }
View Full Code Here

 
  public void selectAndDirectEditPart(final ISapphirePart part)
  {
    if (part instanceof DiagramNodePart || part instanceof ShapePart || part instanceof DiagramConnectionPart)
    {
      GraphicalViewer viewer = getGraphicalViewer();
      // Bug 370869 - DND from the tool palette would show an invalid cursor before placing the new node
      // in direct edit mode. TODO why?
      //viewer.getControl().forceFocus();
     
      GraphicalEditPart editpart = getGraphicalEditPart(part);
      ISapphirePart parentPart = part.parent();
      while ((editpart == null || !editpart.isSelectable()) && parentPart != null)
      {
        editpart = getGraphicalEditPart(parentPart);
        parentPart = parentPart.parent();
      }
      if (editpart != null)
      {
        // Force a layout first.
        viewer.flush();
        viewer.select(editpart);
        viewer.reveal(editpart);
        if (part instanceof DiagramNodePart)
        {         
          getDiagramModel().handleDirectEditing((DiagramNodePart)part);
        }
        else if (part instanceof ShapePart)
View Full Code Here

    }
    }
 
  public void selectAll()
  {
    GraphicalViewer viewer = this.getGraphicalViewer();
    for (Object obj : viewer.getEditPartRegistry().values())
    {
      if (obj instanceof DiagramConnectionEditPart ||
          obj instanceof DiagramNodeEditPart)
      {
        viewer.appendSelection((EditPart)obj);
      }
    }
  }
View Full Code Here

    }
  }
 
  public void selectAllNodes()
  {
    GraphicalViewer viewer = this.getGraphicalViewer();
    viewer.deselectAll();
    for (Object obj : viewer.getEditPartRegistry().values())
    {
      if (obj instanceof DiagramNodeEditPart)
      {
        viewer.appendSelection((DiagramNodeEditPart)obj);
      }
    }
  }
View Full Code Here

      {
        selectionChanged = true;
      }
      if (selectionChanged)
      {
        GraphicalViewer viewer = this.getGraphicalViewer();
       
        if (selections.isEmpty())
        {
          viewer.flush();
          viewer.deselectAll();
          return;
        }
        boolean first = true;
        for (ISapphirePart sapphirePart : selections)
        {
          Object editpartObj = getGraphicalEditPart(sapphirePart);
          if (editpartObj != null)
          {
            if (first)
            {
              viewer.flush();
              viewer.select((EditPart)editpartObj);             
              first = false;
            }
            else
            {
              viewer.appendSelection((EditPart)editpartObj);
            }
            viewer.reveal((EditPart)editpartObj);
          }
        }       
      }
  }
View Full Code Here

    this.part.setMouseLocation(realLocation.x, realLocation.y);
  }
 
  public FigureCanvas getFigureCanvas()
  {
    GraphicalViewer viewer = getGraphicalViewer();
    return (FigureCanvas) viewer.getControl();
  }
View Full Code Here

TOP

Related Classes of org.eclipse.gef.GraphicalViewer

Copyright © 2018 www.massapicom. 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.