use of au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue in project constellation by constellation-app.
the class VisualGraphTopComponent method getActions.
@Override
public Action[] getActions() {
// Add new actions above the default actions.
final ArrayList<Action> actionList = new ArrayList<>();
// An action that closes the topcomponent without saving the (possibly modified) graph.
final Action discard = new AbstractAction(DISCARD) {
@Override
public void actionPerformed(final ActionEvent e) {
savable.setModified(false);
close();
}
};
actionList.add(discard);
// If this graph is in a nebula, add some nebula-related actions.
final NebulaDataObject nebula = getGraphNode().getDataObject().getNebulaDataObject();
if (nebula != null) {
// Discard the nebula without saving.
final Action discardNebula = new AbstractAction("Discard nebula") {
@Override
public void actionPerformed(final ActionEvent e) {
TopComponent.getRegistry().getOpened().stream().filter(tc -> (tc instanceof VisualGraphTopComponent)).map(tc -> (VisualGraphTopComponent) tc).forEach(vtc -> {
final NebulaDataObject ndo = vtc.getGraphNode().getDataObject().getNebulaDataObject();
if (nebula.equalsPath(ndo)) {
vtc.savable.setModified(false);
vtc.close();
}
});
}
};
actionList.add(discardNebula);
// Are there any graphs in this nebula (if it exists) that need saving?
final List<Savable> savables = getNebulaSavables(nebula);
if (!savables.isEmpty()) {
// There's at least one graph in this nebula that needs saving...
final Action saveNebula = new AbstractAction("Save nebula") {
@Override
public void actionPerformed(final ActionEvent e) {
try {
for (final Savable s : savables) {
s.save();
}
} catch (final IOException ex) {
LOGGER.log(Level.SEVERE, ex.getLocalizedMessage(), ex);
}
}
};
actionList.add(saveNebula);
} else {
// No graphs in this nebula need saving, so offer to close the nebula.
final Action closeNebula = new AbstractAction("Close nebula") {
@Override
public void actionPerformed(final ActionEvent e) {
TopComponent.getRegistry().getOpened().stream().filter(tc -> (tc instanceof VisualGraphTopComponent)).map(tc -> (VisualGraphTopComponent) tc).forEach(vtc -> {
final NebulaDataObject ndo = vtc.getGraphNode().getDataObject().getNebulaDataObject();
if (nebula.equalsPath(ndo)) {
vtc.close();
}
});
}
};
actionList.add(closeNebula);
}
}
// An action that renames the topcomponent without saving the (possibly modified) graph.
final Action rename = new AbstractAction("Rename") {
@Override
public void actionPerformed(final ActionEvent e) {
final PluginParameters parameters = new PluginParameters();
final PluginParameter<StringParameterValue> newGraphNameParameter = StringParameterType.build(NEW_GRAPH_NAME_PARAMETER_ID);
newGraphNameParameter.setName("New Graph Name");
newGraphNameParameter.setStringValue(graphNode.getDisplayName());
newGraphNameParameter.storeRecentValue();
parameters.addParameter(newGraphNameParameter);
final PluginParametersSwingDialog dialog = new PluginParametersSwingDialog("Rename Graph", parameters);
dialog.showAndWait();
if (PluginParametersSwingDialog.OK.equals(dialog.getResult())) {
final String newGraphName = parameters.getStringValue(NEW_GRAPH_NAME_PARAMETER_ID);
if (!newGraphName.isEmpty()) {
try {
// set the graph object name so the name is retained when you Save As
graphNode.getDataObject().rename(newGraphName);
// set the other graph name properties
graphNode.setName(newGraphName);
graphNode.setDisplayName(newGraphName);
// set the top component
setName(newGraphName);
setDisplayName(newGraphName);
// this changes the text on the tab
setHtmlDisplayName(newGraphName);
} catch (final IOException ex) {
throw new RuntimeException(String.format("The name %s already exists.", newGraphName), ex);
}
savable.setModified(true);
}
}
}
};
actionList.add(rename);
// Add the default actions.
for (final Action action : super.getActions()) {
actionList.add(action);
}
return actionList.toArray(new Action[actionList.size()]);
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue in project constellation by constellation-app.
the class FindFormatter method createParameters.
@Override
public PluginParameters createParameters() {
PluginParameters params = new PluginParameters();
final PluginParameter<StringParameterValue> findParameter = StringParameterType.build(FIND_PARAMETER_ID);
findParameter.setName("Find");
findParameter.setStringValue("");
params.addParameter(findParameter);
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue in project constellation by constellation-app.
the class FindReplaceFormatter method createParameters.
@Override
public PluginParameters createParameters() {
PluginParameters params = new PluginParameters();
final PluginParameter<StringParameterValue> findParameter = StringParameterType.build(FIND_PARAMETER_ID);
findParameter.setName("Find");
findParameter.setStringValue("");
params.addParameter(findParameter);
final PluginParameter<StringParameterValue> replaceParameter = StringParameterType.build(REPLACE_PARAMETER_ID);
replaceParameter.setName("Replace");
replaceParameter.setStringValue("");
params.addParameter(replaceParameter);
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue in project constellation by constellation-app.
the class ScriptFormatter method createParameters.
@Override
public PluginParameters createParameters() {
PluginParameters params = new PluginParameters();
final PluginParameter<StringParameterValue> scriptParameter = StringParameterType.build(SCRIPT_PARAMETER_ID);
StringParameterType.setLines(scriptParameter, 10);
scriptParameter.setName("Script");
scriptParameter.setStringValue("");
params.addParameter(scriptParameter);
return params;
}
use of au.gov.asd.tac.constellation.plugins.parameters.types.StringParameterValue in project constellation by constellation-app.
the class TestParameterBuildingPlugin method createParameters.
@Override
public PluginParameters createParameters() {
final PluginParameters params = new PluginParameters();
final PluginParameter<SingleChoiceParameterValue> fupChoiceParam = SingleChoiceParameterType.build(CHOICE_PARAMETER_ID);
fupChoiceParam.setName(SOME_CHOICE_NAME);
fupChoiceParam.setDescription(SOME_CHOICE_DESCRIPTION);
SingleChoiceParameterType.setOptions(fupChoiceParam, Arrays.asList("Choice 1", "Choice 2", "Choice 3"));
SingleChoiceParameterType.setChoice(fupChoiceParam, "Choice 1");
params.addParameter(fupChoiceParam);
final PluginParameter<LocalDateParameterValue> ldParam = LocalDateParameterType.build(LOCALDATE_PARAMETER_ID);
ldParam.setName("Date");
ldParam.setDescription("Pick a day");
params.addParameter(ldParam);
final PluginParameter<IntegerParameterValue> lenParam = IntegerParameterType.build(INT_PARAMETER_ID);
lenParam.setName(SOME_INT_NAME);
lenParam.setDescription(SOME_INT_DESCRIPTION);
lenParam.setIntegerValue(5);
params.addParameter(lenParam);
final PluginParameter<FloatParameterValue> thresholdParam = FloatParameterType.build(FLOAT_PARAMETER_ID);
thresholdParam.setName(FLOAT_NAME);
thresholdParam.setDescription(FLOAT_DESCRIPTION);
thresholdParam.setFloatValue(0F);
FloatParameterType.setMinimum(thresholdParam, 0);
FloatParameterType.setMaximum(thresholdParam, 1);
FloatParameterType.setStep(thresholdParam, 0.1F);
params.addParameter(thresholdParam);
final PluginParameter<BooleanParameterValue> caseParam = BooleanParameterType.build(BOOLEAN_PARAMETER_ID);
caseParam.setName(SOME_BOOLEAN_NAME);
caseParam.setDescription(SOME_BOOLEAN_DESCRIPTION);
params.addParameter(caseParam);
for (int i = 0; i < 2; i++) {
final PluginParameter<StringParameterValue> text = StringParameterType.build("text" + i);
text.setName("Some text " + i);
text.setDescription("Type some text into this thing");
text.setStringValue("Value " + i);
params.addParameter(text);
}
return params;
}
Aggregations