Search in sources :

Example 96 with ChangeEvent

use of javax.swing.event.ChangeEvent in project gephi by gephi.

the class RankingSizeTransformerPanel method setup.

public void setup(RankingFunction function) {
    sizeTransformer = (RankingNodeSizeTransformer) function.getTransformer();
    final String MIN_SIZE = "RankingSizeTransformerPanel_" + sizeTransformer.getClass().getSimpleName() + "_min";
    final String MAX_SIZE = "RankingSizeTransformerPanel_" + sizeTransformer.getClass().getSimpleName() + "_max";
    float minSizeStart = NbPreferences.forModule(RankingSizeTransformerPanel.class).getFloat(MIN_SIZE, sizeTransformer.getMinSize());
    float maxSizeStart = NbPreferences.forModule(RankingSizeTransformerPanel.class).getFloat(MAX_SIZE, sizeTransformer.getMaxSize());
    sizeTransformer.setMinSize(minSizeStart);
    sizeTransformer.setMaxSize(maxSizeStart);
    minSize.setValue(minSizeStart);
    maxSize.setValue(maxSizeStart);
    minSize.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            sizeTransformer.setMinSize((Float) minSize.getValue());
            NbPreferences.forModule(RankingSizeTransformerPanel.class).putFloat(MIN_SIZE, (Float) minSize.getValue());
        }
    });
    maxSize.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            sizeTransformer.setMaxSize((Float) maxSize.getValue());
            NbPreferences.forModule(RankingSizeTransformerPanel.class).putFloat(MAX_SIZE, (Float) maxSize.getValue());
        }
    });
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ChangeListener(javax.swing.event.ChangeListener)

Example 97 with ChangeEvent

use of javax.swing.event.ChangeEvent in project gephi by gephi.

the class ConvertColumnToDynamicTimestampsUI method buildValidationPanel.

private void buildValidationPanel() {
    validationPanel = new ValidationPanel();
    validationPanel.setInnerComponent(this);
    ValidationGroup group = validationPanel.getValidationGroup();
    group.add(titleTextField, new ColumnTitleValidator(table));
    group.add(timestampText, new IntervalBoundValidator());
    validationPanel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            dialogControls.setOkButtonEnabled(!validationPanel.isProblem());
        }
    });
}
Also used : ColumnTitleValidator(org.gephi.ui.utils.ColumnTitleValidator) ChangeEvent(javax.swing.event.ChangeEvent) ValidationGroup(org.netbeans.validation.api.ui.ValidationGroup) IntervalBoundValidator(org.gephi.ui.utils.IntervalBoundValidator) ChangeListener(javax.swing.event.ChangeListener) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel)

Example 98 with ChangeEvent

use of javax.swing.event.ChangeEvent in project gephi by gephi.

the class ConvertColumnToDynamicUI method buildValidationPanel.

private void buildValidationPanel() {
    validationPanel = new ValidationPanel();
    validationPanel.setInnerComponent(this);
    ValidationGroup group = validationPanel.getValidationGroup();
    group.add(titleTextField, new ColumnTitleValidator(table));
    group.add(intervalStartText, new IntervalBoundValidator());
    group.add(intervalEndText, new IntervalBoundValidator(intervalStartText));
    validationPanel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            dialogControls.setOkButtonEnabled(!validationPanel.isProblem());
        }
    });
}
Also used : ColumnTitleValidator(org.gephi.ui.utils.ColumnTitleValidator) ChangeEvent(javax.swing.event.ChangeEvent) ValidationGroup(org.netbeans.validation.api.ui.ValidationGroup) IntervalBoundValidator(org.gephi.ui.utils.IntervalBoundValidator) ChangeListener(javax.swing.event.ChangeListener) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel)

Example 99 with ChangeEvent

use of javax.swing.event.ChangeEvent in project gephi by gephi.

the class EqualStringPanel method createValidationPanel.

public static ValidationPanel createValidationPanel(final EqualStringPanel innerPanel) {
    final ValidationPanel validationPanel = new ValidationPanel();
    validationPanel.setInnerComponent(innerPanel);
    ValidationGroup group = validationPanel.getValidationGroup();
    validationPanel.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            innerPanel.okButton.setEnabled(!validationPanel.isProblem());
        }
    });
    //Node field
    group.add(innerPanel.textField, new RegexValidator(innerPanel));
    return validationPanel;
}
Also used : ChangeEvent(javax.swing.event.ChangeEvent) ValidationGroup(org.netbeans.validation.api.ui.ValidationGroup) ChangeListener(javax.swing.event.ChangeListener) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel)

Example 100 with ChangeEvent

use of javax.swing.event.ChangeEvent in project gephi by gephi.

the class DesktopImportControllerUI method importStream.

@Override
public void importStream(final InputStream stream, String importerName) {
    try {
        final FileImporter importer = controller.getFileImporter(importerName);
        if (importer == null) {
            NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "DesktopImportControllerUI.error_no_matching_file_importer"), NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notify(msg);
            return;
        }
        ImporterUI ui = controller.getUI(importer);
        if (ui != null) {
            String title = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.file.ui.dialog.title", ui.getDisplayName());
            JPanel panel = ui.getPanel();
            FileImporter[] fi = (FileImporter[]) Array.newInstance(importer.getClass(), 1);
            fi[0] = importer;
            ui.setup(fi);
            final DialogDescriptor dd = new DialogDescriptor(panel, title);
            if (panel instanceof ValidationPanel) {
                ValidationPanel vp = (ValidationPanel) panel;
                vp.addChangeListener(new ChangeListener() {

                    @Override
                    public void stateChanged(ChangeEvent e) {
                        dd.setValid(!((ValidationPanel) e.getSource()).isProblem());
                    }
                });
            }
            Object result = DialogDisplayer.getDefault().notify(dd);
            if (!result.equals(NotifyDescriptor.OK_OPTION)) {
                ui.unsetup(false);
                return;
            }
            ui.unsetup(true);
        }
        LongTask task = null;
        if (importer instanceof LongTask) {
            task = (LongTask) importer;
        }
        //Execute task
        final String containerSource = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.streamSource", importerName);
        String taskName = NbBundle.getMessage(DesktopImportControllerUI.class, "DesktopImportControllerUI.taskName", containerSource);
        executor.execute(task, new Runnable() {

            @Override
            public void run() {
                try {
                    Container container = controller.importFile(stream, importer);
                    if (container != null) {
                        container.setSource(containerSource);
                        finishImport(container);
                    }
                } catch (Exception ex) {
                    throw new RuntimeException(ex);
                }
            }
        }, taskName, errorHandler);
    } catch (Exception ex) {
        Logger.getLogger("").log(Level.WARNING, "", ex);
    }
}
Also used : ImporterUI(org.gephi.io.importer.spi.ImporterUI) JPanel(javax.swing.JPanel) FileImporter(org.gephi.io.importer.spi.FileImporter) ValidationPanel(org.netbeans.validation.api.ui.ValidationPanel) InvocationTargetException(java.lang.reflect.InvocationTargetException) IOException(java.io.IOException) NotifyDescriptor(org.openide.NotifyDescriptor) Container(org.gephi.io.importer.api.Container) ChangeEvent(javax.swing.event.ChangeEvent) LongTask(org.gephi.utils.longtask.spi.LongTask) DialogDescriptor(org.openide.DialogDescriptor) ChangeListener(javax.swing.event.ChangeListener) FileObject(org.openide.filesystems.FileObject)

Aggregations

ChangeEvent (javax.swing.event.ChangeEvent)164 ChangeListener (javax.swing.event.ChangeListener)130 JPanel (javax.swing.JPanel)45 ActionEvent (java.awt.event.ActionEvent)43 ActionListener (java.awt.event.ActionListener)38 JLabel (javax.swing.JLabel)30 GridBagConstraints (java.awt.GridBagConstraints)18 JButton (javax.swing.JButton)17 BorderLayout (java.awt.BorderLayout)16 JCheckBox (javax.swing.JCheckBox)16 JSpinner (javax.swing.JSpinner)16 SpinnerNumberModel (javax.swing.SpinnerNumberModel)16 GridBagLayout (java.awt.GridBagLayout)15 Dimension (java.awt.Dimension)14 PropertyChangeEvent (java.beans.PropertyChangeEvent)14 JSlider (javax.swing.JSlider)14 Insets (java.awt.Insets)13 ValidationPanel (org.netbeans.validation.api.ui.ValidationPanel)13 IOException (java.io.IOException)12 JTabbedPane (javax.swing.JTabbedPane)12