Package org.eclipse.gef

Examples of org.eclipse.gef.GraphicalViewer


* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run(IAction action) {
  int style = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell().getStyle();
  Shell shell = new Shell((style & SWT.MIRRORED) != 0 ? SWT.RIGHT_TO_LEFT : SWT.NONE);
  GraphicalViewer viewer = new ScrollingGraphicalViewer();
  viewer.createControl(shell);
  viewer.setEditDomain(new DefaultEditDomain(null));
  viewer.setRootEditPart(new ScalableFreeformRootEditPart());
  viewer.setEditPartFactory(new GraphicalPartFactory());
  viewer.setContents(getContents());
  viewer.flush();
 
  int printMode = new PrintModeDialog(shell).open();
  if (printMode == -1)
    return;
  PrintDialog dialog = new PrintDialog(shell, SWT.NULL);
View Full Code Here


  protected final SWTBotGefViewer viewer;
 
  public SWTBotGefView(final IViewReference partReference, SWTWorkbenchBot bot) {
    super(partReference, bot);
    GraphicalViewer graphicalViewer = UIThreadRunnable.syncExec(new Result<GraphicalViewer>() {
      public GraphicalViewer run() {
        final IViewPart view = partReference.getView(true);
        return (GraphicalViewer) view.getAdapter(GraphicalViewer.class);
      }
    });
View Full Code Here

   * @param bot the workbench bot
   * @throws WidgetNotFoundException if widget could not be found
   */
  public SWTBotGefEditor(final IEditorReference reference, final SWTWorkbenchBot bot) throws WidgetNotFoundException {
    super(reference, bot);
    GraphicalViewer graphicalViewer = UIThreadRunnable.syncExec(new Result<GraphicalViewer>() {
      public GraphicalViewer run() {
        final IEditorPart editor = partReference.getEditor(true);
        return (GraphicalViewer) editor.getAdapter(GraphicalViewer.class);
      }
    });
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

    updateDirtyState();
  }

  private void marshallImage(Bpmn2MemoryModel model, String modelFileName) {
    try {
      final GraphicalViewer graphicalViewer =  (GraphicalViewer) ((DiagramEditor) model.getFeatureProvider()
              .getDiagramTypeProvider().getDiagramEditor()).getAdapter(GraphicalViewer.class);

      if (graphicalViewer == null || graphicalViewer.getEditPartRegistry() == null) {
        return;
      }
      final ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) graphicalViewer.getEditPartRegistry().get(LayerManager.ID);
      final IFigure rootFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.PRINTABLE_LAYERS);
      final IFigure gridFigure = ((LayerManager) rootEditPart).getLayer(LayerConstants.GRID_LAYER);
      final Rectangle rootFigureBounds = rootFigure.getBounds();

      final boolean toggleRequired = gridFigure.isShowing();

      final Display display = Display.getDefault();

      final Image img = new Image(display, rootFigureBounds.width, rootFigureBounds.height);
      final GC imageGC = new GC(img);
      final SWTGraphics grap = new SWTGraphics(imageGC);

      // Access UI thread from runnable to print the canvas to the image
      display.syncExec(new Runnable() {

        @Override
        public void run() {
          if (toggleRequired) {
            // Disable any grids temporarily
            gridFigure.setVisible(false);
          }
          // Deselect any selections
          graphicalViewer.deselectAll();
          rootFigure.paint(grap);
        }
      });

      ImageLoader imgLoader = new ImageLoader();
View Full Code Here

    getActionRegistry().registerAction(zoomOut);
    getActionRegistry().registerAction(new ExportAction(this));
    getSite().getKeyBindingService().registerAction(zoomIn);
    getSite().getKeyBindingService().registerAction(zoomOut);

    GraphicalViewer viewer = getGraphicalViewer();
    viewer.setRootEditPart(root);
    viewer.setKeyHandler(new GraphicalViewerKeyHandler(viewer));
    viewer.setEditPartFactory(new GraphicalPartFactory());
    viewer.getControl().setBackground(ColorConstants.listBackground);

    ContextMenuProvider provider = new GraphContextMenuProvider(viewer, getActionRegistry());
    viewer.setContextMenu(provider);
    getSite().registerContextMenu(CONTEXT_MENU_ID, provider, viewer);
  }
View Full Code Here

  /**
   * Creates the GraphicalViewer on the specified <code>Composite</code>.
   * @param parent the parent composite
   */
  protected void createGraphicalViewer(Composite parent) {
    GraphicalViewer viewer = new ScrollingGraphicalViewer();
    viewer.createControl(parent);
    getSite().setSelectionProvider(viewer);
    setGraphicalViewer(viewer);
    configureGraphicalViewer();
    initializeGraphicalViewer();
  }
View Full Code Here

      SpringUIUtils.openInEditor(type);
    }
  }

  protected EditPart getFirstSelectedEditPart() {
    GraphicalViewer viewer = ((GraphEditor) getWorkbenchPart())
        .getGraphicalViewer();
    List list = viewer.getSelectedEditParts();
    if (!list.isEmpty()) {
      return (EditPart) list.get(0);
    }
    return null;
  }
View Full Code Here

    Bean bean = ((BeanPart) getFirstSelectedEditPart()).getBean();
    BeansUIUtils.openInEditor(bean.getBean());
  }

  protected EditPart getFirstSelectedEditPart() {
    GraphicalViewer viewer = ((GraphEditor)
                     getWorkbenchPart()).getGraphicalViewer();
    List list = viewer.getSelectedEditParts();
    if (!list.isEmpty()) {
      return (EditPart) list.get(0);
    }
    return null;
  }
View Full Code Here

  /**
   * @return
   */
  protected EditPart getFirstSelectedEditPart() {
    GraphicalViewer viewer = ((WebflowEditor) getWorkbenchPart())
        .getGraphViewer();
    List list = viewer.getSelectedEditParts();
    if (!list.isEmpty()) {
      return (EditPart) list.get(0);
    }
    return null;
  }
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.