Search in sources :

Example 1 with PluginParametersSwingDialog

use of au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog in project constellation by constellation-app.

the class SaveTemplateAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Plugin plugin = PluginRegistry.get(GraphNodePluginRegistry.SAVE_TEMPLATE);
    final PluginParameters params = plugin.createParameters();
    while (true) {
        final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_SaveTemplateAction(), params);
        dialog.showAndWait();
        if (PluginParametersDialog.OK.equals(dialog.getResult())) {
            if (NewSchemaGraphAction.getTemplateNames().containsKey(params.getStringValue(SaveTemplatePlugin.TEMPLATE_NAME_PARAMETER_ID))) {
                final PluginParameters warningParams = new PluginParameters();
                final PluginParameter<StringParameterValue> warningMessageParam = StringParameterType.build("");
                warningMessageParam.setName("");
                warningMessageParam.setStringValue("Warning template with that name already exists - really overwrite?");
                StringParameterType.setIsLabel(warningMessageParam, true);
                warningParams.addParameter(warningMessageParam);
                final PluginParametersSwingDialog overwrite = new PluginParametersSwingDialog("Overwrite?", warningParams);
                overwrite.showAndWait();
                if (!PluginParametersDialog.OK.equals(overwrite.getResult())) {
                    continue;
                }
            }
            Future<?> f = PluginExecution.withPlugin(plugin).withParameters(params).executeLater(context.getGraph());
            PluginExecution.withPlugin(new SimplePlugin() {

                @Override
                public String getName() {
                    return "Update Template Menu";
                }

                @Override
                protected void execute(final PluginGraphs graphs, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
                    NewSchemaGraphAction.recreateTemplateMenuItems();
                }
            }).waitingFor(f).executeLater(null);
        }
        break;
    }
}
Also used : PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

Example 2 with PluginParametersSwingDialog

use of au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog in project constellation by constellation-app.

the class ManageTemplatesAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Plugin plugin = PluginRegistry.get(GraphNodePluginRegistry.MANAGE_TEMPLATES);
    final PluginParameters params = plugin.createParameters();
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_ManageTemplatesAction(), params);
    dialog.showAndWait();
    if (PluginParametersDialog.OK.equals(dialog.getResult())) {
        Future<?> f = PluginExecution.withPlugin(plugin).withParameters(params).executeLater(null);
        PluginExecution.withPlugin(new SimplePlugin() {

            @Override
            public String getName() {
                return "Update Template Menu";
            }

            @Override
            protected void execute(final PluginGraphs graphs, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
                NewSchemaGraphAction.recreateTemplateMenuItems();
            }
        }).waitingFor(f).executeLater(null);
    }
}
Also used : PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) PluginGraphs(au.gov.asd.tac.constellation.plugins.PluginGraphs) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

Example 3 with PluginParametersSwingDialog

use of au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog in project constellation by constellation-app.

the class TestNotificationsAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    // plugin notifications
    final Plugin plugin = new TestNotificationsPlugin();
    final PluginParameters pp = plugin.createParameters();
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_TestNotificationsAction(), pp);
    dialog.showAndWait();
    if (PluginParametersDialog.OK.equals(dialog.getResult())) {
        PluginExecution.withPlugin(plugin).withParameters(pp).executeLater(context.getGraph());
    }
    // NetBeans NotifyDisplayer options
    NotifyDisplayer.display(PLAIN_MESSAGE, NotifyDescriptor.PLAIN_MESSAGE);
    NotifyDisplayer.display(QUESTION_MESSAGE, NotifyDescriptor.QUESTION_MESSAGE);
    NotifyDisplayer.display(INFORMATION_MESSAGE, NotifyDescriptor.INFORMATION_MESSAGE);
    NotifyDisplayer.display(WARNING_MESSAGE, NotifyDescriptor.WARNING_MESSAGE);
    NotifyDisplayer.display(ERROR_MESSAGE, NotifyDescriptor.ERROR_MESSAGE);
    // Constellation Utility options
    Platform.runLater(() -> {
        NotifyDisplayer.displayAlert(DISPLAY_ALERT, PLAIN, PLAIN_MESSAGE, Alert.AlertType.NONE);
        NotifyDisplayer.displayAlert(DISPLAY_ALERT, INFORMATION, INFORMATION_MESSAGE, Alert.AlertType.INFORMATION);
        NotifyDisplayer.displayAlert(DISPLAY_ALERT, WARNING, WARNING_MESSAGE, Alert.AlertType.WARNING);
        NotifyDisplayer.displayAlert(DISPLAY_ALERT, ERROR, ERROR_MESSAGE, Alert.AlertType.ERROR);
        NotifyDisplayer.displayLargeAlert(DISPLAY_LARGE_ALERT, PLAIN, PLAIN_MESSAGE, Alert.AlertType.NONE);
        NotifyDisplayer.displayLargeAlert(DISPLAY_LARGE_ALERT, INFORMATION, INFORMATION_MESSAGE, Alert.AlertType.INFORMATION);
        NotifyDisplayer.displayLargeAlert(DISPLAY_LARGE_ALERT, WARNING, WARNING_MESSAGE, Alert.AlertType.WARNING);
        NotifyDisplayer.displayLargeAlert(DISPLAY_LARGE_ALERT, ERROR, ERROR_MESSAGE, Alert.AlertType.ERROR);
    });
}
Also used : PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 4 with PluginParametersSwingDialog

use of au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog in project constellation by constellation-app.

the class TestParameterBuildingAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final Plugin plugin = new TestParameterBuildingPlugin();
    final PluginParameters pp = plugin.createParameters();
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_TestParameterBuildingAction(), pp);
    dialog.showAndWait();
    if (PluginParametersDialog.OK.equals(dialog.getResult())) {
        PluginExecution.withPlugin(plugin).withParameters(pp).executeLater(context.getGraph());
    }
}
Also used : PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 5 with PluginParametersSwingDialog

use of au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog in project constellation by constellation-app.

the class BlazeUtilities method colorDialog.

/**
 * Display a dialog box to select a color. Option to save color as a preset
 * is represented by a checkbox. The preset will be saved in the first
 * instance of a free position, otherwise the last index of the presets will
 * be used and overridden.
 *
 * @param blazeColor The initial value of the color.
 *
 * @return a pair containing 1) if the user pressed OK and 2) the selected
 * blaze color.
 */
public static Pair<Boolean, ConstellationColor> colorDialog(final ConstellationColor blazeColor) {
    final PluginParameters dlgParams = new PluginParameters();
    final PluginParameter<ColorParameterValue> colorParam = ColorParameterType.build(COLOR_PARAMETER_ID);
    colorParam.setName("Color");
    colorParam.setDescription(BLAZE_COLOR_PARAMETER_ID);
    dlgParams.addParameter(colorParam);
    final PluginParameter<BooleanParameterValue> presetParam = BooleanParameterType.build(PRESET_PARAMETER_ID);
    presetParam.setName("Preset");
    presetParam.setDescription("Save as Preset");
    presetParam.setBooleanValue(false);
    dlgParams.addParameter(presetParam);
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(BLAZE_COLOR_PARAMETER_ID, dlgParams);
    dialog.showAndWait();
    final boolean isOk = PluginParametersDialog.OK.equals(dialog.getResult());
    ConstellationColor colorResult = blazeColor;
    if (isOk) {
        colorResult = dlgParams.getColorValue(COLOR_PARAMETER_ID);
        if (dlgParams.getBooleanValue(PRESET_PARAMETER_ID)) {
            savePreset(colorResult.getJavaColor());
        }
    }
    return new Pair<>(isOk, colorResult);
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Pair(javafx.util.Pair)

Aggregations

PluginParametersSwingDialog (au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog)10 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)9 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)4 Graph (au.gov.asd.tac.constellation.graph.Graph)2 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)2 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)2 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)2 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)2 File (java.io.File)2 IOException (java.io.IOException)2 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)1 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 GraphDataObject (au.gov.asd.tac.constellation.graph.file.GraphDataObject)1 GraphObjectUtilities (au.gov.asd.tac.constellation.graph.file.GraphObjectUtilities)1 SaveNotification (au.gov.asd.tac.constellation.graph.file.SaveNotification)1 GraphJsonWriter (au.gov.asd.tac.constellation.graph.file.io.GraphJsonWriter)1 NebulaDataObject (au.gov.asd.tac.constellation.graph.file.nebula.NebulaDataObject)1 AutosaveUtilities (au.gov.asd.tac.constellation.graph.file.save.AutosaveUtilities)1 GraphVisualManagerFactory (au.gov.asd.tac.constellation.graph.interaction.framework.GraphVisualManagerFactory)1