alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

What this is

This file is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Other links

The source code

// $Id: ActionModifier.java,v 1.4 2004/09/29 18:46:27 mvw Exp $
// Copyright (c) 1996-2001 The Regents of the University of California. All
// Rights Reserved. Permission to use, copy, modify, and distribute this
// software and its documentation without fee, and without a written
// agreement is hereby granted, provided that the above copyright notice
// and this paragraph appear in all copies.  This software program and
// documentation are copyrighted by The Regents of the University of
// California. The software program and documentation are supplied "AS
// IS", without any accompanying services from The Regents. The Regents
// does not warrant that the operation of the program will be
// uninterrupted or error-free. The end-user understands that the program
// was developed for research purposes and is advised not to rely
// exclusively on the program for any reason.  IN NO EVENT SHALL THE
// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.

// File: ActionModifier.java
// Classes: ActionModifier
// Original Author: Bob Tarling
// $Id: ActionModifier.java,v 1.4 2004/09/29 18:46:27 mvw Exp $

// 9 Apr 2002: Jeremy Bennett (mail@jeremybennett.com). Extended to support
// use cases


package org.argouml.uml.diagram.ui;

import org.argouml.uml.ui.*;
import java.awt.event.*;
import java.beans.PropertyVetoException;
import org.argouml.model.ModelFacade;

/**
 * 

A class to perform the action of changing value of the modifiers on a * package, use case, interface or class.

* * @author Bob Tarling * * @author Jeremy Bennett (mail@jeremybennett.com)— use case extensions. */ public class ActionModifier extends UMLAction { private UMLBooleanProperty property; private Object object; private Class mclassClass = (Class) ModelFacade.CLASS; private Class mpackageClass = (Class) ModelFacade.PACKAGE; private Class minterfaceClass = (Class) ModelFacade.INTERFACE; private Class museCaseClass = (Class) ModelFacade.USE_CASE; //Jeremy Bennett private Object trueValue = null; private Object falseValue = null; /** * Defines an Action object with the specified description which * will use the given reflection methods to modify boolean values * in an MClass object. * * @param name the text for the actions menu item * @param propertyName the name of the modifier property to be amended * @param getMethod the name of the getter method to retrieve the * property * @param setMethod the name of the setter method to change the * property * @param mclass the MClass object containing the * modifier property. */ public ActionModifier(String name, String propertyName, String getMethod, String setMethod, Object mclass) { super(name, NO_ICON); this.object = mclass; property = new UMLReflectionBooleanProperty(propertyName, mclassClass, getMethod, setMethod); putValue("SELECTED", new Boolean(property.getProperty(object))); } /** * Defines an Action object with the specified description which * will use the given reflection methods to modify an enumerated * values in an MClass object. * * @param name the text for the actions menu item * @param propertyName the name of the modifier property to be amended * @param getMethod the name of the getter method to retrieve the * property * @param setMethod the name of the setter method to change the * property * @param mclass the MClass object containing the * modifier property. * @param enumClass the class representing the enumeration * @param theTrueValue The enumerated value representing true * @param theFalseValue The enumerated value representing false */ public ActionModifier(String name, String propertyName, String getMethod, String setMethod, Object mclass, Class enumClass, Object theTrueValue, Object theFalseValue) { super(name, NO_ICON); this.object = mclass; property = new UMLEnumerationBooleanProperty(propertyName, mclassClass, getMethod, setMethod, enumClass, theTrueValue, theFalseValue); putValue("SELECTED", new Boolean(property.getProperty(object))); } //////////////////////////////////////////////////////////////// // main methods /** * To perform the action of changing a modifier. * * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) */ public void actionPerformed(ActionEvent ae) { try { property.setProperty(object, !property.getProperty(object)); } catch (PropertyVetoException ve) { } } /** * The action is always enabled * * @see org.argouml.uml.ui.UMLAction#shouldBeEnabled() */ public boolean shouldBeEnabled() { return true; } } /* end class ActionModifier */
... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.