use of javax.swing.JSeparator in project vcell by virtualcell.
the class DefineROI_Panel method initialize.
public void initialize() {
setLayout(new BorderLayout());
JPanel tPanel = new JPanel(new BorderLayout());
tPanel.add(getTopPanel(), BorderLayout.NORTH);
tPanel.add(new JSeparator(), BorderLayout.CENTER);
add(tPanel, BorderLayout.NORTH);
add(getCenterPanel(), BorderLayout.CENTER);
}
use of javax.swing.JSeparator in project vcell by virtualcell.
the class MolecularTypePropertiesPanel method showPopupMenu.
private void showPopupMenu(MouseEvent e) {
if (!e.isPopupTrigger()) {
return;
}
if (popupMenu == null) {
popupMenu = new JPopupMenu();
}
if (popupMenu.isShowing()) {
return;
}
selectClickPath(e);
TreePath[] selectedPaths = molecularTypeTree.getSelectionPaths();
boolean bDelete = true;
boolean bAdd = true;
if (selectedPaths == null) {
return;
}
for (TreePath tp : selectedPaths) {
Object obj = tp.getLastPathComponent();
if (obj == null || !(obj instanceof BioModelNode)) {
continue;
}
BioModelNode selectedNode = (BioModelNode) obj;
Object userObject = selectedNode.getUserObject();
if (userObject instanceof MolecularType) {
getAddFromTreeMenuItem().setText("Add " + MolecularComponent.typeName);
bAdd = true;
bDelete = false;
} else if (userObject instanceof MolecularComponent) {
getAddFromTreeMenuItem().setText("Add " + ComponentStateDefinition.typeName);
bAdd = true;
bDelete = true;
} else if (userObject instanceof ComponentStateDefinition) {
bAdd = false;
bDelete = true;
}
}
popupMenu.removeAll();
// everything can be renamed
popupMenu.add(getRenameFromTreeMenuItem());
if (bDelete) {
popupMenu.add(getDeleteFromTreeMenuItem());
}
popupMenu.add(new JSeparator());
if (bAdd) {
popupMenu.add(getAddFromTreeMenuItem());
}
Point mousePoint = e.getPoint();
popupMenu.show(molecularTypeTree, mousePoint.x, mousePoint.y);
}
use of javax.swing.JSeparator in project vcell by virtualcell.
the class MolecularTypePropertiesPanel method showPopupMenu.
private void showPopupMenu(MouseEvent e, PointLocationInShapeContext locationContext) {
if (popupFromShapeMenu == null) {
popupFromShapeMenu = new JPopupMenu();
}
if (popupFromShapeMenu.isShowing()) {
return;
}
final Object deepestShape = locationContext.getDeepestShape();
final Object selectedObject;
if (deepestShape == null) {
selectedObject = null;
// when cursor is outside there's nothing to do ???
System.out.println("outside");
return;
} else if (deepestShape instanceof ComponentStateLargeShape) {
System.out.println("inside state");
if (((ComponentStateLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((ComponentStateLargeShape) deepestShape).getComponentStateDefinition();
} else {
// right click only works on highlighted entity, if it's not highlighted we simply return
return;
}
} else if (deepestShape instanceof MolecularComponentLargeShape) {
System.out.println("inside component");
if (((MolecularComponentLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularComponentLargeShape) deepestShape).getMolecularComponent();
} else {
return;
}
} else if (deepestShape instanceof MolecularTypeLargeShape) {
System.out.println("inside molecule");
if (((MolecularTypeLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularTypeLargeShape) deepestShape).getMolecularType();
} else {
return;
}
} else if (deepestShape instanceof SpeciesPatternLargeShape) {
// this cannot happen, here just for symmetry
System.out.println("inside species pattern");
if (((SpeciesPatternLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((SpeciesPatternLargeShape) deepestShape).getSpeciesPattern();
} else {
return;
}
} else {
selectedObject = null;
System.out.println("inside something else?");
return;
}
System.out.println(selectedObject);
boolean bDelete = false;
boolean bAdd = false;
popupFromShapeMenu.removeAll();
Point mousePoint = e.getPoint();
if (selectedObject instanceof MolecularType) {
// rename, add
if (selectedObject != molecularType) {
throw new RuntimeException("The selected object from shape different from the current object");
}
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem addMenuItem = new JMenuItem("Add " + MolecularComponent.typeName);
// Icon icon = new MolecularTypeSmallShape(1, 4, mt, gc, mt);
// menuItem.setIcon(icon);
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(addMenuItem);
addMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent molecularComponent = molecularType.createMolecularComponent();
molecularType.addMolecularComponent(molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustSpeciesContextPatterns(molecularType, molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, molecularComponent);
bioModel.getModel().getRbmModelContainer().adjustRulesPatterns(molecularType, molecularComponent);
// editInPlace((LargeShape)deepestShape);
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
} else if (selectedObject instanceof MolecularComponent) {
// move left / right / separator / rename, delete, separator, add
String moveRightMenuText = "Move <b>" + "right" + "</b>";
moveRightMenuText = "<html>" + moveRightMenuText + "</html>";
JMenuItem moveRightMenuItem = new JMenuItem(moveRightMenuText);
Icon icon = VCellIcons.moveRightIcon;
moveRightMenuItem.setIcon(icon);
moveRightMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent from = (MolecularComponent) selectedObject;
List<MolecularComponent> mcList = molecularType.getComponentList();
int fromIndex = mcList.indexOf(from);
if (mcList.size() == fromIndex + 1) {
// already the last element
return;
}
int toIndex = fromIndex + 1;
MolecularComponent to = mcList.remove(toIndex);
mcList.add(fromIndex, to);
molecularTypeTreeModel.populateTree();
molecularType.firePropertyChange("entityChange", null, "bbb");
}
});
popupFromShapeMenu.add(moveRightMenuItem);
String moveLeftMenuText = "Move <b>" + "left" + "</b>";
moveLeftMenuText = "<html>" + moveLeftMenuText + "</html>";
JMenuItem moveLeftMenuItem = new JMenuItem(moveLeftMenuText);
icon = VCellIcons.moveLeftIcon;
moveLeftMenuItem.setIcon(icon);
moveLeftMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent from = (MolecularComponent) selectedObject;
List<MolecularComponent> mcList = molecularType.getComponentList();
int fromIndex = mcList.indexOf(from);
if (fromIndex == 0) {
// already the first element
return;
}
int toIndex = fromIndex - 1;
MolecularComponent to = mcList.remove(toIndex);
mcList.add(fromIndex, to);
molecularTypeTreeModel.populateTree();
molecularType.firePropertyChange("entityChange", null, "bbb");
}
});
popupFromShapeMenu.add(moveLeftMenuItem);
popupFromShapeMenu.add(new JSeparator());
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem addMenuItem = new JMenuItem("Add " + ComponentStateDefinition.typeName);
JMenuItem deleteMenuItem = new JMenuItem("Delete ");
popupFromShapeMenu.add(deleteMenuItem);
popupFromShapeMenu.add(new JSeparator());
popupFromShapeMenu.add(addMenuItem);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent mc = (MolecularComponent) selectedObject;
// detailed verifications will be done there, to see if they are being used in reactions, species, observables
if (!mc.getComponentStateDefinitions().isEmpty()) {
String[] options = { "OK" };
String errMsg = mc.getDisplayType() + " '<b>" + mc.getDisplayName() + "</b>' cannot be deleted because it contains explicit States.";
errMsg += "<br>Please delete each individual State first.";
errMsg += "<br><br>Detailed usage information will be provided at that time to help you decide.";
errMsg = "<html>" + errMsg + "</html>";
JOptionPane.showOptionDialog(shapePanel, errMsg, "Delete " + mc.getDisplayType(), JOptionPane.NO_OPTION, JOptionPane.WARNING_MESSAGE, null, options, options[0]);
return;
}
// we find and display component usage information to help the user decide
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
bioModel.getModel().getRbmModelContainer().findComponentUsage(molecularType, mc, usedHere);
if (!usedHere.isEmpty()) {
String errMsg = mc.dependenciesToHtml(usedHere);
errMsg += "<br><br>Delete anyway?";
errMsg = "<html>" + errMsg + "</html>";
int dialogButton = JOptionPane.YES_NO_OPTION;
int returnCode = JOptionPane.showConfirmDialog(shapePanel, errMsg, "Delete " + mc.getDisplayType(), dialogButton);
if (returnCode == JOptionPane.YES_OPTION) {
// keep this code in sync with MolecularTypeTableModel.setValueAt
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc) == true) {
molecularType.removeMolecularComponent(mc);
}
}
} else {
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc) == true) {
molecularType.removeMolecularComponent(mc);
}
}
}
});
addMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularComponent mc = (MolecularComponent) selectedObject;
ComponentStateDefinition componentStateDefinition = mc.createComponentStateDefinition();
mc.addComponentStateDefinition(componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustObservablesPatterns(molecularType, mc, componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustRulesPatterns(molecularType, mc, componentStateDefinition);
bioModel.getModel().getRbmModelContainer().adjustSpeciesPatterns(molecularType, mc, componentStateDefinition);
// editInPlace((LargeShape)deepestShape);
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
} else if (selectedObject instanceof ComponentStateDefinition) {
// rename, delete
JMenuItem renamMenuItem = new JMenuItem("Rename");
popupFromShapeMenu.add(renamMenuItem);
JMenuItem deleteMenuItem = new JMenuItem("Delete");
popupFromShapeMenu.add(deleteMenuItem);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
ComponentStateDefinition csd = (ComponentStateDefinition) selectedObject;
// must exist, we're deleting one of its states
MolecularComponent mc = locationContext.mcs.getMolecularComponent();
Map<String, Pair<Displayable, SpeciesPattern>> usedHere = new LinkedHashMap<String, Pair<Displayable, SpeciesPattern>>();
bioModel.getModel().getRbmModelContainer().findStateUsage(molecularType, mc, csd, usedHere);
if (!usedHere.isEmpty()) {
String errMsg = csd.dependenciesToHtml(usedHere);
errMsg += "<br><br>Delete anyway?";
errMsg = "<html>" + errMsg + "</html>";
int dialogButton = JOptionPane.YES_NO_OPTION;
int returnCode = JOptionPane.showConfirmDialog(shapePanel, errMsg, "Delete " + ComponentStateDefinition.typeName, dialogButton);
if (returnCode == JOptionPane.YES_OPTION) {
// keep this code in sync with MolecularTypeTableModel.setValueAt
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc, csd) == true) {
mc.deleteComponentStateDefinition(csd);
}
}
} else {
if (bioModel.getModel().getRbmModelContainer().delete(molecularType, mc, csd) == true) {
mc.deleteComponentStateDefinition(csd);
}
}
}
});
renamMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
editInPlace((LargeShape) deepestShape);
}
});
}
popupFromShapeMenu.show(e.getComponent(), mousePoint.x, mousePoint.y);
}
use of javax.swing.JSeparator in project vcell by virtualcell.
the class Wizard method initComponents.
/**
* This method initializes the components for the wizard dialog: it creates a JDialog
* as a CardLayout panel , as well as three buttons at the bottom.
*/
private void initComponents() {
wizardModel.addPropertyChangeListener(this);
wizardController = new WizardController(this);
wizardDialog.getContentPane().setLayout(new BorderLayout());
wizardDialog.addWindowListener(this);
// Create the outer wizard panel, which is responsible for three buttons:
// Next, Back, and Cancel. It is also responsible a JPanel above them that
// uses a CardLayout layout manager to display multiple panels in the
// same spot.
JPanel buttonPanel = new JPanel();
JSeparator separator = new JSeparator();
Box buttonBox = new Box(BoxLayout.X_AXIS);
cardPanel = new JPanel();
cardPanel.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
cardLayout = new CardLayout();
cardPanel.setLayout(cardLayout);
backButton = new JButton();
nextButton = new JButton();
cancelButton = new JButton();
backButton.setActionCommand(BACK_BUTTON_ACTION_COMMAND);
nextButton.setActionCommand(NEXT_BUTTON_ACTION_COMMAND);
cancelButton.setActionCommand(CANCEL_BUTTON_ACTION_COMMAND);
backButton.addActionListener(wizardController);
nextButton.addActionListener(wizardController);
cancelButton.addActionListener(wizardController);
// Create the buttons with a separator above them, then put them
// on the east side of the panel with a small amount of space between
// the back and the next button, and a larger amount of space between
// the next button and the cancel button.
buttonPanel.setLayout(new BorderLayout());
buttonPanel.add(separator, BorderLayout.NORTH);
buttonBox.setBorder(new EmptyBorder(new Insets(5, 10, 5, 10)));
buttonBox.add(backButton);
buttonBox.add(Box.createHorizontalStrut(10));
buttonBox.add(nextButton);
buttonBox.add(Box.createHorizontalStrut(30));
buttonBox.add(cancelButton);
buttonPanel.add(buttonBox, java.awt.BorderLayout.EAST);
wizardDialog.getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
wizardDialog.getContentPane().add(cardPanel, java.awt.BorderLayout.CENTER);
}
use of javax.swing.JSeparator in project vcell by virtualcell.
the class SpeciesPropertiesPanel method showPopupMenu.
private void showPopupMenu(MouseEvent e, PointLocationInShapeContext locationContext) {
if (popupFromShapeMenu == null) {
popupFromShapeMenu = new JPopupMenu();
}
if (popupFromShapeMenu.isShowing()) {
return;
}
final Object deepestShape = locationContext.getDeepestShape();
final RbmElementAbstract selectedObject;
if (deepestShape == null) {
selectedObject = null;
// when cursor is outside any species pattern we offer to add a new one
System.out.println("outside");
// popupFromShapeMenu.add(getAddSpeciesPatternFromShapeMenuItem());
} else if (deepestShape instanceof ComponentStateLargeShape) {
System.out.println("inside state");
if (((ComponentStateLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((ComponentStateLargeShape) deepestShape).getComponentStatePattern();
} else {
return;
}
} else if (deepestShape instanceof MolecularComponentLargeShape) {
System.out.println("inside component");
if (((MolecularComponentLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularComponentLargeShape) deepestShape).getMolecularComponentPattern();
} else {
return;
}
} else if (deepestShape instanceof MolecularTypeLargeShape) {
System.out.println("inside molecule");
if (((MolecularTypeLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((MolecularTypeLargeShape) deepestShape).getMolecularTypePattern();
} else {
return;
}
} else if (deepestShape instanceof SpeciesPatternLargeShape) {
System.out.println("inside species pattern");
if (((SpeciesPatternLargeShape) deepestShape).isHighlighted()) {
selectedObject = ((SpeciesPatternLargeShape) deepestShape).getSpeciesPattern();
} else {
if (!fieldSpeciesContext.hasSpeciesPattern()) {
selectedObject = new SpeciesPattern();
} else {
return;
}
}
} else {
selectedObject = null;
System.out.println("inside something else?");
return;
}
System.out.println(selectedObject);
popupFromShapeMenu.removeAll();
Point mousePoint = e.getPoint();
if (selectedObject instanceof SpeciesPattern) {
final SpeciesPattern sp = (SpeciesPattern) selectedObject;
JMenu addMenuItem = new JMenu(VCellErrorMessages.SpecifyMolecularTypes);
popupFromShapeMenu.add(addMenuItem);
addMenuItem.removeAll();
for (final MolecularType mt : bioModel.getModel().getRbmModelContainer().getMolecularTypeList()) {
JMenuItem menuItem = new JMenuItem(mt.getName());
Graphics gc = shapePanel.getGraphics();
Icon icon = new MolecularTypeSmallShape(1, 4, mt, null, gc, mt, null, issueManager);
menuItem.setIcon(icon);
addMenuItem.add(menuItem);
menuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern molecularTypePattern = new MolecularTypePattern(mt);
for (MolecularComponentPattern mcp : molecularTypePattern.getComponentPatternList()) {
mcp.setBondType(BondType.None);
}
if (!fieldSpeciesContext.hasSpeciesPattern()) {
fieldSpeciesContext.setSpeciesPattern(sp);
}
fieldSpeciesContext.getSpeciesPattern().addMolecularTypePattern(molecularTypePattern);
}
});
}
// JMenu compartmentMenuItem = new JMenu("Specify structure");
// popupFromShapeMenu.add(compartmentMenuItem);
// compartmentMenuItem.removeAll();
// for (final Structure struct : bioModel.getModel().getStructures()) {
// JMenuItem menuItem = new JMenuItem(struct.getName());
// compartmentMenuItem.add(menuItem);
// menuItem.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// String nameStruct = e.getActionCommand();
// Structure struct = bioModel.getModel().getStructure(nameStruct);
// fieldSpeciesContext.setStructure(struct);
// }
// });
// }
} else if (selectedObject instanceof MolecularTypePattern) {
MolecularTypePattern mtp = (MolecularTypePattern) selectedObject;
String moveRightMenuText = "Move <b>" + "right" + "</b>";
moveRightMenuText = "<html>" + moveRightMenuText + "</html>";
JMenuItem moveRightMenuItem = new JMenuItem(moveRightMenuText);
Icon icon = VCellIcons.moveRightIcon;
moveRightMenuItem.setIcon(icon);
moveRightMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern from = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.shiftRight(from);
speciesPropertiesTreeModel.populateTree();
}
});
popupFromShapeMenu.add(moveRightMenuItem);
String moveLeftMenuText = "Move <b>" + "left" + "</b>";
moveLeftMenuText = "<html>" + moveLeftMenuText + "</html>";
JMenuItem moveLeftMenuItem = new JMenuItem(moveLeftMenuText);
icon = VCellIcons.moveLeftIcon;
moveLeftMenuItem.setIcon(icon);
moveLeftMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern from = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.shiftLeft(from);
speciesPropertiesTreeModel.populateTree();
}
});
popupFromShapeMenu.add(moveLeftMenuItem);
popupFromShapeMenu.add(new JSeparator());
String deleteMenuText = "Delete <b>" + mtp.getMolecularType().getName() + "</b>";
deleteMenuText = "<html>" + deleteMenuText + "</html>";
JMenuItem deleteMenuItem = new JMenuItem(deleteMenuText);
deleteMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
MolecularTypePattern mtp = (MolecularTypePattern) selectedObject;
SpeciesPattern sp = locationContext.sps.getSpeciesPattern();
sp.removeMolecularTypePattern(mtp);
if (sp.getMolecularTypePatterns().isEmpty()) {
fieldSpeciesContext.setSpeciesPattern(null);
}
}
});
popupFromShapeMenu.add(deleteMenuItem);
} else if (selectedObject instanceof MolecularComponentPattern) {
manageComponentPatternFromShape(selectedObject, locationContext, ShowWhat.ShowBond);
} else if (selectedObject instanceof ComponentStatePattern) {
MolecularComponentPattern mcp = ((ComponentStateLargeShape) deepestShape).getMolecularComponentPattern();
manageComponentPatternFromShape(mcp, locationContext, ShowWhat.ShowState);
} else {
System.out.println("Where am I ???");
}
popupFromShapeMenu.show(e.getComponent(), mousePoint.x, mousePoint.y);
}
Aggregations