001/* 002 * Copyright (c) 2003-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: welker $' 006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 007 * '$Revision: 24234 $' 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; 031 032import java.awt.Component; 033import java.awt.event.ActionEvent; 034 035import javax.swing.JOptionPane; 036import javax.swing.tree.TreePath; 037 038import ptolemy.vergil.basic.BasicGraphFrame; 039import ptolemy.vergil.toolbox.FigureAction; 040 041/** 042 * This action removes actors from the tree 043 * 044 *@author Chad Berkley 045 *@since February 17, 2005 046 */ 047public class RemoveActorAction extends FigureAction { 048 private final static String LABEL = "Remove Actor"; 049 private TreePath path; 050 private Component parent; 051 private NewActorFrame naFrame; 052 053 /** 054 * Constructor 055 * 056 *@param path 057 * the TreePath where the actor is being removed. 058 */ 059 public RemoveActorAction(TreePath path, Component parent) { 060 super(LABEL); 061 this.path = path; 062 this.parent = parent; 063 } 064 065 /** 066 * Invoked when an action occurs. 067 * 068 *@param e 069 * ActionEvent 070 */ 071 public void actionPerformed(ActionEvent e) { 072 super.actionPerformed(e); 073 Component current = parent; 074 while (parent != null && !(parent instanceof BasicGraphFrame)) { 075 parent = current.getParent(); 076 current = parent; 077 } 078 079 int userChoice = JOptionPane 080 .showConfirmDialog( 081 null, 082 "Are you sure you " 083 + "want to remove this actor? It will no longer be accessible from the " 084 + "actor library. Click \"Yes\" to remove the actor.", 085 "Are you sure?", JOptionPane.YES_NO_OPTION); 086 if (userChoice == JOptionPane.YES_OPTION) { 087 System.out.println("removing actor..."); 088 JOptionPane 089 .showMessageDialog( 090 null, 091 "This functionality isn't implemented yet...check back in alpha 6.", 092 "alert", JOptionPane.ERROR_MESSAGE); 093 } 094 } 095}