Search in sources :

Example 81 with Plugin

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

the class ScriptingUtilities method executePlugin.

/**
 * Lookup a plugin by name and execute it with default parameter values.
 *
 * @param graph The graph on which to execute the plugin.
 * @param pluginName The name of the plugin to execute.
 */
public void executePlugin(final SGraph graph, final String pluginName) {
    final Plugin plugin = PluginRegistry.get(pluginName);
    final PluginParameters parameters = new PluginParameters();
    parameters.appendParameters(plugin.createParameters());
    try {
        PluginExecution.withPlugin(plugin).withParameters(parameters).executeNow(graph.getGraph());
    } catch (final InterruptedException ex) {
        LOGGER.log(Level.SEVERE, ex, () -> pluginName + " was interrupted");
        Thread.currentThread().interrupt();
    } catch (final PluginException ex) {
        LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
    }
}
Also used : PluginException(au.gov.asd.tac.constellation.plugins.PluginException) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 82 with Plugin

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

the class PermanentMergeAction method execute.

/**
 * verify the number of selected nodes and then display the dialog to
 * confirm the attribute selection
 *
 * @param vxId id of the primary node
 *
 * @throws java.lang.InterruptedException if the process is interrupted
 * because it has been canceled.
 */
public void execute(final int vxId) throws InterruptedException {
    assert !SwingUtilities.isEventDispatchThread();
    final Graph graph = context.getGraph();
    // make sure that selected node is part of selection set
    if (vxId != Graph.NOT_FOUND) {
        WritableGraph wg = graph.getWritableGraph("merge add", false);
        try {
            int attrId = wg.getAttribute(GraphElementType.VERTEX, VisualConcept.VertexAttribute.SELECTED.getName());
            wg.setBooleanValue(attrId, vxId, true);
        } finally {
            wg.commit();
        }
    }
    final ArrayList<Integer> selections = getSelectedVertexCount(graph);
    if (selections.size() < 2) {
        final NotifyDescriptor nd = new NotifyDescriptor.Message(Bundle.ErrorInsufficientSelections(), NotifyDescriptor.ERROR_MESSAGE);
        nd.setTitle(Bundle.CTL_PermanentMergeAction());
        DialogDisplayer.getDefault().notify(nd);
    } else {
        final PermanentMergePanel pmp = new PermanentMergePanel(graph, selections, vxId);
        final DialogDescriptor dd = new DialogDescriptor(pmp, Bundle.CTL_PermanentMergeAction());
        final Object result = DialogDisplayer.getDefault().notify(dd);
        if (result == DialogDescriptor.OK_OPTION) {
            final Plugin plugin = PluginRegistry.get(VisualGraphPluginRegistry.PERMANENT_MERGE);
            final PluginParameters params = plugin.createParameters();
            pmp.setParameterValues(params);
            PluginExecution.withPlugin(plugin).withParameters(params).executeLater(graph);
        }
    }
}
Also used : NotifyDescriptor(org.openide.NotifyDescriptor) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) DialogDescriptor(org.openide.DialogDescriptor) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) WritableGraph(au.gov.asd.tac.constellation.graph.WritableGraph) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 83 with Plugin

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

the class HopActions method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final String command = e.getActionCommand();
    final Plugin plugin;
    final PluginParameters parameters;
    switch(command) {
        case HOP_OUT_HALF_ACTION:
            plugin = PluginRegistry.get(VisualGraphPluginRegistry.HOP_OUT);
            parameters = DefaultPluginParameters.getDefaultParameters(plugin);
            parameters.getParameters().get(HopOutPlugin.HOPS_PARAMETER_ID).setIntegerValue(HopUtilities.HOP_OUT_HALF);
            parameters.getParameters().get(HopOutPlugin.OUTGOING_PARAMETER_ID).setBooleanValue(outgoing.isSelected());
            parameters.getParameters().get(HopOutPlugin.INCOMING_PARAMETER_ID).setBooleanValue(incoming.isSelected());
            parameters.getParameters().get(HopOutPlugin.UNDIRECTED_PARAMETER_ID).setBooleanValue(undirected.isSelected());
            PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
            break;
        case HOP_OUT_ONE_ACTION:
            plugin = PluginRegistry.get(VisualGraphPluginRegistry.HOP_OUT);
            parameters = DefaultPluginParameters.getDefaultParameters(plugin);
            parameters.getParameters().get(HopOutPlugin.HOPS_PARAMETER_ID).setIntegerValue(HopUtilities.HOP_OUT_ONE);
            parameters.getParameters().get(HopOutPlugin.OUTGOING_PARAMETER_ID).setBooleanValue(outgoing.isSelected());
            parameters.getParameters().get(HopOutPlugin.INCOMING_PARAMETER_ID).setBooleanValue(incoming.isSelected());
            parameters.getParameters().get(HopOutPlugin.UNDIRECTED_PARAMETER_ID).setBooleanValue(undirected.isSelected());
            PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
            break;
        case HOP_OUT_FULL_ACTION:
            plugin = PluginRegistry.get(VisualGraphPluginRegistry.HOP_OUT);
            parameters = DefaultPluginParameters.getDefaultParameters(plugin);
            parameters.getParameters().get(HopOutPlugin.HOPS_PARAMETER_ID).setIntegerValue(HopUtilities.HOP_OUT_FULL);
            parameters.getParameters().get(HopOutPlugin.OUTGOING_PARAMETER_ID).setBooleanValue(outgoing.isSelected());
            parameters.getParameters().get(HopOutPlugin.INCOMING_PARAMETER_ID).setBooleanValue(incoming.isSelected());
            parameters.getParameters().get(HopOutPlugin.UNDIRECTED_PARAMETER_ID).setBooleanValue(undirected.isSelected());
            PluginExecution.withPlugin(plugin).withParameters(parameters).executeLater(graph);
            break;
        default:
            break;
    }
}
Also used : DefaultPluginParameters(au.gov.asd.tac.constellation.plugins.parameters.DefaultPluginParameters) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 84 with Plugin

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

the class CascadingQueryPlugin method run.

@Override
public final void run(final PluginGraphs graphs, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
    final Graph graph = graphs.getGraph();
    // If the graph no longer exists
    if (graph == null) {
        return;
    }
    // Make the graph appear busy
    interaction.setBusy(graph.getId(), true);
    try {
        // Make the progress bar appear nondeterminent
        try {
            interaction.setProgress(0, 0, "Executing child plugins", true);
            Map<Plugin, PluginParameters> childPlugins = getChildPlugins(parameters);
            PluginSynchronizer pluginSynchronizer = new PluginSynchronizer(childPlugins.size() + 1);
            for (final Entry<Plugin, PluginParameters> entry : childPlugins.entrySet()) {
                PluginExecution.withPlugin(entry.getKey()).withParameters(entry.getValue()).synchronizingOn(pluginSynchronizer).executeLater(graph);
            }
            // Wait at gate 0 for CascadingQueryPlugin to finish reading
            graphs.waitAtGate(0);
            // Wait for child plugins at gate 1 to finish reading
            pluginSynchronizer.waitForGate(1);
            // Wait for all plugins to finish reading and querying
            interaction.setProgress(0, 0, "Waiting For Other Plugins...", true);
            // Wait at gate 1 for any SimpleQueryPlugins to finish reading
            graphs.waitAtGate(1);
        } catch (DuplicateKeyException ex) {
            interaction.notify(PluginNotificationLevel.ERROR, ex.getMessage());
        } finally {
            interaction.setProgress(2, 1, "Finished", true);
        }
    } finally {
        interaction.setBusy(graph.getId(), false);
    }
}
Also used : PluginSynchronizer(au.gov.asd.tac.constellation.plugins.PluginSynchronizer) Graph(au.gov.asd.tac.constellation.graph.Graph) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) DuplicateKeyException(au.gov.asd.tac.constellation.graph.DuplicateKeyException) AbstractPlugin(au.gov.asd.tac.constellation.plugins.AbstractPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 85 with Plugin

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

the class TimelinePanel method updateExclusionState.

protected void updateExclusionState(final Graph graph, final long lowerTimeExtent, final long upperTimeExtent, final int exclusionState) {
    final Plugin updatePlugin = clusteringManager.new UpdateDimOrHidePlugin(lowerTimeExtent, upperTimeExtent, exclusionState, (vxMod, txMod) -> {
        expectedvxMod = vxMod;
        expectedtxMod = txMod;
    });
    PluginExecution.withPlugin(updatePlugin).executeLater(graph);
}
Also used : Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Aggregations

Plugin (au.gov.asd.tac.constellation.plugins.Plugin)85 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)52 Test (org.testng.annotations.Test)43 Graph (au.gov.asd.tac.constellation.graph.Graph)24 PluginException (au.gov.asd.tac.constellation.plugins.PluginException)19 PluginInteraction (au.gov.asd.tac.constellation.plugins.PluginInteraction)14 SimplePlugin (au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)10 PluginSynchronizer (au.gov.asd.tac.constellation.plugins.PluginSynchronizer)9 Future (java.util.concurrent.Future)9 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)8 WritableGraph (au.gov.asd.tac.constellation.graph.WritableGraph)8 PluginExecution (au.gov.asd.tac.constellation.plugins.PluginExecution)8 PluginGraphs (au.gov.asd.tac.constellation.plugins.PluginGraphs)8 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)7 CompletableFuture (java.util.concurrent.CompletableFuture)7 ExecutorService (java.util.concurrent.ExecutorService)7 ArrayList (java.util.ArrayList)6 Callable (java.util.concurrent.Callable)6 GraphWriteMethods (au.gov.asd.tac.constellation.graph.GraphWriteMethods)5 CopyToNewGraphPlugin (au.gov.asd.tac.constellation.graph.interaction.plugins.clipboard.CopyToNewGraphPlugin)5