import java.awt.FlowLayout;
import java.awt.Font;
+import java.util.ArrayList;
+import java.util.List;
import java.util.concurrent.Callable;
import javax.swing.BoxLayout;
panel.add(descriptionPanel);
JLabel nameLabel = new JLabel(label1);
- nameLabel.setFont(COURIER_12);
+ // nameLabel.setFont(COURIER_12);
namePanel.add(nameLabel);
id = new JTextField(name, 40);
if (desc != null || label2 != null)
{
JLabel descLabel = new JLabel(label2);
- descLabel.setFont(COURIER_12);
+ // descLabel.setFont(COURIER_12);
descriptionPanel.add(descLabel);
descriptionPanel.add(description);
}
*
* @param action
*/
- public void showDialog(JComponent parent, String title, Callable action)
+ public void showDialog(JComponent parent, String title,
+ Callable<Void> action)
{
- Object[] options = new Object[] { MessageManager.getString("action.ok"),
- MessageManager.getString("action.cancel") };
- JvOptionPane.newOptionDialog(parent).setResponseHandler(0, action)
- .showInternalDialog(panel, title,
- JvOptionPane.YES_NO_CANCEL_OPTION,
- JvOptionPane.PLAIN_MESSAGE, null, options,
- MessageManager.getString("action.ok"));
+ String ok = MessageManager.getString("action.ok");
+ String cancel = MessageManager.getString("action.cancel");
+ String[] options = new String[] { ok, cancel };
+
+ /*
+ JvOptionPane.newOptionDialog(parent)
+ .setResponseHandler(JvOptionPane.OK_OPTION, action)
+ .showInternalDialog(panel, title, JvOptionPane.OK_CANCEL_OPTION,
+ JvOptionPane.PLAIN_MESSAGE, null, options, ok);
+ */
+
+ List<Callable<Void>> actions = new ArrayList<>();
+ actions.add(action);
+ actions.add(JvOptionPane.NULLCALLABLE);
+
+ JvOptionPane.frameDialog(panel, title, JvOptionPane.PLAIN_MESSAGE,
+ options, ok, actions, false);
}
}
private static boolean interactiveMode = true;
+ public static final Callable<Void> NULLCALLABLE = () -> {
+ return null;
+ };
+
private Component parentComponent;
private ExecutorService executor = Executors.newCachedThreadPool();
}
}
- public void showInternalDialog(JPanel mainPanel, String title,
+ public void showInternalDialog(Object mainPanel, String title,
int yesNoCancelOption, int questionMessage, Icon icon,
Object[] options, String initresponse)
{
this.setMessage(mainPanel);
ourOptions = Arrays.asList(options);
- int response;
if (parentComponent != this
&& !(parentComponent == null && Desktop.instance == null))
{
public JvOptionPane setResponseHandler(Object response,
Callable<Void> action)
{
+ if (action == null)
+ {
+ action = NULLCALLABLE;
+ }
callbacks.put(response, action);
return this;
}
public ExecutorService getExecutor()
{
if (executor == null)
- executor = Executors.newSingleThreadExecutor();
+ executor = Executors.newCachedThreadPool();
return executor;
}
}
}
- public static JvOptionPane frameDialog(String message, String title,
+ public static JvOptionPane frameDialog(Object message, String title,
int messageType, String[] buttonsTextS, String defaultButtonS,
- Callable<Void>[] handlers, boolean modal)
+ List<Callable<Void>> handlers, boolean modal)
{
JFrame parent = new JFrame();
JvOptionPane jvop = JvOptionPane.newOptionDialog();
{
dialogType = JOptionPane.YES_NO_CANCEL_OPTION;
}
- Callable<Void> nullCallable = () -> {
- return null;
- };
jvop.setResponseHandler(JOptionPane.YES_OPTION,
- (handlers != null && handlers.length > 0) ? handlers[0]
- : nullCallable);
+ (handlers != null && handlers.size() > 0) ? handlers.get(0)
+ : NULLCALLABLE);
if (dialogType == JOptionPane.YES_NO_OPTION
|| dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
{
jvop.setResponseHandler(JOptionPane.NO_OPTION,
- (handlers != null && handlers.length > 1) ? handlers[1]
- : nullCallable);
+ (handlers != null && handlers.size() > 1) ? handlers.get(1)
+ : NULLCALLABLE);
}
if (dialogType == JOptionPane.YES_NO_CANCEL_OPTION)
{
jvop.setResponseHandler(JOptionPane.CANCEL_OPTION,
- (handlers != null && handlers.length > 2) ? handlers[2]
- : nullCallable);
+ (handlers != null && handlers.size() > 2) ? handlers.get(2)
+ : NULLCALLABLE);
}
final int dt = dialogType;
{
if (dialog.getName().indexOf(" ") > -1)
{
- JvOptionPane.frameDialog(
- MessageManager.getString(
- "label.spaces_converted_to_underscores"),
- MessageManager.getString(
- "label.no_spaces_allowed_sequence_name"),
- JvOptionPane.WARNING_MESSAGE, null, null, null,
- false);
+ if (!Platform.isJS())
+ /**
+ * Java only
+ *
+ * @j2sIgnore
+ */
+ {
+ String ok = MessageManager.getString("action.ok");
+ String cancel = MessageManager
+ .getString("action.cancel");
+ String message = MessageManager.getString(
+ "label.spaces_converted_to_underscores");
+ String title = MessageManager.getString(
+ "label.no_spaces_allowed_sequence_name");
+ Object[] options = new Object[] { ok, cancel };
+
+ JvOptionPane.frameDialog(message, title,
+ JvOptionPane.WARNING_MESSAGE, null, null, null,
+ false);
+ }
}
sequence.setName(dialog.getName().replace(' ', '_'));
ap.paintAlignment(false, false);