提交 1fb3fd07 编写于 作者: M Mathieu Bastian

Remove dynamic processor in ProcessorPlugin

上级 310efb35
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<NonVisualComponents>
<Component class="javax.swing.ButtonGroup" name="buttongroup">
</Component>
</NonVisualComponents>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelMatchingCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="285" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="labelLastFrame" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lastFrameLabel" pref="243" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="136" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="21" pref="21" max="21" attributes="0"/>
<Component id="labelDate" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="datePicker" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="dateRadio" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="21" pref="21" max="21" attributes="0"/>
<Component id="labelTime" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="timestampField" min="-2" pref="117" max="-2" attributes="0"/>
</Group>
<Component id="timeStampRadio" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="205" max="32767" attributes="0"/>
</Group>
<Component id="header" alignment="0" pref="498" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="header" min="-2" pref="91" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="labelMatchingCheckbox" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="18" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="labelLastFrame" min="-2" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="dateRadio" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lastFrameLabel" min="-2" pref="14" max="-2" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="labelDate" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="datePicker" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="timeStampRadio" min="-2" max="-2" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="labelTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="timestampField" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="30" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="org.jdesktop.swingx.JXHeader" name="header">
<Properties>
<Property name="description" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.header.description" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
<Property name="title" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.header.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JRadioButton" name="dateRadio">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttongroup"/>
</Property>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.dateRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelDate">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.labelDate.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<BindingProperties>
<BindingProperty name="enabled" source="dateRadio" sourcePath="${selected}" target="labelDate" targetPath="enabled" updateStrategy="0" immediately="false"/>
</BindingProperties>
</Component>
<Component class="org.jdesktop.swingx.JXDatePicker" name="datePicker">
<BindingProperties>
<BindingProperty name="enabled" source="dateRadio" sourcePath="${selected}" target="datePicker" targetPath="enabled" updateStrategy="0" immediately="false"/>
</BindingProperties>
</Component>
<Component class="javax.swing.JRadioButton" name="timeStampRadio">
<Properties>
<Property name="buttonGroup" type="javax.swing.ButtonGroup" editor="org.netbeans.modules.form.RADComponent$ButtonGroupPropertyEditor">
<ComponentRef name="buttongroup"/>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.timeStampRadio.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="labelTime">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.labelTime.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
<BindingProperties>
<BindingProperty name="enabled" source="timeStampRadio" sourcePath="${selected}" target="labelTime" targetPath="enabled" updateStrategy="0" immediately="false"/>
</BindingProperties>
</Component>
<Component class="javax.swing.JTextField" name="timestampField">
<BindingProperties>
<BindingProperty name="enabled" source="timeStampRadio" sourcePath="${selected}" target="timestampField" targetPath="enabled" updateStrategy="0" immediately="false"/>
</BindingProperties>
</Component>
<Component class="javax.swing.JLabel" name="labelLastFrame">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.modules.form.editors2.FontEditor">
<FontInfo relative="true">
<Font bold="true" component="labelLastFrame" property="font" relativeSize="true" size="0"/>
</FontInfo>
</Property>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.labelLastFrame.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lastFrameLabel">
</Component>
<Component class="javax.swing.JCheckBox" name="labelMatchingCheckbox">
<Properties>
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/gephi/ui/processor/plugin/Bundle.properties" key="DynamicProcessorPanel.labelMatchingCheckbox.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
</Property>
</Properties>
</Component>
</SubComponents>
</Form>
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.ui.processor.plugin;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import org.gephi.dynamic.DynamicUtilities;
import org.gephi.dynamic.api.DynamicController;
import org.gephi.dynamic.api.DynamicModel;
import org.gephi.io.processor.plugin.DynamicProcessor;
import org.netbeans.validation.api.Problems;
import org.netbeans.validation.api.Validator;
import org.netbeans.validation.api.ui.ValidationGroup;
import org.netbeans.validation.api.ui.ValidationListener;
import org.netbeans.validation.api.ui.ValidationPanel;
import org.openide.util.Lookup;
/**
*
* @author Mathieu Bastian
*/
public class DynamicProcessorPanel extends javax.swing.JPanel {
private double lastFrame = Double.POSITIVE_INFINITY;
public DynamicProcessorPanel() {
initComponents();
}
public void setup(DynamicProcessor processor) {
DynamicController dynamicController = Lookup.getDefault().lookup(DynamicController.class);
DynamicModel dynamicModel = dynamicController.getModel();
if (dynamicModel != null) {
lastFrame = dynamicModel.getMax();
}
lastFrameLabel.setText("None");
if (dynamicModel != null && !(dynamicModel.getMin() == Double.NEGATIVE_INFINITY && dynamicModel.getMax() == Double.POSITIVE_INFINITY)) {
//Select only the current time format
DynamicModel.TimeFormat timeFormat = dynamicModel.getTimeFormat();
if (timeFormat.equals(DynamicModel.TimeFormat.DATE)) {
dateRadio.setSelected(true);
timeStampRadio.setEnabled(false);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
try {
datePicker.setDate(sdf.parse(processor.getDate()));
} catch (Exception e) {
datePicker.setDate(new Date());
}
lastFrameLabel.setText(DynamicUtilities.getXMLDateStringFromDouble(lastFrame));
} else {
timeStampRadio.setSelected(true);
dateRadio.setEnabled(false);
lastFrameLabel.setText(Double.toString(lastFrame));
}
}
labelMatchingCheckbox.setSelected(processor.isLabelmatching());
}
public void unsetup(DynamicProcessor processor) {
processor.setDateMode(dateRadio.isSelected());
if (dateRadio.isSelected()) {
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String begin = sdf.format(datePicker.getDate());
processor.setDate(begin);
} catch (Exception e) {
//Exception catched later in processor
}
} else {
processor.setDate(timestampField.getText());
}
processor.setLabelmatching(labelMatchingCheckbox.isSelected());
}
public static ValidationPanel createValidationPanel(DynamicProcessorPanel innerPanel) {
ValidationPanel validationPanel = new ValidationPanel();
validationPanel.setInnerComponent(innerPanel);
ValidationGroup group = validationPanel.getValidationGroup();
final FullValidationListener fullValidationListener = new FullValidationListener(innerPanel);
group.add(fullValidationListener);
PropertyChangeListener listener = new PropertyChangeListener() {
@Override
public void propertyChange(PropertyChangeEvent e) {
if ("date".equals(e.getPropertyName())) {
fullValidationListener.event();
}
}
};
innerPanel.datePicker.addPropertyChangeListener(listener);
innerPanel.timestampField.getDocument().addDocumentListener(new DocumentListener() {
public void insertUpdate(DocumentEvent e) {
fullValidationListener.event();
}
public void removeUpdate(DocumentEvent e) {
fullValidationListener.event();
}
public void changedUpdate(DocumentEvent e) {
}
});
innerPanel.dateRadio.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fullValidationListener.event();
}
});
innerPanel.timeStampRadio.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
fullValidationListener.event();
}
});
return validationPanel;
}
private static class FullValidationListener extends ValidationListener {
FullValidator lastFrameValidator;
public FullValidationListener(DynamicProcessorPanel panel) {
lastFrameValidator = new FullValidator((panel));
}
@Override
protected boolean validate(Problems problems) {
return lastFrameValidator.validate(problems, "", "");
}
public void event() {
this.validate();
}
}
private static class FullValidator implements Validator<String> {
private DynamicProcessorPanel panel;
public FullValidator(DynamicProcessorPanel panel) {
this.panel = panel;
}
@Override
public boolean validate(Problems problems, String compName, String model) {
if (panel.dateRadio.isSelected()) {
if (panel.datePicker.getDate() == null) {
problems.add("The date can't be empty");
return false;
} else if (!Double.isInfinite(panel.lastFrame)) {
//Date
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String begin = sdf.format(panel.datePicker.getDate());
double d = DynamicUtilities.getDoubleFromXMLDateString(begin);
if (d <= panel.lastFrame) {
problems.add("The new date must be later than the last current date");
return false;
}
}
} else {
String t = panel.timestampField.getText();
if (t.isEmpty()) {
problems.add("The time stamp can't be empty");
return false;
}
try {
Double.parseDouble(panel.timestampField.getText());
} catch (Exception e) {
problems.add("The time stamp must be a number");
return false;
}
if (!Double.isInfinite(panel.lastFrame) && Double.parseDouble(panel.timestampField.getText()) <= panel.lastFrame) {
problems.add("The new time stamp must be greater than the last frame");
return false;
}
}
return true;
}
}
/** 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() {
bindingGroup = new org.jdesktop.beansbinding.BindingGroup();
buttongroup = new javax.swing.ButtonGroup();
header = new org.jdesktop.swingx.JXHeader();
dateRadio = new javax.swing.JRadioButton();
labelDate = new javax.swing.JLabel();
datePicker = new org.jdesktop.swingx.JXDatePicker();
timeStampRadio = new javax.swing.JRadioButton();
labelTime = new javax.swing.JLabel();
timestampField = new javax.swing.JTextField();
labelLastFrame = new javax.swing.JLabel();
lastFrameLabel = new javax.swing.JLabel();
labelMatchingCheckbox = new javax.swing.JCheckBox();
header.setDescription(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.header.description")); // NOI18N
header.setTitle(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.header.title")); // NOI18N
buttongroup.add(dateRadio);
dateRadio.setSelected(true);
dateRadio.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.dateRadio.text")); // NOI18N
labelDate.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.labelDate.text")); // NOI18N
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, dateRadio, org.jdesktop.beansbinding.ELProperty.create("${selected}"), labelDate, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, dateRadio, org.jdesktop.beansbinding.ELProperty.create("${selected}"), datePicker, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
buttongroup.add(timeStampRadio);
timeStampRadio.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.timeStampRadio.text")); // NOI18N
labelTime.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.labelTime.text")); // NOI18N
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, timeStampRadio, org.jdesktop.beansbinding.ELProperty.create("${selected}"), labelTime, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, timeStampRadio, org.jdesktop.beansbinding.ELProperty.create("${selected}"), timestampField, org.jdesktop.beansbinding.BeanProperty.create("enabled"));
bindingGroup.addBinding(binding);
labelLastFrame.setFont(labelLastFrame.getFont().deriveFont(labelLastFrame.getFont().getStyle() | java.awt.Font.BOLD));
labelLastFrame.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.labelLastFrame.text")); // NOI18N
labelMatchingCheckbox.setText(org.openide.util.NbBundle.getMessage(DynamicProcessorPanel.class, "DynamicProcessorPanel.labelMatchingCheckbox.text")); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(labelMatchingCheckbox)
.addContainerGap(285, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(labelLastFrame)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lastFrameLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 243, Short.MAX_VALUE)
.addGap(136, 136, 136))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(labelDate)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(dateRadio)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(labelTime)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(timestampField, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(timeStampRadio))
.addContainerGap(205, Short.MAX_VALUE))
.addComponent(header, javax.swing.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(header, javax.swing.GroupLayout.PREFERRED_SIZE, 91, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(labelMatchingCheckbox)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(labelLastFrame)
.addGap(18, 18, 18)
.addComponent(dateRadio))
.addComponent(lastFrameLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelDate)
.addComponent(datePicker, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(timeStampRadio)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(labelTime)
.addComponent(timestampField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(30, Short.MAX_VALUE))
);
bindingGroup.bind();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.ButtonGroup buttongroup;
private org.jdesktop.swingx.JXDatePicker datePicker;
private javax.swing.JRadioButton dateRadio;
private org.jdesktop.swingx.JXHeader header;
private javax.swing.JLabel labelDate;
private javax.swing.JLabel labelLastFrame;
private javax.swing.JCheckBox labelMatchingCheckbox;
private javax.swing.JLabel labelTime;
private javax.swing.JLabel lastFrameLabel;
private javax.swing.JRadioButton timeStampRadio;
private javax.swing.JTextField timestampField;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables
}
/*
Copyright 2008-2010 Gephi
Authors : Mathieu Bastian <mathieu.bastian@gephi.org>
Website : http://www.gephi.org
This file is part of Gephi.
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
Copyright 2011 Gephi Consortium. All rights reserved.
The contents of this file are subject to the terms of either the GNU
General Public License Version 3 only ("GPL") or the Common
Development and Distribution License("CDDL") (collectively, the
"License"). You may not use this file except in compliance with the
License. You can obtain a copy of the License at
http://gephi.org/about/legal/license-notice/
or /cddl-1.0.txt and /gpl-3.0.txt. See the License for the
specific language governing permissions and limitations under the
License. When distributing the software, include this License Header
Notice in each file and include the License files at
/cddl-1.0.txt and /gpl-3.0.txt. If applicable, add the following below the
License Header, with the fields enclosed by brackets [] replaced by
your own identifying information:
"Portions Copyrighted [year] [name of copyright owner]"
If you wish your version of this file to be governed by only the CDDL
or only the GPL Version 3, indicate your decision by adding
"[Contributor] elects to include this software in this distribution
under the [CDDL or GPL Version 3] license." If you do not indicate a
single choice of license, a recipient has the option to distribute
your version of this file under either the CDDL, the GPL Version 3 or
to extend the choice of license to its licensees as provided above.
However, if you add GPL Version 3 code and therefore, elected the GPL
Version 3 license, then the option applies only if the new code is
made subject to such option by the copyright holder.
Contributor(s):
Portions Copyrighted 2011 Gephi Consortium.
*/
package org.gephi.ui.processor.plugin;
import javax.swing.JPanel;
import org.gephi.io.importer.api.Container;
import org.gephi.io.processor.plugin.DynamicProcessor;
import org.gephi.io.processor.spi.Processor;
import org.gephi.io.processor.spi.ProcessorUI;
import org.openide.util.lookup.ServiceProvider;
/**
*
* @author Mathieu Bastian
*/
@ServiceProvider(service = ProcessorUI.class)
public class DynamicProcessorUI implements ProcessorUI {
private DynamicProcessor dynamicProcessor;
private DynamicProcessorSettings settings = new DynamicProcessorSettings();
private DynamicProcessorPanel panel;
@Override
public void setup(Processor processor) {
dynamicProcessor = (DynamicProcessor) processor;
settings.load(dynamicProcessor);
panel.setup(dynamicProcessor);
}
@Override
public JPanel getPanel() {
panel = new DynamicProcessorPanel();
return DynamicProcessorPanel.createValidationPanel(panel);
}
@Override
public void unsetup() {
panel.unsetup(dynamicProcessor);
settings.save(dynamicProcessor);
panel = null;
dynamicProcessor = null;
}
@Override
public boolean isUIFoProcessor(Processor processor) {
return processor instanceof DynamicProcessor;
}
@Override
public boolean isValid(Container container) {
return !container.isDynamicGraph();
}
private static class DynamicProcessorSettings {
private boolean dateMode = true;
private String date = "";
private boolean labelMatching = true;
private void save(DynamicProcessor dynamicProcessor) {
this.dateMode = dynamicProcessor.isDateMode();
this.date = dynamicProcessor.getDate();
this.labelMatching = dynamicProcessor.isLabelmatching();
}
private void load(DynamicProcessor dynamicProcessor) {
dynamicProcessor.setDateMode(dateMode);
dynamicProcessor.setDate(date);
dynamicProcessor.setLabelmatching(labelMatching);
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册