/*
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.dynamic;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import org.gephi.filters.plugin.dynamic.DynamicRangeBuilder.DynamicRangeFilter;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
import org.openide.windows.WindowManager;
/**
*
* @author Mathieu Bastian
*/
public class DynamicRangePanel extends javax.swing.JPanel {
private final String OPEN;
private final String CLOSE;
public DynamicRangePanel() {
initComponents();
OPEN = NbBundle.getMessage(DynamicRangePanel.class, "DynamicRangePanel.timelineButton.text");
CLOSE = NbBundle.getMessage(DynamicRangePanel.class, "DynamicRangePanel.timelineButton.closetext");
}
public void setup(final DynamicRangeFilter filter) {
final TopComponent topComponent = WindowManager.getDefault().findTopComponent("TimelineTopComponent");
timelineButton.setText(topComponent.isOpened() ? CLOSE : OPEN);
timelineButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (!topComponent.isOpened()) {
topComponent.open();
topComponent.requestActive();
timelineButton.setText(CLOSE);
} else {
topComponent.close();
timelineButton.setText(OPEN);
}
}
});
keepEmptyCheckbox.setSelected(filter.isKeepNull());
keepEmptyCheckbox.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
if (!filter.isKeepNull() == keepEmptyCheckbox.isSelected()) {
filter.getProperties()[1].setValue(keepEmptyCheckbox.isSelected());
}
}
});
}
/** 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() {
java.awt.GridBagConstraints gridBagConstraints;
timelineButton = new javax.swing.JButton();
keepEmptyCheckbox = new javax.swing.JCheckBox();
setLayout(new java.awt.GridBagLayout());
timelineButton.setText(org.openide.util.NbBundle.getMessage(DynamicRangePanel.class, "DynamicRangePanel.timelineButton.text")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
add(timelineButton, gridBagConstraints);
keepEmptyCheckbox.setText(org.openide.util.NbBundle.getMessage(DynamicRangePanel.class, "DynamicRangePanel.keepEmptyCheckbox.text")); // NOI18N
keepEmptyCheckbox.setToolTipText(org.openide.util.NbBundle.getMessage(DynamicRangePanel.class, "DynamicRangePanel.keepEmptyCheckbox.toolTipText")); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
add(keepEmptyCheckbox, gridBagConstraints);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox keepEmptyCheckbox;
private javax.swing.JButton timelineButton;
// End of variables declaration//GEN-END:variables
}