use of jmri.jmrit.symbolicprog.FactoryResetAction in project JMRI by JMRI.
the class PaneProgFrame method installComponents.
protected void installComponents() {
// create ShutDownTasks
if (jmri.InstanceManager.getNullableDefault(jmri.ShutDownManager.class) != null) {
if (decoderDirtyTask == null) {
decoderDirtyTask = new SwingShutDownTask("DecoderPro Decoder Window Check", Bundle.getMessage("PromptQuitWindowNotWrittenDecoder"), (String) null, this) {
@Override
public boolean checkPromptNeeded() {
return !checkDirtyDecoder();
}
};
}
jmri.InstanceManager.getDefault(jmri.ShutDownManager.class).register(decoderDirtyTask);
if (fileDirtyTask == null) {
fileDirtyTask = new SwingShutDownTask("DecoderPro Decoder Window Check", Bundle.getMessage("PromptQuitWindowNotWrittenConfig"), Bundle.getMessage("PromptSaveQuit"), this) {
@Override
public boolean checkPromptNeeded() {
return !checkDirtyFile();
}
@Override
public boolean doPrompt() {
// storeFile false if failed, abort shutdown
boolean result = storeFile();
return result;
}
};
}
jmri.InstanceManager.getDefault(jmri.ShutDownManager.class).register(fileDirtyTask);
}
// Create a menu bar
JMenuBar menuBar = new JMenuBar();
setJMenuBar(menuBar);
// add a "File" menu
JMenu fileMenu = new JMenu(Bundle.getMessage("MenuFile"));
menuBar.add(fileMenu);
// add a "Factory Reset" menu
resetMenu = new JMenu(Bundle.getMessage("MenuReset"));
menuBar.add(resetMenu);
resetMenu.add(new FactoryResetAction(Bundle.getMessage("MenuFactoryReset"), resetModel, this));
resetMenu.setEnabled(false);
// Add a save item
fileMenu.add(new AbstractAction(Bundle.getMessage("MenuSave")) {
@Override
public void actionPerformed(ActionEvent e) {
storeFile();
}
});
JMenu printSubMenu = new JMenu(Bundle.getMessage("MenuPrint"));
printSubMenu.add(new PrintAction(Bundle.getMessage("MenuPrintAll"), this, false));
printSubMenu.add(new PrintCvAction(Bundle.getMessage("MenuPrintCVs"), cvModel, this, false, _rosterEntry));
fileMenu.add(printSubMenu);
JMenu printPreviewSubMenu = new JMenu(Bundle.getMessage("MenuPrintPreview"));
printPreviewSubMenu.add(new PrintAction(Bundle.getMessage("MenuPrintPreviewAll"), this, true));
printPreviewSubMenu.add(new PrintCvAction(Bundle.getMessage("MenuPrintPreviewCVs"), cvModel, this, true, _rosterEntry));
fileMenu.add(printPreviewSubMenu);
// add "Import" submenu; this is heirarchical because
// some of the names are so long, and we expect more formats
JMenu importSubMenu = new JMenu(Bundle.getMessage("MenuImport"));
fileMenu.add(importSubMenu);
importSubMenu.add(new CsvImportAction(Bundle.getMessage("MenuImportCSV"), cvModel, this, progStatus));
importSubMenu.add(new Pr1ImportAction(Bundle.getMessage("MenuImportPr1"), cvModel, this, progStatus));
importSubMenu.add(new LokProgImportAction(Bundle.getMessage("MenuImportLokProg"), cvModel, this, progStatus));
importSubMenu.add(new QuantumCvMgrImportAction(Bundle.getMessage("MenuImportQuantumCvMgr"), cvModel, this, progStatus));
// add "Export" submenu; this is heirarchical because
// some of the names are so long, and we expect more formats
JMenu exportSubMenu = new JMenu(Bundle.getMessage("MenuExport"));
fileMenu.add(exportSubMenu);
exportSubMenu.add(new CsvExportAction(Bundle.getMessage("MenuExportCSV"), cvModel, this));
exportSubMenu.add(new Pr1ExportAction(Bundle.getMessage("MenuExportPr1DOS"), cvModel, this));
exportSubMenu.add(new Pr1WinExportAction(Bundle.getMessage("MenuExportPr1WIN"), cvModel, this));
// to control size, we need to insert a single
// JPanel, then have it laid out with BoxLayout
JPanel pane = new JPanel();
tempPane = pane;
// general GUI config
pane.setLayout(new BorderLayout());
// configure GUI elements
// set read buttons enabled state, tooltips
enableReadButtons();
readChangesButton.addItemListener(l1 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(readChangesButton);
readChangesButton.setText(Bundle.getMessage("ButtonStopReadChangesAll"));
readChanges();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
readChangesButton.setText(Bundle.getMessage("ButtonReadChangesAllSheets"));
}
}
});
readAllButton.addItemListener(l3 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(readAllButton);
readAllButton.setText(Bundle.getMessage("ButtonStopReadAll"));
readAll();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
readAllButton.setText(Bundle.getMessage("ButtonReadAllSheets"));
}
}
});
writeChangesButton.setToolTipText(Bundle.getMessage("TipWriteHighlightedValues"));
writeChangesButton.addItemListener(l2 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(writeChangesButton);
writeChangesButton.setText(Bundle.getMessage("ButtonStopWriteChangesAll"));
writeChanges();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
writeChangesButton.setText(Bundle.getMessage("ButtonWriteChangesAllSheets"));
}
}
});
writeAllButton.setToolTipText(Bundle.getMessage("TipWriteAllValues"));
writeAllButton.addItemListener(l4 = new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (e.getStateChange() == ItemEvent.SELECTED) {
prepGlassPane(writeAllButton);
writeAllButton.setText(Bundle.getMessage("ButtonStopWriteAll"));
writeAll();
} else {
if (_programmingPane != null) {
_programmingPane.stopProgramming();
}
paneListIndex = paneList.size();
writeAllButton.setText(Bundle.getMessage("ButtonWriteAllSheets"));
}
}
});
// most of the GUI is done from XML in readConfig() function
// which configures the tabPane
pane.add(tabPane, BorderLayout.CENTER);
// and put that pane into the JFrame
getContentPane().add(pane);
// add help
addHelp();
}
Aggregations