Java Code Examples for org.eclipse.gef.GraphicalViewer#setProperty()

The following examples show how to use org.eclipse.gef.GraphicalViewer#setProperty() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ERDiagramEditor.java    From ermasterr with Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void initializeGraphicalViewer() {
    final GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(editPartFactory);

    initViewerAction(viewer);
    initDragAndDrop(viewer);

    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
    viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

    final MenuManager menuMgr = new ERDiagramPopupMenuManager(getActionRegistry(), diagram);

    extensionLoader.addERDiagramPopupMenu(menuMgr, getActionRegistry());

    viewer.setContextMenu(menuMgr);

    viewer.setContents(diagram);

    outlineMenuMgr = new ERDiagramOutlinePopupMenuManager(diagram, getActionRegistry(), outlinePage.getOutlineActionRegistory(), outlinePage.getViewer());
}
 
Example 2
Source File: MainDiagramEditor.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected void initializeGraphicalViewer() {
    final GraphicalViewer viewer = getGraphicalViewer();
    viewer.setEditPartFactory(editPartFactory);
    initViewerAction(viewer);
    initDragAndDrop(viewer);
    viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1), MouseWheelZoomHandler.SINGLETON);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
    viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
    viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

    prepareERDiagramPopupMenu(viewer);

    prepareERDiagramOutlinePopupMenu();

    this.gotoMaker = new ERDiagramGotoMarker(this);
}
 
Example 3
Source File: SankeyDiagram.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
@Override
protected void configureGraphicalViewer() {
	super.configureGraphicalViewer();

	MenuManager menu = SankeyMenu.create(this);
	getGraphicalViewer().setContextMenu(menu);

	GraphicalViewer viewer = getGraphicalViewer();
	viewer.setEditPartFactory(new SankeyEditPartFactory());
	ScalableRootEditPart root = new ScalableRootEditPart();
	viewer.setRootEditPart(root);

	// append zoom actions to action registry
	ZoomManager zoom = root.getZoomManager();
	getActionRegistry().registerAction(new ZoomInAction(zoom));
	getActionRegistry().registerAction(new ZoomOutAction(zoom));
	zoom.setZoomLevelContributions(Arrays.asList(
			ZoomManager.FIT_ALL,
			ZoomManager.FIT_HEIGHT,
			ZoomManager.FIT_WIDTH));

	// create key handler
	KeyHandler keyHandler = new KeyHandler();
	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.setKeyHandler(keyHandler);

	viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.NONE),
			MouseWheelZoomHandler.SINGLETON);
}
 
Example 4
Source File: ERDiagramEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
	 * {@inheritDoc}
	 */
	@Override
	protected void initializeGraphicalViewer() {
		GraphicalViewer viewer = this.getGraphicalViewer();
		viewer.setEditPartFactory(editPartFactory);

		this.initViewerAction(viewer);
		this.initDragAndDrop(viewer);

		viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
				MouseWheelZoomHandler.SINGLETON);
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
		viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

		MenuManager menuMgr = new ERDiagramPopupMenuManager(this
				.getActionRegistry(), this.diagram);

		this.extensionLoader.addERDiagramPopupMenu(menuMgr, this
				.getActionRegistry());

		viewer.setContextMenu(menuMgr);

//		if (diagram.getCurrentErmodel() == null) {
//			viewer.setContents(diagram);
//		} else {
//			// �Ƃ肠����OFF���āA�ŏ��Ƀt�H�[�J�X�����������Ƃ��ɃR���e���c���l�߂�
//		}

		this.outlineMenuMgr = new ERDiagramOutlinePopupMenuManager(
				this.diagram, this.getActionRegistry(), this.outlinePage
						.getOutlineActionRegistory(), this.outlinePage
						.getViewer());

		this.gotoMaker = new ERDiagramGotoMarker(this);
	}
 
Example 5
Source File: EROneDiagramEditor.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
@Override
	protected void initializeGraphicalViewer() {
		GraphicalViewer viewer = this.getGraphicalViewer();
		viewer.setEditPartFactory(editPartFactory);

		this.initViewerAction(viewer);
		this.initDragAndDrop(viewer);

		viewer.setProperty(MouseWheelHandler.KeyGenerator.getKey(SWT.MOD1),
				MouseWheelZoomHandler.SINGLETON);
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, true);
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, true);
		viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, true);

		MenuManager menuMgr = new ERDiagramOnePopupMenuManager(this.getActionRegistry(), this.model);

		this.extensionLoader.addERDiagramPopupMenu(menuMgr, this.getActionRegistry());

		viewer.setContextMenu(menuMgr);

		viewer.setContents(model);
//		viewer.getRootEditPart().setContents(editPartFactory.);

		this.outlineMenuMgr = new ERDiagramOutlinePopupMenuManager(
				this.diagram, this.getActionRegistry(),
				this.outlinePage.getOutlineActionRegistory(), this.outlinePage.getViewer());

		this.gotoMaker = new ERDiagramGotoMarker(this);
	}