Skip to content

Commit

Permalink
Provide variable substitution selection dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
Bananeweizen authored and anb0s committed Jun 17, 2023
1 parent c11f04e commit 16a4316
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 1 deletion.
3 changes: 2 additions & 1 deletion plugin/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.cdt.ui;resolution:=optional,
org.eclipse.cdt.core;resolution:=optional,
org.eclipse.ui.workbench.texteditor,
org.eclipse.jface.text
org.eclipse.jface.text,
org.eclipse.debug.ui
Bundle-RequiredExecutionEnvironment: JavaSE-11
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: target/easyshell-library.jar
Expand Down
7 changes: 7 additions & 0 deletions plugin/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,5 +235,12 @@
name="EasyShell All (Multiple Action)">
</editor>
</extension>
<extension
point="org.eclipse.debug.ui.stringVariablePresentations">
<variablePresentation
argumentSelector="de.anbos.eclipse.easyshell.plugin.misc.DynamicVariableSelector"
variableName="easyshell">
</variablePresentation>
</extension>

</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package de.anbos.eclipse.easyshell.plugin.misc;

import org.eclipse.core.variables.IStringVariable;
import org.eclipse.debug.ui.stringsubstitution.IArgumentSelector;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

import de.anbos.eclipse.easyshell.plugin.types.Variable;

public class DynamicVariableSelector implements IArgumentSelector {

@Override
public String selectArgument(IStringVariable stringVariable, Shell shell) {
ElementListSelectionDialog dialog = new ElementListSelectionDialog(shell, new LabelProvider());
var varNames = Variable.getVisibleVariables().stream().map(variable -> variable.getName()).sorted()
.toArray(String[]::new);
dialog.setElements(varNames);
dialog.setTitle("Select EasyShell Variable");
dialog.setMessage("Select an EasyShell variable (? = any character, * = any String):");
if (dialog.open() == Window.OK) {
return (String) dialog.getResult()[0];
}
return null;
}

}

0 comments on commit 16a4316

Please sign in to comment.