Search in sources :

Example 1 with IdentifiableNode

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);
            }
        }
    }
}
Also used : IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) Identifiable(org.vcell.util.document.Identifiable)

Example 2 with IdentifiableNode

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);
        }
    });
}
Also used : GridBagConstraints(java.awt.GridBagConstraints) JTree(javax.swing.JTree) Insets(java.awt.Insets) GridBagLayout(java.awt.GridBagLayout) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) TreeSelectionListener(javax.swing.event.TreeSelectionListener) Dimension(java.awt.Dimension) TreeSelectionEvent(javax.swing.event.TreeSelectionEvent)

Example 3 with 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);
    }
}
Also used : UtilCancelException(org.vcell.util.UtilCancelException) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) Annotation(cbit.vcell.desktop.Annotation) UtilCancelException(org.vcell.util.UtilCancelException) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)

Example 4 with IdentifiableNode

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);
    }
}
Also used : DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ActionListener(java.awt.event.ActionListener) ActionEvent(java.awt.event.ActionEvent) IdentifiableNode(cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) JMenuItem(javax.swing.JMenuItem) JPopupMenu(javax.swing.JPopupMenu)

Aggregations

IdentifiableNode (cbit.vcell.xml.gui.MiriamTreeModel.IdentifiableNode)4 URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)2 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)1 Annotation (cbit.vcell.desktop.Annotation)1 LinkNode (cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)1 Dimension (java.awt.Dimension)1 GridBagConstraints (java.awt.GridBagConstraints)1 GridBagLayout (java.awt.GridBagLayout)1 Insets (java.awt.Insets)1 ActionEvent (java.awt.event.ActionEvent)1 ActionListener (java.awt.event.ActionListener)1 JMenuItem (javax.swing.JMenuItem)1 JPopupMenu (javax.swing.JPopupMenu)1 JTree (javax.swing.JTree)1 TreeSelectionEvent (javax.swing.event.TreeSelectionEvent)1 TreeSelectionListener (javax.swing.event.TreeSelectionListener)1 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)1 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)1 UtilCancelException (org.vcell.util.UtilCancelException)1 Identifiable (org.vcell.util.document.Identifiable)1