KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > apisupport > project > ui > customizer > SuiteCustomizerSplashBranding


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.apisupport.project.ui.customizer;
21
22 import java.awt.Image JavaDoc;
23 import java.awt.Rectangle JavaDoc;
24 import java.beans.PropertyChangeEvent JavaDoc;
25 import java.beans.PropertyChangeListener JavaDoc;
26 import java.io.File JavaDoc;
27 import java.net.MalformedURLException JavaDoc;
28 import java.net.URL JavaDoc;
29 import java.text.ParseException JavaDoc;
30 import java.util.Locale JavaDoc;
31 import javax.swing.JFileChooser JavaDoc;
32 import javax.swing.JFormattedTextField JavaDoc;
33 import javax.swing.event.ChangeEvent JavaDoc;
34 import javax.swing.event.ChangeListener JavaDoc;
35 import javax.swing.event.DocumentEvent JavaDoc;
36 import org.netbeans.modules.apisupport.project.ui.UIUtil;
37 import org.netbeans.spi.project.ui.support.ProjectCustomizer;
38 import org.openide.ErrorManager;
39 import org.openide.util.NbBundle;
40
41 /**
42  * Represents <em>Splash branding parameters</em> panel in Suite customizer.
43  *
44  * @author Radek Matous
45  */

46 public class SuiteCustomizerSplashBranding extends NbPropertyPanel.Suite {
47     
48     private SplashComponentPreview splashImage;
49     private JFormattedTextField JavaDoc fontSize;
50     private JFormattedTextField JavaDoc runningTextBounds;
51     private JFormattedTextField JavaDoc progressBarBounds;
52     private SplashUISupport.ColorComboBox textColor;
53     private SplashUISupport.ColorComboBox barColor;
54     private SplashUISupport.ColorComboBox edgeColor;
55     private SplashUISupport.ColorComboBox cornerColor;
56     
57     private URL JavaDoc splashSource;
58     private ProjectCustomizer.Category cat;
59     /**
60      * Creates new form SuiteCustomizerLibraries
61      */

62     public SuiteCustomizerSplashBranding(final SuiteProperties suiteProps, final ProjectCustomizer.Category cat) {
63         super(suiteProps, SuiteCustomizerSplashBranding.class);
64         this.cat = cat;
65         BasicBrandingModel branding = getBrandingModel();
66         branding.addChangeListener(new ChangeListener JavaDoc() {
67             public void stateChanged(ChangeEvent JavaDoc e) {
68                 enableDisableComponents();
69             }
70         });
71         
72         splashImage =new SplashComponentPreview();
73         fontSize = SplashUISupport.getIntegerField();
74         runningTextBounds = SplashUISupport.getBoundsField();
75         progressBarBounds = SplashUISupport.getBoundsField();
76         textColor = SplashUISupport.getColorComboBox();
77         barColor = SplashUISupport.getColorComboBox();
78         edgeColor = SplashUISupport.getColorComboBox();
79         cornerColor = SplashUISupport.getColorComboBox();
80         splashImage.setDropHandletForProgress(new DragManager.DropHandler(){
81             public void dragAccepted(Rectangle JavaDoc original, Rectangle JavaDoc afterDrag) {
82                 progressBarBounds.setValue(afterDrag);
83             }
84         });
85         
86         splashImage.setDropHandletForText(new DragManager.DropHandler(){
87             public void dragAccepted(Rectangle JavaDoc original, Rectangle JavaDoc afterDrag) {
88                 runningTextBounds.setValue(afterDrag);
89                 double ratio = ((double)afterDrag.height)/original.height;
90                 int size = (int)((((Number JavaDoc)fontSize.getValue()).intValue()*ratio));
91                 size = (size > 0) ? size : 3;
92                 fontSize.setValue(new Integer JavaDoc(size));
93             }
94         });
95         
96         initComponents();
97         refresh();
98         
99         PropertyChangeListener JavaDoc pL = new PropertyChangeListener JavaDoc() {
100             public void propertyChange(PropertyChangeEvent JavaDoc evt) {
101                 if (evt.getPropertyName() != SplashUISupport.ColorComboBox.PROP_COLOR) {
102                     return;
103                 }
104                 resetSplashPreview();
105             }
106         };
107         textColor.addPropertyChangeListener(pL);
108         barColor.addPropertyChangeListener(pL);
109         edgeColor.addPropertyChangeListener(pL);
110         cornerColor.addPropertyChangeListener(pL);
111         
112         fontSize.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
113             
114             public void insertUpdate(DocumentEvent JavaDoc e) {
115                 if (e != null || fontSize.isFocusOwner()) {
116                     try {
117                         fontSize.commitEdit();
118                         ((Number JavaDoc) fontSize.getValue()).intValue();
119                         cat.setErrorMessage(null);
120                         cat.setValid(true);
121                         resetSplashPreview();
122                     } catch (ParseException JavaDoc ex) {
123                         //user's invalide input
124
cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidFontSize"));
125                         cat.setValid(false);
126                     }
127                 }
128             }
129         });
130         
131         runningTextBounds.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
132             public void insertUpdate(DocumentEvent JavaDoc e) {
133                 if (e != null || runningTextBounds.isFocusOwner()) {
134                     try {
135                         runningTextBounds.commitEdit();
136                         cat.setErrorMessage(null);
137                         cat.setValid(true);
138                         resetSplashPreview();
139                     } catch (ParseException JavaDoc ex) {
140                         //user's invalide input
141
cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidTextBounds"));
142                         cat.setValid(false);
143                     }
144                 }
145             }
146         });
147         
148         progressBarBounds.getDocument().addDocumentListener(new UIUtil.DocumentAdapter() {
149             public void insertUpdate(DocumentEvent JavaDoc e) {
150                 if (e != null || progressBarBounds.isFocusOwner()) {
151                     try {
152                         progressBarBounds.commitEdit();
153                         cat.setErrorMessage(null);
154                         cat.setValid(true);
155                         resetSplashPreview();
156                     } catch (ParseException JavaDoc ex) {
157                         //user's invalide input
158
cat.setErrorMessage(NbBundle.getMessage(SuiteCustomizerSplashBranding.class, "ERR_InvalidProgressBarBounds"));
159                         cat.setValid(false);
160                     }
161                 }
162             }
163         });
164         
165     }
166     
167     
168     public void store() {
169         BasicBrandingModel branding = getBrandingModel();
170         
171         branding.getSplashRunningTextFontSize().setValue(SplashUISupport.integerToString(((Number JavaDoc)fontSize.getValue()).intValue()));
172         branding.getSplashRunningTextBounds().setValue(SplashUISupport.boundsToString((Rectangle JavaDoc)runningTextBounds.getValue()));
173         branding.getSplashProgressBarBounds().setValue(SplashUISupport.boundsToString((Rectangle JavaDoc)progressBarBounds.getValue()));
174         branding.getSplashRunningTextColor().setValue(SplashUISupport.colorToString(textColor.getColor()));
175         branding.getSplashProgressBarColor().setValue(SplashUISupport.colorToString(barColor.getColor()));
176         //these colors below has a little effect on resulting branded splash
177
//then user can't adjust it from UI
178
//edgeColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarEdgeColor().getValue()));
179
//cornerColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarCornerColor().getValue()));
180

181         branding.getSplashShowProgressBar().setValue(Boolean.toString(progressBarEnabled.isSelected()));
182         branding.getSplash().setBrandingSource(splashSource);
183         
184         branding.getSplashWidth().setValue(Integer.toString(splashImage.image.getWidth(null),10));
185         branding.getSplashHeight().setValue(Integer.toString(splashImage.image.getHeight(null),10));
186     }
187     
188     
189     void refresh() {
190         BasicBrandingModel branding = getBrandingModel();
191         
192         fontSize.setValue(new Integer JavaDoc(SplashUISupport.stringToInteger(branding.getSplashRunningTextFontSize().getValue())));
193         runningTextBounds.setValue(SplashUISupport.stringToBounds(branding.getSplashRunningTextBounds().getValue()));
194         progressBarBounds.setValue(SplashUISupport.stringToBounds(branding.getSplashProgressBarBounds().getValue()));
195         textColor.setColor(SplashUISupport.stringToColor(branding.getSplashRunningTextColor().getValue()));
196         barColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarColor().getValue()));//
197
edgeColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarEdgeColor().getValue()));
198         cornerColor.setColor(SplashUISupport.stringToColor(branding.getSplashProgressBarCornerColor().getValue()));
199         progressBarEnabled.setSelected(getBrandingModel().getSplashShowProgressBar().getValue().trim().toLowerCase(Locale.ENGLISH).equals("true")); // NOI18N
200

201         splashSource = getBrandingModel().getSplash().getBrandingSource();
202         resetSplashPreview();
203         
204         splashImage.setMaxSteps(10);
205         //splashImage.increment(10);
206
splashImage.resetSteps();
207         splashImage.setText(NbBundle.getMessage(getClass(),"TEXT_SplashSample"));
208         
209         enableDisableComponents();
210         
211     }
212     
213     private void enableDisableComponents() {
214         final BasicBrandingModel branding = getBrandingModel();
215         jLabel1.setEnabled(branding.isBrandingEnabled());
216         jLabel2.setEnabled(branding.isBrandingEnabled());
217         fontSize.setEnabled(branding.isBrandingEnabled());
218         runningTextBounds.setEnabled(branding.isBrandingEnabled());
219         progressBarBounds.setEnabled(branding.isBrandingEnabled());
220         textColor.setEnabled(branding.isBrandingEnabled());
221         barColor.setEnabled(branding.isBrandingEnabled());
222         edgeColor.setEnabled(branding.isBrandingEnabled());
223         cornerColor.setEnabled(branding.isBrandingEnabled());
224         progressBarEnabled.setEnabled(branding.isBrandingEnabled());
225         splashImage.setEnabled(branding.isBrandingEnabled());
226         barBoundsLabel.setEnabled(branding.isBrandingEnabled());
227         barColorLabel.setEnabled(branding.isBrandingEnabled());
228         browse.setEnabled(branding.isBrandingEnabled());
229         splashLabel.setEnabled(branding.isBrandingEnabled());
230         splashPreview.setEnabled(branding.isBrandingEnabled());
231         textBoundsLabel.setEnabled(branding.isBrandingEnabled());
232         textColorLabel.setEnabled(branding.isBrandingEnabled());
233         textFontSizeLabel.setEnabled(branding.isBrandingEnabled());
234         splashImage.setEnabled(branding.isBrandingEnabled());
235     }
236     
237     private void resetSplashPreview() throws NumberFormatException JavaDoc {
238         splashImage.setSplashImageIcon(splashSource);
239         Rectangle JavaDoc tRectangle = (Rectangle JavaDoc)runningTextBounds.getValue();
240         Rectangle JavaDoc pRectangle = (Rectangle JavaDoc)progressBarBounds.getValue();
241         splashImage.setTextColor(textColor.getColor());
242         splashImage.setColorBar(barColor.getColor());
243         splashImage.setColorEdge(edgeColor.getColor());
244         splashImage.setColorEdge(cornerColor.getColor());
245         splashImage.setFontSize(((Number JavaDoc)fontSize.getValue()).intValue());
246         splashImage.setRunningTextBounds(tRectangle);
247         splashImage.setProgressBarBounds(pRectangle);
248         splashImage.setProgressBarEnabled(progressBarEnabled.isSelected());
249         splashImage.resetSteps();
250         splashImage.setText(NbBundle.getMessage(getClass(),"TEXT_SplashSample"));
251     }
252     
253     /** This method is called from within the constructor to
254      * initialize the form.
255      * WARNING: Do NOT modify this code. The content of this method is
256      * always regenerated by the Form Editor.
257      */

258     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
259
private void initComponents() {
260         javax.swing.JComboBox JavaDoc barColor;
261         javax.swing.JTextField JavaDoc fontSize;
262         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
263         javax.swing.JTextField JavaDoc jTextField1;
264         javax.swing.JTextField JavaDoc jTextField4;
265         javax.swing.JComboBox JavaDoc textColor;
266
267         barColor = this.barColor;
268         jTextField1 = this.progressBarBounds;
269         barColorLabel = new javax.swing.JLabel JavaDoc();
270         barBoundsLabel = new javax.swing.JLabel JavaDoc();
271         textColorLabel = new javax.swing.JLabel JavaDoc();
272         textColor = this.textColor;
273         jTextField4 = this.runningTextBounds;
274         fontSize = this.fontSize;
275         progressBarEnabled = new javax.swing.JCheckBox JavaDoc();
276         textFontSizeLabel = new javax.swing.JLabel JavaDoc();
277         textBoundsLabel = new javax.swing.JLabel JavaDoc();
278         jLabel1 = new javax.swing.JLabel JavaDoc();
279         jLabel2 = new javax.swing.JLabel JavaDoc();
280         jPanel1 = new javax.swing.JPanel JavaDoc();
281         splashLabel = new javax.swing.JLabel JavaDoc();
282         jScrollPane1 = new javax.swing.JScrollPane JavaDoc();
283         splashPreview = splashImage;
284         browse = new javax.swing.JButton JavaDoc();
285
286         setLayout(new java.awt.GridBagLayout JavaDoc());
287
288         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
289         gridBagConstraints.gridx = 3;
290         gridBagConstraints.gridy = 1;
291         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
292         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
293         gridBagConstraints.weightx = 1.0;
294         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
295         add(barColor, gridBagConstraints);
296
297         jTextField1.setInputVerifier(jTextField1.getInputVerifier());
298         jTextField1.setVerifyInputWhenFocusTarget(false);
299         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
300         gridBagConstraints.gridx = 5;
301         gridBagConstraints.gridy = 1;
302         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
303         gridBagConstraints.ipadx = 10;
304         gridBagConstraints.weightx = 1.0;
305         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
306         add(jTextField1, gridBagConstraints);
307
308         barColorLabel.setLabelFor(barColor);
309         org.openide.awt.Mnemonics.setLocalizedText(barColorLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_BarColor"));
310         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
311         gridBagConstraints.gridx = 2;
312         gridBagConstraints.gridy = 1;
313         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
314         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
315         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
316         add(barColorLabel, gridBagConstraints);
317         barColorLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_BarColor"));
318
319         barBoundsLabel.setLabelFor(jTextField1);
320         org.openide.awt.Mnemonics.setLocalizedText(barBoundsLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_BarBounds"));
321         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
322         gridBagConstraints.gridx = 4;
323         gridBagConstraints.gridy = 1;
324         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
325         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
326         add(barBoundsLabel, gridBagConstraints);
327         barBoundsLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_BarBounds"));
328
329         textColorLabel.setLabelFor(textColor);
330         org.openide.awt.Mnemonics.setLocalizedText(textColorLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextColor"));
331         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
332         gridBagConstraints.gridx = 2;
333         gridBagConstraints.gridy = 3;
334         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
335         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
336         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
337         add(textColorLabel, gridBagConstraints);
338         textColorLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_TextColor"));
339
340         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
341         gridBagConstraints.gridx = 3;
342         gridBagConstraints.gridy = 3;
343         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
344         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
345         gridBagConstraints.weightx = 1.0;
346         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
347         add(textColor, gridBagConstraints);
348
349         jTextField4.setInputVerifier(jTextField1.getInputVerifier());
350         jTextField4.setVerifyInputWhenFocusTarget(false);
351         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
352         gridBagConstraints.gridx = 5;
353         gridBagConstraints.gridy = 3;
354         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
355         gridBagConstraints.ipadx = 10;
356         gridBagConstraints.weightx = 1.0;
357         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
358         add(jTextField4, gridBagConstraints);
359
360         fontSize.setInputVerifier(jTextField1.getInputVerifier());
361         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
362         gridBagConstraints.gridx = 1;
363         gridBagConstraints.gridy = 3;
364         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
365         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
366         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 12);
367         add(fontSize, gridBagConstraints);
368
369         org.openide.awt.Mnemonics.setLocalizedText(progressBarEnabled, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_ProgressBarEnabled"));
370         progressBarEnabled.setBorder(javax.swing.BorderFactory.createEmptyBorder(0, 0, 0, 0));
371         progressBarEnabled.setMargin(new java.awt.Insets JavaDoc(0, 0, 0, 0));
372         progressBarEnabled.addActionListener(new java.awt.event.ActionListener JavaDoc() {
373             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
374                 progressBarEnabledActionPerformed(evt);
375             }
376         });
377
378         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
379         gridBagConstraints.gridx = 0;
380         gridBagConstraints.gridy = 1;
381         gridBagConstraints.gridwidth = 2;
382         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
383         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
384         gridBagConstraints.weightx = 1.0;
385         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 1, 0, 12);
386         add(progressBarEnabled, gridBagConstraints);
387         progressBarEnabled.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_ProgressEnabled"));
388
389         textFontSizeLabel.setLabelFor(fontSize);
390         org.openide.awt.Mnemonics.setLocalizedText(textFontSizeLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextFontSize"));
391         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
392         gridBagConstraints.gridx = 0;
393         gridBagConstraints.gridy = 3;
394         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
395         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
396         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
397         add(textFontSizeLabel, gridBagConstraints);
398         textFontSizeLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_FontSize"));
399
400         textBoundsLabel.setLabelFor(jTextField4);
401         org.openide.awt.Mnemonics.setLocalizedText(textBoundsLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_TextBounds"));
402         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
403         gridBagConstraints.gridx = 4;
404         gridBagConstraints.gridy = 3;
405         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
406         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
407         add(textBoundsLabel, gridBagConstraints);
408         textBoundsLabel.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_TextBounds"));
409
410         org.openide.awt.Mnemonics.setLocalizedText(jLabel1, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_ProgressBar"));
411         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
412         gridBagConstraints.gridx = 0;
413         gridBagConstraints.gridy = 0;
414         gridBagConstraints.gridwidth = 6;
415         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
416         gridBagConstraints.anchor = java.awt.GridBagConstraints.SOUTHWEST;
417         gridBagConstraints.weightx = 1.0;
418         add(jLabel1, gridBagConstraints);
419
420         org.openide.awt.Mnemonics.setLocalizedText(jLabel2, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_RunningText"));
421         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
422         gridBagConstraints.gridx = 0;
423         gridBagConstraints.gridy = 2;
424         gridBagConstraints.gridwidth = 6;
425         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
426         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
427         gridBagConstraints.weightx = 1.0;
428         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
429         add(jLabel2, gridBagConstraints);
430
431         jPanel1.setLayout(new java.awt.GridBagLayout JavaDoc());
432
433         org.openide.awt.Mnemonics.setLocalizedText(splashLabel, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_Splash"));
434         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
435         gridBagConstraints.gridx = 0;
436         gridBagConstraints.gridy = 0;
437         gridBagConstraints.gridwidth = 2;
438         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
439         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
440         gridBagConstraints.weightx = 1.0;
441         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
442         jPanel1.add(splashLabel, gridBagConstraints);
443
444         jScrollPane1.setBorder(null);
445         jScrollPane1.setViewportView(splashPreview);
446
447         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
448         gridBagConstraints.gridx = 0;
449         gridBagConstraints.gridy = 1;
450         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
451         gridBagConstraints.ipadx = 20;
452         gridBagConstraints.weightx = 1.0;
453         gridBagConstraints.weighty = 1.0;
454         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 12);
455         jPanel1.add(jScrollPane1, gridBagConstraints);
456
457         org.openide.awt.Mnemonics.setLocalizedText(browse, java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("LBL_Browse"));
458         browse.addActionListener(new java.awt.event.ActionListener JavaDoc() {
459             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
460                 browseActionPerformed(evt);
461             }
462         });
463
464         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
465         gridBagConstraints.gridx = 1;
466         gridBagConstraints.gridy = 1;
467         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
468         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST;
469         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
470         jPanel1.add(browse, gridBagConstraints);
471         browse.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/apisupport/project/ui/customizer/Bundle").getString("ACS_SplashBrowse"));
472
473         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
474         gridBagConstraints.gridx = 0;
475         gridBagConstraints.gridy = 4;
476         gridBagConstraints.gridwidth = 6;
477         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
478         gridBagConstraints.weightx = 1.0;
479         gridBagConstraints.weighty = 1.0;
480         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
481         add(jPanel1, gridBagConstraints);
482
483     }// </editor-fold>//GEN-END:initComponents
484

485     private void browseActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseActionPerformed
486
JFileChooser JavaDoc chooser = UIUtil.getIconFileChooser();
487         int ret = chooser.showDialog(this, NbBundle.getMessage(getClass(), "LBL_Select")); // NOI18N
488
if (ret == JFileChooser.APPROVE_OPTION) {
489             File JavaDoc file = chooser.getSelectedFile();
490             try {
491                 splashSource = file.toURI().toURL();
492                 Image JavaDoc oldImage = splashImage.image;
493                 splashImage.setSplashImageIcon(splashSource);
494                 Image JavaDoc newImage = splashImage.image;
495                 int newWidth = newImage.getWidth(null);
496                 int newHeight = newImage.getHeight(null);
497                 int oldWidth = oldImage.getWidth(null);
498                 int oldHeight = oldImage.getHeight(null);
499                 if (newWidth != oldWidth || newHeight != oldHeight) {
500                     double xRatio = newWidth / ((double) oldWidth);
501                     double yRatio = newHeight / ((double) oldHeight);
502                     Rectangle JavaDoc tRectangle = (Rectangle JavaDoc)runningTextBounds.getValue();
503                     Rectangle JavaDoc pRectangle = (Rectangle JavaDoc)progressBarBounds.getValue();
504                     
505                     int x = ((int)(tRectangle.x*xRatio));
506                     int y = ((int)(tRectangle.y*yRatio));
507                     int width = ((int)(tRectangle.width*xRatio));
508                     int height = ((int)(tRectangle.height*xRatio));
509                     width = (width <= 0) ? 2 : width;
510                     height = (height <= 0) ? 2 : height;
511                     tRectangle.setBounds(x,y,width,height);
512                     
513                     x = ((int)(pRectangle.x*xRatio));
514                     y = ((int)(pRectangle.y*yRatio));
515                     width = ((int)(pRectangle.width*xRatio));
516                     height = ((int)(pRectangle.height*xRatio));
517                     width = (width <= 6) ? 6 : width;
518                     height = (height <= 6) ? 6 : height;
519                     pRectangle.setBounds(x,y,width,height);
520
521                     runningTextBounds.setValue(tRectangle);
522                     progressBarBounds.setValue(pRectangle);
523                     int size = (int)((((Number JavaDoc)fontSize.getValue()).intValue()*yRatio));
524                     size = (size <= 6) ? 6 : size;
525                     fontSize.setValue(new Integer JavaDoc(size));
526                 } else {
527                     resetSplashPreview();
528                 }
529                 
530             } catch (MalformedURLException JavaDoc ex) {
531                 ErrorManager.getDefault().notify(ex);
532             }
533             
534         }
535         
536     }//GEN-LAST:event_browseActionPerformed
537

538     private void progressBarEnabledActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_progressBarEnabledActionPerformed
539
resetSplashPreview();
540     }//GEN-LAST:event_progressBarEnabledActionPerformed
541

542     
543     // Variables declaration - do not modify//GEN-BEGIN:variables
544
private javax.swing.JLabel JavaDoc barBoundsLabel;
545     private javax.swing.JLabel JavaDoc barColorLabel;
546     private javax.swing.JButton JavaDoc browse;
547     private javax.swing.JLabel JavaDoc jLabel1;
548     private javax.swing.JLabel JavaDoc jLabel2;
549     private javax.swing.JPanel JavaDoc jPanel1;
550     private javax.swing.JScrollPane JavaDoc jScrollPane1;
551     private javax.swing.JCheckBox JavaDoc progressBarEnabled;
552     private javax.swing.JLabel JavaDoc splashLabel;
553     private javax.swing.JLabel JavaDoc splashPreview;
554     private javax.swing.JLabel JavaDoc textBoundsLabel;
555     private javax.swing.JLabel JavaDoc textColorLabel;
556     private javax.swing.JLabel JavaDoc textFontSizeLabel;
557     // End of variables declaration//GEN-END:variables
558

559     private BasicBrandingModel getBrandingModel() {
560         return getProperties().getBrandingModel();
561     }
562 }
563
Popular Tags