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; 033 034import javax.swing.JPopupMenu; 035import javax.swing.tree.TreePath; 036 037import org.apache.commons.logging.Log; 038import org.apache.commons.logging.LogFactory; 039 040import ptolemy.actor.gui.PtolemyFrame; 041 042/** 043 * A class for organizing popup menus in the Library. By extending this class 044 * you can add actions to the different types of items that show up in the 045 * library. See examples such as OntologyComponentPopup. See the AnnotatedPTree 046 * method "maybeShowPopup" for where to add the subclass in order for it to show 047 * up. 048 * 049 * @author Aaron Schultz 050 * 051 */ 052public class NoLiidLibraryPopup extends JPopupMenu { 053 054 private static final long serialVersionUID = 1L; 055 private static final Log log = LogFactory.getLog(LibraryPopup.class); 056 private static final boolean isDebugging = log.isDebugEnabled(); 057 058 private TreePath _selectionPath; 059 private PtolemyFrame _parentFrame; 060 private int _liid; 061 062 public NoLiidLibraryPopup() { 063 _selectionPath = null; 064 _parentFrame = null; 065 } 066 067 /** 068 * @param path 069 * @param comp 070 */ 071 public NoLiidLibraryPopup(TreePath path, Component comp) { 072 073 while (comp != null && !(comp instanceof PtolemyFrame)) { 074 comp = comp.getParent(); 075 } 076 077 if (comp == null) { 078 System.out.println("Cannot find the PtolemyFrame."); 079 return; 080 } 081 082 setParentFrame((PtolemyFrame) comp); 083 setSelectionPath(path); 084 085 } 086 087 /** 088 * Override this method with the good stuff. 089 */ 090 public void initialize() { 091 } 092 093 public NoLiidLibraryPopup(TreePath path, PtolemyFrame parentFrame) { 094 _selectionPath = path; 095 _parentFrame = parentFrame; 096 } 097 098// public LibItem getInfo() { 099// LibItem li = LibraryManager.getInstance().getTreeItemIndexInformation( 100// getLiid()); 101// return li; 102// } 103 104// public int getLiid() { 105// return _liid; 106// } 107 108// private void setLiid(int liid) { 109// _liid = liid; 110// } 111// 112 public TreePath getSelectionPath() { 113 return _selectionPath; 114 } 115 116 public void setSelectionPath(TreePath selectionPath) { 117 _selectionPath = selectionPath; 118 } 119 120 public PtolemyFrame getParentFrame() { 121 return _parentFrame; 122 } 123 124 public void setParentFrame(PtolemyFrame parentFrame) { 125 _parentFrame = parentFrame; 126 } 127 128}