Search in sources :

Example 1 with FileParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue in project constellation by constellation-app.

the class TestParametersPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final String css = TestParametersPlugin.class.getResource("resources/test.css").toExternalForm();
    final BooleanParameterValue selectedpv = new BooleanParameterValue(true);
    selectedpv.setGuiInit(control -> {
        final CheckBox field = (CheckBox) control;
        field.getStylesheets().add(css);
    });
    final PluginParameter<BooleanParameterValue> selected = BooleanParameterType.build(SELECTED_PARAMETER_ID, selectedpv);
    selected.setName("Use selected");
    selected.setDescription("Only use selected elements");
    params.addParameter(selected);
    final PluginParameter<StringParameterValue> queryName = CoreGlobalParameters.QUERY_NAME_PARAMETER;
    params.addParameter(queryName);
    final PluginParameter<DateTimeRangeParameterValue> dt = CoreGlobalParameters.DATETIME_RANGE_PARAMETER;
    params.addParameter(dt);
    final PluginParameter<StringParameterValue> string1 = StringParameterType.build(TEST1_PARAMETER_ID);
    string1.setName("Test1");
    string1.setDescription("A test string");
    string1.setStringValue("Plugh.");
    params.addParameter(string1);
    final StringParameterValue string2pv = new StringParameterValue();
    string2pv.setGuiInit(control -> {
        final TextArea field = (TextArea) control;
        field.getStylesheets().add(css);
    });
    final PluginParameter<StringParameterValue> string2 = StringParameterType.build(TEST2_PARAMETER_ID, string2pv);
    string2.setName("Test2");
    string2.setDescription("A two line test string");
    StringParameterType.setLines(string2, 2);
    params.addParameter(string2);
    final PluginParameter<PasswordParameterValue> passwd = PasswordParameterType.build(PASSWORD_PARAMETER_ID);
    passwd.setName("Password");
    passwd.setDescription("Everyone needs a password");
    params.addParameter(passwd);
    final PluginParameter<LocalDateParameterValue> date = LocalDateParameterType.build(LOCAL_DATE_PARAMETER_ID);
    date.setName("Date");
    date.setDescription("Pick a day");
    date.setLocalDateValue(LocalDate.of(2001, Month.JANUARY, 1));
    params.addParameter(date);
    final List<GraphElementTypeParameterValue> elementTypeOptions = new ArrayList<>();
    for (final GraphElementType elementType : GraphElementType.values()) {
        elementTypeOptions.add(new GraphElementTypeParameterValue(elementType));
    }
    final PluginParameter<SingleChoiceParameterValue> elementType = SingleChoiceParameterType.build(ELEMENT_TYPE_PARAMETER_ID, GraphElementTypeParameterValue.class);
    elementType.setName("Graph element type");
    elementType.setDescription("Graph element type");
    SingleChoiceParameterType.setOptionsData(elementType, elementTypeOptions);
    params.addParameter(elementType);
    // A single choice list with a subtype of String.
    final SingleChoiceParameterValue robotpv = new SingleChoiceParameterValue(StringParameterValue.class);
    robotpv.setGuiInit(control -> {
        // control will be of type ComboBox<ParameterValue> which extends from Region
        @SuppressWarnings("unchecked") final ComboBox<ParameterValue> field = (ComboBox<ParameterValue>) control;
        final Image img = new Image(ALIEN_ICON);
        field.setCellFactory((ListView<ParameterValue> param) -> new ListCell<ParameterValue>() {

            @Override
            protected void updateItem(final ParameterValue item, final boolean empty) {
                super.updateItem(item, empty);
                this.setText(empty ? "" : item.toString());
                final float f = empty ? 0 : item.toString().length() / 11F;
                final Color c = Color.color(1 - f / 2F, 0, 0);
                setTextFill(c);
                setGraphic(new ImageView(img));
            }
        });
    });
    final PluginParameter<SingleChoiceParameterValue> robotOptions = SingleChoiceParameterType.build(ROBOT_PARAMETER_ID, robotpv);
    robotOptions.setName("Robot options");
    robotOptions.setDescription("A list of robots to choose from");
    // Use the helper method to add string options.
    SingleChoiceParameterType.setOptions(robotOptions, Arrays.asList("Bender", "Gort", "Maximillian", "Robbie", "Tom Servo"));
    // Create a ParameterValue of the underlying type (in this case, String) to set the default choice.
    final StringParameterValue robotChoice = new StringParameterValue("Gort");
    SingleChoiceParameterType.setChoiceData(robotOptions, robotChoice);
    params.addParameter(robotOptions);
    final PluginParameter<ParameterValue> buttonParam = ActionParameterType.build(REFRESH_PARAMETER_ID);
    buttonParam.setName("Refresh");
    buttonParam.setDescription("Update the available robots");
    params.addParameter(buttonParam);
    final PluginParameter<MultiChoiceParameterValue> planetOptions = MultiChoiceParameterType.build(PLANETS_PARAMETER_ID);
    planetOptions.setName("Planets");
    planetOptions.setDescription("Some planets");
    MultiChoiceParameterType.setOptions(planetOptions, Arrays.asList("Mercury", "Venus", "Earth", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Coruscant"));
    final List<String> checked = new ArrayList<>();
    checked.add("Earth");
    MultiChoiceParameterType.setChoices(planetOptions, checked);
    params.addParameter(planetOptions);
    final PluginParameter<IntegerParameterValue> diceOptions = IntegerParameterType.build(DICE_PARAMETER_ID);
    diceOptions.setName("Dice");
    diceOptions.setDescription("2d6");
    IntegerParameterType.setMinimum(diceOptions, 2);
    IntegerParameterType.setMaximum(diceOptions, 12);
    diceOptions.setIntegerValue(7);
    params.addParameter(diceOptions);
    final PluginParameter<FloatParameterValue> probability = FloatParameterType.build(PROBABILITY_PARAMETER_ID);
    probability.setName("Probability");
    probability.setDescription("0 <= p <= 1");
    FloatParameterType.setMinimum(probability, 0F);
    FloatParameterType.setMaximum(probability, 1F);
    FloatParameterType.setStep(probability, 0.1F);
    probability.setFloatValue(1F);
    params.addParameter(probability);
    final PluginParameter<FileParameterValue> openFileParam = FileParameterType.build(INPUT_FILE_PARAMETER_ID);
    openFileParam.setName("Input file");
    openFileParam.setDescription("A file to read stuff from");
    params.addParameter(openFileParam);
    final PluginParameter<FileParameterValue> saveFileParam = FileParameterType.build(OUTPUT_FILE_PARAMETER_ID);
    saveFileParam.setName("Output file");
    saveFileParam.setDescription("A file to write stuff to");
    FileParameterType.setKind(saveFileParam, FileParameterType.FileParameterKind.SAVE);
    FileParameterType.setFileFilters(saveFileParam, new FileChooser.ExtensionFilter("Text files", "*.txt"));
    params.addParameter(saveFileParam);
    final PluginParameter<ColorParameterValue> color = ColorParameterType.build(COLOR_PARAMETER_ID);
    color.setName("Color");
    color.setDescription("Your favourite colour");
    color.setColorValue(ConstellationColor.BLUE);
    params.addParameter(color);
    final PluginParameter<BooleanParameterValue> crash = BooleanParameterType.build(CRASH_PARAMETER_ID);
    crash.setName("Crash");
    crash.setDescription("Simulate plugin failure");
    params.addParameter(crash);
    final PluginParameter<SingleChoiceParameterValue> interactionOptions = SingleChoiceParameterType.build(INTERACTION_PARAMETER_ID);
    interactionOptions.setName("Interaction level");
    interactionOptions.setDescription("Interaction level for some interaction with the user");
    SingleChoiceParameterType.setOptions(interactionOptions, Arrays.asList(NONE, DEBUG, INFO, WARNING, ERROR, FATAL));
    params.addParameter(interactionOptions);
    final PluginParameter<SingleChoiceParameterValue> levelOptions = SingleChoiceParameterType.build(LEVEL_PARAMETER_ID);
    levelOptions.setName("PluginException level");
    levelOptions.setDescription("PluginException level to throw an exception at");
    levelOptions.setHelpID("not.actually.helpful");
    SingleChoiceParameterType.setOptions(levelOptions, Arrays.asList(NONE, DEBUG, INFO, WARNING, ERROR, FATAL));
    params.addParameter(levelOptions);
    final PluginParameter<IntegerParameterValue> sleepParam = IntegerParameterType.build(SLEEP_PARAMETER_ID);
    sleepParam.setName("Sleep");
    sleepParam.setDescription("Seconds");
    IntegerParameterType.setMinimum(sleepParam, 0);
    IntegerParameterType.setMaximum(sleepParam, 20);
    sleepParam.setIntegerValue(0);
    params.addParameter(sleepParam);
    params.addController(SELECTED_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
        if (change == ParameterChange.VALUE) {
            final boolean masterBoolean = master.getBooleanValue();
            // TEST1_PARAMETER will always be of type StringParameter
            @SuppressWarnings("unchecked") final PluginParameter<StringParameterValue> t1 = (PluginParameter<StringParameterValue>) parameters.get(TEST1_PARAMETER_ID);
            t1.setEnabled(masterBoolean);
            // TEST1_PARAMETER will always be of type StringParameter
            @SuppressWarnings("unchecked") final PluginParameter<StringParameterValue> t2 = (PluginParameter<StringParameterValue>) parameters.get(TEST2_PARAMETER_ID);
            t2.setEnabled(masterBoolean);
            // PLANETS_PARAMETER will always be of type MultiChoiceParameter
            @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> p = (PluginParameter<MultiChoiceParameterValue>) parameters.get(PLANETS_PARAMETER_ID);
            p.setEnabled(masterBoolean);
            // DICE_PARAMETER will always be of type IntegerParameter
            @SuppressWarnings("unchecked") final PluginParameter<IntegerParameterValue> d = (PluginParameter<IntegerParameterValue>) parameters.get(DICE_PARAMETER_ID);
            d.setEnabled(masterBoolean);
            // COLOR_PARAMETER will always be of type ColorParameter
            @SuppressWarnings("unchecked") final PluginParameter<ColorParameterValue> c = (PluginParameter<ColorParameterValue>) parameters.get(COLOR_PARAMETER_ID);
            c.setVisible(masterBoolean);
        }
    });
    params.addController(REFRESH_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
        if (change == ParameterChange.NO_CHANGE) {
            // button pressed
            // ROBOT_PARAMETER will always be of type SingleChoiceParameter
            @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> robot = (PluginParameter<SingleChoiceParameterValue>) parameters.get(ROBOT_PARAMETER_ID);
            final int n = (int) (System.currentTimeMillis() % 100);
            SingleChoiceParameterType.setOptions(robot, Arrays.asList("Kryton " + n, "C-3PO " + n, "R2-D2 " + n));
            SingleChoiceParameterType.setChoice(robot, "C-3PO " + n);
        }
    });
    return params;
}
Also used : TextArea(javafx.scene.control.TextArea) ArrayList(java.util.ArrayList) PasswordParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.PasswordParameterValue) Image(javafx.scene.image.Image) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) ListView(javafx.scene.control.ListView) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) FileChooser(javafx.stage.FileChooser) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) ImageView(javafx.scene.image.ImageView) ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) LocalDateParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.LocalDateParameterType.LocalDateParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) FloatParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue) PasswordParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.PasswordParameterValue) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) DateTimeRangeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRangeParameterType.DateTimeRangeParameterValue) ComboBox(javafx.scene.control.ComboBox) Color(javafx.scene.paint.Color) ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) CheckBox(javafx.scene.control.CheckBox) Map(java.util.Map) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) DateTimeRangeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.DateTimeRangeParameterType.DateTimeRangeParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) LocalDateParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.LocalDateParameterType.LocalDateParameterValue) FloatParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue)

Example 2 with FileParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue in project constellation by constellation-app.

the class AbstractGeoExportPlugin method createParameters.

@Override
// the fallthrough at the switch statement is intentional
@SuppressWarnings("fallthrough")
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<FileParameterValue> outputParameter = FileParameterType.build(OUTPUT_PARAMETER_ID);
    outputParameter.setName("Output File");
    outputParameter.setDescription("The name of the output file");
    FileParameterType.setKind(outputParameter, FileParameterType.FileParameterKind.SAVE);
    FileParameterType.setFileFilters(outputParameter, getExportType());
    parameters.addParameter(outputParameter);
    if (includeSpatialReference()) {
        final PluginParameter<SingleChoiceParameterValue> spatialReferenceParameter = SingleChoiceParameterType.build(SPATIAL_REFERENCE_PARAMETER_ID, SpatialReferenceParameterValue.class);
        spatialReferenceParameter.setName("Spatial Reference");
        spatialReferenceParameter.setDescription("The spatial reference to use for the geopackage");
        final List<SpatialReferenceParameterValue> spatialReferences = Arrays.asList(Shape.SpatialReference.values()).stream().map(spatialReference -> new SpatialReferenceParameterValue(spatialReference)).collect(Collectors.toList());
        SingleChoiceParameterType.setOptionsData(spatialReferenceParameter, spatialReferences);
        SingleChoiceParameterType.setChoiceData(spatialReferenceParameter, spatialReferences.get(0));
        parameters.addParameter(spatialReferenceParameter);
    }
    final PluginParameter<SingleChoiceParameterValue> elementTypeParameter = SingleChoiceParameterType.build(ELEMENT_TYPE_PARAMETER_ID, ElementTypeParameterValue.class);
    elementTypeParameter.setName("Element Type");
    elementTypeParameter.setDescription("The graph element type");
    final List<ElementTypeParameterValue> elementTypes = new ArrayList<>();
    elementTypes.add(new ElementTypeParameterValue(GraphElementType.TRANSACTION));
    elementTypes.add(new ElementTypeParameterValue(GraphElementType.VERTEX));
    SingleChoiceParameterType.setOptionsData(elementTypeParameter, elementTypes);
    parameters.addParameter(elementTypeParameter);
    final PluginParameter<MultiChoiceParameterValue> attributesParameter = MultiChoiceParameterType.build(ATTRIBUTES_PARAMETER_ID, GraphAttributeParameterValue.class);
    attributesParameter.setName("Attributes");
    attributesParameter.setDescription("The list of attribute names to include in the export");
    attributesParameter.setEnabled(false);
    parameters.addParameter(attributesParameter);
    final PluginParameter<BooleanParameterValue> selectedOnlyParameter = BooleanParameterType.build(SELECTED_ONLY_PARAMETER_ID);
    selectedOnlyParameter.setName("Selected Only");
    selectedOnlyParameter.setDescription("If True, only export the selected nodes. The default is False.");
    selectedOnlyParameter.setBooleanValue(false);
    parameters.addParameter(selectedOnlyParameter);
    parameters.addController(ELEMENT_TYPE_PARAMETER_ID, (master, params, change) -> {
        if (change == ParameterChange.VALUE) {
            final Graph activeGraph = GraphManager.getDefault().getActiveGraph();
            if (activeGraph != null) {
                // create options by getting attributes for the chosen element type from the graph
                final List<GraphAttributeParameterValue> attributeOptions = new ArrayList<>();
                final ReadableGraph readableGraph = activeGraph.getReadableGraph();
                try {
                    final ParameterValue pv = params.get(master.getId()).getSingleChoice();
                    assert (pv instanceof ElementTypeParameterValue);
                    final GraphElementType elementType = ((ElementTypeParameterValue) pv).getGraphElementType();
                    switch(elementType) {
                        case TRANSACTION:
                            final int transactionAttributeCount = readableGraph.getAttributeCount(GraphElementType.TRANSACTION);
                            for (int attributePosition = 0; attributePosition < transactionAttributeCount; attributePosition++) {
                                final int attributeId = readableGraph.getAttribute(GraphElementType.TRANSACTION, attributePosition);
                                final GraphAttribute graphAttribute = new GraphAttribute(readableGraph, attributeId);
                                attributeOptions.add(new GraphAttributeParameterValue(graphAttribute));
                            }
                        // fall through
                        case VERTEX:
                            final int vertexAttributeCount = readableGraph.getAttributeCount(GraphElementType.VERTEX);
                            for (int attributePosition = 0; attributePosition < vertexAttributeCount; attributePosition++) {
                                final int attributeId = readableGraph.getAttribute(GraphElementType.VERTEX, attributePosition);
                                final GraphAttribute graphAttribute = new GraphAttribute(readableGraph, attributeId);
                                attributeOptions.add(new GraphAttributeParameterValue(graphAttribute));
                            }
                            break;
                        default:
                            return;
                    }
                } finally {
                    readableGraph.release();
                }
                // create choices by deselecting lowercase attributes by default
                final List<GraphAttributeParameterValue> attributeChoices = attributeOptions.stream().filter(attributeOption -> !((GraphAttribute) attributeOption.getObjectValue()).getName().matches("[a-z]{1}.*")).collect(Collectors.toList());
                // sort options and choices lists
                Collections.sort(attributeOptions);
                Collections.sort(attributeChoices);
                // update attributes parameter
                // Attrbutes_Parameter is created as a MultiChoice parameter in this class on line 137.
                @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> updatedAttributesParameter = (PluginParameter<MultiChoiceParameterValue>) params.get(ATTRIBUTES_PARAMETER_ID);
                MultiChoiceParameterType.setOptionsData(updatedAttributesParameter, attributeOptions);
                MultiChoiceParameterType.setChoicesData(updatedAttributesParameter, attributeChoices);
                updatedAttributesParameter.setEnabled(true);
            }
        }
    });
    return parameters;
}
Also used : Arrays(java.util.Arrays) Tuple(au.gov.asd.tac.constellation.utilities.datastructure.Tuple) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) GraphAttributeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.GraphAttributeParameterValue) ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) SingleChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) SimpleReadPlugin(au.gov.asd.tac.constellation.plugins.templates.SimpleReadPlugin) SpatialConcept(au.gov.asd.tac.constellation.graph.schema.analytic.concept.SpatialConcept) HashMap(java.util.HashMap) VisualConcept(au.gov.asd.tac.constellation.graph.schema.visual.concept.VisualConcept) StringUtils(org.apache.commons.lang3.StringUtils) GraphConstants(au.gov.asd.tac.constellation.graph.GraphConstants) ArrayList(java.util.ArrayList) Graph(au.gov.asd.tac.constellation.graph.Graph) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) PluginInteraction(au.gov.asd.tac.constellation.plugins.PluginInteraction) Shape(au.gov.asd.tac.constellation.utilities.geospatial.Shape) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) Map(java.util.Map) GraphReadMethods(au.gov.asd.tac.constellation.graph.GraphReadMethods) GraphManager(au.gov.asd.tac.constellation.graph.manager.GraphManager) OUTPUT_PARAMETER_ID(au.gov.asd.tac.constellation.plugins.importexport.geospatial.AbstractGeoExportPlugin.OUTPUT_PARAMETER_ID) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ELEMENT_TYPE_PARAMETER_ID(au.gov.asd.tac.constellation.plugins.importexport.geospatial.AbstractGeoExportPlugin.ELEMENT_TYPE_PARAMETER_ID) ElementTypeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ElementTypeParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) FileParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType) MultiChoiceParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) IOException(java.io.IOException) GraphRecordStoreUtilities(au.gov.asd.tac.constellation.graph.processing.GraphRecordStoreUtilities) PluginException(au.gov.asd.tac.constellation.plugins.PluginException) Collectors(java.util.stream.Collectors) File(java.io.File) BooleanParameterType(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType) PluginNotificationLevel(au.gov.asd.tac.constellation.plugins.PluginNotificationLevel) List(java.util.List) NotifyDescriptor(org.openide.NotifyDescriptor) NotifyDisplayer(au.gov.asd.tac.constellation.utilities.gui.NotifyDisplayer) ConstellationLoggerHelper(au.gov.asd.tac.constellation.plugins.logging.ConstellationLoggerHelper) GraphNode(au.gov.asd.tac.constellation.graph.node.GraphNode) GeometryType(au.gov.asd.tac.constellation.utilities.geospatial.Shape.GeometryType) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) Collections(java.util.Collections) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) ElementTypeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ElementTypeParameterValue) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) GraphAttribute(au.gov.asd.tac.constellation.graph.GraphAttribute) ArrayList(java.util.ArrayList) GraphElementType(au.gov.asd.tac.constellation.graph.GraphElementType) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) GraphAttributeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.GraphAttributeParameterValue) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) ElementTypeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ElementTypeParameterValue) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) ParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue) GraphAttributeParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.GraphAttributeParameterValue) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) ReadableGraph(au.gov.asd.tac.constellation.graph.ReadableGraph) Graph(au.gov.asd.tac.constellation.graph.Graph) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 3 with FileParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue in project constellation by constellation-app.

the class NewNebulaAction method actionPerformed.

@Override
public void actionPerformed(final ActionEvent e) {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<FileParameterValue> fileParam = FileParameterType.build(NEBULA_FILE_PARAMETER_ID);
    fileParam.setName("Nebula file");
    FileParameterType.setFileFilters(fileParam, new ExtensionFilter("Nebula file", "*.nebula"));
    fileParam.getParameterValue().setKind(FileParameterKind.SAVE);
    fileParam.setHelpID("au.gov.asd.tac.constellation.file.nebula");
    params.addParameter(fileParam);
    final PluginParameter<ColorParameterValue> colorParam = ColorParameterType.build(COLOR_PARAMETER_ID);
    colorParam.setName("Nebula colour");
    params.addParameter(colorParam);
    final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog(Bundle.CTL_NewNebulaAction(), params);
    dialog.showAndWait();
    if (PluginParametersDialog.OK.equals(dialog.getResult())) {
        final FileParameterValue fpv = fileParam.getParameterValue();
        if (!fpv.get().isEmpty()) {
            final Properties props = new Properties();
            final ConstellationColor c = colorParam.getColorValue();
            props.setProperty("colour", String.format("%f,%f,%f", c.getRed(), c.getGreen(), c.getBlue()));
            File f = fpv.get().get(0);
            if (!StringUtils.endsWithIgnoreCase(f.getName(), FileExtensionConstants.NEBULA)) {
                f = new File(f.getAbsoluteFile() + FileExtensionConstants.NEBULA);
            }
            try {
                try (final FileOutputStream fos = new FileOutputStream(f)) {
                    props.store(fos, null);
                    NebulaDataObject.addRecent(f);
                }
            } catch (final IOException ex) {
                LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
            }
        }
    }
}
Also used : ConstellationColor(au.gov.asd.tac.constellation.utilities.color.ConstellationColor) PluginParametersSwingDialog(au.gov.asd.tac.constellation.plugins.gui.PluginParametersSwingDialog) FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) FileOutputStream(java.io.FileOutputStream) ColorParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) IOException(java.io.IOException) Properties(java.util.Properties) File(java.io.File)

Example 4 with FileParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue in project constellation by constellation-app.

the class ImportDelimitedPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<ObjectParameterValue> parserParam = ObjectParameterType.build(PARSER_PARAMETER_ID);
    parserParam.setName("Parser");
    parserParam.setDescription("The type of parser which is one that extends ImportFileParser");
    parserParam.setObjectValue(null);
    params.addParameter(parserParam);
    final PluginParameter<FileParameterValue> fileParam = FileParameterType.build(FILES_PARAMETER_ID);
    fileParam.setName("Files");
    fileParam.setDescription("The list of file names to import");
    fileParam.setObjectValue(null);
    params.addParameter(fileParam);
    final PluginParameter<ObjectParameterValue> definitionParam = ObjectParameterType.build(DEFINITIONS_PARAMETER_ID);
    definitionParam.setName("Definitions");
    definitionParam.setDescription("The list of definitions that extend ImportDefinition");
    definitionParam.setObjectValue(null);
    params.addParameter(definitionParam);
    final PluginParameter<BooleanParameterValue> schemaParam = BooleanParameterType.build(SCHEMA_PARAMETER_ID);
    schemaParam.setName("Complete with Schema");
    schemaParam.setDescription("True if the graph should run the schema rules");
    schemaParam.setBooleanValue(true);
    params.addParameter(schemaParam);
    final PluginParameter<ObjectParameterValue> parserParameters = ObjectParameterType.build(PARSER_PARAMETER_IDS_PARAMETER_ID);
    parserParameters.setName("Parser Parameters");
    parserParameters.setDescription("The PluginParameters used by the parser");
    params.addParameter(parserParameters);
    final PluginParameter<BooleanParameterValue> filesIncludeHeadersParam = BooleanParameterType.build(FILES_INCLUDE_HEADERS_PARAMETER_ID);
    filesIncludeHeadersParam.setName("Files Include Headers");
    filesIncludeHeadersParam.setDescription("True if the files include headers in the first row");
    filesIncludeHeadersParam.setBooleanValue(true);
    params.addParameter(filesIncludeHeadersParam);
    return params;
}
Also used : FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) ObjectParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)

Example 5 with FileParameterValue

use of au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue in project constellation by constellation-app.

the class ImageGraphBuilderPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<FileParameterValue> imageFileParameter = FileParameterType.build(IMAGE_FILE_PARAMETER_ID);
    imageFileParameter.setName("Image File");
    imageFileParameter.setDescription("The image file from which to build a graph");
    FileParameterType.setFileFilters(imageFileParameter, new ExtensionFilter("Image Files", "*.png", "*.jpg", "*.gif"));
    parameters.addParameter(imageFileParameter);
    return parameters;
}
Also used : FileParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue) ExtensionFilter(javafx.stage.FileChooser.ExtensionFilter) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Aggregations

PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)5 FileParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FileParameterType.FileParameterValue)5 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)3 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)2 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)2 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)2 ColorParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue)2 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)2 ParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ParameterValue)2 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 ExtensionFilter (javafx.stage.FileChooser.ExtensionFilter)2 Graph (au.gov.asd.tac.constellation.graph.Graph)1 GraphAttribute (au.gov.asd.tac.constellation.graph.GraphAttribute)1 GraphConstants (au.gov.asd.tac.constellation.graph.GraphConstants)1 GraphReadMethods (au.gov.asd.tac.constellation.graph.GraphReadMethods)1 ReadableGraph (au.gov.asd.tac.constellation.graph.ReadableGraph)1 GraphManager (au.gov.asd.tac.constellation.graph.manager.GraphManager)1 GraphNode (au.gov.asd.tac.constellation.graph.node.GraphNode)1