-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide variable substitution selection dialog
- Loading branch information
1 parent
c11f04e
commit 16a4316
Showing
3 changed files
with
37 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
plugin/src/de/anbos/eclipse/easyshell/plugin/misc/DynamicVariableSelector.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
|
||
} |