001/*
002 * Copyright (c) 2010 The Regents of the University of California.
003 * All rights reserved.
004 *
005 * '$Author: crawl $'
006 * '$Date: 2012-11-26 22:22:25 +0000 (Mon, 26 Nov 2012) $' 
007 * '$Revision: 31122 $'
008 * 
009 * Permission is hereby granted, without written agreement and without
010 * license or royalty fees, to use, copy, modify, and distribute this
011 * software and its documentation for any purpose, provided that the above
012 * copyright notice and the following two paragraphs appear in all copies
013 * of this software.
014 *
015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY
016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
019 * SUCH DAMAGE.
020 *
021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES,
026 * ENHANCEMENTS, OR MODIFICATIONS.
027 *
028 */
029
030package org.kepler.gui.popups;
031
032import java.awt.Component;
033import java.util.Collections;
034import java.util.List;
035
036import javax.swing.JMenu;
037import javax.swing.JMenuItem;
038import javax.swing.JSeparator;
039import javax.swing.tree.TreePath;
040
041import org.kepler.gui.component.ToggleLsidAction;
042import org.kepler.objectmanager.lsid.KeplerLSID;
043
044/**
045 * Subclass of LibraryPopup that handles library items that are components and
046 * not inside of a KAR (i.e. components inside ontologies).
047 * 
048 * @author Aaron Schultz
049 * 
050 */
051public class RemoteOntologyComponentPopup extends NoLiidLibraryPopup {
052
053        public RemoteOntologyComponentPopup(TreePath path, Component comp) {
054                super(path, comp);
055        }
056
057        public void initialize() {
058                Object obj = getSelectionPath().getLastPathComponent();
059//              KeplerLSID lsid = getInfo().getLsid();
060
061                // LSID Toggle Menu
062                addLsidToggleMenu();
063                
064                // View Documentation
065//              ShowDocumentationAction sda = new ShowDocumentationAction(
066//                              getSelectionPath(), getParentFrame());
067//              sda.setPtolemyFrame(getParentFrame());
068//              sda.setLsidToView(lsid);
069//              this.add(new JMenuItem(sda));
070
071                // View LSID
072//              LibLsidViewerAction lva = new LibLsidViewerAction(getParentFrame());
073//              lva.setLsidToView(lsid);
074//              this.add(new JMenuItem(lva));
075        }
076
077        /**
078         * It is possible that there is more than one LSID associated with this
079         * Library Item. Add a menu item that allows the user to toggle which LSID
080         * is currently the default LSID. If there is only one lsid associated with
081         * this item then we don't add the menu.
082         */
083        private void addLsidToggleMenu() {
084
085                JMenu jm = new JMenu("");
086//              jm.add(new JMenuItem("Blah blah blah"));
087//              Vector<KeplerLSID> lsids = getInfo().getLsids();
088                List<KeplerLSID> lsids = Collections.emptyList();
089                if (lsids.size() > 1) {
090                        for (KeplerLSID altLSID : lsids) {
091                                JMenuItem jmi = new JMenuItem(altLSID.toString());
092                                ToggleLsidAction tla = new ToggleLsidAction();
093//                              tla.setLiid(this.getLiid());
094                                jmi.addActionListener(tla);
095                                jm.add(jmi);
096                        }
097                        this.add(jm);
098                        this.add(new JSeparator());
099                }
100                this.add(jm);
101        }
102}