1 32 33 package it.businesslogic.ireport.gui.style; 34 import it.businesslogic.ireport.ConditionedStyle; 35 import it.businesslogic.ireport.CrosstabReportElement; 36 import it.businesslogic.ireport.IReportFont; 37 import it.businesslogic.ireport.Report; 38 import it.businesslogic.ireport.ReportElement; 39 import it.businesslogic.ireport.SubDataset; 40 import it.businesslogic.ireport.gui.ExpressionEditor; 41 import it.businesslogic.ireport.gui.JRParameterDialog; 42 import it.businesslogic.ireport.gui.event.SheetPropertyValueChangedListener; 43 import it.businesslogic.ireport.gui.sheet.*; 44 import it.businesslogic.ireport.Style; 45 import it.businesslogic.ireport.gui.MainFrame; 46 import it.businesslogic.ireport.gui.event.StyleChangedEvent; 47 import it.businesslogic.ireport.gui.sheet.FontSheetProperty; 48 import it.businesslogic.ireport.gui.sheet.SheetProperty; 49 import java.util.Enumeration ; 50 import java.util.HashMap ; 51 import java.util.Iterator ; 52 import java.util.Vector ; 53 import javax.swing.DefaultListModel ; 54 import javax.swing.JOptionPane ; 55 import javax.swing.ListSelectionModel ; 56 import it.businesslogic.ireport.util.I18n; 57 58 62 public class StyleDialog extends javax.swing.JDialog implements SheetPropertyValueChangedListener { 63 64 71 private boolean libraryStyle = false; 72 73 74 78 private Style style = null; 79 80 83 private Style masterStyle = null; 84 85 88 private Style editingStyle = null; 89 90 93 private boolean init = false; 94 95 98 JPanelStyleSample panelSample = new JPanelStyleSample(); 99 100 101 private CategorySheetPanel sheetPanel = null; 102 103 104 private IReportFont ireportFont = null; 105 private Report currentReport = null; 106 107 108 public StyleDialog(java.awt.Dialog parent, boolean modal) { 110 super(parent,modal); 111 initAll(); 112 } 113 114 115 public StyleDialog(java.awt.Frame parent, boolean modal) { 116 super(parent,modal); 117 initAll(); 118 } 119 120 public void initAll() 121 { 122 initComponents(); 123 124 style = new Style(); 125 126 setMasterStyle(style); 127 applyI18n(); 128 this.pack(); 130 131 it.businesslogic.ireport.util.Misc.centerFrame(this); 133 134 java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints (); 135 gridBagConstraints.gridx = 4; 136 gridBagConstraints.gridy = 2; 137 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 138 gridBagConstraints.weightx = 1.0; 139 gridBagConstraints.weighty = 1.0; 140 gridBagConstraints.fill = gridBagConstraints.BOTH; 141 gridBagConstraints.insets = new java.awt.Insets (0, -1, -1, -1); 142 sheetPanel = new CategorySheetPanel(); 143 sheetPanel.addSheetPropertyValueChangedListener(this); 144 145 jPanelProperties.add(sheetPanel, gridBagConstraints); 146 147 149 SheetProperty customizerClassProperty = new SheetProperty( Style.ATTRIBUTE_name ,"Style name", SheetProperty.STRING); 151 sheetPanel.addSheetProperty("Style", customizerClassProperty); 152 153 SheetProperty isDefaultProperty = new SheetProperty(Style.ATTRIBUTE_isDefault,"Default style", SheetProperty.BOOLEAN); 154 sheetPanel.addSheetProperty("Style", isDefaultProperty); 155 156 SheetProperty modeProperty = new SheetProperty(Style.ATTRIBUTE_mode,"Mode", SheetProperty.COMBOBOX); 157 modeProperty.setTags( new Tag[]{ new Tag(null,"Default"), new Tag("Opaque","Opaque"), 158 new Tag("Transparent","Transparent")}); 159 sheetPanel.addSheetProperty("Common", modeProperty); 160 161 SheetProperty forecolorProperty = new SheetProperty(Style.ATTRIBUTE_forecolor,"Forecolor", SheetProperty.COLOR); 162 forecolorProperty.setValue( null ); 163 sheetPanel.addSheetProperty("Common", forecolorProperty); 164 165 SheetProperty backcolorProperty = new SheetProperty(Style.ATTRIBUTE_backcolor,"Backcolor", SheetProperty.COLOR); 166 backcolorProperty.setValue( null ); 167 sheetPanel.addSheetProperty("Common", backcolorProperty); 168 169 ComboBoxSheetProperty styleProperty = new ComboBoxSheetProperty(Style.ATTRIBUTE_style,"Parent style"); 170 171 sheetPanel.addSheetProperty("Style", styleProperty); 172 173 SheetProperty penProperty = new SheetProperty(Style.ATTRIBUTE_pen,"Pen", SheetProperty.COMBOBOX); 174 penProperty.setTags( new Tag[]{ new Tag(null,"Default"),new Tag("Thin","Thin"), 175 new Tag("1Point","1Point"), 176 new Tag("2Point","2Point"), 177 new Tag("4Point","4Point"), 178 new Tag("Dotted","Dotted")}); 179 sheetPanel.addSheetProperty("Graphics", penProperty); 180 181 SheetProperty fillProperty = new SheetProperty(Style.ATTRIBUTE_fill,"Fill", SheetProperty.COMBOBOX); 182 fillProperty.setTags( new Tag[]{ new Tag(null,"Default"),new Tag("Solid","Solid")}); 183 sheetPanel.addSheetProperty("Graphics", fillProperty); 184 185 SheetProperty radiusProperty = new SheetProperty(Style.ATTRIBUTE_radius,"Radius", SheetProperty.INTEGER); 186 sheetPanel.addSheetProperty("Graphics", radiusProperty); 187 188 SheetProperty scaleImageProperty = new SheetProperty(Style.ATTRIBUTE_scaleImage,"Scale image", SheetProperty.COMBOBOX); 189 scaleImageProperty.setTags( new Tag[]{ new Tag(null,"Default"),new Tag("Clip","Clip"), 190 new Tag("FillFrame","FillFrame"), 191 new Tag("RetainShape","RetainShape")}); 192 sheetPanel.addSheetProperty("Graphics", scaleImageProperty); 193 194 SheetProperty hAlignProperty = new SheetProperty(Style.ATTRIBUTE_hAlign,"Horizontal align", SheetProperty.COMBOBOX); 195 hAlignProperty.setTags( new Tag[]{ new Tag(null,"Default"),new Tag("Left","Left"), 196 new Tag("Center","Center"), 197 new Tag("Right","Right"), 198 new Tag("Justified","Justified")}); 199 sheetPanel.addSheetProperty("Graphics", hAlignProperty); 200 201 SheetProperty vAlignProperty = new SheetProperty(Style.ATTRIBUTE_vAlign,"Vertical align", SheetProperty.COMBOBOX); 202 vAlignProperty.setTags( new Tag[]{ new Tag(null,"Default"),new Tag("Top","Top"), 203 new Tag("Middle","Middle"), 204 new Tag("Bottom","Bottom")}); 205 sheetPanel.addSheetProperty("Graphics", vAlignProperty); 206 207 208 SheetProperty borderProperty = new SheetProperty(Style.ATTRIBUTE_border,"Border", SheetProperty.COMBOBOX); 209 borderProperty.setTags( new Tag[]{new Tag(null,"Default"), 210 new Tag("Thin","Thin"), 211 new Tag("1Point","1Point"), 212 new Tag("2Point","2Point"), 213 new Tag("4Point","4Point"), 214 new Tag("Dotted","Dotted")}); 215 sheetPanel.addSheetProperty("Border and padding", borderProperty); 216 217 SheetProperty borderColorProperty = new SheetProperty(Style.ATTRIBUTE_borderColor,"Border color", SheetProperty.COLOR); 218 sheetPanel.addSheetProperty("Border and padding", borderColorProperty); 219 220 SheetProperty paddingProperty = new SheetProperty(Style.ATTRIBUTE_padding,"Padding", SheetProperty.INTEGER); 221 sheetPanel.addSheetProperty("Border and padding", paddingProperty); 222 223 SheetProperty topBorderProperty = new SheetProperty(Style.ATTRIBUTE_topBorder,"Top border", SheetProperty.COMBOBOX); 224 topBorderProperty.setTags( new Tag[]{ 225 new Tag(null,"Default"), 226 new Tag("Thin","Thin"), 227 new Tag("1Point","1Point"), 228 new Tag("2Point","2Point"), 229 new Tag("4Point","4Point"), 230 new Tag("Dotted","Dotted")}); 231 sheetPanel.addSheetProperty("Border and padding", topBorderProperty); 232 233 SheetProperty topBorderColorProperty = new SheetProperty(Style.ATTRIBUTE_topBorderColor,"Top border color", SheetProperty.COLOR); 234 sheetPanel.addSheetProperty("Border and padding", topBorderColorProperty); 235 236 SheetProperty topPaddingProperty = new SheetProperty(Style.ATTRIBUTE_topPadding,"Top padding", SheetProperty.INTEGER); 237 sheetPanel.addSheetProperty("Border and padding", topPaddingProperty); 238 239 SheetProperty leftBorderProperty = new SheetProperty(Style.ATTRIBUTE_leftBorder,"Left border", SheetProperty.COMBOBOX); 240 leftBorderProperty.setTags( new Tag[]{ 241 new Tag(null,"Default"), 242 new Tag("Thin","Thin"), 243 new Tag("1Point","1Point"), 244 new Tag("2Point","2Point"), 245 new Tag("4Point","4Point"), 246 new Tag("Dotted","Dotted")}); 247 sheetPanel.addSheetProperty("Border and padding", leftBorderProperty); 248 249 SheetProperty leftBorderColorProperty = new SheetProperty(Style.ATTRIBUTE_leftBorderColor,"Left border color", SheetProperty.COLOR); 250 sheetPanel.addSheetProperty("Border and padding", leftBorderColorProperty); 251 252 SheetProperty leftPaddingProperty = new SheetProperty(Style.ATTRIBUTE_leftPadding,"Left padding", SheetProperty.INTEGER); 253 sheetPanel.addSheetProperty("Border and padding", leftPaddingProperty); 254 255 SheetProperty bottomBorderProperty = new SheetProperty(Style.ATTRIBUTE_bottomBorder,"Bottom border", SheetProperty.COMBOBOX); 256 bottomBorderProperty.setTags( new Tag[]{ 257 new Tag(null,"Default"), 258 new Tag("Thin","Thin"), 259 new Tag("1Point","1Point"), 260 new Tag("2Point","2Point"), 261 new Tag("4Point","4Point"), 262 new Tag("Dotted","Dotted")}); 263 sheetPanel.addSheetProperty("Border and padding", bottomBorderProperty); 264 265 SheetProperty bottomBorderColorProperty = new SheetProperty(Style.ATTRIBUTE_bottomBorderColor,"Bottom border color", SheetProperty.COLOR); 266 sheetPanel.addSheetProperty("Border and padding", bottomBorderColorProperty); 267 268 SheetProperty bottomPaddingProperty = new SheetProperty(Style.ATTRIBUTE_bottomPadding,"Bottom padding", SheetProperty.INTEGER); 269 sheetPanel.addSheetProperty("Border and padding", bottomPaddingProperty); 270 271 SheetProperty rightBorderProperty = new SheetProperty(Style.ATTRIBUTE_rightBorder,"Right border", SheetProperty.COMBOBOX); 272 rightBorderProperty.setTags( new Tag[]{ 273 new Tag(null,"Default"), 274 new Tag("Thin","Thin"), 275 new Tag("1Point","1Point"), 276 new Tag("2Point","2Point"), 277 new Tag("4Point","4Point"), 278 new Tag("Dotted","Dotted")}); 279 sheetPanel.addSheetProperty("Border and padding", rightBorderProperty); 280 281 SheetProperty rightBorderColorProperty = new SheetProperty(Style.ATTRIBUTE_rightBorderColor,"Right border color", SheetProperty.COLOR); 282 sheetPanel.addSheetProperty("Border and padding", rightBorderColorProperty); 283 284 SheetProperty rightPaddingProperty = new SheetProperty(Style.ATTRIBUTE_rightPadding,"Right padding", SheetProperty.INTEGER); 285 sheetPanel.addSheetProperty("Border and padding", rightPaddingProperty); 286 287 SheetProperty rotationProperty = new SheetProperty(Style.ATTRIBUTE_rotation,"Rotation", SheetProperty.COMBOBOX); 288 rotationProperty.setTags( new Tag[]{ new Tag(null,"Default"), 289 new Tag("None","None"), 290 new Tag("Left","Left"), 291 new Tag("Right","Right"), 292 new Tag("UpsideDown","UpsideDown")}); 293 sheetPanel.addSheetProperty("Text properties", rotationProperty); 294 295 SheetProperty patternProperty = new SheetProperty(Style.ATTRIBUTE_pattern,"Pattern", SheetProperty.STRING); 296 sheetPanel.addSheetProperty("Text properties", patternProperty); 297 298 SheetProperty isBlankWhenNullProperty = new SheetProperty(Style.ATTRIBUTE_isBlankWhenNull,"Is Blank when Null", SheetProperty.BOOLEAN); 299 sheetPanel.addSheetProperty("Text properties", isBlankWhenNullProperty); 300 301 FontSheetProperty theFontSpacingProperty = new FontSheetProperty("style.font","Font"); 303 theFontSpacingProperty.setFontMode( 3 ); 304 sheetPanel.addSheetProperty("Text properties", theFontSpacingProperty); 305 306 SheetProperty lineSpacingProperty = new SheetProperty(Style.ATTRIBUTE_lineSpacing,"Line spacing", SheetProperty.COMBOBOX); 307 lineSpacingProperty.setTags( new Tag[]{ new Tag(null,"Default"), 308 new Tag("Single","Single"), 309 new Tag("1_1_2","1_1_2"), 310 new Tag("Double","Double")}); 311 sheetPanel.addSheetProperty("Text properties", lineSpacingProperty); 312 313 318 SheetProperty isBoldProperty = new SheetProperty(Style.ATTRIBUTE_isBold,"Bold", SheetProperty.BOOLEAN); 319 sheetPanel.addSheetProperty("Text properties", isBoldProperty); 320 321 SheetProperty isItalicProperty = new SheetProperty(Style.ATTRIBUTE_isItalic,"Italic", SheetProperty.BOOLEAN); 322 sheetPanel.addSheetProperty("Text properties", isItalicProperty); 323 324 SheetProperty isUnderlineProperty = new SheetProperty(Style.ATTRIBUTE_isUnderline,"Underline", SheetProperty.BOOLEAN); 325 sheetPanel.addSheetProperty("Text properties", isUnderlineProperty); 326 327 SheetProperty isStrikeThroughProperty = new SheetProperty(Style.ATTRIBUTE_isStrikeThrough,"StrikeThrough", SheetProperty.BOOLEAN); 328 sheetPanel.addSheetProperty("Text properties", isStrikeThroughProperty); 329 330 333 344 345 gridBagConstraints.gridx = 0; 346 gridBagConstraints.gridy = 0; 347 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST; 348 gridBagConstraints.weightx = 1.0; 349 gridBagConstraints.weighty = 1.0; 350 gridBagConstraints.fill = gridBagConstraints.BOTH; 351 gridBagConstraints.insets = new java.awt.Insets (0,0, 0, 0); 352 353 this.jPanelSample.add(panelSample,gridBagConstraints); 354 355 SheetProperty isStyledTextProperty = new SheetProperty(Style.ATTRIBUTE_isStyledText,"Is Styled Text", SheetProperty.BOOLEAN); 356 sheetPanel.addSheetProperty("Text properties", isStyledTextProperty); 357 sheetPanel.recreateSheet(); 359 360 sheetPanel.collapseCategory("Border and padding"); 361 362 this.updateStyleValues(); 363 364 this.jConditionsList.setModel( new DefaultListModel ()); 365 this.jConditionsList.setSelectionMode( ListSelectionModel.SINGLE_SELECTION); 366 367 ((DefaultListModel )this.jConditionsList.getModel()).addElement("Default"); 368 this.jConditionsList.setSelectedIndex(0); 369 370 javax.swing.KeyStroke escape = javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_ESCAPE, 0, false); 371 javax.swing.Action escapeAction = new javax.swing.AbstractAction () { 372 public void actionPerformed(java.awt.event.ActionEvent e) { 373 jButtonCancelActionPerformed(e); 374 } 375 }; 376 377 getRootPane().getInputMap(javax.swing.JComponent.WHEN_IN_FOCUSED_WINDOW).put(escape, "ESCAPE"); 378 getRootPane().getActionMap().put("ESCAPE", escapeAction); 379 380 381 this.getRootPane().setDefaultButton(this.jButtonOK); 383 } 384 385 386 391 private void initComponents() { 393 java.awt.GridBagConstraints gridBagConstraints; 394 395 jSplitPane1 = new javax.swing.JSplitPane (); 396 jPanelProperties = new javax.swing.JPanel (); 397 jPanelConditions = new javax.swing.JPanel (); 398 jLabelStyleConditions = new javax.swing.JLabel (); 399 jScrollPane1 = new javax.swing.JScrollPane (); 400 jConditionsList = new javax.swing.JList (); 401 jPanel2 = new javax.swing.JPanel (); 402 jButtonAddCondition = new javax.swing.JButton (); 403 jButtonModifyCondition = new javax.swing.JButton (); 404 jButtonRemoveCondition = new javax.swing.JButton (); 405 jButtonUpCondition = new javax.swing.JButton (); 406 jButtonDownCondition = new javax.swing.JButton (); 407 jLabelSample = new javax.swing.JLabel (); 408 jPanelSample = new javax.swing.JPanel (); 409 jPanel1 = new javax.swing.JPanel (); 410 jButtonOK = new javax.swing.JButton (); 411 jButtonCancel = new javax.swing.JButton (); 412 413 getContentPane().setLayout(new java.awt.GridBagLayout ()); 414 415 setTitle("Add/modify Style"); 416 setTitle(it.businesslogic.ireport.util.I18n.getString("addModStyle", "Add/modify Style")); setModal(true); 418 addWindowListener(new java.awt.event.WindowAdapter () { 419 public void windowClosing(java.awt.event.WindowEvent evt) { 420 closeDialog(evt); 421 } 422 }); 423 424 jSplitPane1.setResizeWeight(0.5); 425 jPanelProperties.setLayout(new java.awt.GridBagLayout ()); 426 427 jPanelProperties.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED)); 428 jPanelProperties.setMinimumSize(new java.awt.Dimension (100, 4)); 429 jPanelProperties.setPreferredSize(new java.awt.Dimension (320, 470)); 430 jSplitPane1.setLeftComponent(jPanelProperties); 431 432 jPanelConditions.setLayout(new java.awt.GridBagLayout ()); 433 434 jPanelConditions.setMinimumSize(new java.awt.Dimension (100, 10)); 435 jPanelConditions.setPreferredSize(new java.awt.Dimension (200, 10)); 436 jLabelStyleConditions.setText("Style conditions"); 437 gridBagConstraints = new java.awt.GridBagConstraints (); 438 gridBagConstraints.gridx = 0; 439 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 440 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 441 gridBagConstraints.weightx = 1.0; 442 gridBagConstraints.insets = new java.awt.Insets (4, 4, 0, 4); 443 jPanelConditions.add(jLabelStyleConditions, gridBagConstraints); 444 445 jConditionsList.addListSelectionListener(new javax.swing.event.ListSelectionListener () { 446 public void valueChanged(javax.swing.event.ListSelectionEvent evt) { 447 jConditionsListValueChanged(evt); 448 } 449 }); 450 jConditionsList.addMouseListener(new java.awt.event.MouseAdapter () { 451 public void mouseClicked(java.awt.event.MouseEvent evt) { 452 jConditionsListMouseClicked(evt); 453 } 454 }); 455 456 jScrollPane1.setViewportView(jConditionsList); 457 458 gridBagConstraints = new java.awt.GridBagConstraints (); 459 gridBagConstraints.gridx = 0; 460 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 461 gridBagConstraints.weightx = 1.0; 462 gridBagConstraints.weighty = 1.0; 463 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 464 jPanelConditions.add(jScrollPane1, gridBagConstraints); 465 466 jPanel2.setLayout(new java.awt.GridBagLayout ()); 467 468 jButtonAddCondition.setText("Add"); 469 jButtonAddCondition.setMargin(new java.awt.Insets (2, 2, 2, 2)); 470 jButtonAddCondition.addActionListener(new java.awt.event.ActionListener () { 471 public void actionPerformed(java.awt.event.ActionEvent evt) { 472 jButtonAddConditionActionPerformed(evt); 473 } 474 }); 475 476 gridBagConstraints = new java.awt.GridBagConstraints (); 477 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 478 gridBagConstraints.weightx = 1.0; 479 jPanel2.add(jButtonAddCondition, gridBagConstraints); 480 481 jButtonModifyCondition.setText("Modify"); 482 jButtonModifyCondition.setEnabled(false); 483 jButtonModifyCondition.setMargin(new java.awt.Insets (2, 2, 2, 2)); 484 jButtonModifyCondition.addActionListener(new java.awt.event.ActionListener () { 485 public void actionPerformed(java.awt.event.ActionEvent evt) { 486 jButtonModifyConditionActionPerformed(evt); 487 } 488 }); 489 490 gridBagConstraints = new java.awt.GridBagConstraints (); 491 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 492 gridBagConstraints.weightx = 1.0; 493 jPanel2.add(jButtonModifyCondition, gridBagConstraints); 494 495 jButtonRemoveCondition.setText("Remove"); 496 jButtonRemoveCondition.setEnabled(false); 497 jButtonRemoveCondition.setMargin(new java.awt.Insets (2, 2, 2, 2)); 498 jButtonRemoveCondition.addActionListener(new java.awt.event.ActionListener () { 499 public void actionPerformed(java.awt.event.ActionEvent evt) { 500 jButtonRemoveConditionActionPerformed(evt); 501 } 502 }); 503 504 gridBagConstraints = new java.awt.GridBagConstraints (); 505 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 506 gridBagConstraints.weightx = 1.0; 507 jPanel2.add(jButtonRemoveCondition, gridBagConstraints); 508 509 jButtonUpCondition.setText("up"); 510 jButtonUpCondition.setEnabled(false); 511 jButtonUpCondition.setMargin(new java.awt.Insets (2, 2, 2, 2)); 512 jButtonUpCondition.addActionListener(new java.awt.event.ActionListener () { 513 public void actionPerformed(java.awt.event.ActionEvent evt) { 514 jButtonUpConditionActionPerformed(evt); 515 } 516 }); 517 518 gridBagConstraints = new java.awt.GridBagConstraints (); 519 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 520 gridBagConstraints.weightx = 1.0; 521 jPanel2.add(jButtonUpCondition, gridBagConstraints); 522 523 jButtonDownCondition.setText("Down"); 524 jButtonDownCondition.setEnabled(false); 525 jButtonDownCondition.setMargin(new java.awt.Insets (2, 2, 2, 2)); 526 jButtonDownCondition.addActionListener(new java.awt.event.ActionListener () { 527 public void actionPerformed(java.awt.event.ActionEvent evt) { 528 jButtonDownConditionActionPerformed(evt); 529 } 530 }); 531 532 gridBagConstraints = new java.awt.GridBagConstraints (); 533 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 534 gridBagConstraints.weightx = 1.0; 535 jPanel2.add(jButtonDownCondition, gridBagConstraints); 536 537 gridBagConstraints = new java.awt.GridBagConstraints (); 538 gridBagConstraints.gridx = 0; 539 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 540 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 541 jPanelConditions.add(jPanel2, gridBagConstraints); 542 543 jLabelSample.setText("Sample"); 544 gridBagConstraints = new java.awt.GridBagConstraints (); 545 gridBagConstraints.gridx = 0; 546 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 547 gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHEAST; 548 gridBagConstraints.weightx = 1.0; 549 gridBagConstraints.insets = new java.awt.Insets (0, 4, 0, 4); 550 jPanelConditions.add(jLabelSample, gridBagConstraints); 551 552 jPanelSample.setLayout(new java.awt.GridBagLayout ()); 553 554 jPanelSample.setBorder(javax.swing.BorderFactory.createEtchedBorder()); 555 jPanelSample.setMinimumSize(new java.awt.Dimension (100, 80)); 556 jPanelSample.setPreferredSize(new java.awt.Dimension (14, 80)); 557 gridBagConstraints = new java.awt.GridBagConstraints (); 558 gridBagConstraints.gridx = 0; 559 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 560 gridBagConstraints.ipadx = 4; 561 gridBagConstraints.ipady = 4; 562 gridBagConstraints.insets = new java.awt.Insets (0, 4, 4, 4); 563 jPanelConditions.add(jPanelSample, gridBagConstraints); 564 565 jSplitPane1.setRightComponent(jPanelConditions); 566 567 gridBagConstraints = new java.awt.GridBagConstraints (); 568 gridBagConstraints.gridx = 0; 569 gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH; 570 gridBagConstraints.ipadx = 4; 571 gridBagConstraints.ipady = 4; 572 gridBagConstraints.weightx = 1.0; 573 gridBagConstraints.weighty = 1.0; 574 getContentPane().add(jSplitPane1, gridBagConstraints); 575 576 jPanel1.setLayout(new java.awt.FlowLayout (java.awt.FlowLayout.RIGHT)); 577 578 jButtonOK.setMnemonic('o'); 579 jButtonOK.setText("OK"); 580 jButtonOK.addActionListener(new java.awt.event.ActionListener () { 581 public void actionPerformed(java.awt.event.ActionEvent evt) { 582 jButtonOKActionPerformed(evt); 583 } 584 }); 585 586 jPanel1.add(jButtonOK); 587 588 jButtonCancel.setText("Cancel"); 589 jButtonCancel.setMnemonic('c'); 590 jButtonCancel.addActionListener(new java.awt.event.ActionListener () { 591 public void actionPerformed(java.awt.event.ActionEvent evt) { 592 jButtonCancelActionPerformed(evt); 593 } 594 }); 595 596 jPanel1.add(jButtonCancel); 597 598 gridBagConstraints = new java.awt.GridBagConstraints (); 599 gridBagConstraints.gridx = 0; 600 gridBagConstraints.gridy = 9; 601 gridBagConstraints.gridwidth = 2; 602 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL; 603 gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST; 604 gridBagConstraints.weightx = 1.0; 605 gridBagConstraints.insets = new java.awt.Insets (3, 3, 3, 3); 606 getContentPane().add(jPanel1, gridBagConstraints); 607 608 pack(); 609 java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize(); 610 java.awt.Dimension dialogSize = getSize(); 611 setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2); 612 } 614 private void jButtonDownConditionActionPerformed(java.awt.event.ActionEvent evt) { DefaultListModel dlm = (DefaultListModel )this.jConditionsList.getModel(); 616 setInit(true); 617 int i = jConditionsList.getSelectedIndex(); 618 Object cs = jConditionsList.getSelectedValue(); 619 dlm.removeElementAt(i); 620 dlm.insertElementAt(cs, i+1); 621 jConditionsList.setSelectedIndex(i+1); 622 623 jButtonUpCondition.setEnabled(true); 624 if (i == dlm.size()-2) jButtonDownCondition.setEnabled(false); 625 setInit(false); 626 } 628 private void jButtonUpConditionActionPerformed(java.awt.event.ActionEvent evt) { 630 DefaultListModel dlm = (DefaultListModel )this.jConditionsList.getModel(); 631 setInit(true); 632 int i = jConditionsList.getSelectedIndex(); 633 Object cs = jConditionsList.getSelectedValue(); 634 dlm.removeElementAt(i); 635 dlm.insertElementAt(cs, i-1); 636 jConditionsList.setSelectedIndex(i-1); 637 638 if (i == 2) jButtonUpCondition.setEnabled(false); 639 jButtonDownCondition.setEnabled(true); 640 setInit(false); 641 642 643 } 645 private void jButtonRemoveConditionActionPerformed(java.awt.event.ActionEvent evt) { 647 if (jConditionsList.getSelectedIndex() == 0) return; 648 int i = jConditionsList.getSelectedIndex(); 649 jConditionsList.setSelectedIndex(i-1); 650 ((DefaultListModel )this.jConditionsList.getModel()).remove( i); 651 652 653 } 655 private void jButtonModifyConditionActionPerformed(java.awt.event.ActionEvent evt) { 657 if (jConditionsList.getSelectedIndex() == 0) return; 658 659 ConditionedStyle s = (ConditionedStyle) jConditionsList.getSelectedValue(); 660 String expression = s.getCondition(); 661 662 ExpressionEditor ed = new ExpressionEditor(); 663 if ( MainFrame.getMainInstance().getActiveReportFrame() != null) 664 { 665 Report report = MainFrame.getMainInstance().getActiveReportFrame().getReport(); 666 ed.setSubDataset( report ); 667 Vector v = report.getElements(); 668 for (int i=0; i<v.size(); ++i) 669 { 670 ReportElement re = (ReportElement)v.elementAt(i); 671 if (re instanceof CrosstabReportElement) 672 { 673 ed.addCrosstabReportElement( (CrosstabReportElement)re ); 674 } 675 } 676 } 677 else 678 { 679 ed.setSubDataset( new SubDataset()); 680 } 681 682 ed.setExpression(expression); 683 ed.setVisible(true); 684 if (ed.getDialogResult() == JOptionPane.OK_OPTION) 685 { 686 String exp = ed.getExpression(); 687 if (exp.trim().length() > 0) 688 { 689 s.setCondition( exp.trim()); 690 jConditionsList.updateUI(); 691 } 692 } 693 694 } 696 private void jConditionsListMouseClicked(java.awt.event.MouseEvent evt) { 698 if (evt.getClickCount() == 2 && evt.getButton() == evt.BUTTON1) 699 { 700 jButtonModifyConditionActionPerformed(null); 701 } 702 703 } 705 private void jButtonAddConditionActionPerformed(java.awt.event.ActionEvent evt) { 707 ExpressionEditor ed = new ExpressionEditor(); 708 if ( MainFrame.getMainInstance().getActiveReportFrame() != null) 709 { 710 Report report = MainFrame.getMainInstance().getActiveReportFrame().getReport(); 711 ed.setSubDataset( report ); 712 Vector v = report.getElements(); 713 for (int i=0; i<v.size(); ++i) 714 { 715 ReportElement re = (ReportElement)v.elementAt(i); 716 if (re instanceof CrosstabReportElement) 717 { 718 ed.addCrosstabReportElement( (CrosstabReportElement)re ); 719 } 720 } 721 } 722 else 723 { 724 ed.setSubDataset( new SubDataset()); 725 } 726 727 ed.setVisible(true); 728 729 if (ed.getDialogResult() == JOptionPane.OK_OPTION) 730 { 731 String exp = ed.getExpression(); 732 if (exp.trim().length() > 0) 733 { 734 saveCurrentStyle(); 735 ConditionedStyle s = new ConditionedStyle(getMasterStyle()); 736 s.setConditionedStyles( new Vector () ); 737 s.setCondition( exp.trim()); 738 DefaultListModel dlm = (DefaultListModel )jConditionsList.getModel(); 739 dlm.addElement(s); 740 jConditionsList.setSelectedValue(s, true); 741 } 742 } 743 } 745 private void jConditionsListValueChanged(javax.swing.event.ListSelectionEvent evt) { 747 if (isInit()) return; 748 if (evt.getValueIsAdjusting()) return; 749 750 saveCurrentStyle(); 753 754 if (jConditionsList.getSelectedIndex() == 0) 755 { 756 jButtonModifyCondition.setEnabled(false); 757 jButtonRemoveCondition.setEnabled(false); 758 jButtonUpCondition.setEnabled(false); 759 jButtonDownCondition.setEnabled(false); 760 761 setStyle(getMasterStyle(), false); 762 } 763 else 764 { 765 jButtonModifyCondition.setEnabled(true); 766 jButtonRemoveCondition.setEnabled(true); 767 jButtonUpCondition.setEnabled(jConditionsList.getSelectedIndex()>1); 768 jButtonDownCondition.setEnabled(jConditionsList.getSelectedIndex()< ((DefaultListModel )jConditionsList.getModel()).size()-1); 769 770 setStyle((Style)jConditionsList.getSelectedValue(), true); 771 } 772 773 774 } 776 private void jButtonCancelActionPerformed(java.awt.event.ActionEvent evt) { setVisible(false); 778 this.setDialogResult( javax.swing.JOptionPane.CANCEL_OPTION); 779 dispose(); 780 } 782 private void jButtonOKActionPerformed(java.awt.event.ActionEvent evt) { 784 saveCurrentStyle(); 785 786 String newName = getMasterStyle().getAttributeString( Style.ATTRIBUTE_name ,""); 787 788 789 if (newName.trim().length() <= 0) 790 { 791 javax.swing.JOptionPane.showMessageDialog(this, 792 I18n.getString("messages.styleDialog.notValidName","Please insert a valid name for the style!"), 793 I18n.getString("messages.styleDialog.notValidNameCaption","Invalid name!"), 794 javax.swing.JOptionPane.WARNING_MESSAGE ); 795 jConditionsList.setSelectedIndex(0); 796 return; 797 } 798 799 Enumeration e = null; 801 802 if (isLibraryStyle()) 803 { 804 e = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getStyleLibrarySet().elements(); 805 } 806 else 807 { 808 e = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getActiveReportFrame().getReport().getStyles().elements(); 809 } 810 811 while (e.hasMoreElements()) 812 { 813 Style st = (Style)e.nextElement(); 814 if (st.getAttributeString( st.ATTRIBUTE_name ,"").equals(newName) && st != getEditingStyle()) 815 { 816 javax.swing.JOptionPane.showMessageDialog(this,"The name \"" + newName + "\" is already in use!\nPlease change it.","Invalid name!",javax.swing.JOptionPane.WARNING_MESSAGE ); 817 return; 818 } 819 } 820 821 DefaultListModel dlm = (DefaultListModel )jConditionsList.getModel(); 822 Vector conditionedStyles = new Vector (); 823 for (int k = 1; k<dlm.size(); ++k) 824 { 825 conditionedStyles.add(dlm.getElementAt(k) ); 826 } 827 getMasterStyle().setConditionedStyles(conditionedStyles); 828 829 String oldName = ""; 830 boolean newStyle = false; 831 832 if (getEditingStyle() == null) 833 { 834 newStyle = true; 835 setEditingStyle( getMasterStyle() ); 836 837 if (!isLibraryStyle()) 838 { 839 MainFrame.getMainInstance().getActiveReportFrame().getReport().getStyles().add(getMasterStyle()); 840 } 841 else 842 { 843 it.businesslogic.ireport.gui.MainFrame.getMainInstance().getStyleLibrarySet().add(getMasterStyle()); 844 } 845 } 846 else 847 { 848 oldName = getEditingStyle().getAttributeString( Style.ATTRIBUTE_name ,""); 849 getEditingStyle().getAttributes().clear(); 850 getEditingStyle().copyStyleFrom(getMasterStyle()); 851 } 852 853 if (!isLibraryStyle()) 854 { 855 MainFrame.getMainInstance().getActiveReportFrame().getReport().fireStyleChangedListenerStyleChanged( 856 new StyleChangedEvent( 857 MainFrame.getMainInstance().getActiveReportFrame().getReport(), 858 (newStyle) ? StyleChangedEvent.ADDED : StyleChangedEvent.CHANGED, 859 getEditingStyle(), 860 getEditingStyle())); 861 } 862 863 this.style = getEditingStyle(); 864 865 875 setVisible(false); 876 this.setDialogResult( javax.swing.JOptionPane.OK_OPTION); 877 dispose(); 878 } 880 881 private void closeDialog(java.awt.event.WindowEvent evt) { setVisible(false); 883 this.setDialogResult( javax.swing.JOptionPane.CLOSED_OPTION); 884 dispose(); 885 } 887 890 public static void main(String args[]) { 891 new JRParameterDialog(new javax.swing.JFrame (), true).setVisible(true); 892 } 893 894 895 899 public int getDialogResult() { 900 return dialogResult; 901 } 902 903 907 public void setDialogResult(int dialogResult) { 908 this.dialogResult = dialogResult; 909 } 910 911 912 private javax.swing.JButton jButtonAddCondition; 914 private javax.swing.JButton jButtonCancel; 915 private javax.swing.JButton jButtonDownCondition; 916 private javax.swing.JButton jButtonModifyCondition; 917 private javax.swing.JButton jButtonOK; 918 private javax.swing.JButton jButtonRemoveCondition; 919 private javax.swing.JButton jButtonUpCondition; 920 private javax.swing.JList jConditionsList; 921 private javax.swing.JLabel jLabelSample; 922 private javax.swing.JLabel jLabelStyleConditions; 923 private javax.swing.JPanel jPanel1; 924 private javax.swing.JPanel jPanel2; 925 private javax.swing.JPanel jPanelConditions; 926 private javax.swing.JPanel jPanelProperties; 927 private javax.swing.JPanel jPanelSample; 928 private javax.swing.JScrollPane jScrollPane1; 929 private javax.swing.JSplitPane jSplitPane1; 930 932 private int dialogResult; 933 934 public CategorySheetPanel getSheetPanel() { 935 return sheetPanel; 936 } 937 938 public void setSheetPanel(CategorySheetPanel sheetPanel) { 939 this.sheetPanel = sheetPanel; 940 } 941 942 public void sheetPropertyValueChanged(it.businesslogic.ireport.gui.event.SheetPropertyValueChangedEvent evt) { 943 944 946 947 if (isInit()) return; 948 if (evt.getPropertyName() != null && evt.getPropertyName().equals("style.font")) 949 { 950 setIreportFont( (IReportFont)evt.getNewValue()); 951 952 boolean initNow = isInit(); 953 setInit(true); 954 if (getIreportFont() != null) 955 { 956 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold, getIreportFont().getBeanProperties().get(getIreportFont().IS_BOLD)); 957 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic, getIreportFont().getBeanProperties().get(getIreportFont().IS_ITALIC)); 958 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStrikeThrough, getIreportFont().getBeanProperties().get(getIreportFont().IS_STRIKETROUGHT)); 959 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isUnderline, getIreportFont().getBeanProperties().get(getIreportFont().IS_UNDERLINE)); 960 } 961 else 962 { 963 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold, null); 964 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic, null); 965 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStrikeThrough, null); 966 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isUnderline, null); 967 } 968 setInit(initNow); 969 970 } 971 else if (evt.getPropertyName() != null && evt.getPropertyName().equals(Style.ATTRIBUTE_isBold)) 972 { 973 IReportFont ifont = getIreportFont(); 974 ifont.getBeanProperties().put(ifont.IS_BOLD, evt.getNewValue()); 975 sheetPanel.setPropertyValue("style.font", ifont); 976 } 977 else if (evt.getPropertyName() != null && evt.getPropertyName().equals(Style.ATTRIBUTE_isItalic)) 978 { 979 IReportFont ifont = getIreportFont(); 980 ifont.getBeanProperties().put(ifont.IS_ITALIC, evt.getNewValue()); 981 sheetPanel.setPropertyValue("style.font", ifont); 982 } 983 else if (evt.getPropertyName() != null && evt.getPropertyName().equals(Style.ATTRIBUTE_isUnderline)) 984 { 985 IReportFont ifont = getIreportFont(); 986 ifont.getBeanProperties().put(ifont.IS_UNDERLINE, evt.getNewValue()); 987 sheetPanel.setPropertyValue("style.font", ifont); 988 } 989 else if (evt.getPropertyName() != null && evt.getPropertyName().equals(Style.ATTRIBUTE_isStrikeThrough)) 990 { 991 IReportFont ifont = getIreportFont(); 992 ifont.getBeanProperties().put(ifont.IS_STRIKETROUGHT, evt.getNewValue()); 993 sheetPanel.setPropertyValue("style.font", ifont); 994 } 995 996 997 998 if (!isInit() && panelSample != null && panelSample.getStyle() != null) 1000 { 1001 Vector properties = this.sheetPanel.getProperties(); 1002 for (int i=0; i<properties.size(); ++i) 1003 { 1004 SheetProperty sp = (SheetProperty)properties.get(i); 1005 { 1007 panelSample.getStyle().getAttributes().put( sp.getKeyName(), sp.getValue()); 1008 } 1009 } 1010 panelSample.invalidate(); 1011 panelSample.repaint(); 1012 } 1013 } 1014 1015 public Style getStyle() { 1016 return style; 1017 } 1018 1019 public void updateStyleValues() 1020 { 1021 setInit(true); 1022 1024 sheetPanel.setPropertyValue(Style.ATTRIBUTE_name,getStyle().getAttribute(style.ATTRIBUTE_name)); 1025 sheetPanel.setPropertyValue(Style.ATTRIBUTE_backcolor,getStyle().getAttribute(style.ATTRIBUTE_backcolor)); 1026 sheetPanel.setPropertyValue(Style.ATTRIBUTE_borderColor,getStyle().getAttribute(style.ATTRIBUTE_borderColor)); 1027 sheetPanel.setPropertyValue(Style.ATTRIBUTE_border,getStyle().getAttribute(style.ATTRIBUTE_border)); 1028 sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomBorderColor,getStyle().getAttribute(style.ATTRIBUTE_bottomBorderColor)); 1029 sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomBorder,getStyle().getAttribute(style.ATTRIBUTE_bottomBorder)); 1030 sheetPanel.setPropertyValue(Style.ATTRIBUTE_bottomPadding,getStyle().getAttribute(style.ATTRIBUTE_bottomPadding)); 1031 sheetPanel.setPropertyValue(Style.ATTRIBUTE_fill,getStyle().getAttribute(style.ATTRIBUTE_fill)); 1032 sheetPanel.setPropertyValue(Style.ATTRIBUTE_forecolor,getStyle().getAttribute(style.ATTRIBUTE_forecolor)); 1033 sheetPanel.setPropertyValue(Style.ATTRIBUTE_hAlign,getStyle().getAttribute(style.ATTRIBUTE_hAlign)); 1034 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBlankWhenNull,getStyle().getAttribute(style.ATTRIBUTE_isBlankWhenNull)); 1035 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isDefault,getStyle().getAttribute(style.ATTRIBUTE_isDefault)); 1036 sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftBorderColor,getStyle().getAttribute(style.ATTRIBUTE_leftBorderColor)); 1037 sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftBorder,getStyle().getAttribute(style.ATTRIBUTE_leftBorder)); 1038 sheetPanel.setPropertyValue(Style.ATTRIBUTE_leftPadding,getStyle().getAttribute(style.ATTRIBUTE_leftPadding)); 1039 sheetPanel.setPropertyValue(Style.ATTRIBUTE_lineSpacing,getStyle().getAttribute(style.ATTRIBUTE_lineSpacing)); 1040 sheetPanel.setPropertyValue(Style.ATTRIBUTE_mode,getStyle().getAttribute(style.ATTRIBUTE_mode)); 1041 sheetPanel.setPropertyValue(Style.ATTRIBUTE_padding,getStyle().getAttribute(style.ATTRIBUTE_padding)); 1042 sheetPanel.setPropertyValue(Style.ATTRIBUTE_pattern,getStyle().getAttribute(style.ATTRIBUTE_pattern)); 1043 sheetPanel.setPropertyValue(Style.ATTRIBUTE_pen,getStyle().getAttribute(style.ATTRIBUTE_pen)); 1044 sheetPanel.setPropertyValue(Style.ATTRIBUTE_radius,getStyle().getAttribute(style.ATTRIBUTE_radius)); 1045 sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightBorderColor,getStyle().getAttribute(style.ATTRIBUTE_rightBorderColor)); 1046 sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightBorder,getStyle().getAttribute(style.ATTRIBUTE_rightBorder)); 1047 sheetPanel.setPropertyValue(Style.ATTRIBUTE_rightPadding,getStyle().getAttribute(style.ATTRIBUTE_rightPadding)); 1048 sheetPanel.setPropertyValue(Style.ATTRIBUTE_rotation,getStyle().getAttribute(style.ATTRIBUTE_rotation)); 1049 sheetPanel.setPropertyValue(Style.ATTRIBUTE_scaleImage,getStyle().getAttribute(style.ATTRIBUTE_scaleImage)); 1050 sheetPanel.setPropertyValue(Style.ATTRIBUTE_style,getStyle().getAttribute(style.ATTRIBUTE_style)); 1051 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStyledText,getStyle().getAttribute(style.ATTRIBUTE_isStyledText)); 1052 1053 sheetPanel.setPropertyValue("style.font", getIreportFont()); 1054 sheetPanel.setPropertyValue(Style.ATTRIBUTE_topBorderColor,getStyle().getAttribute(style.ATTRIBUTE_topBorderColor)); 1055 sheetPanel.setPropertyValue(Style.ATTRIBUTE_topBorder,getStyle().getAttribute(style.ATTRIBUTE_topBorder)); 1056 sheetPanel.setPropertyValue(Style.ATTRIBUTE_topPadding,getStyle().getAttribute(style.ATTRIBUTE_topPadding)); 1057 sheetPanel.setPropertyValue(Style.ATTRIBUTE_vAlign,getStyle().getAttribute(style.ATTRIBUTE_vAlign)); 1058 1059 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isBold,getStyle().getAttribute(style.ATTRIBUTE_isBold)); 1060 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isUnderline,getStyle().getAttribute(style.ATTRIBUTE_isUnderline)); 1061 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isItalic,getStyle().getAttribute(style.ATTRIBUTE_isItalic)); 1062 sheetPanel.setPropertyValue(Style.ATTRIBUTE_isStrikeThrough,getStyle().getAttribute(style.ATTRIBUTE_isStrikeThrough)); 1063 setInit(false); 1064 1065 } 1066 1067 1072 public void setStyle(Style myStyle) { 1073 1074 Style copyStyle = new Style( myStyle ); 1075 copyStyle.setName(myStyle.getName()); 1076 this.setMasterStyle(copyStyle); 1077 1078 if (myStyle.getAttributeBoolean(myStyle.ATTRIBUTE_isDefault, false)) 1079 { 1080 this.getMasterStyle().getAttributes().put( myStyle.ATTRIBUTE_isDefault, new Boolean (true) ); 1081 } 1082 1083 setStyle(getMasterStyle(), false); 1084 1085 this.setEditingStyle(myStyle); 1086 1087 updateParentStylesList(); 1088 1089 setInit(true); 1090 1091 ((DefaultListModel )jConditionsList.getModel()).removeAllElements(); 1092 ((DefaultListModel )jConditionsList.getModel()).addElement("Default"); 1093 1094 1095 for (int i=0; i<getMasterStyle().getConditionedStyles().size(); ++i) 1096 { 1097 ((DefaultListModel )jConditionsList.getModel()).addElement( 1098 getMasterStyle().getConditionedStyles().elementAt(i) ); 1099 } 1100 1101 this.jConditionsList.setSelectedIndex(0); 1102 1103 setInit(false); 1104 } 1105 1106 public void updateParentStylesList() 1107 { 1108 if (it.businesslogic.ireport.gui.MainFrame.getMainInstance().getActiveReportFrame() != null) 1110 { 1111 currentReport = it.businesslogic.ireport.gui.MainFrame.getMainInstance().getActiveReportFrame().getReport(); 1112 Enumeration enum_styles = currentReport.getStyles().elements(); 1113 1114 1115 1116 Vector tags = new Vector (); 1117 while (enum_styles.hasMoreElements()) 1118 { 1119 Style s = (Style)enum_styles.nextElement(); 1120 if (s != this.getMasterStyle() && !s.getName().equals( this.getMasterStyle().getName() ) ) 1121 { 1122 tags.add(s); } 1124 } 1125 ComboBoxSheetProperty sp = (ComboBoxSheetProperty)getSheetPanel().getSheetProperty(Style.ATTRIBUTE_style); 1126 sp.updateValues(tags,true); 1127 } 1128 } 1129 1130 1135 private void setStyle(Style myStyle, boolean conditionalStyle) 1136 { 1137 this.style = myStyle; 1138 1139 ((SheetProperty)sheetPanel.getSheetProperty(Style.ATTRIBUTE_name)).setReadOnly(conditionalStyle); 1140 ((SheetProperty)sheetPanel.getSheetProperty(Style.ATTRIBUTE_isDefault)).setReadOnly(conditionalStyle); 1141 ((SheetProperty)sheetPanel.getSheetProperty(Style.ATTRIBUTE_style)).setReadOnly(conditionalStyle); 1142 1143 setIreportFont(new IReportFont()); 1144 1145 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_isBold) != null) 1146 getIreportFont().setBold( myStyle.getAttributeBoolean( myStyle.ATTRIBUTE_isBold, false)); 1147 1148 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_fontName) != null) 1149 getIreportFont().setFontName( myStyle.getAttributeString( myStyle.ATTRIBUTE_fontName, getIreportFont().getFontName())); 1150 1151 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_fontSize) != null) 1152 getIreportFont().setFontSize( myStyle.getAttributeInteger( myStyle.ATTRIBUTE_fontSize, getIreportFont().getFontSize())); 1153 1154 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_isItalic) != null) 1155 getIreportFont().setItalic( myStyle.getAttributeBoolean( myStyle.ATTRIBUTE_isItalic, false)); 1156 1157 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_isPdfEmbedded) != null) 1158 getIreportFont().setPdfEmbedded( myStyle.getAttributeBoolean( myStyle.ATTRIBUTE_isPdfEmbedded, false)); 1159 1160 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_pdfEncoding) != null) 1161 getIreportFont().setPdfEncoding( myStyle.getAttributeString( myStyle.ATTRIBUTE_pdfEncoding, getIreportFont().getPdfEncoding())); 1162 1163 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_isStrikeThrough) != null) 1164 getIreportFont().setStrikeTrought( myStyle.getAttributeBoolean( myStyle.ATTRIBUTE_isStrikeThrough, false)); 1165 1166 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_pdfFontName) != null) 1168 getIreportFont().setPDFFontName( myStyle.getAttributeString( myStyle.ATTRIBUTE_pdfFontName, getIreportFont().getPDFFontName())); 1169 1170 if (myStyle.getAttributes().get( myStyle.ATTRIBUTE_isUnderline) != null) 1171 getIreportFont().setUnderline( myStyle.getAttributeBoolean( myStyle.ATTRIBUTE_isUnderline, false)); 1172 1173 updateParentStylesList(); 1174 updateStyleValues(); 1175 1176 1177 panelSample.setStyle(myStyle); 1178 } 1179 1180 public IReportFont getIreportFont() { 1181 if (ireportFont == null) ireportFont = new IReportFont(); 1182 return ireportFont; 1183 } 1184 1185 public void setIreportFont(IReportFont ireportFont) { 1186 this.ireportFont = ireportFont; 1187 } 1188 1189 private Style getMasterStyle() { 1190 return masterStyle; 1191 } 1192 1193 private void setMasterStyle(Style masterStyle) { 1194 this.masterStyle = masterStyle; 1195 } 1196 1197 1201 private void saveCurrentStyle() 1202 { 1203 Vector properties = this.sheetPanel.getProperties(); 1206 1207 if (getStyle() instanceof ConditionedStyle) 1208 { 1209 String condition = ((ConditionedStyle)getStyle()).getCondition(); 1210 getStyle().getAttributes().clear(); 1211 ((ConditionedStyle)getStyle()).setCondition(condition); 1212 } 1213 else 1214 { 1215 getStyle().getAttributes().clear(); 1216 } 1217 1218 for (int i=0; i<properties.size(); ++i) 1219 { 1220 SheetProperty sp = (SheetProperty)properties.get(i); 1221 if ( sp.getValue() != null) 1222 { 1223 getStyle().getAttributes().put( sp.getKeyName(), sp.getValue()); 1224 } 1226 } 1227 1228 if ( getStyle().getAttributes().get(getStyle().ATTRIBUTE_style) != null && 1229 !(getStyle().getAttributes().get(getStyle().ATTRIBUTE_style) instanceof Style)) 1230 { 1231 String sname = ""+getStyle().getAttributes().get(getStyle().ATTRIBUTE_style); 1232 if (sname.trim().length() == 0) 1233 { 1234 getStyle().getAttributes().remove(getStyle().ATTRIBUTE_style); 1235 } 1236 else 1237 { 1238 for (int j=0; j<currentReport.getStyles().size(); ++j) 1239 { 1240 Style sparent = (Style)currentReport.getStyles().elementAt(j); 1241 if (sparent.getName().equals( sname )) 1242 { 1243 getStyle().getAttributes().put(getStyle().ATTRIBUTE_style, sparent); 1244 } 1245 } 1246 } 1247 } 1248 1249 if (getStyle().getAttributeBoolean(getStyle().ATTRIBUTE_isDefault, false)) 1250 { 1251 Enumeration enum_s = MainFrame.getMainInstance().getActiveReportFrame().getReport().getStyles().elements(); 1252 while (enum_s.hasMoreElements()) 1253 { 1254 Style tmp_s = (Style)enum_s.nextElement(); 1255 if (tmp_s != getStyle()) 1256 { 1257 tmp_s.getAttributes().remove( getStyle().ATTRIBUTE_isDefault); 1258 } 1259 } 1260 } 1261 1262 if (ireportFont != null) 1263 { 1264 getStyle().getAttributes().put( Style.ATTRIBUTE_fontName, ireportFont.getBeanProperties().get( ireportFont.FONT_NAME) ); 1265 1266 if (ireportFont.getBeanProperties().get( ireportFont.FONT_SIZE) != null) 1267 getStyle().getAttributes().put( Style.ATTRIBUTE_fontSize, new Integer (ireportFont.getFontSize())); 1268 1269 if (ireportFont.getBeanProperties().get( ireportFont.IS_BOLD) != null) 1270 getStyle().getAttributes().put( style.ATTRIBUTE_isBold, new Boolean ( ireportFont.isBold())); 1271 1272 if (ireportFont.getBeanProperties().get( ireportFont.IS_ITALIC) != null) 1273 getStyle().getAttributes().put( style.ATTRIBUTE_isItalic, new Boolean ( ireportFont.isItalic())); 1274 1275 if (ireportFont.getBeanProperties().get( ireportFont.IS_UNDERLINE) != null) 1276 getStyle().getAttributes().put( style.ATTRIBUTE_isUnderline, new Boolean ( ireportFont.isUnderline())); 1277 1278 if (ireportFont.getBeanProperties().get( ireportFont.IS_STRIKETROUGHT) != null) 1279 getStyle().getAttributes().put( style.ATTRIBUTE_isStrikeThrough, new Boolean ( ireportFont.isStrikeTrought())); 1280 1281 if (ireportFont.getBeanProperties().get( ireportFont.IS_PDF_EMBEDDED) != null) 1282 getStyle().getAttributes().put( style.ATTRIBUTE_isPdfEmbedded, new Boolean ( ireportFont.isPdfEmbedded())); 1283 1284 if (ireportFont.getBeanProperties().get( ireportFont.PDF_FONT_NAME) != null) 1285 getStyle().getAttributes().put( Style.ATTRIBUTE_pdfFontName, ireportFont.getPDFFontName()); 1286 1287 if (ireportFont.getBeanProperties().get( ireportFont.PDF_ENCODING) != null) 1288 getStyle().getAttributes().put( Style.ATTRIBUTE_pdfEncoding, ireportFont.getPdfEncoding()); 1289 1290 } 1291 1301 } 1302 1303 public boolean isInit() { 1304 return init; 1305 } 1306 1307 public void setInit(boolean init) { 1308 this.init = init; 1309 } 1310 1311 public Style getEditingStyle() { 1312 return editingStyle; 1313 } 1314 1315 public void setEditingStyle(Style editingStyle) { 1316 this.editingStyle = editingStyle; 1317 } 1318 1319 public boolean isLibraryStyle() { 1320 return libraryStyle; 1321 } 1322 1323 public void setLibraryStyle(boolean libraryStyle) { 1324 this.libraryStyle = libraryStyle; 1325 } 1326 public void applyI18n(){ 1327 jButtonAddCondition.setText(I18n.getString("styleDialog.buttonAddCondition","Add")); 1329 jButtonCancel.setText(I18n.getString("styleDialog.buttonCancel","Cancel")); 1330 jButtonDownCondition.setText(I18n.getString("styleDialog.buttonDownCondition","Down")); 1331 jButtonModifyCondition.setText(I18n.getString("styleDialog.buttonModifyCondition","Modify")); 1332 jButtonOK.setText(I18n.getString("styleDialog.buttonOK","OK")); 1333 jButtonRemoveCondition.setText(I18n.getString("styleDialog.buttonRemoveCondition","Remove")); 1334 jButtonUpCondition.setText(I18n.getString("styleDialog.buttonUpCondition","up")); 1335 jLabelSample.setText(I18n.getString("styleDialog.labelSample","Sample")); 1336 jLabelStyleConditions.setText(I18n.getString("styleDialog.labelStyleConditions","Style conditions")); 1337 } 1339} 1340 | Popular Tags |