Package org.eclipse.gef

Examples of org.eclipse.gef.GraphicalViewer


    setLabelAlignment(PositionConstants.CENTER);
    // TODO how to reconcile both horizontal and vertical alignment with draw2d label alignment
    this.verticalAlignment = getSwtTextAlignment(textPresentation.getLayoutConstraint().getVerticalAlignment().content());
    setFont(this.resourceCache.getFont(textPresentation.getFontDef()));
   
    GraphicalViewer viewer = textPresentation.getConfigurationManager().getDiagramEditor().getGraphicalViewer();
    Composite composite = (Composite)viewer.getControl();
    swtText = new Text(composite, SWT.NONE);
    swtText.setVisible(false);
    zoomMgr = (ZoomManager) viewer.getProperty(ZoomManager.class.toString());
    // this will force the font to be set
    cachedZoom = -1.0;
    updateScaledFont(zoomMgr.getZoom());
    zoomMgr.addZoomListener(zoomListener);
   
View Full Code Here


            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();
View Full Code Here

  }
 
  public static void setGridVisible(boolean visible) {
    RiderDesignEditor editor = Activator.getDiagramEditor();
    if (editor != null) {
      GraphicalViewer graphicalViewer = editor.getGraphicalViewer();
      if (graphicalViewer != null
          && graphicalViewer.getEditPartRegistry() != null) {
        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
        IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
        gridFigure.setVisible(visible);
        editor.getDiagramBehavior().refreshContent();
      }
    }
View Full Code Here

    editor.getSelectionSyncer().addViewer(getViewer());

    // Creation de la miniature.
    Canvas canvas = new Canvas(sash, SWT.BORDER);
    LightweightSystem lws = new LightweightSystem(canvas);
    GraphicalViewer graphicalViewer = editor.getGraphicalViewer();
    if (graphicalViewer == null)
      return;
   
    RootEditPart rootEditPart = graphicalViewer.getRootEditPart();
   
    // TODO Graphiti - not a ScalableRootEditPart but some kind of DiagramEditPart
    if (rootEditPart instanceof ScalableRootEditPartAnimated) {
      ScalableRootEditPartAnimated diagramEditPart = (ScalableRootEditPartAnimated) rootEditPart;
      IFigure figure = diagramEditPart.getFigure();
      thumbnail = new ScrollableThumbnail( (Viewport) figure);
      IFigure source = diagramEditPart.getLayer(LayerConstants.PRINTABLE_LAYERS);
      thumbnail.setSource(source);
      lws.setContents(thumbnail);
    } else if (rootEditPart instanceof ScalableRootEditPart) {
      thumbnail = new ScrollableThumbnail( (Viewport) ((ScalableRootEditPart) rootEditPart).getFigure());
      thumbnail.setSource(((ScalableRootEditPart) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS));
      lws.setContents(thumbnail);
    }
    disposeListener = new DisposeListener() {
      /*
       * (non-Javadoc)
       * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
       */
      @Override
      public void widgetDisposed(DisposeEvent e) {
        if (thumbnail != null) {
          thumbnail.deactivate();
          thumbnail = null;
        }
      }
    };
    graphicalViewer.getControl().addDisposeListener(disposeListener);

    final TreeViewer viewer = getTreeViewer();
    // TODO how to find the part?
    final IWorkbenchPart part = null;
    viewer.addSelectionChangedListener(new ISelectionChangedListener() {
View Full Code Here

   */
  @Override
  protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();

    GraphicalViewer viewer = getGraphicalViewer();
    /*
    // TODO Graphiti
    viewer.setEditPartFactory(new RouteEditPartFactory());

    double[] zoomLevels;
    ArrayList<String> zoomContributions;
    rootEditPart = new ScalableRootEditPart();
    viewer.setRootEditPart(rootEditPart);

    ZoomManager manager = rootEditPart.getZoomManager();
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));
    // zooms possible. 1 = 100%
    zoomLevels = new double[] { 0.25, 0.5, 0.75, 1.0, 1.5, 2.0, 2.5, 3.0,
        4.0, 5.0, 10.0, 20.0 };
    manager.setZoomLevels(zoomLevels);

    zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    KeyHandler keyHandler = new KeyHandler();
    keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
        getActionRegistry().getAction(ActionFactory.DELETE.getId()));
    keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_IN));
    keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0),
        getActionRegistry().getAction(GEFActionConstants.ZOOM_OUT));
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE),
        MouseWheelZoomHandler.SINGLETON);
    viewer.setKeyHandler(keyHandler);

    // IMPORTANT: the following is a dirty workaround to get the delete
    // action behave normal. Without this code no delete will be
    // possible. TODO: try to get this fixed by time.
    ActionRegistry registry = getActionRegistry();
    String id = ActionFactory.UNDO.getId();
    getEditorSite().getKeyBindingService().registerAction(
        registry.getAction(id));
    id = ActionFactory.REDO.getId();
    getEditorSite().getKeyBindingService().registerAction(
        registry.getAction(id));
    id = ActionFactory.DELETE.getId();
    getEditorSite().getKeyBindingService().registerAction(
        registry.getAction(id));

     */
    ContextMenuProvider provider = new RiderEditorContextMenuProvider(this, this, viewer, getActionRegistry());
    viewer.setContextMenu(provider);
  }
View Full Code Here

    } else if (type == EditDomain.class) {
      return getEditDomain();
    } else if (type == ActionRegistry.class) {
      return getActionRegistry();
    } else if (type == ZoomManager.class) {
      GraphicalViewer graphicalViewer = getGraphicalViewer();
      if (graphicalViewer == null)
        return null;
     
      RootEditPart root = graphicalViewer.getRootEditPart();
      if (root instanceof ScalableRootEditPartAnimated) {
        ScalableRootEditPartAnimated scalableRoot = (ScalableRootEditPartAnimated) root;
        return scalableRoot.getZoomManager();
      } else if (root instanceof ScalableRootEditPart) {
        return ((ScalableRootEditPart) root).getZoomManager();
View Full Code Here

   * initializeGraphicalViewer()
   */
  @Override
  public void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    GraphicalViewer viewer = getGraphicalViewer();

    // listen for dropped parts
    viewer.addDropTargetListener(createTransferDropTargetListener());
  }
View Full Code Here

    initializeDiagramForSelectedRoute();
    if (activeConfig.diagram != null) {
      getDiagramTypeProvider().init(activeConfig.diagram, getDiagramBehavior());
      getDiagramBehavior().getRefreshBehavior().initRefresh();
          setPictogramElementsForSelection(null);
          GraphicalViewer graphicalViewer = getGraphicalViewer();
         
          if (graphicalViewer == null)
            return;
         
          // set Diagram as contents for the graphical viewer and refresh
          graphicalViewer.setContents(activeConfig.diagram);         
          getDiagramBehavior().refreshContent();
    }
  }
View Full Code Here

  }

  @Override
  protected void doExecute() {
    if (designEditor != null) {
      GraphicalViewer graphicalViewer = designEditor.getGraphicalViewer();
      if (graphicalViewer != null
          && graphicalViewer.getEditPartRegistry() != null) {
        ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
        IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
        IColorConstant cc = StyleUtil.getColorConstant(PreferenceManager.getInstance().loadPreferenceAsString(PreferencesConstants.EDITOR_GRID_COLOR));
        Diagram diagram = designEditor.getDiagram();
        if (cc != null && diagram != null) {
          GraphicsAlgorithm ga = diagram.getGraphicsAlgorithm();
View Full Code Here

    /* (non-Javadoc)
     * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
     */
    protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();
        GraphicalViewer viewer = getGraphicalViewer();
        viewer.getControl().setBackground( ColorConstants.white );
        viewer.setEditPartFactory( new VertexEditPartFactory() );
        viewer.setRootEditPart( rootEditPart );
        viewer.setKeyHandler( new GraphicalViewerKeyHandler( viewer ) );
    }
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.