Skip to content

Commit

Permalink
reenable fork when executing wizizards
Browse files Browse the repository at this point in the history
  • Loading branch information
koentsje committed Jan 29, 2014
1 parent 381b1d5 commit ed55ad4
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.jboss.forge.addon.ui.input.UIPrompt;

Expand All @@ -19,27 +20,50 @@
*/
public class ForgeUIPrompt implements UIPrompt {
private final Shell shell;
private boolean booleanResult = false;
private String stringResult = null;

public ForgeUIPrompt(Shell shell) {
this.shell = shell;
}

@Override
public String prompt(String message) {
InputDialog dlg = new InputDialog(shell, "", message, "", null);
return (dlg.open() == Window.OK) ? dlg.getValue() : null;
public String prompt(final String message) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
InputDialog dlg = new InputDialog(shell, "", message, "", null);
stringResult = (dlg.open() == Window.OK) ? dlg.getValue() : null;
}

});
return stringResult;
}

@Override
public boolean promptBoolean(String message) {
return MessageDialog.openQuestion(shell, "Question", message);
public boolean promptBoolean(final String message) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
booleanResult = MessageDialog.openQuestion(shell, "Question", message);;
}

});
return booleanResult;
}

@Override
public String promptSecret(String message) {
// FIXME: Should mask the input
InputDialog dlg = new InputDialog(shell, "", message, "", null);
return (dlg.open() == Window.OK) ? dlg.getValue() : null;
public String promptSecret(final String message) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
// FIXME: Should mask the input
InputDialog dlg = new InputDialog(shell, "", message, "", null);
stringResult = (dlg.open() == Window.OK) ? dlg.getValue() : null;
}

});
return stringResult;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,7 @@ public boolean performFinish() {
public void performFinish(final IRunnableContext container,
final Shell shell) throws InvocationTargetException,
InterruptedException {
// Cannot fork, otherwise Eclipse Shell in UIPrompt will throw an
// exception
boolean fork = false;
container.run(fork, true, new IRunnableWithProgress() {
container.run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
Expand Down

0 comments on commit ed55ad4

Please sign in to comment.