Example usage for weka.gui GenericObjectEditor GenericObjectEditor

List of usage examples for weka.gui GenericObjectEditor GenericObjectEditor

Introduction

In this page you can find the example usage for weka.gui GenericObjectEditor GenericObjectEditor.

Prototype

public GenericObjectEditor(boolean canChangeClassInDialog) 

Source Link

Document

Constructor that allows specifying whether it is possible to change the class within the editor dialog.

Usage

From source file:moa.gui.WEKAClassOptionEditComponent.java

License:Open Source License

public void editObject() {
    final GenericObjectEditor goe = new GenericObjectEditor(true);
    goe.setClassType(editedOption.getRequiredType());
    try {//from  w ww . j  a va 2  s .  co  m
        String[] options = Utils.splitOptions(editedOption.getValueAsCLIString());
        String classname = options[0];
        options[0] = "";
        Object obj = Class.forName(classname).newInstance();
        if (obj instanceof weka.core.OptionHandler) {
            ((weka.core.OptionHandler) obj).setOptions(options);
        }
        goe.setValue(obj);
        ((GOEPanel) goe.getCustomEditor()).addOkListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                Object obj = goe.getValue();
                String s = obj.getClass().getName();
                if (obj instanceof weka.core.OptionHandler) {
                    s += " " + Utils.joinOptions(((weka.core.OptionHandler) obj).getOptions());
                }
                setEditState(s.trim());
            }
        });
        PropertyDialog dialog;
        if (PropertyDialog.getParentDialog(this) != null) {
            dialog = new PropertyDialog(PropertyDialog.getParentDialog(this), goe);
        } else {
            dialog = new PropertyDialog(PropertyDialog.getParentFrame(this), goe);
        }
        dialog.setModal(true);
        dialog.setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

From source file:sirius.trainer.step3.SelectFeaturePane.java

License:Open Source License

/**
 * Pops up generic object editor with list of conversion filters
 *
 * @param f the File// w  ww  . j a  v a2  s  .c o m
 */
private void converterQuery(final File f) {
    final GenericObjectEditor convEd = new GenericObjectEditor(true);
    try {
        convEd.setClassType(weka.core.converters.Loader.class);
        convEd.setValue(new weka.core.converters.CSVLoader());
        ((GenericObjectEditor.GOEPanel) convEd.getCustomEditor()).addOkListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                tryConverter((Loader) convEd.getValue(), f);
            }
        });
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    //PropertyDialog pd = new PropertyDialog(convEd, 100, 100);
}

From source file:tr.gov.ulakbim.jDenetX.gui.WEKAClassOptionEditComponent.java

License:Open Source License

public void editObject() {
    final GenericObjectEditor goe = new GenericObjectEditor(true);
    goe.setClassType(editedOption.getRequiredType());
    try {/*from w  w w. j a  v a2s. c  om*/
        String[] options = Utils.splitOptions(editedOption.getValueAsCLIString());
        String classname = options[0];
        options[0] = "";
        Object obj = Class.forName(classname).newInstance();
        if (obj instanceof weka.core.OptionHandler)
            ((weka.core.OptionHandler) obj).setOptions(options);
        goe.setValue(obj);
        ((GOEPanel) goe.getCustomEditor()).addOkListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Object obj = goe.getValue();
                String s = obj.getClass().getName();
                if (obj instanceof weka.core.OptionHandler)
                    s += " " + Utils.joinOptions(((weka.core.OptionHandler) obj).getOptions());
                setEditState(s.trim());
            }
        });
        PropertyDialog dialog;
        if (PropertyDialog.getParentDialog(this) != null)
            dialog = new PropertyDialog(PropertyDialog.getParentDialog(this), goe);
        else
            dialog = new PropertyDialog(PropertyDialog.getParentFrame(this), goe);
        dialog.setModal(true);
        dialog.setVisible(true);
    } catch (Exception e) {
        e.printStackTrace();
    }
}