001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041: /*
042: * ExportDataSourcesDialog.java
043: *
044: * Created on March 8, 2004, 12:09 PM
045: */
046:
047: package org.netbeans.modules.visualweb.ejb.ui;
048:
049: import java.awt.BorderLayout;
050: import javax.swing.*;
051:
052: /**
053: * A panle to allow the user to export EJB datasources to a jar file
054: *
055: * @author dongmei cao
056: */
057: public class ExportEjbDataSourcesPanel extends JPanel {
058:
059: private EjbDataSourcesSelectionPanel ejbDataSourceSelectionPanel;
060: private EjbDataSourcePropertiesPanel propsPanel;
061:
062: public ExportEjbDataSourcesPanel() {
063: initComponents();
064:
065: propsPanel = new EjbDataSourcePropertiesPanel();
066: ejbDataSourceSelectionPanel = new EjbDataSourcesSelectionPanel(
067: propsPanel);
068:
069: selectionPanel.add(ejbDataSourceSelectionPanel,
070: BorderLayout.CENTER);
071: propertiesPanel.add(propsPanel, BorderLayout.CENTER);
072: fileNameText.setText(ImportExportFileChooser.defaultFilePath);
073: }
074:
075: public void setEjbDataSources(PortableEjbDataSource[] ejbDataSources) {
076: ejbDataSourceSelectionPanel.setEjbDataSources(ejbDataSources);
077: }
078:
079: public String getFilePath() {
080: return fileNameText.getText().trim();
081: }
082:
083: public boolean saveChange() {
084: return propsPanel.saveChange();
085: }
086:
087: /** This method is called from within the constructor to
088: * initialize the form.
089: * WARNING: Do NOT modify this code. The content of this method is
090: * always regenerated by the Form Editor.
091: */
092: private void initComponents() {//GEN-BEGIN:initComponents
093: java.awt.GridBagConstraints gridBagConstraints;
094:
095: title = new javax.swing.JLabel();
096: selectionPanel = new javax.swing.JPanel();
097: filePanel = new javax.swing.JPanel();
098: fileNameLabel = new javax.swing.JLabel();
099: fileNameText = new javax.swing.JTextField();
100: browseButton = new javax.swing.JButton();
101: propertiesPanel = new javax.swing.JPanel();
102:
103: setLayout(new java.awt.GridBagLayout());
104:
105: getAccessibleContext().setAccessibleName(
106: org.openide.util.NbBundle.getMessage(
107: ExportEjbDataSourcesPanel.class,
108: "EXPORT_EJB_DATASOURCES"));
109: getAccessibleContext().setAccessibleDescription(
110: org.openide.util.NbBundle.getMessage(
111: ExportEjbDataSourcesPanel.class,
112: "EXPORT_EJB_DATASOURCES"));
113: title.setLabelFor(selectionPanel);
114: title.setText(java.util.ResourceBundle.getBundle(
115: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
116: .getString("EXPORT_TITLE"));
117: title.setPreferredSize(null);
118: gridBagConstraints = new java.awt.GridBagConstraints();
119: gridBagConstraints.gridwidth = 3;
120: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
121: gridBagConstraints.insets = new java.awt.Insets(10, 10, 0, 0);
122: add(title, gridBagConstraints);
123: title.getAccessibleContext().setAccessibleDescription(
124: java.util.ResourceBundle.getBundle(
125: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
126: .getString("EXPORT_TITLE"));
127:
128: selectionPanel.setLayout(new java.awt.BorderLayout());
129:
130: selectionPanel.setBorder(new javax.swing.border.EmptyBorder(
131: new java.awt.Insets(5, 10, 10, 10)));
132: selectionPanel.setVerifyInputWhenFocusTarget(false);
133: gridBagConstraints = new java.awt.GridBagConstraints();
134: gridBagConstraints.gridx = 0;
135: gridBagConstraints.gridy = 4;
136: gridBagConstraints.gridwidth = 2;
137: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
138: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
139: gridBagConstraints.weightx = 0.5;
140: gridBagConstraints.weighty = 1.0;
141: gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
142: add(selectionPanel, gridBagConstraints);
143:
144: filePanel.setLayout(new java.awt.BorderLayout(5, 1));
145:
146: filePanel.setBorder(new javax.swing.border.EmptyBorder(
147: new java.awt.Insets(5, 10, 10, 10)));
148: fileNameLabel.setDisplayedMnemonic(org.openide.util.NbBundle
149: .getMessage(ExportEjbDataSourcesPanel.class,
150: "FILE_NAME_MNEMONIC").charAt(0));
151: fileNameLabel.setLabelFor(fileNameText);
152: fileNameLabel.setText(java.util.ResourceBundle.getBundle(
153: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
154: .getString("FILE_NAME"));
155: filePanel.add(fileNameLabel, java.awt.BorderLayout.WEST);
156: fileNameLabel.getAccessibleContext().setAccessibleDescription(
157: java.util.ResourceBundle.getBundle(
158: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
159: .getString("FILE_NAME_DESC"));
160:
161: filePanel.add(fileNameText, java.awt.BorderLayout.CENTER);
162: fileNameText.getAccessibleContext().setAccessibleDescription(
163: java.util.ResourceBundle.getBundle(
164: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
165: .getString("FILE_NAME_DESC"));
166:
167: browseButton.setMnemonic(java.util.ResourceBundle.getBundle(
168: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
169: .getString("BROWSE_EXPORT_FILE_BUTTON_MNEMONIC")
170: .charAt(0));
171: browseButton.setText(java.util.ResourceBundle.getBundle(
172: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
173: .getString("BROWSE_EXPORT_FILE_BUTTON_LABEL"));
174: browseButton.setToolTipText("");
175: browseButton
176: .addActionListener(new java.awt.event.ActionListener() {
177: public void actionPerformed(
178: java.awt.event.ActionEvent evt) {
179: browseButtonActionPerformed(evt);
180: }
181: });
182:
183: filePanel.add(browseButton, java.awt.BorderLayout.EAST);
184: browseButton.getAccessibleContext().setAccessibleDescription(
185: java.util.ResourceBundle.getBundle(
186: "org/netbeans/modules/visualweb/ejb/ui/Bundle")
187: .getString("BROWSE_EXPORT_FILE_BUTTON_DESC"));
188:
189: gridBagConstraints = new java.awt.GridBagConstraints();
190: gridBagConstraints.gridx = 0;
191: gridBagConstraints.gridy = 6;
192: gridBagConstraints.gridwidth = 3;
193: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
194: gridBagConstraints.insets = new java.awt.Insets(17, 0, 0, 0);
195: add(filePanel, gridBagConstraints);
196:
197: propertiesPanel.setLayout(new java.awt.BorderLayout());
198:
199: propertiesPanel.setMinimumSize(new java.awt.Dimension(0, 0));
200: gridBagConstraints = new java.awt.GridBagConstraints();
201: gridBagConstraints.gridx = 2;
202: gridBagConstraints.gridy = 4;
203: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
204: gridBagConstraints.weightx = 1.0;
205: gridBagConstraints.weighty = 1.0;
206: gridBagConstraints.insets = new java.awt.Insets(12, 17, 0, 12);
207: add(propertiesPanel, gridBagConstraints);
208:
209: }//GEN-END:initComponents
210:
211: private void browseButtonActionPerformed(
212: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
213:
214: // Select a file to expoprt the EJB datasources to
215:
216: ImportExportFileChooser fileChooser = new ImportExportFileChooser(
217: this );
218: String selectedFile = fileChooser.getExportFile();
219: if (selectedFile != null) {
220: fileChooser.setCurrentFilePath(selectedFile);
221: fileNameText.setText(selectedFile);
222: }
223: }//GEN-LAST:event_browseButtonActionPerformed
224:
225: // Variables declaration - do not modify//GEN-BEGIN:variables
226: private javax.swing.JButton browseButton;
227: private javax.swing.JLabel fileNameLabel;
228: private javax.swing.JTextField fileNameText;
229: private javax.swing.JPanel filePanel;
230: private javax.swing.JPanel propertiesPanel;
231: private javax.swing.JPanel selectionPanel;
232: private javax.swing.JLabel title;
233: // End of variables declaration//GEN-END:variables
234:
235: }
|