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; 040 041import ptolemy.actor.gui.Effigy; 042import ptolemy.actor.gui.PtolemyEffigy; 043import ptolemy.actor.gui.Tableau; 044import ptolemy.actor.gui.TableauFrame; 045import ptolemy.kernel.Entity; 046import ptolemy.kernel.util.Attribute; 047import ptolemy.kernel.util.NamedObj; 048import ptolemy.vergil.toolbox.FigureAction; 049 050/** 051 * An action for viewing the LSID and LSID Referral List (aka Derived From list) 052 * in a popup dialog box. 053 * 054 * @author Aaron Schultz 055 * 056 */ 057public class LSIDViewerAction extends FigureAction { 058 059 private static final Log log = LogFactory.getLog(LSIDViewerAction.class 060 .getName()); 061 private static final boolean isDebugging = log.isDebugEnabled(); 062 063 private final static String LABEL = "View LSID"; 064 065 private TableauFrame _parent; 066 private NamedObj _obj; 067 068 public LSIDViewerAction(TableauFrame parent) { 069 super(LABEL); 070 071 _parent = parent; 072 073 if (parent == null) { 074 IllegalArgumentException iae = new IllegalArgumentException( 075 "ExportArchiveAction constructor received NULL argument for TableauFrame"); 076 iae.fillInStackTrace(); 077 throw iae; 078 } 079 080 this.putValue("tooltip", "Open the LSID Viewer Dialog."); 081 } 082 083 public void setObject(NamedObj no) { 084 _obj = no; 085 } 086 087 public void actionPerformed(ActionEvent e) { 088 super.actionPerformed(e); 089 090 if (isDebugging) 091 log.debug("LSIDViewerAction.actionPerformed()"); 092 093 NamedObj object = null; 094 if (_obj == null) { 095 object = getTarget(); 096 } else { 097 object = _obj; 098 } 099 100 if (isDebugging) 101 log.debug( object.getClass().getName() ); 102 103 if (object instanceof Entity) { 104 105 } else if (object instanceof Attribute) { 106 107 } else { 108 109 // get the entity from parent 110 Tableau tableau = _parent.getTableau(); 111 Effigy effigy = (Effigy) tableau.getContainer(); 112 Entity entity = null; 113 if (effigy instanceof PtolemyEffigy) { 114 entity = (Entity) ((PtolemyEffigy) effigy).getModel(); 115 } 116 117 if (entity == null) 118 return; 119 object = entity; 120 } 121 122 LSIDViewer lv = new LSIDViewer(); 123 lv.setEditingEnabled(false); 124 lv.initialize((NamedObj) object); 125 lv.setSize(new Dimension(400, 300)); 126 lv.setLocation(_parent.getLocation()); 127 lv.setVisible(true); 128 129 } 130 131}