X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=net.mograsim.logic.model.editor%2Fsrc%2Fnet%2Fmograsim%2Flogic%2Fmodel%2Feditor%2Fui%2FDialogManager.java;h=df7455e66e2fa12420c83fb249fa91640d39f55d;hb=8bed58cd47f4e53a0a83e066d38864aa6875502f;hp=b6d6ad9c0ac900ab0bc06d2b40d0061b87e9cd01;hpb=a00663c79d0e26b494ff79eee4b6c049f086c7e0;p=Mograsim.git diff --git a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/DialogManager.java b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/DialogManager.java index b6d6ad9c..df7455e6 100644 --- a/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/DialogManager.java +++ b/net.mograsim.logic.model.editor/src/net/mograsim/logic/model/editor/ui/DialogManager.java @@ -15,7 +15,7 @@ import org.eclipse.swt.widgets.Text; public class DialogManager { private Shell parent; - + public DialogManager(Shell parent) { this.parent = parent; @@ -32,14 +32,14 @@ public class DialogManager private static abstract class FlexibleInputsDialog extends Dialog { private final String title, acceptLabel, cancelLabel; - + protected String[] result; public FlexibleInputsDialog(String title, String acceptLabel, String cancelLabel, String... inputs) { this(false, title, acceptLabel, cancelLabel, inputs); } - + public FlexibleInputsDialog(boolean resizable, String title, String acceptLabel, String cancelLabel, String... inputs) { super(new Shell(SWT.CLOSE | (resizable ? SWT.RESIZE | SWT.MAX : 0) | SWT.TITLE | SWT.MIN | SWT.ON_TOP | SWT.APPLICATION_MODAL)); @@ -47,8 +47,9 @@ public class DialogManager this.acceptLabel = acceptLabel; this.cancelLabel = cancelLabel; } - + protected abstract void setupWidgets(Composite parent); + protected abstract void buildResult(); /** @@ -73,15 +74,14 @@ public class DialogManager gd.grabExcessVerticalSpace = true; inputContainer.setLayoutData(gd); setupWidgets(inputContainer); - - + Button b1 = new Button(shell, SWT.PUSH); b1.addListener(SWT.Selection, e -> { buildResult(); shell.dispose(); }); - + b1.setText(acceptLabel); Button b2 = new Button(shell, SWT.PUSH); b2.addListener(SWT.Selection, e -> @@ -104,13 +104,13 @@ public class DialogManager { private final String[] inputs; private Text[] textFields; - + public MultiTextFieldsDialog(String title, String acceptLabel, String cancelLabel, String... inputs) { super(title, acceptLabel, cancelLabel); this.inputs = inputs; } - + @Override protected void setupWidgets(Composite parent) { @@ -138,28 +138,29 @@ public class DialogManager for (int i = 0; i < textFields.length; i++) result[i] = textFields[i].getText(); } - + } - + /** - * @return The Strings entered, in order of the input labels the dialog was opened with, if the dialog was accepted, null if the dialog was cancelled. + * @return The Strings entered, in order of the input labels the dialog was opened with, if the dialog was accepted, null if the dialog + * was cancelled. */ public static String[] openMultiTextDialog(String title, String acceptLabel, String cancelLabel, String... inputs) { return new MultiTextFieldsDialog(title, acceptLabel, cancelLabel, inputs).open(); } - + public static class MultiLineTextFieldDialog extends FlexibleInputsDialog { private final String input; private Text textField; - + public MultiLineTextFieldDialog(String title, String acceptLabel, String cancelLabel, String input) { super(true, title, acceptLabel, cancelLabel); this.input = input; } - + @Override protected void setupWidgets(Composite parent) { @@ -184,7 +185,7 @@ public class DialogManager protected void buildResult() { result = new String[] { textField.getText() }; - } + } } /**