use of cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method removeSelectedRefGroups.
public void removeSelectedRefGroups() {
Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent();
if (treeNode instanceof IdentifiableNode) {
Identifiable identifiable = ((IdentifiableNode) treeNode).getIdentifiable();
Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(identifiable);
for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()) {
MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup);
try {
vcMetaData.getMiriamManager().remove(identifiable, qualifier, refGroup);
} catch (URNParseFailureException e) {
e.printStackTrace(System.out);
}
}
}
}
use of cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method initialize.
/**
* This method initializes this
*/
private void initialize() {
GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
gridBagConstraints5.gridx = 0;
gridBagConstraints5.fill = GridBagConstraints.NONE;
gridBagConstraints5.insets = new Insets(4, 4, 4, 4);
gridBagConstraints5.gridy = 2;
GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
gridBagConstraints1.fill = GridBagConstraints.BOTH;
gridBagConstraints1.weighty = 1.0;
gridBagConstraints1.gridx = 0;
gridBagConstraints1.gridy = 0;
gridBagConstraints1.weightx = 1.0;
this.setLayout(new GridBagLayout());
this.setSize(new Dimension(627, 333));
this.add(getJScrollPane(), gridBagConstraints1);
this.add(getJPanel(), gridBagConstraints5);
getJButtonAdd().setEnabled(false);
getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() {
public void valueChanged(TreeSelectionEvent e) {
getJButtonAdd().setEnabled(((JTree) e.getSource()).getSelectionPath() != null && ((JTree) e.getSource()).getSelectionPath().getLastPathComponent() instanceof IdentifiableNode);
// getJButtonAdd().setEnabled(e.getPath().getLastPathComponent() instanceof IdentifiableNode);
}
});
}
use of cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method showEditFreehandText.
private void showEditFreehandText(DefaultMutableTreeNode node) {
final IdentifiableNode parentIdentifiableNode = (IdentifiableNode) ((BioModelNode) node).getParent();
final Annotation oldAnnotation = (Annotation) ((BioModelNode) node).getUserObject();
try {
String newAnnotation = DialogUtils.showAnnotationDialog(MIRIAMAnnotationEditor.this, oldAnnotation.toString());
if (BeanUtils.triggersPropertyChangeEvent(oldAnnotation, newAnnotation)) {
vcMetaData.setFreeTextAnnotation(parentIdentifiableNode.getIdentifiable(), newAnnotation);
}
} catch (UtilCancelException uce) {
// ignore
} catch (Exception exc) {
exc.printStackTrace();
DialogUtils.showErrorDialog(MIRIAMAnnotationEditor.this, "Error editing Annotation:\n" + exc.getMessage(), exc);
}
}
use of cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode in project vcell by virtualcell.
the class MIRIAMAnnotationEditor method showPopup.
private void showPopup(MouseEvent mouseEvent, final TreePath closestMousePath) {
final DefaultMutableTreeNode lastPathComp = ((DefaultMutableTreeNode) closestMousePath.getLastPathComponent());
if (mouseEvent.isPopupTrigger()) {
JPopupMenu jpop = new JPopupMenu();
if (lastPathComp.getParent() == null) {
JMenuItem expandJMenuItem = new JMenuItem("Expand all");
expandJMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
expandJTreeNode(jTreeMIRIAM, lastPathComp, 0, 3);
}
});
jpop.add(expandJMenuItem);
}
if (lastPathComp instanceof IdentifiableNode) {
JMenuItem addAnnotationElementMenuItem = new JMenuItem("Add Annotation element");
addAnnotationElementMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
fireActionPerformed(new ActionEvent(MIRIAMAnnotationEditor.this, 0, MIRIAMAnnotationEditor.ACTION_ADD));
}
});
jpop.add(addAnnotationElementMenuItem);
// JMenuItem addIDentifierJMenuItem = new JMenuItem("Add Identifier...");
// addIDentifierJMenuItem.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// addIdentifierDialog();
// }
// });
// jpop.add(addIDentifierJMenuItem);
//
// JMenuItem addIDateJMenuItem = new JMenuItem("Add Date...");
// addIDateJMenuItem.addActionListener(new ActionListener() {
// public void actionPerformed(ActionEvent e) {
// addTimeUTCDialog();
// }
// });
// jpop.add(addIDateJMenuItem);
} else if (isNodeFreeHandTextEditable(lastPathComp)) {
JMenuItem editFreehandJMenuItem = new JMenuItem("Edit freehand text");
editFreehandJMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showEditFreehandText(lastPathComp);
}
});
jpop.add(editFreehandJMenuItem);
} else if (lastPathComp instanceof LinkNode) {
JMenuItem showLinkJMenuItem = new JMenuItem("Show link in web browser");
showLinkJMenuItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
showBrowseToLink((LinkNode) lastPathComp);
}
});
jpop.add(showLinkJMenuItem);
}
jpop.show(jTreeMIRIAM, mouseEvent.getPoint().x, mouseEvent.getPoint().y);
}
}
Aggregations