Search in sources :

Example 1 with MessageDialogResult

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

the class RunMessageBox method showInputDialog2.

@Test(enabled = !true)
public void showInputDialog2() {
    MessageDialog messageBox = uc.obtainMessageDialog();
    MessageDialogResult result = messageBox.showInputDialog("Press ok!", "initialValue");
    Assert.assertEquals(result.getReturnValue(), ReturnType.OK);
    Assert.assertEquals(result.getUserInput(), "initialValue");
}
Also used : MessageDialogResult(org.openecard.gui.message.MessageDialogResult) MessageDialog(org.openecard.gui.MessageDialog) Test(org.testng.annotations.Test) BeforeTest(org.testng.annotations.BeforeTest)

Example 2 with MessageDialogResult

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

the class RunMessageBox method showInputDialog4.

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

Example 3 with MessageDialogResult

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

the class SwingMessageDialog method showOptionDialog.

@Override
public MessageDialogResult showOptionDialog(String msg, String title, OptionType optionType, DialogType msgType, byte[] iconData, String... options) {
    msg = formatMessage(msg);
    if (options.length == 0) {
        throw new IllegalArgumentException("List of options must be given.");
    }
    ImageIcon icon = null;
    if (iconData != null) {
        icon = new ImageIcon(iconData);
    }
    JOptionPane jop;
    jop = new JOptionPane(msg, convertDialogType(msgType), convertOptionType(optionType), icon, options);
    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);
    }
    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 4 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, String initialValue) {
    msg = formatMessage(msg);
    JOptionPane jop = new JOptionPane(msg, convertDialogType(msgType), JOptionPane.OK_CANCEL_OPTION);
    JDialog dialog = jop.createDialog(title);
    dialog.setIconImage(FRAME_ICON);
    jop.setInitialSelectionValue(initialValue);
    jop.setWantsInput(true);
    if (SwingDialogWrapper.needsFullscreen()) {
        dialog.setAlwaysOnTop(true);
    }
    dialog.setVisible(true);
    dialog.toFront();
    Object returnValue = jop.getInputValue();
    if (returnValue == null) {
        return new MessageDialogResult((String) null);
    } else {
        return new MessageDialogResult((String) returnValue);
    }
}
Also used : MessageDialogResult(org.openecard.gui.message.MessageDialogResult) JOptionPane(javax.swing.JOptionPane) JDialog(javax.swing.JDialog)

Example 5 with MessageDialogResult

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

the class RunMessageBox method showOptionDialog.

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

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