Search in sources :

Example 16 with Dialog

use of java.awt.Dialog in project gephi by gephi.

the class DataLaboratoryHelper method executeAttributeColumnsManipulator.

/**
     * Prepares the dialog UI of a AttributeColumnsManipulator if it has one and executes the manipulator in a separate
     * Thread when the dialog is accepted or directly if there is no UI.
     * @param m AttributeColumnsManipulator
     * @param graphModel Graph model of the table
     * @param table Table of the column
     * @param column Column to manipulate
     */
public void executeAttributeColumnsManipulator(final AttributeColumnsManipulator m, final GraphModel graphModel, final Table table, final Column column) {
    if (m.canManipulateColumn(table, column)) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                final AttributeColumnsManipulatorUI ui = m.getUI(table, column);
                //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
                if (ui != null) {
                    final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
                    DialogControls dialogControls = new DialogControlsImpl(okButton);
                    ui.setup(m, graphModel, table, column, dialogControls);
                    JPanel settingsPanel = ui.getSettingsPanel();
                    DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            if (e.getSource().equals(okButton)) {
                                ui.unSetup();
                                executeAttributeColumnsManipulatorInOtherThread(m, table, column);
                            } else {
                                ui.unSetup();
                            }
                        }
                    });
                    dd.setOptions(new Object[] { okButton, DialogDescriptor.CANCEL_OPTION });
                    //All options close
                    dd.setClosingOptions(null);
                    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
                    dialog.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            ui.unSetup();
                        }
                    });
                    dialog.setVisible(true);
                } else {
                    executeAttributeColumnsManipulatorInOtherThread(m, table, column);
                }
            }
        });
    }
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) AttributeColumnsManipulatorUI(org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI) ActionListener(java.awt.event.ActionListener) Dialog(java.awt.Dialog) WindowEvent(java.awt.event.WindowEvent) DialogDescriptor(org.openide.DialogDescriptor) DialogControls(org.gephi.datalab.spi.DialogControls)

Example 17 with Dialog

use of java.awt.Dialog in project gephi by gephi.

the class DataLaboratoryHelper method executeManipulator.

/**
     * Prepares the dialog UI of a manipulator if it has one and executes the manipulator in a separate
     * Thread when the dialog is accepted or directly if there is no UI.
     * @param m Manipulator to execute
     */
public void executeManipulator(final Manipulator m) {
    if (m.canExecute()) {
        SwingUtilities.invokeLater(new Runnable() {

            @Override
            public void run() {
                final ManipulatorUI ui = m.getUI();
                //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
                if (ui != null) {
                    final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
                    DialogControls dialogControls = new DialogControlsImpl(okButton);
                    ui.setup(m, dialogControls);
                    JPanel settingsPanel = ui.getSettingsPanel();
                    DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {

                        @Override
                        public void actionPerformed(ActionEvent e) {
                            if (e.getSource().equals(okButton)) {
                                ui.unSetup();
                                executeManipulatorInOtherThread(m);
                            } else {
                                ui.unSetup();
                            }
                        }
                    });
                    dd.setOptions(new Object[] { okButton, DialogDescriptor.CANCEL_OPTION });
                    //All options close
                    dd.setClosingOptions(null);
                    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
                    dialog.addWindowListener(new WindowAdapter() {

                        @Override
                        public void windowClosing(WindowEvent e) {
                            ui.unSetup();
                        }
                    });
                    dialog.setVisible(true);
                } else {
                    executeManipulatorInOtherThread(m);
                }
            }
        });
    }
}
Also used : JPanel(javax.swing.JPanel) ActionEvent(java.awt.event.ActionEvent) JButton(javax.swing.JButton) WindowAdapter(java.awt.event.WindowAdapter) ActionListener(java.awt.event.ActionListener) AttributeColumnsManipulatorUI(org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI) ManipulatorUI(org.gephi.datalab.spi.ManipulatorUI) Dialog(java.awt.Dialog) WindowEvent(java.awt.event.WindowEvent) DialogDescriptor(org.openide.DialogDescriptor) DialogControls(org.gephi.datalab.spi.DialogControls)

Example 18 with Dialog

use of java.awt.Dialog in project gephi by gephi.

the class DataLaboratoryHelper method showAttributeRowsMergeStrategyUIDialog.

/**
     * This method shows the UI of an AttributeRowsMergeStrategy if it is provided and the AttributeRowsMergeStrategy can be executed.
     * These UI only configures (calls unSetup) the AttributeRowsMergeStrategy if the dialog is accepted,
     * and it does not execute the AttributeRowsMergeStrategy.
     * @param m AttributeRowsMergeStrategy
     * @return True if the AttributeRowsMergeStrategy UI is provided
     */
public boolean showAttributeRowsMergeStrategyUIDialog(final AttributeRowsMergeStrategy m) {
    final ManipulatorUI ui = m.getUI();
    //Show a dialog for the manipulator UI if it provides one. If not, execute the manipulator directly:
    if (ui != null && m.canExecute()) {
        final JButton okButton = new JButton(NbBundle.getMessage(DataLaboratoryHelper.class, "DataLaboratoryHelper.ui.okButton.text"));
        DialogControls dialogControls = new DialogControlsImpl(okButton);
        ui.setup(m, dialogControls);
        JPanel settingsPanel = ui.getSettingsPanel();
        DialogDescriptor dd = new DialogDescriptor(settingsPanel, NbBundle.getMessage(DataLaboratoryHelper.class, "SettingsPanel.title", ui.getDisplayName()), ui.isModal(), new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                if (e.getSource().equals(okButton)) {
                    ui.unSetup();
                }
            }
        });
        dd.setOptions(new Object[] { okButton, DialogDescriptor.CANCEL_OPTION });
        //All options close
        dd.setClosingOptions(null);
        Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
        dialog.setVisible(true);
        return true;
    }
    return false;
}
Also used : JPanel(javax.swing.JPanel) ActionListener(java.awt.event.ActionListener) AttributeColumnsManipulatorUI(org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI) ManipulatorUI(org.gephi.datalab.spi.ManipulatorUI) ActionEvent(java.awt.event.ActionEvent) Dialog(java.awt.Dialog) JButton(javax.swing.JButton) DialogDescriptor(org.openide.DialogDescriptor) DialogControls(org.gephi.datalab.spi.DialogControls)

Example 19 with Dialog

use of java.awt.Dialog in project gephi by gephi.

the class ImportWizard method actionPerformed.

@Override
public void actionPerformed(ActionEvent e) {
    WizardIterator wizardIterator = new WizardIterator();
    WizardDescriptor wizardDescriptor = new WizardDescriptor(wizardIterator);
    wizardDescriptor.setTitleFormat(new MessageFormat("{0} ({1})"));
    wizardDescriptor.setTitle(NbBundle.getMessage(getClass(), "ImportWizard.wizard.title"));
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        ImporterWizardUI wizardUI = wizardIterator.getCurrentWizardUI();
        //Get Importer
        WizardImporter importer = null;
        for (WizardImporterBuilder wizardBuilder : Lookup.getDefault().lookupAll(WizardImporterBuilder.class)) {
            WizardImporter im = wizardBuilder.buildImporter();
            if (wizardUI.isUIForImporter(im)) {
                importer = im;
            }
        }
        if (importer == null) {
            NotifyDescriptor.Message msg = new NotifyDescriptor.Message(NbBundle.getMessage(getClass(), "ImportWizard.error_no_matching_importer"), NotifyDescriptor.WARNING_MESSAGE);
            DialogDisplayer.getDefault().notify(msg);
            return;
        }
        //Unsetup
        wizardIterator.unsetupPanels(importer);
        ImportControllerUI importControllerUI = Lookup.getDefault().lookup(ImportControllerUI.class);
        importControllerUI.importWizard(importer);
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) MessageFormat(java.text.MessageFormat) Dialog(java.awt.Dialog) WizardImporter(org.gephi.io.importer.spi.WizardImporter) ImportControllerUI(org.gephi.desktop.importer.api.ImportControllerUI) WizardDescriptor(org.openide.WizardDescriptor) ImporterWizardUI(org.gephi.io.importer.spi.ImporterWizardUI) WizardImporterBuilder(org.gephi.io.importer.spi.WizardImporterBuilder)

Example 20 with Dialog

use of java.awt.Dialog in project gephi by gephi.

the class ImportCSVUIWizardAction method performAction.

@Override
public void performAction() {
    wizardDescriptor = new WizardDescriptor(getPanels());
    step1.setWizardDescriptor(wizardDescriptor);
    step2.setWizardDescriptor(wizardDescriptor);
    // {0} will be replaced by WizardDesriptor.Panel.getComponent().getName()
    wizardDescriptor.setTitleFormat(new MessageFormat("{0}"));
    wizardDescriptor.setTitle(getName());
    Dialog dialog = DialogDisplayer.getDefault().createDialog(wizardDescriptor);
    dialog.setVisible(true);
    dialog.toFront();
    boolean cancelled = wizardDescriptor.getValue() != WizardDescriptor.FINISH_OPTION;
    if (!cancelled) {
        //General parameters:
        File file = (File) wizardDescriptor.getProperty("file");
        Character separator = (Character) wizardDescriptor.getProperty("separator");
        Charset charset = (Charset) wizardDescriptor.getProperty("charset");
        String[] columnNames = (String[]) wizardDescriptor.getProperty("columns-names");
        Class[] columnTypes = (Class[]) wizardDescriptor.getProperty("columns-types");
        //Nodes import parameters:
        Boolean assignNewNodeIds = (Boolean) wizardDescriptor.getProperty("assign-new-node-ids");
        //Edges import parameters:
        Boolean createNewNodes = (Boolean) wizardDescriptor.getProperty("create-new-nodes");
        Graph graph = Lookup.getDefault().lookup(GraphController.class).getGraphModel().getGraph();
        AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
        DataTablesController dtc = Lookup.getDefault().lookup(DataTablesController.class);
        dtc.setAutoRefreshEnabled(false);
        try {
            switch((Mode) wizardDescriptor.getProperty("mode")) {
                case NODES_TABLE:
                    ac.importCSVToNodesTable(graph, file, separator, charset, columnNames, columnTypes, assignNewNodeIds);
                    break;
                case EDGES_TABLE:
                    ac.importCSVToEdgesTable(graph, file, separator, charset, columnNames, columnTypes, createNewNodes);
                    break;
            }
            dtc.refreshCurrentTable();
        } catch (Exception e) {
            Logger.getLogger("").log(Level.SEVERE, null, e);
        } finally {
            dtc.setAutoRefreshEnabled(true);
        }
    }
    step1.unSetup();
    step2.unSetup();
}
Also used : MessageFormat(java.text.MessageFormat) Charset(java.nio.charset.Charset) WizardDescriptor(org.openide.WizardDescriptor) Graph(org.gephi.graph.api.Graph) Dialog(java.awt.Dialog) AttributeColumnsController(org.gephi.datalab.api.AttributeColumnsController) File(java.io.File) DataTablesController(org.gephi.datalab.api.datatables.DataTablesController)

Aggregations

Dialog (java.awt.Dialog)34 Frame (java.awt.Frame)19 Window (java.awt.Window)8 JButton (javax.swing.JButton)5 Container (java.awt.Container)4 Graphics (java.awt.Graphics)4 Panel (java.awt.Panel)4 JInternalFrame (javax.swing.JInternalFrame)4 JPanel (javax.swing.JPanel)4 ElementNotFoundException (com.axway.ats.uiengine.exceptions.ElementNotFoundException)3 BorderLayout (java.awt.BorderLayout)3 Point (java.awt.Point)3 ActionEvent (java.awt.event.ActionEvent)3 ActionListener (java.awt.event.ActionListener)3 WindowAdapter (java.awt.event.WindowAdapter)3 WindowEvent (java.awt.event.WindowEvent)3 DialogControls (org.gephi.datalab.spi.DialogControls)3 AttributeColumnsManipulatorUI (org.gephi.datalab.spi.columns.AttributeColumnsManipulatorUI)3 DialogDescriptor (org.openide.DialogDescriptor)3 Button (java.awt.Button)2