KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > clipboard > control > PasteAction


1 /***
2  * FractalGUI: a graphical tool to edit Fractal component configurations.
3  * Copyright (C) 2003 France Telecom R&D
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 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  *
19  * Contact: fractal@objectweb.org
20  *
21  * Authors: Eric Bruneton, Patrice Fauvel
22  */

23
24 package org.objectweb.fractal.gui.clipboard.control;
25
26 import org.objectweb.fractal.gui.model.Component;
27
28 import java.net.URL JavaDoc;
29 import java.awt.event.ActionEvent JavaDoc;
30
31 import javax.swing.ImageIcon JavaDoc;
32 import javax.swing.KeyStroke JavaDoc;
33
34 /**
35  * An action that just calls the {@link
36  * org.objectweb.fractal.gui.clipboard.model.Clipboard#paste paste} method on a
37  * {@link org.objectweb.fractal.gui.clipboard.model.Clipboard}.
38  */

39
40 public class PasteAction extends ClipboardAction {
41
42   /**
43    * Constructs a new {@link PasteAction} component.
44    */

45
46   public PasteAction () {
47     putValue(NAME, "Paste");
48     putValue(SHORT_DESCRIPTION, "Paste");
49     putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke("control V"));
50     URL JavaDoc url = getClass().getResource(
51       "/org/objectweb/fractal/gui/resources/editpaste.gif");
52     putValue(SMALL_ICON, new ImageIcon JavaDoc(url));
53     setEnabled(false);
54   }
55
56   // -------------------------------------------------------------------------
57
// Implementation of the SelectionListener interface
58
// -------------------------------------------------------------------------
59

60   public void selectionChanged () {
61     Object JavaDoc o = selection.getSelection();
62     if (o instanceof Component) {
63       setEnabled(clipboard.canPaste((Component)o));
64     } else {
65       setEnabled(clipboard.canPaste(null));
66     }
67   }
68
69   // -------------------------------------------------------------------------
70
// Implementation of the ActionListener interface
71
// -------------------------------------------------------------------------
72

73   public void actionPerformed (final ActionEvent JavaDoc e) {
74     Object JavaDoc o = selection.getSelection();
75     clipboard.paste((Component)o, graph, factory);
76   }
77 }
78
79
Popular Tags