本文整理汇总了Java中org.eclipse.gef.KeyHandler类的典型用法代码示例。如果您正苦于以下问题:Java KeyHandler类的具体用法?Java KeyHandler怎么用?Java KeyHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyHandler类属于org.eclipse.gef包,在下文中一共展示了KeyHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: configureGraphicalViewer
import org.eclipse.gef.KeyHandler; //导入依赖的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);
}
示例2: configureGraphicalViewer
import org.eclipse.gef.KeyHandler; //导入依赖的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);
}
示例3: DiagramEditorOutlinePage
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* Creates a new GraphicsEditorOutlinePage. It is important, that this outline page uses the same handlers (ActionRegistry, KeyHandler, ZoomManagerAdapter,
* ...) as the main editor, so that the behaviour is synchronized between them.
*
* @param diagramEditor
* the attached diagram editor
* @since 0.9
*/
public DiagramEditorOutlinePage(IDiagramContainerUI diagramEditor) {
super(new TriqOutlineTreeViewer(diagramEditor));
_graphicalViewer = diagramEditor.getGraphicalViewer();
_actionRegistry = diagramEditor.getAdapter(ActionRegistry.class);
_editDomain = diagramEditor.getEditDomain();
_keyHandler = diagramEditor.getAdapter(KeyHandler.class);
_selectionSynchronizer = diagramEditor.getAdapter(SelectionSynchronizer.class);
_diagramEditor = diagramEditor;
}
示例4: createViewer
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* Creates the viewer for the relations pane.
*
* @param inParent
* Composite
* @return GraphicalViewer
*/
public GraphicalViewer createViewer(final Composite inParent) {
final GraphicalViewer outViewer = new ScrollingGraphicalViewer();
outViewer.createControl(inParent);
// configure the viewer
outViewer.getControl().setBackground(BG_COLOR);
rootPart = new RelationsRootEditPart();
outViewer.setRootEditPart(rootPart);
final KeyHandler lKeyHandler = new BrowserKeyHandler(outViewer);
lKeyHandler.put(KeyStroke.getPressed(SWT.CONTROL, SWT.NONE), new Action() {
@Override
public void run() {
rootPart.makeMousOverPartClickable(true);
}
});
lKeyHandler.put(KeyStroke.getReleased(SWT.CONTROL, SWT.CONTROL), new Action() {
@Override
public void run() {
rootPart.makeMousOverPartClickable(false);
}
});
outViewer.setKeyHandler(lKeyHandler);
outViewer.setEditPartFactory(getEditPartFactory());
return outViewer;
}
示例5: configureKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
void configureKeyHandler() {
KeyHandler keyHandler = new KeyHandler();
IAction delete = actionRegistry.getAction(org.eclipse.ui.actions.ActionFactory.DELETE.getId());
IAction zoomIn = actionRegistry.getAction(GEFActionConstants.ZOOM_IN);
IAction zoomOut = actionRegistry.getAction(GEFActionConstants.ZOOM_OUT);
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), delete);
keyHandler.put(KeyStroke.getPressed('+', SWT.KEYPAD_ADD, 0), zoomIn);
keyHandler.put(KeyStroke.getPressed('-', SWT.KEYPAD_SUBTRACT, 0), zoomOut);
viewer.setKeyHandler(keyHandler);
}
示例6: configureGraphicalViewer
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
@Override
protected void configureGraphicalViewer() {
ArrayList<String> zoomContributions;
// configure viewer
super.configureGraphicalViewer();
MenuManager menu = SankeyMenu.create(this);
getGraphicalViewer().setContextMenu(menu);
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(new SankeyEditPartFactory());
ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
viewer.setRootEditPart(rootEditPart);
ZoomManager zoomManager = rootEditPart.getZoomManager();
// append zoom actions to action registry
getActionRegistry().registerAction(new ZoomInAction(zoomManager));
getActionRegistry().registerAction(new ZoomOutAction(zoomManager));
zoomContributions = new ArrayList<>();
zoomContributions.add(ZoomManager.FIT_ALL);
zoomContributions.add(ZoomManager.FIT_HEIGHT);
zoomContributions.add(ZoomManager.FIT_WIDTH);
zoomManager.setZoomLevelContributions(zoomContributions);
// 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);
}
示例7: configureGraphicalViewer
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* @generated NOT
*/
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
DiagramEditorContextMenuProvider provider = new DiagramEditorContextMenuProvider(
this, getDiagramGraphicalViewer());
getDiagramGraphicalViewer().setContextMenu(provider);
getSite().registerContextMenu(ActionIds.DIAGRAM_EDITOR_CONTEXT_MENU,
provider, getDiagramGraphicalViewer());
// sets a key handler.
IDiagramGraphicalViewer viewer = getDiagramGraphicalViewer();
KeyHandler dcaseKeyHandler = new DcaseDiagramKeyHandler(viewer);
dcaseKeyHandler.setParent(viewer.getKeyHandler());
viewer.setKeyHandler(dcaseKeyHandler);
}
示例8: configureGraphicalViewer
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
protected void configureGraphicalViewer() {
super.configureGraphicalViewer();
double[] zoomLevels;
List<String> zoomContributions;
GraphicalViewer viewer = getGraphicalViewer();
viewer.setEditPartFactory(gw4eEditPartFactory);
keyHandler = new KeyHandler();
keyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
getActionRegistry().getAction(ActionFactory.DELETE.getId()));
keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
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));
getGraphicalViewer().setKeyHandler(new GraphicalViewerKeyHandler(getGraphicalViewer()).setParent(keyHandler));
ScalableRootEditPart rootEditPart = new ScalableRootEditPart();
viewer.setRootEditPart(rootEditPart);
ZoomManager manager = rootEditPart.getZoomManager();
getActionRegistry().registerAction(new ZoomInAction(manager));
getActionRegistry().registerAction(new ZoomOutAction(manager));
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);
getActionRegistry().registerAction(new ToggleGridAction(getGraphicalViewer()));
getActionRegistry().registerAction(new ToggleSnapToGeometryAction(getGraphicalViewer()));
getActionRegistry().registerAction(new ClearEdgeBendpointLayoutAction(this));
ContextMenuProvider provider = new ContextMenuProvider(this, viewer, getActionRegistry());
viewer.setContextMenu(provider);
}
示例9: registerKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
private void registerKeyHandler() {
GraphicalViewerKeyHandler graphicalViewerKeyHandler = new GraphicalViewerKeyHandler(getGraphicalViewer());
KeyHandler parentKeyHandler = graphicalViewerKeyHandler.setParent(getCommonKeyHandler());
getGraphicalViewer().setKeyHandler(parentKeyHandler);
}
示例10: getCommonKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
public KeyHandler getCommonKeyHandler() {
KeyHandler sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 127, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
sharedKeyHandler.put(KeyStroke.getReleased((char)1, 97, SWT.CTRL), getActionRegistry().getAction(ActionFactory.SELECT_ALL.getId()));
return sharedKeyHandler;
}
示例11: getKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* @see EditPartViewer#getKeyHandler()
*/
public KeyHandler getKeyHandler() {
return keyHandler;
}
示例12: setKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* @see EditPartViewer#setKeyHandler(KeyHandler)
*/
public void setKeyHandler(KeyHandler handler) {
keyHandler = handler;
}
示例13: setParent
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
public KeyHandler setParent( KeyHandler parent )
{
return super.setParent( parent );
}
示例14: GraphicsEditorOutlinePage
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* Creates a new GraphicsEditorOutlinePage. It is important, that this
* outline page uses the same handlers (ActionRegistry, KeyHandler,
* ZoomManagerAdapter, ...) as the main editor, so that the behaviour is
* synchronized between them.
*
* @param viewer
* The viewer (typically a tree-viewer) for the hierarchical
* outline.
* @param graphicalViewer
* The GraphicalViewer for the Thumbnail.
* @param actionRegistry
* The ActionRegistry to find/register Actions.
* @param editDomain
* The EditDomain to use for Commands.
* @param keyHandler
* The KeyHandler to use.
* @param zoomManagerAdapter
* The ZoomManagerAdapter to use for the Thumbnail-Display.
* @param selectionSynchronizer
* The selection-synchronizer for the main-editor and this
* outline page.
* @param configurationProviderHolder
* the configuration provider holder
*/
public GraphicsEditorOutlinePage(EditPartViewer viewer, GraphicalViewer graphicalViewer, ActionRegistry actionRegistry,
EditDomain editDomain, KeyHandler keyHandler, Object zoomManagerAdapter, SelectionSynchronizer selectionSynchronizer,
DiagramEditor diagramEditor) {
super(viewer);
_graphicalViewer = graphicalViewer;
_actionRegistry = actionRegistry;
_editDomain = editDomain;
_keyHandler = keyHandler;
_zoomManagerAdapter = zoomManagerAdapter;
_selectionSynchronizer = selectionSynchronizer;
_diagramEditor = diagramEditor;
}
示例15: createKeyHandler
import org.eclipse.gef.KeyHandler; //导入依赖的package包/类
/**
* KeyHandler를 생성한다.
*
* @return
*/
protected KeyHandler createKeyHandler(GraphicalViewer viewer) {
return new GraphicalViewerKeyHandler(viewer).setParent(getKeyHandler());
}