Search in sources :

Example 36 with IntegerParameterValue

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

the class UncollidePlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    final PluginParameter<IntegerParameterValue> dimensionsParam = IntegerParameterType.build(DIMENSION_PARAMETER_ID);
    dimensionsParam.setName("Dimensions");
    dimensionsParam.setDescription("The dimention being 2D or 3D. The default is 2 for 2D.");
    dimensionsParam.setIntegerValue(2);
    parameters.addParameter(dimensionsParam);
    final PluginParameter<BooleanParameterValue> set2Param = BooleanParameterType.build(SET_XYZ2_PARAMETER_ID);
    set2Param.setName("Set XYZ 2");
    set2Param.setDescription("If True, set X2, Y2, Z2. The default is False.");
    set2Param.setBooleanValue(false);
    parameters.addParameter(set2Param);
    return parameters;
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 37 with IntegerParameterValue

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

the class ExtractWordsFromTextPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> attributeType = SingleChoiceParameterType.build(ATTRIBUTE_PARAMETER_ID);
    attributeType.setName("Content Attribute");
    attributeType.setDescription("Set the attribute from which to extract words");
    params.addParameter(attributeType);
    final PluginParameter<StringParameterValue> text = StringParameterType.build(WORDS_PARAMETER_ID);
    StringParameterType.setLines(text, 15);
    text.setName("Words to Extract");
    text.setDescription("Whitelist of words to extract from content (new line delimited, extract all words if empty)");
    text.setStringValue(null);
    params.addParameter(text);
    final PluginParameter<BooleanParameterValue> useRegex = BooleanParameterType.build(USE_REGEX_PARAMETER_ID);
    useRegex.setName("Use Regular Expressions");
    useRegex.setDescription("Words to Extract will be treated as regex patterns");
    useRegex.setBooleanValue(false);
    useRegex.setEnabled(false);
    params.addParameter(useRegex);
    final PluginParameter<BooleanParameterValue> wholeWordsOnly = BooleanParameterType.build(WHOLE_WORDS_ONLY_PARAMETER_ID);
    wholeWordsOnly.setName("Whole Words Only");
    wholeWordsOnly.setDescription("Words to Extract will be treated as whole words only");
    wholeWordsOnly.setBooleanValue(false);
    wholeWordsOnly.setEnabled(false);
    params.addParameter(wholeWordsOnly);
    final PluginParameter<IntegerParameterValue> minWordLength = IntegerParameterType.build(MIN_WORD_LENGTH_PARAMETER_ID);
    minWordLength.setName("Minimum Word Length");
    minWordLength.setDescription("Only extract words of length equal to or greater than this");
    minWordLength.setIntegerValue(3);
    IntegerParameterType.setMinimum(minWordLength, 1);
    params.addParameter(minWordLength);
    final PluginParameter<BooleanParameterValue> removeSpecialChars = BooleanParameterType.build(REMOVE_SPECIAL_CHARS_PARAMETER_ID);
    removeSpecialChars.setName("Remove Special Characters");
    removeSpecialChars.setDescription("Removes special characters from words before extraction");
    removeSpecialChars.setBooleanValue(true);
    params.addParameter(removeSpecialChars);
    final PluginParameter<BooleanParameterValue> caseInsensitive = BooleanParameterType.build(LOWER_CASE_PARAMETER_ID);
    caseInsensitive.setName("Lower Case");
    caseInsensitive.setDescription("Results are lower-cased");
    caseInsensitive.setBooleanValue(true);
    params.addParameter(caseInsensitive);
    final PluginParameter<BooleanParameterValue> types = BooleanParameterType.build(SCHEMA_TYPES_PARAMETER_ID);
    types.setName("Extract Schema Types");
    types.setDescription("Extract schema types");
    types.setBooleanValue(true);
    params.addParameter(types);
    final PluginParameter<SingleChoiceParameterValue> inOrOutParam = SingleChoiceParameterType.build(IN_OR_OUT_PARAMETER_ID);
    inOrOutParam.setName("Transactions");
    inOrOutParam.setDescription("Link nodes to outgoing or incoming words: 'outgoing' or 'incoming'");
    SingleChoiceParameterType.setOptions(inOrOutParam, List.of(OUTGOING, INCOMING));
    inOrOutParam.setStringValue(OUTGOING);
    params.addParameter(inOrOutParam);
    final PluginParameter<BooleanParameterValue> selected = BooleanParameterType.build(SELECTED_ONLY_PARAMETER_ID);
    selected.setName("Selected Transactions Only");
    selected.setDescription("Only extract words from selected transactions only");
    selected.setBooleanValue(false);
    params.addParameter(selected);
    final PluginParameter<BooleanParameterValue> regexOnlyParam = BooleanParameterType.build(REGEX_ONLY_PARAMETER_ID);
    regexOnlyParam.setName("Regular Expression Only");
    regexOnlyParam.setDescription("The regexes control everything");
    regexOnlyParam.setBooleanValue(false);
    params.addParameter(regexOnlyParam);
    params.addController(WORDS_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.VALUE) {
            final String words = master.getStringValue();
            if (StringUtils.isBlank(words)) {
                parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(false);
                parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(false);
                parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(true);
                parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(true);
            } else {
                parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(true);
                parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(true);
                parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(false);
                parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(false);
            }
        }
    });
    // How well does this interact with the controller above?
    // 
    params.addController(REGEX_ONLY_PARAMETER_ID, (master, parameters, change) -> {
        if (change == ParameterChange.VALUE) {
            final boolean regexOnly = master.getBooleanValue();
            parameters.get(USE_REGEX_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(WHOLE_WORDS_ONLY_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(MIN_WORD_LENGTH_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(REMOVE_SPECIAL_CHARS_PARAMETER_ID).setEnabled(!regexOnly);
            parameters.get(SCHEMA_TYPES_PARAMETER_ID).setEnabled(!regexOnly);
            if (!regexOnly) {
                // If the checkbox is being unchecked, trigger a WORDS_PARAMETER_ID
                // change to set the GUI state.
                // 
                parameters.get(WORDS_PARAMETER_ID).fireChangeEvent(ParameterChange.VALUE);
            }
        }
    });
    return params;
}
Also used : BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) StringParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 38 with IntegerParameterValue

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

the class MergeTransactionsPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    PluginParameters params = new PluginParameters();
    final PluginParameter<SingleChoiceParameterValue> mergeType = SingleChoiceParameterType.build(MERGE_TYPE_PARAMETER_ID);
    mergeType.setName("Merge By");
    mergeType.setDescription("Transactions will be merged based on this");
    List<String> mergeTypes = new ArrayList<>(MERGE_TYPES.keySet());
    SingleChoiceParameterType.setOptions(mergeType, mergeTypes);
    params.addParameter(mergeType);
    final PluginParameter<IntegerParameterValue> threshold = IntegerParameterType.build(THRESHOLD_PARAMETER_ID);
    threshold.setName("Threshold");
    threshold.setIntegerValue(0);
    IntegerParameterType.setMinimum(threshold, 0);
    threshold.setEnabled(false);
    params.addParameter(threshold);
    final PluginParameter<SingleChoiceParameterValue> mergingRule = SingleChoiceParameterType.build(MERGER_PARAMETER_ID);
    mergingRule.setName("Merging Rule");
    mergingRule.setDescription("The rule deciding how attributes are merged");
    List<String> mergerNames = new ArrayList<>(MERGERS.keySet());
    SingleChoiceParameterType.setOptions(mergingRule, mergerNames);
    SingleChoiceParameterType.setChoice(mergingRule, mergerNames.get(0));
    mergingRule.setEnabled(false);
    params.addParameter(mergingRule);
    final PluginParameter<SingleChoiceParameterValue> leadParam = SingleChoiceParameterType.build(LEAD_PARAMETER_ID);
    leadParam.setName("Lead Transaction");
    leadParam.setDescription("The rule deciding how to choose the lead transaction");
    List<String> leadTransactionChooserNames = new ArrayList<>(LEAD_TRANSACTION_CHOOSERS.keySet());
    SingleChoiceParameterType.setOptions(leadParam, leadTransactionChooserNames);
    SingleChoiceParameterType.setChoice(leadParam, leadTransactionChooserNames.get(0));
    leadParam.setEnabled(false);
    params.addParameter(leadParam);
    final PluginParameter<BooleanParameterValue> selectedParam = BooleanParameterType.build(SELECTED_PARAMETER_ID);
    selectedParam.setName("Selected Only");
    selectedParam.setDescription("Merge Only Selected Transactions");
    selectedParam.setBooleanValue(false);
    selectedParam.setEnabled(false);
    params.addParameter(selectedParam);
    params.addController(MERGE_TYPE_PARAMETER_ID, (final PluginParameter<?> master, final Map<String, PluginParameter<?>> parameters, final ParameterChange change) -> {
        if (change == ParameterChange.VALUE) {
            final String selectedMergeType = parameters.get(MERGE_TYPE_PARAMETER_ID).getStringValue();
            if (MERGE_TYPES.containsKey(selectedMergeType)) {
                final MergeTransactionType mergeTransactionTypeSelected = MERGE_TYPES.get(selectedMergeType);
                mergeTransactionTypeSelected.updateParameters(parameters);
            }
        }
    });
    return params;
}
Also used : ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) ArrayList(java.util.ArrayList) BooleanParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Example 39 with IntegerParameterValue

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

the class WorkflowQueryPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters parameters = new PluginParameters();
    // instantiate a copy of each plugin in the workflow to create their parameters and add them to this plugin.
    // this plugin then adds the set parameters values back to the individual workflow plugins at query time.
    final Set<String> globalParameterIds = GlobalParameters.getParameters(null).getParameters().keySet();
    getWorkflow().forEach(pluginName -> {
        final PluginParameters pluginParameters = PluginRegistry.get(pluginName).createParameters();
        if (pluginParameters != null && !pluginParameters.getParameters().isEmpty() && !parameters.hasGroup(pluginName)) {
            parameters.addGroup(pluginName, new PluginParametersPane.TitledSeparatedParameterLayout(String.format("%s Parameters", PluginRegistry.get(pluginName).getName()), 12, false));
            pluginParameters.getParameters().entrySet().forEach(parameter -> {
                if (!parameters.hasParameter(parameter.getKey())) {
                    if (globalParameterIds.contains(parameter.getKey())) {
                        parameters.addParameter(parameter.getValue());
                    } else {
                        parameters.addParameter(parameter.getValue(), pluginName);
                    }
                }
            });
            pluginParameters.getControllers().entrySet().forEach(controller -> {
                if (!parameters.getControllers().containsKey(controller)) {
                    parameters.addController(controller.getKey(), controller.getValue());
                }
            });
        }
    });
    // add parameters specific to a batched workflow plugin
    parameters.addGroup(WORKFLOW_GROUP, new PluginParametersPane.TitledSeparatedParameterLayout("Workflow Parameters", 12, false));
    final PluginParameter<IntegerParameterValue> batchSizeParameter = IntegerParameterType.build(BATCH_SIZE_PARAMETER_ID);
    batchSizeParameter.setName(BATCH_SIZE_PARAM_NAME);
    batchSizeParameter.setDescription(BATCH_SIZE_PARAM_DESCRIPTION);
    batchSizeParameter.setIntegerValue(getDefaultBatchSize());
    parameters.addParameter(batchSizeParameter, WORKFLOW_GROUP);
    final PluginParameter<IntegerParameterValue> maxConcurrentPluginsParam = IntegerParameterType.build(MAX_CONCURRENT_PLUGINS_PARAMETER_ID);
    maxConcurrentPluginsParam.setName(MAX_CONCURRENT_THREADS_PARAM_NAME);
    maxConcurrentPluginsParam.setDescription(MAX_CONCURRENT_THREADS_PARAM_DESCRIPTION);
    maxConcurrentPluginsParam.setIntegerValue(getDefaultConcurrentThreads());
    parameters.addParameter(maxConcurrentPluginsParam, WORKFLOW_GROUP);
    return parameters;
}
Also used : PluginParametersPane(au.gov.asd.tac.constellation.plugins.gui.PluginParametersPane) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)

Example 40 with IntegerParameterValue

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

the class SelectTopNPlugin method createParameters.

@Override
public PluginParameters createParameters() {
    final PluginParameters params = new PluginParameters();
    final List<String> modes = new ArrayList<>();
    modes.add(NODE);
    modes.add(TRANSACTION);
    final PluginParameter<SingleChoiceParameterValue> modeParameter = SingleChoiceParameterType.build(MODE_PARAMETER_ID);
    modeParameter.setName("Mode");
    modeParameter.setDescription("Select either the Node or Transaction mode");
    SingleChoiceParameterType.setOptions(modeParameter, modes);
    params.addParameter(modeParameter);
    final PluginParameter<SingleChoiceParameterValue> typeCategoryParameter = SingleChoiceParameterType.build(TYPE_CATEGORY_PARAMETER_ID);
    typeCategoryParameter.setName("Type Category");
    typeCategoryParameter.setDescription("The high level type category");
    params.addParameter(typeCategoryParameter);
    final PluginParameter<MultiChoiceParameterValue> typeParameter = MultiChoiceParameterType.build(TYPE_PARAMETER_ID);
    typeParameter.setName("Specific Types");
    typeParameter.setDescription("The specific types to include when calculating the top N");
    params.addParameter(typeParameter);
    final PluginParameter<IntegerParameterValue> limitParameter = IntegerParameterType.build(LIMIT_PARAMETER_ID);
    limitParameter.setName("Limit");
    limitParameter.setDescription("The limit, default being 10");
    limitParameter.setIntegerValue(10);
    params.addParameter(limitParameter);
    params.addController(MODE_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
        if (change == ParameterChange.VALUE) {
            final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
            if (mode != null) {
                final List<String> types = new ArrayList<>();
                switch(mode) {
                    case NODE:
                        for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
                            if (type.isTopLevelType()) {
                                types.add(type.getName());
                            }
                        }
                        break;
                    case TRANSACTION:
                        for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
                            if (type.isTopLevelType()) {
                                types.add(type.getName());
                            }
                        }
                        break;
                    default:
                        LOGGER.severe("Invalid mode provided. Mode values accepted are " + NODE + " or " + TRANSACTION);
                }
                // TYPE_CATEGORY_PARAMETER will always be of type SingleChoiceParameter
                @SuppressWarnings("unchecked") final PluginParameter<SingleChoiceParameterValue> typeCategoryParamter = (PluginParameter<SingleChoiceParameterValue>) parameters.get(TYPE_CATEGORY_PARAMETER_ID);
                types.sort(String::compareTo);
                SingleChoiceParameterType.setOptions(typeCategoryParamter, types);
            }
        }
    });
    params.addController(TYPE_CATEGORY_PARAMETER_ID, (PluginParameter<?> master, Map<String, PluginParameter<?>> parameters, ParameterChange change) -> {
        if (change == ParameterChange.VALUE) {
            final String mode = parameters.get(MODE_PARAMETER_ID).getStringValue();
            final String typeCategory = parameters.get(TYPE_CATEGORY_PARAMETER_ID).getStringValue();
            if (mode != null && typeCategory != null) {
                final List<String> types = new ArrayList<>();
                switch(mode) {
                    case NODE:
                        final SchemaVertexType typeCategoryVertexType = SchemaVertexTypeUtilities.getType(typeCategory);
                        for (final SchemaVertexType type : SchemaVertexTypeUtilities.getTypes()) {
                            if (type.getSuperType().equals(typeCategoryVertexType)) {
                                types.add(type.getName());
                            }
                        }
                        break;
                    case TRANSACTION:
                        final SchemaTransactionType typeCategoryTransactionType = SchemaTransactionTypeUtilities.getType(typeCategory);
                        for (final SchemaTransactionType type : SchemaTransactionTypeUtilities.getTypes()) {
                            if (type.getSuperType().equals(typeCategoryTransactionType)) {
                                types.add(type.getName());
                            }
                        }
                        break;
                    default:
                        break;
                }
                // update the sub level types
                // TYPE_PARAMETER will always be of type MultiChoiceParameter
                @SuppressWarnings("unchecked") final PluginParameter<MultiChoiceParameterValue> typeParamter = (PluginParameter<MultiChoiceParameterValue>) parameters.get(TYPE_PARAMETER_ID);
                types.sort(String::compareTo);
                MultiChoiceParameterType.setOptions(typeParamter, types);
                MultiChoiceParameterType.setChoices(typeParamter, types);
            }
        }
    });
    return params;
}
Also used : ParameterChange(au.gov.asd.tac.constellation.plugins.parameters.ParameterChange) SchemaVertexType(au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType) MultiChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue) ArrayList(java.util.ArrayList) SchemaTransactionType(au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType) IntegerParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue) PluginParameters(au.gov.asd.tac.constellation.plugins.parameters.PluginParameters) PluginParameter(au.gov.asd.tac.constellation.plugins.parameters.PluginParameter) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) SingleChoiceParameterValue(au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)

Aggregations

IntegerParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.IntegerParameterType.IntegerParameterValue)51 PluginParameters (au.gov.asd.tac.constellation.plugins.parameters.PluginParameters)44 BooleanParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.BooleanParameterType.BooleanParameterValue)27 SingleChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.SingleChoiceParameterType.SingleChoiceParameterValue)13 PluginParameter (au.gov.asd.tac.constellation.plugins.parameters.PluginParameter)11 FloatParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.FloatParameterType.FloatParameterValue)8 ArrayList (java.util.ArrayList)8 Test (org.testng.annotations.Test)8 MultiChoiceParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.MultiChoiceParameterType.MultiChoiceParameterValue)5 ObjectParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ObjectParameterType.ObjectParameterValue)5 ParameterChange (au.gov.asd.tac.constellation.plugins.parameters.ParameterChange)4 Map (java.util.Map)4 StringParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue)3 LinkedHashMap (java.util.LinkedHashMap)3 ColorParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.ColorParameterType.ColorParameterValue)2 LocalDateParameterValue (au.gov.asd.tac.constellation.plugins.parameters.types.LocalDateParameterType.LocalDateParameterValue)2 GraphElementType (au.gov.asd.tac.constellation.graph.GraphElementType)1 SchemaTransactionType (au.gov.asd.tac.constellation.graph.schema.type.SchemaTransactionType)1 SchemaVertexType (au.gov.asd.tac.constellation.graph.schema.type.SchemaVertexType)1 PluginParametersPane (au.gov.asd.tac.constellation.plugins.gui.PluginParametersPane)1