use of javax.swing.filechooser.FileNameExtensionFilter in project beast-mcmc by beast-dev.
the class BeautiFrame method doImport.
public final void doImport() {
File[] files = selectImportFiles("Import Aligment...", true, new FileNameExtensionFilter[] { new FileNameExtensionFilter("Microsatellite (tab-delimited *.txt) Files", "txt"), new FileNameExtensionFilter("NEXUS, BEAST or FASTA Files", "nex", "nexus", "nx", "xml", "beast", "fa", "fasta", "afa") });
// new FileNameExtensionFilter( "Microsatellite (tab-delimited *.txt) Files", "txt");
if (files != null && files.length != 0) {
importFiles(files);
tabbedPane.setSelectedComponent(dataPanel);
}
}
use of javax.swing.filechooser.FileNameExtensionFilter in project drmips by brunonova.
the class FrmSimulator method translate.
/**
* Translates the form's strings.
*/
protected final void translate() {
Lang.tButton(lbl, "file");
Lang.tButton(mnuNew, "new");
Lang.tButton(mnuOpen, "open");
Lang.tButton(mnuOpenRecent, "open_recent");
Lang.tButton(mnuOpenLastFileAtStartup, "open_last_file_at_startup");
Lang.tButton(mnuSave, "save");
Lang.tButton(mnuSaveAs, "save_as");
Lang.tButton(mnuPrint, "print");
Lang.tButton(mnuExit, "exit");
Lang.tButton(mnuEdit, "edit");
Lang.tButton(mnuUndo, "undo");
Lang.tButton(mnuRedo, "redo");
Lang.tButton(mnuCut, "cut");
Lang.tButton(mnuCopy, "copy");
Lang.tButton(mnuPaste, "paste");
Lang.tButton(mnuSelectAll, "select_all");
Lang.tButton(mnuFindReplace, "find_replace");
Lang.tButton(mnuView, "view");
Lang.tButton(mnuDatapath, "datapath");
Lang.tButton(mnuPerformanceMode, "performance_mode");
Lang.tButton(mnuControlPath, "control_path");
Lang.tButton(mnuArrowsInWires, "arrows_in_wires");
Lang.tButton(mnuOverlayed, "overlayed_data");
Lang.tButton(mnuOverlayedData, "enable");
Lang.tButton(mnuOverlayedShowNames, "show_names");
Lang.tButton(mnuOverlayedShowForAll, "show_for_all_components");
Lang.tButton(mnuInternalWindows, "internal_windows");
Lang.tButton(mnuSwitchTheme, "dark_theme");
Lang.tButton(mnuMarginLine, "show_margin_line");
Lang.tButton(mnuWindows, "windows");
Lang.tButton(mnuTileWindows, "tile");
Lang.tButton(mnuCascadeWindows, "cascade");
Lang.tButton(mnuOpenGL, "opengl_acceleration");
Lang.tButton(mnuExecute, "execute");
Lang.tButton(mnuAssemble, "assemble");
Lang.tButton(mnuRestart, "restart");
Lang.tButton(mnuBackStep, "back_step");
Lang.tButton(mnuStep, "step");
Lang.tButton(mnuRun, "run");
Lang.tButton(mnuZoomIn, "zoom_in");
Lang.tButton(mnuZoomOut, "zoom_out");
Lang.tButton(mnuZoomNormal, "normal");
Lang.tButton(mnuZoomAutoAdjust, "adjust_automatically");
Lang.tButton(mnuResetDataBeforeAssembling, "reset_data_before_assembling");
Lang.tButton(mnuCPU, "cpu");
Lang.tButton(mnuLoadCPU, "load");
Lang.tButton(mnuLoadRecentCPU, "load_recent");
Lang.tButton(mnuSupportedInstructions, "supported_instructions");
Lang.tButton(mnuRestoreLatencies, "restore_latencies");
Lang.tButton(mnuRemoveLatencies, "remove_latencies");
Lang.tButton(mnuStatistics, "statistics");
Lang.tButton(mnuLanguage, "language");
Lang.tButton(mnuHelp, "help");
Lang.tButton(mnuDocs, "documentation");
Lang.tButton(mnuAbout, "about");
Lang.tButton(mnuUndoP, "undo");
Lang.tButton(mnuRedoP, "redo");
Lang.tButton(mnuCutP, "cut");
Lang.tButton(mnuCopyP, "copy");
Lang.tButton(mnuPasteP, "paste");
Lang.tButton(mnuSelectAllP, "select_all");
Lang.tButton(mnuFindReplaceP, "find_replace");
Lang.tButton(mnuSwitchSide, "switch_side");
if (mnuInternalWindows.isSelected()) {
frmCode.setTitle(Lang.t("code"));
frmDatapath.setTitle(Lang.t("datapath"));
frmRegisters.setTitle(Lang.t("registers"));
frmAssembledCode.setTitle(Lang.t("assembled"));
frmDataMemory.setTitle(Lang.t("data_memory"));
} else {
tabCode.setTitle(Lang.t("code"));
tabDatapath.setTitle(Lang.t("datapath"));
tabRegisters.setTitle(Lang.t("registers"));
tabAssembledCode.setTitle(Lang.t("assembled"));
tabDataMemory.setTitle(Lang.t("data_memory"));
}
cpuFileChooser = new JFileChooser(DrMIPS.path + File.separator + CPU.FILENAME_PATH);
cpuFileChooser.setDialogTitle(Lang.t("load_cpu_from_file"));
cpuFileChooser.setFileFilter(new FileNameExtensionFilter(Lang.t("cpu_files"), CPU.FILENAME_EXTENSION));
codeFileChooser = new JFileChooser();
codeFileChooser.setFileFilter(codeFileFilter = new FileNameExtensionFilter(Lang.t("assembly_files"), "asm", "s"));
dlgFindReplace.translate();
dlgSupportedInstructions.translate();
dlgStatistics.translate();
cmdNew.setToolTipText(Lang.t("new"));
cmdOpen.setToolTipText(Lang.t("open"));
cmdSave.setToolTipText(Lang.t("save"));
cmdSaveAs.setToolTipText(Lang.t("save_as"));
cmdAssemble.setToolTipText(Lang.t("assemble"));
cmdRestart.setToolTipText(Lang.t("restart"));
cmdBackStep.setToolTipText(Lang.t("back_step"));
cmdStep.setToolTipText(Lang.t("step"));
cmdRun.setToolTipText(Lang.t("run"));
cmdStatistics.setToolTipText(Lang.t("statistics"));
cmdSupportedInstructions.setToolTipText(Lang.t("supported_instructions"));
cmdHelp.setToolTipText(Lang.t("documentation"));
cmdZoomIn.setToolTipText(Lang.t("zoom_in"));
cmdZoomOut.setToolTipText(Lang.t("zoom_out"));
cmdZoomNormal.setToolTipText(Lang.t("normal"));
chkZoomAutoAdjust.setToolTipText(Lang.t("adjust_automatically"));
lblZoom.setText(Lang.t("zoom", Math.round(datapath.getScale() * 100) + "%"));
updateCaretPosition();
lblRegFormat.setText(Lang.t("format") + ":");
lblDatapathDataFormat.setText(Lang.t("format") + ":");
lblDatapathPerformance.setText(Lang.t("performance") + ":");
lblAssembledCodeFormat.setText(Lang.t("format") + ":");
lblDataMemoryFormat.setText(Lang.t("format") + ":");
lblFile.setText(Lang.t("file") + ":");
initFormatComboBox(cmbRegFormat, DrMIPS.REGISTER_FORMAT_PREF, DrMIPS.DEFAULT_REGISTER_FORMAT);
initFormatComboBox(cmbDatapathDataFormat, DrMIPS.DATAPATH_DATA_FORMAT_PREF, DrMIPS.DEFAULT_DATAPATH_DATA_FORMAT);
initFormatComboBox(cmbAssembledCodeFormat, DrMIPS.ASSEMBLED_CODE_FORMAT_PREF, DrMIPS.DEFAULT_ASSEMBLED_CODE_FORMAT);
initFormatComboBox(cmbDataMemoryFormat, DrMIPS.DATA_MEMORY_FORMAT_PREF, DrMIPS.DEFAULT_DATA_MEMORY_FORMAT);
initPerformanceComboBox();
datapath.translate(cmbDatapathDataFormat.getSelectedIndex());
tblAssembledCode.translate();
tblRegisters.translate();
tblDataMemory.translate();
txtCode.translate();
refreshDatapathHelp();
repaint();
JMenuItem mnu;
for (int i = 0; i < mnuLanguage.getItemCount(); i++) {
mnu = mnuLanguage.getItem(i);
mnu.setText(Lang.getDisplayName(mnu.getToolTipText()));
}
}
use of javax.swing.filechooser.FileNameExtensionFilter in project jgnash by ccavanaugh.
the class ImportQifAction method importQif.
private static void importQif() {
final ResourceBundle rb = ResourceUtils.getBundle();
final Preferences pref = Preferences.userNodeForPackage(ImportQifAction.class);
final Logger logger = Logger.getLogger("qifimport");
if (debug) {
try {
Handler fh = new FileHandler("%h/jgnash%g.log");
fh.setFormatter(new SimpleFormatter());
logger.addHandler(fh);
logger.setLevel(Level.FINEST);
} catch (IOException ioe) {
logger.log(Level.SEVERE, "Could not install file handler", ioe);
}
}
final Engine engine = EngineFactory.getEngine(EngineFactory.DEFAULT);
Objects.requireNonNull(engine);
if (engine.getRootAccount() == null) {
StaticUIMethods.displayError(rb.getString("Message.Error.CreateBasicAccounts"));
return;
}
final JFileChooser chooser = new JFileChooser(pref.get(QIFDIR, null));
chooser.setMultiSelectionEnabled(false);
chooser.addChoosableFileFilter(new FileNameExtensionFilter("Qif Files (*.qif)", "qif"));
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
pref.put(QIFDIR, chooser.getCurrentDirectory().getAbsolutePath());
boolean fullFile = QifUtils.isFullFile(chooser.getSelectedFile());
if (fullFile) {
// prompt for date format
final DateFormat dateFormat = getQIFDateFormat();
class ImportFile extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
UIApplication.getFrame().displayWaitMessage(rb.getString("Message.ImportWait"));
QifImport imp = new QifImport();
try {
imp.doFullParse(chooser.getSelectedFile(), dateFormat);
} catch (NoAccountException e) {
logger.log(Level.SEVERE, "Mistook partial qif file as a full qif file", e);
}
imp.dumpStats();
imp.doFullImport();
if (imp.getDuplicateCount() > 0) {
String message = imp.getDuplicateCount() + " duplicate transactions were found";
logger.info(message);
}
return null;
}
@Override
protected void done() {
UIApplication.getFrame().stopWaitMessage();
}
}
new ImportFile().execute();
} else {
final QifImport imp = new QifImport();
if (!imp.doPartialParse(chooser.getSelectedFile())) {
StaticUIMethods.displayError(rb.getString("Message.Error.ParseTransactions"));
return;
}
imp.dumpStats();
if (imp.getParser().accountList.isEmpty()) {
StaticUIMethods.displayError(rb.getString("Message.Error.ParseTransactions"));
return;
}
PartialDialog dlg = new PartialDialog(imp.getParser());
DialogUtils.addBoundsListener(dlg);
dlg.setVisible(true);
if (dlg.isWizardValid()) {
imp.doPartialImport(dlg.getAccount());
if (imp.getDuplicateCount() > 0) {
if (YesNoDialog.showYesNoDialog(UIApplication.getFrame(), new MultiLineLabel(TextResource.getString("DupeTransImport.txt")), rb.getString("Title.DuplicateTransactionsFound"), YesNoDialog.WARNING_MESSAGE)) {
Transaction[] t = imp.getDuplicates();
for (Transaction element : t) {
engine.addTransaction(element);
}
}
}
}
}
}
}
use of javax.swing.filechooser.FileNameExtensionFilter in project jgnash by ccavanaugh.
the class ExportAccountsAction method exportAccounts.
private static void exportAccounts() {
final ResourceBundle rb = ResourceUtils.getBundle();
final Preferences pref = Preferences.userNodeForPackage(ExportAccountsAction.class);
JFileChooser chooser = new JFileChooser(pref.get(CURRENT_DIR, null));
chooser.addChoosableFileFilter(new FileNameExtensionFilter(rb.getString("Label.XMLFiles") + " (*.xml)", "xml"));
chooser.setMultiSelectionEnabled(false);
if (chooser.showSaveDialog(UIApplication.getFrame()) == JFileChooser.APPROVE_OPTION) {
pref.put(CURRENT_DIR, chooser.getCurrentDirectory().getAbsolutePath());
// strip the file extension if added and ensure it ends with XML
final Path file = Paths.get(FileUtils.stripFileExtension(chooser.getSelectedFile().getAbsolutePath()) + ".xml");
final class Export extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
UIApplication.getFrame().displayWaitMessage(rb.getString("Message.PleaseWait"));
AccountTreeXMLFactory.exportAccountTree(EngineFactory.getEngine(EngineFactory.DEFAULT), file);
return null;
}
@Override
protected void done() {
UIApplication.getFrame().stopWaitMessage();
}
}
new Export().execute();
}
}
use of javax.swing.filechooser.FileNameExtensionFilter in project jgnash by ccavanaugh.
the class ImportAccountsAction method importAccounts.
private static void importAccounts() {
final Preferences pref = Preferences.userNodeForPackage(ImportAccountsAction.class);
final JFileChooser chooser = new JFileChooser(pref.get(ACCOUNTS_IMPORT_DIR, null));
chooser.addChoosableFileFilter(new FileNameExtensionFilter(ResourceUtils.getString("Label.XMLFiles") + " (*.xml)", "xml"));
chooser.setMultiSelectionEnabled(false);
if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) {
final File file = chooser.getSelectedFile();
pref.put(ACCOUNTS_IMPORT_DIR, chooser.getCurrentDirectory().getAbsolutePath());
final class Import extends SwingWorker<Void, Void> {
@Override
protected Void doInBackground() throws Exception {
UIApplication.getFrame().displayWaitMessage(ResourceUtils.getString("Message.ImportWait"));
RootAccount root = AccountTreeXMLFactory.loadAccountTree(file.toPath());
if (root != null) {
AccountTreeXMLFactory.mergeAccountTree(EngineFactory.getEngine(EngineFactory.DEFAULT), root);
}
return null;
}
@Override
protected void done() {
UIApplication.getFrame().stopWaitMessage();
// Close and reopen, otherwise UI may link to some stale currency information
EngineFactory.closeEngine(EngineFactory.DEFAULT);
OpenAction.openLastAction();
}
}
new Import().execute();
}
}
Aggregations