MCPcopy Create free account
hub / github.com/Truphone/LPAdesktop / DialogHelper

Class DialogHelper

src/main/java/com/truphone/lpap/DialogHelper.java:18–64  ·  view source on GitHub ↗

@author amilcar.pereira

Source from the content-addressed store, hash-verified

16 * @author amilcar.pereira
17 */
18public class DialogHelper {
19
20 public static void setUpMacShortcuts(javax.swing.InputMap im) {
21 im.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, KeyEvent.META_DOWN_MASK), DefaultEditorKit.copyAction);
22 im.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, KeyEvent.META_DOWN_MASK), DefaultEditorKit.pasteAction);
23 im.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, KeyEvent.META_DOWN_MASK), DefaultEditorKit.cutAction);
24 }
25
26 public static Optional<String> showInputDialog(JFrame parent, String text, String predefinedValue) {
27 InputDialog id = new InputDialog(parent);
28 id.setText(text);
29 id.setPredefinedValue(predefinedValue);
30 id.setVisible(true);
31
32 return Optional.ofNullable(id.isOkPressed() ? id.getValue() : null);
33 }
34
35
36 public static Optional<String> showInputActivationCodeDialog(JFrame parent, String text, String predefinedValue) {
37 InputActivationCodeDialog id = new InputActivationCodeDialog(parent);
38
39 id.setPredefinedMatchingId(predefinedValue);
40 id.setVisible(true);
41
42 String matchingID = id.getMatchingId();
43 String server = id.getServerURL();
44
45 //returns the activation code
46 return Optional.ofNullable(id.isOkPressed() ? String.format("1$%s$%s", server, matchingID) : null);
47 }
48
49 public static void showMessageDialog(JFrame parent, String text) {
50 MessageDialog d = new MessageDialog(parent);
51 d.setText(text);
52
53 d.setVisible(true);
54 }
55
56 public static int showConfirmDialog(JFrame parent, String text, String title) {
57 ConfirmDialog d = new ConfirmDialog(parent);
58 d.setTitle(title);
59 d.setText(text);
60
61 d.setVisible(true);
62 return d.getResult();
63 }
64}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected