use of javax.swing.ActionMap in project vcell by virtualcell.
the class EditorKeyboardHandler method createActionMap.
/**
* Return the mapping between JTree's input map and JGraph's actions.
*/
protected ActionMap createActionMap() {
ActionMap map = super.createActionMap();
map.put("save", new EditorActions.SaveAction(false));
map.put("saveAs", new EditorActions.SaveAction(true));
map.put("new", new EditorActions.NewAction());
map.put("open", new EditorActions.OpenAction());
map.put("undo", new EditorActions.HistoryAction(true));
map.put("redo", new EditorActions.HistoryAction(false));
map.put("selectVertices", mxGraphActions.getSelectVerticesAction());
map.put("selectEdges", mxGraphActions.getSelectEdgesAction());
return map;
}
use of javax.swing.ActionMap in project sulky by huxi.
the class SwingLogging method logInputMaps.
public static void logInputMaps(JComponent component) {
final Logger logger = LoggerFactory.getLogger(SwingLogging.class);
if (logger.isDebugEnabled()) {
final int[] conditions = { JComponent.WHEN_IN_FOCUSED_WINDOW, JComponent.WHEN_FOCUSED, JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT };
final String[] conditionStrings = { "WHEN_IN_FOCUSED_WINDOW", "WHEN_FOCUSED", "WHEN_ANCESTOR_OF_FOCUSED_COMPONENT" };
StringBuilder msg = new StringBuilder();
for (int i = 0; i < conditions.length; i++) {
@SuppressWarnings("MagicConstant") InputMap inputMap = component.getInputMap(conditions[i]);
msg.append("InputMap for '").append(conditionStrings[i]).append("':\n");
for (; ; ) {
KeyStroke[] keyStrokes = inputMap.keys();
if (keyStrokes != null) {
for (KeyStroke ks : keyStrokes) {
msg.append("\tKeyStroke: ").append(ks).append("\n\tActionMapKey: ").append(inputMap.get(ks)).append("\n\n");
}
}
msg.append("######################################\n");
inputMap = inputMap.getParent();
if (inputMap == null) {
msg.append("No parent.\n\n");
break;
} else {
msg.append("Parent:\n");
}
}
}
ActionMap actionMap = component.getActionMap();
msg.append("ActionMap:\n");
for (; ; ) {
Object[] keys = actionMap.keys();
if (keys != null) {
for (Object key : keys) {
msg.append("\tKey: ").append(key).append("\n\tAction: ").append(actionMap.get(key)).append("\n\n");
}
}
msg.append("######################################\n");
actionMap = actionMap.getParent();
if (actionMap == null) {
msg.append("No parent.\n\n");
break;
} else {
msg.append("Parent:\n");
}
}
if (logger.isDebugEnabled())
logger.debug(msg.toString());
}
}
use of javax.swing.ActionMap in project sulky by huxi.
the class KeyStrokes method registerCommand.
public static void registerCommand(JComponent component, Action action, String commandName) {
KeyStroke keyStroke = (KeyStroke) action.getValue(Action.ACCELERATOR_KEY);
if (keyStroke == null) {
return;
}
logInputMaps(component, "BEFORE");
InputMap inputMap = component.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
ActionMap actionMap = component.getActionMap();
inputMap.put(keyStroke, commandName);
actionMap.put(commandName, action);
Object value;
inputMap = component.getInputMap(JComponent.WHEN_FOCUSED);
value = inputMap.get(keyStroke);
if (value != null) {
inputMap.put(keyStroke, commandName);
}
inputMap = component.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
value = inputMap.get(keyStroke);
if (value != null) {
inputMap.put(keyStroke, commandName);
}
logInputMaps(component, "AFTER");
}
use of javax.swing.ActionMap in project cayenne by apache.
the class DefaultActionManager method setupCutCopyPaste.
public void setupCutCopyPaste(JComponent comp, Class<? extends Action> cutActionType, Class<? extends Action> copyActionType) {
ActionMap map = comp.getActionMap();
map.put(TransferHandler.getCutAction().getValue(Action.NAME), getAction(cutActionType));
map.put(TransferHandler.getCopyAction().getValue(Action.NAME), getAction(copyActionType));
map.put(TransferHandler.getPasteAction().getValue(Action.NAME), getAction(PasteAction.class));
}
Aggregations