KickJava   Java API By Example, From Geeks To Geeks.

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


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.Frame JavaDoc;
35 import java.awt.Toolkit JavaDoc;
36 import java.awt.event.ActionEvent JavaDoc;
37 import java.util.ArrayList JavaDoc;
38 import java.util.Arrays JavaDoc;
39
40 import javax.swing.JButton JavaDoc;
41 import javax.swing.JDialog JavaDoc;
42 import javax.swing.JPanel JavaDoc;
43 import javax.swing.JTabbedPane JavaDoc;
44
45 import com.genimen.djeneric.language.Messages;
46 import com.genimen.djeneric.structure.EditorDefinition;
47 import com.genimen.djeneric.structure.ResourceDefinition;
48 import com.genimen.djeneric.structure.ScriptDefinition;
49 import com.genimen.djeneric.ui.Util;
50 import com.genimen.djeneric.util.DjLogger;
51
52 public class MergeViewDialog extends JDialog JavaDoc
53 {
54   private static final long serialVersionUID = 1L;
55   JPanel JavaDoc panel1 = new JPanel JavaDoc();
56   BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
57   JPanel JavaDoc jPanel1 = new JPanel JavaDoc();
58   JButton JavaDoc _butOk = new JButton JavaDoc();
59   JPanel JavaDoc jPanel4 = new JPanel JavaDoc();
60   BorderLayout JavaDoc borderLayout2 = new BorderLayout JavaDoc();
61   JButton JavaDoc _butCancel = new JButton JavaDoc();
62   BorderLayout JavaDoc borderLayout3 = new BorderLayout JavaDoc();
63   JPanel JavaDoc jPanel3 = new JPanel JavaDoc();
64   boolean _canceled = true;
65   JTabbedPane JavaDoc jTabbedPane1 = new JTabbedPane JavaDoc();
66   SelectionPanel _pnlEditors = new SelectionPanel();
67   SelectionPanel _pnlResources = new SelectionPanel();
68   SelectionPanel _pnlScripts = new SelectionPanel();
69
70   public MergeViewDialog(Frame JavaDoc frame, EditorDefinition[] editors, ResourceDefinition[] resources,
71                          ScriptDefinition[] scripts)
72   {
73     super(frame, Messages.getString("MergeViewDialog.MergeView"), true); //$NON-NLS-1$
74
try
75     {
76       jbInit();
77       _pnlEditors.setAvailable(Arrays.asList(editors));
78       _pnlResources.setAvailable(Arrays.asList(resources));
79       _pnlScripts.setAvailable(Arrays.asList(scripts));
80
81       setSize(new Dimension JavaDoc(544, 400));
82
83       Dimension JavaDoc screenSize = Toolkit.getDefaultToolkit().getScreenSize();
84       Dimension JavaDoc frameSize = getSize();
85       setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2);
86
87       setVisible(true);
88     }
89     catch (Exception JavaDoc ex)
90     {
91       DjLogger.log(ex);
92     }
93   }
94
95   public ArrayList JavaDoc getSelectedEditors()
96   {
97     return _pnlEditors.getSelection();
98   }
99
100   public ArrayList JavaDoc getSelectedResources()
101   {
102     return _pnlResources.getSelection();
103   }
104
105   public ArrayList JavaDoc getSelectedScripts()
106   {
107     return _pnlScripts.getSelection();
108   }
109
110   private void jbInit() throws Exception JavaDoc
111   {
112     panel1.setLayout(borderLayout1);
113     jPanel1.setLayout(borderLayout2);
114     _butOk.setText(Messages.getString("global.Ok")); //$NON-NLS-1$
115
_butOk.addActionListener(new java.awt.event.ActionListener JavaDoc()
116     {
117       public void actionPerformed(ActionEvent JavaDoc e)
118       {
119         _butOk_actionPerformed(e);
120       }
121     });
122     _butCancel.setText(Messages.getString("global.Cancel")); //$NON-NLS-1$
123
_butCancel.addActionListener(new java.awt.event.ActionListener JavaDoc()
124     {
125       public void actionPerformed(ActionEvent JavaDoc e)
126       {
127         _butCancel_actionPerformed(e);
128       }
129     });
130     jPanel3.setLayout(borderLayout3);
131     getContentPane().add(panel1);
132     panel1.add(jPanel1, BorderLayout.SOUTH);
133     jPanel1.add(jPanel3, BorderLayout.SOUTH);
134     jPanel3.add(jPanel4, BorderLayout.EAST);
135     jPanel4.add(_butCancel, null);
136     jPanel4.add(_butOk, null);
137     panel1.add(jTabbedPane1, BorderLayout.CENTER);
138     jTabbedPane1.add(_pnlEditors, Messages.getString("MergeViewDialog.Editors")); //$NON-NLS-1$
139
jTabbedPane1.add(_pnlResources, Messages.getString("MergeViewDialog.Resources")); //$NON-NLS-1$
140
jTabbedPane1.add(_pnlScripts, Messages.getString("MergeViewDialog.Scripts")); //$NON-NLS-1$
141
Util.sizeButtons(jPanel4);
142   }
143
144   public boolean wasCanceled()
145   {
146     return _canceled;
147   }
148
149   void _butCancel_actionPerformed(ActionEvent JavaDoc e)
150   {
151     setVisible(false);
152   }
153
154   void _butOk_actionPerformed(ActionEvent JavaDoc e)
155   {
156     _canceled = false;
157     setVisible(false);
158   }
159
160 }
Popular Tags