use of org.vcell.client.logicalwindow.LWTitledOptionPaneDialog in project vcell by virtualcell.
the class DialogUtils method showInfoDialog.
/**
* Insert the method's description here.
* Creation date: (5/21/2004 3:17:45 AM)
* @param owner java.awt.Component
* @param message java.lang.Object
*/
public static void showInfoDialog(final Component requester, final String title, final String message) {
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
Doer doer = () -> {
JPanel panel = MessagePanelFactory.createSimple(message);
JOptionPane pane = new JOptionPane(panel, JOptionPane.INFORMATION_MESSAGE);
LWDialog dialog = new LWTitledOptionPaneDialog(lwParent, title, pane);
dialog.setResizable(true);
showOnce(dialog);
};
VCSwingFunction.executeAsRuntimeException(doer);
}
use of org.vcell.client.logicalwindow.LWTitledOptionPaneDialog in project vcell by virtualcell.
the class DialogUtils method showListDialog.
/**
* Insert the method's description here.
* Creation date: (5/21/2004 3:23:18 AM)
* @return int
* @param owner java.awt.Component
* @param message java.lang.String
* @param preferences cbit.vcell.client.UserPreferences
* @param preferenceName java.lang.String
*/
public static Object showListDialog(final Component requester, final Object[] names, final String dialogTitle, final ListCellRenderer<Object> listCellRenderer) {
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
Producer<Object> prod = () -> {
JPanel panel = new JPanel(new BorderLayout());
final JOptionPane pane = new JOptionPane(null, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION);
JScrollPane scroller = new JScrollPane(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED, JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
final JList<Object> list = new JList<>(names);
if (listCellRenderer != null) {
list.setCellRenderer(listCellRenderer);
}
list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
list.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
scroller.setViewportView(list);
Dimension size = new Dimension(list.getPreferredSize());
size.width = Math.max(80, Math.min(500, size.width + 40));
size.height = Math.max(75, Math.min(500, size.height + 40));
scroller.getViewport().setPreferredSize(size);
panel.add(scroller, BorderLayout.CENTER);
pane.setMessage(panel);
setInternalNotCancelEnabled(pane, false, false);
list.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent e) {
if (!e.getValueIsAdjusting()) {
DialogUtils.setInternalNotCancelEnabled(pane, list.getSelectedIndex() != -1, false);
}
}
});
final JDialog dialog = new LWTitledOptionPaneDialog(lwParent, dialogTitle, pane);
dialog.setResizable(true);
try {
dialog.setVisible(true);
Object selectedValue = pane.getValue();
if (selectedValue == null || (((Integer) selectedValue).intValue() == JOptionPane.CLOSED_OPTION) || (((Integer) selectedValue).intValue() == JOptionPane.CANCEL_OPTION)) {
return null;
} else {
int index = list.getSelectedIndex();
if (index >= 0 && index < names.length) {
return names[index];
}
// Should never get here
return null;
}
} finally {
dialog.dispose();
}
};
return VCSwingFunction.executeAsRuntimeException(prod);
}
Aggregations