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