001/* 002 * Copyright (c) 2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: crawl $' 006 * '$Date: 2013-01-23 21:50:06 +0000 (Wed, 23 Jan 2013) $' 007 * '$Revision: 31361 $' 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.io.File; 034 035import javax.swing.JMenuItem; 036import javax.swing.tree.TreePath; 037 038import org.kepler.gui.kar.DeleteArchiveAction; 039import org.kepler.gui.kar.KarUploaderAction; 040import org.kepler.gui.kar.OpenArchiveAction; 041import org.kepler.gui.kar.ViewManifestAction; 042import org.kepler.moml.KAREntityLibrary; 043import org.kepler.objectmanager.library.LibIndex; 044 045/** 046 * Subclass of LibraryPopup that handles the popup menu for KARs inside the 047 * library. 048 * 049 * @author Aaron Schultz 050 * 051 */ 052public class KARPopup extends LibraryPopup { 053 054 private static final long serialVersionUID = 4797725289324539443L; 055 056 public KARPopup(TreePath path, Component comp) { 057 super(path, comp); 058 059 Object obj = getSelectionPath().getLastPathComponent(); 060 061 if (obj instanceof KAREntityLibrary) { 062 063 String karFileStr = getInfo().getAttributeValue(LibIndex.ATT_KARFILE); 064 065 // make sure the file string is not null. the string can be null when 066 // the kar is deleted but not removed from the library tree. 067 if(karFileStr != null) { 068 File karFile = new File(karFileStr); 069 070 // Open 071 OpenArchiveAction oaa = new OpenArchiveAction(getParentFrame()); 072 if (karFile != null) { 073 oaa.setArchiveFileToOpen(karFile); 074 } 075 this.add(new JMenuItem(oaa)); 076 077 ViewManifestAction vma = new ViewManifestAction(getParentFrame()); 078 if (karFile != null) { 079 vma.setArchiveFileToOpen(karFile); 080 } 081 this.add(new JMenuItem(vma)); 082 083 // Upload To Repository 084 KarUploaderAction kua = new KarUploaderAction(getParentFrame()); 085 if (karFile != null) { 086 kua.setArchiveFileToUpload(karFile); 087 } 088 this.add(new JMenuItem(kua)); 089 090 // Delete 091 DeleteArchiveAction daa = new DeleteArchiveAction(getParentFrame()); 092 daa.setArchiveFileToDelete(karFile); 093 this.add(new JMenuItem(daa)); 094 } 095 } 096 097 // this.add(new JMenuItem("Under Construction: KARPopup")); 098 099 // Remove KAR from library here 100 101 } 102}