List of usage examples for weka.gui ConverterFileChooser showOpenDialog
@Override public int showOpenDialog(Component parent)
From source file:meka.gui.explorer.classify.OpenTestData.java
License:Open Source License
/** * Returns the action lister to use in the menu. * * @return the listener//w w w .j a va 2 s .co m */ public ActionListener getActionListener(final ClassifyTab owner) { return new ActionListener() { @Override public void actionPerformed(ActionEvent e) { ConverterFileChooser filechooser; if (!hasSessionValue(owner, SESSION_KEY_FILECHOOSER)) { filechooser = GUIHelper.newConverterFileChooser(); ExtensionFileFilter filter = new ExtensionFileFilter(".model", "Model files (*.model)"); filechooser.addChoosableFileFilter(filter); filechooser.setFileFilter(filter); filechooser.setAcceptAllFileFilterUsed(true); setSessionValue(owner, SESSION_KEY_FILECHOOSER, filechooser); } else { filechooser = (ConverterFileChooser) getSessionValue(owner, SESSION_KEY_FILECHOOSER); } if (filechooser.showOpenDialog(owner) != ConverterFileChooser.APPROVE_OPTION) return; AbstractFileLoader loader = filechooser.getLoader(); try { Instances data = loader.getDataSet(); if (data != null) owner.setTestData(data); } catch (Exception ex) { String msg = "Failed to load file: " + filechooser.getSelectedFile(); System.err.println(msg); ex.printStackTrace(); JOptionPane.showMessageDialog(owner, msg + "\n" + ex, "Error", JOptionPane.ERROR_MESSAGE); } } }; }