001/* 002 * Copyright (c) 2004-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2015-08-24 22:44:14 +0000 (Mon, 24 Aug 2015) $' 007 * '$Revision: 33630 $' 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.kar; 031 032import java.awt.event.ActionEvent; 033 034import javax.swing.Action; 035import javax.swing.ImageIcon; 036import javax.swing.KeyStroke; 037 038import org.apache.commons.logging.Log; 039import org.apache.commons.logging.LogFactory; 040import org.kepler.util.StaticResources; 041 042import diva.gui.GUIUtilities; 043import ptolemy.actor.gui.TableauFrame; 044import ptolemy.kernel.ComponentEntity; 045import ptolemy.kernel.util.NamedObj; 046 047/** 048 * This action saves an actor as a kar file. It is called from right clicking on 049 * an actor. 050 * 051 *@author Aaron Schultz 052 */ 053public class ExportActorArchiveAction extends ExportArchiveAction { 054 055 private static final Log log = LogFactory 056 .getLog(ExportActorArchiveAction.class.getName()); 057 private static final boolean isDebugging = log.isDebugEnabled(); 058 059 private static String DISPLAY_NAME = StaticResources.getDisplayString( 060 "actions.actor.displayName", "Save Archive (KAR)..."); 061 private static String TOOLTIP = StaticResources.getDisplayString( 062 "actions.actor.tooltip", "Save a KAR file archive."); 063 064 private static ImageIcon LARGE_ICON = null; 065 private static KeyStroke ACCELERATOR_KEY = null; 066 067 /** 068 * Constructor 069 * 070 * @param parent 071 * the "frame" (derived from ptolemy.gui.Top) where the menu is 072 * being added. 073 */ 074 public ExportActorArchiveAction(TableauFrame parent) { 075 super(parent); 076 077 // note: initialize method is called in super class constructor 078 } 079 080 /** 081 * Override the initialize method to change the behavior of the constructor. 082 */ 083 protected void initialize() { 084 085 this.putValue(Action.NAME, DISPLAY_NAME); 086 this.putValue(GUIUtilities.LARGE_ICON, LARGE_ICON); 087 this.putValue("tooltip", TOOLTIP); 088 this.putValue(GUIUtilities.ACCELERATOR_KEY, ACCELERATOR_KEY); 089 090 this.setSingleItemKAR(true); 091 setRefreshFrameAfterSave(false); 092 setMapKARToCurrentFrame(false); 093 } 094 095 /** 096 * Invoked when an action occurs. 097 * 098 *@param e 099 * ActionEvent 100 */ 101 public boolean handleAction(ActionEvent e) { 102 103 // Get the NamedObj 104 NamedObj target = super.getTarget(); 105 106 if (target instanceof ComponentEntity) { 107 108 // check it for LSID, Name, and SemanticTypes 109 boolean continueExport = checkSingleObject(target, true); 110 if (!continueExport) { 111 return false; 112 } 113 114 _savekar.addSaveInitiator((ComponentEntity)target); 115 116 return true; 117 } 118 return false; 119 } 120}