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);
}
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);
}
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));
}
}
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);
}
}
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);
}
Aggregations