use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultPluginEnvironmentNGTest method testExecutePluginLaterWithNullAsync.
/**
* Test of executePluginLater method, of class DefaultPluginEnvironment.
*/
@Test
public void testExecutePluginLaterWithNullAsync() throws ExecutionException, InterruptedException {
System.out.println("executePluginLater");
Graph graph = mock(Graph.class);
Plugin plugin = mock(Plugin.class);
PluginParameters parameters = mock(PluginParameters.class);
boolean interactive = false;
PluginSynchronizer synchronizer = mock(PluginSynchronizer.class);
List<Future<?>> async = null;
final ExecutorService executorService = mock(ExecutorService.class);
DefaultPluginEnvironment instance = spy(new DefaultPluginEnvironment());
doReturn(executorService).when(instance).getPluginExecutor();
when(executorService.submit(any(Callable.class))).thenAnswer(iom -> {
final Callable callable = iom.getArgument(0);
callable.call();
return CompletableFuture.completedFuture(null);
});
Object expResult = null;
Future future = instance.executePluginLater(graph, plugin, parameters, interactive, async, synchronizer);
Object result = future.get();
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.Plugin 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);
}
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class HistogramTopComponent method filterOnSelection.
void filterOnSelection() {
if (currentGraph != null) {
Plugin plugin = new HistogramFilterOnSelectionPlugin();
PluginParameters params = plugin.createParameters();
params.getParameters().get(HistogramFilterOnSelectionPlugin.ELEMENT_TYPE_PARAMETER_ID).setObjectValue(new ElementTypeParameterValue(currentHistogramState.getElementType()));
PluginExecution.withPlugin(plugin).withParameters(params).executeLater(currentGraph);
}
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultInteractionEventHandler method performBoxSelection.
/**
* Performs a selection based on a given start and end point.
*
* If the start and end point are equal, a point selection is performed
* based on the hit tester.
*
* If the start and end point differ, a box selection is performed with the
* two points representing diagonally opposite corners of the box.
*
* In the latter case, the 2d box is actually converted to a 3d frustrum in
* order to make the correct selection on the 3 dimensional graph.
*
* @param selectTo the point where selection ends
* @param selectFrom the point where selection begins.
* @param appendSelection whether or not the selection will be appended to
* the current selection
* @param toggleSelection whether or not the selection will toggle the
* current selection. Note that if appendSelection is true, this parameter
* has no effect.
*/
private void performBoxSelection(final GraphReadMethods rg, final Point selectTo, final Point selectFrom, final boolean appendSelection, final boolean toggleSelection) {
if (selectTo.equals(selectFrom)) {
return;
}
// Sort the press/release coordinates to look like a drag from top-left to bottom-right: pressed<=released.
Point bottomRight = new Point();
if (selectTo.x < selectFrom.x) {
bottomRight.x = selectFrom.x;
selectFrom.x = selectTo.x;
} else {
bottomRight.x = selectTo.x;
}
if (selectTo.y < selectFrom.y) {
bottomRight.y = selectFrom.y;
selectFrom.y = selectTo.y;
} else {
bottomRight.y = selectTo.y;
}
final float[] boxCameraCoordinates = visualInteraction.windowBoxToCameraBox(selectFrom.x, bottomRight.x, selectFrom.y, bottomRight.y);
Plugin plugin = new BoxSelectionPlugin(appendSelection, toggleSelection, VisualGraphUtilities.getCamera(rg), boxCameraCoordinates);
PluginExecution.withPlugin(plugin).executeLater(graph);
}
use of au.gov.asd.tac.constellation.plugins.Plugin in project constellation by constellation-app.
the class DefaultInteractionEventHandler method performPointSelection.
private void performPointSelection(final boolean toggleSelection, final boolean clearSelection, final GraphElementType elementType, final int elementId) {
final IntArray vxIds = new IntArray();
final IntArray txIds = new IntArray();
switch(elementType) {
case VERTEX:
vxIds.add(elementId);
break;
case TRANSACTION:
txIds.add(elementId);
break;
default:
break;
}
if (!(vxIds.isEmpty() && txIds.isEmpty() && !clearSelection)) {
Plugin selectPoint = new PointSelectionPlugin(vxIds, txIds, toggleSelection, clearSelection);
PluginExecution.withPlugin(selectPoint).executeLater(graph);
}
}
Aggregations