Skip to content

Commit 16a4316

Browse files
Bananeweizenanb0s
authored andcommitted
Provide variable substitution selection dialog
1 parent c11f04e commit 16a4316

File tree

3 files changed

+37
-1
lines changed

3 files changed

+37
-1
lines changed

plugin/META-INF/MANIFEST.MF

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
1515
org.eclipse.cdt.ui;resolution:=optional,
1616
org.eclipse.cdt.core;resolution:=optional,
1717
org.eclipse.ui.workbench.texteditor,
18-
org.eclipse.jface.text
18+
org.eclipse.jface.text,
19+
org.eclipse.debug.ui
1920
Bundle-RequiredExecutionEnvironment: JavaSE-11
2021
Bundle-ActivationPolicy: lazy
2122
Bundle-ClassPath: target/easyshell-library.jar

plugin/plugin.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,5 +235,12 @@
235235
name="EasyShell All (Multiple Action)">
236236
</editor>
237237
</extension>
238+
<extension
239+
point="org.eclipse.debug.ui.stringVariablePresentations">
240+
<variablePresentation
241+
argumentSelector="de.anbos.eclipse.easyshell.plugin.misc.DynamicVariableSelector"
242+
variableName="easyshell">
243+
</variablePresentation>
244+
</extension>
238245

239246
</plugin>
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package de.anbos.eclipse.easyshell.plugin.misc;
2+
3+
import org.eclipse.core.variables.IStringVariable;
4+
import org.eclipse.debug.ui.stringsubstitution.IArgumentSelector;
5+
import org.eclipse.jface.viewers.LabelProvider;
6+
import org.eclipse.jface.window.Window;
7+
import org.eclipse.swt.widgets.Shell;
8+
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
9+
10+
import de.anbos.eclipse.easyshell.plugin.types.Variable;
11+
12+
public class DynamicVariableSelector implements IArgumentSelector {
13+
14+
@Override
15+
public String selectArgument(IStringVariable stringVariable, Shell shell) {
16+
ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
17+
var varNames = Variable.getVisibleVariables().stream().map(variable -> variable.getName()).sorted()
18+
.toArray(String[]::new);
19+
dialog.setElements(varNames);
20+
dialog.setTitle("Select EasyShell Variable");
21+
dialog.setMessage("Select an EasyShell variable (? = any character, * = any String):");
22+
if (dialog.open() == Window.OK) {
23+
return (String) dialog.getResult()[0];
24+
}
25+
return null;
26+
}
27+
28+
}

0 commit comments

Comments
 (0)