use of org.vcell.client.logicalwindow.LWTitledDialog 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