KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejtools > adwt > service > ConsoleServiceInternalFrame


1 /*
2  * EJTools, the Enterprise Java Tools
3  *
4  * Distributable under LGPL license.
5  * See terms of license at www.gnu.org.
6  */

7 package org.ejtools.adwt.service;
8
9 import java.awt.BorderLayout JavaDoc;
10 import java.beans.beancontext.BeanContext JavaDoc;
11 import java.util.ResourceBundle JavaDoc;
12
13 import javax.swing.JMenuBar JavaDoc;
14 import javax.swing.JScrollPane JavaDoc;
15 import javax.swing.JTextArea JavaDoc;
16
17 import org.ejtools.adwt.action.Command;
18 import org.ejtools.adwt.action.edit.CopyAction;
19 import org.ejtools.adwt.action.edit.CutAction;
20 import org.ejtools.adwt.action.edit.DeleteAction;
21
22 /**
23  * @author Laurent Etiemble
24  * @version $Revision: 1.6 $
25  */

26 public class ConsoleServiceInternalFrame extends BeanContextInternalFrame implements ConsoleService
27 {
28    /** Description of the Field */
29    protected BeanContext JavaDoc context = null;
30    /** Description of the Field */
31    protected MenuBarServiceProvider menubarProvider;
32    /** Description of the Field */
33    protected JTextArea JavaDoc textarea = null;
34    /** Description of the Field */
35    protected ToolBarServiceProvider toolbarProvider;
36    /** Description of the Field */
37    private final static ResourceBundle JavaDoc resources = ResourceBundle.getBundle("org.ejtools.adwt.service.ConsoleService");
38
39
40    /**
41     * Constructor for ConsoleServiceInternalFrame.
42     *
43     * @param context Description of the Parameter
44     */

45    public ConsoleServiceInternalFrame(BeanContext JavaDoc context)
46    {
47       super();
48       this.context = context;
49       this.textarea = new JTextArea JavaDoc();
50
51       this.menubarProvider = new MenuBarServiceProvider();
52       this.toolbarProvider = new ToolBarServiceProvider();
53
54       this.add(this.toolbarProvider);
55       this.add(this.menubarProvider);
56
57       this.add(new CutAction(
58          new Command()
59          {
60             /** */
61             public void execute()
62             {
63                ConsoleServiceInternalFrame.this.cut();
64             }
65          }));
66
67       this.add(new CopyAction(
68          new Command()
69          {
70             /** */
71             public void execute()
72             {
73                ConsoleServiceInternalFrame.this.copy();
74             }
75          }));
76
77       this.add(new DeleteAction(
78          new Command()
79          {
80             /** */
81             public void execute()
82             {
83                ConsoleServiceInternalFrame.this.delete();
84             }
85          }));
86
87       this.frame.setJMenuBar((JMenuBar JavaDoc) this.menubarProvider.getContainer());
88       this.frame.getContentPane().add(BorderLayout.NORTH, this.toolbarProvider.getContainer());
89       this.frame.getContentPane().add(BorderLayout.CENTER, new JScrollPane JavaDoc(this.textarea));
90
91       this.setTitle(resources.getString("frame.title"));
92    }
93
94
95    /**
96     * @param message Description of the Parameter
97     */

98    public void append(String JavaDoc message)
99    {
100       this.textarea.append(message);
101       this.textarea.append("\n");
102       this.show();
103    }
104
105
106    /** */
107    public void copy()
108    {
109       this.textarea.copy();
110    }
111
112
113    /** */
114    public void cut()
115    {
116       this.textarea.cut();
117    }
118
119
120    /** */
121    public void delete()
122    {
123       this.textarea.setText("");
124    }
125
126
127    /** */
128    public void hide()
129    {
130       if (this.context.contains(this))
131       {
132          this.close();
133       }
134    }
135
136
137    /** */
138    public void show()
139    {
140       if (!this.context.contains(this))
141       {
142          this.context.add(this);
143       }
144       this.activate();
145    }
146 }
147
Popular Tags