use of javax.swing.KeyStroke in project freeplane by freeplane.
the class MenuRadioActionComponentProvider method createComponent.
/* (non-Javadoc)
* @see org.freeplane.core.ui.menubuilders.menu.ComponentProvider#createComponent(org.freeplane.core.ui.menubuilders.generic.Entry)
*/
@Override
public Component createComponent(Entry entry) {
final AFreeplaneAction action = entryAccessor.getAction(entry);
if (action != null) {
final JMenuItem actionComponent;
IFreeplaneAction wrappedAction = acceleratebleActionProvider.wrap(action);
if (action.isSelectable()) {
actionComponent = new JAutoRadioButtonMenuItem(wrappedAction);
} else {
actionComponent = new JRadioButtonMenuItem(wrappedAction);
}
actionComponent.setSelected(Boolean.parseBoolean(String.valueOf(entry.getAttribute("selected"))) || entry.getName().equals(getSelectedActionName(entry)));
buttonGroup.add(actionComponent);
final KeyStroke accelerator = accelerators.getAccelerator(action);
actionComponent.setAccelerator(accelerator);
MenuIconScaling.scaleIcon(actionComponent);
return actionComponent;
} else if (entry.builders().contains("separator")) {
return new JPopupMenu.Separator();
} else
return null;
}
use of javax.swing.KeyStroke in project freeplane by freeplane.
the class MModeControllerFactory method createStandardControllers.
private void createStandardControllers() {
final Controller controller = Controller.getCurrentController();
modeController = new MModeController(controller);
final UserInputListenerFactory userInputListenerFactory = new UserInputListenerFactory(modeController);
final IMouseListener nodeMouseMotionListener = new MNodeMotionListener();
userInputListenerFactory.setNodeMouseMotionListener(nodeMouseMotionListener);
userInputListenerFactory.setNodeMouseWheelListener(new MNodeMouseWheelListener(userInputListenerFactory.getMapMouseWheelListener()));
final JPopupMenu popupmenu = new JPopupMenu();
userInputListenerFactory.setNodePopupMenu(popupmenu);
modeController.setUserInputListenerFactory(userInputListenerFactory);
controller.addModeController(modeController);
controller.selectModeForBuild(modeController);
new MMapController(modeController);
final MFileManager fileManager = new MFileManager();
UrlManager.install(fileManager);
MMapIO.install(modeController);
controller.getMapViewManager().addMapViewChangeListener(fileManager);
new MIconController(modeController).install(modeController);
new ProgressFactory().installActions(modeController);
final MapController mapController = modeController.getMapController();
EdgeController.install(new MEdgeController(modeController));
CloudController.install(new MCloudController(modeController));
NoteController.install(new MNoteController(modeController));
userInputListenerFactory.setMapMouseListener(new MMapMouseListener());
final MTextController textController = new MTextController(modeController);
textController.install(modeController);
LinkController.install(new MLinkController(modeController));
NodeStyleController.install(new MNodeStyleController(modeController));
ClipboardController.install(new MClipboardController());
userInputListenerFactory.setNodeDragListener(new MNodeDragListener());
userInputListenerFactory.setNodeDropTargetListener(new MNodeDropListener());
LocationController.install(new MLocationController());
final MLogicalStyleController logicalStyleController = new MLogicalStyleController(modeController);
LogicalStyleController.install(logicalStyleController);
logicalStyleController.initM();
AttributeController.install(new MAttributeController(modeController));
userInputListenerFactory.setNodeKeyListener(new DefaultNodeKeyListener(new IEditHandler() {
public void edit(final KeyEvent e, final FirstAction action, final boolean editLong) {
((MTextController) MTextController.getController(modeController)).getEventQueue().activate(e);
textController.edit(action, editLong);
}
}));
userInputListenerFactory.setNodeMotionListener(new MNodeMotionListener());
modeController.addAction(new EditAttributesAction());
SpellCheckerController.install(modeController);
ExportController.install(new ExportController("/xml/ExportWithXSLT.xml"));
MapStyle.install(true);
final FreeplaneToolBar toolbar = new FreeplaneToolBar("main_toolbar", SwingConstants.HORIZONTAL);
final FrameController frameController = (FrameController) controller.getViewController();
UIComponentVisibilityDispatcher.install(frameController, toolbar, "toolbarVisible");
userInputListenerFactory.addToolBar("/main_toolbar", ViewController.TOP, toolbar);
userInputListenerFactory.addToolBar("/filter_toolbar", FilterController.TOOLBAR_SIDE, FilterController.getController(controller).getFilterToolbar());
userInputListenerFactory.addToolBar("/status", ViewController.BOTTOM, frameController.getStatusBar());
final JTabbedPane formattingPanel = new JTabbedPane();
Box resisableTabs = new CollapseableBoxBuilder(frameController).setPropertyNameBase("styleScrollPaneVisible").createBox(formattingPanel, Direction.RIGHT);
userInputListenerFactory.addToolBar("/format", ViewController.RIGHT, resisableTabs);
final JRootPane rootPane = ((RootPaneContainer) frameController.getMenuComponent()).getRootPane();
final FButtonBar fButtonToolBar = new FButtonBar(rootPane);
UIComponentVisibilityDispatcher.install(frameController, fButtonToolBar, "fbarVisible");
fButtonToolBar.setVisible(ResourceController.getResourceController().getBooleanProperty("fbarVisible"));
userInputListenerFactory.addToolBar("/fbuttons", ViewController.TOP, fButtonToolBar);
userInputListenerFactory.setKeyEventProcessor(new IKeyStrokeProcessor() {
@Override
public boolean processKeyBinding(KeyStroke ks, KeyEvent e) {
return ResourceController.getResourceController().getAcceleratorManager().processKeyBinding(ks, e) || fButtonToolBar.processKeyBinding(ks, e);
}
});
controller.addAction(new ToggleToolbarAction("ToggleFBarAction", "/fbuttons"));
SModeControllerFactory.install();
modeController.addAction(new SetAcceleratorOnNextClickAction());
modeController.addAction(new ShowNotesInMapAction());
// userInputListenerFactory.getMenuBuilder().setAcceleratorChangeListener(fButtonToolBar);
ResourceController.getResourceController().getAcceleratorManager().addAcceleratorChangeListener(modeController, fButtonToolBar);
userInputListenerFactory.addToolBar("/icon_toolbar", ViewController.LEFT, ((MIconController) IconController.getController()).getIconToolBarScrollPane());
modeController.addAction(new ToggleToolbarAction("ToggleLeftToolbarAction", "/icon_toolbar"));
new RevisionPlugin();
FoldingController.install(new FoldingController());
uiFactory = new MUIFactory();
mapController.addNodeChangeListener(uiFactory);
mapController.addNodeSelectionListener(uiFactory);
mapController.addMapChangeListener(uiFactory);
controller.getMapViewManager().addMapSelectionListener(uiFactory);
modeController.addExtension(MUIFactory.class, uiFactory);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_name", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
final Container fontBox = uiFactory.createFontBox();
return fontBox;
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_font_size", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createSizeBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.ACTIONS, "main_toolbar_style", new ComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return uiFactory.createStyleBox();
}
}), EntryVisitor.EMTPY);
modeController.addUiBuilder(Phase.UI, "main_toolbar_zoom", new JToolbarComponentBuilder(new ComponentProvider() {
@Override
public Component createComponent(Entry entry) {
return controller.getMapViewManager().createZoomBox();
}
}));
// IconController.getController(modeController).addStateIconProvider(new IStateIconProvider() {
// public UIIcon getStateIcon(NodeModel node) {
// final URI link = NodeLinks.getLink(node);
// return wrapIcon(LinkController.getLinkIcon(link, node));
// }
//
// private UIIcon wrapIcon(final Icon linkIcon) {
// UIIcon icon = null;
// if(linkIcon != null) {
// if(linkIcon instanceof UIIcon) {
// icon = (UIIcon) linkIcon;
// }
// else {
// icon = new UIIcon("ownIcon", null) {
// public Icon getIcon() {
// return linkIcon;
// }
// };
// }
// }
// return icon;
// }
// });
}
use of javax.swing.KeyStroke in project ffx by mjschnie.
the class MainMenu method configureAction.
private void configureAction(Action a, String icon, String actionCommand, int mnemonic, int accelerator) {
String name;
try {
name = locale.getValue(actionCommand);
} catch (Exception e) {
name = actionCommand;
}
ImageIcon imageIcon = getIcon(icon);
KeyStroke keyStroke = KeyStroke.getKeyStroke(accelerator, keyMask);
a.putValue(ACCELERATOR_KEY, keyStroke);
a.putValue(ACTION_COMMAND_KEY, actionCommand);
a.putValue(MNEMONIC_KEY, mnemonic);
a.putValue(NAME, name);
a.putValue(SHORT_DESCRIPTION, name);
a.putValue(LONG_DESCRIPTION, name);
a.putValue(SMALL_ICON, imageIcon);
a.putValue(LARGE_ICON_KEY, imageIcon);
if (!icon.equalsIgnoreCase("BLANK")) {
toolBar.add(a);
}
}
use of javax.swing.KeyStroke in project fql by CategoricalData.
the class XDisplay method display.
// private final Map<String, String> indices = new HashMap<>();
private void display(String s, @SuppressWarnings("unused") List<String> order) {
frame = new JFrame();
// name = s;
Vector<String> ooo = new Vector<>();
// int index = 0;
for (Pair<String, JComponent> p : frames) {
x.add(p.second, p.first);
ooo.add(p.first);
// indices.put(order.get(index++), p.first);
}
x.add(new JPanel(), "blank");
cl.show(x, "blank");
yyy.setListData(ooo);
JPanel temp1 = new JPanel(new GridLayout(1, 1));
temp1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Select:"));
JScrollPane yyy1 = new JScrollPane(yyy);
temp1.add(yyy1);
// temp1.setMinimumSize(new Dimension(200, 600));
// yyy.setPreferredSize(new Dimension(200, 600));
yyy.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
yyy.addListSelectionListener((ListSelectionEvent e) -> {
int i = yyy.getSelectedIndex();
if (i == -1) {
cl.show(x, "blank");
} else {
cl.show(x, ooo.get(i));
}
});
JPanel north = new JPanel(new GridLayout(1, 1));
// JButton saveButton = new JButton("Save GUI");
// north.add(saveButton);
// saveButton.setMinimumSize(new Dimension(10,10));
// saveButton.addActionListener(x -> GUI.save2(env));
JSplitPane px = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
// px.setResizeWeight(.8);
px.setDividerLocation(200);
// FQLSplit px = new FQLSplit(.5, JSplitPane.HORIZONTAL_SPLIT);
px.setDividerSize(4);
frame = new JFrame(/* "Viewer for " + */
s);
JSplitPane temp2 = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
temp2.setResizeWeight(1);
temp2.setDividerSize(0);
temp2.setBorder(BorderFactory.createEmptyBorder());
temp2.add(temp1);
temp2.add(north);
// px.add(temp1);
px.add(temp2);
px.add(x);
// JPanel bd = new JPanel(new BorderLayout());
// bd.add(px, BorderLayout.CENTER);
// bd.add(north, BorderLayout.NORTH);
// frame.setContentPane(bd);
frame.setContentPane(px);
frame.setSize(900, 600);
ActionListener escListener = (ActionEvent e) -> frame.dispose();
frame.getRootPane().registerKeyboardAction(escListener, KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
KeyStroke ctrlW = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.CTRL_MASK);
KeyStroke commandW = KeyStroke.getKeyStroke(KeyEvent.VK_W, InputEvent.META_MASK);
frame.getRootPane().registerKeyboardAction(escListener, ctrlW, JComponent.WHEN_IN_FOCUSED_WINDOW);
frame.getRootPane().registerKeyboardAction(escListener, commandW, JComponent.WHEN_IN_FOCUSED_WINDOW);
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
use of javax.swing.KeyStroke in project fql by CategoricalData.
the class AqlCodeEditor method doTemplates.
@Override
protected void doTemplates() {
CompletionProvider provider = createCompletionProvider();
AutoCompletion ac = new AutoCompletion(provider);
KeyStroke key = KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, InputEvent.META_DOWN_MASK | InputEvent.SHIFT_DOWN_MASK);
ac.setTriggerKey(key);
ac.install(topArea);
}
Aggregations