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);
}
}
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);
}
}
}
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;
}
}
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);
}
}
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);
}
Aggregations