public void openFiles(OpenFilesEvent arg0) {
    System.out.println("Opening an arff/xrff file under Mac OS X...");
    File toOpen = arg0.getFiles().get(0);

    if (toOpen.toString().toLowerCase().endsWith(".arff")
        || toOpen.toString().toLowerCase().endsWith(".xrff")) {
      weka.gui.GUIChooser.createSingleton();
      weka.gui.GUIChooser.getSingleton().showExplorer(toOpen.toString());
    } else if (toOpen.toString().toLowerCase().endsWith(".kf")
        || toOpen.toString().toLowerCase().endsWith(".kfml")) {
      weka.gui.GUIChooser.createSingleton();
      weka.gui.GUIChooser.getSingleton().showKnowledgeFlow(toOpen.toString());
    }
  }
Exemple #2
0
  /**
   * Tests out the GUIChooser environment.
   *
   * @param args ignored.
   */
  public static void main(String[] args) {

    LookAndFeel.setLookAndFeel();

    try {

      // uncomment to disable the memory management:
      // m_Memory.setEnabled(false);

      m_chooser = new GUIChooser();
      m_chooser.setVisible(true);

      Thread memMonitor =
          new Thread() {
            public void run() {
              while (true) {
                try {
                  // System.out.println("before sleeping");
                  this.sleep(4000);

                  System.gc();

                  if (m_Memory.isOutOfMemory()) {
                    // clean up
                    m_chooser.dispose();
                    if (m_chooser.m_ExperimenterFrame != null) {
                      m_chooser.m_ExperimenterFrame.dispose();
                      m_chooser.m_ExperimenterFrame = null;
                    }
                    if (m_chooser.m_ExplorerFrame != null) {
                      m_chooser.m_ExplorerFrame.dispose();
                      m_chooser.m_ExplorerFrame = null;
                    }
                    if (m_chooser.m_KnowledgeFlowFrame != null) {
                      m_chooser.m_KnowledgeFlowFrame.dispose();
                      m_chooser.m_KnowledgeFlowFrame = null;
                    }
                    if (m_chooser.m_SimpleCLI != null) {
                      m_chooser.m_SimpleCLI.dispose();
                      m_chooser.m_SimpleCLI = null;
                    }
                    m_chooser = null;
                    System.gc();

                    // stop threads
                    m_Memory.stopThreads();

                    // display error
                    System.err.println("\ndisplayed message:");
                    m_Memory.showOutOfMemory();
                    System.err.println("\nexiting...");
                    System.exit(-1);
                  }
                } catch (InterruptedException ex) {
                  ex.printStackTrace();
                }
              }
            }
          };

      memMonitor.setPriority(Thread.NORM_PRIORITY);
      memMonitor.start();
    } catch (Exception ex) {
      ex.printStackTrace();
      System.err.println(ex.getMessage());
    }
  }