KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > css > visual > ui > BackgroundStyleEditor


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-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 /*
21  * BackgroundStyleEditor.java
22  *
23  * Created on October 13, 2004, 12:23 PM
24  */

25
26 package org.netbeans.modules.css.visual.ui;
27
28 import org.netbeans.modules.css.visual.model.BackgroundModel;
29 import org.netbeans.modules.css.visual.model.BackgroundPositionData;
30 import org.netbeans.modules.css.visual.model.CssProperties;
31 import org.netbeans.modules.css.visual.model.CssStyleData;
32 import org.netbeans.modules.css.visual.model.PropertyData;
33 import org.netbeans.modules.css.visual.model.PropertyData;
34 import java.awt.BorderLayout JavaDoc;
35 import java.beans.PropertyChangeEvent JavaDoc;
36 import java.beans.PropertyChangeListener JavaDoc;
37 import java.io.File JavaDoc;
38 import javax.swing.DefaultComboBoxModel JavaDoc;
39 import javax.swing.JTextField JavaDoc;
40 import javax.swing.SwingUtilities JavaDoc;
41 import org.netbeans.modules.css.visual.model.Utils;
42 import org.openide.util.NbBundle;
43
44
45 /**
46  * Background Style editor.
47  * @author Winston Prakash
48  * @version 1.0
49  */

50 public class BackgroundStyleEditor extends StyleEditor implements PropertyChangeListener JavaDoc{
51
52     static File JavaDoc currentFile = null;
53
54     ColorSelectionField colorField = new ColorSelectionField();
55     BackgroundPositionData bgPositionData = new BackgroundPositionData();
56
57     /** Creates new form FontStyleEditor */
58     public BackgroundStyleEditor() {
59         setName("backgroundStyleEditor"); //NOI18N
60
setDisplayName(NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_EDITOR_DISPNAME"));
61         initComponents();
62         colorSelectionPanel.add(colorField,BorderLayout.CENTER);
63         colorField.addPropertyChangeListener(this);
64         initialize();
65
66         // Add editor listeners to the horizontal position combobox
67
final JTextField JavaDoc horizontalPosComboBoxEditor = (JTextField JavaDoc) horizontalPosComboBox.getEditor().getEditorComponent();
68         horizontalPosComboBoxEditor.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
69             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
70                 SwingUtilities.invokeLater(new Runnable JavaDoc(){
71                     public void run(){
72                         horizontalUnitComboBox.setEnabled(Utils.isInteger(horizontalPosComboBoxEditor.getText()));
73                         enablePositionCombo();
74                     }
75                 });
76             }
77         });
78
79         // Add editor listeners to the vertical position combobox
80
final JTextField JavaDoc verticalPosComboBoxEditor = (JTextField JavaDoc) verticalPosComboBox.getEditor().getEditorComponent();
81         verticalPosComboBoxEditor.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
82             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
83                 SwingUtilities.invokeLater(new Runnable JavaDoc(){
84                     public void run(){
85                         verticalUnitComboBox.setEnabled(Utils.isInteger(verticalPosComboBoxEditor.getText()));
86                     }
87                 });
88
89             }
90         });
91     }
92
93     protected void initialize(){
94         // Set the background repeat info to the GUI
95
BackgroundModel backgroundModel = new BackgroundModel();
96         DefaultComboBoxModel JavaDoc backgroundRepeatList = backgroundModel.getBackgroundRepeatList();
97         repeatComboBox.setModel(backgroundRepeatList);
98
99         // Set the background scroll to the GUI
100
DefaultComboBoxModel JavaDoc backgroundScrollList = backgroundModel.getBackgroundScrollList();
101         scrollComboBox.setModel(backgroundScrollList);
102
103         // Set the background poistion data to the GUI
104

105         horizontalPosComboBox.setModel(backgroundModel.getBackgroundPositionList());
106         verticalPosComboBox.setModel(backgroundModel.getBackgroundPositionList());
107         horizontalUnitComboBox.setModel(backgroundModel.getBackgroundPositionUnitList());
108         verticalUnitComboBox.setModel(backgroundModel.getBackgroundPositionUnitList());
109     }
110
111     /**
112      * Set the CSS Properties Values from the CssStyleData data structure
113      * to the GUI components.
114      */

115     protected void setCssPropertyValues(CssStyleData cssStyleData){
116         removeCssPropertyChangeListener();
117         
118         // Set the Bckground Color to the GUI
119
String JavaDoc backGroundColor = cssStyleData.getProperty(CssProperties.BACKGROUND_COLOR);
120         if(backGroundColor != null){
121             colorField.setColorString(backGroundColor);
122         }else{
123             imageFileField.setText(CssStyleData.NOT_SET);
124         }
125         
126         // Set the Bckground Image name to the GUI
127
String JavaDoc backGroundImage = cssStyleData.getProperty(CssProperties.BACKGROUND_IMAGE);
128         if(backGroundImage != null && !backGroundImage.trim().equals("")){
129             int openBracketPos = backGroundImage.indexOf("(");
130             int endBracketPos = backGroundImage.indexOf(")");
131             if((openBracketPos >= 0) && (endBracketPos >= 0)){
132                 String JavaDoc imgString = backGroundImage.substring(openBracketPos + 1, endBracketPos);
133                 imageFileField.setText(imgString);
134             }else{
135                 imageFileField.setText(backGroundImage);
136             }
137         }else{
138             imageFileField.setText(CssStyleData.NOT_SET);
139         }
140         
141         String JavaDoc backGroundRepeat = cssStyleData.getProperty(CssProperties.BACKGROUND_REPEAT);
142         if(backGroundRepeat != null){
143             repeatComboBox.setSelectedItem(backGroundRepeat);
144         }else{
145             repeatComboBox.setSelectedIndex(0);
146         }
147         
148         String JavaDoc backGroundScroll = cssStyleData.getProperty(CssProperties.BACKGROUND_ATTACHMENT);
149         if(backGroundScroll != null){
150             scrollComboBox.setSelectedItem(backGroundScroll);
151         }else{
152             scrollComboBox.setSelectedIndex(0);
153         }
154         
155         String JavaDoc backgroundPosition = cssStyleData.getProperty(CssProperties.BACKGROUND_POSITION);
156         if(backgroundPosition != null){
157             bgPositionData.setBackgroundPosition(backgroundPosition);
158             horizontalPosComboBox.setSelectedItem(bgPositionData.getHorizontalValue());
159             horizontalUnitComboBox.setSelectedItem(bgPositionData.getHorizontalUnit());
160             verticalPosComboBox.setSelectedItem(bgPositionData.getVerticalValue());
161             verticalUnitComboBox.setSelectedItem(bgPositionData.getVerticalUnit());
162         }else{
163             horizontalPosComboBox.setSelectedIndex(0);
164             verticalPosComboBox.setSelectedIndex(0);
165         }
166         setCssPropertyChangeListener(cssStyleData);
167     }
168     
169     /** Listens to the color property change in the color chooser filed */
170     public void propertyChange(PropertyChangeEvent JavaDoc evt) {
171         setBackgroundColor();
172     }
173     
174     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
175
private void initComponents() {
176         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
177
178         colorPanel = new javax.swing.JPanel JavaDoc();
179         colorLabel = new javax.swing.JLabel JavaDoc();
180         browseButton = new javax.swing.JButton JavaDoc();
181         imageFileField = new javax.swing.JTextField JavaDoc();
182         lineHeightLabel = new javax.swing.JLabel JavaDoc();
183         imageTileLabel = new javax.swing.JLabel JavaDoc();
184         imageScrollLabel = new javax.swing.JLabel JavaDoc();
185         scrollComboBox = new javax.swing.JComboBox JavaDoc();
186         repeatComboBox = new javax.swing.JComboBox JavaDoc();
187         horizontalPosLabel = new javax.swing.JLabel JavaDoc();
188         verticalPosLabel = new javax.swing.JLabel JavaDoc();
189         horizontalPosComboBox = new javax.swing.JComboBox JavaDoc();
190         verticalPosComboBox = new javax.swing.JComboBox JavaDoc();
191         horizontalUnitComboBox = new javax.swing.JComboBox JavaDoc();
192         verticalUnitComboBox = new javax.swing.JComboBox JavaDoc();
193         colorSelectionPanel = new javax.swing.JPanel JavaDoc();
194         errorPanel = new javax.swing.JPanel JavaDoc();
195         errorLabel = new javax.swing.JLabel JavaDoc();
196
197         setLayout(new java.awt.BorderLayout JavaDoc());
198
199         colorPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
200
201         colorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
202         colorLabel.setLabelFor(colorPanel);
203         colorLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_COLOR"));
204         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
205         gridBagConstraints.gridx = 0;
206         gridBagConstraints.gridy = 0;
207         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
208         gridBagConstraints.insets = new java.awt.Insets JavaDoc(0, 0, 0, 10);
209         colorPanel.add(colorLabel, gridBagConstraints);
210
211         browseButton.setText("...");
212         browseButton.setToolTipText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMAGE_BROWSE_BTN_TOOLTIP"));
213         browseButton.setMargin(new java.awt.Insets JavaDoc(2, 2, 2, 2));
214         browseButton.setPreferredSize(new java.awt.Dimension JavaDoc(20, 20));
215         browseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
216             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
217                 browseButtonActionPerformed(evt);
218             }
219         });
220
221         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
222         gridBagConstraints.gridx = 3;
223         gridBagConstraints.gridy = 1;
224         gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
225         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
226         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 3, 0, 0);
227         colorPanel.add(browseButton, gridBagConstraints);
228         browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IAMGE_BROWSE_ACCESS_NAME"));
229         browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IAMGE_BROWSE_ACCESS_DESC"));
230
231         imageFileField.addActionListener(new java.awt.event.ActionListener JavaDoc() {
232             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
233                 imageFileFieldActionPerformed(evt);
234             }
235         });
236         imageFileField.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
237             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
238                 imageFileFieldFocusLost(evt);
239             }
240         });
241
242         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
243         gridBagConstraints.gridx = 1;
244         gridBagConstraints.gridy = 1;
245         gridBagConstraints.gridwidth = 2;
246         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
247         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
248         gridBagConstraints.weightx = 1.0;
249         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
250         colorPanel.add(imageFileField, gridBagConstraints);
251         imageFileField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMG_TEXTFIELD_ACCESS_NAME"));
252         imageFileField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMG_TEXTFIELD_ACCESS_DESC"));
253
254         lineHeightLabel.setLabelFor(imageFileField);
255         lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_IMAGE"));
256         lineHeightLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP);
257         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
258         gridBagConstraints.gridx = 0;
259         gridBagConstraints.gridy = 1;
260         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
261         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 10);
262         colorPanel.add(lineHeightLabel, gridBagConstraints);
263
264         imageTileLabel.setLabelFor(repeatComboBox);
265         imageTileLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUNDTILE"));
266         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
267         gridBagConstraints.gridx = 0;
268         gridBagConstraints.gridy = 2;
269         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
270         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 10);
271         colorPanel.add(imageTileLabel, gridBagConstraints);
272
273         imageScrollLabel.setLabelFor(scrollComboBox);
274         imageScrollLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_SCROLL"));
275         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
276         gridBagConstraints.gridx = 0;
277         gridBagConstraints.gridy = 3;
278         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
279         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 10);
280         colorPanel.add(imageScrollLabel, gridBagConstraints);
281
282         scrollComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
283             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
284                 scrollComboBoxItemStateChanged(evt);
285             }
286         });
287
288         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
289         gridBagConstraints.gridx = 1;
290         gridBagConstraints.gridy = 3;
291         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
292         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
293         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
294         colorPanel.add(scrollComboBox, gridBagConstraints);
295         scrollComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "SCROLL_COMBO_ACCESSIBLE_NAME"));
296         scrollComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "SCROLL_COMBO_ACCESSIBLE_DESC"));
297
298         repeatComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
299             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
300                 repeatComboBoxItemStateChanged(evt);
301             }
302         });
303
304         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
305         gridBagConstraints.gridx = 1;
306         gridBagConstraints.gridy = 2;
307         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
308         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
309         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
310         colorPanel.add(repeatComboBox, gridBagConstraints);
311         repeatComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "TILE_COMBO_ACCESSIBLE_NAME"));
312         repeatComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "TILE_COMBO_ACCESSIBLE_DESC"));
313
314         horizontalPosLabel.setLabelFor(horizontalPosComboBox);
315         horizontalPosLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_HORIZONTAL_POS"));
316         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
317         gridBagConstraints.gridx = 0;
318         gridBagConstraints.gridy = 4;
319         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
320         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 10);
321         colorPanel.add(horizontalPosLabel, gridBagConstraints);
322
323         verticalPosLabel.setLabelFor(verticalPosComboBox);
324         verticalPosLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_VERTICAL_POS"));
325         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
326         gridBagConstraints.gridx = 0;
327         gridBagConstraints.gridy = 5;
328         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
329         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 20, 0, 10);
330         colorPanel.add(verticalPosLabel, gridBagConstraints);
331
332         horizontalPosComboBox.setEditable(true);
333         horizontalPosComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
334             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
335                 horizontalPosComboBoxItemStateChanged(evt);
336             }
337         });
338         horizontalPosComboBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
339             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
340                 horizontalPosComboBoxActionPerformed(evt);
341             }
342         });
343
344         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
345         gridBagConstraints.gridx = 1;
346         gridBagConstraints.gridy = 4;
347         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
348         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
349         gridBagConstraints.weightx = 1.0;
350         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
351         colorPanel.add(horizontalPosComboBox, gridBagConstraints);
352         horizontalPosComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_COMBO_ACCESSIBLE_NAME"));
353         horizontalPosComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_COMBO_ACCESSIBLE_DESC"));
354
355         verticalPosComboBox.setEditable(true);
356         verticalPosComboBox.addActionListener(new java.awt.event.ActionListener JavaDoc() {
357             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
358                 verticalPosComboBoxActionPerformed(evt);
359             }
360         });
361         verticalPosComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
362             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
363                 verticalPosComboBoxItemStateChanged(evt);
364             }
365         });
366
367         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
368         gridBagConstraints.gridx = 1;
369         gridBagConstraints.gridy = 5;
370         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
371         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
372         gridBagConstraints.weightx = 1.0;
373         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
374         colorPanel.add(verticalPosComboBox, gridBagConstraints);
375         verticalPosComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_COMBO_ACCESSIBLE_NAME"));
376         verticalPosComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_COMBO_ACCESSIBLE_DESC"));
377
378         horizontalUnitComboBox.setEnabled(false);
379         horizontalUnitComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
380             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
381                 horizontalUnitComboBoxItemStateChanged(evt);
382             }
383         });
384
385         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
386         gridBagConstraints.gridx = 2;
387         gridBagConstraints.gridy = 4;
388         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
389         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
390         colorPanel.add(horizontalUnitComboBox, gridBagConstraints);
391         horizontalUnitComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_UNIT_COMBO_ACCESSIBLE_NAME"));
392         horizontalUnitComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_UNIT_COMBO_ACCESSIBLE_DESC"));
393
394         verticalUnitComboBox.setEnabled(false);
395         verticalUnitComboBox.addItemListener(new java.awt.event.ItemListener JavaDoc() {
396             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
397                 verticalUnitComboBoxItemStateChanged(evt);
398             }
399         });
400
401         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
402         gridBagConstraints.gridx = 2;
403         gridBagConstraints.gridy = 5;
404         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
405         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
406         colorPanel.add(verticalUnitComboBox, gridBagConstraints);
407         verticalUnitComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_UNIT_COMBO_ACCESSIBLE_NAME"));
408         verticalUnitComboBox.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/css/visual/ui/Bundle").getString("VERTPOS_UNIT_COMBO_ACCESSIBLE_DESC"));
409
410         colorSelectionPanel.setLayout(new java.awt.BorderLayout JavaDoc());
411
412         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
413         gridBagConstraints.gridwidth = 3;
414         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
415         colorPanel.add(colorSelectionPanel, gridBagConstraints);
416
417         add(colorPanel, java.awt.BorderLayout.NORTH);
418
419         errorPanel.setLayout(new java.awt.BorderLayout JavaDoc());
420
421         errorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 1));
422         errorLabel.setForeground(new java.awt.Color JavaDoc(0, 0, 153));
423         errorPanel.add(errorLabel, java.awt.BorderLayout.NORTH);
424
425         add(errorPanel, java.awt.BorderLayout.CENTER);
426
427     }// </editor-fold>//GEN-END:initComponents
428

429     private void verticalUnitComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_verticalUnitComboBoxItemStateChanged
430
if (evt.getStateChange() != evt.DESELECTED) {
431             bgPositionData.setVerticalUnit((String JavaDoc)verticalUnitComboBox.getSelectedItem());
432             setBackgroundPosition();
433         }
434     }//GEN-LAST:event_verticalUnitComboBoxItemStateChanged
435

436     private void horizontalUnitComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_horizontalUnitComboBoxItemStateChanged
437
if (evt.getStateChange() != evt.DESELECTED) {
438             bgPositionData.setHorizontalUnit((String JavaDoc)horizontalUnitComboBox.getSelectedItem());
439             setBackgroundPosition();
440         }
441     }//GEN-LAST:event_horizontalUnitComboBoxItemStateChanged
442

443     private void verticalPosComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_verticalPosComboBoxItemStateChanged
444
if (evt.getStateChange() != evt.DESELECTED) {
445             bgPositionData.setVerticalValue((String JavaDoc)verticalPosComboBox.getSelectedItem());
446             setBackgroundPosition();
447         }
448     }//GEN-LAST:event_verticalPosComboBoxItemStateChanged
449

450     private void verticalPosComboBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_verticalPosComboBoxActionPerformed
451
bgPositionData.setVerticalValue((String JavaDoc)verticalPosComboBox.getSelectedItem());
452         setBackgroundPosition();
453     }//GEN-LAST:event_verticalPosComboBoxActionPerformed
454

455     private void horizontalPosComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_horizontalPosComboBoxItemStateChanged
456
if (evt.getStateChange() != evt.DESELECTED) {
457             bgPositionData.setHorizontalValue((String JavaDoc)horizontalPosComboBox.getSelectedItem());
458             setBackgroundPosition();
459         }
460     }//GEN-LAST:event_horizontalPosComboBoxItemStateChanged
461

462     private void horizontalPosComboBoxActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_horizontalPosComboBoxActionPerformed
463
bgPositionData.setHorizontalValue((String JavaDoc)horizontalPosComboBox.getSelectedItem());
464         setBackgroundPosition();
465     }//GEN-LAST:event_horizontalPosComboBoxActionPerformed
466

467     private void scrollComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_scrollComboBoxItemStateChanged
468
setBackgroundAttachment();
469     }//GEN-LAST:event_scrollComboBoxItemStateChanged
470

471     private void repeatComboBoxItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_repeatComboBoxItemStateChanged
472
if (evt.getStateChange() != evt.DESELECTED) {
473             setBackgroundRepeat();
474         }
475     }//GEN-LAST:event_repeatComboBoxItemStateChanged
476

477     private void imageFileFieldFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_imageFileFieldFocusLost
478
setBackgroundImage();
479     }//GEN-LAST:event_imageFileFieldFocusLost
480

481     private void imageFileFieldActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_imageFileFieldActionPerformed
482
setBackgroundImage();
483     }//GEN-LAST:event_imageFileFieldActionPerformed
484

485     private void browseButtonActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_browseButtonActionPerformed
486
BackgroundImageUrlDialog imageUrlDialog = new BackgroundImageUrlDialog();
487         if(imageUrlDialog.show(this)){
488             imageFileField.setText(imageUrlDialog.getImageUrl());
489         }
490         setBackgroundImage();
491     }//GEN-LAST:event_browseButtonActionPerformed
492

493     private void setBackgroundColor(){
494         PropertyData backgroundColorData = new PropertyData();
495         backgroundColorData.setValue(colorField.getColorString());
496         cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_COLOR, null, backgroundColorData.toString());
497     }
498     
499     private void setBackgroundImage(){
500         PropertyData backgroundImageData = new PropertyData();
501         String JavaDoc imgPath = imageFileField.getText();
502         if((imgPath == null) || (imgPath.equals(""))) {
503             imgPath = CssStyleData.NOT_SET;
504             imageFileField.setText(imgPath);
505         }
506         if(!imgPath.equals(CssStyleData.NOT_SET)){
507             backgroundImageData.setValue("url(" + imgPath + ")"); //NOI18N
508
}else{
509             backgroundImageData.setValue(CssStyleData.NOT_SET);
510         }
511         cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_IMAGE, null, backgroundImageData.toString());
512     }
513     
514     private void setBackgroundRepeat(){
515         PropertyData backgroundRepeatData = new PropertyData();
516         backgroundRepeatData.setValue(repeatComboBox.getSelectedItem().toString());
517         cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_REPEAT, null, backgroundRepeatData.toString());
518     }
519     
520     private void setBackgroundAttachment(){
521         PropertyData backgroundAttachmentData = new PropertyData();
522         backgroundAttachmentData.setValue(scrollComboBox.getSelectedItem().toString());
523         cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_ATTACHMENT, null, backgroundAttachmentData.toString());
524     }
525     
526     private void setBackgroundPosition(){
527         cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_POSITION, null, bgPositionData.toString());
528         enablePositionCombo();
529     }
530     
531     private void enablePositionCombo(){
532         String JavaDoc horizontalPos = bgPositionData.getHorizontalValue();
533         if (Utils.isInteger(horizontalPos)){
534             horizontalUnitComboBox.setEnabled(true);
535         }else{
536             horizontalUnitComboBox.setEnabled(false);
537         }
538         String JavaDoc verticalPos = bgPositionData.getVerticalValue();
539         if (Utils.isInteger(verticalPos)){
540             verticalUnitComboBox.setEnabled(true);
541         }else{
542             verticalUnitComboBox.setEnabled(false);
543         }
544     }
545     
546     // Variables declaration - do not modify//GEN-BEGIN:variables
547
private javax.swing.JButton JavaDoc browseButton;
548     private javax.swing.JLabel JavaDoc colorLabel;
549     private javax.swing.JPanel JavaDoc colorPanel;
550     private javax.swing.JPanel JavaDoc colorSelectionPanel;
551     private javax.swing.JLabel JavaDoc errorLabel;
552     private javax.swing.JPanel JavaDoc errorPanel;
553     private javax.swing.JComboBox JavaDoc horizontalPosComboBox;
554     private javax.swing.JLabel JavaDoc horizontalPosLabel;
555     private javax.swing.JComboBox JavaDoc horizontalUnitComboBox;
556     private javax.swing.JTextField JavaDoc imageFileField;
557     private javax.swing.JLabel JavaDoc imageScrollLabel;
558     private javax.swing.JLabel JavaDoc imageTileLabel;
559     private javax.swing.JLabel JavaDoc lineHeightLabel;
560     private javax.swing.JComboBox JavaDoc repeatComboBox;
561     private javax.swing.JComboBox JavaDoc scrollComboBox;
562     private javax.swing.JComboBox JavaDoc verticalPosComboBox;
563     private javax.swing.JLabel JavaDoc verticalPosLabel;
564     private javax.swing.JComboBox JavaDoc verticalUnitComboBox;
565     // End of variables declaration//GEN-END:variables
566

567 }
568
Popular Tags