KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > fractal > gui > menu > control > CreateAction


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.menu.control;
25
26 import org.objectweb.fractal.api.control.BindingController;
27
28 import org.objectweb.fractal.gui.selection.model.SelectionListener;
29 import org.objectweb.fractal.gui.selection.model.Selection;
30 import org.objectweb.fractal.gui.model.Factory;
31 import org.objectweb.fractal.swing.AbstractAction;
32
33 /**
34  * Super classes of actions that create components or interfaces.
35  */

36
37 public abstract class CreateAction extends AbstractAction implements
38   SelectionListener,
39   BindingController
40 {
41
42   /**
43    * A mandatory client interface bound to a {@link Selection selection} model.
44    * This model is used to select the created components or interfaces, and
45    * to add them to the selected component.
46    */

47
48   public final static String JavaDoc SELECTION_BINDING = "selection";
49
50   /**
51    * A mandatory client interface bound to a {@link Factory factory} component.
52    * This factory is used to create components or interfaces.
53    */

54
55   public final static String JavaDoc FACTORY_BINDING = "configuration-factory";
56
57   /**
58    * The selection client interface.
59    */

60
61   Selection selection;
62
63   /**
64    * The factory client interface.
65    */

66
67   Factory factory;
68
69   // -------------------------------------------------------------------------
70
// Implementation of the BindingController interface
71
// -------------------------------------------------------------------------
72

73   public String JavaDoc[] listFc () {
74     return new String JavaDoc[] { SELECTION_BINDING, FACTORY_BINDING };
75   }
76
77   public Object JavaDoc lookupFc (final String JavaDoc clientItfName) {
78     if (SELECTION_BINDING.equals(clientItfName)) {
79       return selection;
80     } else if (FACTORY_BINDING.equals(clientItfName)) {
81       return factory;
82     }
83     return null;
84   }
85
86   public void bindFc (
87     final String JavaDoc clientItfName,
88     final Object JavaDoc serverItf)
89   {
90     if (SELECTION_BINDING.equals(clientItfName)) {
91       selection = (Selection)serverItf;
92     } else if (FACTORY_BINDING.equals(clientItfName)) {
93       factory = (Factory)serverItf;
94     }
95   }
96
97   public void unbindFc (final String JavaDoc clientItfName) {
98     if (SELECTION_BINDING.equals(clientItfName)) {
99       selection = null;
100     } else if (FACTORY_BINDING.equals(clientItfName)) {
101       factory = null;
102     }
103   }
104 }
105
106
Popular Tags