diff --git a/vcell-client/pom.xml b/vcell-client/pom.xml index a822a73b6b..090f51abb0 100644 --- a/vcell-client/pom.xml +++ b/vcell-client/pom.xml @@ -2,8 +2,20 @@ 4.0.0 - - + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + + + + org.vcell vcell-pom 0.0.1-SNAPSHOT diff --git a/vcell-admin/src/main/java/cbit/vcell/server/manage/ServerConfiguration.java b/vcell-client/src/main/java/cbit/image/gui/manage/ServerConfiguration.java similarity index 96% rename from vcell-admin/src/main/java/cbit/vcell/server/manage/ServerConfiguration.java rename to vcell-client/src/main/java/cbit/image/gui/manage/ServerConfiguration.java index f4333c9d0b..79b245569c 100644 --- a/vcell-admin/src/main/java/cbit/vcell/server/manage/ServerConfiguration.java +++ b/vcell-client/src/main/java/cbit/image/gui/manage/ServerConfiguration.java @@ -1,129 +1,129 @@ -/* - * Copyright (C) 1999-2011 University of Connecticut Health Center - * - * Licensed under the MIT License (the "License"). - * You may not use this file except in compliance with the License. - * You may obtain a copy of the License at: - * - * http://www.opensource.org/licenses/mit-license.php - */ - -package cbit.vcell.server.manage; - -import java.io.File; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.io.LineNumberReader; -import java.util.Vector;/** - * Insert the type's description here. - * Creation date: (10/24/2001 2:25:13 PM) - * @author: Ion Moraru - */ -public class ServerConfiguration { - private VCellHost[] allHosts = new VCellHost[0]; -/** - * Insert the method's description here. - * Creation date: (10/24/2001 3:29:24 PM) - * @param configurationFile java.io.File - * @exception java.io.IOException The exception description. - * @exception java.io.FileNotFoundException The exception description. - */ -public ServerConfiguration(File configurationFile) throws IOException, FileNotFoundException { - LineNumberReader reader = new LineNumberReader(new FileReader(configurationFile)); - Vector hosts = new Vector(); - VCellHost host = null; - String line = reader.readLine(); - while (line != null) { - if (!line.startsWith("#")) { - if(line.startsWith("hosttype=")) { - if (host != null) hosts.add(host); - String type = line.substring(line.indexOf("=") + 1); - if (type.equals("vcell")) { - host = new VCellHost(VCellHost.VCELL_SERVER); - } else if (type.equals("data")) { - host = new VCellHost(VCellHost.DATA_SERVER); - } else if (type.equals("database")) { - host = new VCellHost(VCellHost.DATABASE_SERVER); - } else if (type.equals("compute")) { - host = new VCellHost(VCellHost.COMPUTE_SERVER); - } else { - host = null; - } - } else if (line.startsWith("name=")) { - if (host != null) host.setName(line.substring(line.indexOf("=") + 1)); - } else if (line.startsWith("port=")) { - if (host != null) host.setPort(Integer.parseInt(line.substring(line.indexOf("=") + 1))); - } else if (line.startsWith("startcmd=")) { - if (host != null) host.setStartCommand(line.substring(line.indexOf("=") + 1)); - } else if (line.startsWith("stopcmd=")) { - if (host != null) host.setStopCommand(line.substring(line.indexOf("=") + 1)); - } else if (line.startsWith("logfile=")) { - if (host != null) host.setLogFile(new File(line.substring(line.indexOf("=") + 1))); - } else if (line.startsWith("restart=")) { - if (host != null) host.setRestartIfDead(Boolean.valueOf(line.substring(line.indexOf("=") + 1)).booleanValue()); - } - } - line = reader.readLine(); - } - if (host != null) hosts.add(host); - allHosts = ((VCellHost[])org.vcell.util.BeanUtils.getArray(hosts, VCellHost.class)); -} -/** - * Insert the method's description here. - * Creation date: (10/24/2001 7:04:58 PM) - * @return cbit.vcell.server.manage.VCellHost[] - */ -public VCellHost[] getComputeServerHosts() { - return getHosts(VCellHost.COMPUTE_SERVER); -} -/** - * Insert the method's description here. - * Creation date: (10/24/2001 7:04:58 PM) - * @return cbit.vcell.server.manage.VCellHost[] - */ -public VCellHost[] getDatabaseServerHosts() { - return getHosts(VCellHost.DATABASE_SERVER); -} -/** - * Insert the method's description here. - * Creation date: (10/24/2001 7:04:58 PM) - * @return cbit.vcell.server.manage.VCellHost[] - */ -public VCellHost[] getDataServerHosts() { - return getHosts(VCellHost.DATA_SERVER); -} -/** - * Insert the method's description here. - * Creation date: (10/24/2001 7:13:10 PM) - * @return cbit.vcell.server.manage.VCellHost[] - * @param hostType int - */ -public VCellHost[] getHosts(int hostType) { - synchronized (allHosts) { - int n = 0; - for (int i=0;i

" - private static String emptyHtmlText2 = "
"; // really empty - - - private class EventHandler extends MouseAdapter implements ActionListener, FocusListener, PropertyChangeListener, KeyListener { - public void focusGained(FocusEvent e) { - } - public void focusLost(FocusEvent e) { - if (e.getSource() == annotationTextArea) { - changeTextAnnotation(); - } - } - @Override - public void mouseExited(MouseEvent e) { - super.mouseExited(e); - if(e.getSource() == annotationTextArea) { - changeTextAnnotation(); - } - } - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (evt.getSource() instanceof SpeciesContext - || evt.getSource() instanceof MolecularType - || evt.getSource() instanceof ReactionRule - || evt.getSource() instanceof ReactionStep - || evt.getSource() instanceof RbmObservable - || evt.getSource() instanceof BioModel - || evt.getSource() instanceof Structure - || evt.getSource() instanceof Model.ModelParameter - || evt.getSource() instanceof BioPaxObject - - || evt.getSource() instanceof SimulationContext -// || evt.getSource() instanceof Simulation // TODO: check why is not saving -// || evt.getSource() instanceof SpeciesContextSpec // TODO: can't use species name for spec too, need some hack -// || evt.getSource() instanceof ReactionSpec - ) { - initializeComboBoxURI(); - updateInterface(); - } - } - @Override - public void actionPerformed(ActionEvent evt) { - if (evt.getSource() == getJButtonAddRef()) { - addIdentifier(); - } else if(evt.getSource() == getJButtonDeleteRef()) { - removeIdentifier(); - } else if(evt.getSource() == getJButtonRemoveText()) { - removeText(); - } - } - @Override - public void keyPressed(KeyEvent e) { - } - @Override - public void keyReleased(KeyEvent e) { - // too expensive to parse it at each keystroke -// System.out.println("key released"); -// if (e.getSource() == annotationTextArea) { -// String text = annotationTextArea.getText(); -// text = text.replaceAll("(\n\r|\n|\r)", ""); -// text = text.replaceAll(" ", ""); -// System.out.println(text); -// } - } - @Override - public void keyTyped(KeyEvent e) { - } - } - - public class ComboboxToolTipRenderer extends DefaultListCellRenderer { - List tooltips; - @SuppressWarnings("rawtypes") - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Component comp; - if(value == null) { - comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } else if(value instanceof DataType) { - DataType dt = (DataType)value; - comp = super.getListCellRendererComponent(list,dt.getDataTypeName(),index,isSelected,cellHasFocus); - } else if(value instanceof MIRIAMQualifier) { - MIRIAMQualifier mc = (MIRIAMQualifier)value; - comp = super.getListCellRendererComponent(list,mc.getDescription(),index,isSelected,cellHasFocus); - } else { - comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - } - if (-1 < index && null != value && null != tooltips) { - list.setToolTipText(tooltips.get(index)); - } - return comp; - } - public void setTooltips(List tooltips) { - this.tooltips = tooltips; - } - } - - -public AnnotationsPanel() { - super(); - initialize(); -} - -private void handleException(java.lang.Throwable exception) { - System.out.println("--------- UNCAUGHT EXCEPTION ---------"); - exception.printStackTrace(System.out); -} - -private JPanel getJPanelNewIdentifier() { - jPanelNewIdentifier = new JPanel(); - jPanelNewIdentifier.setLayout(new GridBagLayout()); -// jPanelNewIdentifier.setPreferredSize(new Dimension(725, 37)); -// jPanelNewIdentifier.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 2)); - - VCMetaDataDataType mdt = (VCMetaDataDataType)getJComboBoxURI().getSelectedItem(); - int gridx = 0; - int gridy = 0; - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(new JLabel("Provider: "), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 5, 3, 4); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(new JLabel("" + mdt.getDataTypeName() + ""), gbc); - - // ------------------------------------- Qualifier combobox ----------------------------- - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right - gbc.gridx = gridx; - gbc.gridy = gridy; - jPanelNewIdentifier.add(new JLabel("Qualifier"), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 5, 3, 4); - gbc.gridx = gridx; - gbc.gridy = gridy; - jPanelNewIdentifier.add(getJComboBoxQualifier(), gbc); - - // ------------------------------------------------------------------------------- - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(new JLabel("Identifier ID"), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 5, 3, 4); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(getJTextFieldFormalID(), gbc); - getJTextFieldFormalID().setText("NewID"); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(new JLabel("Example: " + mdt.getExample() +""), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.anchor = GridBagConstraints.EAST; - jPanelNewIdentifier.add(new JLabel(), gbc); - - // --------------------------------------------------------------------- - gridx = 0; - gridy++; - - JLabel linkLabel = new JLabel(); - String s = "" + "Navigate to" + " " + mdt.getDataTypeURL() + "  "; - s += "and find the identifier ID, then paste it in the box above." + ""; - linkLabel.setToolTipText("Double-click to open link"); - linkLabel.setText(s); - linkLabel.addMouseListener(new MouseAdapter() { - public void mousePressed(MouseEvent e) { - if(e.getClickCount() == 2) { - showBrowseToLink(mdt); - } - } - }); - - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.gridwidth = 8; - gbc.anchor = GridBagConstraints.WEST; - jPanelNewIdentifier.add(linkLabel, gbc); - - // --------------------------------------------------------------------- - List rows = new ArrayList<> (); - String value = mdt.getDescription(); - StringTokenizer tokenizer = new StringTokenizer(value, " "); - String row = ""; - while(tokenizer.hasMoreTokens()) { - String word = tokenizer.nextToken(); - if((row.length() + word.length()) > MAX_DESCRIPTION_LENGTH) { - rows.add(row); - row = word + " "; - } else { - row += word + " "; - } - } - if(!row.isEmpty()) { - rows.add(row); - } - for(String currentRow : rows) { - gridx = 0; - gridy++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); - gbc.gridx = gridx; - gbc.gridy = gridy; - gbc.gridwidth = 8; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - jPanelNewIdentifier.add(new JLabel(currentRow), gbc); - - } - return jPanelNewIdentifier; -} -private JPanel getJPanelLeftTitle() { - JPanel jPanelLeftTitle = new JPanel(); - jPanelLeftTitle.setLayout(new GridBagLayout()); - jPanelLeftTitle.setPreferredSize(new Dimension(260, 37)); - jPanelLeftTitle.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); - int gridx = 0; - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - jPanelLeftTitle.add(new JLabel("User defined cross-references."), gbc); - return jPanelLeftTitle; -} -private JPanel getJPanelRightTitle() { - JPanel jPanelRightTitle = new JPanel(); - jPanelRightTitle.setLayout(new GridBagLayout()); - jPanelRightTitle.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); - - int gridx = 0; - GridBagConstraints gbc = new GridBagConstraints(); - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.insets = new Insets(6, 8, 0, 0); // top left bottom right - gbc.anchor = GridBagConstraints.NORTHWEST; - jPanelRightTitle.add(new JLabel("Text Annotations"), gbc); - - gridx++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.fill = java.awt.GridBagConstraints.BOTH; - jPanelRightTitle.add(new JLabel(), gbc); - - gridx++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.insets = new Insets(3, 0, 3, 3); - gbc.anchor = GridBagConstraints.NORTHEAST; - jPanelRightTitle.add(getJButtonRemoveText(), gbc); - - getJButtonRemoveText().addActionListener(eventHandler); - return jPanelRightTitle; -} -private JPanel getJPanelIdentifierManager() { - if (jPanelIdentifierManager == null) { - jPanelIdentifierManager = new JPanel(); - jPanelIdentifierManager.setLayout(new GridBagLayout()); - jPanelIdentifierManager.setPreferredSize(new Dimension(260, 37)); - jPanelIdentifierManager.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); - - int gridx = 0; - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right - gbc.gridx = gridx; - gbc.gridy = 0; - jPanelIdentifierManager.add(new JLabel("Provider"), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 5, 3, 4); - gbc.gridx = gridx; - gbc.gridy = 0; - jPanelIdentifierManager.add(getJComboBoxURI(), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 5, 3, 5); - gbc.gridx = gridx; - gbc.gridy = 0; - jPanelIdentifierManager.add(getJButtonAddRef(), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 0, 3, 0); - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - jPanelIdentifierManager.add(new JLabel(""), gbc); - - getJButtonAddRef().addActionListener(eventHandler); - } - return jPanelIdentifierManager; -} -private JPanel getJPanelLowerLeft() { - if (jPanelLowerLeft == null) { - jPanelLowerLeft = new JPanel(); - jPanelLowerLeft.setLayout(new GridBagLayout()); - jPanelLowerLeft.setPreferredSize(new Dimension(300, 37)); - jPanelLowerLeft.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); - - int gridx = 0; - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 3, 3, 3); - gbc.gridx = gridx; - gbc.gridy = 0; - jPanelLowerLeft.add(getJButtonDeleteRef(), gbc); - - gridx++; - gbc = new GridBagConstraints(); - gbc.insets = new Insets(3, 0, 3, 0); - gbc.gridx = gridx; - gbc.gridy = 0; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - jPanelLowerLeft.add(new JLabel(""), gbc); - - getJButtonDeleteRef().setEnabled(false); - getJButtonDeleteRef().addActionListener(eventHandler); - } - return jPanelLowerLeft; -} - -private JComboBox getJComboBoxQualifier() { - if (jComboBoxQualifier == null) { - jComboBoxQualifier = new JComboBox(); -// defaultComboBoxModelQualifier = new DefaultComboBoxModel(); // already allocated - jComboBoxQualifier.setModel(defaultComboBoxModelQualifier); - Dimension d = jComboBoxQualifier.getPreferredSize(); - jComboBoxQualifier.setMinimumSize(new Dimension(COMBO_QUALIFIER_WIDTH, d.height)); - jComboBoxQualifier.setPreferredSize(new Dimension(COMBO_QUALIFIER_WIDTH, d.height)); - ComboboxToolTipRenderer renderer = new ComboboxToolTipRenderer(); - jComboBoxQualifier.setRenderer(renderer); - } - return jComboBoxQualifier; -} -private JTextField getJTextFieldFormalID() { - if (jTextFieldFormalID == null) { - jTextFieldFormalID = new JTextField(); - jTextFieldFormalID.setText("NewID"); - Dimension d = jTextFieldFormalID.getPreferredSize(); - jTextFieldFormalID.setMinimumSize(new Dimension(100, d.height)); - jTextFieldFormalID.setPreferredSize(new Dimension(100, d.height)); - } - return jTextFieldFormalID; -} - -@SuppressWarnings({ "rawtypes", "unchecked" }) -private JComboBox getJComboBoxURI() { - if (jComboBoxURI == null) { - jComboBoxURI = new JComboBox(); - defaultComboBoxModelURI = new DefaultComboBoxModel(); - jComboBoxURI.setModel(defaultComboBoxModelURI); - Dimension d = jComboBoxURI.getPreferredSize(); - jComboBoxURI.setMinimumSize(new Dimension(MAX_URI_LENGTH, d.height)); - jComboBoxURI.setPreferredSize(new Dimension(MAX_URI_LENGTH, d.height)); - ComboboxToolTipRenderer renderer = new ComboboxToolTipRenderer(); - jComboBoxURI.setRenderer(renderer); -// jComboBoxURI.setRenderer(new DefaultListCellRenderer() { -// public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { -// if(value == null) { -// return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); -// } else { -// DataType dt = (DataType)value; -// Component comp = super.getListCellRendererComponent(list,dt.getDataTypeName(),index,isSelected,cellHasFocus); -// return comp; -// } -// } -// }); - } - return jComboBoxURI; -} - -private JPanel getBottomPanel() { - if (jBottomPanel == null) { - - jBottomPanel = new JPanel(); - jBottomPanel.setLayout(new BorderLayout()); - jBottomPanel.add(getSplitPane(), BorderLayout.CENTER); - } - return jBottomPanel; - -} -private JSplitPane getSplitPane() { - if (splitPane == null) { - - JPanel leftPanel = new JPanel(); - leftPanel.setLayout(new GridBagLayout()); - leftPanel.setBackground(Color.white); - - int gridy = 0; - GridBagConstraints gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.insets = new Insets(3, 3, 1, 3); - gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.NORTHWEST; - leftPanel.add(getJPanelLeftTitle(), gbc); - - gridy++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.insets = new Insets(2, 3, 1, 3); - gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.NORTHWEST; - leftPanel.add(getJPanelIdentifierManager(), gbc); - - gridy++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.insets = new Insets(2, 3, 1, 3); - gbc.fill = java.awt.GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.SOUTHWEST; - leftPanel.add(getJScrollPane(), gbc); - - gridy++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 0; - gbc.insets = new Insets(2, 3, 3, 3); - gbc.fill = java.awt.GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.SOUTHWEST; - leftPanel.add(getJPanelLowerLeft(), gbc); - // ----------------------------------------------------------------------- - - JPanel rightPanel = new JPanel(); - rightPanel.setLayout(new GridBagLayout()); - rightPanel.setBackground(Color.white); - - gridy = 0; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.insets = new Insets(3, 3, 2, 2); - gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; - gbc.anchor = GridBagConstraints.NORTHWEST; - rightPanel.add(getJPanelRightTitle(), gbc); - - annotationTextArea = new JTextPane(); - annotationTextArea.setContentType("text/html"); - annotationTextArea.setEditable(false); - annotationTextArea.addFocusListener(eventHandler); - annotationTextArea.addMouseListener(eventHandler); - JScrollPane annotationPanel = new JScrollPane(annotationTextArea); - - gridy++; - gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.insets = new Insets(1, 3, 1, 2); - gbc.fill = java.awt.GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.NORTHWEST; - rightPanel.add(annotationPanel, gbc); - // ---------------------------------------------------------------------------------- - - splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); - splitPane.setOneTouchExpandable(true); - splitPane.setLeftComponent(leftPanel); - splitPane.setRightComponent(rightPanel); - splitPane.setResizeWeight(0.1); - splitPane.setDividerLocation(0.3); - - annotationTextArea.addKeyListener(eventHandler); - } - return splitPane; -} - -private JScrollPane getJScrollPane() { - if (jScrollPane == null) { - jScrollPane = new JScrollPane(); - jScrollPane.setViewportView(getJTreeMIRIAM()); - } - return jScrollPane; -} -private JTree getJTreeMIRIAM() { - if (jTreeMIRIAM == null) { - try { - DefaultTreeSelectionModel ivjLocalSelectionModel; - ivjLocalSelectionModel = new DefaultTreeSelectionModel(); - ivjLocalSelectionModel.setSelectionMode(1); - jTreeMIRIAM = new JTree(); - jTreeMIRIAM.setName("JTree1"); - jTreeMIRIAM.setToolTipText(""); - jTreeMIRIAM.setBounds(0, 0, 357, 405); - jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72)); - jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel); - jTreeMIRIAM.setRowHeight(0); - jTreeMIRIAM.setRootVisible(false); - - // Add cellRenderer - DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) { - @Override - public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { - // default for LinkNode is in BioModelCellRenderer.java - JLabel component = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); - // TODO: here - component.setIcon(null); - return component; - } - }; - jTreeMIRIAM.setCellRenderer(dtcr); - - MouseListener mouseListener = new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - super.mouseClicked(e); -// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); -// showPopup(e, closestMousePath); - } - - @Override - public void mouseReleased(MouseEvent e) { - super.mouseReleased(e); -// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); -// showPopup(e,closestMousePath); - } - - public void mousePressed(MouseEvent e) { - TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); - jTreeMIRIAM.setSelectionPath(closestMousePath); -// showPopup(e,closestMousePath); - if(e.getClickCount() == 2) { - DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTreeMIRIAM.getLastSelectedPathComponent(); - if (node instanceof LinkNode) { - showBrowseToLink((LinkNode)node); - } - } - } - }; - jTreeMIRIAM.addMouseListener(mouseListener); - - } catch (java.lang.Throwable ivjExc) { - ivjExc.printStackTrace(System.out); - } - } - return jTreeMIRIAM; -} -private void showBrowseToLink(LinkNode linkNode) { - String link = linkNode.getLink(); - if (link != null) { - DialogUtils.browserLauncher(jTreeMIRIAM, link, "failed to launch"); - }else{ - DialogUtils.showWarningDialog(this, "No Web-site link available"); - } -} -private void showBrowseToLink(VCMetaDataDataType md) { - String link = md.getDataTypeURL(); - if (link != null) { - DialogUtils.browserLauncher(getJComboBoxURI(), link, "Failed to launch"); - } else { - DialogUtils.showWarningDialog(this, "No Web-site link available"); - } -} - -private void initialize() { - try { - setLayout(new GridBagLayout()); - setBackground(Color.white); - - int gridy = 0; - GridBagConstraints gbc = new java.awt.GridBagConstraints(); - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - gbc.insets = new Insets(4, 4, 4, 4); - gbc.fill = java.awt.GridBagConstraints.BOTH; - gbc.anchor = GridBagConstraints.SOUTHWEST; - add(getBottomPanel(), gbc); - - JTextPane tenpTextPane = new JTextPane(); // used just to initialize emptyText once - tenpTextPane.setContentType("text/html"); - tenpTextPane.setText(null); - emptyHtmlText = tenpTextPane.getText(); - - initializeComboBoxQualifier(); - - getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() { - public void valueChanged(TreeSelectionEvent e) { - TreePath tp = ((JTree)e.getSource()).getSelectionPath(); - if(tp == null) { - getJButtonDeleteRef().setEnabled(false); - } else { - Object lastPathComponent = tp.getLastPathComponent(); - getJButtonDeleteRef().setEnabled(tp != null && lastPathComponent instanceof LinkNode); - } - } - }); - - } catch (java.lang.Throwable ivjExc) { - handleException(ivjExc); - } -} - -private void changeTextAnnotation() { - try{ - if (bioModel == null || selectedObject == null) { - return; - } - Identifiable entity = getIdentifiable(selectedObject); - String textAreaStr = (annotationTextArea.getText() == null || annotationTextArea.getText().length()==0?null:annotationTextArea.getText()); - String oldText = bioModel.getVCMetaData().getFreeTextAnnotation(entity); - - if(textAreaStr == null || textAreaStr.isEmpty() || emptyHtmlText.equals(textAreaStr)) { // no annotation now, the field is empty - bioModel.getVCMetaData().deleteFreeTextAnnotation(entity); // delete, if there's something previously saved - if(selectedObject instanceof ReactionStep) { - // we tell ReactionPropertiesPanel to refresh the annotation icon - ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); - } - } else if(!Compare.isEqualOrNull(oldText,textAreaStr)) { // some text annotation different from what's already saved - bioModel.getVCMetaData().setFreeTextAnnotation(entity, textAreaStr); // overwrite - if(selectedObject instanceof ReactionStep) { - // we tell ReactionPropertiesPanel to refresh the text annotation icon - ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); - } - } - } catch(Exception e) { - e.printStackTrace(System.out); - PopupGenerator.showErrorDialog(this,"Annotation Error\n"+e.getMessage(), e); - } -} -private void removeText() { - if (bioModel == null || selectedObject == null) { - return; - } - Identifiable entity = getIdentifiable(selectedObject); - annotationTextArea.setText(null); - bioModel.getVCMetaData().deleteFreeTextAnnotation(entity); // delete, if there's something previously saved - if(selectedObject instanceof ReactionStep) { - ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); - } -} - -public void setBioModel(BioModel newValue) { - if (newValue == bioModel) { - return; - } - bioModel = newValue; - vcMetaData = bioModel.getVCMetaData(); - - // set tree model on jTableMIRIAM here, since we have access to miriamDescrHeir here - miriamTreeModel = new MiriamTreeModel(new DefaultMutableTreeNode("Object Annotations",true), vcMetaData, false); - jTreeMIRIAM.setModel(miriamTreeModel); - - initializeComboBoxURI(); - getJTextFieldFormalID().setText("NewID"); - updateInterface(); -} - -private void updateInterface() { - if (bioModel == null) { - return; - } - Identifiable entity = getIdentifiable(selectedObject); - if(selectedObject != null && entity != null) { - getJComboBoxURI().setEnabled(true); - getJTextFieldFormalID().setEnabled(true); - getJButtonAddRef().setEnabled(true); - getJButtonRemoveText().setEnabled(true); - VCMetaDataDataType mdt = (VCMetaDataDataType)getJComboBoxURI().getSelectedItem(); - miriamTreeModel.createTree(entity); - - String freeText = bioModel.getVCMetaData().getFreeTextAnnotation(entity); - if(freeText == null || freeText.isEmpty()) { - annotationTextArea.setText(null); - } else { - annotationTextArea.setText(freeText); - } - annotationTextArea.setEditable(true); - annotationTextArea.setCaretPosition(0); - } else { - getJComboBoxURI().setEnabled(false); - getJTextFieldFormalID().setEnabled(false); - getJButtonAddRef().setEnabled(false); - getJButtonRemoveText().setEnabled(false); - miriamTreeModel.createTree(null); - - annotationTextArea.setText(null); - annotationTextArea.setEditable(false); - } -} -public static Identifiable getIdentifiable(Identifiable selectedObject) { - // - // for SpeciesContext objects: - // MIRIAM tree needs the Species !!! - // text Annotation needs the SpeciesContext - // - // !!! use this only for the tree !!! - // - if(selectedObject == null) { - return null; - } - if(selectedObject instanceof SpeciesContext) { - return (Species)((SpeciesContext)selectedObject).getSpecies(); - } else if(selectedObject instanceof MolecularType) { - return (MolecularType)selectedObject; - } else if(selectedObject instanceof ReactionRule) { - return (ReactionRule)selectedObject; - } else if(selectedObject instanceof ReactionStep) { - return (ReactionStep)selectedObject; - } else if(selectedObject instanceof RbmObservable) { - return (RbmObservable)selectedObject; - } else if(selectedObject instanceof BioModel) { - return (BioModel)selectedObject; - } else if(selectedObject instanceof Structure) { - return (Structure)selectedObject; - } else if(selectedObject instanceof BioPaxObject) { - return null; - } else if(selectedObject instanceof Model.ModelParameter) { - return (Model.ModelParameter)selectedObject; - } else if(selectedObject instanceof SimulationContext) { - return (SimulationContext)selectedObject; -// } else if(selectedObject instanceof Simulation) { -// return (Simulation)selectedObject; -// } else if(selectedObject instanceof SpeciesContextSpec) { -// return (SpeciesContextSpec)selectedObject; -// } else if(selectedObject instanceof ReactionSpec) { -// return (ReactionSpec)selectedObject; - } else { - return null; - } -} - -@Override -protected void onSelectedObjectsChange(Object[] selectedObjects) { - if (selectedObjects != null && selectedObjects.length == 1) { - if(selectedObjects[0] instanceof BioModelInfo || selectedObjects[0] instanceof MathModelInfo) { - return; - } - if(selectedObjects[0] instanceof Identifiable && selectedObjects[0] instanceof Displayable) { - selectedObject = (Identifiable)selectedObjects[0]; - System.out.println("AnnotationsPanel: class: " + selectedObject.getClass().getSimpleName() + ", selected object: " + ((Displayable)selectedObject).getDisplayName()); - } else { - selectedObject = null; - System.out.println("Unsupported or null entity"); - } - initializeComboBoxURI(); // if selectedObject or entity are null we just empty the combobox - getJButtonDeleteRef().setEnabled(false); - getJTextFieldFormalID().setText("NewID"); - updateInterface(); - } -} - -// ------------------------------------------------------------------------------------------------------- - -private void addIdentifier() { - if(PopupGenerator.showComponentOKCancelDialog(AnnotationsPanel.this, getJPanelNewIdentifier(), "Define New Formal Identifier") != JOptionPane.OK_OPTION) { - return; - } - MIRIAMQualifier qualifier = (MIRIAMQualifier)getJComboBoxQualifier().getSelectedItem(); - MiriamManager.DataType objectNamespace = (MiriamManager.DataType)getJComboBoxURI().getSelectedItem(); - String objectID = getJTextFieldFormalID().getText(); - if(objectID.compareTo("NewID") == 0) { - return; - } - MiriamManager miriamManager = vcMetaData.getMiriamManager(); - HashSet miriamResources = new HashSet(); - try { - Identifiable entity = getIdentifiable(selectedObject); - MiriamResource mr = miriamManager.createMiriamResource(objectNamespace.getBaseURN()+":"+objectID); - miriamResources.add(mr); - miriamManager.addMiriamRefGroup(entity, qualifier, miriamResources); -// System.out.println(vcMetaData.printRdfStatements()); - updateInterface(); - if(selectedObject instanceof ReactionStep) { - // we tell ReactionPropertiesPanel to refresh the annotation icon - ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); - } - } catch (Exception e) { - e.printStackTrace(); - DialogUtils.showErrorDialog(this,"Add Identifier failed:\n"+e.getMessage(), e); - } -} -private void removeIdentifier() { - Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent(); - if (treeNode instanceof LinkNode) { - LinkNode linkNode = (LinkNode)treeNode; - MiriamResource resourceToDelete = linkNode.getMiriamResource(); - Identifiable entity = getIdentifiable(selectedObject); - //Map refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(entity); - MiriamManager mm = vcMetaData.getMiriamManager(); - Map refGroupsToRemove = mm.getMiriamTreeMap().get(entity); - - boolean found = false; - for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()){ - MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup); - for (MiriamResource miriamResource : refGroup.getMiriamRefs()) { - - if(!isEqual(miriamResource, resourceToDelete)) { - continue; - } - try { - mm.remove2(entity, qualifier, refGroup); // remove the ref group for this resource - System.out.println(vcMetaData.printRdfStatements()); - - found = true; - break; - } catch (URNParseFailureException e) { - e.printStackTrace(System.out); - } - } - if(found == true) { - updateInterface(); - if(selectedObject instanceof ReactionStep) { - ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", true, false); - } - break; - } - } - } -} - -private boolean isEqual(MiriamResource aThis, MiriamResource aThat) { - if (aThis == aThat) { - return true; - } - if (!(aThis instanceof MiriamResource)) { - return false; - } - if (!(aThat instanceof MiriamResource)) { - return false; - } - MiriamResource athis = (MiriamResource)aThis; - MiriamResource athat = (MiriamResource)aThat; - - if (athis.getDataType() != null && athat.getDataType() != null && !athis.getDataType().equals(athat.getDataType())) { - return false; - } - if (!Compare.isEqual(athis.getMiriamURN(), athat.getMiriamURN())) { - return false; - } - if (!Compare.isEqual(athis.getIdentifier(), athat.getIdentifier())) { - return false; - } - return true; -} - -@SuppressWarnings("unchecked") -private void initializeComboBoxURI() { - Identifiable entity = getIdentifiable(selectedObject); - defaultComboBoxModelURI.removeAllElements(); - List tooltips = new ArrayList (); - List dataTypeList = new ArrayList<>(); - if(entity == null) { - for (DataType dt : vcMetaData.getMiriamManager().getAllDataTypes().values()) { - dataTypeList.add(dt); - } - } else { - for (DataType dt : VCMetaDataMiriamManager.getSpecificDataTypes(entity)) { - dataTypeList.add(dt); - } - } - Collections.sort(dataTypeList); - for(DataType dt : dataTypeList) { - tooltips.add(dt.getDescription()); - defaultComboBoxModelURI.addElement(dt); - } - ((ComboboxToolTipRenderer)getJComboBoxURI().getRenderer()).setTooltips(tooltips); -} -private void initializeComboBoxQualifier() { - //Set MIRIAM_all; - //AnnotationQualifiers.MIRIAM_all; - List qualifierList = new ArrayList<>(); - for(MIRIAMQualifier qualifier : AnnotationQualifiers.MIRIAM_all) { - qualifierList.add(qualifier); - } - Collections.sort(qualifierList); - for(MIRIAMQualifier qualifier : qualifierList) { - defaultComboBoxModelQualifier.addElement(qualifier); - } -} - -private JButton getJButtonAddRef() { - if (jButtonAddRef == null) { - jButtonAddRef = new JButton(); - jButtonAddRef.setText(ACTION_ADD); - jButtonAddRef.setToolTipText("Add a new reference with this provider"); - } - return jButtonAddRef; -} -private JButton getJButtonDeleteRef() { - if (jButtonDeleteRef == null) { - jButtonDeleteRef = new JButton(); - jButtonDeleteRef.setText(ACTION_DELETE); - jButtonDeleteRef.setToolTipText("Delete the selected cross-reference"); - - } - return jButtonDeleteRef; -} -private JButton getJButtonRemoveText() { - if (jButtonRemoveText == null) { - jButtonRemoveText = new JButton(); - jButtonRemoveText.setText(ACTION_REMOVE_TEXT); - jButtonRemoveText.setToolTipText("Remove the entire text annotation"); - } - return jButtonRemoveText; -} - /* - -Universal (goes in all types of annotations): -PubMed ID https://www.ncbi.nlm.nih.gov/pubmed -DOI: https://www.doi.org/ - -Model -BioModels Database https://www.ebi.ac.uk/biomodels/ -Reactome: https://reactome.org/ -Grey: NeuronDB: https://senselab.med.yale.edu/neurondb/ -Grey: https://senselab.med.yale.edu/modeldb/ -Grey: CellML Model Repository: https://models.cellml.org/cellml - -Species/Molecules/Observables: -CheBI: https://www.ebi.ac.uk/chebi/ -Kegg Compound: https://www.genome.jp/kegg/compound/ -Uniprot: https://www.uniprot.org/ -Enzyme Nomenclature: http://www.sbcs.qmul.ac.uk/iubmb/enzyme/ -Gene Ontology: http://www.geneontology.org/ -Reactome: https://reactome.org/ - -Reactions -Kegg Reaction: https://www.genome.jp/kegg/reaction/ -Kegg Pathway: https://www.genome.jp/kegg/pathway.html -Reactome: https://reactome.org/ -Grey: BRENDA: https://www.brenda-enzymes.org/ -Grey: BIND https://www.bindingdb.org/bind/index.jsp - -Parameters (all grey for now) -Grey:BIND https://www.bindingdb.org/bind/index.jsp - -Structures -Grey: BRENDA: https://www.brenda-enzymes.org/ -Grey: Gene Ontology http://geneontology.org/ - - -DataType DataType_PIR "PIRSF" -DataType DataType_DOI "DOI" -DataType DataType_BIOMODELS "BioModels Database" -DataType DataType_Chebi "ChEBI" -DataType DataType_IntAct "IntAct" -DataType DataType_InterPro "InterPro" -DataType DataType_ECCODE "Enzyme Nomenclature" -DataType DataType_ENSEMBLE "Ensembl" -DataType DataType_GO "Gene Ontology" -DataType DataType_KEGGCOMPOUND "KEGG Compound" -DataType DataType_KEGGPATHWAY "KEGG Pathway" -DataType DataType_KEGGREACTION "KEGG Reaction" -DataType DataType_PUBMED "PubMed" -DataType DataType_TAXONOMY "Taxonomy" -DataType DataType_REACTOME "Reactome" -DataType DataType_UNIPROT "UniProt" -DataType DataType_ICD "ICD" - - - - -*/ - - - - - -} diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditor.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditor.java index 1eaa09851c..b084fd93cc 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditor.java +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditor.java @@ -24,6 +24,7 @@ import javax.swing.JComponent; import javax.swing.ListSelectionModel; +import cbit.vcell.client.desktop.biomodel.annotations.AnnotationsPanel; import org.vcell.model.rbm.MolecularType; import org.vcell.model.rbm.SpeciesPattern; import org.vcell.pathway.BioPaxObject; @@ -53,7 +54,6 @@ import cbit.vcell.clientdb.DocumentManager; import cbit.vcell.data.DataSymbol; import cbit.vcell.desktop.BioModelNode; -import cbit.vcell.desktop.BioModelNode.PublicationInfoNode; import cbit.vcell.geometry.CSGObject; import cbit.vcell.geometry.GeometryInfo; import cbit.vcell.geometry.gui.CSGObjectPropertiesPanel; diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditorModelPanel.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditorModelPanel.java index 1047e7a5f6..bb3bd61dc2 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditorModelPanel.java +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/BioModelEditorModelPanel.java @@ -61,6 +61,7 @@ import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; +import cbit.vcell.client.desktop.biomodel.annotations.AnnotationsPanel; import org.vcell.model.rbm.MolecularType; import org.vcell.model.rbm.RbmNetworkGenerator.CompartmentMode; import org.vcell.model.rbm.RbmUtils; diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/ReactionPropertiesPanel.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/ReactionPropertiesPanel.java index 3bd7be0d1e..8da9e0b8e5 100644 --- a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/ReactionPropertiesPanel.java +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/ReactionPropertiesPanel.java @@ -13,7 +13,6 @@ import java.awt.Color; import java.awt.Component; import java.awt.Dimension; -import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import java.awt.Insets; @@ -22,7 +21,6 @@ import java.awt.event.FocusListener; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.beans.PropertyVetoException; @@ -39,10 +37,10 @@ import javax.swing.JList; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.ListSelectionModel; +import cbit.vcell.client.desktop.biomodel.annotations.AnnotationsPanel; import org.vcell.pathway.BioPaxObject; import org.vcell.pathway.Entity; import org.vcell.relationship.RelationshipEvent; @@ -50,18 +48,14 @@ import org.vcell.relationship.RelationshipObject; import org.vcell.sybil.models.miriam.MIRIAMQualifier; import org.vcell.util.BeanUtils; -import org.vcell.util.Compare; import org.vcell.util.document.Identifiable; -import org.vcell.util.gui.CollapsiblePanel; import org.vcell.util.gui.DialogUtils; import org.vcell.util.gui.ScrollTable; import org.vcell.util.gui.VCellIcons; import cbit.vcell.biomodel.BioModel; import cbit.vcell.biomodel.meta.MiriamManager; -import cbit.vcell.biomodel.meta.VCMetaData; import cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup; -import cbit.vcell.client.PopupGenerator; import cbit.vcell.client.desktop.biomodel.DocumentEditorTreeModel.DocumentEditorTreeFolderClass; import cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveView; import cbit.vcell.client.desktop.biomodel.SelectionManager.ActiveViewID; diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AddAnnotationsPanel.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AddAnnotationsPanel.java new file mode 100644 index 0000000000..621df12f44 --- /dev/null +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AddAnnotationsPanel.java @@ -0,0 +1,362 @@ +package cbit.vcell.client.desktop.biomodel.annotations; + +import cbit.vcell.biomodel.meta.VCMetaDataMiriamManager; +import org.vcell.util.document.Identifiable; +import org.xml.sax.SAXException; + +import javax.swing.*; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import javax.xml.parsers.ParserConfigurationException; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.io.IOException; +import java.net.URISyntaxException; +import java.util.List; +import java.util.Objects; + +public class AddAnnotationsPanel extends JFrame implements ActionListener { + + private JButton searchButton; + private JTextField searchBar; + private JList list; + private JComboBox ontologiesBox; + private JComboBox containsBox; + private JComboBox limitBox; + private JTextArea descriptionArea; + private List SearchElements; + private final JButton addButton, oKButton; + private final AnnotationsPanel annotationsPanel; //to connect AnnotationsPanel with AddAnnotationsPanel + private String annotDescription; + private JComboBox jComboBoxURI, jComboBoxQualifier; // identity provider combo + DefaultComboBoxModel defaultComboBoxModelURI = null; + public static final int MAX_URI_LENGTH = 130; + private Identifiable selectedObject = null; + + public AddAnnotationsPanel (AnnotationsPanel annotationsPanel, JComboBox JComboBoxURI, JComboBox JComboBoxQualifier) { + this.annotationsPanel = annotationsPanel; + this.jComboBoxURI = (JComboBoxURI==null) ? new JComboBox<>(): JComboBoxURI; + this.jComboBoxQualifier = (JComboBoxQualifier==null) ? new JComboBox<>(): JComboBoxQualifier; + + setTitle("Add Annotations"); + setResizable(false); + setLocationRelativeTo(null); + + GridBagLayout gbl = new GridBagLayout(); + JPanel mainPanel = new JPanel(gbl); + + + GridBagConstraints gbc = new GridBagConstraints(); + gbc.weightx = 1; + gbc.weighty = 1; + gbc.fill = GridBagConstraints.BOTH; + gbc.insets = new Insets(15,0,0,0); + + //Add left panel for searching annotations + gbc.gridy = 0; + JPanel searchPanel = new JPanel(); + addSearchPanelComponents(searchPanel); + mainPanel.add(searchPanel, gbc); + + //Add right panel for descriptions + gbc.gridx = 1; + gbc.gridwidth = 2; + gbc.insets = new Insets(0,15,0,0); + JPanel descriptionPanel = new JPanel(); + addDescriptionPanelComponents(descriptionPanel); + mainPanel.add(descriptionPanel,gbc); + + //Add JComboBox for qualifier + gbc.gridy = 1; + gbc.gridx = 0; + gbc.fill = GridBagConstraints.VERTICAL; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(0,0,12,10); + mainPanel.add(jComboBoxQualifier,gbc); + + //Add "add" button to main panel + gbc.gridy = 1; + gbc.gridx = 1; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.WEST; + gbc.insets = new Insets(0,0,12,0); + addButton = new JButton("Add"); + addButton.addActionListener(this); + mainPanel.add(addButton, gbc); + + //Add OK button to main panel + gbc.gridy = 1; + gbc.gridx = 2; + gbc.fill = GridBagConstraints.NONE; + gbc.anchor = GridBagConstraints.EAST; + gbc.insets = new Insets(0,0,12,15); + oKButton = new JButton("OK"); + oKButton.setSize(10,20); + oKButton.setMinimumSize(oKButton.getPreferredSize()); + oKButton.addActionListener(this); + mainPanel.add(oKButton, gbc); + + this.getContentPane().add(mainPanel); + this.pack(); + this.setDefaultCloseOperation(DISPOSE_ON_CLOSE); + this.setVisible(true); + } + + public JButton getOkButton() { + return oKButton; + } + + private void addSearchPanelComponents(JPanel leftPanel) { + GridBagLayout sGbl = new GridBagLayout(); + GridBagConstraints sGbc = new GridBagConstraints(); + leftPanel.setLayout(sGbl); + + sGbc.weightx = 1; + sGbc.weighty = 1; + sGbc.fill = GridBagConstraints.NONE; + + //adding select ontology Label + sGbc.gridy = 0; + sGbc.gridx = 0; + sGbc.insets = new Insets(0,10,0,0); + JLabel selectOntologyLabel = new JLabel("Select Ontology:"); + leftPanel.add(selectOntologyLabel, sGbc); + + //adding ontologies combobox + sGbc.gridy = 0; + sGbc.gridx = 1; + sGbc.insets = new Insets(0,10,0,0); + +// ontologiesBox = new JComboBox<>(); +// ontologiesBox.addItem("All Selected"); +// ontologiesBox.addItem("GO"); +// ontologiesBox.addItem("NCIT"); +// ontologiesBox.addItem("CHEBI"); +// ontologiesBox.addItem("FMA"); +// ontologiesBox.addItem("BTO"); +// leftPanel.add(ontologiesBox, sGbc); +// leftPanel.add(annotationsPanel.getJComboBoxURI(), sGbc); + leftPanel.add(jComboBoxURI, sGbc); + + //adding search label + sGbc.gridy = 1; + sGbc.gridx = 0; + sGbc.anchor = GridBagConstraints.EAST; + sGbc.insets = new Insets(15,0,0,0); + JLabel searchLabel = new JLabel("Search term:"); + leftPanel.add(searchLabel, sGbc); + + //adding contains/exaxt Jcombobox + sGbc.gridy = 1; + sGbc.gridx = 1; + sGbc.anchor = GridBagConstraints.CENTER; + sGbc.insets = new Insets(15,0,0,5); + + containsBox = new JComboBox<>(); + containsBox.addItem("contains"); + containsBox.addItem("exact"); + leftPanel.add(containsBox, sGbc); + + //adding search bar + sGbc.gridy = 1; + sGbc.fill = GridBagConstraints.HORIZONTAL; + sGbc.gridx = 2; + sGbc.gridwidth = 2; + sGbc.anchor = GridBagConstraints.CENTER; + sGbc.insets = new Insets(15,0,0,10); + searchBar = new JTextField(25); + leftPanel.add(searchBar, sGbc); + + //adding limit label + sGbc.fill = GridBagConstraints.NONE; + sGbc.anchor = GridBagConstraints.EAST; + sGbc.gridwidth = 1; + sGbc.gridy = 2; + sGbc.gridx = 0; + sGbc.insets = new Insets(8,0,0,3); + JLabel limitLabel = new JLabel("Limit to"); + leftPanel.add(limitLabel, sGbc); + + //adding limit JComboBox + sGbc.fill = GridBagConstraints.HORIZONTAL; + sGbc.anchor = GridBagConstraints.CENTER; + sGbc.gridy = 2; + sGbc.gridx = 1; + sGbc.insets = new Insets(8,0,0,2); + limitBox = new JComboBox<>(); + limitBox.addItem("50"); + limitBox.addItem("100"); + limitBox.addItem("500"); + + leftPanel.add(limitBox, sGbc); + + //adding limit term label + sGbc.fill = GridBagConstraints.NONE; + sGbc.anchor = GridBagConstraints.WEST; + sGbc.gridy = 2; + sGbc.gridx = 2; + sGbc.insets = new Insets(8,0,0,3); + JLabel elementLabel = new JLabel("elements"); + leftPanel.add(elementLabel, sGbc); + + //adding search button + sGbc.anchor = GridBagConstraints.EAST; + sGbc.gridy = 2; + sGbc.gridx = 3; +// sGbc.insets = new Insets(8,0,0,0); + searchButton = new JButton("Search"); + searchButton.addActionListener(this); + leftPanel.add(searchButton, sGbc); + + + //adding results label + sGbc.fill = GridBagConstraints.HORIZONTAL; + sGbc.gridy = 3; + sGbc.gridx = 0; + sGbc.gridwidth = 4; + sGbc.insets = new Insets(8,10,0,0); + JLabel resultLabel = new JLabel("Search Results:"); + leftPanel.add(resultLabel, sGbc); + + //adding term list + sGbc.gridy = 4; + sGbc.gridx = 0; + sGbc.insets = new Insets(0,10,15,0); + sGbc.ipady = 80; + list = new JList<>(); + list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + list.addListSelectionListener(new ListSelectionListener() { + @Override + public void valueChanged(ListSelectionEvent listSelectionEvent) { + if (!listSelectionEvent.getValueIsAdjusting()) { + getDescription(); + } + } + }); + leftPanel.add(new JScrollPane(list), sGbc); + } + + private void addDescriptionPanelComponents(JPanel rightPanel) { + GridBagLayout dGbl = new GridBagLayout(); + GridBagConstraints dGbc = new GridBagConstraints(); + rightPanel.setLayout(dGbl); + + dGbc.weightx = 1; + dGbc.weighty = 0.5; + dGbc.fill = GridBagConstraints.HORIZONTAL; + + //adding label + dGbc.gridy = 0; + dGbc.anchor = GridBagConstraints.SOUTH; + dGbc.insets = new Insets(0,0,5,0); + JLabel descLabel = new JLabel("Description:"); + rightPanel.add(descLabel, dGbc); + + //adding text area + dGbc.weighty = 1; + dGbc.gridy = 1; + dGbc.ipady = 30; + dGbc.anchor = GridBagConstraints.NORTH; + dGbc.fill = GridBagConstraints.BOTH; + dGbc.insets = new Insets(0,0,20,15); + descriptionArea = new JTextArea(); + descriptionArea.setLineWrap(true); + descriptionArea.setWrapStyleWord(true); + descriptionArea.setColumns(35); + descriptionArea.setEditable(false); +// descriptionArea.setMaximumSize(new Dimension(10,10)); + rightPanel.add(new JScrollPane(descriptionArea),dGbc); + } + + + @Override + public void actionPerformed(ActionEvent evt) { + if (evt.getSource() == searchButton) { + getSearchResults(); + } else if (evt.getSource() == addButton) { + setAnnotationDescAndIdentifier(); + } else if (evt.getSource() == oKButton) { + this.dispose(); + } + } + + private void getSearchResults() { + //clear description area and search list before new + descriptionArea.setText(null); +// list.removeAll(); + DefaultListModel dlm = new DefaultListModel<>(); + String searchTerm = searchBar.getText(); + BioPortalSearch bioPortalSearch = new BioPortalSearch(); + +// String bioPortalDatabases = Objects.equals(ontologiesBox.getSelectedItem(), "All Selected") ? +// "GO,NCIT,CHEBI,FMA,BTO" : Objects.requireNonNull(ontologiesBox.getSelectedItem()).toString(); + //MiriamManager.DataType dataType = (MiriamManager.DataType) annotationsPanel.getJComboBoxURI().getSelectedItem(); + VCMetaDataMiriamManager.VCMetaDataDataType mdt = (VCMetaDataMiriamManager.VCMetaDataDataType)jComboBoxURI.getSelectedItem(); +// String bioPortalDatabases = dataType.getDataTypeName(); + String bioPortalDatabases = mdt.getDataTypeName(); + + boolean exactMatch = Objects.equals(containsBox.getSelectedItem(), "exact"); + + int pageSize = Integer.parseInt(Objects.requireNonNull(limitBox.getSelectedItem()).toString()); + + try { + SearchElements = bioPortalSearch.search(searchTerm,pageSize,bioPortalDatabases,exactMatch); + if (!SearchElements.isEmpty()) { + list.setEnabled(true); + list.setFont(new Font("TimesRoman",Font.PLAIN,13)); + for (SearchElement element: SearchElements) { + dlm.addElement(element.getEntityName()); + } + } else { + list.setFont(new Font("Arial", Font.BOLD, 14)); + dlm.addElement("No matches found"); + list.setEnabled(false); + } + list.setModel(dlm); + } catch (IOException | SAXException | URISyntaxException | ParserConfigurationException | + InterruptedException ex) { + throw new RuntimeException(ex); + } + } + + private void getDescription() { + if (!list.isSelectionEmpty()) { + annotDescription = SearchElements.get(list.getSelectedIndex()).toString(); + descriptionArea.setText(annotDescription); + descriptionArea.setCaretPosition(0); + } + } + + private void setAnnotationDescAndIdentifier() { + if (!list.isSelectionEmpty()) { + annotationsPanel.addToAnnotationTextArea(annotDescription); + } + annotationsPanel.addIdentifier(SearchElements.get(list.getSelectedIndex())); + } + + //getter and setter for JComboBoxURI + public JComboBox getjComboBoxURI() { + return jComboBoxURI; + } + + public void setjComboBoxURI(JComboBox jComboBoxURI) { + this.jComboBoxURI = jComboBoxURI; + } + + +// JComboBox getJComboBoxURI() { +// if (jComboBoxURI == null) { +// jComboBoxURI = new JComboBox(); +// defaultComboBoxModelURI = new DefaultComboBoxModel(); +// jComboBoxURI.setModel(defaultComboBoxModelURI); +// Dimension d = jComboBoxURI.getPreferredSize(); +// jComboBoxURI.setMinimumSize(new Dimension(MAX_URI_LENGTH, d.height)); +// jComboBoxURI.setPreferredSize(new Dimension(MAX_URI_LENGTH, d.height)); +// AnnotationsPanel.ComboboxToolTipRenderer renderer = new AnnotationsPanel.ComboboxToolTipRenderer(); +// jComboBoxURI.setRenderer(renderer); +// } +// return jComboBoxURI; +// } + +} diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AnnotationsPanel.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AnnotationsPanel.java new file mode 100644 index 0000000000..51110c9496 --- /dev/null +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/AnnotationsPanel.java @@ -0,0 +1,1204 @@ +/* + * Copyright (C) 1999-2011 University of Connecticut Health Center + * + * Licensed under the MIT License (the "License"). + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at: + * + * http://www.opensource.org/licenses/mit-license.php + */ + +package cbit.vcell.client.desktop.biomodel.annotations; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.Insets; +import java.awt.SystemColor; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.FocusEvent; +import java.awt.event.FocusListener; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.MouseListener; +import java.beans.PropertyChangeEvent; +import java.beans.PropertyChangeListener; +import java.net.URI; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.swing.*; +import javax.swing.event.TreeSelectionEvent; +import javax.swing.event.TreeSelectionListener; +import javax.swing.tree.DefaultMutableTreeNode; +import javax.swing.tree.DefaultTreeCellRenderer; +import javax.swing.tree.DefaultTreeSelectionModel; +import javax.swing.tree.TreePath; + +import cbit.vcell.client.desktop.biomodel.DocumentEditorSubPanel; +import org.vcell.model.rbm.MolecularType; +import org.vcell.pathway.BioPaxObject; +import org.vcell.sybil.models.AnnotationQualifiers; +import org.vcell.sybil.models.miriam.MIRIAMQualifier; +import org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException; +import org.vcell.util.Compare; +import org.vcell.util.Displayable; +import org.vcell.util.document.BioModelInfo; +import org.vcell.util.document.Identifiable; +import org.vcell.util.document.MathModelInfo; +import org.vcell.util.gui.DialogUtils; + +import cbit.vcell.biomodel.BioModel; +import cbit.vcell.biomodel.meta.MiriamManager; +import cbit.vcell.biomodel.meta.VCMetaData; +import cbit.vcell.biomodel.meta.VCMetaDataMiriamManager; +import cbit.vcell.biomodel.meta.VCMetaDataMiriamManager.VCMetaDataDataType; +import cbit.vcell.biomodel.meta.MiriamManager.DataType; +import cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup; +import cbit.vcell.biomodel.meta.MiriamManager.MiriamResource; +import cbit.vcell.client.PopupGenerator; +import cbit.vcell.desktop.BioModelCellRenderer; +import cbit.vcell.mapping.SimulationContext; +import cbit.vcell.model.Model; +import cbit.vcell.model.RbmObservable; +import cbit.vcell.model.ReactionRule; +import cbit.vcell.model.ReactionStep; +import cbit.vcell.model.Species; +import cbit.vcell.model.SpeciesContext; +import cbit.vcell.model.Structure; +import cbit.vcell.xml.gui.MiriamTreeModel; +import cbit.vcell.xml.gui.MiriamTreeModel.LinkNode; +/** + * Superclass for all the Annotation panels + * Creation date: (11/6/2018 3:44:00 PM) + * @author: Dan Vasilescu + */ +@SuppressWarnings("serial") +public class AnnotationsPanel extends DocumentEditorSubPanel { + private BioModel bioModel = null; + private VCMetaData vcMetaData = null; + MiriamTreeModel miriamTreeModel = null; + + private Identifiable selectedObject = null; + + public static final String ACTION_ADD ="Add..."; + public static final String ACTION_DELETE ="Delete"; + public static final String ACTION_REMOVE_TEXT = "Delete"; + public static final String ACTION_GOTO ="Go"; + public static final int COMBO_QUALIFIER_WIDTH = 200; + public static final int MAX_DESCRIPTION_LENGTH = 145; + public static final int MAX_URI_LENGTH = 130; + + private EventHandler eventHandler = new EventHandler(); + + private JTree jTreeMIRIAM = null; + + private JPanel jPanelNewIdentifier = null; // add new identity dialog + private JPanel jPanelIdentifierManager = null; // upper panel with the identity provider combobox, Navigate and Add buttons + private JPanel jPanelLowerLeft = null; // lower left panel with the Delete buttons + private JPanel jBottomPanel = null; + private JSplitPane splitPane = null; + private JScrollPane jScrollPane = null; // will show the MIRIAM JTree + + private JComboBox jComboBoxURI = null; // identity provider combo + private DefaultComboBoxModel defaultComboBoxModelURI = null; + private JComboBox jComboBoxQualifier = null; // annotation qualifier combo (isDescribedBy, etc) + private DefaultComboBoxModel defaultComboBoxModelQualifier = new DefaultComboBoxModel(); + + private JTextField jTextFieldFormalID = null; // immortal ID text + private JButton jButtonAddRef = null; // add a cross-reference + private JButton jButtonDeleteRef = null; // delete selected cross-reference + private JButton jButtonRemoveText = null; // remove text annotation + + JTextArea annotationTextArea = null; + private String emptyHtmlText = null; // content of annotationTextArea after initialization with null + // will contain an empty html object "

" + private static String emptyHtmlText2 = "
"; // really empty + + private AddAnnotationsPanel addAnnotationsPanel; //new window to add annotations from online DBs. + + + private class EventHandler extends MouseAdapter implements ActionListener, FocusListener, PropertyChangeListener, KeyListener { + public void focusGained(FocusEvent e) { + } + public void focusLost(FocusEvent e) { + if (e.getSource() == annotationTextArea) { + changeTextAnnotation(); + } + } + @Override + public void mouseExited(MouseEvent e) { + super.mouseExited(e); + if(e.getSource() == annotationTextArea) { + changeTextAnnotation(); + } + } + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getSource() instanceof SpeciesContext + || evt.getSource() instanceof MolecularType + || evt.getSource() instanceof ReactionRule + || evt.getSource() instanceof ReactionStep + || evt.getSource() instanceof RbmObservable + || evt.getSource() instanceof BioModel + || evt.getSource() instanceof Structure + || evt.getSource() instanceof Model.ModelParameter + || evt.getSource() instanceof BioPaxObject + + || evt.getSource() instanceof SimulationContext +// || evt.getSource() instanceof Simulation // TODO: check why is not saving +// || evt.getSource() instanceof SpeciesContextSpec // TODO: can't use species name for spec too, need some hack +// || evt.getSource() instanceof ReactionSpec + ) { + initializeComboBoxURI(); + updateInterface(); + } + } + @Override + public void actionPerformed(ActionEvent evt) { + if (evt.getSource() == getJButtonAddRef()) { + initializeAddAnnotationsPanel(); + +// addIdentifier(); + } + else if(evt.getSource() == addAnnotationsPanel.getOkButton()) { + annotationTextArea.setText("A test from the void"); + } + + else if(evt.getSource() == getJButtonDeleteRef()) { + removeIdentifier(); + } else if(evt.getSource() == getJButtonRemoveText()) { + removeText(); + } + } + @Override + public void keyPressed(KeyEvent e) { + } + @Override + public void keyReleased(KeyEvent e) { + // too expensive to parse it at each keystroke +// System.out.println("key released"); +// if (e.getSource() == annotationTextArea) { +// String text = annotationTextArea.getText(); +// text = text.replaceAll("(\n\r|\n|\r)", ""); +// text = text.replaceAll(" ", ""); +// System.out.println(text); +// } + } + @Override + public void keyTyped(KeyEvent e) { + } + } + + public static class ComboboxToolTipRenderer extends DefaultListCellRenderer { + List tooltips; + @SuppressWarnings("rawtypes") + @Override + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { + Component comp; + if(value == null) { + comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } else if(value instanceof DataType) { + DataType dt = (DataType)value; + comp = super.getListCellRendererComponent(list,dt.getDataTypeName(),index,isSelected,cellHasFocus); + } else if(value instanceof MIRIAMQualifier) { + MIRIAMQualifier mc = (MIRIAMQualifier)value; + comp = super.getListCellRendererComponent(list,mc.getDescription(),index,isSelected,cellHasFocus); + } else { + comp = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + } + if (-1 < index && null != value && null != tooltips) { + list.setToolTipText(tooltips.get(index)); + } + return comp; + } + public void setTooltips(List tooltips) { + this.tooltips = tooltips; + } + } + + + public AnnotationsPanel() { + super(); + initialize(); + } + + private void handleException(java.lang.Throwable exception) { + System.out.println("--------- UNCAUGHT EXCEPTION ---------"); + exception.printStackTrace(System.out); + } + + private JPanel getJPanelNewIdentifier() { + jPanelNewIdentifier = new JPanel(); + jPanelNewIdentifier.setLayout(new GridBagLayout()); +// jPanelNewIdentifier.setPreferredSize(new Dimension(725, 37)); +// jPanelNewIdentifier.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 2)); +//////////////////////////////////////////////////////////////////////////////////////////////////////// +// VCMetaDataDataType mdt = (VCMetaDataDataType)getJComboBoxURI().getSelectedItem(); + int gridx = 0; + int gridy = 0; + GridBagConstraints gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right +// gbc.gridx = gridx; +// gbc.gridy = gridy; +// gbc.anchor = GridBagConstraints.WEST; +// jPanelNewIdentifier.add(new JLabel("Provider: "), gbc); +// +// gridx++; +// gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 5, 3, 4); +// gbc.gridx = gridx; +// gbc.gridy = gridy; +// gbc.anchor = GridBagConstraints.WEST; +// jPanelNewIdentifier.add(new JLabel("" + mdt.getDataTypeName() + ""), gbc); + + // ------------------------------------- Qualifier combobox ----------------------------- + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right + gbc.gridx = gridx; + gbc.gridy = gridy; + jPanelNewIdentifier.add(new JLabel("Qualifier"), gbc); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 5, 3, 4); + gbc.gridx = gridx; + gbc.gridy = gridy; + jPanelNewIdentifier.add(getJComboBoxQualifier(), gbc); + + // ------------------------------------------------------------------------------- + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.anchor = GridBagConstraints.WEST; + jPanelNewIdentifier.add(new JLabel("Identifier ID"), gbc); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 5, 3, 4); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.anchor = GridBagConstraints.WEST; + jPanelNewIdentifier.add(getJTextFieldFormalID(), gbc); + getJTextFieldFormalID().setText("NewID"); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.anchor = GridBagConstraints.WEST; +// jPanelNewIdentifier.add(new JLabel("Example: " + mdt.getExample() +""), gbc); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.anchor = GridBagConstraints.EAST; + jPanelNewIdentifier.add(new JLabel(), gbc); + + // --------------------------------------------------------------------- + gridx = 0; + gridy++; + + JLabel linkLabel = new JLabel(); +// String s = "" + "Navigate to" + " " + mdt.getDataTypeURL() + "  "; +// s += "and find the identifier ID, then paste it in the box above." + ""; + linkLabel.setToolTipText("Double-click to open link"); +// linkLabel.setText(s); + linkLabel.addMouseListener(new MouseAdapter() { + public void mousePressed(MouseEvent e) { + if(e.getClickCount() == 2) { +// showBrowseToLink(mdt); + } + } + }); + + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.gridwidth = 8; + gbc.anchor = GridBagConstraints.WEST; + jPanelNewIdentifier.add(linkLabel, gbc); + + // --------------------------------------------------------------------- + List rows = new ArrayList<> (); +// String value = mdt.getDescription(); +// StringTokenizer tokenizer = new StringTokenizer(value, " "); + String row = ""; +// while(tokenizer.hasMoreTokens()) { +// String word = tokenizer.nextToken(); +// if((row.length() + word.length()) > MAX_DESCRIPTION_LENGTH) { +// rows.add(row); +// row = word + " "; +// } else { +// row += word + " "; +// } +// } + if(!row.isEmpty()) { + rows.add(row); + } + for(String currentRow : rows) { + gridx = 0; + gridy++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); + gbc.gridx = gridx; + gbc.gridy = gridy; + gbc.gridwidth = 8; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + jPanelNewIdentifier.add(new JLabel(currentRow), gbc); + + } + return jPanelNewIdentifier; + } + private JPanel getJPanelLeftTitle() { + JPanel jPanelLeftTitle = new JPanel(); + jPanelLeftTitle.setLayout(new GridBagLayout()); + jPanelLeftTitle.setPreferredSize(new Dimension(260, 37)); + jPanelLeftTitle.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); + int gridx = 0; + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right + gbc.gridx = gridx; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + jPanelLeftTitle.add(new JLabel("User defined cross-references."), gbc); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 6, 3, 8); + gbc.gridx = gridx; + gbc.gridy = 0; + jPanelLeftTitle.add(getJButtonAddRef(), gbc); + getJButtonAddRef().addActionListener(eventHandler); + + return jPanelLeftTitle; + } + private JPanel getJPanelRightTitle() { + JPanel jPanelRightTitle = new JPanel(); + jPanelRightTitle.setLayout(new GridBagLayout()); + jPanelRightTitle.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); + + int gridx = 0; + GridBagConstraints gbc = new GridBagConstraints(); + gbc.gridx = gridx; + gbc.gridy = 0; + gbc.insets = new Insets(6, 8, 0, 0); // top left bottom right + gbc.anchor = GridBagConstraints.NORTHWEST; + jPanelRightTitle.add(new JLabel("Text Annotations"), gbc); + + gridx++; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = gridx; + gbc.gridy = 0; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.fill = java.awt.GridBagConstraints.BOTH; + jPanelRightTitle.add(new JLabel(), gbc); + + gridx++; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = gridx; + gbc.gridy = 0; + gbc.insets = new Insets(3, 0, 3, 3); + gbc.anchor = GridBagConstraints.NORTHEAST; + jPanelRightTitle.add(getJButtonRemoveText(), gbc); + + getJButtonRemoveText().addActionListener(eventHandler); + return jPanelRightTitle; + } + private JPanel getJPanelIdentifierManager() { + if (jPanelIdentifierManager == null) { + jPanelIdentifierManager = new JPanel(); +// jPanelIdentifierManager.setLayout(new GridBagLayout()); +// jPanelIdentifierManager.setPreferredSize(new Dimension(260, 300)); //37 +// jPanelIdentifierManager.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); +// +// int gridx = 0; +// GridBagConstraints gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 15, 3, 0); // top left bottom right +// gbc.gridx = gridx; +// gbc.gridy = 0; +// jPanelIdentifierManager.add(new JLabel("Provider"), gbc); + +// gridx++; +// gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 5, 3, 4); +// gbc.gridx = gridx; +// gbc.gridy = 0; +// jPanelIdentifierManager.add(getJComboBoxURI(), gbc); + +// gridx++; +// gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 5, 3, 5); +// gbc.gridx = gridx; +// gbc.gridy = 0; +// jPanelIdentifierManager.add(getJButtonAddRef(), gbc); + +// gbc = new GridBagConstraints(); +// gbc.insets = new Insets(3, 0, 3, 0); +// gbc.gridx = gridx; +// gbc.gridy = 0; +// gbc.fill = GridBagConstraints.HORIZONTAL; +// gbc.weightx = 1.0; +// jPanelIdentifierManager.add(new JLabel(""), gbc); +// +// getJButtonAddRef().addActionListener(eventHandler); + } + return jPanelIdentifierManager; + } + private JPanel getJPanelLowerLeft() { + if (jPanelLowerLeft == null) { + jPanelLowerLeft = new JPanel(); + jPanelLowerLeft.setLayout(new GridBagLayout()); + jPanelLowerLeft.setPreferredSize(new Dimension(300, 37)); + jPanelLowerLeft.setBorder(BorderFactory.createLineBorder(SystemColor.windowBorder, 1)); + + int gridx = 0; + GridBagConstraints gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 3, 3, 3); + gbc.gridx = gridx; + gbc.gridy = 0; + jPanelLowerLeft.add(getJButtonDeleteRef(), gbc); + + gridx++; + gbc = new GridBagConstraints(); + gbc.insets = new Insets(3, 0, 3, 0); + gbc.gridx = gridx; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + gbc.weightx = 1.0; + jPanelLowerLeft.add(new JLabel(""), gbc); + + getJButtonDeleteRef().setEnabled(false); + getJButtonDeleteRef().addActionListener(eventHandler); + } + return jPanelLowerLeft; + } + + public JComboBox getJComboBoxQualifier() { + if (jComboBoxQualifier == null) { + jComboBoxQualifier = new JComboBox(); +// defaultComboBoxModelQualifier = new DefaultComboBoxModel(); // already allocated + jComboBoxQualifier.setModel(defaultComboBoxModelQualifier); + Dimension d = jComboBoxQualifier.getPreferredSize(); + jComboBoxQualifier.setMinimumSize(new Dimension(COMBO_QUALIFIER_WIDTH, d.height)); + jComboBoxQualifier.setPreferredSize(new Dimension(COMBO_QUALIFIER_WIDTH, d.height)); + ComboboxToolTipRenderer renderer = new ComboboxToolTipRenderer(); + jComboBoxQualifier.setRenderer(renderer); + } + return jComboBoxQualifier; + } + private JTextField getJTextFieldFormalID() { + if (jTextFieldFormalID == null) { + jTextFieldFormalID = new JTextField(); + jTextFieldFormalID.setText("NewID"); + Dimension d = jTextFieldFormalID.getPreferredSize(); + jTextFieldFormalID.setMinimumSize(new Dimension(100, d.height)); + jTextFieldFormalID.setPreferredSize(new Dimension(100, d.height)); + } + return jTextFieldFormalID; + } + + @SuppressWarnings({ "rawtypes", "unchecked" }) + public JComboBox getJComboBoxURI() { + if (jComboBoxURI == null) { + jComboBoxURI = new JComboBox(); + defaultComboBoxModelURI = new DefaultComboBoxModel(); + jComboBoxURI.setModel(defaultComboBoxModelURI); + Dimension d = jComboBoxURI.getPreferredSize(); + jComboBoxURI.setMinimumSize(new Dimension(MAX_URI_LENGTH, d.height)); + jComboBoxURI.setPreferredSize(new Dimension(MAX_URI_LENGTH, d.height)); + ComboboxToolTipRenderer renderer = new ComboboxToolTipRenderer(); + jComboBoxURI.setRenderer(renderer); +// jComboBoxURI.setRenderer(new DefaultListCellRenderer() { +// public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { +// if(value == null) { +// return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); +// } else { +// DataType dt = (DataType)value; +// Component comp = super.getListCellRendererComponent(list,dt.getDataTypeName(),index,isSelected,cellHasFocus); +// return comp; +// } +// } +// }); + } + return jComboBoxURI; + } + + private JPanel getBottomPanel() { + if (jBottomPanel == null) { + jBottomPanel = new JPanel(); + jBottomPanel.setLayout(new BorderLayout()); + jBottomPanel.add(getSplitPane(), BorderLayout.CENTER); + } + return jBottomPanel; + + } + private JSplitPane getSplitPane() { + if (splitPane == null) { + + JPanel leftPanel = new JPanel(); + leftPanel.setLayout(new GridBagLayout()); + leftPanel.setBackground(Color.white); + + int gridy = 0; + GridBagConstraints gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.weighty = 0; + gbc.insets = new Insets(3, 3, 1, 3); + gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.NORTHWEST; + leftPanel.add(getJPanelLeftTitle(), gbc); + +// gridy++; +// gbc = new java.awt.GridBagConstraints(); +// gbc.gridx = 0; +// gbc.gridy = gridy; +// gbc.weightx = 1.0; +// gbc.weighty = 0; +// gbc.insets = new Insets(2, 3, 1, 3); +// gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; +// gbc.anchor = GridBagConstraints.NORTHWEST; +// leftPanel.add(getJPanelIdentifierManager(), gbc); + + gridy++; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(2, 3, 1, 3); + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.SOUTHWEST; + leftPanel.add(getJScrollPane(), gbc); + + gridy++; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.weighty = 0; + gbc.insets = new Insets(2, 3, 3, 3); + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.SOUTHWEST; + leftPanel.add(getJPanelLowerLeft(), gbc); + // ----------------------------------------------------------------------- + + JPanel rightPanel = new JPanel(); + rightPanel.setLayout(new GridBagLayout()); + rightPanel.setBackground(Color.white); + + gridy = 0; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.insets = new Insets(3, 3, 2, 2); + gbc.fill = java.awt.GridBagConstraints.HORIZONTAL; + gbc.anchor = GridBagConstraints.NORTHWEST; + rightPanel.add(getJPanelRightTitle(), gbc); + + annotationTextArea = new JTextArea(); +// annotationTextArea.setContentType("text/html"); + annotationTextArea.setEditable(false); + annotationTextArea.addFocusListener(eventHandler); + annotationTextArea.addMouseListener(eventHandler); + annotationTextArea.setLineWrap(true); + annotationTextArea.setWrapStyleWord(true); + annotationTextArea.setCaretPosition(0); + JScrollPane annotationPanel = new JScrollPane(annotationTextArea); + + gridy++; + gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(1, 3, 1, 2); + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.NORTHWEST; + rightPanel.add(annotationPanel, gbc); + // ---------------------------------------------------------------------------------- + + splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); + splitPane.setOneTouchExpandable(true); + splitPane.setLeftComponent(leftPanel); + splitPane.setRightComponent(rightPanel); + splitPane.setResizeWeight(0.1); + splitPane.setDividerLocation(0.3); + + annotationTextArea.addKeyListener(eventHandler); + } + return splitPane; + } + + private JScrollPane getJScrollPane() { + if (jScrollPane == null) { + jScrollPane = new JScrollPane(); + jScrollPane.setViewportView(getJTreeMIRIAM()); + } + return jScrollPane; + } + private JTree getJTreeMIRIAM() { + if (jTreeMIRIAM == null) { + try { + DefaultTreeSelectionModel ivjLocalSelectionModel; + ivjLocalSelectionModel = new DefaultTreeSelectionModel(); + ivjLocalSelectionModel.setSelectionMode(1); + jTreeMIRIAM = new JTree(); + jTreeMIRIAM.setName("JTree1"); + jTreeMIRIAM.setToolTipText(""); + jTreeMIRIAM.setBounds(0, 0, 357, 405); + jTreeMIRIAM.setMinimumSize(new java.awt.Dimension(100, 72)); + jTreeMIRIAM.setSelectionModel(ivjLocalSelectionModel); + jTreeMIRIAM.setRowHeight(0); + jTreeMIRIAM.setRootVisible(false); + + // Add cellRenderer + DefaultTreeCellRenderer dtcr = new BioModelCellRenderer(null) { + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, boolean sel, boolean expanded, boolean leaf, int row, boolean hasFocus) { + // default for LinkNode is in BioModelCellRenderer.java + JLabel component = (JLabel)super.getTreeCellRendererComponent(tree, value, sel, expanded, leaf, row, hasFocus); + // TODO: here + component.setIcon(null); + return component; + } + }; + jTreeMIRIAM.setCellRenderer(dtcr); + + MouseListener mouseListener = new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + super.mouseClicked(e); +// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); +// showPopup(e, closestMousePath); + } + + @Override + public void mouseReleased(MouseEvent e) { + super.mouseReleased(e); +// TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); +// showPopup(e,closestMousePath); + } + + public void mousePressed(MouseEvent e) { + TreePath closestMousePath =jTreeMIRIAM.getClosestPathForLocation(e.getPoint().x, e.getPoint().y); + jTreeMIRIAM.setSelectionPath(closestMousePath); +// showPopup(e,closestMousePath); + if(e.getClickCount() == 2) { + DefaultMutableTreeNode node = (DefaultMutableTreeNode)jTreeMIRIAM.getLastSelectedPathComponent(); + if (node instanceof LinkNode) { + showBrowseToLink((LinkNode)node); + } + } + } + }; + jTreeMIRIAM.addMouseListener(mouseListener); + + } catch (java.lang.Throwable ivjExc) { + ivjExc.printStackTrace(System.out); + } + } + return jTreeMIRIAM; + } + private void showBrowseToLink(LinkNode linkNode) { + String link = linkNode.getLink(); + if (link != null) { + DialogUtils.browserLauncher(jTreeMIRIAM, link, "failed to launch"); + }else{ + DialogUtils.showWarningDialog(this, "No Web-site link available"); + } + } + private void showBrowseToLink(VCMetaDataDataType md) { + String link = md.getDataTypeURL(); + if (link != null) { + DialogUtils.browserLauncher(getJComboBoxURI(), link, "Failed to launch"); + } else { + DialogUtils.showWarningDialog(this, "No Web-site link available"); + } + } + + private void initialize() { + try { + setLayout(new GridBagLayout()); + setBackground(Color.white); + + int gridy = 0; + GridBagConstraints gbc = new java.awt.GridBagConstraints(); + gbc.gridx = 0; + gbc.gridy = gridy; + gbc.weightx = 1.0; + gbc.weighty = 1.0; + gbc.insets = new Insets(4, 4, 4, 4); + gbc.fill = java.awt.GridBagConstraints.BOTH; + gbc.anchor = GridBagConstraints.SOUTHWEST; + add(getBottomPanel(), gbc); + + JTextPane tenpTextPane = new JTextPane(); // used just to initialize emptyText once + tenpTextPane.setContentType("text/html"); + tenpTextPane.setText(null); + emptyHtmlText = tenpTextPane.getText(); + + initializeComboBoxQualifier(); + initializeComboBoxURI(); + + getJTreeMIRIAM().addTreeSelectionListener(new TreeSelectionListener() { + public void valueChanged(TreeSelectionEvent e) { + TreePath tp = ((JTree)e.getSource()).getSelectionPath(); + if(tp == null) { + getJButtonDeleteRef().setEnabled(false); + } else { + Object lastPathComponent = tp.getLastPathComponent(); + getJButtonDeleteRef().setEnabled(tp != null && lastPathComponent instanceof LinkNode); + } + } + }); + + } catch (java.lang.Throwable ivjExc) { + handleException(ivjExc); + } + } + + public void addToAnnotationTextArea(String annotDescription) { +// annotationTextArea.setText("Text can be set from addToAnnotation method"); + String existingTest = annotationTextArea.getText(); + if (annotationTextArea.getText().length() != 0) { + annotationTextArea.setText(existingTest + "\n" + annotDescription); + } else { + annotationTextArea.setText(annotDescription); + } + +// String existingText = ""; +// if (annotationTextArea != null || annotationTextArea.getText().length() != 0) { +// existingText = annotationTextArea.getText(); +// } +// annotationTextArea.setText("\n" + existingText + annotDescription); + changeTextAnnotation(); + } + + private void changeTextAnnotation() { + try{ + if (bioModel == null || selectedObject == null) { + return; + } + Identifiable entity = getIdentifiable(selectedObject); + String textAreaStr = (annotationTextArea.getText() == null || annotationTextArea.getText().length()==0?null:annotationTextArea.getText()); + String oldText = bioModel.getVCMetaData().getFreeTextAnnotation(entity); + + if(textAreaStr == null || textAreaStr.isEmpty() || emptyHtmlText.equals(textAreaStr)) { // no annotation now, the field is empty + bioModel.getVCMetaData().deleteFreeTextAnnotation(entity); // delete, if there's something previously saved + if(selectedObject instanceof ReactionStep) { + // we tell ReactionPropertiesPanel to refresh the annotation icon + ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); + } + } else if(!Compare.isEqualOrNull(oldText,textAreaStr)) { // some text annotation different from what's already saved + bioModel.getVCMetaData().setFreeTextAnnotation(entity, textAreaStr); // overwrite + if(selectedObject instanceof ReactionStep) { + // we tell ReactionPropertiesPanel to refresh the text annotation icon + ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); + } + } + } catch(Exception e) { + e.printStackTrace(System.out); + PopupGenerator.showErrorDialog(this,"Annotation Error\n"+e.getMessage(), e); + } + } + private void removeText() { + if (bioModel == null || selectedObject == null) { + return; + } + Identifiable entity = getIdentifiable(selectedObject); + annotationTextArea.setText(null); + bioModel.getVCMetaData().deleteFreeTextAnnotation(entity); // delete, if there's something previously saved + if(selectedObject instanceof ReactionStep) { + ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); + } + } + + public void setBioModel(BioModel newValue) { + if (newValue == bioModel) { + return; + } + bioModel = newValue; + vcMetaData = bioModel.getVCMetaData(); + + // set tree model on jTableMIRIAM here, since we have access to miriamDescrHeir here + miriamTreeModel = new MiriamTreeModel(new DefaultMutableTreeNode("Object Annotations",true), vcMetaData, false); + jTreeMIRIAM.setModel(miriamTreeModel); + + initializeComboBoxURI(); + getJTextFieldFormalID().setText("NewID"); + updateInterface(); + } + + private void updateInterface() { + if (bioModel == null) { + return; + } + Identifiable entity = getIdentifiable(selectedObject); + if(selectedObject != null && entity != null) { + getJComboBoxURI().setEnabled(true); + getJTextFieldFormalID().setEnabled(true); + getJButtonAddRef().setEnabled(true); + getJButtonRemoveText().setEnabled(true); + VCMetaDataDataType mdt = (VCMetaDataDataType)getJComboBoxURI().getSelectedItem(); + miriamTreeModel.createTree(entity); + + String freeText = bioModel.getVCMetaData().getFreeTextAnnotation(entity); + if(freeText == null || freeText.isEmpty()) { + annotationTextArea.setText(null); + } else { + annotationTextArea.setText(freeText); + } + annotationTextArea.setEditable(true); + annotationTextArea.setCaretPosition(0); + } else { + getJComboBoxURI().setEnabled(false); + getJTextFieldFormalID().setEnabled(false); + getJButtonAddRef().setEnabled(false); + getJButtonRemoveText().setEnabled(false); + miriamTreeModel.createTree(null); + + annotationTextArea.setText(null); + annotationTextArea.setEditable(false); + } + } + public static Identifiable getIdentifiable(Identifiable selectedObject) { + // + // for SpeciesContext objects: + // MIRIAM tree needs the Species !!! + // text Annotation needs the SpeciesContext + // + // !!! use this only for the tree !!! + // + if(selectedObject == null) { + return null; + } + if(selectedObject instanceof SpeciesContext) { + return (Species)((SpeciesContext)selectedObject).getSpecies(); + } else if(selectedObject instanceof MolecularType) { + return (MolecularType)selectedObject; + } else if(selectedObject instanceof ReactionRule) { + return (ReactionRule)selectedObject; + } else if(selectedObject instanceof ReactionStep) { + return (ReactionStep)selectedObject; + } else if(selectedObject instanceof RbmObservable) { + return (RbmObservable)selectedObject; + } else if(selectedObject instanceof BioModel) { + return (BioModel)selectedObject; + } else if(selectedObject instanceof Structure) { + return (Structure)selectedObject; + } else if(selectedObject instanceof BioPaxObject) { + return null; + } else if(selectedObject instanceof Model.ModelParameter) { + return (Model.ModelParameter)selectedObject; + } else if(selectedObject instanceof SimulationContext) { + return (SimulationContext)selectedObject; +// } else if(selectedObject instanceof Simulation) { +// return (Simulation)selectedObject; +// } else if(selectedObject instanceof SpeciesContextSpec) { +// return (SpeciesContextSpec)selectedObject; +// } else if(selectedObject instanceof ReactionSpec) { +// return (ReactionSpec)selectedObject; + } else { + return null; + } + } + + @Override + protected void onSelectedObjectsChange(Object[] selectedObjects) { + if (selectedObjects != null && selectedObjects.length == 1) { + if(selectedObjects[0] instanceof BioModelInfo || selectedObjects[0] instanceof MathModelInfo) { + return; + } + if(selectedObjects[0] instanceof Identifiable && selectedObjects[0] instanceof Displayable) { + selectedObject = (Identifiable)selectedObjects[0]; + System.out.println("AnnotationsPanel: class: " + selectedObject.getClass().getSimpleName() + ", selected object: " + ((Displayable)selectedObject).getDisplayName()); + } else { + selectedObject = null; + System.out.println("Unsupported or null entity"); + } + initializeComboBoxURI(); // if selectedObject or entity are null we just empty the combobox + getJButtonDeleteRef().setEnabled(false); + getJTextFieldFormalID().setText("NewID"); + updateInterface(); + } + } + + // ------------------------------------------------------------------------------------------------------- + private void initializeAddAnnotationsPanel() { + //generate addAnnotationPanel with URI and Qualifier ComboBox + if (addAnnotationsPanel == null) { + addAnnotationsPanel = new AddAnnotationsPanel(this, getJComboBoxURI(), getJComboBoxQualifier()); + } + else { + addAnnotationsPanel.dispose(); + addAnnotationsPanel = new AddAnnotationsPanel(this, getJComboBoxURI(), getJComboBoxQualifier()); + } + } + + protected void addIdentifier(SearchElement searchElement) { +// if(PopupGenerator.showComponentOKCancelDialog(AnnotationsPanel.this, getJPanelNewIdentifier(), "Define New Formal Identifier") != JOptionPane.OK_OPTION) { +// return; +// } +///////////////////////////////////////////////////////////////////////////////////////////////////// + MIRIAMQualifier qualifier = (MIRIAMQualifier)getJComboBoxQualifier().getSelectedItem(); + + MiriamManager.DataType objectNamespace = (MiriamManager.DataType)getJComboBoxURI().getSelectedItem(); + +// String objectID = getJTextFieldFormalID().getText(); + String objectID = getId(searchElement.getDbLink(), objectNamespace.getDataTypeName()); +// if(objectID.compareTo("NewID") == 0) { +// return; +// } + MiriamManager miriamManager = vcMetaData.getMiriamManager(); + HashSet miriamResources = new HashSet<>(); + try { + Identifiable entity = getIdentifiable(selectedObject); + MiriamResource mr = miriamManager.createMiriamResource(objectNamespace.getBaseURN()+":"+objectID); + miriamResources.add(mr); + miriamManager.addMiriamRefGroup(entity, qualifier, miriamResources); +// System.out.println(vcMetaData.printRdfStatements()); + updateInterface(); + if(selectedObject instanceof ReactionStep) { + // we tell ReactionPropertiesPanel to refresh the annotation icon + ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", false, true); + } + } catch (Exception e) { + e.printStackTrace(); + DialogUtils.showErrorDialog(this,"Add Identifier failed:\n"+e.getMessage(), e); + } + } + private String getId(URI uri, String dataTypeName) { + String id = "Wrong ID"; + + if (uri.toString().contains("BTO")) + id = uri.getPath().replace("/obo/BTO_",""); + else if (uri.toString().contains("CHEBI")) + id = uri.getPath().replace("/obo/CHEBI_",""); + else if (uri.toString().contains("CL")) + id = uri.getPath().replace("/obo/CL_",""); + else if (uri.toString().contains("EFO")) + id = uri.getPath().replace("/efo/EFO_",""); + else if (uri.toString().contains("GO")) + id = uri.getPath().replace("/obo/GO_",""); + else if (uri.toString().contains("ncit")) + id = uri.toString().replace("https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&ns=ncit&code=",""); + else if (uri.toString().contains("PATO")) + id = uri.getPath().replace("/obo/PATO_",""); + else if (uri.toString().contains("PR")) + id = uri.getPath().replace("/obo/PR_",""); + + return id; + } + private void removeIdentifier() { + Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent(); + if (treeNode instanceof LinkNode) { + LinkNode linkNode = (LinkNode)treeNode; + MiriamResource resourceToDelete = linkNode.getMiriamResource(); + Identifiable entity = getIdentifiable(selectedObject); + //Map refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(entity); + MiriamManager mm = vcMetaData.getMiriamManager(); + Map refGroupsToRemove = mm.getMiriamTreeMap().get(entity); + + boolean found = false; + for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()){ + MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup); + for (MiriamResource miriamResource : refGroup.getMiriamRefs()) { + + if(!isEqual(miriamResource, resourceToDelete)) { + continue; + } + try { + mm.remove2(entity, qualifier, refGroup); // remove the ref group for this resource + System.out.println(vcMetaData.printRdfStatements()); + + found = true; + break; + } catch (URNParseFailureException e) { + e.printStackTrace(System.out); + } + } + if(found == true) { + updateInterface(); + if(selectedObject instanceof ReactionStep) { + ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", true, false); + } + break; + } + } + } + } + + private boolean isEqual(MiriamResource aThis, MiriamResource aThat) { + if (aThis == aThat) { + return true; + } + if (!(aThis instanceof MiriamResource)) { + return false; + } + if (!(aThat instanceof MiriamResource)) { + return false; + } + MiriamResource athis = (MiriamResource)aThis; + MiriamResource athat = (MiriamResource)aThat; + + if (athis.getDataType() != null && athat.getDataType() != null && !athis.getDataType().equals(athat.getDataType())) { + return false; + } + if (!Compare.isEqual(athis.getMiriamURN(), athat.getMiriamURN())) { + return false; + } + if (!Compare.isEqual(athis.getIdentifier(), athat.getIdentifier())) { + return false; + } + return true; + } + + @SuppressWarnings("unchecked") + private void initializeComboBoxURI() { + jComboBoxURI = getJComboBoxURI(); + Identifiable entity = getIdentifiable(selectedObject); + defaultComboBoxModelURI.removeAllElements(); + List tooltips = new ArrayList<> (); + List dataTypeList = new ArrayList<>(); + if(entity == null) { + for (DataType dt : vcMetaData.getMiriamManager().getAllDataTypes().values()) { + dataTypeList.add(dt); + } + } else { + for (DataType dt : VCMetaDataMiriamManager.getSpecificDataTypes(entity)) { + dataTypeList.add(dt); + } + } + Collections.sort(dataTypeList); + for(DataType dt : dataTypeList) { + tooltips.add(dt.getDescription()); + defaultComboBoxModelURI.addElement(dt); + } + ((ComboboxToolTipRenderer)getJComboBoxURI().getRenderer()).setTooltips(tooltips); + } + private void initializeComboBoxQualifier() { + //Set MIRIAM_all; + //AnnotationQualifiers.MIRIAM_all; + List qualifierList = new ArrayList<>(); + for(MIRIAMQualifier qualifier : AnnotationQualifiers.MIRIAM_all) { + qualifierList.add(qualifier); + } + Collections.sort(qualifierList); + for(MIRIAMQualifier qualifier : qualifierList) { + defaultComboBoxModelQualifier.addElement(qualifier); + } + } + + private JButton getJButtonAddRef() { + if (jButtonAddRef == null) { + jButtonAddRef = new JButton(); + jButtonAddRef.setText(ACTION_ADD); + jButtonAddRef.setToolTipText("Add a new reference with this provider"); + } + return jButtonAddRef; + } + private JButton getJButtonDeleteRef() { + if (jButtonDeleteRef == null) { + jButtonDeleteRef = new JButton(); + jButtonDeleteRef.setText(ACTION_DELETE); + jButtonDeleteRef.setToolTipText("Delete the selected cross-reference"); + + } + return jButtonDeleteRef; + } + private JButton getJButtonRemoveText() { + if (jButtonRemoveText == null) { + jButtonRemoveText = new JButton(); + jButtonRemoveText.setText(ACTION_REMOVE_TEXT); + jButtonRemoveText.setToolTipText("Remove the entire text annotation"); + } + return jButtonRemoveText; + } + /* + +Universal (goes in all types of annotations): +PubMed ID https://www.ncbi.nlm.nih.gov/pubmed +DOI: https://www.doi.org/ + +Model +BioModels Database https://www.ebi.ac.uk/biomodels/ +Reactome: https://reactome.org/ +Grey: NeuronDB: https://senselab.med.yale.edu/neurondb/ +Grey: https://senselab.med.yale.edu/modeldb/ +Grey: CellML Model Repository: https://models.cellml.org/cellml + +Species/Molecules/Observables: +CheBI: https://www.ebi.ac.uk/chebi/ +Kegg Compound: https://www.genome.jp/kegg/compound/ +Uniprot: https://www.uniprot.org/ +Enzyme Nomenclature: http://www.sbcs.qmul.ac.uk/iubmb/enzyme/ +Gene Ontology: http://www.geneontology.org/ +Reactome: https://reactome.org/ + +Reactions +Kegg Reaction: https://www.genome.jp/kegg/reaction/ +Kegg Pathway: https://www.genome.jp/kegg/pathway.html +Reactome: https://reactome.org/ +Grey: BRENDA: https://www.brenda-enzymes.org/ +Grey: BIND https://www.bindingdb.org/bind/index.jsp + +Parameters (all grey for now) +Grey:BIND https://www.bindingdb.org/bind/index.jsp + +Structures +Grey: BRENDA: https://www.brenda-enzymes.org/ +Grey: Gene Ontology http://geneontology.org/ + + +DataType DataType_PIR "PIRSF" +DataType DataType_DOI "DOI" +DataType DataType_BIOMODELS "BioModels Database" +DataType DataType_Chebi "ChEBI" +DataType DataType_IntAct "IntAct" +DataType DataType_InterPro "InterPro" +DataType DataType_ECCODE "Enzyme Nomenclature" +DataType DataType_ENSEMBLE "Ensembl" +DataType DataType_GO "Gene Ontology" +DataType DataType_KEGGCOMPOUND "KEGG Compound" +DataType DataType_KEGGPATHWAY "KEGG Pathway" +DataType DataType_KEGGREACTION "KEGG Reaction" +DataType DataType_PUBMED "PubMed" +DataType DataType_TAXONOMY "Taxonomy" +DataType DataType_REACTOME "Reactome" +DataType DataType_UNIPROT "UniProt" +DataType DataType_ICD "ICD" + + + + +*/ + + + + + +} diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/BioPortalSearch.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/BioPortalSearch.java new file mode 100644 index 0000000000..4149b79434 --- /dev/null +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/BioPortalSearch.java @@ -0,0 +1,182 @@ +package cbit.vcell.client.desktop.biomodel.annotations; + +import org.xml.sax.Attributes; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.helpers.DefaultHandler; + +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import java.io.*; +import java.net.HttpURLConnection; +import java.net.URISyntaxException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +public class BioPortalSearch { + // base URL for class search + private final String REST_URL = "http://data.bioontology.org/search?q="; + private final String API_KEY = "d77db9ae-3fb4-4cc9-b95a-5ea18b1bfda4"; + private String format; + private final List SearchElements = new ArrayList<>(); + + public List search(String searchTerm) throws IOException, URISyntaxException, ParserConfigurationException, InterruptedException, SAXException { + return search(searchTerm, 5000, "", false); + } + + public List search(String searchTerm, int pageSize, String ontologyNicknames, boolean requireExactMatch) throws IOException, SAXException, URISyntaxException, ParserConfigurationException, InterruptedException { + //Advanced Search Attributes + String includeAttr = "prefLabel,synonym,definition"; //,notation,cui,semanticType,properties + format = "xml"; +// String pageSize = "500"; //max page size +// boolean requireExactMatch = false; + + // GET request returns xml string for processing +// HttpResponse response = get(REST_URL + + String response = get(REST_URL + + searchTerm + + "&include=" + includeAttr + + "&pagesize=" + pageSize + + "&display_context=false" + + "&display_links=false" + + "&ontologies=" + ontologyNicknames + + "&require_exact_match=" + requireExactMatch + ); +// System.out.println("Status Code: " + response.statusCode()); +// System.out.println("Response Body:\n" + response.body()); + System.out.println(); + + SAXParserFactory fact = SAXParserFactory.newInstance(); + SAXParser saxParser = fact.newSAXParser(); + + //List to hold all search results + + +// boolean collectionEnds = false; + DefaultHandler handle = new DefaultHandler() { + boolean bTotalCount=false, bPrefLabel=false, bSynonym=false, bDefinition=false, bId=false, collectionEnds=false; + String prefLabel, definition, id; + final ArrayList synonyms = new ArrayList<>(); + @Override + public void startElement(String uri, String localName, String qName, Attributes attributes) { + //System.out.println("Start Element: " + qName); + switch (qName) { + case "totalCount": + bTotalCount = true; + break; + case "class": + prefLabel = ""; + synonyms.clear(); + definition = ""; + id = ""; + break; + case "prefLabel": + bPrefLabel = true; + break; + case "synonym": + bSynonym = true; + break; + case "definition": + bDefinition = true; + break; + case "id": + bId = true; + break; + } + } + + @Override + public void endElement(String uri, String localName, String qName) { + //System.out.println("End Element: " + qName); + if (qName.equals("collection")) collectionEnds = true; +// if (searchElements.size()-1 < noOfElements) { +// if (qName.equals("class")) { + if (qName.equals("class") && !collectionEnds) { + SearchElements.add(new SearchElement(prefLabel, synonyms, definition, id)); +// } + } + + } + + @Override + public void characters(char[] ch, int start, int length) { +// if (bTotalCount) { +// noOfElements = Integer.parseInt(new String(ch,start,length)); +// System.out.println("totalCount: " + noOfElements +"\n"); +// bTotalCount = false; +// } + if (bPrefLabel) { + prefLabel = new String(ch,start,length); + //System.out.println("prefLabel: " + prefLabel); + bPrefLabel = false; + } + if (bSynonym) { + String synonym = new String(ch,start,length); + synonyms.add(synonym); + //System.out.println("synonym: " + synonym); + bSynonym = false; + } + if (bDefinition) { + definition = new String(ch,start,length); + //System.out.println("definition: " + definition); + bDefinition = false; + } + if (bId) { + id = new String(ch,start,length); + //System.out.println("id: " + id); + bId = false; + //System.out.println(); + } + + } + }; + + saxParser.parse(new InputSource(new StringReader(response)), handle); + for (SearchElement element: SearchElements) { + System.out.println(element.toString()); + } + return SearchElements; + } + + // private HttpResponse get(String urlToGet) throws URISyntaxException, IOException, InterruptedException { + private String get(String urlToGet) throws IOException { + //build request + URL url; + HttpURLConnection conn; + BufferedReader rd; + String line; + StringBuilder result = new StringBuilder(); + + url = new URL(urlToGet); + conn = (HttpURLConnection) url.openConnection(); + conn.setRequestMethod("GET"); + conn.setRequestProperty("Authorization", "apikey token=" + API_KEY); + conn.setRequestProperty("Accept", "application/" + format); + System.out.println("Status Code: " + conn.getResponseCode()); + + rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + while ((line = rd.readLine()) != null) { + result.append(line); + } + rd.close(); + + return result.toString(); + ///////////////////////////////////////////////////////////////////////////////////// +// HttpRequest GET_Request = HttpRequest.newBuilder() +// .uri(new URI(urlToGet)) +// .header("Authorization", "apikey token=" + API_KEY) +// .header("Accept", "application/" + format) +// .GET() +// .build(); +// System.out.println("GET Request Built: " + GET_Request); +// +// //instantiate client to send request +// HttpClient httpClient = HttpClient.newHttpClient(); +// +// //use client to send request and store response +// return httpClient.send(GET_Request, HttpResponse.BodyHandlers.ofString()); + } +} + diff --git a/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/SearchElement.java b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/SearchElement.java new file mode 100644 index 0000000000..40d54a7d1d --- /dev/null +++ b/vcell-client/src/main/java/cbit/vcell/client/desktop/biomodel/annotations/SearchElement.java @@ -0,0 +1,53 @@ +package cbit.vcell.client.desktop.biomodel.annotations; + + +import java.net.URI; +import java.util.ArrayList; +import java.util.List; + +public class SearchElement { + private final String entityName; + private final List synonyms; + private final String definition; + private final URI dbLink; + + public SearchElement(String entityName, List synonyms, String definition, String dbLink) { + this.entityName = entityName; + this.synonyms = new ArrayList<>(synonyms); + this.definition = definition; + + if (dbLink.contains("http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#")) { + String newDbLink = dbLink.replace("http://ncicb.nci.nih.gov/xml/owl/EVS/Thesaurus.owl#", + "https://ncit.nci.nih.gov/ncitbrowser/ConceptReport.jsp?dictionary=NCI_Thesaurus&ns=ncit&code="); + this.dbLink = URI.create(newDbLink); + } else { + this.dbLink = URI.create(dbLink); + } + + } + + public String getEntityName() { + return entityName; + } + + public List getSynonyms() { + return synonyms; + } + + public String getDefinition() { + return definition; + } + + public URI getDbLink() { + return dbLink; + } + + @Override + public String toString() { + return "Name: " + entityName + + "\nSynonyms: " + synonyms.toString() + + "\nDefinition: " + definition + + "\nLink: " + dbLink; + } +} + diff --git a/vcell-client/src/main/java/cbit/vcell/graph/gui/ReactionCartoonTool.java b/vcell-client/src/main/java/cbit/vcell/graph/gui/ReactionCartoonTool.java index d315ad8822..cf7895037f 100644 --- a/vcell-client/src/main/java/cbit/vcell/graph/gui/ReactionCartoonTool.java +++ b/vcell-client/src/main/java/cbit/vcell/graph/gui/ReactionCartoonTool.java @@ -33,7 +33,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; @@ -46,13 +45,11 @@ import javax.swing.AbstractAction; import javax.swing.ActionMap; import javax.swing.DefaultComboBoxModel; -import javax.swing.DefaultListCellRenderer; import javax.swing.InputMap; import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JFileChooser; import javax.swing.JLabel; -import javax.swing.JList; import javax.swing.JMenuItem; import javax.swing.JOptionPane; import javax.swing.JPanel; @@ -66,7 +63,6 @@ import org.vcell.model.rbm.MolecularType; import org.vcell.model.rbm.MolecularTypePattern; import org.vcell.model.rbm.SpeciesPattern; -import org.vcell.sybil.models.miriam.MIRIAMQualifier; import org.vcell.util.BeanUtils; import org.vcell.util.Compare; import org.vcell.util.Matchable; @@ -98,16 +94,12 @@ import cbit.gui.graph.visualstate.VisualState.PaintLayer; import cbit.vcell.biomodel.BioModel; import cbit.vcell.biomodel.meta.VCMetaData; -import cbit.vcell.biomodel.meta.MiriamManager.DataType; -import cbit.vcell.biomodel.meta.VCMetaDataMiriamManager.VCMetaDataDataType; import cbit.vcell.client.BioModelWindowManager; import cbit.vcell.client.ChildWindowManager; import cbit.vcell.client.PopupGenerator; import cbit.vcell.client.ChildWindowManager.ChildWindow; import cbit.vcell.client.desktop.DocumentWindow; -import cbit.vcell.client.desktop.biomodel.AnnotationsPanel; import cbit.vcell.client.desktop.biomodel.BioModelEditor; -import cbit.vcell.client.desktop.biomodel.AnnotationsPanel.ComboboxToolTipRenderer; import cbit.vcell.client.server.ClientServerManager; import cbit.vcell.client.server.UserPreferences; import cbit.vcell.desktop.VCellTransferable; diff --git a/vcell-core/src/main/java/cbit/vcell/biomodel/meta/VCMetaDataMiriamManager.java b/vcell-core/src/main/java/cbit/vcell/biomodel/meta/VCMetaDataMiriamManager.java index fb3399c4d9..c331af3f2d 100644 --- a/vcell-core/src/main/java/cbit/vcell/biomodel/meta/VCMetaDataMiriamManager.java +++ b/vcell-core/src/main/java/cbit/vcell/biomodel/meta/VCMetaDataMiriamManager.java @@ -83,16 +83,15 @@ public static class VCMetaDataDataType implements DataType { "urn:miriam:doi", "The Digital Object Identifier System is for identifying content objects in the digital environment.", "10.1038/nbt1156"); - public final static DataType DataType_BIOMODELS = new VCMetaDataDataType("BioModels Database", + public final static DataType DataType_BIOMODELS = new VCMetaDataDataType("BIOMODELS", "http://www.ebi.ac.uk/biomodels/", biomodelsDbWebAccessBaseURL, // ^((BIOMD|MODEL)\d{10})|(BMID\d{12})$ "urn:miriam:biomodels.db", "BioModels Database is a data resource that allows biologists to store, search and retrieve published mathematical models of biological interests.", "BIOMD0000000048"); - public final static DataType DataType_Chebi = new VCMetaDataDataType("ChEBI", + public final static DataType DataType_Chebi = new VCMetaDataDataType("CHEBI", "http://www.ebi.ac.uk/chebi/", -// "http://www.ebi.ac.uk/chebi/searchFreeText.do?searchString=", // old - "https://www.ebi.ac.uk/ols/ontologies/chebi/terms?obo_id=", // ^CHEBI:\d+$ + "https://www.ebi.ac.uk/ols/ontologies/chebi/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FCHEBI_", // ^CHEBI:\d+$ "urn:miriam:chebi", "Chemical Entities of Biological Interest (ChEBI) is a freely available dictionary of molecular entities focused on 'small' chemical compounds.", "CHEBI:36927"); // CHEBI:36927 @@ -121,10 +120,9 @@ public static class VCMetaDataDataType implements DataType { "urn:miriam:ensembl", "Ensembl is a joint project between EMBL - EBI and the Sanger Institute to develop a software system which produces and maintains automatic annotation on selected eukaryotic genomes.", "ENSG00000139618"); - public final static DataType DataType_GO = new VCMetaDataDataType("Gene Ontology", + public final static DataType DataType_GO = new VCMetaDataDataType("GO", "http://www.geneontology.org/", - //"http://www.ebi.ac.uk/ego/GTerm?id=", // old - "https://www.ebi.ac.uk/ols/ontologies/go/terms?obo_id=", // ^GO:\d{7}$ + "https://www.ebi.ac.uk/ols/ontologies/go/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FGO_", // ^GO:\d{7}$ "urn:miriam:obo.go", "The Gene Ontology project provides a controlled vocabulary to describe gene and gene product attributes in any organism.", "GO:0006915"); // GO:0006915 @@ -216,7 +214,7 @@ public static class VCMetaDataDataType implements DataType { // "urn:miriam:", // "BindingDB Description", // null); - public final static DataType DataType_Mamo = new VCMetaDataDataType("Mamo", + public final static DataType DataType_Mamo = new VCMetaDataDataType("MAMO", "http://bioportal.bioontology.org/ontologies/MAMO/", "http://identifiers.org/mamo/", "urn:miriam:mamo", @@ -240,7 +238,7 @@ public static class VCMetaDataDataType implements DataType { "urn:miriam:pubchem.substance", "PubChem is the collection of freely accessible chemical information.", "3324"); - public final static DataType DataType_Doid = new VCMetaDataDataType("Doid", + public final static DataType DataType_Doid = new VCMetaDataDataType("DOID", "http://disease-ontology.org/", "http://purl.bioontology.org/ontology/DOID/", // http://disease-ontology.org/term/ "urn:miriam:doid", @@ -258,9 +256,9 @@ public static class VCMetaDataDataType implements DataType { "urn:miriam:3dmet", "3DMET is a database collecting three-dimensional structures of natural metabolites.", "B00006"); - public final static DataType DataType_CL = new VCMetaDataDataType("Cell Ontology", + public final static DataType DataType_CL = new VCMetaDataDataType("CL", "http://bioportal.bioontology.org/ontologies/CL/", - "http://purl.bioontology.org/ontology/CL/", + "https://www.ebi.ac.uk/ols/ontologies/cl/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FCL_", "urn:miriam:cl", "The Cell Ontology is a structured controlled vocabulary for cell types.", "CL:0000145"); @@ -271,14 +269,14 @@ public static class VCMetaDataDataType implements DataType { "CAS (Chemical Abstracts Service) is a comprehensive database of chemical information.", "50-78-2"); public final static DataType DataType_BTO = new VCMetaDataDataType("BTO", - "http://bioportal.bioontology.org/ontologies/BTO/", - "http://purl.bioontology.org/ontology/BTO/", + "https://www.ebi.ac.uk/ols/ontologies/bto/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBTO_", + "https://www.ebi.ac.uk/ols/ontologies/bto/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FBTO_", "urn:miriam:bto", "The Brenda Tissue Ontology is a structured controlled vocabulary used to identify the source of an enzyme cited in the Brenda enzyme database. It comprises terms of tissues, cell lines, cell types and cell cultures.", "BTO:0000028"); - public final static DataType DataType_Pato = new VCMetaDataDataType("Pato", + public final static DataType DataType_Pato = new VCMetaDataDataType("PATO", "http://bioportal.bioontology.org/ontologies/PATO/", - "http://purl.bioontology.org/ontology/PATO/", + "https://www.ebi.ac.uk/ols/ontologies/pato/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FPATO_", "urn:miriam:pato", "PATO is an ontology of phenotypic qualities.", "PATO:0002220"); @@ -300,15 +298,15 @@ public static class VCMetaDataDataType implements DataType { "urn:miriam:fma", "The Foundational Model of Anatomy Ontology (FMA) represents a coherent body of explicit declarative knowledge about human anatomy.", "FMA:74531"); - public final static DataType DataType_Pr = new VCMetaDataDataType("Pr", + public final static DataType DataType_Pr = new VCMetaDataDataType("PR", "https://proconsortium.org/", - "http://purl.bioontology.org/ontology/PR/", // or https://proconsortium.org/app/entry/ or https://www.ebi.ac.uk/ols/ontologies/pr/terms?obo_id= + "https://www.ebi.ac.uk/ols/ontologies/pr/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FPR_", // or https://proconsortium.org/app/entry/ or https://www.ebi.ac.uk/ols/ontologies/pr/terms?obo_id= "urn:miriam:pr", "The PRotein Ontology (PRO) describes the relationships of proteins and protein evolutionary classes, to delineate the multiple protein forms of a gene locus.", "PR:000007300"); - public final static DataType DataType_Ncit = new VCMetaDataDataType("Ncit", + public final static DataType DataType_Ncit = new VCMetaDataDataType("NCIT", "http://www.ontobee.org/ontology/NCIT/", - "http://purl.obolibrary.org/obo/NCIT_", + "https://www.ebi.ac.uk/ols/ontologies/ncit/terms?iri=http%3A%2F%2Fpurl.obolibrary.org%2Fobo%2FNCIT_", "urn:miriam:ncit", "NCIt is a reference terminology that includes broad coverage of the cancer domain, including cancer related diseases, findings and abnormalities.", "C67381"); @@ -483,57 +481,58 @@ public Map getAllDataTypes() { public static List getSpecificDataTypes(Identifiable entity) { List list = new ArrayList<>(); - list.add(VCMetaDataDataType.DataType_PUBMED); - list.add(VCMetaDataDataType.DataType_DOI); + //temp comment ontologies not supported by search feature +// list.add(VCMetaDataDataType.DataType_PUBMED); +// list.add(VCMetaDataDataType.DataType_DOI); list.add(VCMetaDataDataType.DataType_Ncit); list.add(VCMetaDataDataType.DataType_GO); if(entity instanceof BioModel) { list.add(VCMetaDataDataType.DataType_BIOMODELS); - list.add(VCMetaDataDataType.DataType_REACTOME); - list.add(VCMetaDataDataType.DataType_NeuronDB); - list.add(VCMetaDataDataType.DataType_SenseLab); +// list.add(VCMetaDataDataType.DataType_REACTOME); +// list.add(VCMetaDataDataType.DataType_NeuronDB); +// list.add(VCMetaDataDataType.DataType_SenseLab); list.add(VCMetaDataDataType.DataType_Mamo); list.add(VCMetaDataDataType.DataType_EFO); list.add(VCMetaDataDataType.DataType_Doid); } else if(entity instanceof Species || entity instanceof MolecularType || entity instanceof RbmObservable) { list.add(VCMetaDataDataType.DataType_Chebi); - list.add(VCMetaDataDataType.DataType_KEGGCOMPOUND); - list.add(VCMetaDataDataType.DataType_UNIPROT); - list.add(VCMetaDataDataType.DataType_ECCODE); - list.add(VCMetaDataDataType.DataType_REACTOME); +// list.add(VCMetaDataDataType.DataType_KEGGCOMPOUND); +// list.add(VCMetaDataDataType.DataType_UNIPROT); +// list.add(VCMetaDataDataType.DataType_ECCODE); +// list.add(VCMetaDataDataType.DataType_REACTOME); list.add(VCMetaDataDataType.DataType_CL); list.add(VCMetaDataDataType.DataType_EFO); list.add(VCMetaDataDataType.DataType_BTO); - list.add(VCMetaDataDataType.DataType_TAXONOMY); +// list.add(VCMetaDataDataType.DataType_TAXONOMY); list.add(VCMetaDataDataType.DataType_Pato); list.add(VCMetaDataDataType.DataType_Pr); } else if(entity instanceof Model.ModelParameter) { list.add(VCMetaDataDataType.DataType_Chebi); - list.add(VCMetaDataDataType.DataType_KEGGCOMPOUND); - list.add(VCMetaDataDataType.DataType_UNIPROT); - list.add(VCMetaDataDataType.DataType_ECCODE); - list.add(VCMetaDataDataType.DataType_REACTOME); +// list.add(VCMetaDataDataType.DataType_KEGGCOMPOUND); +// list.add(VCMetaDataDataType.DataType_UNIPROT); +// list.add(VCMetaDataDataType.DataType_ECCODE); +// list.add(VCMetaDataDataType.DataType_REACTOME); list.add(VCMetaDataDataType.DataType_CL); list.add(VCMetaDataDataType.DataType_EFO); list.add(VCMetaDataDataType.DataType_BTO); - list.add(VCMetaDataDataType.DataType_TAXONOMY); +// list.add(VCMetaDataDataType.DataType_TAXONOMY); list.add(VCMetaDataDataType.DataType_Pato); list.add(VCMetaDataDataType.DataType_Pr); list.add(VCMetaDataDataType.DataType_SBO); } else if(entity instanceof ReactionRule || entity instanceof ReactionStep) { - list.add(VCMetaDataDataType.DataType_KEGGPATHWAY); - list.add(VCMetaDataDataType.DataType_KEGGREACTION); - list.add(VCMetaDataDataType.DataType_REACTOME); - list.add(VCMetaDataDataType.DataType_Brenda); - list.add(VCMetaDataDataType.DataType_IntAct); +// list.add(VCMetaDataDataType.DataType_KEGGPATHWAY); +// list.add(VCMetaDataDataType.DataType_KEGGREACTION); +// list.add(VCMetaDataDataType.DataType_REACTOME); +// list.add(VCMetaDataDataType.DataType_Brenda); +// list.add(VCMetaDataDataType.DataType_IntAct); list.add(VCMetaDataDataType.DataType_SBO); } else if(entity instanceof Structure) { - list.add(VCMetaDataDataType.DataType_Brenda); +// list.add(VCMetaDataDataType.DataType_Brenda); list.add(VCMetaDataDataType.DataType_BTO); list.add(VCMetaDataDataType.DataType_EFO);