use of de.neemann.gui.ToolTipAction in project Digital by hneemann.
the class LibrarySelector method libraryChanged.
@Override
public void libraryChanged(LibraryNode node) {
componentsMenu.removeAll();
for (LibraryNode n : library.getRoot()) addComponents(componentsMenu, n);
if (library.getCustomNode() != null) {
JMenuItem m = componentsMenu.getItem(componentsMenu.getItemCount() - 1);
if (m instanceof JMenu) {
JMenu menu = (JMenu) m;
menu.addSeparator();
menu.add(new ToolTipAction(Lang.get("menu_update")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
library.updateEntries();
} catch (IOException ex) {
SwingUtilities.invokeLater(new ErrorMessage(Lang.get("msg_errorUpdatingLibrary")).addCause(ex));
}
}
}.setToolTip(Lang.get("menu_update_tt")).createJMenuItem());
}
}
}
use of de.neemann.gui.ToolTipAction in project Digital by hneemann.
the class TableDialog method createFileMenu.
private JMenu createFileMenu() {
JMenu fileMenu = new JMenu(Lang.get("menu_file"));
fileMenu.add(new ToolTipAction(Lang.get("menu_open")) {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new MyFileChooser();
if (TableDialog.this.filename != null)
fc.setSelectedFile(SaveAsHelper.checkSuffix(TableDialog.this.filename, "tru"));
if (fc.showOpenDialog(TableDialog.this) == JFileChooser.APPROVE_OPTION) {
try {
File file = fc.getSelectedFile();
TruthTable truthTable = TruthTable.readFromFile(file);
setModel(new TruthTableTableModel(truthTable));
TableDialog.this.filename = file;
} catch (IOException e1) {
new ErrorMessage().addCause(e1).show(TableDialog.this);
}
}
}
});
fileMenu.add(new ToolTipAction(Lang.get("menu_save")) {
@Override
public void actionPerformed(ActionEvent e) {
JFileChooser fc = new MyFileChooser();
if (TableDialog.this.filename != null)
fc.setSelectedFile(SaveAsHelper.checkSuffix(TableDialog.this.filename, "tru"));
new SaveAsHelper(TableDialog.this, fc, "tru").checkOverwrite(file -> {
model.getTable().save(file);
TableDialog.this.filename = file;
});
}
});
fileMenu.add(new ToolTipAction(Lang.get("menu_table_exportTableLaTeX")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
ExpressionListener expressionListener = new LaTeXExpressionListener(model);
if (createJK.isSelected())
expressionListener = new ExpressionListenerJK(expressionListener);
lastGeneratedExpressions.replayTo(expressionListener);
} catch (ExpressionException | FormatterException e1) {
new ErrorMessage(Lang.get("msg_errorDuringCalculation")).addCause(e1).show(TableDialog.this);
}
}
});
fileMenu.add(new ToolTipAction(Lang.get("menu_table_exportHex")) {
@Override
public void actionPerformed(ActionEvent e) {
int res = JOptionPane.OK_OPTION;
if (model.getTable().getVars().size() > 20)
res = JOptionPane.showConfirmDialog(TableDialog.this, Lang.get("msg_tableHasManyRowsConfirm"));
if (res == JOptionPane.OK_OPTION) {
JFileChooser fc = new MyFileChooser();
if (TableDialog.this.filename != null)
fc.setSelectedFile(SaveAsHelper.checkSuffix(TableDialog.this.filename, "hex"));
new SaveAsHelper(TableDialog.this, fc, "hex").checkOverwrite(file -> model.getTable().saveHex(file));
}
}
}.setToolTip(Lang.get("menu_table_exportHex_tt")).createJMenuItem());
createJK = new JCheckBoxMenuItem(Lang.get("menu_table_JK"));
createJK.addActionListener(e -> calculateExpressions());
fileMenu.add(createJK);
return fileMenu;
}
use of de.neemann.gui.ToolTipAction in project Digital by hneemann.
the class TableDialog method createCreateMenu.
private JMenu createCreateMenu() {
JMenu createMenu = new JMenu(Lang.get("menu_table_create"));
createMenu.add(new ToolTipAction(Lang.get("menu_table_createCircuit")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(ExpressionModifier.IDENTITY);
}
}.setToolTip(Lang.get("menu_table_createCircuit_tt")).setAccelerator("F2").enableAcceleratorIn(table).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createCircuitJK")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(true, ExpressionModifier.IDENTITY);
}
}.setToolTip(Lang.get("menu_table_createCircuitJK_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs());
}
}.setToolTip(Lang.get("menu_table_createTwo_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNAnd")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new NAnd());
}
}.setToolTip(Lang.get("menu_table_createNAnd_tt")).createJMenuItem());
if (Main.isExperimentalMode()) {
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNAndTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs(), new NAnd());
}
}.setToolTip(Lang.get("menu_table_createNAndTwo_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNOr")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new NOr());
}
}.setToolTip(Lang.get("menu_table_createNOr_tt")).createJMenuItem());
createMenu.add(new ToolTipAction(Lang.get("menu_table_createNOrTwo")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {
createCircuit(new TwoInputs(), new NOr());
}
}.setToolTip(Lang.get("menu_table_createNOrTwo_tt")).createJMenuItem());
}
JMenu hardware = new JMenu(Lang.get("menu_table_create_hardware"));
register(hardware, new GenerateCUPL(CuplExporter::new, "GAL16v8/CUPL"));
register(hardware, new GenerateFile("jed", () -> new ExpressionToFileExporter(new Gal16v8JEDECExporter()), "GAL16v8/JEDEC", Lang.get("menu_table_create_jedec_tt")));
register(hardware, new GenerateCUPL(Gal22v10CuplExporter::new, "GAL22v10/CUPL"));
register(hardware, new GenerateFile("jed", () -> new ExpressionToFileExporter(new Gal22v10JEDECExporter()), "GAL22v10/JEDEC", Lang.get("menu_table_create_jedec_tt")));
for (ATFDevice atfDev : ATFDevice.values()) {
register(hardware, new GenerateCUPL(atfDev::getCuplExporter, "ATF150x/" + atfDev.getMenuName() + "/CUPL"));
register(hardware, new GenerateFile("tt2", () -> atfDev.createExpressionToFileExporter(TableDialog.this, getProjectName()), "ATF150x/" + atfDev.getMenuName() + "/TT2, JEDEC", Lang.get("menu_table_createTT2_tt")));
}
createMenu.add(hardware);
return createMenu;
}
use of de.neemann.gui.ToolTipAction in project Digital by hneemann.
the class TableDialog method createSetMenu.
private JMenu createSetMenu() {
JMenu setMenu = new JMenu(Lang.get("menu_table_set"));
setMenu.add(new ToolTipAction(Lang.get("menu_table_setXTo0")) {
@Override
public void actionPerformed(ActionEvent e) {
TruthTable t = model.getTable();
t.setXto(false);
setModel(new TruthTableTableModel(t));
}
}.setToolTip(Lang.get("menu_table_setXTo0_tt")).createJMenuItem());
setMenu.add(new ToolTipAction(Lang.get("menu_table_setXTo1")) {
@Override
public void actionPerformed(ActionEvent e) {
TruthTable t = model.getTable();
t.setXto(true);
setModel(new TruthTableTableModel(t));
}
}.setToolTip(Lang.get("menu_table_setXTo1_tt")).createJMenuItem());
setMenu.add(new ToolTipAction(Lang.get("menu_table_setAllToX")) {
@Override
public void actionPerformed(ActionEvent e) {
setAllValuesTo(2);
}
}.setToolTip(Lang.get("menu_table_setAllToX_tt")).createJMenuItem());
setMenu.add(new ToolTipAction(Lang.get("menu_table_setAllTo0")) {
@Override
public void actionPerformed(ActionEvent e) {
setAllValuesTo(0);
}
}.setToolTip(Lang.get("menu_table_setAllTo0_tt")).createJMenuItem());
setMenu.add(new ToolTipAction(Lang.get("menu_table_setAllTo1")) {
@Override
public void actionPerformed(ActionEvent e) {
setAllValuesTo(1);
}
}.setToolTip(Lang.get("menu_table_setAllTo1_tt")).createJMenuItem());
return setMenu;
}
use of de.neemann.gui.ToolTipAction in project Digital by hneemann.
the class TestCaseDescriptionEditor method getComponent.
@Override
protected JComponent getComponent(ElementAttributes elementAttributes) {
JPanel panel = new JPanel(new FlowLayout());
panel.add(new ToolTipAction(Lang.get("btn_edit")) {
@Override
public void actionPerformed(ActionEvent e) {
new TestCaseDescriptionDialog(SwingUtilities.getWindowAncestor(panel), data, null).setVisible(true);
}
}.createJButton());
panel.add(new ToolTipAction(Lang.get("btn_editDetached")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
getAttributeDialog().fireOk();
VisualElement visualElement = TestCaseDescriptionEditor.this.getAttributeDialog().getVisualElement();
Main main = getAttributeDialog().getMain();
if (main != null) {
TestCaseDescriptionDialog dialog = new TestCaseDescriptionDialog(main, data, visualElement);
main.getWindowPosManager().register("testdata", dialog);
dialog.setVisible(true);
}
} catch (EditorParseException e1) {
e1.printStackTrace();
}
}
}.setToolTip(Lang.get("btn_editDetached_tt")).createJButton());
return panel;
}
Aggregations