Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide variable substitution selection dialog #276

Merged
merged 1 commit into from
Jun 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}

}