use of org.vcell.client.logicalwindow.LWContainerHandle in project vcell by virtualcell.
the class DialogUtils method showOptionsDialog.
private static String showOptionsDialog(final Component requester, Component showComponent, final int JOptionPaneMessageType, String[] options, String initOption, OKEnabler okEnabler, String title) {
VCellThreadChecker.checkSwingInvocation();
checkForNull(requester);
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
JOptionPane pane = new JOptionPane(showComponent, JOptionPaneMessageType, 0, null, options, initOption);
final JDialog dialog = new LWTitledOptionPaneDialog(lwParent, title, pane);
dialog.setResizable(true);
dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
if (okEnabler != null) {
okEnabler.setJOptionPane(pane);
}
try {
dialog.setVisible(true);
Object selectedValue = pane.getValue();
if (selectedValue == null || selectedValue.equals(JOptionPane.UNINITIALIZED_VALUE)) {
return SimpleUserMessage.OPTION_CANCEL;
} else {
return selectedValue.toString();
}
} finally {
dialog.dispose();
}
}
use of org.vcell.client.logicalwindow.LWContainerHandle 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.LWContainerHandle 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);
}
use of org.vcell.client.logicalwindow.LWContainerHandle in project vcell by virtualcell.
the class AsynchProgressPopup method getDialog.
/**
* select and created dialog based on {@link #knowsProgress} value
* @return {@link DefaultProgressDialog} or {@link IndefiniteProgressDialog}
*/
protected ProgressDialog getDialog() {
if (dialog == null) {
LWContainerHandle owner = LWNamespace.findLWOwner(requester);
if (knowsProgress) {
dialog = new LinearDefiniteProgressDialog(owner);
} else {
dialog = new IndefiniteProgressDialog(owner);
}
if (bCancelable && progressDialogListener != null) {
dialog.setCancelButtonVisible(true);
dialog.addProgressDialogListener(progressDialogListener);
} else {
dialog.setCancelButtonVisible(false);
}
BeanUtils.centerOnComponent(dialog, owner.getWindow());
dialog.setResizable(false);
if (title != null) {
dialog.setTitle(title);
}
if (message != null) {
dialog.setMessage(message);
}
dialog.setModal(inputBlocking);
if (!knowsProgress) {
dialog.setProgressBarString("WORKING...");
}
dialog.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
}
return dialog;
}
use of org.vcell.client.logicalwindow.LWContainerHandle in project vcell by virtualcell.
the class GeometrySubVolumePanel method createAnalyticSubVolume.
public static AnalyticSubVolume createAnalyticSubVolume(Component requester, int dimensions, Coordinate center, String newSubVolName) throws UserCancelException {
// Geometry g = getGeometry();
// final int dim = g.getDimension();
AddShapeJPanel addShapeJPanel = new AddShapeJPanel(dimensions);
addShapeJPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
addShapeJPanel.setDefaultCenter(center.getX(), center.getY(), center.getZ());
// (getGeometry().getDimension() > 2?getGeometry().getOrigin().getZ()+getGeometry().getExtent().getZ()/2:null));
while (true) {
try {
final boolean[] acceptFlag = new boolean[] { false };
LWContainerHandle lwParent = LWNamespace.findLWOwner(requester);
final JDialog d = new LWTitledDialog(lwParent, "Define New Subdomain Shape");
// BeanUtils.centerOnComponent(d, GeometrySubVolumePanel.this);
JPanel main = new JPanel();
BoxLayout mainBoxLayout = new BoxLayout(main, BoxLayout.Y_AXIS);
main.setLayout(mainBoxLayout);
JPanel menuPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
menuPanel.add(LWNamespace.createRightSideIconMenuBar());
main.add(menuPanel);
JPanel addCancelJPanel = new JPanel();
addCancelJPanel.setBorder(new EmptyBorder(10, 10, 10, 10));
BoxLayout addCancelBoxLayout = new BoxLayout(addCancelJPanel, BoxLayout.X_AXIS);
addCancelJPanel.setLayout(addCancelBoxLayout);
{
JButton helpButton = new JButton("Help");
helpButton.addActionListener(ae -> {
VcellHelpViewer.showStandaloneViewer();
});
addCancelJPanel.add(helpButton);
}
JButton addJButton = new JButton("New Subdomain");
addJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
d.dispose();
acceptFlag[0] = true;
}
});
addCancelJPanel.add(addJButton);
JButton cancelJButton = new JButton("Cancel");
cancelJButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
d.dispose();
}
});
addCancelJPanel.add(cancelJButton);
main.add(addShapeJPanel);
main.add(Box.createVerticalStrut(10));
main.add(addCancelJPanel);
main.add(Box.createVerticalStrut(10));
addShapeJPanel.addPropertyChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(AddShapeJPanel.PROPCHANGE_VALID_ANALYTIC)) {
addJButton.setEnabled(((Boolean) evt.getNewValue()));
}
}
});
d.setModalityType(ModalityType.DOCUMENT_MODAL);
// d.setModal(true);
d.getContentPane().add(main);
d.pack();
d.setSize(new Dimension(400, 400));
d.setVisible(true);
if (acceptFlag[0]) {
// new Expression(addShapeJPanel.getCurrentAnalyticExpression()), -1));
return new AnalyticSubVolume(null, newSubVolName, new Expression(addShapeJPanel.getCurrentAnalyticExpression()), -1);
} else {
throw UserCancelException.CANCEL_GENERIC;
}
} catch (UserCancelException uce) {
throw uce;
} catch (Exception e1) {
e1.printStackTrace();
DialogUtils.showErrorDialog(requester, "Error adding shape:\n" + e1.getMessage(), e1);
}
}
}
Aggregations