Source Code Cross Referenced for BackgroundStyleEditor.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » propertyeditors » css » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.propertyeditors.css 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        package org.netbeans.modules.visualweb.propertyeditors.css;
042:
043:        import org.netbeans.modules.visualweb.propertyeditors.css.model.BackgroundModel;
044:        import org.netbeans.modules.visualweb.propertyeditors.css.model.BackgroundPositionData;
045:        import org.netbeans.modules.visualweb.propertyeditors.css.model.CssStyleData;
046:        import org.netbeans.modules.visualweb.propertyeditors.css.model.PropertyData;
047:        import org.netbeans.modules.visualweb.propertyeditors.css.model.Utils;
048:        import com.sun.rave.designtime.DesignProperty;
049:        import java.awt.BorderLayout;
050:        import java.awt.event.FocusAdapter;
051:        import java.awt.event.FocusEvent;
052:        import java.beans.PropertyChangeEvent;
053:        import java.beans.PropertyChangeListener;
054:        import java.io.File;
055:        import javax.swing.DefaultComboBoxModel;
056:        import javax.swing.JTextField;
057:        import javax.swing.SwingUtilities;
058:        import javax.swing.filechooser.FileFilter;
059:        import org.openide.util.NbBundle;
060:
061:        /**
062:         * Background Style editor.
063:         * @author  Winston Prakash
064:         *          Jeff Hoffman (HIE design)
065:         */
066:        public class BackgroundStyleEditor extends StyleEditor implements 
067:                PropertyChangeListener {
068:
069:            CssStyleData cssStyleData = null;
070:            static File currentFile = null;
071:
072:            BackgroundModel backgroundModel = new BackgroundModel();
073:
074:            ColorSelectionField colorField = new ColorSelectionField();
075:            BackgroundPositionData bgPositionData = new BackgroundPositionData();
076:
077:            DesignProperty designProperty = null;
078:
079:            /** Creates new form FontStyleEditor */
080:            public BackgroundStyleEditor(CssStyleData styleData) {
081:                cssStyleData = styleData;
082:                setName("backgroundStyleEditor"); //NOI18N
083:                setDisplayName(NbBundle.getMessage(StyleBuilderDialog.class,
084:                        "BACKGROUND_EDITOR_DISPNAME"));
085:                initComponents();
086:                colorSelectionPanel.add(colorField, BorderLayout.CENTER);
087:                colorField.addCssPropertyChangeListener(this );
088:                initialize();
089:
090:                // Add editor listeners to the horizontal position combobox
091:                final JTextField horizontalPosComboBoxEditor = (JTextField) horizontalPosComboBox
092:                        .getEditor().getEditorComponent();
093:                horizontalPosComboBoxEditor
094:                        .addKeyListener(new java.awt.event.KeyAdapter() {
095:                            public void keyTyped(java.awt.event.KeyEvent evt) {
096:                                SwingUtilities.invokeLater(new Runnable() {
097:                                    public void run() {
098:                                        horizontalUnitComboBox
099:                                                .setEnabled(Utils
100:                                                        .isInteger(horizontalPosComboBoxEditor
101:                                                                .getText()));
102:                                        enablePositionCombo();
103:                                    }
104:                                });
105:                            }
106:                        });
107:
108:                // Add editor listeners to the vertical position combobox
109:                final JTextField verticalPosComboBoxEditor = (JTextField) verticalPosComboBox
110:                        .getEditor().getEditorComponent();
111:                verticalPosComboBoxEditor
112:                        .addKeyListener(new java.awt.event.KeyAdapter() {
113:                            public void keyTyped(java.awt.event.KeyEvent evt) {
114:                                SwingUtilities.invokeLater(new Runnable() {
115:                                    public void run() {
116:                                        verticalUnitComboBox
117:                                                .setEnabled(Utils
118:                                                        .isInteger(verticalPosComboBoxEditor
119:                                                                .getText()));
120:                                    }
121:                                });
122:
123:                            }
124:                        });
125:            }
126:
127:            public void setDesignProperty(DesignProperty liveProperty) {
128:                this .designProperty = liveProperty;
129:            }
130:
131:            private void initialize() {
132:                // Set the Bckground Color to the GUI
133:                String backGroundColor = cssStyleData
134:                        .getProperty(CssStyleData.BACKGROUND_COLOR);
135:                if (backGroundColor != null) {
136:                    colorField.setColorString(backGroundColor);
137:                }
138:
139:                // Set the Bckground Image name to the GUI
140:                String backGroundImage = cssStyleData
141:                        .getProperty(CssStyleData.BACKGROUND_IMAGE);
142:                if (backGroundImage != null) {
143:                    String imgString = backGroundImage.substring(
144:                            backGroundImage.indexOf("(") + 1, backGroundImage
145:                                    .indexOf(")")); //NOI18N
146:                    imageFileField.setText(imgString);
147:                } else {
148:                    imageFileField.setText(CssStyleData.NOT_SET);
149:                }
150:
151:                // Set the background repeat info to the GUI
152:                DefaultComboBoxModel backgroundRepeatList = backgroundModel
153:                        .getBackgroundRepeatList();
154:                repeatComboBox.setModel(backgroundRepeatList);
155:                String backGroundRepeat = cssStyleData
156:                        .getProperty(CssStyleData.BACKGROUND_REPEAT);
157:                if (backGroundRepeat != null) {
158:                    repeatComboBox.setSelectedItem(backGroundRepeat);
159:                } else {
160:                    repeatComboBox.setSelectedIndex(0);
161:                }
162:
163:                // Set the background scroll to the GUI
164:                DefaultComboBoxModel backgroundScrollList = backgroundModel
165:                        .getBackgroundScrollList();
166:                scrollComboBox.setModel(backgroundScrollList);
167:                String backGroundScroll = cssStyleData
168:                        .getProperty(CssStyleData.BACKGROUND_ATTACHMENT);
169:                if (backGroundScroll != null) {
170:                    scrollComboBox.setSelectedItem(backGroundScroll);
171:                } else {
172:                    scrollComboBox.setSelectedIndex(0);
173:                }
174:
175:                // Set the background poistion data to the GUI
176:                horizontalPosComboBox.setModel(backgroundModel
177:                        .getBackgroundPositionList());
178:                verticalPosComboBox.setModel(backgroundModel
179:                        .getBackgroundPositionList());
180:                horizontalUnitComboBox.setModel(backgroundModel
181:                        .getBackgroundPositionUnitList());
182:                verticalUnitComboBox.setModel(backgroundModel
183:                        .getBackgroundPositionUnitList());
184:
185:                String backgroundPosition = cssStyleData
186:                        .getProperty(CssStyleData.BACKGROUND_POSITION);
187:                if (backgroundPosition != null) {
188:                    bgPositionData.setBackgroundPosition(backgroundPosition);
189:                    horizontalPosComboBox.setSelectedItem(bgPositionData
190:                            .getHorizontalValue());
191:                    horizontalUnitComboBox.setSelectedItem(bgPositionData
192:                            .getHorizontalUnit());
193:                    verticalPosComboBox.setSelectedItem(bgPositionData
194:                            .getVerticalValue());
195:                    verticalUnitComboBox.setSelectedItem(bgPositionData
196:                            .getVerticalUnit());
197:                } else {
198:                    horizontalPosComboBox.setSelectedIndex(0);
199:                    verticalPosComboBox.setSelectedIndex(0);
200:                }
201:
202:                verticalPosComboBox.getEditor().getEditorComponent()
203:                        .addFocusListener(new FocusAdapter() {
204:                            public void focusGained(FocusEvent evt) {
205:                                errorLabel
206:                                        .setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
207:                            }
208:
209:                            public void focusLost(FocusEvent evt) {
210:                                errorLabel.setText("");
211:                            }
212:                        });
213:
214:                horizontalPosComboBox.getEditor().getEditorComponent()
215:                        .addFocusListener(new FocusAdapter() {
216:                            public void focusGained(FocusEvent evt) {
217:                                errorLabel
218:                                        .setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
219:                            }
220:
221:                            public void focusLost(FocusEvent evt) {
222:                                errorLabel.setText("");
223:                            }
224:                        });
225:
226:                scrollComboBox.addFocusListener(new FocusAdapter() {
227:                    public void focusGained(FocusEvent evt) {
228:                        errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED);
229:                    }
230:
231:                    public void focusLost(FocusEvent evt) {
232:                        errorLabel.setText("");
233:                    }
234:                });
235:
236:            }
237:
238:            /** Listens to the color property change in the color chooser filed */
239:            public void propertyChange(PropertyChangeEvent evt) {
240:                setBackgroundColor();
241:            }
242:
243:            // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
244:            private void initComponents() {
245:                java.awt.GridBagConstraints gridBagConstraints;
246:
247:                colorPanel = new javax.swing.JPanel();
248:                colorLabel = new javax.swing.JLabel();
249:                browseButton = new javax.swing.JButton();
250:                imageFileField = new javax.swing.JTextField();
251:                lineHeightLabel = new javax.swing.JLabel();
252:                imageTileLabel = new javax.swing.JLabel();
253:                imageScrollLabel = new javax.swing.JLabel();
254:                scrollComboBox = new javax.swing.JComboBox();
255:                repeatComboBox = new javax.swing.JComboBox();
256:                horizontalPosLabel = new javax.swing.JLabel();
257:                verticalPosLabel = new javax.swing.JLabel();
258:                horizontalPosComboBox = new javax.swing.JComboBox();
259:                verticalPosComboBox = new javax.swing.JComboBox();
260:                horizontalUnitComboBox = new javax.swing.JComboBox();
261:                verticalUnitComboBox = new javax.swing.JComboBox();
262:                colorSelectionPanel = new javax.swing.JPanel();
263:                errorPanel = new javax.swing.JPanel();
264:                errorLabel = new javax.swing.JLabel();
265:
266:                setLayout(new java.awt.BorderLayout());
267:
268:                colorPanel.setBorder(javax.swing.BorderFactory
269:                        .createEmptyBorder(5, 5, 5, 5));
270:                colorPanel.setLayout(new java.awt.GridBagLayout());
271:
272:                colorLabel.setLabelFor(colorPanel);
273:                colorLabel.setText(org.openide.util.NbBundle.getMessage(
274:                        BackgroundStyleEditor.class, "BACKGROUND_COLOR")); // NOI18N
275:                gridBagConstraints = new java.awt.GridBagConstraints();
276:                gridBagConstraints.gridx = 0;
277:                gridBagConstraints.gridy = 0;
278:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
279:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
280:                colorPanel.add(colorLabel, gridBagConstraints);
281:
282:                browseButton.setText("...");
283:                java.util.ResourceBundle bundle = java.util.ResourceBundle
284:                        .getBundle("org/netbeans/modules/visualweb/propertyeditors/css/Bundle"); // NOI18N
285:                browseButton.setToolTipText(bundle
286:                        .getString("BG_SELECTION_BUTTON_TOOLTIP")); // NOI18N
287:                browseButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
288:                browseButton.setPreferredSize(new java.awt.Dimension(20, 20));
289:                browseButton
290:                        .addActionListener(new java.awt.event.ActionListener() {
291:                            public void actionPerformed(
292:                                    java.awt.event.ActionEvent evt) {
293:                                browseButtonActionPerformed(evt);
294:                            }
295:                        });
296:                gridBagConstraints = new java.awt.GridBagConstraints();
297:                gridBagConstraints.gridx = 3;
298:                gridBagConstraints.gridy = 1;
299:                gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
300:                gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
301:                gridBagConstraints.insets = new java.awt.Insets(6, 3, 0, 0);
302:                colorPanel.add(browseButton, gridBagConstraints);
303:                browseButton
304:                        .getAccessibleContext()
305:                        .setAccessibleName(
306:                                bundle
307:                                        .getString("BG_SELECTION_BUTTON_ACCESSIBLE_NAME")); // NOI18N
308:                browseButton
309:                        .getAccessibleContext()
310:                        .setAccessibleDescription(
311:                                bundle
312:                                        .getString("BG_SELECTION_BUTTON_ACCESSIBLE_DESC")); // NOI18N
313:
314:                imageFileField
315:                        .addActionListener(new java.awt.event.ActionListener() {
316:                            public void actionPerformed(
317:                                    java.awt.event.ActionEvent evt) {
318:                                imageFileFieldActionPerformed(evt);
319:                            }
320:                        });
321:                imageFileField
322:                        .addFocusListener(new java.awt.event.FocusAdapter() {
323:                            public void focusLost(java.awt.event.FocusEvent evt) {
324:                                imageFileFieldFocusLost(evt);
325:                            }
326:                        });
327:                gridBagConstraints = new java.awt.GridBagConstraints();
328:                gridBagConstraints.gridx = 1;
329:                gridBagConstraints.gridy = 1;
330:                gridBagConstraints.gridwidth = 2;
331:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
332:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
333:                gridBagConstraints.weightx = 1.0;
334:                gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
335:                colorPanel.add(imageFileField, gridBagConstraints);
336:                imageFileField.getAccessibleContext().setAccessibleDescription(
337:                        org.openide.util.NbBundle.getMessage(
338:                                BackgroundStyleEditor.class,
339:                                "BG_IMAGE_FIELD_ACCESS_DESC")); // NOI18N
340:
341:                lineHeightLabel
342:                        .setDisplayedMnemonic(java.util.ResourceBundle
343:                                .getBundle(
344:                                        "org/netbeans/modules/visualweb/propertyeditors/css/Bundle")
345:                                .getString("BACKGROUND_IMAGE_MNEMONIC").charAt(
346:                                        0));
347:                lineHeightLabel.setLabelFor(imageFileField);
348:                lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(
349:                        BackgroundStyleEditor.class, "BACKGROUND_IMAGE")); // NOI18N
350:                lineHeightLabel
351:                        .setVerticalAlignment(javax.swing.SwingConstants.TOP);
352:                gridBagConstraints = new java.awt.GridBagConstraints();
353:                gridBagConstraints.gridx = 0;
354:                gridBagConstraints.gridy = 1;
355:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
356:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
357:                colorPanel.add(lineHeightLabel, gridBagConstraints);
358:
359:                imageTileLabel
360:                        .setDisplayedMnemonic(java.util.ResourceBundle
361:                                .getBundle(
362:                                        "org/netbeans/modules/visualweb/propertyeditors/css/Bundle")
363:                                .getString("BACKGROUNDTILE_MNEMONIC").charAt(0));
364:                imageTileLabel.setLabelFor(repeatComboBox);
365:                imageTileLabel.setText(org.openide.util.NbBundle.getMessage(
366:                        BackgroundStyleEditor.class, "BACKGROUNDTILE")); // NOI18N
367:                gridBagConstraints = new java.awt.GridBagConstraints();
368:                gridBagConstraints.gridx = 0;
369:                gridBagConstraints.gridy = 2;
370:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
371:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
372:                colorPanel.add(imageTileLabel, gridBagConstraints);
373:
374:                imageScrollLabel
375:                        .setDisplayedMnemonic(java.util.ResourceBundle
376:                                .getBundle(
377:                                        "org/netbeans/modules/visualweb/propertyeditors/css/Bundle")
378:                                .getString("BACKGROUND_SCROLL_MNEMONIC")
379:                                .charAt(0));
380:                imageScrollLabel.setLabelFor(scrollComboBox);
381:                imageScrollLabel.setText(org.openide.util.NbBundle.getMessage(
382:                        BackgroundStyleEditor.class, "BACKGROUND_SCROLL")); // NOI18N
383:                gridBagConstraints = new java.awt.GridBagConstraints();
384:                gridBagConstraints.gridx = 0;
385:                gridBagConstraints.gridy = 3;
386:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
387:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
388:                colorPanel.add(imageScrollLabel, gridBagConstraints);
389:
390:                scrollComboBox
391:                        .addItemListener(new java.awt.event.ItemListener() {
392:                            public void itemStateChanged(
393:                                    java.awt.event.ItemEvent evt) {
394:                                scrollComboBoxItemStateChanged(evt);
395:                            }
396:                        });
397:                gridBagConstraints = new java.awt.GridBagConstraints();
398:                gridBagConstraints.gridx = 1;
399:                gridBagConstraints.gridy = 3;
400:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
401:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
402:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
403:                colorPanel.add(scrollComboBox, gridBagConstraints);
404:                scrollComboBox.getAccessibleContext().setAccessibleDescription(
405:                        bundle.getString("SCROLL_COMBO_ACCESSIBLE_DESC")); // NOI18N
406:
407:                repeatComboBox
408:                        .addItemListener(new java.awt.event.ItemListener() {
409:                            public void itemStateChanged(
410:                                    java.awt.event.ItemEvent evt) {
411:                                repeatComboBoxItemStateChanged(evt);
412:                            }
413:                        });
414:                gridBagConstraints = new java.awt.GridBagConstraints();
415:                gridBagConstraints.gridx = 1;
416:                gridBagConstraints.gridy = 2;
417:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
418:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
419:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
420:                colorPanel.add(repeatComboBox, gridBagConstraints);
421:                repeatComboBox.getAccessibleContext().setAccessibleDescription(
422:                        bundle.getString("TILE_COMBO_ACCESSIBLE_DESC")); // NOI18N
423:
424:                horizontalPosLabel.setLabelFor(horizontalPosComboBox);
425:                horizontalPosLabel.setText(org.openide.util.NbBundle
426:                        .getMessage(BackgroundStyleEditor.class,
427:                                "BG_HORIZONTAL_POS")); // NOI18N
428:                gridBagConstraints = new java.awt.GridBagConstraints();
429:                gridBagConstraints.gridx = 0;
430:                gridBagConstraints.gridy = 4;
431:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
432:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
433:                colorPanel.add(horizontalPosLabel, gridBagConstraints);
434:
435:                verticalPosLabel.setLabelFor(verticalPosComboBox);
436:                verticalPosLabel.setText(org.openide.util.NbBundle.getMessage(
437:                        BackgroundStyleEditor.class, "BG_VERTICAL_POS")); // NOI18N
438:                gridBagConstraints = new java.awt.GridBagConstraints();
439:                gridBagConstraints.gridx = 0;
440:                gridBagConstraints.gridy = 5;
441:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
442:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
443:                colorPanel.add(verticalPosLabel, gridBagConstraints);
444:
445:                horizontalPosComboBox.setEditable(true);
446:                horizontalPosComboBox
447:                        .addItemListener(new java.awt.event.ItemListener() {
448:                            public void itemStateChanged(
449:                                    java.awt.event.ItemEvent evt) {
450:                                horizontalPosComboBoxItemStateChanged(evt);
451:                            }
452:                        });
453:                horizontalPosComboBox
454:                        .addActionListener(new java.awt.event.ActionListener() {
455:                            public void actionPerformed(
456:                                    java.awt.event.ActionEvent evt) {
457:                                horizontalPosComboBoxActionPerformed(evt);
458:                            }
459:                        });
460:                gridBagConstraints = new java.awt.GridBagConstraints();
461:                gridBagConstraints.gridx = 1;
462:                gridBagConstraints.gridy = 4;
463:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
464:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
465:                gridBagConstraints.weightx = 1.0;
466:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
467:                colorPanel.add(horizontalPosComboBox, gridBagConstraints);
468:                horizontalPosComboBox
469:                        .getAccessibleContext()
470:                        .setAccessibleDescription(
471:                                bundle
472:                                        .getString("HORIZPOS_COMBO_ACCESSIBLE_DESC")); // NOI18N
473:
474:                verticalPosComboBox.setEditable(true);
475:                verticalPosComboBox.setEnabled(false);
476:                verticalPosComboBox
477:                        .addItemListener(new java.awt.event.ItemListener() {
478:                            public void itemStateChanged(
479:                                    java.awt.event.ItemEvent evt) {
480:                                verticalPosComboBoxItemStateChanged(evt);
481:                            }
482:                        });
483:                verticalPosComboBox
484:                        .addActionListener(new java.awt.event.ActionListener() {
485:                            public void actionPerformed(
486:                                    java.awt.event.ActionEvent evt) {
487:                                verticalPosComboBoxActionPerformed(evt);
488:                            }
489:                        });
490:                gridBagConstraints = new java.awt.GridBagConstraints();
491:                gridBagConstraints.gridx = 1;
492:                gridBagConstraints.gridy = 5;
493:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
494:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
495:                gridBagConstraints.weightx = 1.0;
496:                gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
497:                colorPanel.add(verticalPosComboBox, gridBagConstraints);
498:                verticalPosComboBox
499:                        .getAccessibleContext()
500:                        .setAccessibleDescription(
501:                                bundle
502:                                        .getString("VERTPOS_COMBO_ACCESSIBLE_DESC")); // NOI18N
503:
504:                horizontalUnitComboBox.setEnabled(false);
505:                horizontalUnitComboBox
506:                        .addItemListener(new java.awt.event.ItemListener() {
507:                            public void itemStateChanged(
508:                                    java.awt.event.ItemEvent evt) {
509:                                horizontalUnitComboBoxItemStateChanged(evt);
510:                            }
511:                        });
512:                gridBagConstraints = new java.awt.GridBagConstraints();
513:                gridBagConstraints.gridx = 2;
514:                gridBagConstraints.gridy = 4;
515:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
516:                gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
517:                colorPanel.add(horizontalUnitComboBox, gridBagConstraints);
518:                horizontalUnitComboBox
519:                        .getAccessibleContext()
520:                        .setAccessibleName(
521:                                bundle
522:                                        .getString("HORIZPOS_UNIT_COMBO_ACCESSIBLE_NAME")); // NOI18N
523:                horizontalUnitComboBox
524:                        .getAccessibleContext()
525:                        .setAccessibleDescription(
526:                                bundle
527:                                        .getString("HORIZPOS_UNIT_COMBO_ACCESSIBLE_DESC")); // NOI18N
528:
529:                verticalUnitComboBox.setEnabled(false);
530:                verticalUnitComboBox
531:                        .addItemListener(new java.awt.event.ItemListener() {
532:                            public void itemStateChanged(
533:                                    java.awt.event.ItemEvent evt) {
534:                                verticalUnitComboBoxItemStateChanged(evt);
535:                            }
536:                        });
537:                gridBagConstraints = new java.awt.GridBagConstraints();
538:                gridBagConstraints.gridx = 2;
539:                gridBagConstraints.gridy = 5;
540:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
541:                gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
542:                colorPanel.add(verticalUnitComboBox, gridBagConstraints);
543:                verticalUnitComboBox.getAccessibleContext().setAccessibleName(
544:                        bundle.getString("VERTPOS_UNIT_COMBO_ACCESSIBLE_NAME")); // NOI18N
545:                verticalUnitComboBox
546:                        .getAccessibleContext()
547:                        .setAccessibleDescription(
548:                                bundle
549:                                        .getString("VERTPOS_UNIT_COMBO_ACCESSIBLE_DESC")); // NOI18N
550:
551:                colorSelectionPanel.setLayout(new java.awt.BorderLayout());
552:                gridBagConstraints = new java.awt.GridBagConstraints();
553:                gridBagConstraints.gridwidth = 3;
554:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
555:                colorPanel.add(colorSelectionPanel, gridBagConstraints);
556:
557:                add(colorPanel, java.awt.BorderLayout.NORTH);
558:
559:                errorPanel.setBorder(javax.swing.BorderFactory
560:                        .createEmptyBorder(1, 10, 1, 1));
561:                errorPanel.setLayout(new java.awt.BorderLayout());
562:
563:                errorLabel.setForeground(new java.awt.Color(0, 0, 153));
564:                errorLabel.setMinimumSize(new java.awt.Dimension(200, 20));
565:                errorLabel.setPreferredSize(new java.awt.Dimension(200, 20));
566:                errorPanel.add(errorLabel, java.awt.BorderLayout.CENTER);
567:
568:                add(errorPanel, java.awt.BorderLayout.SOUTH);
569:            }// </editor-fold>//GEN-END:initComponents
570:
571:            private void verticalUnitComboBoxItemStateChanged(
572:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_verticalUnitComboBoxItemStateChanged
573:                if (evt.getStateChange() != evt.DESELECTED) {
574:                    bgPositionData
575:                            .setVerticalUnit((String) verticalUnitComboBox
576:                                    .getSelectedItem());
577:                    setBackgroundPosition();
578:                }
579:            }//GEN-LAST:event_verticalUnitComboBoxItemStateChanged
580:
581:            private void horizontalUnitComboBoxItemStateChanged(
582:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_horizontalUnitComboBoxItemStateChanged
583:                if (evt.getStateChange() != evt.DESELECTED) {
584:                    bgPositionData
585:                            .setHorizontalUnit((String) horizontalUnitComboBox
586:                                    .getSelectedItem());
587:                    setBackgroundPosition();
588:                }
589:            }//GEN-LAST:event_horizontalUnitComboBoxItemStateChanged
590:
591:            private void verticalPosComboBoxItemStateChanged(
592:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_verticalPosComboBoxItemStateChanged
593:                if (evt.getStateChange() != evt.DESELECTED) {
594:                    bgPositionData
595:                            .setVerticalValue((String) verticalPosComboBox
596:                                    .getSelectedItem());
597:                    setBackgroundPosition();
598:                }
599:            }//GEN-LAST:event_verticalPosComboBoxItemStateChanged
600:
601:            private void verticalPosComboBoxActionPerformed(
602:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_verticalPosComboBoxActionPerformed
603:                bgPositionData.setVerticalValue((String) verticalPosComboBox
604:                        .getSelectedItem());
605:                setBackgroundPosition();
606:            }//GEN-LAST:event_verticalPosComboBoxActionPerformed
607:
608:            private void horizontalPosComboBoxItemStateChanged(
609:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_horizontalPosComboBoxItemStateChanged
610:                if (evt.getStateChange() != evt.DESELECTED) {
611:                    bgPositionData
612:                            .setHorizontalValue((String) horizontalPosComboBox
613:                                    .getSelectedItem());
614:                    setBackgroundPosition();
615:                }
616:            }//GEN-LAST:event_horizontalPosComboBoxItemStateChanged
617:
618:            private void horizontalPosComboBoxActionPerformed(
619:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_horizontalPosComboBoxActionPerformed
620:                bgPositionData
621:                        .setHorizontalValue((String) horizontalPosComboBox
622:                                .getSelectedItem());
623:                setBackgroundPosition();
624:            }//GEN-LAST:event_horizontalPosComboBoxActionPerformed
625:
626:            private void scrollComboBoxItemStateChanged(
627:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_scrollComboBoxItemStateChanged
628:                setBackgroundAttachment();
629:            }//GEN-LAST:event_scrollComboBoxItemStateChanged
630:
631:            private void repeatComboBoxItemStateChanged(
632:                    java.awt.event.ItemEvent evt) {//GEN-FIRST:event_repeatComboBoxItemStateChanged
633:                if (evt.getStateChange() != evt.DESELECTED) {
634:                    setBackgroundRepeat();
635:                }
636:            }//GEN-LAST:event_repeatComboBoxItemStateChanged
637:
638:            private void imageFileFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_imageFileFieldFocusLost
639:                setBackgroundImage();
640:            }//GEN-LAST:event_imageFileFieldFocusLost
641:
642:            private void imageFileFieldActionPerformed(
643:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageFileFieldActionPerformed
644:                setBackgroundImage();
645:            }//GEN-LAST:event_imageFileFieldActionPerformed
646:
647:            private void browseButtonActionPerformed(
648:                    java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
649:
650:                BackgroundImageUrlDialog imageUrlDialog = new BackgroundImageUrlDialog();
651:                if (designProperty != null) {
652:                    imageUrlDialog.setDesignContext(designProperty
653:                            .getDesignBean().getDesignContext());
654:                }
655:                imageUrlDialog.initialize();
656:                imageUrlDialog.showDialog();
657:                String imgResource = (String) imageUrlDialog.getPropertyValue();
658:                if (imgResource.startsWith("/")) {
659:                    imgResource = "." + imgResource;
660:                }
661:                StringBuffer sb = new StringBuffer();
662:                int len = imgResource.length();
663:                for (int i = 0; i < len; i++) {
664:                    char chr = imgResource.charAt(i);
665:                    if (chr == ' ') {
666:                        sb.append("%20");
667:                    } else {
668:                        sb.append(chr);
669:                    }
670:                }
671:                imgResource = sb.toString();
672:                imageFileField.setText(imgResource);
673:                setBackgroundImage();
674:            }//GEN-LAST:event_browseButtonActionPerformed
675:
676:            class ImageFileFilter extends FileFilter {
677:
678:                //Accept all directories and all ".jar" files.
679:                public boolean accept(File f) {
680:                    if (f.isDirectory()) {
681:                        return true;
682:                    }
683:                    String extension = null;
684:                    String s = f.getName();
685:                    int i = s.lastIndexOf('.');
686:
687:                    if (i > 0 && i < s.length() - 1) {
688:                        extension = s.substring(i + 1).toLowerCase();
689:                    }
690:
691:                    if (extension != null) {
692:                        if (extension.toLowerCase().equals("gif") || //NOI18N
693:                                extension.toLowerCase().equals("jpg") || //NOI18N
694:                                extension.toLowerCase().equals("png")) { //NOI18N
695:                            return true;
696:                        } else {
697:                            return false;
698:                        }
699:                    }
700:                    return false;
701:                }
702:
703:                //The description of this filter
704:                public String getDescription() {
705:                    return NbBundle.getMessage(BackgroundStyleEditor.class,
706:                            "IMAGE_FILE_FILTER");
707:                }
708:            }
709:
710:            private void setBackgroundColor() {
711:                PropertyData backgroundColorData = new PropertyData();
712:                backgroundColorData.setValue(colorField.getColorString());
713:                cssStyleData.modifyProperty(CssStyleData.BACKGROUND_COLOR,
714:                        backgroundColorData.toString());
715:            }
716:
717:            private void setBackgroundImage() {
718:                PropertyData backgroundImageData = new PropertyData();
719:                String imgPath = imageFileField.getText();
720:                if ((imgPath == null) || (imgPath.equals(""))) {
721:                    imgPath = CssStyleData.NOT_SET;
722:                    imageFileField.setText(imgPath);
723:                }
724:                backgroundImageData.setValue("url(" + imgPath + ")"); //NOI18N
725:                cssStyleData.modifyProperty(CssStyleData.BACKGROUND_IMAGE,
726:                        backgroundImageData.toString());
727:            }
728:
729:            private void setBackgroundRepeat() {
730:                PropertyData backgroundRepeatData = new PropertyData();
731:                backgroundRepeatData.setValue(repeatComboBox.getSelectedItem()
732:                        .toString());
733:                cssStyleData.modifyProperty(CssStyleData.BACKGROUND_REPEAT,
734:                        backgroundRepeatData.toString());
735:            }
736:
737:            private void setBackgroundAttachment() {
738:                PropertyData backgroundAttachmentData = new PropertyData();
739:                backgroundAttachmentData.setValue(scrollComboBox
740:                        .getSelectedItem().toString());
741:                cssStyleData.modifyProperty(CssStyleData.BACKGROUND_ATTACHMENT,
742:                        backgroundAttachmentData.toString());
743:            }
744:
745:            private void setBackgroundPosition() {
746:                String backgroundPosition = bgPositionData.toString();
747:                cssStyleData.modifyProperty(CssStyleData.BACKGROUND_POSITION,
748:                        backgroundPosition);
749:                enablePositionCombo();
750:            }
751:
752:            private void enablePositionCombo() {
753:                String horizontalPos = bgPositionData.getHorizontalValue();
754:                if (Utils.isInteger(horizontalPos)) {
755:                    horizontalUnitComboBox.setEnabled(true);
756:                } else {
757:                    horizontalUnitComboBox.setEnabled(false);
758:                }
759:                if ((horizontalPos.equals("")
760:                        || horizontalPos.startsWith(CssStyleData.NOT_SET) || horizontalPos
761:                        .startsWith(CssStyleData.VALUE))) {
762:                    verticalPosComboBox.setEnabled(false);
763:                    verticalUnitComboBox.setEnabled(false);
764:                } else {
765:                    verticalPosComboBox.setEnabled(true);
766:                    verticalUnitComboBox.setEnabled(true);
767:                }
768:                String verticalPos = bgPositionData.getVerticalValue();
769:                if (Utils.isInteger(verticalPos)) {
770:                    verticalUnitComboBox.setEnabled(true);
771:                } else {
772:                    verticalUnitComboBox.setEnabled(false);
773:                }
774:            }
775:
776:            // Variables declaration - do not modify//GEN-BEGIN:variables
777:            private javax.swing.JButton browseButton;
778:            private javax.swing.JLabel colorLabel;
779:            private javax.swing.JPanel colorPanel;
780:            private javax.swing.JPanel colorSelectionPanel;
781:            private javax.swing.JLabel errorLabel;
782:            private javax.swing.JPanel errorPanel;
783:            private javax.swing.JComboBox horizontalPosComboBox;
784:            private javax.swing.JLabel horizontalPosLabel;
785:            private javax.swing.JComboBox horizontalUnitComboBox;
786:            private javax.swing.JTextField imageFileField;
787:            private javax.swing.JLabel imageScrollLabel;
788:            private javax.swing.JLabel imageTileLabel;
789:            private javax.swing.JLabel lineHeightLabel;
790:            private javax.swing.JComboBox repeatComboBox;
791:            private javax.swing.JComboBox scrollComboBox;
792:            private javax.swing.JComboBox verticalPosComboBox;
793:            private javax.swing.JLabel verticalPosLabel;
794:            private javax.swing.JComboBox verticalUnitComboBox;
795:            // End of variables declaration//GEN-END:variables
796:
797:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.