List of usage examples for weka.gui ConverterFileChooser getLoader
public AbstractFileLoader getLoader()
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/*ww w . j av a 2 s. c o 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); } } }; }