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:
042: /*
043: * BackgroundStyleEditor.java
044: *
045: * Created on October 13, 2004, 12:23 PM
046: */
047:
048: package org.netbeans.modules.css.visual.ui;
049:
050: import org.netbeans.modules.css.visual.model.BackgroundModel;
051: import org.netbeans.modules.css.visual.model.BackgroundPositionData;
052: import org.netbeans.modules.css.visual.model.CssProperties;
053: import org.netbeans.modules.css.editor.model.CssRuleContent;
054: import org.netbeans.modules.css.visual.model.PropertyData;
055: import org.netbeans.modules.css.visual.model.PropertyData;
056: import java.awt.BorderLayout;
057: import java.beans.PropertyChangeEvent;
058: import java.beans.PropertyChangeListener;
059: import java.io.File;
060: import javax.swing.DefaultComboBoxModel;
061: import javax.swing.JTextField;
062: import javax.swing.SwingUtilities;
063: import org.netbeans.modules.css.visual.model.Utils;
064: import org.openide.util.NbBundle;
065:
066: /**
067: * Background Style editor.
068: * @author Winston Prakash
069: * @version 1.0
070: */
071: public class BackgroundStyleEditor extends StyleEditor {
072:
073: ColorSelectionField colorField = new ColorSelectionField();
074: BackgroundPositionData bgPositionData = new BackgroundPositionData();
075:
076: /** Creates new form FontStyleEditor */
077: public BackgroundStyleEditor() {
078: setName("backgroundStyleEditor"); //NOI18N
079: setDisplayName(NbBundle.getMessage(BackgroundStyleEditor.class,
080: "BACKGROUND_EDITOR_DISPNAME"));
081: initComponents();
082: colorSelectionPanel.add(colorField, BorderLayout.CENTER);
083: colorField.addPropertyChangeListener("color",
084: new PropertyChangeListener() {
085: public void propertyChange(PropertyChangeEvent evt) {
086: setBackgroundColor();
087: }
088: });
089: initialize();
090:
091: // Add editor listeners to the horizontal position combobox
092: final JTextField horizontalPosComboBoxEditor = (JTextField) horizontalPosComboBox
093: .getEditor().getEditorComponent();
094: horizontalPosComboBoxEditor
095: .addKeyListener(new java.awt.event.KeyAdapter() {
096: public void keyTyped(java.awt.event.KeyEvent evt) {
097: SwingUtilities.invokeLater(new Runnable() {
098: public void run() {
099: horizontalUnitComboBox
100: .setEnabled(Utils
101: .isInteger(horizontalPosComboBoxEditor
102: .getText()));
103: enablePositionCombo();
104: }
105: });
106: }
107: });
108:
109: // Add editor listeners to the vertical position combobox
110: final JTextField verticalPosComboBoxEditor = (JTextField) verticalPosComboBox
111: .getEditor().getEditorComponent();
112: verticalPosComboBoxEditor
113: .addKeyListener(new java.awt.event.KeyAdapter() {
114: public void keyTyped(java.awt.event.KeyEvent evt) {
115: SwingUtilities.invokeLater(new Runnable() {
116: public void run() {
117: verticalUnitComboBox
118: .setEnabled(Utils
119: .isInteger(verticalPosComboBoxEditor
120: .getText()));
121: }
122: });
123:
124: }
125: });
126: }
127:
128: protected void initialize() {
129: // Set the background repeat info to the GUI
130: BackgroundModel backgroundModel = new BackgroundModel();
131: DefaultComboBoxModel backgroundRepeatList = backgroundModel
132: .getBackgroundRepeatList();
133: repeatComboBox.setModel(backgroundRepeatList);
134:
135: // Set the background scroll to the GUI
136: DefaultComboBoxModel backgroundScrollList = backgroundModel
137: .getBackgroundScrollList();
138: scrollComboBox.setModel(backgroundScrollList);
139:
140: // Set the background poistion data to the GUI
141:
142: horizontalPosComboBox.setModel(backgroundModel
143: .getBackgroundPositionList());
144: verticalPosComboBox.setModel(backgroundModel
145: .getBackgroundPositionList());
146: horizontalUnitComboBox.setModel(backgroundModel
147: .getBackgroundPositionUnitList());
148: verticalUnitComboBox.setModel(backgroundModel
149: .getBackgroundPositionUnitList());
150: }
151:
152: /**
153: * Set the CSS Properties Values from the CssStyleData data structure
154: * to the GUI components.
155: */
156: protected void setCssPropertyValues(CssRuleContent cssStyleData) {
157: removeCssPropertyChangeListener();
158:
159: // Set the Bckground Color to the GUI
160: String backGroundColor = cssStyleData
161: .getProperty(CssProperties.BACKGROUND_COLOR);
162: if (backGroundColor != null) {
163: colorField.setColorString(backGroundColor);
164: } else {
165: colorField.setColorString(CssRuleContent.NOT_SET);
166: }
167:
168: // Set the Bckground Image name to the GUI
169: String backGroundImage = cssStyleData
170: .getProperty(CssProperties.BACKGROUND_IMAGE);
171: if (backGroundImage != null
172: && !backGroundImage.trim().equals("")) {
173: int openBracketPos = backGroundImage.indexOf("(");
174: int endBracketPos = backGroundImage.indexOf(")");
175: if ((openBracketPos >= 0) && (endBracketPos >= 0)) {
176: String imgString = backGroundImage.substring(
177: openBracketPos + 1, endBracketPos);
178: imageFileField.setText(imgString);
179: } else {
180: imageFileField.setText(backGroundImage);
181: }
182: } else {
183: imageFileField.setText(CssRuleContent.NOT_SET);
184: }
185:
186: String backGroundRepeat = cssStyleData
187: .getProperty(CssProperties.BACKGROUND_REPEAT);
188: if (backGroundRepeat != null) {
189: repeatComboBox.setSelectedItem(backGroundRepeat);
190: } else {
191: repeatComboBox.setSelectedIndex(0);
192: }
193:
194: String backGroundScroll = cssStyleData
195: .getProperty(CssProperties.BACKGROUND_ATTACHMENT);
196: if (backGroundScroll != null) {
197: scrollComboBox.setSelectedItem(backGroundScroll);
198: } else {
199: scrollComboBox.setSelectedIndex(0);
200: }
201:
202: String backgroundPosition = cssStyleData
203: .getProperty(CssProperties.BACKGROUND_POSITION);
204: if (backgroundPosition != null) {
205: bgPositionData.setBackgroundPosition(backgroundPosition);
206: horizontalPosComboBox.setSelectedItem(bgPositionData
207: .getHorizontalValue());
208: horizontalUnitComboBox.setSelectedItem(bgPositionData
209: .getHorizontalUnit());
210: verticalPosComboBox.setSelectedItem(bgPositionData
211: .getVerticalValue());
212: verticalUnitComboBox.setSelectedItem(bgPositionData
213: .getVerticalUnit());
214: } else {
215: horizontalPosComboBox.setSelectedIndex(0);
216: verticalPosComboBox.setSelectedIndex(0);
217: }
218: setCssPropertyChangeListener(cssStyleData);
219: }
220:
221: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
222: private void initComponents() {
223: java.awt.GridBagConstraints gridBagConstraints;
224:
225: colorPanel = new javax.swing.JPanel();
226: colorLabel = new javax.swing.JLabel();
227: browseButton = new javax.swing.JButton();
228: imageFileField = new javax.swing.JTextField();
229: lineHeightLabel = new javax.swing.JLabel();
230: imageTileLabel = new javax.swing.JLabel();
231: imageScrollLabel = new javax.swing.JLabel();
232: scrollComboBox = new javax.swing.JComboBox();
233: repeatComboBox = new javax.swing.JComboBox();
234: horizontalPosLabel = new javax.swing.JLabel();
235: verticalPosLabel = new javax.swing.JLabel();
236: horizontalPosComboBox = new javax.swing.JComboBox();
237: verticalPosComboBox = new javax.swing.JComboBox();
238: horizontalUnitComboBox = new javax.swing.JComboBox();
239: verticalUnitComboBox = new javax.swing.JComboBox();
240: colorSelectionPanel = new javax.swing.JPanel();
241: errorPanel = new javax.swing.JPanel();
242: errorLabel = new javax.swing.JLabel();
243:
244: setLayout(new java.awt.BorderLayout());
245:
246: colorPanel.setBorder(javax.swing.BorderFactory
247: .createEmptyBorder(5, 5, 5, 5));
248: colorPanel.setLayout(new java.awt.GridBagLayout());
249:
250: colorLabel.setDisplayedMnemonic(java.util.ResourceBundle
251: .getBundle("org/netbeans/modules/css/visual/ui/Bundle")
252: .getString("MNE_BACKGROUND_COLOR").charAt(0));
253: colorLabel.setLabelFor(colorPanel);
254: colorLabel.setText(org.openide.util.NbBundle.getMessage(
255: BackgroundStyleEditor.class, "BACKGROUND_COLOR")); // NOI18N
256: gridBagConstraints = new java.awt.GridBagConstraints();
257: gridBagConstraints.gridx = 0;
258: gridBagConstraints.gridy = 0;
259: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
260: gridBagConstraints.insets = new java.awt.Insets(0, 0, 0, 10);
261: colorPanel.add(colorLabel, gridBagConstraints);
262:
263: browseButton.setText("...");
264: browseButton.setMargin(new java.awt.Insets(2, 2, 2, 2));
265: browseButton.setPreferredSize(new java.awt.Dimension(20, 20));
266: browseButton
267: .addActionListener(new java.awt.event.ActionListener() {
268: public void actionPerformed(
269: java.awt.event.ActionEvent evt) {
270: browseButtonActionPerformed(evt);
271: }
272: });
273: gridBagConstraints = new java.awt.GridBagConstraints();
274: gridBagConstraints.gridx = 3;
275: gridBagConstraints.gridy = 1;
276: gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
277: gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
278: gridBagConstraints.insets = new java.awt.Insets(6, 3, 0, 0);
279: colorPanel.add(browseButton, gridBagConstraints);
280: browseButton.getAccessibleContext().setAccessibleName(null);
281: browseButton.getAccessibleContext().setAccessibleDescription(
282: null);
283:
284: imageFileField
285: .addActionListener(new java.awt.event.ActionListener() {
286: public void actionPerformed(
287: java.awt.event.ActionEvent evt) {
288: imageFileFieldActionPerformed(evt);
289: }
290: });
291: imageFileField
292: .addFocusListener(new java.awt.event.FocusAdapter() {
293: public void focusLost(java.awt.event.FocusEvent evt) {
294: imageFileFieldFocusLost(evt);
295: }
296: });
297: gridBagConstraints = new java.awt.GridBagConstraints();
298: gridBagConstraints.gridx = 1;
299: gridBagConstraints.gridy = 1;
300: gridBagConstraints.gridwidth = 2;
301: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
302: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
303: gridBagConstraints.weightx = 1.0;
304: gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
305: colorPanel.add(imageFileField, gridBagConstraints);
306: imageFileField.getAccessibleContext().setAccessibleName(null);
307: imageFileField.getAccessibleContext().setAccessibleDescription(
308: org.openide.util.NbBundle.getMessage(
309: BackgroundStyleEditor.class,
310: "BG_IMG_TEXTFIELD_ACCESS_DESC")); // NOI18N
311:
312: lineHeightLabel.setDisplayedMnemonic(java.util.ResourceBundle
313: .getBundle("org/netbeans/modules/css/visual/ui/Bundle")
314: .getString("MNE_BACKGROUND_IMAGE").charAt(0));
315: lineHeightLabel.setLabelFor(imageFileField);
316: lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(
317: BackgroundStyleEditor.class, "BACKGROUND_IMAGE")); // NOI18N
318: lineHeightLabel
319: .setVerticalAlignment(javax.swing.SwingConstants.TOP);
320: gridBagConstraints = new java.awt.GridBagConstraints();
321: gridBagConstraints.gridx = 0;
322: gridBagConstraints.gridy = 1;
323: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
324: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
325: colorPanel.add(lineHeightLabel, gridBagConstraints);
326:
327: imageTileLabel.setDisplayedMnemonic(java.util.ResourceBundle
328: .getBundle("org/netbeans/modules/css/visual/ui/Bundle")
329: .getString("MNE_BACKGROUNDTILE").charAt(0));
330: imageTileLabel.setLabelFor(repeatComboBox);
331: imageTileLabel.setText(org.openide.util.NbBundle.getMessage(
332: BackgroundStyleEditor.class, "BACKGROUNDTILE")); // NOI18N
333: gridBagConstraints = new java.awt.GridBagConstraints();
334: gridBagConstraints.gridx = 0;
335: gridBagConstraints.gridy = 2;
336: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
337: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
338: colorPanel.add(imageTileLabel, gridBagConstraints);
339:
340: imageScrollLabel.setDisplayedMnemonic(java.util.ResourceBundle
341: .getBundle("org/netbeans/modules/css/visual/ui/Bundle")
342: .getString("MNE_BACKGROUND_SCROLL").charAt(0));
343: imageScrollLabel.setLabelFor(scrollComboBox);
344: imageScrollLabel.setText(org.openide.util.NbBundle.getMessage(
345: BackgroundStyleEditor.class, "BACKGROUND_SCROLL")); // NOI18N
346: gridBagConstraints = new java.awt.GridBagConstraints();
347: gridBagConstraints.gridx = 0;
348: gridBagConstraints.gridy = 3;
349: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
350: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
351: colorPanel.add(imageScrollLabel, gridBagConstraints);
352:
353: scrollComboBox
354: .addItemListener(new java.awt.event.ItemListener() {
355: public void itemStateChanged(
356: java.awt.event.ItemEvent evt) {
357: scrollComboBoxItemStateChanged(evt);
358: }
359: });
360: gridBagConstraints = new java.awt.GridBagConstraints();
361: gridBagConstraints.gridx = 1;
362: gridBagConstraints.gridy = 3;
363: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
364: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
365: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
366: colorPanel.add(scrollComboBox, gridBagConstraints);
367: scrollComboBox.getAccessibleContext().setAccessibleName(null);
368: scrollComboBox.getAccessibleContext().setAccessibleDescription(
369: null);
370:
371: repeatComboBox
372: .addItemListener(new java.awt.event.ItemListener() {
373: public void itemStateChanged(
374: java.awt.event.ItemEvent evt) {
375: repeatComboBoxItemStateChanged(evt);
376: }
377: });
378: gridBagConstraints = new java.awt.GridBagConstraints();
379: gridBagConstraints.gridx = 1;
380: gridBagConstraints.gridy = 2;
381: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
382: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
383: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
384: colorPanel.add(repeatComboBox, gridBagConstraints);
385: repeatComboBox.getAccessibleContext().setAccessibleName(null);
386: repeatComboBox.getAccessibleContext().setAccessibleDescription(
387: null);
388:
389: horizontalPosLabel
390: .setDisplayedMnemonic(java.util.ResourceBundle
391: .getBundle(
392: "org/netbeans/modules/css/visual/ui/Bundle")
393: .getString("MNE_BG_HORIZONTAL_POS").charAt(0));
394: horizontalPosLabel.setLabelFor(horizontalPosComboBox);
395: horizontalPosLabel.setText(org.openide.util.NbBundle
396: .getMessage(BackgroundStyleEditor.class,
397: "BG_HORIZONTAL_POS")); // NOI18N
398: gridBagConstraints = new java.awt.GridBagConstraints();
399: gridBagConstraints.gridx = 0;
400: gridBagConstraints.gridy = 4;
401: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
402: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
403: colorPanel.add(horizontalPosLabel, gridBagConstraints);
404:
405: verticalPosLabel.setDisplayedMnemonic(java.util.ResourceBundle
406: .getBundle("org/netbeans/modules/css/visual/ui/Bundle")
407: .getString("MNE_BG_VERTICAL_POS").charAt(0));
408: verticalPosLabel.setLabelFor(verticalPosComboBox);
409: verticalPosLabel.setText(org.openide.util.NbBundle.getMessage(
410: BackgroundStyleEditor.class, "BG_VERTICAL_POS")); // NOI18N
411: gridBagConstraints = new java.awt.GridBagConstraints();
412: gridBagConstraints.gridx = 0;
413: gridBagConstraints.gridy = 5;
414: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
415: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 10);
416: colorPanel.add(verticalPosLabel, gridBagConstraints);
417:
418: horizontalPosComboBox.setEditable(true);
419: horizontalPosComboBox
420: .addItemListener(new java.awt.event.ItemListener() {
421: public void itemStateChanged(
422: java.awt.event.ItemEvent evt) {
423: horizontalPosComboBoxItemStateChanged(evt);
424: }
425: });
426: gridBagConstraints = new java.awt.GridBagConstraints();
427: gridBagConstraints.gridx = 1;
428: gridBagConstraints.gridy = 4;
429: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
430: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
431: gridBagConstraints.weightx = 1.0;
432: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
433: colorPanel.add(horizontalPosComboBox, gridBagConstraints);
434: horizontalPosComboBox.getAccessibleContext().setAccessibleName(
435: null);
436: horizontalPosComboBox.getAccessibleContext()
437: .setAccessibleDescription(null);
438:
439: verticalPosComboBox.setEditable(true);
440: verticalPosComboBox
441: .addItemListener(new java.awt.event.ItemListener() {
442: public void itemStateChanged(
443: java.awt.event.ItemEvent evt) {
444: verticalPosComboBoxItemStateChanged(evt);
445: }
446: });
447: gridBagConstraints = new java.awt.GridBagConstraints();
448: gridBagConstraints.gridx = 1;
449: gridBagConstraints.gridy = 5;
450: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
451: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
452: gridBagConstraints.weightx = 1.0;
453: gridBagConstraints.insets = new java.awt.Insets(5, 0, 0, 0);
454: colorPanel.add(verticalPosComboBox, gridBagConstraints);
455: verticalPosComboBox.getAccessibleContext().setAccessibleName(
456: null);
457: verticalPosComboBox.getAccessibleContext()
458: .setAccessibleDescription(null);
459:
460: horizontalUnitComboBox.setEnabled(false);
461: horizontalUnitComboBox
462: .addItemListener(new java.awt.event.ItemListener() {
463: public void itemStateChanged(
464: java.awt.event.ItemEvent evt) {
465: horizontalUnitComboBoxItemStateChanged(evt);
466: }
467: });
468: gridBagConstraints = new java.awt.GridBagConstraints();
469: gridBagConstraints.gridx = 2;
470: gridBagConstraints.gridy = 4;
471: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
472: gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
473: colorPanel.add(horizontalUnitComboBox, gridBagConstraints);
474: horizontalUnitComboBox.getAccessibleContext()
475: .setAccessibleName(null);
476: horizontalUnitComboBox.getAccessibleContext()
477: .setAccessibleDescription(null);
478:
479: verticalUnitComboBox.setEnabled(false);
480: verticalUnitComboBox
481: .addItemListener(new java.awt.event.ItemListener() {
482: public void itemStateChanged(
483: java.awt.event.ItemEvent evt) {
484: verticalUnitComboBoxItemStateChanged(evt);
485: }
486: });
487: gridBagConstraints = new java.awt.GridBagConstraints();
488: gridBagConstraints.gridx = 2;
489: gridBagConstraints.gridy = 5;
490: gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
491: gridBagConstraints.insets = new java.awt.Insets(5, 10, 0, 0);
492: colorPanel.add(verticalUnitComboBox, gridBagConstraints);
493: verticalUnitComboBox.getAccessibleContext().setAccessibleName(
494: null);
495: verticalUnitComboBox.getAccessibleContext()
496: .setAccessibleDescription(null);
497:
498: colorSelectionPanel.setLayout(new java.awt.BorderLayout());
499: gridBagConstraints = new java.awt.GridBagConstraints();
500: gridBagConstraints.gridwidth = 3;
501: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
502: colorPanel.add(colorSelectionPanel, gridBagConstraints);
503:
504: add(colorPanel, java.awt.BorderLayout.NORTH);
505:
506: errorPanel.setBorder(javax.swing.BorderFactory
507: .createEmptyBorder(1, 10, 1, 1));
508: errorPanel.setLayout(new java.awt.BorderLayout());
509:
510: errorLabel.setForeground(new java.awt.Color(0, 0, 153));
511: errorPanel.add(errorLabel, java.awt.BorderLayout.NORTH);
512:
513: add(errorPanel, java.awt.BorderLayout.CENTER);
514: }// </editor-fold>//GEN-END:initComponents
515:
516: private void verticalUnitComboBoxItemStateChanged(
517: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_verticalUnitComboBoxItemStateChanged
518: if (evt.getStateChange() != evt.DESELECTED) {
519: bgPositionData
520: .setVerticalUnit((String) verticalUnitComboBox
521: .getSelectedItem());
522: setBackgroundPosition();
523: }
524: }//GEN-LAST:event_verticalUnitComboBoxItemStateChanged
525:
526: private void horizontalUnitComboBoxItemStateChanged(
527: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_horizontalUnitComboBoxItemStateChanged
528: if (evt.getStateChange() != evt.DESELECTED) {
529: bgPositionData
530: .setHorizontalUnit((String) horizontalUnitComboBox
531: .getSelectedItem());
532: setBackgroundPosition();
533: }
534: }//GEN-LAST:event_horizontalUnitComboBoxItemStateChanged
535:
536: private void verticalPosComboBoxItemStateChanged(
537: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_verticalPosComboBoxItemStateChanged
538: if (evt.getStateChange() != evt.DESELECTED) {
539: bgPositionData
540: .setVerticalValue((String) verticalPosComboBox
541: .getSelectedItem());
542: setBackgroundPosition();
543: }
544: }//GEN-LAST:event_verticalPosComboBoxItemStateChanged
545:
546: private void horizontalPosComboBoxItemStateChanged(
547: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_horizontalPosComboBoxItemStateChanged
548: if (evt.getStateChange() != evt.DESELECTED) {
549: bgPositionData
550: .setHorizontalValue((String) horizontalPosComboBox
551: .getSelectedItem());
552: setBackgroundPosition();
553: }
554: }//GEN-LAST:event_horizontalPosComboBoxItemStateChanged
555:
556: private void scrollComboBoxItemStateChanged(
557: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_scrollComboBoxItemStateChanged
558: if (evt.getStateChange() != evt.DESELECTED) {
559: setBackgroundAttachment();
560: }
561: }//GEN-LAST:event_scrollComboBoxItemStateChanged
562:
563: private void repeatComboBoxItemStateChanged(
564: java.awt.event.ItemEvent evt) {//GEN-FIRST:event_repeatComboBoxItemStateChanged
565: if (evt.getStateChange() != evt.DESELECTED) {
566: setBackgroundRepeat();
567: }
568: }//GEN-LAST:event_repeatComboBoxItemStateChanged
569:
570: private void imageFileFieldFocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_imageFileFieldFocusLost
571: setBackgroundImage();
572: }//GEN-LAST:event_imageFileFieldFocusLost
573:
574: private void imageFileFieldActionPerformed(
575: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_imageFileFieldActionPerformed
576: setBackgroundImage();
577: }//GEN-LAST:event_imageFileFieldActionPerformed
578:
579: private void browseButtonActionPerformed(
580: java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
581: BackgroundImageUrlDialog imageUrlDialog = new BackgroundImageUrlDialog(
582: content().fileObject());
583: if (imageUrlDialog.show(this )) {
584: imageFileField.setText(imageUrlDialog.getImageUrl());
585: }
586: setBackgroundImage();
587: }//GEN-LAST:event_browseButtonActionPerformed
588:
589: private void setBackgroundColor() {
590: PropertyData backgroundColorData = new PropertyData();
591: backgroundColorData.setValue(colorField.getColorString());
592: cssPropertyChangeSupport().firePropertyChange(
593: CssProperties.BACKGROUND_COLOR, null,
594: backgroundColorData.toString());
595: }
596:
597: private void setBackgroundImage() {
598: PropertyData backgroundImageData = new PropertyData();
599: String imgPath = imageFileField.getText();
600: if ((imgPath == null) || (imgPath.equals(""))) {
601: imgPath = CssRuleContent.NOT_SET;
602: imageFileField.setText(imgPath);
603: }
604: if (!imgPath.equals(CssRuleContent.NOT_SET)) {
605: backgroundImageData.setValue("url(" + imgPath + ")"); //NOI18N
606: } else {
607: backgroundImageData.setValue(CssRuleContent.NOT_SET);
608: }
609: cssPropertyChangeSupport().firePropertyChange(
610: CssProperties.BACKGROUND_IMAGE, null,
611: backgroundImageData.toString());
612: }
613:
614: private void setBackgroundRepeat() {
615: PropertyData backgroundRepeatData = new PropertyData();
616: backgroundRepeatData.setValue(repeatComboBox.getSelectedItem()
617: .toString());
618: cssPropertyChangeSupport().firePropertyChange(
619: CssProperties.BACKGROUND_REPEAT, null,
620: backgroundRepeatData.toString());
621: }
622:
623: private void setBackgroundAttachment() {
624: PropertyData backgroundAttachmentData = new PropertyData();
625: backgroundAttachmentData.setValue(scrollComboBox
626: .getSelectedItem().toString());
627: cssPropertyChangeSupport().firePropertyChange(
628: CssProperties.BACKGROUND_ATTACHMENT, null,
629: backgroundAttachmentData.toString());
630: }
631:
632: private void setBackgroundPosition() {
633: cssPropertyChangeSupport().firePropertyChange(
634: CssProperties.BACKGROUND_POSITION, null,
635: bgPositionData.toString());
636: enablePositionCombo();
637: }
638:
639: private void enablePositionCombo() {
640: String horizontalPos = bgPositionData.getHorizontalValue();
641: if (Utils.isInteger(horizontalPos)) {
642: horizontalUnitComboBox.setEnabled(true);
643: } else {
644: horizontalUnitComboBox.setEnabled(false);
645: }
646: String verticalPos = bgPositionData.getVerticalValue();
647: if (Utils.isInteger(verticalPos)) {
648: verticalUnitComboBox.setEnabled(true);
649: } else {
650: verticalUnitComboBox.setEnabled(false);
651: }
652: }
653:
654: // Variables declaration - do not modify//GEN-BEGIN:variables
655: private javax.swing.JButton browseButton;
656: private javax.swing.JLabel colorLabel;
657: private javax.swing.JPanel colorPanel;
658: private javax.swing.JPanel colorSelectionPanel;
659: private javax.swing.JLabel errorLabel;
660: private javax.swing.JPanel errorPanel;
661: private javax.swing.JComboBox horizontalPosComboBox;
662: private javax.swing.JLabel horizontalPosLabel;
663: private javax.swing.JComboBox horizontalUnitComboBox;
664: private javax.swing.JTextField imageFileField;
665: private javax.swing.JLabel imageScrollLabel;
666: private javax.swing.JLabel imageTileLabel;
667: private javax.swing.JLabel lineHeightLabel;
668: private javax.swing.JComboBox repeatComboBox;
669: private javax.swing.JComboBox scrollComboBox;
670: private javax.swing.JComboBox verticalPosComboBox;
671: private javax.swing.JLabel verticalPosLabel;
672: private javax.swing.JComboBox verticalUnitComboBox;
673: // End of variables declaration//GEN-END:variables
674:
675: }
|