1 19 20 25 26 package org.netbeans.modules.css.visual.ui; 27 28 import org.netbeans.modules.css.visual.model.CssProperties; 29 import org.netbeans.modules.css.visual.model.CssStyleData; 30 import org.netbeans.modules.css.visual.model.PropertyData; 31 import org.netbeans.modules.css.visual.model.PropertyWithUnitData; 32 import org.netbeans.modules.css.visual.model.TextBlockData; 33 import org.netbeans.modules.css.visual.model.TextBlockModel; 34 import org.netbeans.modules.css.visual.model.PropertyData; 35 import java.awt.event.FocusAdapter ; 36 import java.awt.event.FocusEvent ; 37 import javax.swing.DefaultComboBoxModel ; 38 import javax.swing.JTextField ; 39 import javax.swing.SwingUtilities ; 40 import org.netbeans.modules.css.visual.model.Utils; 41 import org.openide.util.NbBundle; 42 43 47 public class TextBlockStyleEditor extends StyleEditor { 48 49 TextBlockModel textBlockModel = new TextBlockModel(); 50 TextBlockData textBlockData = new TextBlockData(); 51 52 PropertyData directionData = new PropertyData(); 53 PropertyData textAlignData = new PropertyData(); 54 PropertyData verticalAlignData = new PropertyWithUnitData(); 55 PropertyWithUnitData wordSpacingData = new PropertyWithUnitData(); 56 PropertyWithUnitData letterSpacingData = new PropertyWithUnitData(); 57 PropertyWithUnitData lineHeightData = new PropertyWithUnitData(); 58 PropertyWithUnitData textIndentData = new PropertyWithUnitData(); 59 60 61 public TextBlockStyleEditor() { 62 setName("textBlockStyleEditor"); setDisplayName(NbBundle.getMessage(TextBlockStyleEditor.class, "TEXTBLOCK_EDITOR_DISPNAME")); 64 initComponents(); 65 initialize(); 66 67 final JTextField textIndentComboEditor = (JTextField ) textIndentCombo.getEditor().getEditorComponent(); 69 textIndentComboEditor.addKeyListener(new java.awt.event.KeyAdapter () { 70 public void keyTyped(java.awt.event.KeyEvent evt) { 71 SwingUtilities.invokeLater(new Runnable (){ 72 public void run(){ 73 textIndentUnitCombo.setEnabled(Utils.isInteger(textIndentComboEditor.getText())); 74 } 75 }); 76 } 77 }); 78 79 final JTextField wordSpacingComboEditor = (JTextField ) wordSpacingCombo.getEditor().getEditorComponent(); 81 wordSpacingComboEditor.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 wordSpacingUnitCombo.setEnabled(Utils.isInteger(wordSpacingComboEditor.getText())); 86 } 87 }); 88 } 89 }); 90 91 final JTextField letterSpacingComboEditor = (JTextField ) letterSpacingCombo.getEditor().getEditorComponent(); 93 letterSpacingComboEditor.addKeyListener(new java.awt.event.KeyAdapter () { 94 public void keyTyped(java.awt.event.KeyEvent evt) { 95 SwingUtilities.invokeLater(new Runnable (){ 96 public void run(){ 97 letterSpacingUnitCombo.setEnabled(Utils.isInteger(letterSpacingComboEditor.getText())); 98 } 99 }); 100 } 101 }); 102 103 final JTextField lineHeightComboEditor = (JTextField ) lineHeightCombo.getEditor().getEditorComponent(); 105 lineHeightComboEditor.addKeyListener(new java.awt.event.KeyAdapter () { 106 public void keyTyped(java.awt.event.KeyEvent evt) { 107 SwingUtilities.invokeLater(new Runnable (){ 108 public void run(){ 109 lineHeightUnitCombo.setEnabled(Utils.isInteger(lineHeightComboEditor.getText())); 110 } 111 }); 112 } 113 }); 114 } 115 116 117 private void initialize(){ 118 119 DefaultComboBoxModel horizontalAlignList = textBlockModel.getHorizontalAlignmentList(); 121 horizontalAlignCombo.setModel(horizontalAlignList); 122 123 DefaultComboBoxModel verticalAlignList = textBlockModel.getVerticalAlignmentList(); 125 verticalAlignCombo.setModel(verticalAlignList); 126 127 DefaultComboBoxModel indentationList = textBlockModel.getIndentationList(); 129 textIndentCombo.setModel(indentationList); 130 textIndentUnitCombo.setModel(textBlockModel.getTextBlockUnitList()); 131 132 DefaultComboBoxModel textDirectionList = textBlockModel.getTextDirectionList(); 134 directionCombo.setModel(textDirectionList); 135 136 DefaultComboBoxModel wordSpacingList = textBlockModel.getWordSpacingList(); 138 wordSpacingCombo.setModel(wordSpacingList); 139 140 DefaultComboBoxModel letterSpacingList = textBlockModel.getLetterSpacingList(); 142 letterSpacingCombo.setModel(letterSpacingList); 143 letterSpacingUnitCombo.setModel(textBlockModel.getTextBlockUnitList()); 144 145 DefaultComboBoxModel lineHeightList = textBlockModel.getLineHeightList(); 147 lineHeightCombo.setModel(lineHeightList); 148 lineHeightUnitCombo.setModel(textBlockModel.getTextBlockUnitList()); 149 150 textIndentCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter () { 151 public void focusGained(FocusEvent evt) { 152 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED); 153 } 154 public void focusLost(FocusEvent evt) { 155 errorLabel.setText(""); 156 } 157 }); 158 159 directionCombo.addFocusListener(new FocusAdapter () { 160 public void focusGained(FocusEvent evt) { 161 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED); 162 } 163 public void focusLost(FocusEvent evt) { 164 errorLabel.setText(""); 165 } 166 }); 167 168 letterSpacingCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter () { 169 public void focusGained(FocusEvent evt) { 170 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED); 171 } 172 public void focusLost(FocusEvent evt) { 173 errorLabel.setText(""); 174 } 175 }); 176 177 wordSpacingCombo.getEditor().getEditorComponent().addFocusListener(new FocusAdapter () { 178 public void focusGained(FocusEvent evt) { 179 errorLabel.setText(CssStyleData.PREVIEW_NOT_SUPPORTED); 180 } 181 public void focusLost(FocusEvent evt) { 182 errorLabel.setText(""); 183 } 184 }); 185 } 186 187 191 protected void setCssPropertyValues(CssStyleData cssStyleData){ 192 removeCssPropertyChangeListener(); 193 194 String horizontalAlign = cssStyleData.getProperty(CssProperties.TEXT_ALIGN); 195 if(horizontalAlign != null){ 196 horizontalAlignCombo.setSelectedItem(horizontalAlign); 197 }else{ 198 horizontalAlignCombo.setSelectedIndex(0); 199 } 200 201 String verticalAlign = cssStyleData.getProperty(CssProperties.VERTICAL_ALIGN); 202 if(verticalAlign != null){ 203 textBlockData.setVerticalAlign(verticalAlign); 204 verticalAlignCombo.setSelectedItem(textBlockData.getVerticalAlignValue()); 205 }else{ 206 verticalAlignCombo.setSelectedIndex(0); 207 } 208 209 String indentation = cssStyleData.getProperty(CssProperties.TEXT_INDENT); 210 if(indentation != null){ 211 textBlockData.setIndentation(indentation); 212 textIndentCombo.setSelectedItem(textBlockData.getIndentationValue()); 213 textIndentUnitCombo.setSelectedItem(textBlockData.getIndentationUnit()); 214 }else{ 215 textIndentCombo.setSelectedIndex(0); 216 textIndentUnitCombo.setSelectedItem("px"); 217 } 218 String textDirection = cssStyleData.getProperty(CssProperties.DIRECTION); 219 if(textDirection != null){ 220 directionCombo.setSelectedItem(textDirection); 221 }else{ 222 directionCombo.setSelectedItem("px"); 223 } 224 225 wordSpacingUnitCombo.setModel(textBlockModel.getTextBlockUnitList()); 226 String wordSpacing = cssStyleData.getProperty(CssProperties.WORD_SPACING); 227 if(wordSpacing != null){ 228 textBlockData.setWordSpacing(wordSpacing); 229 wordSpacingCombo.setSelectedItem(textBlockData.getWordSpacingValue()); 230 wordSpacingUnitCombo.setSelectedItem(textBlockData.getWordSpacingUnit()); 231 }else{ 232 wordSpacingCombo.setSelectedIndex(0); 233 wordSpacingUnitCombo.setSelectedItem("px"); 234 } 235 String letterSpacing = cssStyleData.getProperty(CssProperties.LETTER_SPACING); 236 if(letterSpacing != null){ 237 textBlockData.setLetterSpacing(letterSpacing); 238 letterSpacingCombo.setSelectedItem(textBlockData.getLetterSpacingValue()); 239 letterSpacingUnitCombo.setSelectedItem(textBlockData.getLetterSpacingUnit()); 240 }else{ 241 letterSpacingCombo.setSelectedIndex(0); 242 letterSpacingUnitCombo.setSelectedItem("px"); 243 } 244 String lineHeight = cssStyleData.getProperty(CssProperties.LINE_HEIGHT); 245 if(lineHeight != null){ 246 textBlockData.setLineHeight(lineHeight); 247 lineHeightCombo.setSelectedItem(textBlockData.getLineHeightValue()); 248 lineHeightUnitCombo.setSelectedItem(textBlockData.getLineHeightUnit()); 249 }else{ 250 lineHeightCombo.setSelectedIndex(0); 251 lineHeightUnitCombo.setSelectedItem("px"); 252 } 253 setCssPropertyChangeListener(cssStyleData); 254 } 255 256 private void initComponents() { 258 java.awt.GridBagConstraints gridBagConstraints; 259 260 textBlockPanel = new javax.swing.JPanel (); 261 decorationLabel = new javax.swing.JLabel (); 262 imageScroll = new javax.swing.JLabel (); 263 directionCombo = new javax.swing.JComboBox (); 264 horizontalAlignCombo = new javax.swing.JComboBox (); 265 textAlignLabel = new javax.swing.JLabel (); 266 jLabel2 = new javax.swing.JLabel (); 267 textIndentCombo = new javax.swing.JComboBox (); 268 verticalAlignCombo = new javax.swing.JComboBox (); 269 wordSpacingUnitCombo = new javax.swing.JComboBox (); 270 imageScroll1 = new javax.swing.JLabel (); 271 wordSpacingCombo = new javax.swing.JComboBox (); 272 imageScroll2 = new javax.swing.JLabel (); 273 letterSpacingCombo = new javax.swing.JComboBox (); 274 letterSpacingUnitCombo = new javax.swing.JComboBox (); 275 textIndentUnitCombo = new javax.swing.JComboBox (); 276 lineHeightLabel = new javax.swing.JLabel (); 277 lineHeightCombo = new javax.swing.JComboBox (); 278 lineHeightUnitCombo = new javax.swing.JComboBox (); 279 errorPanel = new javax.swing.JPanel (); 280 errorLabel = new javax.swing.JLabel (); 281 282 setLayout(new java.awt.BorderLayout ()); 283 284 textBlockPanel.setLayout(new java.awt.GridBagLayout ()); 285 286 textBlockPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(5, 5, 5, 5)); 287 decorationLabel.setLabelFor(textIndentCombo); 288 decorationLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_INDENTATION")); 289 gridBagConstraints = new java.awt.GridBagConstraints (); 290 gridBagConstraints.gridx = 0; 291 gridBagConstraints.gridy = 2; 292 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 293 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 10); 294 textBlockPanel.add(decorationLabel, gridBagConstraints); 295 296 imageScroll.setLabelFor(directionCombo); 297 imageScroll.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_DIRECTION")); 298 gridBagConstraints = new java.awt.GridBagConstraints (); 299 gridBagConstraints.gridx = 0; 300 gridBagConstraints.gridy = 3; 301 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 302 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 303 textBlockPanel.add(imageScroll, gridBagConstraints); 304 305 directionCombo.addItemListener(new java.awt.event.ItemListener () { 306 public void itemStateChanged(java.awt.event.ItemEvent evt) { 307 directionComboItemStateChanged(evt); 308 } 309 }); 310 311 gridBagConstraints = new java.awt.GridBagConstraints (); 312 gridBagConstraints.gridx = 1; 313 gridBagConstraints.gridy = 3; 314 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 315 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 316 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 317 textBlockPanel.add(directionCombo, gridBagConstraints); 318 directionCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "DIRECTION_ACCESS_NAME")); 319 directionCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "DIRECTION_ACCESS_DESC")); 320 321 horizontalAlignCombo.addFocusListener(new java.awt.event.FocusAdapter () { 322 public void focusLost(java.awt.event.FocusEvent evt) { 323 horizontalAlignComboFocusLost(evt); 324 } 325 }); 326 horizontalAlignCombo.addItemListener(new java.awt.event.ItemListener () { 327 public void itemStateChanged(java.awt.event.ItemEvent evt) { 328 horizontalAlignComboItemStateChanged(evt); 329 } 330 }); 331 332 gridBagConstraints = new java.awt.GridBagConstraints (); 333 gridBagConstraints.gridx = 1; 334 gridBagConstraints.gridy = 0; 335 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 336 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 337 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 0); 338 textBlockPanel.add(horizontalAlignCombo, gridBagConstraints); 339 horizontalAlignCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "HORIZONTAL_ALIGN_ACCESS_NAME")); 340 horizontalAlignCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "HORIZONTAL_ALIGN_ACCESS_DESC")); 341 342 textAlignLabel.setLabelFor(horizontalAlignCombo); 343 textAlignLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_HORIZ_ALIGN")); 344 gridBagConstraints = new java.awt.GridBagConstraints (); 345 gridBagConstraints.gridx = 0; 346 gridBagConstraints.gridy = 0; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 10); 349 textBlockPanel.add(textAlignLabel, gridBagConstraints); 350 351 jLabel2.setLabelFor(verticalAlignCombo); 352 jLabel2.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "TEXT_VERTICAL_ALIGN")); 353 gridBagConstraints = new java.awt.GridBagConstraints (); 354 gridBagConstraints.gridx = 0; 355 gridBagConstraints.gridy = 1; 356 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 357 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 358 textBlockPanel.add(jLabel2, gridBagConstraints); 359 360 textIndentCombo.setEditable(true); 361 textIndentCombo.addItemListener(new java.awt.event.ItemListener () { 362 public void itemStateChanged(java.awt.event.ItemEvent evt) { 363 textIndentComboItemStateChanged(evt); 364 } 365 }); 366 textIndentCombo.addActionListener(new java.awt.event.ActionListener () { 367 public void actionPerformed(java.awt.event.ActionEvent evt) { 368 textIndentComboActionPerformed(evt); 369 } 370 }); 371 textIndentCombo.addFocusListener(new java.awt.event.FocusAdapter () { 372 public void focusLost(java.awt.event.FocusEvent evt) { 373 textIndentComboFocusLost(evt); 374 } 375 }); 376 377 gridBagConstraints = new java.awt.GridBagConstraints (); 378 gridBagConstraints.gridx = 1; 379 gridBagConstraints.gridy = 2; 380 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 381 gridBagConstraints.weightx = 1.0; 382 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 0); 383 textBlockPanel.add(textIndentCombo, gridBagConstraints); 384 textIndentCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_ACCESS_NAME")); 385 textIndentCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_ACCESS_DESC")); 386 387 verticalAlignCombo.setEditable(true); 388 verticalAlignCombo.addActionListener(new java.awt.event.ActionListener () { 389 public void actionPerformed(java.awt.event.ActionEvent evt) { 390 verticalAlignComboActionPerformed(evt); 391 } 392 }); 393 verticalAlignCombo.addFocusListener(new java.awt.event.FocusAdapter () { 394 public void focusLost(java.awt.event.FocusEvent evt) { 395 verticalAlignComboFocusLost(evt); 396 } 397 }); 398 verticalAlignCombo.addItemListener(new java.awt.event.ItemListener () { 399 public void itemStateChanged(java.awt.event.ItemEvent evt) { 400 verticalAlignComboItemStateChanged(evt); 401 } 402 }); 403 404 gridBagConstraints = new java.awt.GridBagConstraints (); 405 gridBagConstraints.gridx = 1; 406 gridBagConstraints.gridy = 1; 407 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 408 gridBagConstraints.weightx = 1.0; 409 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 410 textBlockPanel.add(verticalAlignCombo, gridBagConstraints); 411 verticalAlignCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "VERTICAL_ALIGN_ACCESS_NAME")); 412 verticalAlignCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "VERTICAL_ALIGN_ACCESS_DESC")); 413 414 wordSpacingUnitCombo.addItemListener(new java.awt.event.ItemListener () { 415 public void itemStateChanged(java.awt.event.ItemEvent evt) { 416 wordSpacingUnitComboItemStateChanged(evt); 417 } 418 }); 419 420 gridBagConstraints = new java.awt.GridBagConstraints (); 421 gridBagConstraints.gridx = 2; 422 gridBagConstraints.gridy = 4; 423 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 424 gridBagConstraints.insets = new java.awt.Insets (10, 10, 0, 0); 425 textBlockPanel.add(wordSpacingUnitCombo, gridBagConstraints); 426 wordSpacingUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_UNIT_ACCESS_NAME")); 427 wordSpacingUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_UNIT_ACCESS_DESC")); 428 429 imageScroll1.setLabelFor(wordSpacingCombo); 430 imageScroll1.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING")); 431 gridBagConstraints = new java.awt.GridBagConstraints (); 432 gridBagConstraints.gridx = 0; 433 gridBagConstraints.gridy = 4; 434 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 435 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 10); 436 textBlockPanel.add(imageScroll1, gridBagConstraints); 437 438 wordSpacingCombo.setEditable(true); 439 wordSpacingCombo.addItemListener(new java.awt.event.ItemListener () { 440 public void itemStateChanged(java.awt.event.ItemEvent evt) { 441 wordSpacingComboItemStateChanged(evt); 442 } 443 }); 444 wordSpacingCombo.addActionListener(new java.awt.event.ActionListener () { 445 public void actionPerformed(java.awt.event.ActionEvent evt) { 446 wordSpacingComboActionPerformed(evt); 447 } 448 }); 449 wordSpacingCombo.addFocusListener(new java.awt.event.FocusAdapter () { 450 public void focusLost(java.awt.event.FocusEvent evt) { 451 wordSpacingComboFocusLost(evt); 452 } 453 }); 454 455 gridBagConstraints = new java.awt.GridBagConstraints (); 456 gridBagConstraints.gridx = 1; 457 gridBagConstraints.gridy = 4; 458 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 459 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 460 gridBagConstraints.insets = new java.awt.Insets (10, 0, 0, 0); 461 textBlockPanel.add(wordSpacingCombo, gridBagConstraints); 462 wordSpacingCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_ACCESS_NAME")); 463 wordSpacingCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "WORD_SPACING_ACCESS_DESC")); 464 465 imageScroll2.setLabelFor(letterSpacingCombo); 466 imageScroll2.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING")); 467 gridBagConstraints = new java.awt.GridBagConstraints (); 468 gridBagConstraints.gridx = 0; 469 gridBagConstraints.gridy = 5; 470 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 471 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 10); 472 textBlockPanel.add(imageScroll2, gridBagConstraints); 473 474 letterSpacingCombo.setEditable(true); 475 letterSpacingCombo.addItemListener(new java.awt.event.ItemListener () { 476 public void itemStateChanged(java.awt.event.ItemEvent evt) { 477 letterSpacingComboItemStateChanged(evt); 478 } 479 }); 480 letterSpacingCombo.addActionListener(new java.awt.event.ActionListener () { 481 public void actionPerformed(java.awt.event.ActionEvent evt) { 482 letterSpacingComboActionPerformed(evt); 483 } 484 }); 485 letterSpacingCombo.addFocusListener(new java.awt.event.FocusAdapter () { 486 public void focusLost(java.awt.event.FocusEvent evt) { 487 letterSpacingComboFocusLost(evt); 488 } 489 }); 490 491 gridBagConstraints = new java.awt.GridBagConstraints (); 492 gridBagConstraints.gridx = 1; 493 gridBagConstraints.gridy = 5; 494 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 495 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 496 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 497 textBlockPanel.add(letterSpacingCombo, gridBagConstraints); 498 letterSpacingCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_ACCESS_NAME")); 499 letterSpacingCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_ACCESS_DESC")); 500 501 letterSpacingUnitCombo.addItemListener(new java.awt.event.ItemListener () { 502 public void itemStateChanged(java.awt.event.ItemEvent evt) { 503 letterSpacingUnitComboItemStateChanged(evt); 504 } 505 }); 506 507 gridBagConstraints = new java.awt.GridBagConstraints (); 508 gridBagConstraints.gridx = 2; 509 gridBagConstraints.gridy = 5; 510 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 511 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 512 textBlockPanel.add(letterSpacingUnitCombo, gridBagConstraints); 513 letterSpacingUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_UNIT_ACCESS_NAME")); 514 letterSpacingUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LETTER_SPACING_UNIT_ACCESS_DESC")); 515 516 textIndentUnitCombo.addItemListener(new java.awt.event.ItemListener () { 517 public void itemStateChanged(java.awt.event.ItemEvent evt) { 518 textIndentUnitComboItemStateChanged(evt); 519 } 520 }); 521 522 gridBagConstraints = new java.awt.GridBagConstraints (); 523 gridBagConstraints.gridx = 2; 524 gridBagConstraints.gridy = 2; 525 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 526 gridBagConstraints.insets = new java.awt.Insets (10, 10, 0, 0); 527 textBlockPanel.add(textIndentUnitCombo, gridBagConstraints); 528 textIndentUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_UNIT_ACCESS_NAME")); 529 textIndentUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "INDENT_UNIT_ACCESS_DESC")); 530 531 lineHeightLabel.setLabelFor(lineHeightCombo); 532 lineHeightLabel.setText(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT")); 533 gridBagConstraints = new java.awt.GridBagConstraints (); 534 gridBagConstraints.gridx = 0; 535 gridBagConstraints.gridy = 6; 536 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 537 gridBagConstraints.insets = new java.awt.Insets (6, 0, 0, 10); 538 textBlockPanel.add(lineHeightLabel, gridBagConstraints); 539 540 lineHeightCombo.setEditable(true); 541 lineHeightCombo.addItemListener(new java.awt.event.ItemListener () { 542 public void itemStateChanged(java.awt.event.ItemEvent evt) { 543 lineHeightComboItemStateChanged(evt); 544 } 545 }); 546 lineHeightCombo.addActionListener(new java.awt.event.ActionListener () { 547 public void actionPerformed(java.awt.event.ActionEvent evt) { 548 lineHeightComboActionPerformed(evt); 549 } 550 }); 551 lineHeightCombo.addFocusListener(new java.awt.event.FocusAdapter () { 552 public void focusLost(java.awt.event.FocusEvent evt) { 553 lineHeightComboFocusLost(evt); 554 } 555 }); 556 557 gridBagConstraints = new java.awt.GridBagConstraints (); 558 gridBagConstraints.gridx = 1; 559 gridBagConstraints.gridy = 6; 560 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 561 gridBagConstraints.insets = new java.awt.Insets (5, 0, 0, 0); 562 textBlockPanel.add(lineHeightCombo, gridBagConstraints); 563 lineHeightCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_ACCESS_NAME")); 564 lineHeightCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_ACCESS_DESC")); 565 566 lineHeightUnitCombo.addItemListener(new java.awt.event.ItemListener () { 567 public void itemStateChanged(java.awt.event.ItemEvent evt) { 568 lineHeightUnitComboItemStateChanged(evt); 569 } 570 }); 571 572 gridBagConstraints = new java.awt.GridBagConstraints (); 573 gridBagConstraints.gridx = 2; 574 gridBagConstraints.gridy = 6; 575 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 576 gridBagConstraints.insets = new java.awt.Insets (5, 10, 0, 0); 577 textBlockPanel.add(lineHeightUnitCombo, gridBagConstraints); 578 lineHeightUnitCombo.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_UNIT_ACCESS_NAME")); 579 lineHeightUnitCombo.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(TextBlockStyleEditor.class, "LINE_HEIGHT_UNIT_ACCESS_DESC")); 580 581 add(textBlockPanel, java.awt.BorderLayout.NORTH); 582 583 errorPanel.setLayout(new java.awt.BorderLayout ()); 584 585 errorPanel.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 10, 1, 1)); 586 errorLabel.setMinimumSize(new java.awt.Dimension (200, 20)); 587 errorPanel.add(errorLabel, java.awt.BorderLayout.CENTER); 588 589 add(errorPanel, java.awt.BorderLayout.CENTER); 590 591 } 593 private void letterSpacingUnitComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 595 setLetterSpacing(); 596 } 597 } 599 private void letterSpacingComboFocusLost(java.awt.event.FocusEvent evt) { setLetterSpacing(); 601 } 603 private void letterSpacingComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 605 setLetterSpacing(); 606 } 607 } 609 private void letterSpacingComboActionPerformed(java.awt.event.ActionEvent evt) { setLetterSpacing(); 611 } 613 private void wordSpacingUnitComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 615 setWordSpacing(); 616 } 617 } 619 private void wordSpacingComboFocusLost(java.awt.event.FocusEvent evt) { setWordSpacing(); 621 } 623 private void wordSpacingComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 625 setWordSpacing(); 626 } 627 } 629 private void wordSpacingComboActionPerformed(java.awt.event.ActionEvent evt) { setWordSpacing(); 631 } 633 private void directionComboItemStateChanged(java.awt.event.ItemEvent evt) { setDirection(); 635 } 637 private void textIndentUnitComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 639 setTextIndent(); 640 } 641 } 643 private void textIndentComboFocusLost(java.awt.event.FocusEvent evt) { setTextIndent(); 645 } 647 private void textIndentComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 649 setTextIndent(); 650 } 651 } 653 private void textIndentComboActionPerformed(java.awt.event.ActionEvent evt) { setTextIndent(); 655 } 657 private void verticalAlignComboFocusLost(java.awt.event.FocusEvent evt) { setVerticalAlign(); 659 } 661 private void horizontalAlignComboFocusLost(java.awt.event.FocusEvent evt) { setTextAlign(); 663 } 665 private void verticalAlignComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 667 setVerticalAlign(); 668 } 669 } 671 private void verticalAlignComboActionPerformed(java.awt.event.ActionEvent evt) { setVerticalAlign(); 673 } 675 private void horizontalAlignComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 677 setTextAlign(); 678 } 679 } 681 private void lineHeightUnitComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 683 setLineHeight(); 684 } 685 } 687 private void lineHeightComboItemStateChanged(java.awt.event.ItemEvent evt) { if (evt.getStateChange() != evt.DESELECTED) { 689 setLineHeight(); 690 } 691 } 693 private void lineHeightComboFocusLost(java.awt.event.FocusEvent evt) { setLineHeight(); 695 } 697 private void lineHeightComboActionPerformed(java.awt.event.ActionEvent evt) { setLineHeight(); 699 } 701 private void setLineHeight(){ 702 lineHeightData.setUnit(lineHeightUnitCombo.getSelectedItem().toString()); 703 lineHeightData.setValue(lineHeightCombo.getSelectedItem().toString()); 704 cssPropertyChangeSupport.firePropertyChange(CssProperties.LINE_HEIGHT, null, lineHeightData.toString()); 705 lineHeightUnitCombo.setEnabled(lineHeightData.isValueInteger()); 706 } 707 708 private void setLetterSpacing(){ 709 letterSpacingData.setUnit(letterSpacingUnitCombo.getSelectedItem().toString()); 710 letterSpacingData.setValue(letterSpacingCombo.getSelectedItem().toString()); 711 cssPropertyChangeSupport.firePropertyChange(CssProperties.LETTER_SPACING, null, letterSpacingData.toString()); 712 letterSpacingUnitCombo.setEnabled(letterSpacingData.isValueInteger()); 713 } 714 715 private void setWordSpacing(){ 716 wordSpacingData.setUnit(wordSpacingUnitCombo.getSelectedItem().toString()); 717 wordSpacingData.setValue(wordSpacingCombo.getSelectedItem().toString()); 718 cssPropertyChangeSupport.firePropertyChange(CssProperties.WORD_SPACING, null, wordSpacingData.toString()); 719 wordSpacingUnitCombo.setEnabled(wordSpacingData.isValueInteger()); 720 } 721 722 private void setDirection(){ 723 directionData.setValue(directionCombo.getSelectedItem().toString()); 724 cssPropertyChangeSupport.firePropertyChange(CssProperties.DIRECTION, null, directionData.toString()); 725 } 726 727 private void setTextIndent(){ 728 textIndentData.setUnit(textIndentUnitCombo.getSelectedItem().toString()); 729 textIndentData.setValue(textIndentCombo.getSelectedItem().toString()); 730 cssPropertyChangeSupport.firePropertyChange(CssProperties.TEXT_INDENT, null, textIndentData.toString()); 731 textIndentUnitCombo.setEnabled(textIndentData.isValueInteger()); 732 } 733 734 private void setVerticalAlign(){ 735 verticalAlignData.setValue(verticalAlignCombo.getSelectedItem().toString()); 736 cssPropertyChangeSupport.firePropertyChange(CssProperties.VERTICAL_ALIGN, null, verticalAlignData.toString()); 737 } 738 739 private void setTextAlign(){ 740 textAlignData.setValue(horizontalAlignCombo.getSelectedItem().toString()); 741 cssPropertyChangeSupport.firePropertyChange(CssProperties.TEXT_ALIGN, null, textAlignData.toString()); 742 } 743 744 private javax.swing.JLabel decorationLabel; 746 private javax.swing.JComboBox directionCombo; 747 private javax.swing.JLabel errorLabel; 748 private javax.swing.JPanel errorPanel; 749 private javax.swing.JComboBox horizontalAlignCombo; 750 private javax.swing.JLabel imageScroll; 751 private javax.swing.JLabel imageScroll1; 752 private javax.swing.JLabel imageScroll2; 753 private javax.swing.JLabel jLabel2; 754 private javax.swing.JComboBox letterSpacingCombo; 755 private javax.swing.JComboBox letterSpacingUnitCombo; 756 private javax.swing.JComboBox lineHeightCombo; 757 private javax.swing.JLabel lineHeightLabel; 758 private javax.swing.JComboBox lineHeightUnitCombo; 759 private javax.swing.JLabel textAlignLabel; 760 private javax.swing.JPanel textBlockPanel; 761 private javax.swing.JComboBox textIndentCombo; 762 private javax.swing.JComboBox textIndentUnitCombo; 763 private javax.swing.JComboBox verticalAlignCombo; 764 private javax.swing.JComboBox wordSpacingCombo; 765 private javax.swing.JComboBox wordSpacingUnitCombo; 766 768 } 769 | Popular Tags |