KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > monitorenter > gui > chart > events > Trace2DActionSetName


1 /*
2  * Trace2DActionSetName, action to set the name of an ITrace2D.
3  * Copyright (C) Achim Westermann, created on 10.12.2004, 13:48:55
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  *
19  * If you modify or optimize the code in a useful way please let me know.
20  * Achim.Westermann@gmx.de
21  *
22  */

23 package info.monitorenter.gui.chart.events;
24
25 import info.monitorenter.gui.chart.ITrace2D;
26
27 import java.awt.Component JavaDoc;
28 import java.awt.event.ActionEvent JavaDoc;
29 import java.beans.PropertyChangeEvent JavaDoc;
30
31 import javax.swing.JOptionPane JavaDoc;
32
33
34 /**
35  * <p>
36  * <code>Action</code> that sets a custom name of the corresponding trace by
37  * showing a modal String chooser.
38  * </p>
39  *
40  * @author <a HREF="mailto:Achim.Westermann@gmx.de">Achim Westermann </a>
41  *
42  * @version $Revision: 1.2 $
43  */

44 public final class Trace2DActionSetName extends ATrace2DAction {
45
46   /**
47    * Generated <code>serialVersionUID</code>.
48    */

49   private static final long serialVersionUID = 3904680491952451890L;
50
51   /**
52    * The component this instance will be registered to as a listener.
53    * <p>
54    *
55    * @see Component#addMouseListener(java.awt.event.MouseListener)
56    *
57    */

58   private Component JavaDoc m_trigger;
59
60   /**
61    * Create an <code>Action</code> that accesses the trace and identifies
62    * itself with the given action String.
63    * <p>
64    *
65    * @param trace
66    * the target the action will work on.
67    *
68    * @param description
69    * the descriptive <code>String</code> that will be displayed by
70    * {@link javax.swing.AbstractButton} subclasses that get this
71    * <code>Action</code> assigned (
72    * {@link javax.swing.AbstractButton#setAction(javax.swing.Action)}).
73    *
74    * @param trigger
75    * the <code>Component</code> the modal color chooser dialog will
76    * be related to.
77    */

78   public Trace2DActionSetName(final ITrace2D trace, final String JavaDoc description,
79       final Component JavaDoc trigger) {
80     super(trace, description);
81     this.m_trigger = trigger;
82   }
83
84   /**
85    * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
86    */

87   public void actionPerformed(final ActionEvent JavaDoc e) {
88     String JavaDoc chosen = JOptionPane.showInputDialog(this.m_trigger,
89         "Please input the new Name for trace " + this.m_trace.getName(), "Set trace name",
90         JOptionPane.PLAIN_MESSAGE);
91     this.m_trace.setName(chosen);
92   }
93
94   /**
95    * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
96    */

97   public void propertyChange(final PropertyChangeEvent JavaDoc evt) {
98     // nop as this action will not be used
99
// by checkbox or radio button menu items that have a state.
100
}
101 }
102
Popular Tags