Search in sources :

Example 21 with Plugin

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);
}
Also used : PluginSynchronizer(au.gov.asd.tac.constellation.plugins.PluginSynchronizer) Graph(au.gov.asd.tac.constellation.graph.Graph) ExecutorService(java.util.concurrent.ExecutorService) CompletableFuture(java.util.concurrent.CompletableFuture) Future(java.util.concurrent.Future) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) Callable(java.util.concurrent.Callable) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) Test(org.testng.annotations.Test)

Example 22 with Plugin

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);
    }
}
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 23 with Plugin

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);
    }
}
Also used : ElementTypeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ElementTypeParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SimpleEditPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleEditPlugin) SimpleReadPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleReadPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin)

Example 24 with Plugin

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);
}
Also used : Point(java.awt.Point) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) CreateTransactionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin) FreeformSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) CreateVertexPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

Example 25 with Plugin

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);
    }
}
Also used : IntArray(au.gov.asd.tac.constellation.utilities.graphics.IntArray) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) PointSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.PointSelectionPlugin) BoxSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.BoxSelectionPlugin) CreateTransactionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateTransactionPlugin) FreeformSelectionPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.select.FreeformSelectionPlugin) Plugin(au.gov.asd.tac.constellation.plugins.Plugin) CreateVertexPlugin(au.gov.asd.tac.constellation.graph.interaction.plugins.draw.CreateVertexPlugin) SimplePlugin(au.gov.asd.tac.constellation.plugins.templates.SimplePlugin)

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