001/* 002 * Copyright (c) 2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: aschultz $' 006 * '$Date: 2010-12-23 19:01:04 +0000 (Thu, 23 Dec 2010) $' 007 * '$Revision: 26600 $' 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 030/** 031 * 032 */ 033package org.kepler.gui.lsid; 034 035import java.awt.Dimension; 036import java.awt.event.ActionEvent; 037 038import org.apache.commons.logging.Log; 039import org.apache.commons.logging.LogFactory; 040import org.kepler.objectmanager.ObjectManager; 041import org.kepler.objectmanager.lsid.KeplerLSID; 042 043import ptolemy.actor.gui.TableauFrame; 044import ptolemy.kernel.util.NamedObj; 045import ptolemy.util.MessageHandler; 046import ptolemy.vergil.toolbox.FigureAction; 047 048/** 049 * An action for viewing the LSID and LSID Referral List (aka Derived From list) 050 * in a popup dialog box. 051 * 052 * @author Aaron Schultz 053 * 054 */ 055public class LibLsidViewerAction extends FigureAction { 056 057 private static final Log log = LogFactory.getLog(LibLsidViewerAction.class 058 .getName()); 059 private static final boolean isDebugging = log.isDebugEnabled(); 060 061 private final static String LABEL = "View LSID"; 062 063 private TableauFrame _parent; 064 private KeplerLSID _lsidToView; 065 066 public void setLsidToView(KeplerLSID lsid) { 067 _lsidToView = lsid; 068 } 069 public KeplerLSID getLsidToView() { 070 return _lsidToView; 071 } 072 073 public LibLsidViewerAction(TableauFrame parent) { 074 super(LABEL); 075 076 _parent = parent; 077 078 if (parent == null) { 079 IllegalArgumentException iae = new IllegalArgumentException( 080 "ExportArchiveAction constructor received NULL argument for TableauFrame"); 081 iae.fillInStackTrace(); 082 throw iae; 083 } 084 085 this.putValue("tooltip", "Open the LSID Viewer Dialog."); 086 } 087 088 public void actionPerformed(ActionEvent e) { 089 super.actionPerformed(e); 090 091 if (isDebugging) 092 log.debug("LSIDViewerAction.actionPerformed()"); 093 094 /* 095 * So this class shouldn't really be needed. The LSID should show up in 096 * the popup menu itself, hopefully that'll happen one of these days. 097 * For now this kludge will let us see what LSID is the default LSID for 098 * a component in the library at least. 099 */ 100 try { 101 NamedObj obj = ObjectManager.getInstance().getObjectRevision(getLsidToView()); 102 103 if (obj == null) { 104 MessageHandler.message("Non-NamedObject LSID: " + getLsidToView().toString()); 105 return; 106 } 107 108 LSIDViewer lv = new LSIDViewer(); 109 lv.setEditingEnabled(false); 110 lv.initialize((NamedObj) obj); 111 lv.setSize(new Dimension(400, 300)); 112 lv.setLocation(_parent.getLocation()); 113 lv.setVisible(true); 114 } catch (Exception ex) { 115 ex.printStackTrace(); 116 } 117 118 } 119 120}