Example usage for weka.gui ListSelectorDialog APPROVE_OPTION

List of usage examples for weka.gui ListSelectorDialog APPROVE_OPTION

Introduction

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

Prototype

int APPROVE_OPTION

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

Click Source Link

Document

Signifies an OK property selection

Usage

From source file:meka.gui.dataviewer.DataPanel.java

License:Open Source License

/**
 * deletes the chosen attributes/*from   w w  w . ja va 2s  . c o  m*/
 */
public void deleteAttributes() {
    ListSelectorDialog dialog;
    DataSortedTableModel model;
    Object[] atts;
    int[] indices;
    int i;
    JList list;
    int result;

    list = new JList(getAttributes());
    dialog = new ListSelectorDialog(null, list);
    result = dialog.showDialog();

    if (result != ListSelectorDialog.APPROVE_OPTION) {
        return;
    }

    atts = list.getSelectedValues();

    // really?
    if (ComponentHelper.showMessageBox(getParent(), "Confirm...",
            "Do you really want to delete these " + atts.length + " attributes?", JOptionPane.YES_NO_OPTION,
            JOptionPane.QUESTION_MESSAGE) != JOptionPane.YES_OPTION) {
        return;
    }

    model = (DataSortedTableModel) m_TableData.getModel();
    indices = new int[atts.length];
    for (i = 0; i < atts.length; i++) {
        indices[i] = model.getAttributeColumn(atts[i].toString());
    }

    setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
    model.deleteAttributes(indices);
    setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}

From source file:meka.gui.dataviewer.DataViewerMainPanel.java

License:Open Source License

/**
 * displays all the attributes, returns the selected item or NULL if canceled
 *
 * @return the name of the selected attribute
 *///from  w  w w .  j a v a2  s .com
public String showAttributes() {
    DataSortedTableModel model;
    ListSelectorDialog dialog;
    int i;
    JList list;
    String name;
    int result;

    if (!isPanelSelected()) {
        return null;
    }

    list = new JList(getCurrentPanel().getAttributes());
    dialog = new ListSelectorDialog(getParentFrame(), list);
    result = dialog.showDialog();

    if (result == ListSelectorDialog.APPROVE_OPTION) {
        model = (DataSortedTableModel) getCurrentPanel().getTable().getModel();
        name = list.getSelectedValue().toString();
        i = model.getAttributeColumn(name);
        JTableHelper.scrollToVisible(getCurrentPanel().getTable(), 0, i);
        getCurrentPanel().getTable().setSelectedColumn(i);
        return name;
    } else {
        return null;
    }
}

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

License:Open Source License

/**
 * Queries the user enough to make a database query to retrieve experiment
 * results.// ww w  . ja v a  2 s  .  c  o m
 */
protected void setInstancesFromDBaseQuery() {

    try {
        if (m_InstanceQuery == null) {
            m_InstanceQuery = new MIInstanceQuery();
        }
        String dbaseURL = m_InstanceQuery.getDatabaseURL();
        dbaseURL = (String) JOptionPane.showInputDialog(this, "Enter the database URL", "Query Database",
                JOptionPane.PLAIN_MESSAGE, null, null, dbaseURL);
        if (dbaseURL == null) {
            m_FromLab.setText("Cancelled");
            return;
        }
        m_InstanceQuery.setDatabaseURL(dbaseURL);
        m_InstanceQuery.connectToDatabase();
        if (!m_InstanceQuery.experimentIndexExists()) {
            m_FromLab.setText("No experiment index");
            return;
        }
        m_FromLab.setText("Getting experiment index");
        Instances index = m_InstanceQuery.retrieveInstances("SELECT * FROM " + MIInstanceQuery.EXP_INDEX_TABLE);
        if (index.numInstances() == 0) {
            m_FromLab.setText("No experiments available");
            return;
        }
        m_FromLab.setText("Got experiment index");

        DefaultListModel lm = new DefaultListModel();
        for (int i = 0; i < index.numInstances(); i++) {
            lm.addElement(index.instance(i).toString());
        }
        JList jl = new JList(lm);
        ListSelectorDialog jd = new ListSelectorDialog(null, jl);
        int result = jd.showDialog();
        if (result != ListSelectorDialog.APPROVE_OPTION) {
            m_FromLab.setText("Cancelled");
            return;
        }
        Instance selInst = index.instance(jl.getSelectedIndex());
        Attribute tableAttr = index.attribute(MIInstanceQuery.EXP_RESULT_COL);
        String table = MIInstanceQuery.EXP_RESULT_PREFIX + selInst.toString(tableAttr);

        setInstancesFromDatabaseTable(table);
    } catch (Exception ex) {
        m_FromLab.setText("Problem reading database");
    }
}

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

License:Open Source License

public void setResultKeyFromDialog() {

    ListSelectorDialog jd = new ListSelectorDialog(null, m_ResultKeyList);

    // Open the dialog
    int result = jd.showDialog();

    // If accepted, update the ttester
    if (result == ListSelectorDialog.APPROVE_OPTION) {
        int[] selected = m_ResultKeyList.getSelectedIndices();
        String selectedList = "";
        for (int i = 0; i < selected.length; i++) {
            selectedList += "," + (selected[i] + 1);
        }/*w ww  .  ja  v  a 2  s  . c o  m*/
        Range generatorRange = new Range();
        if (selectedList.length() != 0) {
            try {
                generatorRange.setRanges(selectedList);
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println(ex.getMessage());
            }
        }
        m_TTester.setResultsetKeyColumns(generatorRange);
        setTTester();
    }
}

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

License:Open Source License

public void setDatasetKeyFromDialog() {

    ListSelectorDialog jd = new ListSelectorDialog(null, m_DatasetKeyList);

    // Open the dialog
    int result = jd.showDialog();

    // If accepted, update the ttester
    if (result == ListSelectorDialog.APPROVE_OPTION) {
        int[] selected = m_DatasetKeyList.getSelectedIndices();
        String selectedList = "";
        for (int i = 0; i < selected.length; i++) {
            selectedList += "," + (selected[i] + 1);
        }//from  w  w  w  .  j a va2 s  .  c o m
        Range generatorRange = new Range();
        if (selectedList.length() != 0) {
            try {
                generatorRange.setRanges(selectedList);
            } catch (Exception ex) {
                ex.printStackTrace();
                System.err.println(ex.getMessage());
            }
        }
        m_TTester.setDatasetKeyColumns(generatorRange);
        setTTester();
    }
}