KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > genimen > djeneric > tools > modeler > dialogs > RoleEditorDialog


1 /*
2  * Copyright (c) 2001-2005 by Genimen BV (www.genimen.com) All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, is permitted provided that the following conditions are met: -
6  * Redistributions of source code must retain the above copyright notice, this
7  * list of conditions and the following disclaimer. - Redistributions in binary
8  * form must reproduce the above copyright notice, this list of conditions and
9  * the following disclaimer in the documentation and/or other materials
10  * provided with the distribution. - All advertising materials mentioning
11  * features or use of this software must display the following acknowledgment:
12  * "This product includes Djeneric." - Products derived from this software may
13  * not be called "Djeneric" nor may "Djeneric" appear in their names without
14  * prior written permission of Genimen BV. - Redistributions of any form
15  * whatsoever must retain the following acknowledgment: "This product includes
16  * Djeneric."
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS"
19  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21  * ARE DISCLAIMED. IN NO EVENT SHALL GENIMEN BV, DJENERIC.ORG, OR CONTRIBUTORS
22  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28  * POSSIBILITY OF SUCH DAMAGE.
29  */

30 package com.genimen.djeneric.tools.modeler.dialogs;
31
32 import java.awt.BorderLayout JavaDoc;
33 import java.awt.Dimension JavaDoc;
34 import java.awt.Toolkit JavaDoc;
35 import java.awt.event.ActionEvent JavaDoc;
36
37 import javax.swing.JButton JavaDoc;
38 import javax.swing.JDialog JavaDoc;
39 import javax.swing.JPanel JavaDoc;
40
41 import com.genimen.djeneric.language.Messages;
42 import com.genimen.djeneric.repository.DjPersistenceManager;
43 import com.genimen.djeneric.ui.Util;
44 import com.genimen.djeneric.util.DjLogger;
45 import java.awt.event.ActionListener JavaDoc;
46
47 public class RoleEditorDialog extends JDialog JavaDoc
48 {
49   private static final long serialVersionUID = 1L;
50   JPanel JavaDoc panel1 = new JPanel JavaDoc();
51   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
52   JPanel JavaDoc jPanel1 = new JPanel JavaDoc();
53   RoleEditorPanel _pnlEditor;
54   BorderLayout JavaDoc borderLayout2 = new BorderLayout JavaDoc();
55   JPanel JavaDoc jPanel2 = new JPanel JavaDoc();
56   JButton JavaDoc _butOk = new JButton JavaDoc();
57   DjPersistenceManager _mgr;
58   JButton JavaDoc _butCancel = new JButton JavaDoc();
59
60   public RoleEditorDialog(DjPersistenceManager mgr)
61   {
62     super(Util.findActiveFrame(), Messages.getString("RoleEditorDialog.title"), true);
63     try
64     {
65       _mgr = mgr;
66       _pnlEditor = new RoleEditorPanel(mgr);
67       jbInit();
68       setSize(500, 500);
69
70       Dimension JavaDoc screenSize = Toolkit.getDefaultToolkit().getScreenSize();
71       Dimension JavaDoc frameSize = getSize();
72       setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
73
74       setVisible(true);
75     }
76     catch (Exception JavaDoc ex)
77     {
78       DjLogger.log(ex);
79     }
80   }
81
82   private void jbInit() throws Exception JavaDoc
83   {
84     panel1.setLayout(borderLayout1);
85     jPanel1.setLayout(borderLayout2);
86     _butOk.setText(Messages.getString("global.Ok"));
87     _butOk.addActionListener(new RoleEditorDialog__butOk_actionAdapter(this));
88     _butCancel.setText(Messages.getString("global.Cancel"));
89     _butCancel.addActionListener(new RoleEditorDialog__butCancel_actionAdapter(this));
90     getContentPane().add(panel1);
91     panel1.add(jPanel1, BorderLayout.SOUTH);
92     panel1.add(_pnlEditor, BorderLayout.CENTER);
93     jPanel1.add(jPanel2, BorderLayout.EAST);
94     jPanel2.add(_butCancel);
95     jPanel2.add(_butOk, null);
96   }
97
98   void _butOk_actionPerformed(ActionEvent JavaDoc e)
99   {
100     _mgr.setRoles(_pnlEditor.getRoles());
101     setVisible(false);
102   }
103
104   public void _butCancel_actionPerformed(ActionEvent JavaDoc e)
105   {
106     setVisible(false);
107   }
108 }
109
110 class RoleEditorDialog__butCancel_actionAdapter implements ActionListener JavaDoc
111 {
112   private RoleEditorDialog adaptee;
113
114   RoleEditorDialog__butCancel_actionAdapter(RoleEditorDialog adaptee)
115   {
116     this.adaptee = adaptee;
117   }
118
119   public void actionPerformed(ActionEvent JavaDoc e)
120   {
121     adaptee._butCancel_actionPerformed(e);
122   }
123 }
124
125 class RoleEditorDialog__butOk_actionAdapter implements java.awt.event.ActionListener JavaDoc
126 {
127   RoleEditorDialog adaptee;
128
129   RoleEditorDialog__butOk_actionAdapter(RoleEditorDialog adaptee)
130   {
131     this.adaptee = adaptee;
132   }
133
134   public void actionPerformed(ActionEvent JavaDoc e)
135   {
136     adaptee._butOk_actionPerformed(e);
137   }
138 }
139
Popular Tags