KickJava   Java API By Example, From Geeks To Geeks.

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


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  * TextBlockStyleEditor.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.CssProperties;
29 import org.netbeans.modules.css.visual.model.CssStyleData;
30 import org.netbeans.modules.css.visual.model.PropertyData;
31 import org.netbeans.modules.css.visual.model.PropertyWithUnitData;
32 import org.netbeans.modules.css.visual.model.TextBlockData;
33 import org.netbeans.modules.css.visual.model.TextBlockModel;
34 import org.netbeans.modules.css.visual.model.PropertyData;
35 import java.awt.event.FocusAdapter JavaDoc;
36 import java.awt.event.FocusEvent JavaDoc;
37 import javax.swing.DefaultComboBoxModel JavaDoc;
38 import javax.swing.JTextField JavaDoc;
39 import javax.swing.SwingUtilities JavaDoc;
40 import org.netbeans.modules.css.visual.model.Utils;
41 import org.openide.util.NbBundle;
42
43 /**
44  * Text Block Style editor.
45  * @author Winston Prakash
46  */

47 public class TextBlockStyleEditor extends StyleEditor {
48
49     TextBlockModel textBlockModel = new TextBlockModel();
50     TextBlockData textBlockData = new TextBlockData();
51
52     PropertyData directionData = new PropertyData();
53     PropertyData textAlignData = new PropertyData();
54     PropertyData verticalAlignData = new PropertyWithUnitData();
55     PropertyWithUnitData wordSpacingData = new PropertyWithUnitData();
56     PropertyWithUnitData letterSpacingData = new PropertyWithUnitData();
57     PropertyWithUnitData lineHeightData = new PropertyWithUnitData();
58     PropertyWithUnitData textIndentData = new PropertyWithUnitData();
59
60     /** Creates new form FontStyleEditor */
61     public TextBlockStyleEditor() {
62         setName("textBlockStyleEditor"); //NOI18N
63
setDisplayName(NbBundle.getMessage(TextBlockStyleEditor.class, "TEXTBLOCK_EDITOR_DISPNAME"));
64         initComponents();
65         initialize();
66
67          // Add editor listeners to the border width combobox
68
final JTextField JavaDoc textIndentComboEditor = (JTextField JavaDoc) textIndentCombo.getEditor().getEditorComponent();
69         textIndentComboEditor.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
70             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
71                 SwingUtilities.invokeLater(new Runnable JavaDoc(){
72                     public void run(){
73                        textIndentUnitCombo.setEnabled(Utils.isInteger(textIndentComboEditor.getText()));
74                     }
75                 });
76             }
77         });
78
79         // Add editor listeners to the border width combobox
80
final JTextField JavaDoc wordSpacingComboEditor = (JTextField JavaDoc) wordSpacingCombo.getEditor().getEditorComponent();
81         wordSpacingComboEditor.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                        wordSpacingUnitCombo.setEnabled(Utils.isInteger(wordSpacingComboEditor.getText()));
86                     }
87                 });
88             }
89         });
90
91         // Add editor listeners to the border width combobox
92
final JTextField JavaDoc letterSpacingComboEditor = (JTextField JavaDoc) letterSpacingCombo.getEditor().getEditorComponent();
93         letterSpacingComboEditor.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
94             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
95                 SwingUtilities.invokeLater(new Runnable JavaDoc(){
96                     public void run(){
97                        letterSpacingUnitCombo.setEnabled(Utils.isInteger(letterSpacingComboEditor.getText()));
98                     }
99                 });
100             }
101         });
102
103         // Add editor listeners to the border width combobox
104
final JTextField JavaDoc lineHeightComboEditor = (JTextField JavaDoc) lineHeightCombo.getEditor().getEditorComponent();
105         lineHeightComboEditor.addKeyListener(new java.awt.event.KeyAdapter JavaDoc() {
106             public void keyTyped(java.awt.event.KeyEvent JavaDoc evt) {
107                 SwingUtilities.invokeLater(new Runnable JavaDoc(){
108                     public void run(){
109                        lineHeightUnitCombo.setEnabled(Utils.isInteger(lineHeightComboEditor.getText()));
110                     }
111                 });
112             }
113         });
114     }
115     
116     
117     private void initialize(){
118         
119         // Set the Horizontal Alignment to the GUI
120
DefaultComboBoxModel JavaDoc horizontalAlignList = textBlockModel.getHorizontalAlignmentList();
121         horizontalAlignCombo.setModel(horizontalAlignList);
122         
123         // Set the Vertical Alignment to the GUI
124
DefaultComboBoxModel JavaDoc verticalAlignList = textBlockModel.getVerticalAlignmentList();
125         verticalAlignCombo.setModel(verticalAlignList);
126         
127         // Set the Indentation to the GUI
128
DefaultComboBoxModel JavaDoc indentationList = textBlockModel.getIndentationList();
129         textIndentCombo.setModel(indentationList);
130         textIndentUnitCombo.setModel(textBlockModel.getTextBlockUnitList());
131         
132         // Set the Text Direction to the GUI
133
DefaultComboBoxModel JavaDoc textDirectionList = textBlockModel.getTextDirectionList();
134         directionCombo.setModel(textDirectionList);
135  
136         // Set the Word Spacing to the GUI
137
DefaultComboBoxModel JavaDoc wordSpacingList = textBlockModel.getWordSpacingList();
138         wordSpacingCombo.setModel(wordSpacingList);
139  
140         // Set the Letter Spacing to the GUI
141
DefaultComboBoxModel JavaDoc letterSpacingList = textBlockModel.getLetterSpacingList();
142         letterSpacingCombo.setModel(letterSpacingList);
143         letterSpacingUnitCombo.setModel(textBlockModel.getTextBlockUnitList());
144   
145         // Set the Letter Spacing to the GUI
146
DefaultComboBoxModel JavaDoc lineHeightList = textBlockModel.getLineHeightList();
147         lineHeightCombo.setModel(lineHeightList);
148         lineHeightUnitCombo.setModel(textBlockModel.getTextBlockUnitList());
149   
150         textIndentCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter JavaDoc() {
151             public void focusGained(FocusEvent JavaDoc evt) {
152                 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
153             }
154             public void focusLost(FocusEvent JavaDoc evt) {
155                 errorLabel.setText("");
156             }
157         });
158         
159         directionCombo.addFocusListener(new FocusAdapter JavaDoc() {
160             public void focusGained(FocusEvent JavaDoc evt) {
161                 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
162             }
163             public void focusLost(FocusEvent JavaDoc evt) {
164                 errorLabel.setText("");
165             }
166         });
167         
168         letterSpacingCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter JavaDoc() {
169             public void focusGained(FocusEvent JavaDoc evt) {
170                 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
171             }
172             public void focusLost(FocusEvent JavaDoc evt) {
173                 errorLabel.setText("");
174             }
175         });
176         
177         wordSpacingCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter JavaDoc() {
178             public void focusGained(FocusEvent JavaDoc evt) {
179                 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
180             }
181             public void focusLost(FocusEvent JavaDoc evt) {
182                 errorLabel.setText("");
183             }
184         });
185     }
186     
187     /**
188      * Set the CSS Properties Values from the CssStyleData data structure
189      * to the GUI components.
190      */

191     protected void setCssPropertyValues(CssStyleData cssStyleData){
192         removeCssPropertyChangeListener();
193         
194         String JavaDoc horizontalAlign = cssStyleData.getProperty(CssProperties.TEXT_ALIGN);
195         if(horizontalAlign != null){
196             horizontalAlignCombo.setSelectedItem(horizontalAlign);
197         }else{
198             horizontalAlignCombo.setSelectedIndex(0);
199         }
200         
201         String JavaDoc verticalAlign = cssStyleData.getProperty(CssProperties.VERTICAL_ALIGN);
202         if(verticalAlign != null){
203             textBlockData.setVerticalAlign(verticalAlign);
204             verticalAlignCombo.setSelectedItem(textBlockData.getVerticalAlignValue());
205         }else{
206             verticalAlignCombo.setSelectedIndex(0);
207         }
208         
209         String JavaDoc indentation = cssStyleData.getProperty(CssProperties.TEXT_INDENT);
210         if(indentation != null){
211             textBlockData.setIndentation(indentation);
212             textIndentCombo.setSelectedItem(textBlockData.getIndentationValue());
213             textIndentUnitCombo.setSelectedItem(textBlockData.getIndentationUnit());
214         }else{
215             textIndentCombo.setSelectedIndex(0);
216             textIndentUnitCombo.setSelectedItem("px");
217         }
218         String JavaDoc textDirection = cssStyleData.getProperty(CssProperties.DIRECTION);
219         if(textDirection != null){
220             directionCombo.setSelectedItem(textDirection);
221         }else{
222             directionCombo.setSelectedItem("px");
223         }
224         
225         wordSpacingUnitCombo.setModel(textBlockModel.getTextBlockUnitList());
226         String JavaDoc wordSpacing = cssStyleData.getProperty(CssProperties.WORD_SPACING);
227         if(wordSpacing != null){
228             textBlockData.setWordSpacing(wordSpacing);
229             wordSpacingCombo.setSelectedItem(textBlockData.getWordSpacingValue());
230             wordSpacingUnitCombo.setSelectedItem(textBlockData.getWordSpacingUnit());
231         }else{
232             wordSpacingCombo.setSelectedIndex(0);
233             wordSpacingUnitCombo.setSelectedItem("px");
234         }
235         String JavaDoc letterSpacing = cssStyleData.getProperty(CssProperties.LETTER_SPACING);
236         if(letterSpacing != null){
237             textBlockData.setLetterSpacing(letterSpacing);
238             letterSpacingCombo.setSelectedItem(textBlockData.getLetterSpacingValue());
239             letterSpacingUnitCombo.setSelectedItem(textBlockData.getLetterSpacingUnit());
240         }else{
241             letterSpacingCombo.setSelectedIndex(0);
242             letterSpacingUnitCombo.setSelectedItem("px");
243         }
244         String JavaDoc lineHeight = cssStyleData.getProperty(CssProperties.LINE_HEIGHT);
245         if(lineHeight != null){
246             textBlockData.setLineHeight(lineHeight);
247             lineHeightCombo.setSelectedItem(textBlockData.getLineHeightValue());
248             lineHeightUnitCombo.setSelectedItem(textBlockData.getLineHeightUnit());
249         }else{
250             lineHeightCombo.setSelectedIndex(0);
251             lineHeightUnitCombo.setSelectedItem("px");
252         }
253         setCssPropertyChangeListener(cssStyleData);
254     }
255     
256     // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
257
private void initComponents() {
258         java.awt.GridBagConstraints JavaDoc gridBagConstraints;
259
260         textBlockPanel = new javax.swing.JPanel JavaDoc();
261         decorationLabel = new javax.swing.JLabel JavaDoc();
262         imageScroll = new javax.swing.JLabel JavaDoc();
263         directionCombo = new javax.swing.JComboBox JavaDoc();
264         horizontalAlignCombo = new javax.swing.JComboBox JavaDoc();
265         textAlignLabel = new javax.swing.JLabel JavaDoc();
266         jLabel2 = new javax.swing.JLabel JavaDoc();
267         textIndentCombo = new javax.swing.JComboBox JavaDoc();
268         verticalAlignCombo = new javax.swing.JComboBox JavaDoc();
269         wordSpacingUnitCombo = new javax.swing.JComboBox JavaDoc();
270         imageScroll1 = new javax.swing.JLabel JavaDoc();
271         wordSpacingCombo = new javax.swing.JComboBox JavaDoc();
272         imageScroll2 = new javax.swing.JLabel JavaDoc();
273         letterSpacingCombo = new javax.swing.JComboBox JavaDoc();
274         letterSpacingUnitCombo = new javax.swing.JComboBox JavaDoc();
275         textIndentUnitCombo = new javax.swing.JComboBox JavaDoc();
276         lineHeightLabel = new javax.swing.JLabel JavaDoc();
277         lineHeightCombo = new javax.swing.JComboBox JavaDoc();
278         lineHeightUnitCombo = new javax.swing.JComboBox JavaDoc();
279         errorPanel = new javax.swing.JPanel JavaDoc();
280         errorLabel = new javax.swing.JLabel JavaDoc();
281
282         setLayout(new java.awt.BorderLayout JavaDoc());
283
284         textBlockPanel.setLayout(new java.awt.GridBagLayout JavaDoc());
285
286         textBlockPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5));
287         decorationLabel.setLabelFor(textIndentCombo);
288         decorationLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_INDENTATION"));
289         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
290         gridBagConstraints.gridx = 0;
291         gridBagConstraints.gridy = 2;
292         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
293         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 10);
294         textBlockPanel.add(decorationLabel, gridBagConstraints);
295
296         imageScroll.setLabelFor(directionCombo);
297         imageScroll.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_DIRECTION"));
298         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
299         gridBagConstraints.gridx = 0;
300         gridBagConstraints.gridy = 3;
301         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
302         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 10);
303         textBlockPanel.add(imageScroll, gridBagConstraints);
304
305         directionCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
306             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
307                 directionComboItemStateChanged(evt);
308             }
309         });
310
311         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
312         gridBagConstraints.gridx = 1;
313         gridBagConstraints.gridy = 3;
314         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
315         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
316         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
317         textBlockPanel.add(directionCombo, gridBagConstraints);
318         directionCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "DIRECTION_ACCESS_NAME"));
319         directionCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "DIRECTION_ACCESS_DESC"));
320
321         horizontalAlignCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
322             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
323                 horizontalAlignComboFocusLost(evt);
324             }
325         });
326         horizontalAlignCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
327             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
328                 horizontalAlignComboItemStateChanged(evt);
329             }
330         });
331
332         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
333         gridBagConstraints.gridx = 1;
334         gridBagConstraints.gridy = 0;
335         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
336         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
337         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 0);
338         textBlockPanel.add(horizontalAlignCombo, gridBagConstraints);
339         horizontalAlignCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "HORIZONTAL_ALIGN_ACCESS_NAME"));
340         horizontalAlignCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "HORIZONTAL_ALIGN_ACCESS_DESC"));
341
342         textAlignLabel.setLabelFor(horizontalAlignCombo);
343         textAlignLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_HORIZ_ALIGN"));
344         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
345         gridBagConstraints.gridx = 0;
346         gridBagConstraints.gridy = 0;
347         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
348         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 10);
349         textBlockPanel.add(textAlignLabel, gridBagConstraints);
350
351         jLabel2.setLabelFor(verticalAlignCombo);
352         jLabel2.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_VERTICAL_ALIGN"));
353         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
354         gridBagConstraints.gridx = 0;
355         gridBagConstraints.gridy = 1;
356         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
357         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 10);
358         textBlockPanel.add(jLabel2, gridBagConstraints);
359
360         textIndentCombo.setEditable(true);
361         textIndentCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
362             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
363                 textIndentComboItemStateChanged(evt);
364             }
365         });
366         textIndentCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
367             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
368                 textIndentComboActionPerformed(evt);
369             }
370         });
371         textIndentCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
372             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
373                 textIndentComboFocusLost(evt);
374             }
375         });
376
377         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
378         gridBagConstraints.gridx = 1;
379         gridBagConstraints.gridy = 2;
380         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
381         gridBagConstraints.weightx = 1.0;
382         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 0);
383         textBlockPanel.add(textIndentCombo, gridBagConstraints);
384         textIndentCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_ACCESS_NAME"));
385         textIndentCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_ACCESS_DESC"));
386
387         verticalAlignCombo.setEditable(true);
388         verticalAlignCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
389             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
390                 verticalAlignComboActionPerformed(evt);
391             }
392         });
393         verticalAlignCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
394             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
395                 verticalAlignComboFocusLost(evt);
396             }
397         });
398         verticalAlignCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
399             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
400                 verticalAlignComboItemStateChanged(evt);
401             }
402         });
403
404         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
405         gridBagConstraints.gridx = 1;
406         gridBagConstraints.gridy = 1;
407         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
408         gridBagConstraints.weightx = 1.0;
409         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
410         textBlockPanel.add(verticalAlignCombo, gridBagConstraints);
411         verticalAlignCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "VERTICAL_ALIGN_ACCESS_NAME"));
412         verticalAlignCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "VERTICAL_ALIGN_ACCESS_DESC"));
413
414         wordSpacingUnitCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
415             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
416                 wordSpacingUnitComboItemStateChanged(evt);
417             }
418         });
419
420         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
421         gridBagConstraints.gridx = 2;
422         gridBagConstraints.gridy = 4;
423         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
424         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 0, 0);
425         textBlockPanel.add(wordSpacingUnitCombo, gridBagConstraints);
426         wordSpacingUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_UNIT_ACCESS_NAME"));
427         wordSpacingUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_UNIT_ACCESS_DESC"));
428
429         imageScroll1.setLabelFor(wordSpacingCombo);
430         imageScroll1.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING"));
431         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
432         gridBagConstraints.gridx = 0;
433         gridBagConstraints.gridy = 4;
434         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
435         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 10);
436         textBlockPanel.add(imageScroll1, gridBagConstraints);
437
438         wordSpacingCombo.setEditable(true);
439         wordSpacingCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
440             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
441                 wordSpacingComboItemStateChanged(evt);
442             }
443         });
444         wordSpacingCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
445             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
446                 wordSpacingComboActionPerformed(evt);
447             }
448         });
449         wordSpacingCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
450             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
451                 wordSpacingComboFocusLost(evt);
452             }
453         });
454
455         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
456         gridBagConstraints.gridx = 1;
457         gridBagConstraints.gridy = 4;
458         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
459         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
460         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 0, 0, 0);
461         textBlockPanel.add(wordSpacingCombo, gridBagConstraints);
462         wordSpacingCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_ACCESS_NAME"));
463         wordSpacingCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_ACCESS_DESC"));
464
465         imageScroll2.setLabelFor(letterSpacingCombo);
466         imageScroll2.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING"));
467         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
468         gridBagConstraints.gridx = 0;
469         gridBagConstraints.gridy = 5;
470         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
471         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 10);
472         textBlockPanel.add(imageScroll2, gridBagConstraints);
473
474         letterSpacingCombo.setEditable(true);
475         letterSpacingCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
476             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
477                 letterSpacingComboItemStateChanged(evt);
478             }
479         });
480         letterSpacingCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
481             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
482                 letterSpacingComboActionPerformed(evt);
483             }
484         });
485         letterSpacingCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
486             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
487                 letterSpacingComboFocusLost(evt);
488             }
489         });
490
491         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
492         gridBagConstraints.gridx = 1;
493         gridBagConstraints.gridy = 5;
494         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
495         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
496         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
497         textBlockPanel.add(letterSpacingCombo, gridBagConstraints);
498         letterSpacingCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_ACCESS_NAME"));
499         letterSpacingCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_ACCESS_DESC"));
500
501         letterSpacingUnitCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
502             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
503                 letterSpacingUnitComboItemStateChanged(evt);
504             }
505         });
506
507         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
508         gridBagConstraints.gridx = 2;
509         gridBagConstraints.gridy = 5;
510         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
511         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
512         textBlockPanel.add(letterSpacingUnitCombo, gridBagConstraints);
513         letterSpacingUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_UNIT_ACCESS_NAME"));
514         letterSpacingUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_UNIT_ACCESS_DESC"));
515
516         textIndentUnitCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
517             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
518                 textIndentUnitComboItemStateChanged(evt);
519             }
520         });
521
522         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
523         gridBagConstraints.gridx = 2;
524         gridBagConstraints.gridy = 2;
525         gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
526         gridBagConstraints.insets = new java.awt.Insets JavaDoc(10, 10, 0, 0);
527         textBlockPanel.add(textIndentUnitCombo, gridBagConstraints);
528         textIndentUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_UNIT_ACCESS_NAME"));
529         textIndentUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_UNIT_ACCESS_DESC"));
530
531         lineHeightLabel.setLabelFor(lineHeightCombo);
532         lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT"));
533         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
534         gridBagConstraints.gridx = 0;
535         gridBagConstraints.gridy = 6;
536         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
537         gridBagConstraints.insets = new java.awt.Insets JavaDoc(6, 0, 0, 10);
538         textBlockPanel.add(lineHeightLabel, gridBagConstraints);
539
540         lineHeightCombo.setEditable(true);
541         lineHeightCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
542             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
543                 lineHeightComboItemStateChanged(evt);
544             }
545         });
546         lineHeightCombo.addActionListener(new java.awt.event.ActionListener JavaDoc() {
547             public void actionPerformed(java.awt.event.ActionEvent JavaDoc evt) {
548                 lineHeightComboActionPerformed(evt);
549             }
550         });
551         lineHeightCombo.addFocusListener(new java.awt.event.FocusAdapter JavaDoc() {
552             public void focusLost(java.awt.event.FocusEvent JavaDoc evt) {
553                 lineHeightComboFocusLost(evt);
554             }
555         });
556
557         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
558         gridBagConstraints.gridx = 1;
559         gridBagConstraints.gridy = 6;
560         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
561         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 0, 0, 0);
562         textBlockPanel.add(lineHeightCombo, gridBagConstraints);
563         lineHeightCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_ACCESS_NAME"));
564         lineHeightCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_ACCESS_DESC"));
565
566         lineHeightUnitCombo.addItemListener(new java.awt.event.ItemListener JavaDoc() {
567             public void itemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {
568                 lineHeightUnitComboItemStateChanged(evt);
569             }
570         });
571
572         gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
573         gridBagConstraints.gridx = 2;
574         gridBagConstraints.gridy = 6;
575         gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
576         gridBagConstraints.insets = new java.awt.Insets JavaDoc(5, 10, 0, 0);
577         textBlockPanel.add(lineHeightUnitCombo, gridBagConstraints);
578         lineHeightUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_UNIT_ACCESS_NAME"));
579         lineHeightUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_UNIT_ACCESS_DESC"));
580
581         add(textBlockPanel, java.awt.BorderLayout.NORTH);
582
583         errorPanel.setLayout(new java.awt.BorderLayout JavaDoc());
584
585         errorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 1));
586         errorLabel.setMinimumSize(new java.awt.Dimension JavaDoc(200, 20));
587         errorPanel.add(errorLabel, java.awt.BorderLayout.CENTER);
588
589         add(errorPanel, java.awt.BorderLayout.CENTER);
590
591     }// </editor-fold>//GEN-END:initComponents
592

593     private void letterSpacingUnitComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_letterSpacingUnitComboItemStateChanged
594
if (evt.getStateChange() != evt.DESELECTED) {
595             setLetterSpacing();
596         }
597     }//GEN-LAST:event_letterSpacingUnitComboItemStateChanged
598

599     private void letterSpacingComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_letterSpacingComboFocusLost
600
setLetterSpacing();
601     }//GEN-LAST:event_letterSpacingComboFocusLost
602

603     private void letterSpacingComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_letterSpacingComboItemStateChanged
604
if (evt.getStateChange() != evt.DESELECTED) {
605             setLetterSpacing();
606         }
607     }//GEN-LAST:event_letterSpacingComboItemStateChanged
608

609     private void letterSpacingComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_letterSpacingComboActionPerformed
610
setLetterSpacing();
611     }//GEN-LAST:event_letterSpacingComboActionPerformed
612

613     private void wordSpacingUnitComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_wordSpacingUnitComboItemStateChanged
614
if (evt.getStateChange() != evt.DESELECTED) {
615             setWordSpacing();
616         }
617     }//GEN-LAST:event_wordSpacingUnitComboItemStateChanged
618

619     private void wordSpacingComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_wordSpacingComboFocusLost
620
setWordSpacing();
621     }//GEN-LAST:event_wordSpacingComboFocusLost
622

623     private void wordSpacingComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_wordSpacingComboItemStateChanged
624
if (evt.getStateChange() != evt.DESELECTED) {
625             setWordSpacing();
626         }
627     }//GEN-LAST:event_wordSpacingComboItemStateChanged
628

629     private void wordSpacingComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_wordSpacingComboActionPerformed
630
setWordSpacing();
631     }//GEN-LAST:event_wordSpacingComboActionPerformed
632

633     private void directionComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_directionComboItemStateChanged
634
setDirection();
635     }//GEN-LAST:event_directionComboItemStateChanged
636

637     private void textIndentUnitComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_textIndentUnitComboItemStateChanged
638
if (evt.getStateChange() != evt.DESELECTED) {
639             setTextIndent();
640         }
641     }//GEN-LAST:event_textIndentUnitComboItemStateChanged
642

643     private void textIndentComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_textIndentComboFocusLost
644
setTextIndent();
645     }//GEN-LAST:event_textIndentComboFocusLost
646

647     private void textIndentComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_textIndentComboItemStateChanged
648
if (evt.getStateChange() != evt.DESELECTED) {
649             setTextIndent();
650         }
651     }//GEN-LAST:event_textIndentComboItemStateChanged
652

653     private void textIndentComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_textIndentComboActionPerformed
654
setTextIndent();
655     }//GEN-LAST:event_textIndentComboActionPerformed
656

657     private void verticalAlignComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_verticalAlignComboFocusLost
658
setVerticalAlign();
659     }//GEN-LAST:event_verticalAlignComboFocusLost
660

661     private void horizontalAlignComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_horizontalAlignComboFocusLost
662
setTextAlign();
663     }//GEN-LAST:event_horizontalAlignComboFocusLost
664

665     private void verticalAlignComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_verticalAlignComboItemStateChanged
666
if (evt.getStateChange() != evt.DESELECTED) {
667             setVerticalAlign();
668         }
669     }//GEN-LAST:event_verticalAlignComboItemStateChanged
670

671     private void verticalAlignComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_verticalAlignComboActionPerformed
672
setVerticalAlign();
673     }//GEN-LAST:event_verticalAlignComboActionPerformed
674

675     private void horizontalAlignComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_horizontalAlignComboItemStateChanged
676
if (evt.getStateChange() != evt.DESELECTED) {
677             setTextAlign();
678         }
679     }//GEN-LAST:event_horizontalAlignComboItemStateChanged
680

681     private void lineHeightUnitComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_lineHeightUnitComboItemStateChanged
682
if (evt.getStateChange() != evt.DESELECTED) {
683             setLineHeight();
684         }
685     }//GEN-LAST:event_lineHeightUnitComboItemStateChanged
686

687     private void lineHeightComboItemStateChanged(java.awt.event.ItemEvent JavaDoc evt) {//GEN-FIRST:event_lineHeightComboItemStateChanged
688
if (evt.getStateChange() != evt.DESELECTED) {
689             setLineHeight();
690         }
691     }//GEN-LAST:event_lineHeightComboItemStateChanged
692

693     private void lineHeightComboFocusLost(java.awt.event.FocusEvent JavaDoc evt) {//GEN-FIRST:event_lineHeightComboFocusLost
694
setLineHeight();
695     }//GEN-LAST:event_lineHeightComboFocusLost
696

697     private void lineHeightComboActionPerformed(java.awt.event.ActionEvent JavaDoc evt) {//GEN-FIRST:event_lineHeightComboActionPerformed
698
setLineHeight();
699     }//GEN-LAST:event_lineHeightComboActionPerformed
700

701     private void setLineHeight(){
702         lineHeightData.setUnit(lineHeightUnitCombo.getSelectedItem().toString());
703         lineHeightData.setValue(lineHeightCombo.getSelectedItem().toString());
704         cssPropertyChangeSupport.firePropertyChange(CssProperties.LINE_HEIGHT, null, lineHeightData.toString());
705         lineHeightUnitCombo.setEnabled(lineHeightData.isValueInteger());
706     }
707     
708     private void setLetterSpacing(){
709         letterSpacingData.setUnit(letterSpacingUnitCombo.getSelectedItem().toString());
710         letterSpacingData.setValue(letterSpacingCombo.getSelectedItem().toString());
711         cssPropertyChangeSupport.firePropertyChange(CssProperties.LETTER_SPACING, null, letterSpacingData.toString());
712         letterSpacingUnitCombo.setEnabled(letterSpacingData.isValueInteger());
713     }
714     
715     private void setWordSpacing(){
716         wordSpacingData.setUnit(wordSpacingUnitCombo.getSelectedItem().toString());
717         wordSpacingData.setValue(wordSpacingCombo.getSelectedItem().toString());
718         cssPropertyChangeSupport.firePropertyChange(CssProperties.WORD_SPACING, null, wordSpacingData.toString());
719         wordSpacingUnitCombo.setEnabled(wordSpacingData.isValueInteger());
720     }
721     
722     private void setDirection(){
723         directionData.setValue(directionCombo.getSelectedItem().toString());
724         cssPropertyChangeSupport.firePropertyChange(CssProperties.DIRECTION, null, directionData.toString());
725     }
726     
727     private void setTextIndent(){
728         textIndentData.setUnit(textIndentUnitCombo.getSelectedItem().toString());
729         textIndentData.setValue(textIndentCombo.getSelectedItem().toString());
730         cssPropertyChangeSupport.firePropertyChange(CssProperties.TEXT_INDENT, null, textIndentData.toString());
731         textIndentUnitCombo.setEnabled(textIndentData.isValueInteger());
732     }
733     
734     private void setVerticalAlign(){
735         verticalAlignData.setValue(verticalAlignCombo.getSelectedItem().toString());
736         cssPropertyChangeSupport.firePropertyChange(CssProperties.VERTICAL_ALIGN, null, verticalAlignData.toString());
737     }
738     
739     private void setTextAlign(){
740         textAlignData.setValue(horizontalAlignCombo.getSelectedItem().toString());
741         cssPropertyChangeSupport.firePropertyChange(CssProperties.TEXT_ALIGN, null, textAlignData.toString());
742     }
743     
744     // Variables declaration - do not modify//GEN-BEGIN:variables
745
private javax.swing.JLabel JavaDoc decorationLabel;
746     private javax.swing.JComboBox JavaDoc directionCombo;
747     private javax.swing.JLabel JavaDoc errorLabel;
748     private javax.swing.JPanel JavaDoc errorPanel;
749     private javax.swing.JComboBox JavaDoc horizontalAlignCombo;
750     private javax.swing.JLabel JavaDoc imageScroll;
751     private javax.swing.JLabel JavaDoc imageScroll1;
752     private javax.swing.JLabel JavaDoc imageScroll2;
753     private javax.swing.JLabel JavaDoc jLabel2;
754     private javax.swing.JComboBox JavaDoc letterSpacingCombo;
755     private javax.swing.JComboBox JavaDoc letterSpacingUnitCombo;
756     private javax.swing.JComboBox JavaDoc lineHeightCombo;
757     private javax.swing.JLabel JavaDoc lineHeightLabel;
758     private javax.swing.JComboBox JavaDoc lineHeightUnitCombo;
759     private javax.swing.JLabel JavaDoc textAlignLabel;
760     private javax.swing.JPanel JavaDoc textBlockPanel;
761     private javax.swing.JComboBox JavaDoc textIndentCombo;
762     private javax.swing.JComboBox JavaDoc textIndentUnitCombo;
763     private javax.swing.JComboBox JavaDoc verticalAlignCombo;
764     private javax.swing.JComboBox JavaDoc wordSpacingCombo;
765     private javax.swing.JComboBox JavaDoc wordSpacingUnitCombo;
766     // End of variables declaration//GEN-END:variables
767

768 }
769
Popular Tags