Example usage for weka.gui PropertySelectorDialog APPROVE_OPTION

List of usage examples for weka.gui PropertySelectorDialog APPROVE_OPTION

Introduction

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

Prototype

int APPROVE_OPTION

To view the source code for weka.gui PropertySelectorDialog APPROVE_OPTION.

Click Source Link

Document

Signifies an OK property selection

Usage

From source file:milk.gui.experiment.MIGeneratorPropertyIteratorPanel.java

License:Open Source License

/**
 * Gets the user to select a property of the current resultproducer.
 *
 * @return APPROVE_OPTION if the selection went OK, otherwise the selection
 * was cancelled./*  w  w  w. j av a2  s . c  om*/
 */
protected int selectProperty() {

    final PropertySelectorDialog jd = new PropertySelectorDialog(null, m_Exp.getResultProducer());
    jd.setLocationRelativeTo(this);
    int result = jd.showDialog();
    if (result == PropertySelectorDialog.APPROVE_OPTION) {
        System.err.println("Property Selected");
        PropertyNode[] path = jd.getPath();
        Object value = path[path.length - 1].value;
        PropertyDescriptor property = path[path.length - 1].property;
        // Make an array containing the propertyValue
        Class propertyClass = property.getPropertyType();
        m_Exp.setPropertyPath(path);
        m_Exp.setPropertyArray(Array.newInstance(propertyClass, 1));
        Array.set(m_Exp.getPropertyArray(), 0, value);
        // Pass it to the arrayeditor
        m_ArrayEditor.setValue(m_Exp.getPropertyArray());
        m_ArrayEditor.repaint();
        System.err.println("Set new array to array editor");
    } else {
        System.err.println("Cancelled");
    }
    return result;
}