use of de.neemann.digital.gui.components.tree.LibraryTreeModel in project Digital by hneemann.
the class Main method createViewMenu.
private void createViewMenu(JMenuBar menuBar, JToolBar toolBar) {
ToolTipAction maximize = new ToolTipAction(Lang.get("menu_maximize"), ICON_EXPAND) {
@Override
public void actionPerformed(ActionEvent e) {
circuitComponent.fitCircuit();
}
}.setAccelerator("F1");
ToolTipAction zoomIn = new ToolTipAction(Lang.get("menu_zoomIn"), ICON_ZOOM_IN) {
@Override
public void actionPerformed(ActionEvent e) {
circuitComponent.scaleCircuit(1 / 0.9);
}
}.setAccelerator("control PLUS");
// enable [+] which is SHIFT+[=] on english keyboard layout
circuitComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_EQUALS, KeyEvent.CTRL_DOWN_MASK, false), zoomIn);
circuitComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ADD, KeyEvent.CTRL_DOWN_MASK, false), zoomIn);
circuitComponent.getActionMap().put(zoomIn, zoomIn);
ToolTipAction zoomOut = new ToolTipAction(Lang.get("menu_zoomOut"), ICON_ZOOM_OUT) {
@Override
public void actionPerformed(ActionEvent e) {
circuitComponent.scaleCircuit(0.9);
}
}.setAccelerator("control MINUS");
// enable [+] which is SHIFT+[=] on english keyboard layout
circuitComponent.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_SUBTRACT, KeyEvent.CTRL_DOWN_MASK, false), zoomOut);
circuitComponent.getActionMap().put(zoomOut, zoomOut);
ToolTipAction viewHelp = new ToolTipAction(Lang.get("menu_viewHelp"), ICON_HELP) {
@Override
public void actionPerformed(ActionEvent e) {
final Circuit circuit = circuitComponent.getCircuit();
final String name = Lang.get("msg_actualCircuit");
File file = filename;
if (file == null)
file = new File(name);
try {
ElementLibrary.ElementTypeDescriptionCustom description = new ElementLibrary.ElementTypeDescriptionCustom(file, attributes -> new CustomElement(circuit, library), circuit);
description.setShortName(name);
description.setDescription(circuit.getAttributes().get(Keys.DESCRIPTION));
new ElementHelpDialog(Main.this, description, circuit.getAttributes()).setVisible(true);
} catch (PinException | NodeException e1) {
new ErrorMessage(Lang.get("msg_creatingHelp")).addCause(e1).show(Main.this);
}
}
}.setToolTip(Lang.get("menu_viewHelp_tt"));
JCheckBoxMenuItem treeCheckBox = new JCheckBoxMenuItem(Lang.get("menu_treeSelect"));
treeCheckBox.setToolTipText(Lang.get("menu_treeSelect_tt"));
treeCheckBox.addActionListener(actionEvent -> {
getContentPane().remove(componentOnPane);
if (treeCheckBox.isSelected()) {
JSplitPane split = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
treeModel = new LibraryTreeModel(library);
split.setLeftComponent(new JScrollPane(new SelectTree(treeModel, circuitComponent, shapeFactory, insertHistory)));
split.setRightComponent(circuitComponent);
getContentPane().add(split);
componentOnPane = split;
} else {
if (treeModel != null) {
library.removeListener(treeModel);
treeModel = null;
}
getContentPane().add(circuitComponent);
componentOnPane = circuitComponent;
}
revalidate();
});
treeCheckBox.setAccelerator(KeyStroke.getKeyStroke("F5"));
if (Settings.getInstance().get(Keys.SETTINGS_DEFAULT_TREESELECT))
SwingUtilities.invokeLater(treeCheckBox::doClick);
toolBar.add(viewHelp.createJButtonNoText());
toolBar.add(zoomIn.createJButtonNoText());
toolBar.add(zoomOut.createJButtonNoText());
toolBar.add(maximize.createJButtonNoText());
JMenu view = new JMenu(Lang.get("menu_view"));
menuBar.add(view);
view.add(maximize.createJMenuItem());
view.add(zoomOut.createJMenuItem());
view.add(zoomIn.createJMenuItem());
view.addSeparator();
view.add(treeCheckBox);
view.addSeparator();
view.add(viewHelp.createJMenuItem());
}
Aggregations