use of au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue in project constellation by constellation-app.
the class ExportToShapefilePlugin method exportGeo.
@Override
protected void exportGeo(final PluginParameters parameters, final String uuid, final Map<String, String> shapes, final Map<String, Map<String, Object>> attributes, final File output) throws IOException {
final ParameterValue geometryTypePV = parameters.getSingleChoice(GEOMETRY_TYPE_PARAMETER_ID);
assert (geometryTypePV instanceof GeometryTypeParameterValue);
final GeometryType geometryType = ((GeometryTypeParameterValue) geometryTypePV).getGeometryType();
final ParameterValue spatialReferencePV = parameters.getSingleChoice(SPATIAL_REFERENCE_PARAMETER_ID);
assert (spatialReferencePV instanceof SpatialReferenceParameterValue);
final SpatialReference spatialReference = ((SpatialReferenceParameterValue) spatialReferencePV).getSpatialReference();
Shape.generateShapefile(uuid, geometryType, shapes, attributes, output, spatialReference);
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue in project constellation by constellation-app.
the class SplitNodesPlugin method edit.
@Override
public void edit(final GraphWriteMethods graph, final PluginInteraction interaction, final PluginParameters parameters) throws InterruptedException, PluginException {
final Map<String, PluginParameter<?>> splitParameters = parameters.getParameters();
final String character = splitParameters.get(SPLIT_PARAMETER_ID) != null && splitParameters.get(SPLIT_PARAMETER_ID).getStringValue() != null ? splitParameters.get(SPLIT_PARAMETER_ID).getStringValue() : "";
final ParameterValue transactionTypeChoice = splitParameters.get(TRANSACTION_TYPE_PARAMETER_ID).getSingleChoice();
final String linkType = transactionTypeChoice != null ? transactionTypeChoice.toString() : AnalyticConcept.TransactionType.CORRELATION.getName();
final boolean allOccurrences = splitParameters.get(ALL_OCCURRENCES_PARAMETER_ID).getBooleanValue();
final boolean splitIntoSameLevel = splitParameters.get(DUPLICATE_TRANSACTIONS_PARAMETER_ID).getBooleanValue();
final int vertexSelectedAttributeId = VisualConcept.VertexAttribute.SELECTED.ensure(graph);
final int vertexIdentifierAttributeId = VisualConcept.VertexAttribute.IDENTIFIER.ensure(graph);
final List<Integer> newVertices = new ArrayList<>();
final int graphVertexCount = graph.getVertexCount();
for (int position = 0; position < graphVertexCount; position++) {
final int currentVertexId = graph.getVertex(position);
if (graph.getBooleanValue(vertexSelectedAttributeId, currentVertexId)) {
final String identifier = graph.getStringValue(vertexIdentifierAttributeId, currentVertexId);
if (identifier != null && identifier.contains(character) && identifier.indexOf(character) < identifier.length() - character.length()) {
String leftNodeIdentifier = "";
if (allOccurrences) {
final String[] substrings = Arrays.stream(identifier.split(character)).filter(value -> value != null && value.length() > 0).toArray(size -> new String[size]);
if (substrings.length <= 0) {
continue;
}
leftNodeIdentifier = substrings[0];
for (int i = 1; i < substrings.length; i++) {
newVertices.add(createNewNode(graph, position, substrings[i], linkType, splitIntoSameLevel));
}
} else {
final int i = identifier.indexOf(character);
leftNodeIdentifier = identifier.substring(0, i);
if (StringUtils.isNotBlank(leftNodeIdentifier)) {
newVertices.add(createNewNode(graph, position, identifier.substring(i + 1), linkType, splitIntoSameLevel));
} else {
leftNodeIdentifier = identifier.substring(i + 1);
}
}
// Rename the selected node
if (StringUtils.isNotBlank(leftNodeIdentifier)) {
graph.setStringValue(vertexIdentifierAttributeId, currentVertexId, leftNodeIdentifier);
newVertices.add(currentVertexId);
}
}
}
}
if (!newVertices.isEmpty()) {
// Reset the view
graph.validateKey(GraphElementType.VERTEX, true);
graph.validateKey(GraphElementType.TRANSACTION, true);
final PluginExecutor arrangement = completionArrangement();
if (arrangement != null) {
// run the arrangement
final VertexListInclusionGraph vlGraph = new VertexListInclusionGraph(graph, AbstractInclusionGraph.Connections.NONE, newVertices);
arrangement.executeNow(vlGraph.getInclusionGraph());
vlGraph.retrieveCoords();
}
if (splitParameters.get(COMPLETE_WITH_SCHEMA_OPTION_ID).getBooleanValue()) {
PluginExecution.withPlugin(VisualSchemaPluginRegistry.COMPLETE_SCHEMA).executeNow(graph);
}
PluginExecutor.startWith(InteractiveGraphPluginRegistry.RESET_VIEW).executeNow(graph);
}
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue in project constellation by constellation-app.
the class FilterPluginNGTest method testCreateCopy.
/**
* Test of createCopy method, of class FilterTypeParameterValue.
*/
@Test
public void testCreateCopy() {
System.out.println("createCopy");
final FilterTypeParameterValue instance = new FilterTypeParameterValue(FilterType.REMOVE_FILTER);
final ParameterValue expResult = new FilterTypeParameterValue(FilterType.REMOVE_FILTER);
final ParameterValue result = instance.createCopy();
assertEquals(result, expResult);
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue in project constellation by constellation-app.
the class ManageTemplatesPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final Preferences prefs = NbPreferences.forModule(ApplicationPreferenceKeys.class);
final PluginParameter<SingleChoiceParameterValue> templateParam = SingleChoiceParameterType.build(TEMPLATE_NAME_PARAMETER_ID);
templateParam.setName(TEMPLATE_NAME_PARAMETER_ID_NAME);
templateParam.setDescription(TEMPLATE_NAME_PARAMETER_ID_DESCRIPTION);
final List<String> templateNames = new ArrayList<>(NewSchemaGraphAction.getTemplateNames().keySet());
SingleChoiceParameterType.setOptions(templateParam, templateNames);
templateParam.setStringValue(templateNames.isEmpty() ? "" : templateNames.get(0));
params.addParameter(templateParam);
final PluginParameter<ParameterValue> deleteParam = ActionParameterType.build(DELETE_TEMPLATE_PARAMETER_ID);
params.addGroup(ACTIONS_GROUP_NAME, new PluginParametersPane.HorizontalParameterGroupLayout(false));
deleteParam.setName(null);
deleteParam.setDescription(null);
deleteParam.setStringValue(DELETE_TEMPLATE_PARAMETER_ID_NAME);
params.addParameter(deleteParam, ACTIONS_GROUP_NAME);
params.addController(DELETE_TEMPLATE_PARAMETER_ID, (master, parameters, change) -> {
if (change == ParameterChange.NO_CHANGE) {
// button pressed
final String deleteTemplateName = parameters.get(TEMPLATE_NAME_PARAMETER_ID).getStringValue();
if (StringUtils.isNotBlank(deleteTemplateName)) {
templateNames.remove(deleteTemplateName);
deletedTemplates.add(deleteTemplateName);
SingleChoiceParameterType.setOptions(templateParam, templateNames);
templateParam.setStringValue("");
if (deleteTemplateName.equals(parameters.get(CURRENT_DEFAULT_PARAMETER_ID).getStringValue())) {
parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(NO_DEFAULT);
}
}
}
});
final PluginParameter<ParameterValue> defaultParam = ActionParameterType.build(DEFAULT_TEMPLATE_PARAMETER_ID);
defaultParam.setName(null);
defaultParam.setDescription(null);
defaultParam.setStringValue(DEFAULT_TEMPLATE_PARAMETER_ID_NAME);
params.addParameter(defaultParam, ACTIONS_GROUP_NAME);
params.addController(DEFAULT_TEMPLATE_PARAMETER_ID, (master, parameters, change) -> {
if (change == ParameterChange.NO_CHANGE) {
// button pressed
final String chosenTemplate = parameters.get(TEMPLATE_NAME_PARAMETER_ID).getStringValue();
if (StringUtils.isNotBlank(chosenTemplate)) {
parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(chosenTemplate);
}
}
});
final PluginParameter<ParameterValue> clearParam = ActionParameterType.build(CLEAR_DEFAULT_PARAMETER_ID);
clearParam.setName(null);
clearParam.setDescription(null);
clearParam.setStringValue(CLEAR_DEFAULT_PARAMETER_ID_NAME);
params.addParameter(clearParam, ACTIONS_GROUP_NAME);
params.addController(CLEAR_DEFAULT_PARAMETER_ID, (master, parameters, change) -> {
if (change == ParameterChange.NO_CHANGE) {
// button pressed
parameters.get(CURRENT_DEFAULT_PARAMETER_ID).setStringValue(NO_DEFAULT);
}
});
final PluginParameter<StringParameterValue> currentDefaultParam = StringParameterType.build(CURRENT_DEFAULT_PARAMETER_ID);
currentDefaultParam.setName(CURRENT_DEFAULT_PARAMETER_ID_NAME);
StringParameterType.setIsLabel(currentDefaultParam, true);
final String currentDefault = prefs.get(ApplicationPreferenceKeys.DEFAULT_TEMPLATE, ApplicationPreferenceKeys.DEFAULT_TEMPLATE_DEFAULT);
currentDefaultParam.setStringValue(Objects.equals(ApplicationPreferenceKeys.DEFAULT_TEMPLATE_DEFAULT, currentDefault) ? NO_DEFAULT : currentDefault);
params.addParameter(currentDefaultParam);
return params;
}
Aggregations