本文整理汇总了Java中org.eclipse.gef.KeyHandler.put方法的典型用法代码示例。如果您正苦于以下问题:Java KeyHandler.put方法的具体用法?Java KeyHandler.put怎么用?Java KeyHandler.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.gef.KeyHandler
的用法示例。
在下文中一共展示了KeyHandler.put方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
示例3: 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);
}
示例4: 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);
}
示例5: 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;
}