当前位置: 首页>>代码示例>>Java>>正文


Java ScrollingGraphicalViewer.setKeyHandler方法代码示例

本文整理汇总了Java中org.eclipse.gef.ui.parts.ScrollingGraphicalViewer.setKeyHandler方法的典型用法代码示例。如果您正苦于以下问题:Java ScrollingGraphicalViewer.setKeyHandler方法的具体用法?Java ScrollingGraphicalViewer.setKeyHandler怎么用?Java ScrollingGraphicalViewer.setKeyHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.gef.ui.parts.ScrollingGraphicalViewer的用法示例。


在下文中一共展示了ScrollingGraphicalViewer.setKeyHandler方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: configureGraphicalViewer

import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入方法依赖的package包/类
/**
 * Configure the graphical viewer before it receives contents.
 * <p>
 * This is the place to choose an appropriate RootEditPart and EditPartFactory for your editor. The RootEditPart determines the behavior of the editor's
 * "work-area". For example, GEF includes zoomable and scrollable root edit parts. The EditPartFactory maps model elements to edit parts (controllers).
 * </p>
 * 
 * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();

    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    root = new UCMConnectionOnBottomRootEditPart(getParent());

    // zoom management is delegated to us from our parent.
    List zoomLevels = new ArrayList(3);
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    root.getZoomManager().setZoomLevelContributions(zoomLevels);

    viewer.setRootEditPart(root);

    registerContextMenuProvider(viewer);

    viewer.setEditPartFactory(new GraphicalEditPartFactory((UCMmap) getModel()));
    KeyHandler handler = new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler());
    viewer.setKeyHandler(handler);
    getEditDomain().getPaletteViewer().setKeyHandler(handler);
}
 
开发者ID:McGill-DP-Group,项目名称:seg.jUCMNav,代码行数:32,代码来源:UcmEditor.java

示例2: configureGraphicalViewer

import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入方法依赖的package包/类
/**
 * Configure the graphical viewer before it receives contents.
 * <p>
 * This is the place to choose an appropriate RootEditPart and EditPartFactory for your editor. The RootEditPart determines the behavior of the editor's
 * "work-area". For example, GEF includes zoomable and scrollable root edit parts. The EditPartFactory maps model elements to edit parts (controllers).
 * </p>
 * 
 * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
 */
protected void configureGraphicalViewer() {
    super.configureGraphicalViewer();

    ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getGraphicalViewer();
    // Root editpart that include a zoom manager
    root = new GrlConnectionOnBottomRootEditPart(getParent());

    // zoom management is delegated to us from our parent.
    List zoomLevels = new ArrayList(3);
    zoomLevels.add(ZoomManager.FIT_ALL);
    zoomLevels.add(ZoomManager.FIT_WIDTH);
    zoomLevels.add(ZoomManager.FIT_HEIGHT);
    root.getZoomManager().setZoomLevelContributions(zoomLevels);

    viewer.setRootEditPart(root);

    registerContextMenuProvider(viewer);

    viewer.setEditPartFactory(new GrlGraphicalEditPartFactory((GRLGraph) getModel()));
    KeyHandler handler = new GraphicalViewerKeyHandler(viewer).setParent(getCommonKeyHandler());
    viewer.setKeyHandler(handler);
    getEditDomain().getPaletteViewer().setKeyHandler(handler);

}
 
开发者ID:McGill-DP-Group,项目名称:seg.jUCMNav,代码行数:34,代码来源:GrlEditor.java

示例3: configureGraphicalViewer

import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入方法依赖的package包/类
/**
 * Override this to enforce that connections can also be selected with a mouse drag marquee selection.
 */
@Override
protected void configureGraphicalViewer() {

  ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getDiagramContainer().getGraphicalViewer();

  ScalableRootEditPartAnimated rootEditPart = new ScalableRootEditPartAnimated(viewer, getConfigurationProvider()) {
    @Override
    protected GridLayer createGridLayer() {
      return new org.eclipse.graphiti.ui.internal.util.draw2d.GridLayer((IConfigurationProviderInternal) getConfigurationProvider());
    }

    @Override
    public DragTracker getDragTracker(Request req) {
      GFMarqueeDragTracker trckr = new GFMarqueeDragTracker(this);
      trckr.setMarqueeBehavior(GFMarqueeSelectionTool.BEHAVIOR_NODES_AND_CONNECTIONS);
      return trckr;
    }
  };

  // configure ZoomManager
  viewer.setRootEditPart(rootEditPart); // support

  // animation of the zoom
  ZoomManager zoomManager = rootEditPart.getZoomManager();
  List<String> zoomLevels = new ArrayList<>(3);
  zoomLevels.add(ZoomManager.FIT_ALL);
  zoomLevels.add(ZoomManager.FIT_WIDTH);
  zoomLevels.add(ZoomManager.FIT_HEIGHT);
  zoomManager.setZoomLevelContributions(zoomLevels);
  IToolBehaviorProvider toolBehaviorProvider = getConfigurationProvider().getDiagramTypeProvider().getCurrentToolBehaviorProvider();
  zoomManager.setZoomLevels(toolBehaviorProvider.getZoomLevels());

  this.initActionRegistry(zoomManager);

  // set the keyhandler.
  viewer.setKeyHandler((new GraphicalViewerKeyHandler(viewer)).setParent(getCommonKeyHandler()));

  // settings for grid and guides
  Diagram diagram = getConfigurationProvider().getDiagram();

  boolean snapToGrid = diagram.isSnapToGrid();
  int horizontalGridUnit = diagram.getGridUnit();
  int verticalGridUnit = diagram.getVerticalGridUnit();
  if (verticalGridUnit == -1) {
    // No vertical grid unit set (or old diagram before 0.8): use
    // vertical grid unit
    verticalGridUnit = horizontalGridUnit;
  }
  boolean gridVisisble = (horizontalGridUnit > 0) && (verticalGridUnit > 0);

  viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(gridVisisble));
  viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(snapToGrid));
  viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(horizontalGridUnit, verticalGridUnit));
  viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, toolBehaviorProvider.isShowGuides());

  // context button manager
  IConfigurationProviderInternal configurationProvider = (IConfigurationProviderInternal) this.getConfigurationProvider();
  configurationProvider.setContextButtonManager(new ContextButtonManagerForPad(this, configurationProvider.getResourceRegistry()));
}
 
开发者ID:eclipse,项目名称:triquetrum,代码行数:63,代码来源:TriqDiagramBehavior.java

示例4: configureGraphicalViewer

import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入方法依赖的package包/类
protected void configureGraphicalViewer() {

		ScrollingGraphicalViewer viewer = (ScrollingGraphicalViewer) getDiagramContainer().getGraphicalViewer();

		FixedScalableFreeformRootEditPart rootEditPart = new FixedScalableFreeformRootEditPart() {

			protected GridLayer createGridLayer() {
				return new org.eclipse.graphiti.ui.internal.util.draw2d.GridLayer(
						(IConfigurationProviderInternal) getConfigurationProvider());
			}

		};

		// configure ZoomManager
		viewer.setRootEditPart(rootEditPart); // support

		// animation of the zoom
		ZoomManager zoomManager = rootEditPart.getZoomManager();
		List<String> zoomLevels = new ArrayList<String>(3);
		zoomLevels.add(ZoomManager.FIT_ALL);
		zoomLevels.add(ZoomManager.FIT_WIDTH);
		zoomLevels.add(ZoomManager.FIT_HEIGHT);
		zoomManager.setZoomLevelContributions(zoomLevels);
		IToolBehaviorProvider toolBehaviorProvider = getConfigurationProvider().getDiagramTypeProvider()
				.getCurrentToolBehaviorProvider();
		zoomManager.setZoomLevels(toolBehaviorProvider.getZoomLevels());

		this.initActionRegistry(zoomManager);

		// set the keyhandler.
		viewer.setKeyHandler((new GraphicalViewerKeyHandler(viewer)).setParent(getCommonKeyHandler()));

		// settings for grid and guides
		Diagram diagram = getConfigurationProvider().getDiagram();

		boolean snapToGrid = diagram.isSnapToGrid();
		int horizontalGridUnit = diagram.getGridUnit();
		int verticalGridUnit = diagram.getVerticalGridUnit();
		if (verticalGridUnit == -1) {
			// No vertical grid unit set (or old diagram before 0.8): use
			// vertical grid unit
			verticalGridUnit = horizontalGridUnit;
		}
		boolean gridVisisble = (horizontalGridUnit > 0) && (verticalGridUnit > 0);

		viewer.setProperty(SnapToGrid.PROPERTY_GRID_VISIBLE, new Boolean(gridVisisble));
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_ENABLED, new Boolean(snapToGrid));
		viewer.setProperty(SnapToGrid.PROPERTY_GRID_SPACING, new Dimension(horizontalGridUnit, verticalGridUnit));
		viewer.setProperty(SnapToGeometry.PROPERTY_SNAP_ENABLED, toolBehaviorProvider.isShowGuides());

		// context button manager
		IConfigurationProviderInternal configurationProvider = (IConfigurationProviderInternal) this
				.getConfigurationProvider();
		configurationProvider.setContextButtonManager(new ContextButtonManagerForPad(this, configurationProvider
				.getResourceRegistry()));

	}
 
开发者ID:CloudScale-Project,项目名称:Environment,代码行数:58,代码来源:CustomDiagramBehavior.java

示例5: createCubeArea

import org.eclipse.gef.ui.parts.ScrollingGraphicalViewer; //导入方法依赖的package包/类
private Composite createCubeArea( Composite parent )
{
	Composite viewerContent = new Composite( parent, SWT.BORDER );
	GridData gd = new GridData( GridData.FILL_BOTH );
	gd.widthHint = 500;
	gd.heightHint = 300;
	viewerContent.setLayoutData( gd );
	viewerContent.setLayout( new FillLayout( ) );
	viewer = new ScrollingGraphicalViewer( );
	EditDomain editDomain = new EditDomain( );
	ScalableFreeformRootEditPart root = new ScalableFreeformRootEditPart( );
	viewer.setRootEditPart( root );
	viewer.setEditDomain( editDomain );
	viewer.createControl( viewerContent );
	viewer.getControl( ).setBackground( ColorConstants.listBackground );
	factory = new GraphicalEditPartsFactory( );
	viewer.setEditPartFactory( factory );
	viewer.setKeyHandler( new GraphicalViewerKeyHandler( viewer ) );
	viewer.addSelectionChangedListener( new ISelectionChangedListener( ) {

		public void selectionChanged( SelectionChangedEvent event )
		{
			if ( event.getSelection( ) != null )
			{
				StructuredSelection selection = (StructuredSelection) event.getSelection( );
				if ( selection.getFirstElement( ) instanceof HierarchyNodeEditPart
						|| selection.getFirstElement( ) instanceof DatasetNodeEditPart )
				{
					Object obj = selection.getFirstElement( );
					if ( obj instanceof HierarchyNodeEditPart )
					{
						TabularHierarchyHandle hierarchy = (TabularHierarchyHandle) ( (HierarchyNodeEditPart) obj ).getModel( );
						if ( hierarchy.getPrimaryKeys( ) != null
								&& hierarchy.getPrimaryKeys( ).size( ) > 0 )
						{
							filterButton.setEnabled( false );
						}
						else
							filterButton.setEnabled( true );
					}
					else
						filterButton.setEnabled( true );
				}
				else
					filterButton.setEnabled( false );
			}
			else
				filterButton.setEnabled( false );
		}
	} );
	load( );
	return viewerContent;
}
 
开发者ID:eclipse,项目名称:birt,代码行数:54,代码来源:LinkGroupsPage.java


注:本文中的org.eclipse.gef.ui.parts.ScrollingGraphicalViewer.setKeyHandler方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。