View Javadoc
1 package net.sourceforge.pmd.swingui; 2 3 import net.sourceforge.pmd.AbstractRule; 4 import net.sourceforge.pmd.PMDException; 5 import net.sourceforge.pmd.Rule; 6 import net.sourceforge.pmd.RuleSet; 7 import net.sourceforge.pmd.swingui.event.ListenerList; 8 import net.sourceforge.pmd.swingui.event.RulesEditingEvent; 9 import net.sourceforge.pmd.swingui.event.RulesEditingEventListener; 10 11 import javax.swing.BorderFactory; 12 import javax.swing.Icon; 13 import javax.swing.JCheckBoxMenuItem; 14 import javax.swing.JMenuItem; 15 import javax.swing.JPopupMenu; 16 import javax.swing.JSeparator; 17 import javax.swing.JTree; 18 import javax.swing.SwingUtilities; 19 import javax.swing.UIManager; 20 import javax.swing.border.EtchedBorder; 21 import javax.swing.tree.DefaultTreeCellEditor; 22 import javax.swing.tree.DefaultTreeCellRenderer; 23 import javax.swing.tree.DefaultTreeModel; 24 import javax.swing.tree.TreePath; 25 import java.awt.Color; 26 import java.awt.Component; 27 import java.awt.Font; 28 import java.awt.Graphics; 29 import java.awt.Point; 30 import java.awt.event.ActionEvent; 31 import java.awt.event.ActionListener; 32 import java.awt.event.MouseAdapter; 33 import java.awt.event.MouseEvent; 34 import java.io.ByteArrayOutputStream; 35 import java.io.File; 36 import java.io.FileFilter; 37 import java.io.FileInputStream; 38 import java.io.FileNotFoundException; 39 import java.io.IOException; 40 import java.text.MessageFormat; 41 import java.util.EventObject; 42 43 /*** 44 * 45 * @author Donald A. Leckie 46 * @since August 29, 2002 47 * @version $Revision: 1.26 $, $Date: 2003/05/28 18:08:35 $ 48 */ 49 class RulesTree extends JTree implements Constants { 50 51 private Color m_background; 52 private boolean m_disablePopupMenu; 53 private boolean m_disableEditing; 54 55 // Constants 56 private final String UNTITLED = "Untitled"; 57 58 protected RulesTree() throws PMDException { 59 super(RulesTreeModel.get()); 60 61 setRootVisible(true); 62 setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 63 setCellRenderer(new TreeNodeRenderer()); 64 setCellEditor(new TreeCellEditor()); 65 m_background = UIManager.getColor("pmdTreeBackground"); 66 expandNode(getRootNode()); 67 TreePath treePath = new TreePath(getRootNode().getPath()); 68 setSelectionPath(treePath); 69 setBackground(m_background); 70 addMouseListener(new RulesTreeMouseListener()); 71 ListenerList.addListener((RulesEditingEventListener) new RulesEditingEventHandler()); 72 } 73 74 /*** 75 ****************************************************************************** 76 * 77 * @return 78 */ 79 protected RulesTreeNode getRootNode() { 80 return (RulesTreeNode) ((RulesTreeModel) getModel()).getRoot(); 81 } 82 83 /*** 84 ****************************************************************************** 85 * 86 */ 87 public void updateUI() { 88 super.updateUI(); 89 setBackground(m_background); 90 } 91 92 /*** 93 *************************************************************************** 94 * 95 * @param node 96 */ 97 protected void expandNode(RulesTreeNode node) { 98 TreePath treePath = new TreePath(node.getPath()); 99 100 expandPath(treePath); 101 } 102 103 /*** 104 *************************************************************************** 105 * 106 * @return 107 */ 108 protected RulesTreeNode getSelectedNode() { 109 TreePath treePath = getSelectionPath(); 110 111 return (treePath == null) ? null : (RulesTreeNode) treePath.getLastPathComponent(); 112 } 113 114 /*** 115 *************************************************************************** 116 * 117 * @param node 118 * 119 * @return 120 */ 121 protected boolean isExpanded(RulesTreeNode node) { 122 TreePath treePath = new TreePath(node.getPath()); 123 124 return isExpanded(treePath); 125 } 126 127 /*** 128 ***************************************************************************** 129 * 130 * @param setting 131 */ 132 protected void setDisablePopupMenu(boolean setting) { 133 m_disablePopupMenu = setting; 134 } 135 136 /*** 137 ***************************************************************************** 138 * 139 * @param setting 140 */ 141 protected void setDisableEditing(boolean setting) { 142 m_disableEditing = setting; 143 } 144 145 /*** 146 ******************************************************************************* 147 ******************************************************************************* 148 ******************************************************************************* 149 */ 150 private class RulesTreeMouseListener extends MouseAdapter { 151 152 private JMenuItem m_addRuleSetMenuItem; 153 private JMenuItem m_removeRuleSetMenuItem; 154 private JMenuItem m_addRuleMenuItem; 155 private JMenuItem m_removeRuleMenuItem; 156 private JMenuItem m_addPropertyMenuItem; 157 private JMenuItem m_removePropertyMenuItem; 158 private JMenuItem m_includeMenuItem; 159 160 /*** 161 *********************************************************************** 162 * 163 * @param event 164 */ 165 public void mouseReleased(MouseEvent event) { 166 if (event.isPopupTrigger()) { 167 RulesTree rulesTree; 168 Point location; 169 TreePath treePath; 170 RulesTreeNode treeNode; 171 JPopupMenu popupMenu; 172 173 rulesTree = RulesTree.this; 174 location = event.getPoint(); 175 treePath = rulesTree.getPathForLocation(location.x, location.y); 176 rulesTree.setSelectionPath(treePath); 177 treeNode = (RulesTreeNode) treePath.getLastPathComponent(); 178 popupMenu = null; 179 180 if (treeNode.isRoot()) { 181 popupMenu = createRootPopupMenu(); 182 } else if (treeNode.isRuleSet()) { 183 popupMenu = createRuleSetPopupMenu(); 184 } else if (treeNode.isRule()) { 185 popupMenu = createRulePopupMenu(); 186 } else if (treeNode.isProperty()) { 187 popupMenu = createPropertyPopupMenu(); 188 } 189 190 if (popupMenu != null) { 191 popupMenu.show(rulesTree, location.x, location.y); 192 } 193 } 194 } 195 196 /*** 197 *********************************************************************** 198 * 199 * @return 200 */ 201 private JPopupMenu createRootPopupMenu() { 202 JPopupMenu popupMenu = createPopupMenu(false); 203 204 m_addRuleSetMenuItem.setEnabled(true); 205 m_removeRuleSetMenuItem.setEnabled(false); 206 m_addRuleMenuItem.setEnabled(false); 207 m_removeRuleMenuItem.setEnabled(false); 208 m_addPropertyMenuItem.setEnabled(false); 209 m_removePropertyMenuItem.setEnabled(false); 210 211 return popupMenu; 212 } 213 214 /*** 215 *********************************************************************** 216 * 217 * @return 218 */ 219 private JPopupMenu createRuleSetPopupMenu() { 220 JPopupMenu popupMenu = createPopupMenu(true); 221 222 m_addRuleSetMenuItem.setEnabled(false); 223 m_removeRuleSetMenuItem.setEnabled(true); 224 m_addRuleMenuItem.setEnabled(true); 225 m_removeRuleMenuItem.setEnabled(false); 226 m_addPropertyMenuItem.setEnabled(false); 227 m_removePropertyMenuItem.setEnabled(false); 228 229 return popupMenu; 230 } 231 232 /*** 233 *********************************************************************** 234 * 235 * @return 236 */ 237 private JPopupMenu createRulePopupMenu() { 238 JPopupMenu popupMenu = createPopupMenu(true); 239 240 m_addRuleSetMenuItem.setEnabled(false); 241 m_removeRuleSetMenuItem.setEnabled(false); 242 m_addRuleMenuItem.setEnabled(false); 243 m_removeRuleMenuItem.setEnabled(true); 244 m_addPropertyMenuItem.setEnabled(true); 245 m_removePropertyMenuItem.setEnabled(false); 246 247 return popupMenu; 248 } 249 250 /*** 251 *********************************************************************** 252 * 253 * @return 254 */ 255 private JPopupMenu createPropertyPopupMenu() { 256 JPopupMenu popupMenu = createPopupMenu(false); 257 258 m_addRuleSetMenuItem.setEnabled(false); 259 m_removeRuleSetMenuItem.setEnabled(false); 260 m_addRuleMenuItem.setEnabled(false); 261 m_removeRuleMenuItem.setEnabled(false); 262 m_addPropertyMenuItem.setEnabled(false); 263 m_removePropertyMenuItem.setEnabled(true); 264 265 return popupMenu; 266 } 267 268 /*** 269 *********************************************************************** 270 * 271 * @return 272 */ 273 private JPopupMenu createPopupMenu(boolean addInclude) { 274 JPopupMenu popupMenu = new JPopupMenu(); 275 276 m_addRuleSetMenuItem = new JMenuItem("Add Rule Set"); 277 m_addRuleSetMenuItem.addActionListener(new AddRuleSetActionListener()); 278 popupMenu.add(m_addRuleSetMenuItem); 279 280 m_removeRuleSetMenuItem = new JMenuItem("Remove Rule Set"); 281 m_removeRuleSetMenuItem.addActionListener(new RemoveRuleSetActionListener()); 282 popupMenu.add(m_removeRuleSetMenuItem); 283 284 popupMenu.add(new JSeparator()); 285 286 m_addRuleMenuItem = new JMenuItem("Add Rule"); 287 m_addRuleMenuItem.addActionListener(new AddRuleActionListener()); 288 popupMenu.add(m_addRuleMenuItem); 289 290 m_removeRuleMenuItem = new JMenuItem("Remove Rule"); 291 m_removeRuleMenuItem.addActionListener(new RemoveRuleActionListener()); 292 popupMenu.add(m_removeRuleMenuItem); 293 294 popupMenu.add(new JSeparator()); 295 296 m_addPropertyMenuItem = new JMenuItem("Add Rule Property"); 297 m_addPropertyMenuItem.addActionListener(new AddRulePropertyActionListener()); 298 popupMenu.add(m_addPropertyMenuItem); 299 300 m_removePropertyMenuItem = new JMenuItem("Remove Rule Property"); 301 m_removePropertyMenuItem.addActionListener(new RemoveRulePropertyActionListener()); 302 popupMenu.add(m_removePropertyMenuItem); 303 304 if (addInclude) { 305 popupMenu.add(new JSeparator()); 306 307 m_includeMenuItem = new JCheckBoxMenuItem("Include"); 308 m_includeMenuItem.addActionListener(new IncludeActionListener()); 309 m_includeMenuItem.setSelected(RulesTree.this.getSelectedNode().include()); 310 popupMenu.add(m_includeMenuItem); 311 } 312 313 return popupMenu; 314 } 315 } 316 317 /*** 318 ******************************************************************************* 319 ******************************************************************************* 320 ******************************************************************************* 321 */ 322 private class IncludeActionListener implements ActionListener { 323 324 public void actionPerformed(ActionEvent event) { 325 JCheckBoxMenuItem includeMenuItem = (JCheckBoxMenuItem) event.getSource(); 326 RulesTree.this.getSelectedNode().setInclude(includeMenuItem.isSelected()); 327 RulesTree.this.updateUI(); 328 RulesTree.this.repaint(); 329 } 330 } 331 332 /*** 333 ******************************************************************************* 334 ******************************************************************************* 335 ******************************************************************************* 336 */ 337 private class AddRuleSetActionListener implements ActionListener { 338 339 public void actionPerformed(ActionEvent event) { 340 RuleSet ruleSet = new RuleSet(); 341 String ruleSetName = UNTITLED; 342 int counter = 0; 343 RulesTree rulesTree = RulesTree.this; 344 RulesTreeNode rootNode = rulesTree.getSelectedNode(); 345 346 while (rootNode.getChildNode(ruleSetName) != null) { 347 counter++; 348 ruleSetName = UNTITLED + "-" + counter; 349 } 350 351 ruleSet.setName(ruleSetName); 352 353 RulesTreeNode ruleSetNode = new RulesTreeNode(ruleSet); 354 DefaultTreeModel treeModel = (DefaultTreeModel) RulesTree.this.getModel(); 355 356 rootNode.add(ruleSetNode); 357 treeModel.nodeStructureChanged(rootNode); 358 359 if (rulesTree.isExpanded(ruleSetNode) == false) { 360 rulesTree.expandNode(ruleSetNode); 361 } 362 363 rootNode.sortChildren(); 364 } 365 } 366 367 /*** 368 ******************************************************************************* 369 ******************************************************************************* 370 ******************************************************************************* 371 */ 372 private class RemoveRuleSetActionListener implements ActionListener { 373 374 public void actionPerformed(ActionEvent event) { 375 RulesTreeNode ruleSetNode = RulesTree.this.getSelectedNode(); 376 377 if (ruleSetNode != null) { 378 String ruleSetName = ruleSetNode.getName(); 379 String template = "Do you really want to remove the rule set \"{0}\"?\nThe remove cannot be undone."; 380 String[] args = {ruleSetName}; 381 String message = MessageFormat.format(template, args); 382 383 if (MessageDialog.answerIsYes(PMDViewer.getViewer(), message)) { 384 DefaultTreeModel treeModel = (DefaultTreeModel) RulesTree.this.getModel(); 385 treeModel.removeNodeFromParent(ruleSetNode); 386 } 387 } 388 } 389 } 390 391 /*** 392 ******************************************************************************* 393 ******************************************************************************* 394 ******************************************************************************* 395 */ 396 private class AddRuleActionListener implements ActionListener { 397 398 /*** 399 *************************************************************************** 400 * 401 * @param event 402 */ 403 public void actionPerformed(ActionEvent event) { 404 Rule rule = null; 405 406 try { 407 rule = getNewRuleFromUser(); 408 } catch (PMDException pmdException) { 409 String message = pmdException.getMessage(); 410 Exception exception = pmdException.getReason(); 411 MessageDialog.show(PMDViewer.getViewer(), message, exception); 412 413 return; 414 } 415 416 if (rule != null) { 417 String className = rule.getClass().getName(); 418 int index = className.lastIndexOf('.') + 1; 419 String baseRuleName = className.substring(index); 420 String ruleName = baseRuleName; 421 int counter = 0; 422 RulesTree rulesTree = RulesTree.this; 423 RulesTreeNode ruleSetNode = rulesTree.getSelectedNode(); 424 425 while (ruleSetNode.getChildNode(ruleName) != null) { 426 counter++; 427 ruleName = baseRuleName + "-" + counter; 428 } 429 430 rule.setName(ruleName); 431 432 RulesTreeNode ruleNode = new RulesTreeNode(ruleSetNode, rule); 433 DefaultTreeModel treeModel = (DefaultTreeModel) rulesTree.getModel(); 434 435 ruleSetNode.add(ruleNode); 436 treeModel.nodeStructureChanged(ruleSetNode); 437 438 if (rulesTree.isExpanded(ruleSetNode) == false) { 439 rulesTree.expandNode(ruleSetNode); 440 } 441 442 ruleSetNode.sortChildren(); 443 TreePath treePath = new TreePath(ruleNode.getPath()); 444 rulesTree.setSelectionPath(treePath); 445 } 446 } 447 448 /*** 449 *************************************************************************** 450 * 451 * @return 452 */ 453 private Rule getNewRuleFromUser() throws PMDException { 454 RulesClassSelectDialog dialog = new RulesClassSelectDialog(PMDViewer.getViewer()); 455 dialog.show(); 456 457 if (dialog.selectWasPressed()) { 458 File selectedFile = dialog.getSelectedClassFile(); 459 RuleClassLoader classLoader = new RuleClassLoader(); 460 Class clazz = classLoader.loadClass(selectedFile); 461 462 try { 463 Object object = clazz.newInstance(); 464 465 if (object instanceof AbstractRule) { 466 return (Rule) object; 467 } 468 469 String abstractRuleClassName = AbstractRule.class.getName(); 470 String template = "The selected class \"{0}\" must subclass the abstract rule class \"{1}\"."; 471 String[] args = {clazz.getName(), abstractRuleClassName}; 472 String message = MessageFormat.format(template, args); 473 MessageDialog.show(PMDViewer.getViewer(), message); 474 } catch (InstantiationException exception) { 475 String template = "Could not instantiate class \"{0}\"."; 476 String[] args = {clazz.getName()}; 477 String message = MessageFormat.format(template, args); 478 MessageDialog.show(PMDViewer.getViewer(), message, exception); 479 } catch (IllegalAccessException exception) { 480 String template = "Encountered illegal access while instantiating class \"{0}\"."; 481 String[] args = {clazz.getName()}; 482 String message = MessageFormat.format(template, args); 483 MessageDialog.show(PMDViewer.getViewer(), message, exception); 484 } 485 } 486 487 return null; 488 } 489 } 490 491 /*** 492 ******************************************************************************* 493 ******************************************************************************* 494 ******************************************************************************* 495 */ 496 private class RulesFileFilter implements FileFilter { 497 /*** 498 *************************************************************************** 499 * 500 * @param file 501 * 502 * @return 503 */ 504 public boolean accept(File file) { 505 if (file.isDirectory()) { 506 return true; 507 } 508 509 return file.getName().endsWith(".class"); 510 } 511 512 /*** 513 ************************************************************************** 514 * 515 * @return 516 */ 517 public String getDescription() { 518 return "Rule Class Files"; 519 } 520 } 521 522 /*** 523 ******************************************************************************* 524 ******************************************************************************* 525 ******************************************************************************* 526 */ 527 private class RuleClassLoader extends ClassLoader { 528 529 /*** 530 ************************************************************************** 531 * 532 */ 533 private RuleClassLoader() { 534 super(); 535 } 536 537 /*** 538 ************************************************************************** 539 * 540 */ 541 private Class loadClass(File file) { 542 FileInputStream inputStream = null; 543 Class clazz = null; 544 545 try { 546 inputStream = new FileInputStream(file); 547 clazz = null; 548 549 if (inputStream != null) { 550 final int size = 10000; 551 int byteCount = 0; 552 byte[] buffer = new byte[size]; 553 ByteArrayOutputStream byteArrayOutputStream; 554 555 byteArrayOutputStream = new ByteArrayOutputStream(size); 556 557 try { 558 while ((byteCount = inputStream.read(buffer)) > 0) { 559 byteArrayOutputStream.write(buffer, 0, byteCount); 560 } 561 } catch (IOException exception) { 562 return null; 563 } 564 565 buffer = byteArrayOutputStream.toByteArray(); 566 clazz = super.defineClass(null, buffer, 0, buffer.length); 567 568 if (clazz != null) { 569 resolveClass(clazz); 570 } 571 } 572 } catch (FileNotFoundException exception) { 573 clazz = null; 574 } finally { 575 if (inputStream != null) { 576 try { 577 inputStream.close(); 578 } catch (IOException exception) { 579 inputStream = null; 580 } 581 } 582 } 583 584 return clazz; 585 } 586 } 587 588 /*** 589 ******************************************************************************* 590 ******************************************************************************* 591 ******************************************************************************* 592 */ 593 private class RemoveRuleActionListener implements ActionListener { 594 595 public void actionPerformed(ActionEvent event) { 596 RulesTreeNode ruleNode = RulesTree.this.getSelectedNode(); 597 String ruleName = ruleNode.getName(); 598 String template = "Do you really want to remove the rule \"{0}\"?\nThe remove cannot be undone."; 599 String[] args = {ruleName}; 600 String message = MessageFormat.format(template, args); 601 602 if (MessageDialog.answerIsYes(PMDViewer.getViewer(), message)) { 603 DefaultTreeModel treeModel = (DefaultTreeModel) RulesTree.this.getModel(); 604 treeModel.removeNodeFromParent(ruleNode); 605 } 606 } 607 } 608 609 /*** 610 ******************************************************************************* 611 ******************************************************************************* 612 ******************************************************************************* 613 */ 614 private class AddRulePropertyActionListener implements ActionListener { 615 616 public void actionPerformed(ActionEvent event) { 617 String propertyName = UNTITLED; 618 int counter = 0; 619 RulesTree rulesTree = RulesTree.this; 620 RulesTreeNode ruleNode = rulesTree.getSelectedNode(); 621 622 while (ruleNode.getChildNode(propertyName) != null) { 623 counter++; 624 propertyName = UNTITLED + "-" + counter; 625 } 626 627 RulesTreeNode propertyNode = new RulesTreeNode(ruleNode, propertyName, "", STRING); 628 DefaultTreeModel treeModel = (DefaultTreeModel) rulesTree.getModel(); 629 630 ruleNode.add(propertyNode); 631 treeModel.nodeStructureChanged(ruleNode); 632 633 if (rulesTree.isExpanded(ruleNode) == false) { 634 rulesTree.expandNode(ruleNode); 635 } 636 637 ruleNode.sortChildren(); 638 } 639 } 640 641 /*** 642 ******************************************************************************* 643 ******************************************************************************* 644 ******************************************************************************* 645 */ 646 private class RemoveRulePropertyActionListener implements ActionListener { 647 648 public void actionPerformed(ActionEvent event) { 649 RulesTreeNode propertyNode = RulesTree.this.getSelectedNode(); 650 String propertyName = propertyNode.getName(); 651 String template = "Do you really want to remove the property \"{0}\"?\nThe remove cannot be undone."; 652 String[] args = {propertyName}; 653 String message = MessageFormat.format(template, args); 654 655 if (MessageDialog.answerIsYes(PMDViewer.getViewer(), message)) { 656 DefaultTreeModel treeModel = (DefaultTreeModel) RulesTree.this.getModel(); 657 treeModel.removeNodeFromParent(propertyNode); 658 } 659 } 660 } 661 662 /*** 663 ******************************************************************************* 664 ******************************************************************************* 665 ******************************************************************************* 666 */ 667 private class TreeCellEditor extends DefaultTreeCellEditor { 668 669 /*** 670 *************************************************************************** 671 * 672 */ 673 private TreeCellEditor() { 674 super(RulesTree.this, (DefaultTreeCellRenderer) RulesTree.this.getCellRenderer()); 675 } 676 677 /*** 678 *************************************************************************** 679 * 680 * @return 681 */ 682 public boolean isCellEditable(EventObject event) { 683 return false; 684 } 685 } 686 687 /*** 688 ******************************************************************************** 689 ******************************************************************************** 690 ******************************************************************************** 691 */ 692 private class TreeNodeRenderer extends DefaultTreeCellRenderer { 693 694 private Icon m_defaultClosedIcon; 695 private Icon m_defaultLeafIcon; 696 private Icon m_defaultOpenIcon; 697 private Icon m_documentIcon; 698 private Font m_plainFont; 699 private Font m_italicFont; 700 701 /*** 702 *************************************************************************** 703 * 704 */ 705 protected TreeNodeRenderer() { 706 super(); 707 708 Font font; 709 710 m_defaultClosedIcon = getDefaultClosedIcon(); 711 m_defaultLeafIcon = getDefaultLeafIcon(); 712 m_defaultOpenIcon = getDefaultOpenIcon(); 713 m_documentIcon = UIManager.getIcon("document"); 714 font = RulesTree.this.getFont(); 715 m_plainFont = new Font(font.getName(), Font.PLAIN, font.getSize()); 716 m_italicFont = new Font(font.getName(), Font.ITALIC, font.getSize()); 717 setBackgroundNonSelectionColor(UIManager.getColor("pmdTreeBackground")); 718 setBackgroundSelectionColor(Color.yellow); 719 } 720 721 /*** 722 ************************************************************************** 723 * 724 * @param tree 725 * @param object 726 * @param isSelected 727 * @param isExpanded 728 * @param isLeaf 729 * @param row 730 * @param hasFocus 731 * 732 * @return 733 */ 734 public Component getTreeCellRendererComponent(JTree tree, Object object, boolean isSelected, boolean isExpanded, boolean isLeaf, int row, boolean hasFocus) { 735 RulesTreeNode treeNode = (RulesTreeNode) object; 736 737 if (treeNode.isProperty()) { 738 setClosedIcon(m_defaultClosedIcon); 739 setLeafIcon(m_documentIcon); 740 setOpenIcon(m_defaultOpenIcon); 741 } else { 742 setClosedIcon(m_defaultClosedIcon); 743 setLeafIcon(m_defaultClosedIcon); 744 setOpenIcon(m_defaultOpenIcon); 745 } 746 747 if (treeNode.include() && treeNode.includeAncestor()) { 748 setTextNonSelectionColor(Color.blue); 749 setTextSelectionColor(Color.blue); 750 setFont(m_plainFont); 751 } else { 752 setTextNonSelectionColor(Color.black); 753 setTextSelectionColor(Color.black); 754 setFont(m_italicFont); 755 756 } 757 758 this.updateUI(); 759 760 return super.getTreeCellRendererComponent(tree, object, isSelected, isExpanded, isLeaf, row, hasFocus); 761 } 762 763 /*** 764 ************************************************************************** 765 * 766 * @param graphics 767 */ 768 public void paint(Graphics graphics) { 769 int x = getX(); 770 int y = getY(); 771 int width = getWidth(); 772 int height = getHeight(); 773 graphics.clearRect(x, y, width, height); 774 super.paint(graphics); 775 } 776 } 777 778 /*** 779 ******************************************************************************* 780 ******************************************************************************* 781 ******************************************************************************* 782 */ 783 private class RulesEditingEventHandler implements RulesEditingEventListener { 784 785 /*** 786 *************************************************************************** 787 * 788 * @param event 789 */ 790 public void saveData(RulesEditingEvent event) { 791 SwingUtilities.invokeLater(new UpdateUI()); 792 } 793 794 /*** 795 *************************************************************************** 796 * 797 * @param event 798 */ 799 public void loadData(RulesEditingEvent event) { 800 } 801 } 802 803 /*** 804 ******************************************************************************* 805 ******************************************************************************* 806 ******************************************************************************* 807 */ 808 private class UpdateUI implements Runnable { 809 810 /*** 811 *************************************************************************** 812 * 813 */ 814 public void run() { 815 RulesTree.this.updateUI(); 816 } 817 } 818 }

This page was automatically generated by Maven