/** * Lets the user add a dataset. */ protected void addDataset() { int retVal; retVal = m_FileChooserDatasets.showOpenDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; m_ModelDatasets.addElement(m_FileChooserDatasets.getSelectedFile().getAbsolutePath()); m_Modified = true; updateButtons(); }
/** * Lets the user add a dataset. */ protected void addDataset() { int retVal; retVal = m_FileChooserDatasets.showOpenDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; m_ModelDatasets.addElement(m_FileChooserDatasets.getSelectedFile().getAbsolutePath()); m_Modified = true; updateButtons(); }
@Override public void actionPerformed(ActionEvent ae) { ConverterFileChooser fc = new ConverterFileChooser(System .getProperty("user.dir")); fc.setDialogTitle("Save Instances As"); int rval = fc.showSaveDialog(GUI.this); if (rval == JFileChooser.APPROVE_OPTION) { String filename = fc.getSelectedFile().toString(); jTfFile.setText(filename); } dlg.setVisible(true); } });
/** * Queries the user for a file to load instances from, then loads the * instances in a background process. This is done in the IO thread, and an * error message is popped up if the IO thread is busy. */ public void setInstancesFromFileQ() { if (m_IOThread == null) { int returnVal = m_FileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selected = m_FileChooser.getSelectedFile(); m_IOThread = new Thread() { @Override public void run() { setInstancesFromFile(selected); m_IOThread = null; } }; m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority m_IOThread.start(); } } else { JOptionPane.showMessageDialog(this, "Can't load at this time,\n" + "currently busy with other IO", "Load Instances", JOptionPane.WARNING_MESSAGE); } }
/** * Queries the user for a file to load instances from, then loads the * instances in a background process. This is done in the IO thread, and an * error message is popped up if the IO thread is busy. */ public void setInstancesFromFileQ() { if (m_IOThread == null) { int returnVal = m_FileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { final File selected = m_FileChooser.getSelectedFile(); m_IOThread = new Thread() { @Override public void run() { setInstancesFromFile(selected); m_IOThread = null; } }; m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority m_IOThread.start(); } } else { JOptionPane.showMessageDialog(this, "Can't load at this time,\n" + "currently busy with other IO", "Load Instances", JOptionPane.WARNING_MESSAGE); } }
@Override public void actionPerformed(ActionEvent ae) { ConverterFileChooser fc = new ConverterFileChooser(System .getProperty("user.dir")); fc.setDialogTitle("Save Instances As"); int rval = fc.showSaveDialog(GUI.this); if (rval == JFileChooser.APPROVE_OPTION) { String filename = fc.getSelectedFile().toString(); jTfFile.setText(filename); } dlg.setVisible(true); } });
File currFile; if ((getSelectedFile() == null) || (getSelectedFile().isDirectory())) { return; filename = getSelectedFile().getAbsolutePath();
File currFile; if ((getSelectedFile() == null) || (getSelectedFile().isDirectory())) { return; filename = getSelectedFile().getAbsolutePath();
/** * Opens a dataset. */ public void open() { int retVal; retVal = m_FileChooser.showOpenDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; open(m_FileChooser.getSelectedFile(), m_FileChooser.getLoader()); }
/** * Opens a dataset. */ public void open() { int retVal; retVal = m_FileChooser.showOpenDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; open(m_FileChooser.getSelectedFile(), m_FileChooser.getLoader()); }
/** * Opens a dataset. */ public void open() { int retVal; retVal = m_FileChooser.showOpenDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; open(m_FileChooser.getSelectedFile(), m_FileChooser.getLoader()); }
/** * Saves the current dataset under a new name. */ public void saveAs() { int retVal; m_FileChooser.setSelectedFile(m_CurrentFile); retVal = m_FileChooser.showSaveDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; save(m_FileChooser.getSelectedFile(), m_FileChooser.getSaver()); }
/** * Saves the current dataset under a new name. */ public void saveAs() { int retVal; m_FileChooser.setSelectedFile(m_CurrentFile); retVal = m_FileChooser.showSaveDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; save(m_FileChooser.getSelectedFile(), m_FileChooser.getSaver()); }
/** * Saves the current dataset under a new name. */ public void saveAs() { int retVal; m_FileChooser.setSelectedFile(m_CurrentFile); retVal = m_FileChooser.showSaveDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; save(m_FileChooser.getSelectedFile(), m_FileChooser.getSaver()); }
/** * Queries the user for a file to load instances from, then loads the * instances in a background process. This is done in the IO thread, and an * error message is popped up if the IO thread is busy. */ public void setInstancesFromFileQ() { if (m_IOThread == null) { int returnVal = m_FileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { addUndoPoint(); } catch (Exception ignored) { // ignored } if (m_FileChooser.getLoader() == null) { JOptionPane.showMessageDialog(this, "Cannot determine file loader automatically, please choose one.", "Load Instances", JOptionPane.ERROR_MESSAGE); converterQuery(m_FileChooser.getSelectedFile()); } else { setInstancesFromFile(m_FileChooser.getLoader()); } } } else { JOptionPane.showMessageDialog(this, "Can't load at this time,\n" + "currently busy with other IO", "Load Instances", JOptionPane.WARNING_MESSAGE); } }
/** * Queries the user for a file to load instances from, then loads the * instances in a background process. This is done in the IO thread, and an * error message is popped up if the IO thread is busy. */ public void setInstancesFromFileQ() { if (m_IOThread == null) { int returnVal = m_FileChooser.showOpenDialog(this); if (returnVal == JFileChooser.APPROVE_OPTION) { try { addUndoPoint(); } catch (Exception ignored) { // ignored } if (m_FileChooser.getLoader() == null) { JOptionPane.showMessageDialog(this, "Cannot determine file loader automatically, please choose one.", "Load Instances", JOptionPane.ERROR_MESSAGE); converterQuery(m_FileChooser.getSelectedFile()); } else { setInstancesFromFile(m_FileChooser.getLoader()); } } } else { JOptionPane.showMessageDialog(this, "Can't load at this time,\n" + "currently busy with other IO", "Load Instances", JOptionPane.WARNING_MESSAGE); } }
/** * Exports the data to a file. */ protected void export() { int retVal; File file; AbstractFileSaver saver; if (m_FileChooser == null) m_FileChooser = GUIHelper.newConverterFileChooser(); retVal = m_FileChooser.showSaveDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; file = m_FileChooser.getSelectedFile(); saver = m_FileChooser.getSaver(); try { saver.setInstances(m_DataPanel.getInstances()); saver.writeBatch(); } catch (Exception e) { JOptionPane.showMessageDialog( this, "Failed to save dataset to '" + file + "':\n" + Utils.throwableToString(e), "Error saving", JOptionPane.ERROR_MESSAGE); } // TODO }
/** * Exports the data to a file. */ protected void export() { int retVal; File file; AbstractFileSaver saver; if (m_FileChooser == null) m_FileChooser = GUIHelper.newConverterFileChooser(); retVal = m_FileChooser.showSaveDialog(this); if (retVal != ConverterFileChooser.APPROVE_OPTION) return; file = m_FileChooser.getSelectedFile(); saver = m_FileChooser.getSaver(); try { saver.setInstances(m_DataPanel.getInstances()); saver.writeBatch(); } catch (Exception e) { JOptionPane.showMessageDialog( this, "Failed to save dataset to '" + file + "':\n" + Utils.throwableToString(e), "Error saving", JOptionPane.ERROR_MESSAGE); } // TODO }
String msg = "Failed to load file: " + filechooser.getSelectedFile(); System.err.println(msg); ex.printStackTrace();
String msg = "Failed to load file: " + filechooser.getSelectedFile(); System.err.println(msg); ex.printStackTrace();