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-2006 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: package org.netbeans.modules.apisupport.project.ui.wizard.javahelp;
043:
044: import javax.swing.JTextField;
045: import org.netbeans.api.project.ProjectUtils;
046: import org.netbeans.modules.apisupport.project.ui.UIUtil;
047: import org.netbeans.modules.apisupport.project.ui.wizard.BasicWizardIterator;
048: import org.openide.WizardDescriptor;
049: import org.openide.util.HelpCtx;
050: import org.openide.util.NbBundle;
051:
052: /**
053: * @author Radek Matous
054: */
055: final class JavaHelpPanel extends BasicWizardIterator.Panel {
056: private NewJavaHelpIterator.DataModel data;
057:
058: /** Creates new NameAndLocationPanel */
059: public JavaHelpPanel(final WizardDescriptor setting,
060: final NewJavaHelpIterator.DataModel data) {
061: super (setting);
062: this .data = data;
063: initComponents();
064: initAccessibility();
065: putClientProperty("NewFileWizard_Title",// NOI18N
066: NbBundle.getMessage(JavaHelpPanel.class,
067: "LBL_JavaHelpWizardTitle")); // NOI18N
068:
069: }
070:
071: protected void storeToDataModel() {
072: }
073:
074: protected void readFromDataModel() {
075: }
076:
077: private void updateData() {
078: createdFilesValue.setText(UIUtil.generateTextAreaContent(data
079: .getCreatedModifiedFiles().getCreatedPaths()));
080: modifiedFilesValue.setText(UIUtil.generateTextAreaContent(data
081: .getCreatedModifiedFiles().getModifiedPaths()));
082: //#68294 check if the paths for newly created files are valid or not..
083: String[] invalid = data.getCreatedModifiedFiles()
084: .getInvalidPaths();
085: if (invalid.length > 0) {
086: setError(NbBundle.getMessage(JavaHelpPanel.class,
087: "ERR_ToBeCreateFileExists", invalid[0]));//NOI18N
088: } else {
089: markValid();
090: }
091: }
092:
093: protected String getPanelName() {
094: return NbBundle.getMessage(JavaHelpPanel.class,
095: "LBL_JavaHelpPanel_Title"); // NOI18N
096: }
097:
098: protected HelpCtx getHelp() {
099: return new HelpCtx(JavaHelpPanel.class);
100: }
101:
102: private static String getMessage(String key) {
103: return NbBundle.getMessage(JavaHelpPanel.class, key);
104: }
105:
106: private void initAccessibility() {
107: this .getAccessibleContext().setAccessibleDescription(
108: getMessage("ACS_JavaHelpPanel"));//NOI18N
109: projectNameValue.getAccessibleContext()
110: .setAccessibleDescription(
111: getMessage("ACS_CTL_ProjectName"));//NOI18N
112: createdFilesValue.getAccessibleContext()
113: .setAccessibleDescription(
114: getMessage("ACS_CTL_CreatedFilesValue"));//NOI18N
115: modifiedFilesValue.getAccessibleContext()
116: .setAccessibleDescription(
117: getMessage("ACS_CTL_ModifiedFilesValue"));//NOI18N
118: }
119:
120: public void addNotify() {
121: super .addNotify();
122: updateData();
123: }
124:
125: /** This method is called from within the constructor to
126: * initialize the form.
127: * WARNING: Do NOT modify this code. The content of this method is
128: * always regenerated by the Form Editor.
129: */
130: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
131: private void initComponents() {
132: java.awt.GridBagConstraints gridBagConstraints;
133:
134: projectName = new javax.swing.JLabel();
135: projectNameValue = new JTextField(ProjectUtils.getInformation(
136: this .data.getProject()).getDisplayName());
137: createdFiles = new javax.swing.JLabel();
138: modifiedFiles = new javax.swing.JLabel();
139: createdFilesValueS = new javax.swing.JScrollPane();
140: createdFilesValue = new javax.swing.JTextArea();
141: modifiedFilesValueS = new javax.swing.JScrollPane();
142: modifiedFilesValue = new javax.swing.JTextArea();
143:
144: setLayout(new java.awt.GridBagLayout());
145:
146: projectName.setLabelFor(projectNameValue);
147: org.openide.awt.Mnemonics
148: .setLocalizedText(
149: projectName,
150: java.util.ResourceBundle
151: .getBundle(
152: "org/netbeans/modules/apisupport/project/ui/wizard/javahelp/Bundle")
153: .getString("LBL_ProjectName"));
154: gridBagConstraints = new java.awt.GridBagConstraints();
155: gridBagConstraints.gridx = 0;
156: gridBagConstraints.gridy = 0;
157: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
158: gridBagConstraints.insets = new java.awt.Insets(1, 0, 6, 12);
159: add(projectName, gridBagConstraints);
160:
161: projectNameValue.setEditable(false);
162: gridBagConstraints = new java.awt.GridBagConstraints();
163: gridBagConstraints.gridx = 1;
164: gridBagConstraints.gridy = 0;
165: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
166: gridBagConstraints.weightx = 1.0;
167: gridBagConstraints.insets = new java.awt.Insets(1, 0, 6, 0);
168: add(projectNameValue, gridBagConstraints);
169:
170: createdFiles.setLabelFor(createdFilesValue);
171: org.openide.awt.Mnemonics
172: .setLocalizedText(
173: createdFiles,
174: java.util.ResourceBundle
175: .getBundle(
176: "org/netbeans/modules/apisupport/project/ui/wizard/javahelp/Bundle")
177: .getString("LBL_CreatedFiles"));
178: gridBagConstraints = new java.awt.GridBagConstraints();
179: gridBagConstraints.gridx = 0;
180: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
181: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
182: gridBagConstraints.insets = new java.awt.Insets(36, 0, 6, 12);
183: add(createdFiles, gridBagConstraints);
184:
185: modifiedFiles.setLabelFor(modifiedFilesValue);
186: org.openide.awt.Mnemonics
187: .setLocalizedText(
188: modifiedFiles,
189: java.util.ResourceBundle
190: .getBundle(
191: "org/netbeans/modules/apisupport/project/ui/wizard/javahelp/Bundle")
192: .getString("LBL_ModifiedFiles"));
193: gridBagConstraints = new java.awt.GridBagConstraints();
194: gridBagConstraints.gridx = 0;
195: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
196: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
197: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 12);
198: add(modifiedFiles, gridBagConstraints);
199:
200: createdFilesValue.setBackground(javax.swing.UIManager
201: .getDefaults().getColor("Label.background"));
202: createdFilesValue.setColumns(20);
203: createdFilesValue.setEditable(false);
204: createdFilesValue.setRows(5);
205: createdFilesValue.setBorder(null);
206: createdFilesValueS.setViewportView(createdFilesValue);
207:
208: gridBagConstraints = new java.awt.GridBagConstraints();
209: gridBagConstraints.gridx = 1;
210: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
211: gridBagConstraints.weightx = 1.0;
212: gridBagConstraints.weighty = 1.0;
213: gridBagConstraints.insets = new java.awt.Insets(36, 0, 6, 0);
214: add(createdFilesValueS, gridBagConstraints);
215:
216: modifiedFilesValue.setBackground(javax.swing.UIManager
217: .getDefaults().getColor("Label.background"));
218: modifiedFilesValue.setColumns(20);
219: modifiedFilesValue.setEditable(false);
220: modifiedFilesValue.setRows(5);
221: modifiedFilesValue.setToolTipText("modifiedFilesValue");
222: modifiedFilesValue.setBorder(null);
223: modifiedFilesValueS.setViewportView(modifiedFilesValue);
224:
225: gridBagConstraints = new java.awt.GridBagConstraints();
226: gridBagConstraints.gridx = 1;
227: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
228: gridBagConstraints.weightx = 1.0;
229: add(modifiedFilesValueS, gridBagConstraints);
230:
231: }// </editor-fold>//GEN-END:initComponents
232:
233: // Variables declaration - do not modify//GEN-BEGIN:variables
234: private javax.swing.JLabel createdFiles;
235: private javax.swing.JTextArea createdFilesValue;
236: private javax.swing.JScrollPane createdFilesValueS;
237: private javax.swing.JLabel modifiedFiles;
238: private javax.swing.JTextArea modifiedFilesValue;
239: private javax.swing.JScrollPane modifiedFilesValueS;
240: private javax.swing.JLabel projectName;
241: private javax.swing.JTextField projectNameValue;
242: // End of variables declaration//GEN-END:variables
243:
244: }
|