KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mc4j > console > connection > create > CallCreateVisualPanel


1 /*
2  * Copyright 2002-2004 Greg Hinkle
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.mc4j.console.connection.create;
18
19 import org.openide.WizardDescriptor;
20 import org.openide.util.HelpCtx;
21
22 import javax.swing.*;
23 import javax.swing.event.ChangeListener JavaDoc;
24 import java.awt.*;
25
26 /**
27  * @author Greg Hinkle (ghinkle@users.sourceforge.net), Sep 22, 2004
28  * @version $Revision: 570 $($Author: ghinkl $ / $Date: 2006-04-12 15:14:16 -0400 (Wed, 12 Apr 2006) $)
29  */

30 public class CallCreateVisualPanel extends JPanel implements WizardDescriptor.Panel {
31
32     private JTextArea textArea;
33
34     CreateWizardDescriptor descriptor;
35     private CreateMBeanData data;
36
37     public CallCreateVisualPanel(CreateWizardDescriptor descriptor) {
38         this.descriptor = descriptor;
39         this.data = descriptor.getData();
40
41         init();
42     }
43
44     public boolean isValid() {
45         return true;
46     }
47     public void executeCreate() {
48         try {
49             this.descriptor.getConnection().createMBean(this.data.getClassName(), this.data.getObjectName());
50
51             this.textArea.setText(
52                 "The MBean was succesfully created under the name: " + this.data.getObjectName());
53
54         } catch (Exception JavaDoc e) {
55             e.printStackTrace();
56             this.textArea.setText(
57                 "Unable to create MBean: " + e.toString()
58             );
59         }
60
61     }
62
63
64     private void init() {
65         textArea = new JTextArea();
66         setLayout(new BorderLayout());
67         add(textArea, BorderLayout.CENTER);
68
69     }
70
71
72
73     public Component getComponent() {
74         return this;
75     }
76
77     public HelpCtx getHelp() {
78         return null;
79     }
80
81     public void readSettings(Object JavaDoc o) {
82         System.out.println("Executing create");
83         executeCreate();
84     }
85
86     public void storeSettings(Object JavaDoc o) {
87
88     }
89
90     public void addChangeListener(ChangeListener JavaDoc changeListener) {
91
92     }
93
94     public void removeChangeListener(ChangeListener JavaDoc changeListener) {
95
96     }
97 }
98
Popular Tags