コード例 #1
0
ファイル: LoaderCustomizer.java プロジェクト: dachylong/weka
  public LoaderCustomizer() {
    /*    m_fileEditor.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      if (m_dsLoader != null) {
        m_dsLoader.setDataSetFile((File)m_fileEditor.getValue());
      }
    }
    }); */

    try {
      /*      m_LoaderEditor.setClassType(weka.core.converters.Loader.class);
      m_LoaderEditor.setValue(new weka.core.converters.ArffLoader()); */
      m_LoaderEditor.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              repaint();
              if (m_dsLoader != null) {
                System.err.println("Property change!!");
                m_dsLoader.setLoader(m_dsLoader.getLoader());
              }
            }
          });
      repaint();
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    setLayout(new BorderLayout());
    //    add(m_fileEditor.getCustomEditor(), BorderLayout.CENTER);
    //    add(m_LoaderEditor, BorderLayout.CENTER);
    m_fileChooser.setDialogType(JFileChooser.OPEN_DIALOG);
    m_fileChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
              try {
                File selectedFile = m_fileChooser.getSelectedFile();
                /*              EnvironmentField ef = m_environmentFields.get(0);
                ef.setText(selectedFile.toString()); */
                m_fileText.setText(selectedFile.toString());

                /*	      ((FileSourcedConverter)m_dsLoader.getLoader()).
                setFile(selectedFile);
                     // tell the loader that a new file has been selected so
                     // that it can attempt to load the header
                     //m_dsLoader.setLoader(m_dsLoader.getLoader());
                     m_dsLoader.newFileSelected(); */
              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            // closing
            if (m_fileChooserFrame != null) {
              // m_parentFrame.dispose();
              m_fileChooserFrame.dispose();
            }
          }
        });
  }
コード例 #2
0
  /** Constructor */
  public SaverCustomizer() {

    try {
      m_SaverEditor.addPropertyChangeListener(
          new PropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent e) {
              repaint();
              if (m_dsSaver != null) {
                System.err.println("Property change!!");
                m_dsSaver.setSaver(m_dsSaver.getSaver());
              }
            }
          });
      repaint();
    } catch (Exception ex) {
      ex.printStackTrace();
    }
    setLayout(new BorderLayout());
    m_fileChooser.setDialogType(JFileChooser.SAVE_DIALOG);
    m_fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    m_fileChooser.setApproveButtonText("Select directory");
    m_fileChooser.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (e.getActionCommand().equals(JFileChooser.APPROVE_SELECTION)) {
              try {
                File selectedFile = m_fileChooser.getSelectedFile();
                m_directoryText.setText(selectedFile.toString());

                /* (m_dsSaver.getSaver()).setFilePrefix(m_prefixText.getText());
                (m_dsSaver.getSaver()).setDir(m_fileChooser.getSelectedFile().getPath());
                m_dsSaver.
                  setRelationNameForFilename(m_relationNameForFilename.isSelected()); */

              } catch (Exception ex) {
                ex.printStackTrace();
              }
            }
            // closing
            if (m_fileChooserFrame != null) {
              m_fileChooserFrame.dispose();
            }
          }
        });
  }