Search in sources :

Example 1 with QueryPhasePane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane in project constellation by constellation-app.

the class DataAccessTabPane method storeParameterValues.

/**
 * Store current parameter values for all tabs and plug-ins in the
 * {@link RecentParameterValues} repository. It will store both global and
 * plugin parameters.
 */
protected void storeParameterValues() {
    getTabPane().getTabs().parallelStream().forEach(tab -> {
        final QueryPhasePane pluginPane = getQueryPhasePane(tab);
        // Store global parameters
        pluginPane.getGlobalParametersPane().getParams().getParameters().entrySet().stream().filter(param -> param.getValue().getStringValue() != null && !param.getValue().getStringValue().isEmpty()).forEach(param -> RecentParameterValues.storeRecentValue(param.getKey(), param.getValue().getStringValue()));
        // Store data access plugin parameters
        pluginPane.getDataAccessPanes().stream().map(DataSourceTitledPane::getParameters).filter(Objects::nonNull).map(PluginParameters::getParameters).map(Map::entrySet).flatMap(Collection::stream).filter(param -> param.getValue().getObjectValue() != null).forEach(param -> {
            if (!param.getValue().getType().toString().contains(LOCAL_DATE_PARAMETER_TYPE)) {
                RecentParameterValues.storeRecentValue(param.getKey(), param.getValue().getStringValue());
            } else {
                RecentParameterValues.storeRecentValue(param.getKey(), param.getValue().getObjectValue().toString());
            }
        });
    });
}
Also used : EventHandler(javafx.event.EventHandler) CoreGlobalParameters(au.gov.asd.tac.constellation.views.dataaccess.CoreGlobalParameters) MouseEvent(javafx.scene.input.MouseEvent) CompletableFuture(java.util.concurrent.CompletableFuture) DataSourceTitledPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane) Function(java.util.function.Function) Side(javafx.geometry.Side) StringUtils(org.apache.commons.lang3.StringUtils) Level(java.util.logging.Level) Future(java.util.concurrent.Future) ScrollPane(javafx.scene.control.ScrollPane) TabPane(javafx.scene.control.TabPane) ListChangeListener(javafx.collections.ListChangeListener) DataAccessPlugin(au.gov.asd.tac.constellation.views.dataaccess.plugins.DataAccessPlugin) WaitForQueriesToCompleteTask(au.gov.asd.tac.constellation.views.dataaccess.tasks.WaitForQueriesToCompleteTask) Map(java.util.Map) DateTimeRange(au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRange) Tooltip(javafx.scene.control.Tooltip) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) TextField(javafx.scene.control.TextField) Label(javafx.scene.control.Label) RecentParameterValues(au.gov.asd.tac.constellation.plugins.parameters.RecentParameterValues) DataAccessPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane) SeparatorConstants(au.gov.asd.tac.constellation.utilities.text.SeparatorConstants) Collection(java.util.Collection) DataAccessPaneState(au.gov.asd.tac.constellation.views.dataaccess.api.DataAccessPaneState) Event(javafx.event.Event) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Objects(java.util.Objects) List(java.util.List) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) Tab(javafx.scene.control.Tab) Optional(java.util.Optional) ObservableValue(javafx.beans.value.ObservableValue) ContentDisplay(javafx.scene.control.ContentDisplay) DataSourceTitledPane(au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) Collection(java.util.Collection) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 2 with QueryPhasePane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane in project constellation by constellation-app.

the class DataAccessTabPane method updateTabMenu.

/**
 * Enable or disable the items in the contextual menu for a tab. There are
 * two types of menu items in the context menu. Menu items relating specifically
 * to plugins and menu items relating specifically to the graph.
 * <p/>
 * Plugin menu items will be enabled if the tab has enabled plugins.
 * <p/>
 * Graph menu items will be enabled if the tab has enabled plugins and the
 * execute button is fully enabled.
 *
 * @param tab the tab to update the menu item status on
 * @param enabled true if the menu items are to be enabled, false otherwise
 * @see #updateTabMenus()
 */
protected void updateTabMenu(final Tab tab, final boolean graphDependentMenuItemsEnabled, final boolean pluginDependentMenuItemsEnabled) {
    final QueryPhasePane queryPhasePane = getQueryPhasePane(tab);
    queryPhasePane.enableGraphDependentMenuItems(graphDependentMenuItemsEnabled);
    queryPhasePane.enablePluginDependentMenuItems(pluginDependentMenuItemsEnabled);
}
Also used : QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)

Example 3 with QueryPhasePane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane in project constellation by constellation-app.

the class ButtonToolbarNGTest method verifyAddTabAction.

/**
 * Verifies that the add button creates a new tab using the global plugin
 * configuration from the last tab if available.
 *
 * @param addButton the button to verify
 */
private void verifyAddTabAction(final Button addButton) {
    final ActionEvent actionEvent = mock(ActionEvent.class);
    final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
    when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
    // Set up the current tab pane. The code will take the last tab, i.e. tab2
    final Tab tab1 = mock(Tab.class);
    final Tab tab2 = mock(Tab.class);
    final ObservableList<Tab> tabs = FXCollections.observableArrayList(tab1, tab2);
    doReturn(tabs).when(buttonToolbar).getTabs();
    final QueryPhasePane queryPhasePane = mock(QueryPhasePane.class);
    final GlobalParametersPane globalParametersPane = mock(GlobalParametersPane.class);
    final PluginParameters pluginParameters = mock(PluginParameters.class);
    when(queryPhasePane.getGlobalParametersPane()).thenReturn(globalParametersPane);
    when(globalParametersPane.getParams()).thenReturn(pluginParameters);
    try (final MockedStatic<DataAccessTabPane> tabPaneMockedStatic = Mockito.mockStatic(DataAccessTabPane.class)) {
        // There will be no interaction with tab1 so only mock out tab2
        tabPaneMockedStatic.when(() -> DataAccessTabPane.getQueryPhasePane(tab2)).thenReturn(queryPhasePane);
        // Run the action
        addButton.getOnAction().handle(actionEvent);
        // Verify a new tab is created with the existing last tab's parameters
        verify(dataAccessTabPane).newTab(pluginParameters, "");
        verify(actionEvent).consume();
    }
}
Also used : Tab(javafx.scene.control.Tab) QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) ActionEvent(javafx.event.ActionEvent) GlobalParametersPane(au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 4 with QueryPhasePane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane in project constellation by constellation-app.

the class ButtonToolbarNGTest method manageFavourites_no_plugins_selected.

@Test
public void manageFavourites_no_plugins_selected() {
    final DataAccessTabPane dataAccessTabPane = mock(DataAccessTabPane.class);
    final QueryPhasePane currentQueryPhasePane = mock(QueryPhasePane.class);
    when(dataAccessPane.getDataAccessTabPane()).thenReturn(dataAccessTabPane);
    when(dataAccessTabPane.getQueryPhasePaneOfCurrentTab()).thenReturn(currentQueryPhasePane);
    when(currentQueryPhasePane.getDataAccessPanes()).thenReturn(List.of());
    try (final MockedStatic<NotifyDisplayer> notifyDisplayerMockedStatic = Mockito.mockStatic(NotifyDisplayer.class)) {
        buttonToolbar.manageFavourites();
        notifyDisplayerMockedStatic.verify(() -> NotifyDisplayer.display("No plugins selected.", NotifyDescriptor.WARNING_MESSAGE));
    }
}
Also used : QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) NotifyDisplayer(au.gov.asd.tac.constellation.utilities.gui.NotifyDisplayer) Test(org.testng.annotations.Test)

Example 5 with QueryPhasePane

use of au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane in project constellation by constellation-app.

the class DataAccessTabPaneNGTest method newTab_name_specified.

@Test
public void newTab_name_specified() {
    try (final MockedConstruction<QueryPhasePane> mockedQueryPhasePane = Mockito.mockConstruction(QueryPhasePane.class, (queryPhasePaneMock, cntxt) -> {
        final List<Object> expectedArgs = new ArrayList<>();
        expectedArgs.add(plugins);
        expectedArgs.add(dataAccessPane);
        expectedArgs.add(null);
        assertEquals(cntxt.arguments(), expectedArgs);
    })) {
        doNothing().when(dataAccessTabPane).newTab(any(QueryPhasePane.class), any(String.class));
        final QueryPhasePane pane = dataAccessTabPane.newTab("new name");
        assertNotNull(pane);
        assertEquals(mockedQueryPhasePane.constructed().size(), 1);
        assertSame(mockedQueryPhasePane.constructed().get(0), pane);
        verify(dataAccessTabPane).newTab(pane, "new name");
    }
}
Also used : QueryPhasePane(au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

QueryPhasePane (au.gov.asd.tac.constellation.views.dataaccess.panes.QueryPhasePane)31 Tab (javafx.scene.control.Tab)20 Test (org.testng.annotations.Test)19 DataSourceTitledPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataSourceTitledPane)12 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)11 GlobalParametersPane (au.gov.asd.tac.constellation.views.dataaccess.panes.GlobalParametersPane)9 ScrollPane (javafx.scene.control.ScrollPane)9 TabPane (javafx.scene.control.TabPane)9 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)8 DataAccessPane (au.gov.asd.tac.constellation.views.dataaccess.panes.DataAccessPane)7 DataAccessTabPane (au.gov.asd.tac.constellation.views.dataaccess.components.DataAccessTabPane)6 ArrayList (java.util.ArrayList)6 ActionEvent (javafx.event.ActionEvent)6 List (java.util.List)5 Plugin (au.gov.asd.tac.constellation.plugins.Plugin)4 WaitForQueriesToCompleteTask (au.gov.asd.tac.constellation.views.dataaccess.tasks.WaitForQueriesToCompleteTask)4 Label (javafx.scene.control.Label)4 Graph (au.gov.asd.tac.constellation.graph.Graph)3 RecentParameterValues (au.gov.asd.tac.constellation.plugins.parameters.RecentParameterValues)3 JsonIO (au.gov.asd.tac.constellation.utilities.genericjsonio.JsonIO)3