Search in sources :

Example 6 with MessageDialogResult

use of org.openecard.gui.message.MessageDialogResult in project open-ecard by ecsec.

the class RunMessageBox method showConfirmDialog4.

@Test(enabled = !true)
public void showConfirmDialog4() throws IOException {
    MessageDialog messageBox = uc.obtainMessageDialog();
    MessageDialogResult result = messageBox.showConfirmDialog("Press ok!", TITLE, OptionType.OK_CANCEL_OPTION, DialogType.ERROR_MESSAGE, iconData);
    Assert.assertEquals(result.getReturnValue(), ReturnType.OK);
}
Also used : MessageDialogResult(org.openecard.gui.message.MessageDialogResult) MessageDialog(org.openecard.gui.MessageDialog) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 7 with MessageDialogResult

use of org.openecard.gui.message.MessageDialogResult in project open-ecard by ecsec.

the class RunMessageBox method showConfirmDialog3.

@Test(enabled = !true)
public void showConfirmDialog3() {
    MessageDialog messageBox = uc.obtainMessageDialog();
    MessageDialogResult result = messageBox.showConfirmDialog("Press ok!", TITLE, OptionType.OK_CANCEL_OPTION, DialogType.ERROR_MESSAGE);
    Assert.assertEquals(result.getReturnValue(), ReturnType.OK);
}
Also used : MessageDialogResult(org.openecard.gui.message.MessageDialogResult) MessageDialog(org.openecard.gui.MessageDialog) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 8 with MessageDialogResult

use of org.openecard.gui.message.MessageDialogResult in project open-ecard by ecsec.

the class SwingMessageDialog method showConfirmDialog.

@Override
public MessageDialogResult showConfirmDialog(String msg, String title, OptionType optionType, DialogType msgType, @Nullable byte[] iconData) {
    msg = formatMessage(msg);
    ImageIcon icon = iconData != null ? new ImageIcon(iconData) : null;
    JOptionPane jop = new JOptionPane(msg, convertDialogType(msgType), convertOptionType(optionType), icon);
    JDialog dialog = jop.createDialog(title);
    dialog.setIconImage(FRAME_ICON);
    if (SwingDialogWrapper.needsFullscreen()) {
        dialog.setAlwaysOnTop(true);
    }
    dialog.setVisible(true);
    dialog.toFront();
    Object returnValue = jop.getValue();
    if (returnValue == null) {
        return new MessageDialogResult(ReturnType.CANCEL);
    } else {
        return new MessageDialogResult(convertReturnType((Integer) returnValue));
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) MessageDialogResult(org.openecard.gui.message.MessageDialogResult) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 9 with MessageDialogResult

use of org.openecard.gui.message.MessageDialogResult in project open-ecard by ecsec.

the class SwingMessageDialog method showInputDialog.

@Override
public MessageDialogResult showInputDialog(String msg, String title, DialogType msgType, byte[] iconData, int initialSelectedIndex, String... options) {
    msg = formatMessage(msg);
    List<String> optionsList = Arrays.asList(options);
    if (optionsList.isEmpty()) {
        throw new IllegalArgumentException("List of options must be given.");
    }
    if (initialSelectedIndex > optionsList.size()) {
        initialSelectedIndex = 0;
    }
    String initialValue = optionsList.get(initialSelectedIndex);
    ImageIcon icon = new ImageIcon(iconData);
    JOptionPane jop = new JOptionPane(msg, convertDialogType(msgType), JOptionPane.OK_CANCEL_OPTION, icon);
    JDialog dialog = jop.createDialog(title);
    dialog.setIconImage(FRAME_ICON);
    jop.setSelectionValues(options);
    jop.setInitialSelectionValue(initialValue);
    jop.setWantsInput(true);
    if (SwingDialogWrapper.needsFullscreen()) {
        dialog.setAlwaysOnTop(true);
    }
    dialog.setVisible(true);
    dialog.toFront();
    Object returnValue = jop.getInputValue();
    if ("uninitializedValue".equals(returnValue) && !optionsList.contains("uninitializedValue")) {
        return new MessageDialogResult(ReturnType.CANCEL);
    } else {
        return new MessageDialogResult((String) returnValue);
    }
}
Also used : ImageIcon(javax.swing.ImageIcon) MessageDialogResult(org.openecard.gui.message.MessageDialogResult) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 10 with MessageDialogResult

use of org.openecard.gui.message.MessageDialogResult in project open-ecard by ecsec.

the class SwingMessageDialog method showMessageDialog.

@Override
public MessageDialogResult showMessageDialog(String msg, String title, DialogType msgType, @Nullable byte[] iconData) {
    msg = formatMessage(msg);
    ImageIcon icon = iconData != null ? new ImageIcon(iconData) : null;
    JOptionPane jop = new JOptionPane(msg, convertDialogType(msgType), JOptionPane.DEFAULT_OPTION, icon);
    final JDialog dialog = jop.createDialog(title);
    dialog.setIconImage(FRAME_ICON);
    if (SwingDialogWrapper.needsFullscreen()) {
        dialog.setAlwaysOnTop(true);
    }
    dialog.setVisible(true);
    dialog.toFront();
    return new MessageDialogResult(ReturnType.OK);
}
Also used : ImageIcon(javax.swing.ImageIcon) MessageDialogResult(org.openecard.gui.message.MessageDialogResult) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Aggregations

MessageDialogResult (org.openecard.gui.message.MessageDialogResult)14 MessageDialog (org.openecard.gui.MessageDialog)9 BeforeTest (org.testng.annotations.BeforeTest)9 Test (org.testng.annotations.Test)9 JDialog (javax.swing.JDialog)5 JOptionPane (javax.swing.JOptionPane)5 ImageIcon (javax.swing.ImageIcon)4