本文整理汇总了Java中org.eclipse.gef.KeyStroke类的典型用法代码示例。如果您正苦于以下问题:Java KeyStroke类的具体用法?Java KeyStroke怎么用?Java KeyStroke使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
KeyStroke类属于org.eclipse.gef包,在下文中一共展示了KeyStroke类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: performStroke
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
private boolean performStroke(KeyStroke key, KeyEvent keyEvent) {
if (actions == null)
return false;
IAction action = actions.get(key);
if (action == null)
return false;
boolean enabled = action.isEnabled();
if (enabled) {
Event event = new Event();
event.character = keyEvent.character;
event.data = keyEvent.data;
event.display = keyEvent.display;
event.doit = keyEvent.doit;
event.keyCode = keyEvent.keyCode;
event.keyLocation = keyEvent.keyLocation;
event.stateMask = keyEvent.stateMask;
event.time = keyEvent.time;
event.widget = keyEvent.widget;
action.runWithEvent(event);
}
return enabled; // CHANGED from "true" in the original eclipse code
}
示例2: TableCellKeyDelegate
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Default Constuctor.
*/
public TableCellKeyDelegate( GraphicalViewer viewer,ActionRegistry actionRegistry )
{
super( viewer );
//this.actionRegistry = actionRegistry;
put( KeyStroke.getPressed('r', 114, SWT.ALT|SWT.SHIFT ),
actionRegistry.getAction( SelectRowAction.ID) );
put( KeyStroke.getPressed('R', 114, SWT.ALT|SWT.SHIFT ),
actionRegistry.getAction( SelectRowAction.ID) );
put( KeyStroke.getPressed('c', 99, SWT.ALT|SWT.SHIFT ),
actionRegistry.getAction( SelectColumnAction.ID) );
put( KeyStroke.getPressed('C', 99, SWT.ALT|SWT.SHIFT ),
actionRegistry.getAction( SelectColumnAction.ID) );
}
示例3: keyPressed
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Processes a <i>key pressed</i> event. This method is called by the Tool whenever a key
* is pressed, and the Tool is in the proper state.
* @param event the KeyEvent
* @return <code>true</code> if KeyEvent was handled in some way
*/
@Override
public boolean keyPressed(KeyEvent event) {
if (performStroke(KeyStroke.getPressed(event.character, event.keyCode, event.stateMask), event)) {
event.doit = false;
return true;
}
return parent != null && parent.keyPressed(event);
}
示例4: keyReleased
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Processes a <i>key released</i> event. This method is called by the Tool whenever a key
* is released, and the Tool is in the proper state.
* @param event the KeyEvent
* @return <code>true</code> if KeyEvent was handled in some way
*/
@Override
public boolean keyReleased(KeyEvent event) {
if (performStroke(KeyStroke.getReleased(event.character, event.keyCode, event.stateMask), event))
return true;
return parent != null && parent.keyReleased(event);
}
示例5: configureKeyboardShortcuts
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* This method sets shortcuts for actions.
* */
private void configureKeyboardShortcuts() {
getGraphicalViewer().getKeyHandler();
GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(
getGraphicalViewer());
keyHandler.put(KeyStroke.getPressed(SWT.F2, 0), getActionRegistry()
.getAction(GEFActionConstants.DIRECT_EDIT));
keyHandler.put(
KeyStroke.getPressed(SWT.CR, '\r', 0),
getActionRegistry().getAction(
CreateAttributeOperationAction.CREATE_A_M_ID));
getGraphicalViewer().setKeyHandler(keyHandler);
}
示例6: ReportViewerKeyHandler
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Constructor of KeyHandler
*
* @param viewer
* @param actionRegistry
*/
public ReportViewerKeyHandler( GraphicalViewer viewer,
ActionRegistry actionRegistry )
{
super( viewer );
this.actionRegistry = actionRegistry;
put( KeyStroke.getPressed( SWT.F2, 0 ),
actionRegistry.getAction( GEFActionConstants.DIRECT_EDIT ) );
tableDelgate = new TableCellKeyDelegate( viewer, actionRegistry );
}
示例7: put
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Bounds actions with key events
*
* @param character
* @param keyCode
* @param stateMask
* @param actionID
*/
public void put( char character, int keyCode, int stateMask, String actionID )
{
IAction action = actionRegistry.getAction( actionID );
if ( action != null )
{
put( KeyStroke.getReleased( character, keyCode, stateMask ), action );
}
}
示例8: createViewer
import org.eclipse.gef.KeyStroke; //导入依赖的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;
}
示例9: configureKeyHandler
import org.eclipse.gef.KeyStroke; //导入依赖的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);
}
示例10: configureGraphicalViewer
import org.eclipse.gef.KeyStroke; //导入依赖的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);
}
示例11: configureGraphicalViewer
import org.eclipse.gef.KeyStroke; //导入依赖的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);
}
示例12: configureKeyboardShortcuts
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
private void configureKeyboardShortcuts() {
GraphicalViewerKeyHandler keyHandler = new GraphicalViewerKeyHandler(getGraphicalViewer());
keyHandler.put(KeyStroke.getPressed(SWT.F4,0), getActionRegistry().getAction(Constants.SUBJOB_OPEN));
getGraphicalViewer().setKeyHandler(keyHandler);
}
示例13: getCommonKeyHandler
import org.eclipse.gef.KeyStroke; //导入依赖的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;
}
示例14: remove
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
/**
* Removed a mapped <code>IAction</code> for the specified <code>KeyStroke</code>.
* @param keystroke the KeyStroke to be unmapped
*/
@Override
public void remove(KeyStroke keystroke) {
if (actions != null)
actions.remove(keystroke);
}
示例15: activate
import org.eclipse.gef.KeyStroke; //导入依赖的package包/类
@Override
public void activate() {
if( isActive() )
return;
TransactionUtils.reading(getModel(), new Runnable() {
@Override
public void run() {
PlanTimelineEditPart.super.activate();
}
});
Action action = null;
KeyStroke key = null;
TimelineKeyHandler keyHandler = new TimelineKeyHandler();
action = new NudgeAction("Nudge Right", 1, this);
key = KeyStroke.getPressed(SWT.ARROW_RIGHT, 0);
keyHandler.put(key, action);
action = new NudgeAction("Fast Nudge Right", FAST_NUDGE_FACTOR, this);
key = KeyStroke.getPressed(SWT.ARROW_RIGHT, SWT.SHIFT);
keyHandler.put(key, action);
action = new NudgeAction("Nudge Left", -1, this);
key = KeyStroke.getPressed(SWT.ARROW_LEFT, 0);
keyHandler.put(key, action);
action = new NudgeAction("Fast Nudge Left", -1*FAST_NUDGE_FACTOR, this);
key = KeyStroke.getPressed(SWT.ARROW_LEFT, SWT.SHIFT);
keyHandler.put(key, action);
// action = new NeighborSelectAction("Select Next Right", this, Direction.RIGHT);
// key = KeyStroke.getPressed(SWT.ARROW_RIGHT, SWT.CONTROL);
// keyHandler.put(key, action);
//
// action = new NeighborSelectAction("Select Next Left", this, Direction.LEFT);
// key = KeyStroke.getPressed(SWT.ARROW_LEFT, SWT.CONTROL);
// keyHandler.put(key, action);
//
// action = new NeighborSelectAction("Select Next (Down) Vertical Category", this, Direction.DOWN);
// key = KeyStroke.getPressed(SWT.ARROW_DOWN, SWT.CONTROL);
// keyHandler.put(key, action);
//
// action = new NeighborSelectAction("Select Previous (Up) Vertical Category", this, Direction.UP);
// key = KeyStroke.getPressed(SWT.ARROW_UP, SWT.CONTROL);
// keyHandler.put(key, action);
TimelineKeyHandler handler = (TimelineKeyHandler) getViewer().getKeyHandler();
if(handler == null) {
handler = new TimelineKeyHandler();
getViewer().setKeyHandler(handler);
}
keyHandler.setParent(handler);
getViewer().setKeyHandler(keyHandler);
}