Java 类weka.core.converters.AbstractFileLoader 实例源码

项目:repo.kmeanspp.silhouette_score    文件:GUI.java   
@Override
public void actionPerformed(ActionEvent ae) {
  ConverterFileChooser fc = new ConverterFileChooser(
    System.getProperty("user.dir"));
  fc.setDialogTitle("Set Data File");
  int rval = fc.showOpenDialog(GUI.this);

  if (rval == JFileChooser.APPROVE_OPTION) {
    AbstractFileLoader loader = fc.getLoader();
    try {
      if (loader != null) {
        m_Instances = loader.getDataSet();
      }
      if (m_Instances.classIndex() == -1) {
        m_Instances.setClassIndex(m_Instances.numAttributes() - 1);
      }
      a_learn.setEnabled(true);
      a_learnCPT.setEnabled(true);
      repaint();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ArffTableModel.java   
/**
 * loads the specified ARFF file
 * 
 * @param filename the file to load
 * @param loaders optional varargs for a loader to use
 */
protected void loadFile(String filename, AbstractFileLoader... loaders) {
  AbstractFileLoader loader;

  if (loaders == null || loaders.length == 0) {
    loader = ConverterUtils.getLoaderForFile(filename);
  } else {
    loader = loaders[0];
  }

  if (loader != null) {
    try {
      loader.setFile(new File(filename));
      setInstances(loader.getDataSet());
    } catch (Exception e) {
      ComponentHelper
        .showMessageBox(null, "Error loading file...", e.toString(),
          JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
      System.out.println(e);
      setInstances(null);
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ArffPanel.java   
/**
 * loads the specified file into the table
 * 
 * @param filename the file to load
 * @param loaders optional varargs loader to use
 */
private void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffSortedTableModel model;

  this.m_Filename = filename;

  createTitle();

  if (filename.equals("")) {
    model = null;
  } else {
    model = new ArffSortedTableModel(filename, loaders);
    model.setShowAttributeIndex(getShowAttributeIndex());
  }

  m_TableArff.setModel(model);
  setChanged(false);
  createName();
}
项目:autoweka    文件:GUI.java   
public void actionPerformed(ActionEvent ae) {
    ConverterFileChooser fc = new ConverterFileChooser(System.getProperty("user.dir"));
    fc.setDialogTitle("Set Data File");
    int rval = fc.showOpenDialog(GUI.this);

    if (rval == JFileChooser.APPROVE_OPTION) {
        AbstractFileLoader loader = fc.getLoader();
        try {
            if (loader != null)
              m_Instances = loader.getDataSet();
            if (m_Instances.classIndex() == -1)
              m_Instances.setClassIndex(m_Instances.numAttributes() - 1);
            a_learn.setEnabled(true);
            a_learnCPT.setEnabled(true);
            repaint();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:autoweka    文件:ArffPanel.java   
/**
 * loads the specified file into the table
 * 
 * @param filename      the file to load
 * @param loaders optional varargs loader to use
 */
private void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffSortedTableModel         model;

  this.m_Filename = filename;

  createTitle();

  if (filename.equals("")) {
    model = null;
  }
  else {
    model = new ArffSortedTableModel(filename, loaders);
    model.setShowAttributeIndex(getShowAttributeIndex());
  }

  m_TableArff.setModel(model);
  setChanged(false);
  createName();
}
项目:umple    文件:GUI.java   
@Override
public void actionPerformed(ActionEvent ae) {
  ConverterFileChooser fc = new ConverterFileChooser(
    System.getProperty("user.dir"));
  fc.setDialogTitle("Set Data File");
  int rval = fc.showOpenDialog(GUI.this);

  if (rval == JFileChooser.APPROVE_OPTION) {
    AbstractFileLoader loader = fc.getLoader();
    try {
      if (loader != null) {
        m_Instances = loader.getDataSet();
      }
      if (m_Instances.classIndex() == -1) {
        m_Instances.setClassIndex(m_Instances.numAttributes() - 1);
      }
      a_learn.setEnabled(true);
      a_learnCPT.setEnabled(true);
      repaint();
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
}
项目:umple    文件:ArffTableModel.java   
/**
 * loads the specified ARFF file
 * 
 * @param filename the file to load
 * @param loaders optional varargs for a loader to use
 */
protected void loadFile(String filename, AbstractFileLoader... loaders) {
  AbstractFileLoader loader;

  if (loaders == null || loaders.length == 0) {
    loader = ConverterUtils.getLoaderForFile(filename);
  } else {
    loader = loaders[0];
  }

  if (loader != null) {
    try {
      loader.setFile(new File(filename));
      setInstances(loader.getDataSet());
    } catch (Exception e) {
      ComponentHelper
        .showMessageBox(null, "Error loading file...", e.toString(),
          JOptionPane.OK_CANCEL_OPTION, JOptionPane.ERROR_MESSAGE);
      System.out.println(e);
      setInstances(null);
    }
  }
}
项目:umple    文件:ArffPanel.java   
/**
 * loads the specified file into the table
 * 
 * @param filename the file to load
 * @param loaders optional varargs loader to use
 */
private void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffSortedTableModel model;

  this.m_Filename = filename;

  createTitle();

  if (filename.equals("")) {
    model = null;
  } else {
    model = new ArffSortedTableModel(filename, loaders);
    model.setShowAttributeIndex(getShowAttributeIndex());
  }

  m_TableArff.setModel(model);
  setChanged(false);
  createName();
}
项目:meka    文件:MekaExperiment.java   
/**
 * Carries out the next iteration of the experiment.
 * 
 * @throws Exception if an error occurs
 */
@Override
public void nextIteration() throws Exception {

    if (m_UsePropertyIterator) {
        if (m_CurrentProperty != m_PropertyNumber) {
            setProperty(0, m_ResultProducer);
            m_CurrentProperty = m_PropertyNumber;
        }
    }

    if (m_CurrentInstances == null) {
        File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
        AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
        loader.setFile(currentFile);
        Instances data = new Instances(loader.getDataSet());
        MLUtils.prepareData(data);
        m_CurrentInstances = data;
        m_ResultProducer.setInstances(m_CurrentInstances);
    }

    m_ResultProducer.doRun(m_RunNumber);

    advanceCounters();
}
项目:jbossBA    文件:GUI.java   
public void actionPerformed(ActionEvent ae) {
    ConverterFileChooser fc = new ConverterFileChooser(System.getProperty("user.dir"));
    fc.setDialogTitle("Set Data File");
    int rval = fc.showOpenDialog(GUI.this);

    if (rval == JFileChooser.APPROVE_OPTION) {
        AbstractFileLoader loader = fc.getLoader();
        try {
            if (loader != null)
              m_Instances = loader.getDataSet();
            if (m_Instances.classIndex() == -1)
              m_Instances.setClassIndex(m_Instances.numAttributes() - 1);
            a_learn.setEnabled(true);
            a_learnCPT.setEnabled(true);
            repaint();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
项目:jbossBA    文件:ArffTableModel.java   
/**
 * loads the specified ARFF file
 *
 * @param filename  the file to load
 */
private void loadFile(String filename) {
  AbstractFileLoader          loader;

  loader = ConverterUtils.getLoaderForFile(filename);

  if (loader != null) {
    try {
      loader.setFile(new File(filename));
      m_Data = loader.getDataSet();
    }
    catch (Exception e) {
      ComponentHelper.showMessageBox(
          null,
          Messages.getInstance().getString("ArffTableModel_LoadFile_ComponentHelperShowMessageBox_Text"),
          e.toString(),
          JOptionPane.OK_CANCEL_OPTION,
          JOptionPane.ERROR_MESSAGE );
      System.out.println(Thread.currentThread().getStackTrace()[1].getClassName() +e);
      m_Data = null;
    }
  }
}
项目:repo.kmeanspp.silhouette_score    文件:HDFSLoaderCustomizer.java   
@Override
public void closingOK() {
  m_loader.getConfig().setHDFSHost(m_hdfsHostText.getText());
  m_loader.getConfig().setHDFSPort(m_hdfsPortText.getText());
  m_loader.setHDFSPath(m_hdfsPathText.getText());
  m_loader.setLoader((AbstractFileLoader) m_baseLoaderEditor.getValue());
}
项目:repo.kmeanspp.silhouette_score    文件:Experiment.java   
/**
 * Carries out the next iteration of the experiment.
 * 
 * @throws Exception if an error occurs
 */
public void nextIteration() throws Exception {

  if (m_UsePropertyIterator) {
    if (m_CurrentProperty != m_PropertyNumber) {
      setProperty(0, m_ResultProducer);
      m_CurrentProperty = m_PropertyNumber;
    }
  }

  if (m_CurrentInstances == null) {
    File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
    AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
    loader.setFile(currentFile);
    Instances data = new Instances(loader.getDataSet());
    // only set class attribute if not already done by loader
    if (data.classIndex() == -1) {
      if (m_ClassFirst) {
        data.setClassIndex(0);
      } else {
        data.setClassIndex(data.numAttributes() - 1);
      }
    }
    m_CurrentInstances = data;
    m_ResultProducer.setInstances(m_CurrentInstances);
  }

  m_ResultProducer.doRun(m_RunNumber);

  advanceCounters();
}
项目:repo.kmeanspp.silhouette_score    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
@Override
public void run() {

  try {
    m_Log.statusMessage("Reading from URL...");
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage("Problem reading " + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
                  "Couldn't read from URL:\n"
                  + u + "\n"
                  + ex.getMessage(),
                  "Load Instances",
                  JOptionPane.ERROR_MESSAGE);
  }

  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);
   }
 }
项目:repo.kmeanspp.silhouette_score    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
    "Cannot perform undo operation!\n" + e.toString(),
    "Undo",
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * returns the loader that was chosen by the user, can be null in case the
 * user aborted the dialog or the save dialog was shown.
 * 
 * @return the chosen loader, if any
 */
public AbstractFileLoader getLoader() {
  configureCurrentConverter(LOADER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileSaver) {
    return null;
  } else {
    return (AbstractFileLoader) m_CurrentConverter;
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * returns the saver that was chosen by the user, can be null in case the user
 * aborted the dialog or the open dialog was shown.
 * 
 * @return the chosen saver, if any
 */
public AbstractFileSaver getSaver() {
  configureCurrentConverter(SAVER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileLoader) {
    return null;
  } else {
    return (AbstractFileSaver) m_CurrentConverter;
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ConverterFileChooser.java   
/**
 * For testing the file chooser.
 * 
 * @param args the commandline options - ignored
 * @throws Exception if something goes wrong with loading/saving
 */
public static void main(String[] args) throws Exception {
  ConverterFileChooser fc;
  int retVal;
  AbstractFileLoader loader;
  AbstractFileSaver saver;
  Instances data;

  fc = new ConverterFileChooser();
  retVal = fc.showOpenDialog(null);

  // load file
  if (retVal == ConverterFileChooser.APPROVE_OPTION) {
    loader = fc.getLoader();
    data = loader.getDataSet();
    retVal = fc.showSaveDialog(null);

    // save file
    if (retVal == ConverterFileChooser.APPROVE_OPTION) {
      saver = fc.getSaver();
      saver.setInstances(data);
      saver.writeBatch();
    } else {
      System.out.println("Saving aborted!");
    }
  } else {
    System.out.println("Loading aborted!");
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ArffTableModel.java   
/**
 * initializes the object and loads the given file
 * 
 * @param filename the file to load
 * @param loaders optional varargs for a loader to use
 */
public ArffTableModel(String filename, AbstractFileLoader... loaders) {
  this();

  if ((filename != null) && (!filename.equals(""))) {
    loadFile(filename, loaders);
  }
}
项目:repo.kmeanspp.silhouette_score    文件:ArffViewerMainPanel.java   
/**
 * loads the specified file
 * 
 * @param filename the file to load
 * @param loaders optional varargs loader to use
 */
public void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffPanel panel;

  panel = new ArffPanel(filename, loaders);
  panel.addChangeListener(this);
  tabbedPane.addTab(panel.getTitle(), panel);
  tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
}
项目:autoweka    文件:Experiment.java   
/**
  * Carries out the next iteration of the experiment.
  *
  * @throws Exception if an error occurs
  */
 public void nextIteration() throws Exception {

   if (m_UsePropertyIterator) {
     if (m_CurrentProperty != m_PropertyNumber) {
setProperty(0, m_ResultProducer);
m_CurrentProperty = m_PropertyNumber;
     }
   }

   if (m_CurrentInstances == null) {
     File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
     loader.setFile(currentFile);
     Instances data = new Instances(loader.getDataSet());
     // only set class attribute if not already done by loader
     if (data.classIndex() == -1) {
if (m_ClassFirst) {
  data.setClassIndex(0);
} else {
  data.setClassIndex(data.numAttributes() - 1);
}
     }
     m_CurrentInstances = data;
     m_ResultProducer.setInstances(m_CurrentInstances);
   }

   m_ResultProducer.doRun(m_RunNumber);

   advanceCounters();
 }
项目:autoweka    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
public void run() {

  try {
    m_Log.statusMessage("Reading from URL...");
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage("Problem reading " + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
                  "Couldn't read from URL:\n"
                  + u + "\n"
                  + ex.getMessage(),
                  "Load Instances",
                  JOptionPane.ERROR_MESSAGE);
  }

  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);
   }
 }
项目:autoweka    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
    "Cannot perform undo operation!\n" + e.toString(),
    "Undo",
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }
项目:autoweka    文件:ConverterFileChooser.java   
/**
 * returns the loader that was chosen by the user, can be null in case the
 * user aborted the dialog or the save dialog was shown.
 * 
 * @return      the chosen loader, if any
 */
public AbstractFileLoader getLoader() {
  configureCurrentConverter(LOADER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileSaver)
    return null;
  else
    return (AbstractFileLoader) m_CurrentConverter;
}
项目:autoweka    文件:ConverterFileChooser.java   
/**
 * returns the saver that was chosen by the user, can be null in case the
 * user aborted the dialog or the open dialog was shown.
 * 
 * @return      the chosen saver, if any
 */
public AbstractFileSaver getSaver() {
  configureCurrentConverter(SAVER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileLoader)
    return null;
  else
    return (AbstractFileSaver) m_CurrentConverter;
}
项目:autoweka    文件:ConverterFileChooser.java   
/**
  * For testing the file chooser.
  * 
  * @param args the commandline options - ignored
  * @throws Exception   if something goes wrong with loading/saving
  */
 public static void main(String[] args) throws Exception {
   ConverterFileChooser fc;
   int              retVal;
   AbstractFileLoader       loader;
   AbstractFileSaver        saver;
   Instances            data;

   fc     = new ConverterFileChooser();
   retVal = fc.showOpenDialog(null);

   // load file
   if (retVal == ConverterFileChooser.APPROVE_OPTION) {
     loader = fc.getLoader();
     data   = loader.getDataSet();
     retVal = fc.showSaveDialog(null);

     // save file
     if (retVal == ConverterFileChooser.APPROVE_OPTION) {
saver = fc.getSaver();
saver.setInstances(data);
saver.writeBatch();
     }
     else {
System.out.println("Saving aborted!");
     }
   }
   else {
     System.out.println("Loading aborted!");
   }
 }
项目:autoweka    文件:ArffTableModel.java   
/**
 * initializes the object and loads the given file
 * 
 * @param filename  the file to load
 * @param loaders optional varargs for a loader to use
 */
public ArffTableModel(String filename, AbstractFileLoader... loaders) {
  this();

  if ( (filename != null) && (!filename.equals("")) )
    loadFile(filename, loaders);
}
项目:autoweka    文件:ArffTableModel.java   
/**
 * loads the specified ARFF file
 * 
 * @param filename  the file to load
 * @param loaders optional varargs for a loader to use
 */
protected void loadFile(String filename, AbstractFileLoader... loaders) {
  AbstractFileLoader          loader;

  if (loaders == null || loaders.length == 0) {
    loader = ConverterUtils.getLoaderForFile(filename);
  } else {
    loader = loaders[0];
  }

  if (loader != null) {
    try {
      loader.setFile(new File(filename));
      setInstances(loader.getDataSet());
    }
    catch (Exception e) {
      ComponentHelper.showMessageBox(
          null, 
          "Error loading file...", 
          e.toString(), 
          JOptionPane.OK_CANCEL_OPTION,
          JOptionPane.ERROR_MESSAGE );
      System.out.println(e);
      setInstances(null);
    }
  }
}
项目:autoweka    文件:ArffViewerMainPanel.java   
/**
 * loads the specified file
 * 
 * @param filename  the file to load
 * @param loaders optional varargs loader to use
 */
public void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffPanel         panel;

  panel    = new ArffPanel(filename, loaders);
  panel.addChangeListener(this);
  tabbedPane.addTab(panel.getTitle(), panel);
  tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
}
项目:umple    文件:Experiment.java   
/**
 * Carries out the next iteration of the experiment.
 * 
 * @throws Exception if an error occurs
 */
public void nextIteration() throws Exception {

  if (m_UsePropertyIterator) {
    if (m_CurrentProperty != m_PropertyNumber) {
      setProperty(0, m_ResultProducer);
      m_CurrentProperty = m_PropertyNumber;
    }
  }

  if (m_CurrentInstances == null) {
    File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
    AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
    loader.setFile(currentFile);
    Instances data = new Instances(loader.getDataSet());
    // only set class attribute if not already done by loader
    if (data.classIndex() == -1) {
      if (m_ClassFirst) {
        data.setClassIndex(0);
      } else {
        data.setClassIndex(data.numAttributes() - 1);
      }
    }
    m_CurrentInstances = data;
    m_ResultProducer.setInstances(m_CurrentInstances);
  }

  m_ResultProducer.doRun(m_RunNumber);

  advanceCounters();
}
项目:umple    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
@Override
public void run() {

  try {
    m_Log.statusMessage("Reading from URL...");
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception("No suitable URLSourcedLoader found for URL!\n" + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage("Problem reading " + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
                  "Couldn't read from URL:\n"
                  + u + "\n"
                  + ex.getMessage(),
                  "Load Instances",
                  JOptionPane.ERROR_MESSAGE);
  }

  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);
   }
 }
项目:umple    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
    "Cannot perform undo operation!\n" + e.toString(),
    "Undo",
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }
项目:umple    文件:ConverterFileChooser.java   
/**
 * returns the loader that was chosen by the user, can be null in case the
 * user aborted the dialog or the save dialog was shown.
 * 
 * @return the chosen loader, if any
 */
public AbstractFileLoader getLoader() {
  configureCurrentConverter(LOADER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileSaver) {
    return null;
  } else {
    return (AbstractFileLoader) m_CurrentConverter;
  }
}
项目:umple    文件:ConverterFileChooser.java   
/**
 * returns the saver that was chosen by the user, can be null in case the user
 * aborted the dialog or the open dialog was shown.
 * 
 * @return the chosen saver, if any
 */
public AbstractFileSaver getSaver() {
  configureCurrentConverter(SAVER_DIALOG);

  if (m_CurrentConverter instanceof AbstractFileLoader) {
    return null;
  } else {
    return (AbstractFileSaver) m_CurrentConverter;
  }
}
项目:umple    文件:ConverterFileChooser.java   
/**
 * For testing the file chooser.
 * 
 * @param args the commandline options - ignored
 * @throws Exception if something goes wrong with loading/saving
 */
public static void main(String[] args) throws Exception {
  ConverterFileChooser fc;
  int retVal;
  AbstractFileLoader loader;
  AbstractFileSaver saver;
  Instances data;

  fc = new ConverterFileChooser();
  retVal = fc.showOpenDialog(null);

  // load file
  if (retVal == ConverterFileChooser.APPROVE_OPTION) {
    loader = fc.getLoader();
    data = loader.getDataSet();
    retVal = fc.showSaveDialog(null);

    // save file
    if (retVal == ConverterFileChooser.APPROVE_OPTION) {
      saver = fc.getSaver();
      saver.setInstances(data);
      saver.writeBatch();
    } else {
      System.out.println("Saving aborted!");
    }
  } else {
    System.out.println("Loading aborted!");
  }
}
项目:umple    文件:ArffTableModel.java   
/**
 * initializes the object and loads the given file
 * 
 * @param filename the file to load
 * @param loaders optional varargs for a loader to use
 */
public ArffTableModel(String filename, AbstractFileLoader... loaders) {
  this();

  if ((filename != null) && (!filename.equals(""))) {
    loadFile(filename, loaders);
  }
}
项目:umple    文件:ArffViewerMainPanel.java   
/**
 * loads the specified file
 * 
 * @param filename the file to load
 * @param loaders optional varargs loader to use
 */
public void loadFile(String filename, AbstractFileLoader... loaders) {
  ArffPanel panel;

  panel = new ArffPanel(filename, loaders);
  panel.addChangeListener(this);
  tabbedPane.addTab(panel.getTitle(), panel);
  tabbedPane.setSelectedIndex(tabbedPane.getTabCount() - 1);
}
项目:jbossBA    文件:Experiment.java   
/**
  * Carries out the next iteration of the experiment.
  *
  * @throws Exception if an error occurs
  */
 public void nextIteration() throws Exception {

   if (m_UsePropertyIterator) {
     if (m_CurrentProperty != m_PropertyNumber) {
setProperty(0, m_ResultProducer);
m_CurrentProperty = m_PropertyNumber;
     }
   }

   if (m_CurrentInstances == null) {
     File currentFile = (File) getDatasets().elementAt(m_DatasetNumber);
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(currentFile);
     loader.setFile(currentFile);
     Instances data = new Instances(loader.getDataSet());
     // only set class attribute if not already done by loader
     if (data.classIndex() == -1) {
if (m_ClassFirst) {
  data.setClassIndex(0);
} else {
  data.setClassIndex(data.numAttributes() - 1);
}
     }
     m_CurrentInstances = data;
     m_ResultProducer.setInstances(m_CurrentInstances);
   }

   m_ResultProducer.doRun(m_RunNumber);

   advanceCounters();
 }
项目:jbossBA    文件:PreprocessPanel.java   
/**
  * Loads instances from a URL.
  *
  * @param u the URL to load from.
  */
 public void setInstancesFromURL(final URL u) {

   if (m_IOThread == null) {
     m_IOThread = new Thread() {
public void run() {

  try {
    m_Log.statusMessage(Messages.getInstance().getString("PreprocessPanel_SetInstancesFromURL_Run_Log_StatusMessage_Text_First"));
    AbstractFileLoader loader = ConverterUtils.getURLLoaderForFile(u.toString());
    if (loader == null)
      throw new Exception(Messages.getInstance().getString("PreprocessPanel_SetInstancesFromURL_Run_Exception_Text_First") + u);
    ((URLSourcedLoader) loader).setURL(u.toString());
    setInstances(loader.getDataSet());
  } catch (Exception ex) {
    ex.printStackTrace();
    m_Log.statusMessage(Messages.getInstance().getString("PreprocessPanel_SetInstancesFromURL_Run_Log_StatusMessage_Text_Second") + u);
    JOptionPane.showMessageDialog(PreprocessPanel.this,
            Messages.getInstance().getString("PreprocessPanel_SetInstancesFromDB_Run_JOptionPaneShowMessageDialog_Text_Fifth")
                  + u + Messages.getInstance().getString("PreprocessPanel_SetInstancesFromDB_Run_JOptionPaneShowMessageDialog_Text_Sixth")
                  + ex.getMessage(),
                  Messages.getInstance().getString("PreprocessPanel_SetInstancesFromDB_Run_JOptionPaneShowMessageDialog_Text_Seventh"),
                  JOptionPane.ERROR_MESSAGE);
  }

  m_IOThread = null;
}
     };
     m_IOThread.setPriority(Thread.MIN_PRIORITY); // UI has most priority
     m_IOThread.start();
   } else {
     JOptionPane.showMessageDialog(this,
          Messages.getInstance().getString("PreprocessPanel_SetInstancesFromDB_Run_JOptionPaneShowMessageDialog_Text_Eighth"),
                Messages.getInstance().getString("PreprocessPanel_SetInstancesFromDB_Run_JOptionPaneShowMessageDialog_Text_Nineth"),
                JOptionPane.WARNING_MESSAGE);
   }
 }
项目:jbossBA    文件:PreprocessPanel.java   
/**
  * Reverts to the last backed up version of the dataset.
  */
 public void undo() {

   if (--m_tempUndoIndex < 0) {
     // wrap pointer around
     m_tempUndoIndex = m_tempUndoFiles.length-1;
   }

   if (m_tempUndoFiles[m_tempUndoIndex] != null) {
     // load instances from the temporary file
     AbstractFileLoader loader = ConverterUtils.getLoaderForFile(m_tempUndoFiles[m_tempUndoIndex]);
     try {
loader.setFile(m_tempUndoFiles[m_tempUndoIndex]);
setInstancesFromFile(loader);
     }
     catch (Exception e) {
e.printStackTrace();
m_Log.logMessage(e.toString());
JOptionPane.showMessageDialog(PreprocessPanel.this,
        Messages.getInstance().getString("PreprocessPanel_Undo_JOptionPaneShowMessageDialog_Text_First") + e.toString(),
        Messages.getInstance().getString("PreprocessPanel_Undo_JOptionPaneShowMessageDialog_Text_Second"),
    JOptionPane.ERROR_MESSAGE);
     }

     // update undo file list
     m_tempUndoFiles[m_tempUndoIndex] = null;
   }

   // update undo button
   int temp = m_tempUndoIndex-1;
   if (temp < 0) {
     temp = m_tempUndoFiles.length-1;
   }
   m_UndoBut.setEnabled(m_tempUndoFiles[temp] != null);
 }