1 19 20 25 26 package org.netbeans.modules.css.visual.ui; 27 28 import org.netbeans.modules.css.visual.model.BackgroundModel; 29 import org.netbeans.modules.css.visual.model.BackgroundPositionData; 30 import org.netbeans.modules.css.visual.model.CssProperties; 31 import org.netbeans.modules.css.visual.model.CssStyleData; 32 import org.netbeans.modules.css.visual.model.PropertyData; 33 import org.netbeans.modules.css.visual.model.PropertyData; 34 import java.awt.BorderLayout ; 35 import java.beans.PropertyChangeEvent ; 36 import java.beans.PropertyChangeListener ; 37 import java.io.File ; 38 import javax.swing.DefaultComboBoxModel ; 39 import javax.swing.JTextField ; 40 import javax.swing.SwingUtilities ; 41 import org.netbeans.modules.css.visual.model.Utils; 42 import org.openide.util.NbBundle; 43 44 45 50 public class BackgroundStyleEditor extends StyleEditor implements PropertyChangeListener { 51 52 static File currentFile = null; 53 54 ColorSelectionField colorField = new ColorSelectionField(); 55 BackgroundPositionData bgPositionData = new BackgroundPositionData(); 56 57 58 public BackgroundStyleEditor() { 59 setName("backgroundStyleEditor"); setDisplayName(NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_EDITOR_DISPNAME")); 61 initComponents(); 62 colorSelectionPanel.add(colorField,BorderLayout.CENTER); 63 colorField.addPropertyChangeListener(this); 64 initialize(); 65 66 final JTextField horizontalPosComboBoxEditor = (JTextField ) horizontalPosComboBox.getEditor().getEditorComponent(); 68 horizontalPosComboBoxEditor.addKeyListener(new java.awt.event.KeyAdapter () { 69 public void keyTyped(java.awt.event.KeyEvent evt) { 70 SwingUtilities.invokeLater(new Runnable (){ 71 public void run(){ 72 horizontalUnitComboBox.setEnabled(Utils.isInteger(horizontalPosComboBoxEditor.getText())); 73 enablePositionCombo(); 74 } 75 }); 76 } 77 }); 78 79 final JTextField verticalPosComboBoxEditor = (JTextField ) verticalPosComboBox.getEditor().getEditorComponent(); 81 verticalPosComboBoxEditor.addKeyListener(new java.awt.event.KeyAdapter () { 82 public void keyTyped(java.awt.event.KeyEvent evt) { 83 SwingUtilities.invokeLater(new Runnable (){ 84 public void run(){ 85 verticalUnitComboBox.setEnabled(Utils.isInteger(verticalPosComboBoxEditor.getText())); 86 } 87 }); 88 89 } 90 }); 91 } 92 93 protected void initialize(){ 94 BackgroundModel backgroundModel = new BackgroundModel(); 96 DefaultComboBoxModel backgroundRepeatList = backgroundModel.getBackgroundRepeatList(); 97 repeatComboBox.setModel(backgroundRepeatList); 98 99 DefaultComboBoxModel backgroundScrollList = backgroundModel.getBackgroundScrollList(); 101 scrollComboBox.setModel(backgroundScrollList); 102 103 105 horizontalPosComboBox.setModel(backgroundModel.getBackgroundPositionList()); 106 verticalPosComboBox.setModel(backgroundModel.getBackgroundPositionList()); 107 horizontalUnitComboBox.setModel(backgroundModel.getBackgroundPositionUnitList()); 108 verticalUnitComboBox.setModel(backgroundModel.getBackgroundPositionUnitList()); 109 } 110 111 115 protected void setCssPropertyValues(CssStyleData cssStyleData){ 116 removeCssPropertyChangeListener(); 117 118 String backGroundColor = cssStyleData.getProperty(CssProperties.BACKGROUND_COLOR); 120 if(backGroundColor != null){ 121 colorField.setColorString(backGroundColor); 122 }else{ 123 imageFileField.setText(CssStyleData.NOT_SET); 124 } 125 126 String backGroundImage = cssStyleData.getProperty(CssProperties.BACKGROUND_IMAGE); 128 if(backGroundImage != null && !backGroundImage.trim().equals("")){ 129 int openBracketPos = backGroundImage.indexOf("("); 130 int endBracketPos = backGroundImage.indexOf(")"); 131 if((openBracketPos >= 0) && (endBracketPos >= 0)){ 132 String imgString = backGroundImage.substring(openBracketPos + 1, endBracketPos); 133 imageFileField.setText(imgString); 134 }else{ 135 imageFileField.setText(backGroundImage); 136 } 137 }else{ 138 imageFileField.setText(CssStyleData.NOT_SET); 139 } 140 141 String backGroundRepeat = cssStyleData.getProperty(CssProperties.BACKGROUND_REPEAT); 142 if(backGroundRepeat != null){ 143 repeatComboBox.setSelectedItem(backGroundRepeat); 144 }else{ 145 repeatComboBox.setSelectedIndex(0); 146 } 147 148 String backGroundScroll = cssStyleData.getProperty(CssProperties.BACKGROUND_ATTACHMENT); 149 if(backGroundScroll != null){ 150 scrollComboBox.setSelectedItem(backGroundScroll); 151 }else{ 152 scrollComboBox.setSelectedIndex(0); 153 } 154 155 String backgroundPosition = cssStyleData.getProperty(CssProperties.BACKGROUND_POSITION); 156 if(backgroundPosition != null){ 157 bgPositionData.setBackgroundPosition(backgroundPosition); 158 horizontalPosComboBox.setSelectedItem(bgPositionData.getHorizontalValue()); 159 horizontalUnitComboBox.setSelectedItem(bgPositionData.getHorizontalUnit()); 160 verticalPosComboBox.setSelectedItem(bgPositionData.getVerticalValue()); 161 verticalUnitComboBox.setSelectedItem(bgPositionData.getVerticalUnit()); 162 }else{ 163 horizontalPosComboBox.setSelectedIndex(0); 164 verticalPosComboBox.setSelectedIndex(0); 165 } 166 setCssPropertyChangeListener(cssStyleData); 167 } 168 169 170 public void propertyChange(PropertyChangeEvent evt) { 171 setBackgroundColor(); 172 } 173 174 private void initComponents() { 176 java.awt.GridBagConstraints gridBagConstraints; 177 178 colorPanel = new javax.swing.JPanel (); 179 colorLabel = new javax.swing.JLabel (); 180 browseButton = new javax.swing.JButton (); 181 imageFileField = new javax.swing.JTextField (); 182 lineHeightLabel = new javax.swing.JLabel (); 183 imageTileLabel = new javax.swing.JLabel (); 184 imageScrollLabel = new javax.swing.JLabel (); 185 scrollComboBox = new javax.swing.JComboBox (); 186 repeatComboBox = new javax.swing.JComboBox (); 187 horizontalPosLabel = new javax.swing.JLabel (); 188 verticalPosLabel = new javax.swing.JLabel (); 189 horizontalPosComboBox = new javax.swing.JComboBox (); 190 verticalPosComboBox = new javax.swing.JComboBox (); 191 horizontalUnitComboBox = new javax.swing.JComboBox (); 192 verticalUnitComboBox = new javax.swing.JComboBox (); 193 colorSelectionPanel = new javax.swing.JPanel (); 194 errorPanel = new javax.swing.JPanel (); 195 errorLabel = new javax.swing.JLabel (); 196 197 setLayout(new java.awt.BorderLayout ()); 198 199 colorPanel.setLayout(new java.awt.GridBagLayout ()); 200 201 colorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); 202 colorLabel.setLabelFor(colorPanel); 203 colorLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_COLOR")); 204 gridBagConstraints = new java.awt.GridBagConstraints (); 205 gridBagConstraints.gridx = 0; 206 gridBagConstraints.gridy = 0; 207 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 208 gridBagConstraints.insets = new java.awt.Insets (0, 0, 0, 10); 209 colorPanel.add(colorLabel, gridBagConstraints); 210 211 browseButton.setText("..."); 212 browseButton.setToolTipText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMAGE_BROWSE_BTN_TOOLTIP")); 213 browseButton.setMargin(new java.awt.Insets (2, 2, 2, 2)); 214 browseButton.setPreferredSize(new java.awt.Dimension (20, 20)); 215 browseButton.addActionListener(new java.awt.event.ActionListener () { 216 public void actionPerformed(java.awt.event.ActionEvent evt) { 217 browseButtonActionPerformed(evt); 218 } 219 }); 220 221 gridBagConstraints = new java.awt.GridBagConstraints (); 222 gridBagConstraints.gridx = 3; 223 gridBagConstraints.gridy = 1; 224 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL; 225 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 226 gridBagConstraints.insets = new java.awt.Insets (6, 3, 0, 0); 227 colorPanel.add(browseButton, gridBagConstraints); 228 browseButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IAMGE_BROWSE_ACCESS_NAME")); 229 browseButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IAMGE_BROWSE_ACCESS_DESC")); 230 231 imageFileField.addActionListener(new java.awt.event.ActionListener () { 232 public void actionPerformed(java.awt.event.ActionEvent evt) { 233 imageFileFieldActionPerformed(evt); 234 } 235 }); 236 imageFileField.addFocusListener(new java.awt.event.FocusAdapter () { 237 public void focusLost(java.awt.event.FocusEvent evt) { 238 imageFileFieldFocusLost(evt); 239 } 240 }); 241 242 gridBagConstraints = new java.awt.GridBagConstraints (); 243 gridBagConstraints.gridx = 1; 244 gridBagConstraints.gridy = 1; 245 gridBagConstraints.gridwidth = 2; 246 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 247 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 248 gridBagConstraints.weightx = 1.0; 249 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 250 colorPanel.add(imageFileField, gridBagConstraints); 251 imageFileField.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMG_TEXTFIELD_ACCESS_NAME")); 252 imageFileField.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_IMG_TEXTFIELD_ACCESS_DESC")); 253 254 lineHeightLabel.setLabelFor(imageFileField); 255 lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_IMAGE")); 256 lineHeightLabel.setVerticalAlignment(javax.swing.SwingConstants.TOP); 257 gridBagConstraints = new java.awt.GridBagConstraints (); 258 gridBagConstraints.gridx = 0; 259 gridBagConstraints.gridy = 1; 260 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 261 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 262 colorPanel.add(lineHeightLabel, gridBagConstraints); 263 264 imageTileLabel.setLabelFor(repeatComboBox); 265 imageTileLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUNDTILE")); 266 gridBagConstraints = new java.awt.GridBagConstraints (); 267 gridBagConstraints.gridx = 0; 268 gridBagConstraints.gridy = 2; 269 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; 270 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 10); 271 colorPanel.add(imageTileLabel, gridBagConstraints); 272 273 imageScrollLabel.setLabelFor(scrollComboBox); 274 imageScrollLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BACKGROUND_SCROLL")); 275 gridBagConstraints = new java.awt.GridBagConstraints (); 276 gridBagConstraints.gridx = 0; 277 gridBagConstraints.gridy = 3; 278 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 279 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 10); 280 colorPanel.add(imageScrollLabel, gridBagConstraints); 281 282 scrollComboBox.addItemListener(new java.awt.event.ItemListener () { 283 public void itemStateChanged(java.awt.event.ItemEvent evt) { 284 scrollComboBoxItemStateChanged(evt); 285 } 286 }); 287 288 gridBagConstraints = new java.awt.GridBagConstraints (); 289 gridBagConstraints.gridx = 1; 290 gridBagConstraints.gridy = 3; 291 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 292 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 293 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 294 colorPanel.add(scrollComboBox, gridBagConstraints); 295 scrollComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "SCROLL_COMBO_ACCESSIBLE_NAME")); 296 scrollComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "SCROLL_COMBO_ACCESSIBLE_DESC")); 297 298 repeatComboBox.addItemListener(new java.awt.event.ItemListener () { 299 public void itemStateChanged(java.awt.event.ItemEvent evt) { 300 repeatComboBoxItemStateChanged(evt); 301 } 302 }); 303 304 gridBagConstraints = new java.awt.GridBagConstraints (); 305 gridBagConstraints.gridx = 1; 306 gridBagConstraints.gridy = 2; 307 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 308 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 309 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 310 colorPanel.add(repeatComboBox, gridBagConstraints); 311 repeatComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "TILE_COMBO_ACCESSIBLE_NAME")); 312 repeatComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "TILE_COMBO_ACCESSIBLE_DESC")); 313 314 horizontalPosLabel.setLabelFor(horizontalPosComboBox); 315 horizontalPosLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_HORIZONTAL_POS")); 316 gridBagConstraints = new java.awt.GridBagConstraints (); 317 gridBagConstraints.gridx = 0; 318 gridBagConstraints.gridy = 4; 319 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 320 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 10); 321 colorPanel.add(horizontalPosLabel, gridBagConstraints); 322 323 verticalPosLabel.setLabelFor(verticalPosComboBox); 324 verticalPosLabel.setText(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "BG_VERTICAL_POS")); 325 gridBagConstraints = new java.awt.GridBagConstraints (); 326 gridBagConstraints.gridx = 0; 327 gridBagConstraints.gridy = 5; 328 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 329 gridBagConstraints.insets = new java.awt.Insets (5, 20, 0, 10); 330 colorPanel.add(verticalPosLabel, gridBagConstraints); 331 332 horizontalPosComboBox.setEditable(true); 333 horizontalPosComboBox.addItemListener(new java.awt.event.ItemListener () { 334 public void itemStateChanged(java.awt.event.ItemEvent evt) { 335 horizontalPosComboBoxItemStateChanged(evt); 336 } 337 }); 338 horizontalPosComboBox.addActionListener(new java.awt.event.ActionListener () { 339 public void actionPerformed(java.awt.event.ActionEvent evt) { 340 horizontalPosComboBoxActionPerformed(evt); 341 } 342 }); 343 344 gridBagConstraints = new java.awt.GridBagConstraints (); 345 gridBagConstraints.gridx = 1; 346 gridBagConstraints.gridy = 4; 347 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 348 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 349 gridBagConstraints.weightx = 1.0; 350 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 351 colorPanel.add(horizontalPosComboBox, gridBagConstraints); 352 horizontalPosComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_COMBO_ACCESSIBLE_NAME")); 353 horizontalPosComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_COMBO_ACCESSIBLE_DESC")); 354 355 verticalPosComboBox.setEditable(true); 356 verticalPosComboBox.addActionListener(new java.awt.event.ActionListener () { 357 public void actionPerformed(java.awt.event.ActionEvent evt) { 358 verticalPosComboBoxActionPerformed(evt); 359 } 360 }); 361 verticalPosComboBox.addItemListener(new java.awt.event.ItemListener () { 362 public void itemStateChanged(java.awt.event.ItemEvent evt) { 363 verticalPosComboBoxItemStateChanged(evt); 364 } 365 }); 366 367 gridBagConstraints = new java.awt.GridBagConstraints (); 368 gridBagConstraints.gridx = 1; 369 gridBagConstraints.gridy = 5; 370 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 371 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 372 gridBagConstraints.weightx = 1.0; 373 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 374 colorPanel.add(verticalPosComboBox, gridBagConstraints); 375 verticalPosComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_COMBO_ACCESSIBLE_NAME")); 376 verticalPosComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_COMBO_ACCESSIBLE_DESC")); 377 378 horizontalUnitComboBox.setEnabled(false); 379 horizontalUnitComboBox.addItemListener(new java.awt.event.ItemListener () { 380 public void itemStateChanged(java.awt.event.ItemEvent evt) { 381 horizontalUnitComboBoxItemStateChanged(evt); 382 } 383 }); 384 385 gridBagConstraints = new java.awt.GridBagConstraints (); 386 gridBagConstraints.gridx = 2; 387 gridBagConstraints.gridy = 4; 388 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 389 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 390 colorPanel.add(horizontalUnitComboBox, gridBagConstraints); 391 horizontalUnitComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_UNIT_COMBO_ACCESSIBLE_NAME")); 392 horizontalUnitComboBox.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "HORIZPOS_UNIT_COMBO_ACCESSIBLE_DESC")); 393 394 verticalUnitComboBox.setEnabled(false); 395 verticalUnitComboBox.addItemListener(new java.awt.event.ItemListener () { 396 public void itemStateChanged(java.awt.event.ItemEvent evt) { 397 verticalUnitComboBoxItemStateChanged(evt); 398 } 399 }); 400 401 gridBagConstraints = new java.awt.GridBagConstraints (); 402 gridBagConstraints.gridx = 2; 403 gridBagConstraints.gridy = 5; 404 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 405 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 406 colorPanel.add(verticalUnitComboBox, gridBagConstraints); 407 verticalUnitComboBox.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(BackgroundStyleEditor.class, "VERTPOS_UNIT_COMBO_ACCESSIBLE_NAME")); 408 verticalUnitComboBox.getAccessibleContext().setAccessibleDescription(java.util.ResourceBundle.getBundle("org/netbeans/modules/css/visual/ui/Bundle").getString("VERTPOS_UNIT_COMBO_ACCESSIBLE_DESC")); 409 410 colorSelectionPanel.setLayout(new java.awt.BorderLayout ()); 411 412 gridBagConstraints = new java.awt.GridBagConstraints (); 413 gridBagConstraints.gridwidth = 3; 414 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 415 colorPanel.add(colorSelectionPanel, gridBagConstraints); 416 417 add(colorPanel, java.awt.BorderLayout.NORTH); 418 419 errorPanel.setLayout(new java.awt.BorderLayout ()); 420 421 errorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 1)); 422 errorLabel.setForeground(new java.awt.Color (0, 0, 153)); 423 errorPanel.add(errorLabel, java.awt.BorderLayout.NORTH); 424 425 add(errorPanel, java.awt.BorderLayout.CENTER); 426 427 } 429 private void verticalUnitComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 431 bgPositionData.setVerticalUnit((String )verticalUnitComboBox.getSelectedItem()); 432 setBackgroundPosition(); 433 } 434 } 436 private void horizontalUnitComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 438 bgPositionData.setHorizontalUnit((String )horizontalUnitComboBox.getSelectedItem()); 439 setBackgroundPosition(); 440 } 441 } 443 private void verticalPosComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 445 bgPositionData.setVerticalValue((String )verticalPosComboBox.getSelectedItem()); 446 setBackgroundPosition(); 447 } 448 } 450 private void verticalPosComboBoxActionPerformed(java.awt.event.ActionEvent evt) { bgPositionData.setVerticalValue((String )verticalPosComboBox.getSelectedItem()); 452 setBackgroundPosition(); 453 } 455 private void horizontalPosComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 457 bgPositionData.setHorizontalValue((String )horizontalPosComboBox.getSelectedItem()); 458 setBackgroundPosition(); 459 } 460 } 462 private void horizontalPosComboBoxActionPerformed(java.awt.event.ActionEvent evt) { bgPositionData.setHorizontalValue((String )horizontalPosComboBox.getSelectedItem()); 464 setBackgroundPosition(); 465 } 467 private void scrollComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { setBackgroundAttachment(); 469 } 471 private void repeatComboBoxItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 473 setBackgroundRepeat(); 474 } 475 } 477 private void imageFileFieldFocusLost(java.awt.event.FocusEvent evt) { setBackgroundImage(); 479 } 481 private void imageFileFieldActionPerformed(java.awt.event.ActionEvent evt) { setBackgroundImage(); 483 } 485 private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) { BackgroundImageUrlDialog imageUrlDialog = new BackgroundImageUrlDialog(); 487 if(imageUrlDialog.show(this)){ 488 imageFileField.setText(imageUrlDialog.getImageUrl()); 489 } 490 setBackgroundImage(); 491 } 493 private void setBackgroundColor(){ 494 PropertyData backgroundColorData = new PropertyData(); 495 backgroundColorData.setValue(colorField.getColorString()); 496 cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_COLOR, null, backgroundColorData.toString()); 497 } 498 499 private void setBackgroundImage(){ 500 PropertyData backgroundImageData = new PropertyData(); 501 String imgPath = imageFileField.getText(); 502 if((imgPath == null) || (imgPath.equals(""))) { 503 imgPath = CssStyleData.NOT_SET; 504 imageFileField.setText(imgPath); 505 } 506 if(!imgPath.equals(CssStyleData.NOT_SET)){ 507 backgroundImageData.setValue("url(" + imgPath + ")"); }else{ 509 backgroundImageData.setValue(CssStyleData.NOT_SET); 510 } 511 cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_IMAGE, null, backgroundImageData.toString()); 512 } 513 514 private void setBackgroundRepeat(){ 515 PropertyData backgroundRepeatData = new PropertyData(); 516 backgroundRepeatData.setValue(repeatComboBox.getSelectedItem().toString()); 517 cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_REPEAT, null, backgroundRepeatData.toString()); 518 } 519 520 private void setBackgroundAttachment(){ 521 PropertyData backgroundAttachmentData = new PropertyData(); 522 backgroundAttachmentData.setValue(scrollComboBox.getSelectedItem().toString()); 523 cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_ATTACHMENT, null, backgroundAttachmentData.toString()); 524 } 525 526 private void setBackgroundPosition(){ 527 cssPropertyChangeSupport.firePropertyChange(CssProperties.BACKGROUND_POSITION, null, bgPositionData.toString()); 528 enablePositionCombo(); 529 } 530 531 private void enablePositionCombo(){ 532 String horizontalPos = bgPositionData.getHorizontalValue(); 533 if (Utils.isInteger(horizontalPos)){ 534 horizontalUnitComboBox.setEnabled(true); 535 }else{ 536 horizontalUnitComboBox.setEnabled(false); 537 } 538 String verticalPos = bgPositionData.getVerticalValue(); 539 if (Utils.isInteger(verticalPos)){ 540 verticalUnitComboBox.setEnabled(true); 541 }else{ 542 verticalUnitComboBox.setEnabled(false); 543 } 544 } 545 546 private javax.swing.JButton browseButton; 548 private javax.swing.JLabel colorLabel; 549 private javax.swing.JPanel colorPanel; 550 private javax.swing.JPanel colorSelectionPanel; 551 private javax.swing.JLabel errorLabel; 552 private javax.swing.JPanel errorPanel; 553 private javax.swing.JComboBox horizontalPosComboBox; 554 private javax.swing.JLabel horizontalPosLabel; 555 private javax.swing.JComboBox horizontalUnitComboBox; 556 private javax.swing.JTextField imageFileField; 557 private javax.swing.JLabel imageScrollLabel; 558 private javax.swing.JLabel imageTileLabel; 559 private javax.swing.JLabel lineHeightLabel; 560 private javax.swing.JComboBox repeatComboBox; 561 private javax.swing.JComboBox scrollComboBox; 562 private javax.swing.JComboBox verticalPosComboBox; 563 private javax.swing.JLabel verticalPosLabel; 564 private javax.swing.JComboBox verticalUnitComboBox; 565 567 } 568 | Popular Tags |