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


    /* (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

   */
  @Override
  protected void initializeGraphicalViewer() {
    super.initializeGraphicalViewer();
    //Sets the model
    GraphicalViewer graphicalViewer = getGraphicalViewer();
    graphicalViewer.setEditPartFactory(new DiagramPartFactory());
    graphicalViewer.setContents(getModel());

    setPartName(getModel().getRootProject().getName());
   
    // Add contextuel Menu
    LayoutActions layoutActions = new LayoutActions(this);
View Full Code Here

    }

    protected void configureGraphicalViewer() {
        super.configureGraphicalViewer();

        GraphicalViewer graphicalViewer = getGraphicalViewer();
        ScalableFreeformRootEditPart scalableFreeformRootEditPart = new ScalableFreeformRootEditPart();
        graphicalViewer.setRootEditPart(scalableFreeformRootEditPart);
        zoomManager = scalableFreeformRootEditPart.getZoomManager();

        graphicalViewer.setEditPartFactory(new PartFactory());

        ContextMenuProvider provider = new PageContextMenuProvider(graphicalViewer,
                getActionRegistry());
        graphicalViewer.setContextMenu(provider);
        getSite().registerContextMenu("org.locationtech.udig.printing.editor.contextmenu", //$NON-NLS-1$
                provider, graphicalViewer);

    }
View Full Code Here

        getGraphicalViewer().setContents(this.page);
    }

    @Override
    protected void createGraphicalViewer( Composite parent ) {
        GraphicalViewer viewer = new PrintingScrollingGraphicalViewer(this);
        viewer.createControl(parent);
        setGraphicalViewer(viewer);
        configureGraphicalViewer();
        hookGraphicalViewer();
        initializeGraphicalViewer();
View Full Code Here

            setId(ActionFactory.SELECT_ALL.getId());
        }

        @Override
        public void run() {
            GraphicalViewer viewer = (GraphicalViewer) part.getAdapter(GraphicalViewer.class);
            if (viewer != null) {
                List<EditPart> elements = new ArrayList<EditPart>();
                getAllChildren(viewer.getContents(), elements);
                viewer.setSelection(new StructuredSelection(elements));
            }
        }
View Full Code Here

   * listens to applied remote records to update action enablement and to
   * document root changes to update the root.
   */
  @Override
  protected void initializeGraphicalViewer() {
    GraphicalViewer viewer = getGraphicalViewer();

    WhiteboardManager.getInstance().getSXEMessageHandler()
        .addMessageListener(new MessageAdapter() {

          // obsolete because of notification listener
          // /*
          // * We have to check the action enablement after receiving
          // a
          // * remove message. I.e. maybe a selected item was deleted
          // * thus copy/delete have to be disabled.
          // */
          // @Override
          // public void sxeRecordMessageApplied(SXEMessage message) {
          // updateActions();
          // }

          @Override
          public void sxeStateMessageApplied(SXEMessage message,
              ElementRecord root) {
            updateViewerContents(root);
          }

        });

    viewer.setContents(WhiteboardManager.getInstance()
        .getSXEMessageHandler().getDocumentRecord().getRoot());

    viewer.addDropTargetListener(new TemplateTransferDropTargetListener(
        viewer) {
      /**
       * Overridden by the superclass method because selecting the created
       * object here does not make sense as it differs from the one that
       * will be created by the command (and finally by the DocumentRecord
View Full Code Here

   * bunch of records.
   */
  @Override
  protected void createGraphicalViewer(Composite parent) {

    final GraphicalViewer viewer = new ScrollingGraphicalViewer() {

      protected boolean isNotifying = false;

      {
        WhiteboardManager.getInstance().getSXEMessageHandler()
            .addNotificationListener(new NotificationListener() {

              @Override
              public void beforeNotification() {
                isNotifying = true;
              }

              @Override
              public void afterNotificaion() {
                isNotifying = false;
                fireSelectionChanged();
                updateActions();
              }

            });
      }

      @Override
      protected void fireSelectionChanged() {
        if (isNotifying)
          return;
        super.fireSelectionChanged();
      }
    };

    viewer.createControl(parent);
    setGraphicalViewer(viewer);
    configureGraphicalViewer();
    hookGraphicalViewer();
    initializeGraphicalViewer();
  }
View Full Code Here

  protected void configureGraphicalViewer() {
    double[] zoomLevels;

    super.configureGraphicalViewer();

    GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(new RecordPartFactory());

    ScalableFreeformRootEditPart rootEditPart = new ScalableFreeformRootEditPart();
    viewer.setRootEditPart(rootEditPart);

    ZoomManager manager = rootEditPart.getZoomManager();
    getActionRegistry().registerAction(new ZoomInAction(manager));
    getActionRegistry().registerAction(new ZoomOutAction(manager));

    zoomLevels = new double[] { 0.1, 0.25, 0.5, 0.75, 1, 1.5, 2.0, 2.5, 3,
        4, 5, 10 };
    manager.setZoomLevels(zoomLevels);
    manager.setZoom(1);
    ArrayList<String> zoomContributions = new ArrayList<String>();
    zoomContributions.add(ZoomManager.FIT_ALL);
    zoomContributions.add(ZoomManager.FIT_HEIGHT);
    zoomContributions.add(ZoomManager.FIT_WIDTH);
    manager.setZoomLevelContributions(zoomContributions);

    /*
     * A workaround because - when embedded in a ViewPart - the SWT.DEL key
     * is not recognized. This problem might be related to the GEF
     * EditDomain, that should be hooked separately in the ViewPart.
     */
    keyHandler = new KeyHandler() {

      @Override
      public boolean keyPressed(KeyEvent event) {
        if (event.keyCode == 127) {
          return performDelete();
        }
        return super.keyPressed(event);
      }

      private boolean performDelete() {
        IAction action = getActionRegistry().getAction(
            ActionFactory.DELETE.getId());
        if (action == null)
          return false;
        if (action.isEnabled())
          action.run();
        return true;
      }

    };
    ;

    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);

    ContextMenuProvider provider = new WhiteboardContextMenuProvider(
        viewer, getActionRegistry());
    viewer.setContextMenu(provider);

  }
View Full Code Here

   * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
   *      org.eclipse.jface.viewers.ISelection)
   */
  public void selectionChanged(IWorkbenchPart part, ISelection selection) {
    if (_viewer != null) {
      GraphicalViewer viewerViewer = getGraphicalViewer();
      if (viewerViewer != null && viewerViewer.getControl() != null
          && viewerViewer.getControl().isFocusControl()) {
        updateActions(getSelectionActions());
        if (selection instanceof IStructuredSelection && //
            !(((IStructuredSelection) selection).getFirstElement() instanceof DocumentEditPart)) {
          ((IHTMLGraphicalViewer) viewerViewer)
              .updateRangeSelection(selection);
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.