/*
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
Gephi is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
Gephi is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with Gephi. If not, see <http://www.gnu.org/licenses/>.
*/
package org.gephi.ui.filters.plugin.attribute;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import org.gephi.filters.plugin.attribute.AttributeEqualBuilder.EqualBooleanFilter;
import org.gephi.filters.spi.FilterProperty;
/**
*
* @author Mathieu Bastian
*/
public class EqualBooleanPanel extends javax.swing.JPanel implements ActionListener {
private EqualBooleanFilter filter;
public EqualBooleanPanel() {
initComponents();
trueButton.addActionListener(this);
falseButton.addActionListener(this);
}
public void setup(EqualBooleanFilter filter) {
this.filter = filter;
this.setToolTipText(filter.getName() + " '" + filter.getColumn().getTitle() + "'");
group.clearSelection();
group.setSelected(trueButton.getModel(), filter.isMatch());
group.setSelected(falseButton.getModel(), !filter.isMatch());
}
public void actionPerformed(ActionEvent evt) {
FilterProperty match = filter.getProperties()[1];
try {
match.setValue(trueButton.isSelected());
} catch (Exception e) {
e.printStackTrace();
}
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
group = new javax.swing.ButtonGroup();
trueButton = new javax.swing.JToggleButton();
falseButton = new javax.swing.JToggleButton();
group.add(trueButton);
trueButton.setText(org.openide.util.NbBundle.getMessage(EqualBooleanPanel.class, "EqualBooleanPanel.trueButton.text")); // NOI18N
add(trueButton);
group.add(falseButton);
falseButton.setText(org.openide.util.NbBundle.getMessage(EqualBooleanPanel.class, "EqualBooleanPanel.falseButton.text")); // NOI18N
add(falseButton);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JToggleButton falseButton;
private javax.swing.ButtonGroup group;
private javax.swing.JToggleButton trueButton;
// End of variables declaration//GEN-END:variables
}