1 19 20 package org.netbeans.modules.form; 21 22 import java.util.*; 23 import javax.swing.undo.*; 24 25 import org.openide.nodes.Node; 26 27 import org.netbeans.modules.form.layoutsupport.*; 28 import org.openide.ErrorManager; 29 30 36 37 public class FormModelEvent extends EventObject 38 { 39 public static final int FORM_LOADED = 1; 41 public static final int FORM_TO_BE_SAVED = 2; 42 public static final int FORM_TO_BE_CLOSED = 3; 43 public static final int CONTAINER_LAYOUT_EXCHANGED = 4; 44 public static final int CONTAINER_LAYOUT_CHANGED = 5; 45 public static final int COMPONENT_LAYOUT_CHANGED = 6; 46 public static final int COMPONENT_ADDED = 7; 47 public static final int COMPONENT_REMOVED = 8; 48 public static final int COMPONENTS_REORDERED = 9; 49 public static final int COMPONENT_PROPERTY_CHANGED = 10; 50 public static final int SYNTHETIC_PROPERTY_CHANGED = 11; 51 public static final int EVENT_HANDLER_ADDED = 12; 52 public static final int EVENT_HANDLER_REMOVED = 13; 53 public static final int EVENT_HANDLER_RENAMED = 14; 54 public static final int OTHER_CHANGE = 15; 55 56 private int changeType; 58 59 private boolean createdDeleted; 60 private RADComponent component; 61 private ComponentContainer container; 62 private LayoutConstraints constraints; 63 private int componentIndex = -1; 64 private int[] reordering; 65 private String propertyName; 66 private Object oldPropertyValue; 67 private Object newPropertyValue; 68 private Event componentEvent; 69 70 private UndoableEdit undoableEdit; 71 72 74 private FormModelEvent additionalEvent; 75 private static List interestList; 77 79 FormModelEvent(FormModel source, int changeType) { 80 super(source); 81 this.changeType = changeType; 82 informInterestedEvents(this); 83 } 84 85 void setProperty(String propName, Object oldValue, Object newValue) { 86 propertyName = propName; 87 oldPropertyValue = oldValue; 88 newPropertyValue = newValue; 89 } 90 91 void setComponentAndContainer(RADComponent metacomp, 92 ComponentContainer metacont) 93 { 94 component = metacomp; 95 container = metacont != null ? metacont : deriveContainer(metacomp); 96 } 97 98 void setLayout(RADVisualContainer metacont, 99 LayoutSupportDelegate oldLayoutSupp, 100 LayoutSupportDelegate newLayoutSupp) 101 { 102 component = metacont; 103 container = metacont; 104 oldPropertyValue = oldLayoutSupp; 105 newPropertyValue = newLayoutSupp; 106 } 107 108 void setReordering(int[] perm) { 109 reordering = perm; 110 } 111 112 void setAddData(RADComponent metacomp, 113 ComponentContainer metacont, 114 boolean addedNew) 115 { 116 setComponentAndContainer(metacomp, metacont); 117 createdDeleted = addedNew; 118 119 if (component instanceof RADVisualComponent 120 && container instanceof RADVisualContainer) 121 { 122 componentIndex = container.getIndexOf(component); 123 if (componentIndex >= 0) { 124 LayoutSupportManager laysup = 125 ((RADVisualContainer)container).getLayoutSupport(); 126 if (laysup != null) 127 constraints = laysup.getConstraints(componentIndex); 128 } 129 } 130 } 131 132 void setRemoveData(RADComponent metacomp, 133 ComponentContainer metacont, 134 int index, 135 boolean removedFromModel) 136 { 137 component = metacomp; 138 container = metacont; 139 componentIndex = index; 140 createdDeleted = removedFromModel; 141 142 if (metacomp instanceof RADVisualComponent 143 && metacont instanceof RADVisualContainer) 144 { 145 LayoutSupportManager laysup = 146 ((RADVisualContainer)metacont).getLayoutSupport(); 147 constraints = laysup == null ? null : 148 laysup.getStoredConstraints((RADVisualComponent)metacomp); 149 } 150 } 151 152 void setEvent(Event event, String handler, 154 String bodyText, 155 boolean createdNew) 156 { 157 if (event != null) 158 component = event.getComponent(); 159 componentEvent = event; 160 propertyName = handler; 161 newPropertyValue = bodyText; 162 createdDeleted = createdNew; 163 } 164 165 void setEvent(String oldHandlerName, String newHandlerName) { 166 oldPropertyValue = oldHandlerName; 167 propertyName = newHandlerName; 168 newPropertyValue = newHandlerName; 169 } 170 171 void setChangeType(int changeType) { 172 this.changeType = changeType; 173 } 174 175 private static ComponentContainer deriveContainer(RADComponent comp) { 176 if (comp == null) 177 return null; 178 if (comp.getParentComponent() instanceof ComponentContainer) 179 return (ComponentContainer) comp.getParentComponent(); 180 else if (comp.getParentComponent() == null) 181 return comp.getFormModel().getModelContainer(); 182 return null; 183 } 184 185 187 public final FormModel getFormModel() { 188 return (FormModel) getSource(); 189 } 190 191 public final int getChangeType() { 192 return changeType; 193 } 194 195 public final boolean isModifying() { 196 return changeType != FORM_LOADED 197 && changeType != FORM_TO_BE_SAVED 198 && changeType != FORM_TO_BE_CLOSED 199 && (changeType != EVENT_HANDLER_ADDED || componentEvent != null); 200 } 201 202 public final boolean getCreatedDeleted() { 203 return createdDeleted; 204 } 205 206 public final ComponentContainer getContainer() { 207 return container; 208 } 209 210 public final RADComponent getComponent() { 211 return component; 212 } 213 214 public final LayoutConstraints getComponentLayoutConstraints() { 215 return constraints; 216 } 217 218 public final int getComponentIndex() { 219 return componentIndex; 220 } 221 222 public final String getPropertyName() { 223 return propertyName; 224 } 225 226 public final RADProperty getComponentProperty() { 227 return component != null && propertyName != null ? 228 component.getBeanProperty(propertyName) : null; 229 } 230 231 public final Object getOldPropertyValue() { 232 return oldPropertyValue; 233 } 234 235 public final Object getNewPropertyValue() { 236 return newPropertyValue; 237 } 238 239 public final LayoutSupportDelegate getOldLayoutSupport() { 240 return (LayoutSupportDelegate) oldPropertyValue; 241 } 242 243 public final LayoutSupportDelegate getNewLayoutSupport() { 244 return (LayoutSupportDelegate) newPropertyValue; 245 } 246 247 public final int[] getReordering() { 248 return reordering; 249 } 250 251 public final Event getComponentEvent() { 252 return componentEvent; 253 } 254 255 public final String getEventHandler() { 256 return propertyName; 257 } 258 259 public final String getOldEventHandler() { 260 return (String ) oldPropertyValue; 261 } 262 263 public final String getNewEventHandler() { 264 return (String ) newPropertyValue; 265 } 266 267 public final String getNewEventHandlerContent() { 268 return changeType == EVENT_HANDLER_ADDED 269 || changeType == EVENT_HANDLER_REMOVED ? 270 (String ) newPropertyValue : null; 271 } 272 273 public final String getOldEventHandlerContent() { 274 if (changeType == EVENT_HANDLER_ADDED 275 || changeType == EVENT_HANDLER_REMOVED) 276 { 277 if (additionalEvent != null) { 278 if (additionalEvent.changeType == EVENT_HANDLER_REMOVED 279 || additionalEvent.changeType == EVENT_HANDLER_ADDED) 280 { 281 oldPropertyValue = additionalEvent.oldPropertyValue; 282 } 283 additionalEvent = null; 284 } 285 return (String ) oldPropertyValue; 286 } 287 return null; 288 } 289 290 public final void setOldEventHandlerContent(String text) { 291 if (changeType == EVENT_HANDLER_ADDED 292 || changeType == EVENT_HANDLER_REMOVED) 293 oldPropertyValue = text; 294 } 295 296 298 UndoableEdit getUndoableEdit() { 299 if (undoableEdit == null) 300 undoableEdit = new FormUndoableEdit(); 301 return undoableEdit; 302 } 303 304 308 private static void addToInterestList(FormModelEvent ev) { 309 if (interestList == null) 310 interestList = new ArrayList(); 311 else 312 interestList.remove(ev); 313 314 interestList.add(ev); 315 } 316 317 private static void removeFromInterestList(FormModelEvent ev) { 318 if (interestList != null) 319 interestList.remove(ev); 320 } 321 322 private static void informInterestedEvents(FormModelEvent newEvent) { 323 if (interestList != null) 324 for (Iterator it=interestList.iterator(); it.hasNext(); ) 325 ((FormModelEvent)it.next()).newEventCreated(newEvent); 326 } 327 328 private void newEventCreated(FormModelEvent newEvent) { 329 additionalEvent = newEvent; 330 } 331 332 334 private class FormUndoableEdit extends AbstractUndoableEdit { 335 public void undo() throws CannotUndoException { 336 super.undo(); 337 338 boolean undoRedoOn = getFormModel().isUndoRedoRecording(); 340 if (undoRedoOn) 341 getFormModel().setUndoRedoRecording(false); 342 343 switch(changeType) { 344 case CONTAINER_LAYOUT_EXCHANGED: 345 FormModel.t("UNDO: container layout change"); undoContainerLayoutExchange(); 347 break; 348 case CONTAINER_LAYOUT_CHANGED: 349 FormModel.t("UNDO: container layout property change"); undoContainerLayoutChange(); 351 break; 352 case COMPONENT_LAYOUT_CHANGED: 353 FormModel.t("UNDO: component layout constraints change"); undoComponentLayoutChange(); 355 break; 356 case COMPONENTS_REORDERED: 357 FormModel.t("UNDO: components reorder"); undoComponentsReorder(); 359 break; 360 case COMPONENT_ADDED: 361 FormModel.t("UNDO: component addition"); undoComponentAddition(); 363 break; 364 case COMPONENT_REMOVED: 365 FormModel.t("UNDO: component removal"); undoComponentRemoval(); 367 break; 368 case COMPONENT_PROPERTY_CHANGED: 369 FormModel.t("UNDO: component property change"); undoComponentPropertyChange(); 371 break; 372 case SYNTHETIC_PROPERTY_CHANGED: 373 FormModel.t("UNDO: synthetic property change"); undoSyntheticPropertyChange(); 375 break; 376 case EVENT_HANDLER_ADDED: 377 FormModel.t("UNDO: event handler addition"); undoEventHandlerAddition(); 379 break; 380 case EVENT_HANDLER_REMOVED: 381 FormModel.t("UNDO: event handler removal"); undoEventHandlerRemoval(); 383 break; 384 case EVENT_HANDLER_RENAMED: 385 FormModel.t("UNDO: event handler renaming"); undoEventHandlerRenaming(); 387 break; 388 389 default: FormModel.t("UNDO: "+changeType); break; 391 } 392 393 if (undoRedoOn) getFormModel().setUndoRedoRecording(true); 395 } 396 397 public void redo() throws CannotRedoException { 398 super.redo(); 399 400 boolean undoRedoOn = getFormModel().isUndoRedoRecording(); 402 if (undoRedoOn) 403 getFormModel().setUndoRedoRecording(false); 404 405 switch(changeType) { 406 case CONTAINER_LAYOUT_EXCHANGED: 407 FormModel.t("REDO: container layout change"); redoContainerLayoutExchange(); 409 break; 410 case CONTAINER_LAYOUT_CHANGED: 411 FormModel.t("REDO: container layout property change"); redoContainerLayoutChange(); 413 break; 414 case COMPONENT_LAYOUT_CHANGED: 415 FormModel.t("REDO: component layout constraints change"); redoComponentLayoutChange(); 417 break; 418 case COMPONENTS_REORDERED: 419 FormModel.t("REDO: components reorder"); redoComponentsReorder(); 421 break; 422 case COMPONENT_ADDED: 423 FormModel.t("REDO: component addition"); redoComponentAddition(); 425 break; 426 case COMPONENT_REMOVED: 427 FormModel.t("REDO: component removal"); redoComponentRemoval(); 429 break; 430 case COMPONENT_PROPERTY_CHANGED: 431 FormModel.t("REDO: component property change"); redoComponentPropertyChange(); 433 break; 434 case SYNTHETIC_PROPERTY_CHANGED: 435 FormModel.t("REDO: synthetic property change"); redoSyntheticPropertyChange(); 437 break; 438 case EVENT_HANDLER_ADDED: 439 FormModel.t("REDO: event handler addition"); redoEventHandlerAddition(); 441 break; 442 case EVENT_HANDLER_REMOVED: 443 FormModel.t("REDO: event handler removal"); redoEventHandlerRemoval(); 445 break; 446 case EVENT_HANDLER_RENAMED: 447 FormModel.t("REDO: event handler renaming"); redoEventHandlerRenaming(); 449 break; 450 451 default: FormModel.t("REDO: "+changeType); break; 453 } 454 455 if (undoRedoOn) getFormModel().setUndoRedoRecording(true); 457 } 458 459 public String getUndoPresentationName() { 460 return ""; } 462 public String getRedoPresentationName() { 463 return ""; } 465 466 468 private void undoContainerLayoutExchange() { 469 try { 470 LayoutSupportDelegate layoutDelegate = getOldLayoutSupport(); 471 if (layoutDelegate != null) { 472 getFormModel().setContainerLayoutImpl( 473 (RADVisualContainer)getContainer(), 474 layoutDelegate, 475 null); 476 } 477 else { 478 getFormModel().setNaturalContainerLayoutImpl( 479 (RADVisualContainer)getContainer()); 480 } 481 } 482 catch (Exception ex) { 483 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 484 } 485 } 486 487 private void redoContainerLayoutExchange() { 488 try { 489 LayoutSupportDelegate layoutDelegate = getNewLayoutSupport(); 490 if (layoutDelegate != null) { 491 getFormModel().setContainerLayoutImpl( 492 (RADVisualContainer)getContainer(), 493 layoutDelegate, 494 null); 495 } 496 else { 497 getFormModel().setNaturalContainerLayoutImpl( 498 (RADVisualContainer)getContainer()); 499 } 500 } 501 catch (Exception ex) { 502 ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); 503 } 504 } 505 506 private void undoContainerLayoutChange() { 507 RADVisualContainer metacont = (RADVisualContainer) getComponent(); 508 LayoutSupportManager laysup = metacont.getLayoutSupport(); 509 if (laysup != null) { 510 String propName = getPropertyName(); 511 if (propName != null) { 512 Node.Property prop = laysup.getLayoutProperty(propName); 513 if (prop != null) { 514 try { 515 prop.setValue(getOldPropertyValue()); 516 } 517 catch (Exception ex) { ex.printStackTrace(); 519 } 520 } 521 } 522 } 523 else { 524 getFormModel().fireContainerLayoutChanged(metacont, null, null, null); 525 } 526 } 527 528 private void redoContainerLayoutChange() { 529 RADVisualContainer metacont = (RADVisualContainer) getComponent(); 530 LayoutSupportManager laysup = metacont.getLayoutSupport(); 531 if (laysup != null) { 532 String propName = getPropertyName(); 533 if (propName != null) { 534 Node.Property prop = laysup.getLayoutProperty(propName); 535 if (prop != null) { 536 try { 537 prop.setValue(getNewPropertyValue()); 538 } 539 catch (Exception ex) { ex.printStackTrace(); 541 } 542 } 543 } 544 } 545 else { 546 getFormModel().fireContainerLayoutChanged(metacont, null, null, null); 547 } 548 } 549 550 private void undoComponentLayoutChange() { 551 if (getComponent() instanceof RADVisualComponent) { 552 ((RADVisualComponent)getComponent()).getConstraintsProperties(); 553 Node.Property prop = 554 getComponent().getPropertyByName(getPropertyName()); 555 if (prop != null) 556 try { 557 prop.setValue(getOldPropertyValue()); 558 } 559 catch (Exception ex) { ex.printStackTrace(); 561 } 562 } 563 } 564 565 private void redoComponentLayoutChange() { 566 if (getComponent() instanceof RADVisualComponent) { 567 ((RADVisualComponent)getComponent()).getConstraintsProperties(); 568 Node.Property prop = 569 getComponent().getPropertyByName(getPropertyName()); 570 if (prop != null) 571 try { 572 prop.setValue(getNewPropertyValue()); 573 } 574 catch (Exception ex) { ex.printStackTrace(); 576 } 577 } 578 } 579 580 private void undoComponentAddition() { 581 removeComponent(); 582 } 583 584 private void undoComponentRemoval() { 585 addComponent(); 586 } 587 588 private void redoComponentAddition() { 589 addComponent(); 590 } 591 592 private void redoComponentRemoval() { 593 removeComponent(); 594 } 595 596 private void addComponent() { 597 RADComponent[] currentSubComps = getContainer().getSubBeans(); 598 RADComponent[] undoneSubComps = 599 new RADComponent[currentSubComps.length+1]; 600 601 if (componentIndex < 0) 602 componentIndex = currentSubComps.length; 603 604 for (int i=0,j=0; j < undoneSubComps.length; i++,j++) { 605 if (i == componentIndex) { 606 undoneSubComps[j] = getComponent(); 607 if (i == currentSubComps.length) 608 break; 609 j++; 610 } 611 undoneSubComps[j] = currentSubComps[i]; 612 } 613 614 if (getCreatedDeleted()) 615 FormModel.setInModelRecursively(getComponent(), true); 616 617 getContainer().initSubComponents(undoneSubComps); 618 619 if (getContainer() instanceof RADVisualContainer 620 && getComponent() instanceof RADVisualComponent) 621 { 622 LayoutSupportManager layoutSupport = 623 ((RADVisualContainer)getContainer()).getLayoutSupport(); 624 if (layoutSupport != null) 625 layoutSupport.addComponents( 626 new RADVisualComponent[] { (RADVisualComponent)getComponent() }, 627 new LayoutConstraints[] { getComponentLayoutConstraints() }, 628 componentIndex); 629 } 630 631 getFormModel().fireComponentAdded(getComponent(), getCreatedDeleted()); 632 } 633 634 private void removeComponent() { 635 getFormModel().removeComponentImpl(getComponent(), getCreatedDeleted()); 636 } 637 638 private void undoComponentsReorder() { 639 if (getContainer() != null && reordering != null) { 640 int[] revPerm = new int[reordering.length]; 641 for (int i=0; i < reordering.length; i++) 642 revPerm[reordering[i]] = i; 643 644 getContainer().reorderSubComponents(revPerm); 645 getFormModel().fireComponentsReordered(getContainer(), revPerm); 646 } 647 } 648 649 private void redoComponentsReorder() { 650 if (getContainer() != null && reordering != null) { 651 getContainer().reorderSubComponents(reordering); 652 getFormModel().fireComponentsReordered(getContainer(), 653 reordering); 654 } 655 } 656 657 private void undoComponentPropertyChange() { 658 Node.Property prop = 659 getComponent().getPropertyByName(getPropertyName()); 660 if (prop != null) 661 try { 662 prop.setValue(getOldPropertyValue()); 663 } 664 catch (Exception ex) { ex.printStackTrace(); 666 } 667 } 668 669 private void redoComponentPropertyChange() { 670 Node.Property prop = 671 getComponent().getPropertyByName(getPropertyName()); 672 if (prop != null) 673 try { 674 prop.setValue(getNewPropertyValue()); 675 } 676 catch (Exception ex) { ex.printStackTrace(); 678 } 679 } 680 681 private void undoSyntheticPropertyChange() { 682 String propName = getPropertyName(); 683 if (propName.startsWith(RADProperty.SYNTH_PREFIX)) { 684 if (propName.startsWith(RADProperty.SYNTH_PRE_CODE)) { 686 FormProperty prop = (FormProperty) 687 getComponent().getPropertyByName( 688 propName.substring(RADProperty.SYNTH_PRE_CODE.length())); 689 prop.setPreCode((String )getOldPropertyValue()); 690 } 691 else if (propName.startsWith(RADProperty.SYNTH_POST_CODE)) { 692 FormProperty prop = (FormProperty) 693 getComponent().getPropertyByName( 694 propName.substring(RADProperty.SYNTH_POST_CODE.length())); 695 prop.setPostCode((String )getOldPropertyValue()); 696 } 697 } else { 698 Node.Property[] props; 699 if (getComponent() == null) { FormEditor formEditor = FormEditor.getFormEditor(getFormModel()); 701 FormRootNode rootNode = (FormRootNode)formEditor.getFormRootNode(); 702 props = rootNode.getAllProperties(); 703 } else { props = getComponent().getSyntheticProperties(); 705 } 706 for (int i=0; i < props.length; i++) { 707 if (props[i].getName().equals(propName)) { 708 try { 709 props[i].setValue(getOldPropertyValue()); 710 } 711 catch (Exception ex) { ex.printStackTrace(); 713 } 714 break; 715 } 716 } 717 } 718 } 719 720 private void redoSyntheticPropertyChange() { 721 String propName = getPropertyName(); 722 if (propName.startsWith(RADProperty.SYNTH_PREFIX)) { 723 if (propName.startsWith(RADProperty.SYNTH_PRE_CODE)) { 725 FormProperty prop = (FormProperty) 726 getComponent().getPropertyByName( 727 propName.substring(RADProperty.SYNTH_PRE_CODE.length())); 728 prop.setPreCode((String )getNewPropertyValue()); 729 } 730 else if (propName.startsWith(RADProperty.SYNTH_POST_CODE)) { 731 FormProperty prop = (FormProperty) 732 getComponent().getPropertyByName( 733 propName.substring(RADProperty.SYNTH_POST_CODE.length())); 734 prop.setPostCode((String )getNewPropertyValue()); 735 } 736 } else { 737 Node.Property[] props; 738 if (getComponent() == null) { FormEditor formEditor = FormEditor.getFormEditor(getFormModel()); 740 FormRootNode rootNode = (FormRootNode)formEditor.getFormRootNode(); 741 props = rootNode.getAllProperties(); 742 } else { props = getComponent().getSyntheticProperties(); 744 } 745 for (int i=0; i < props.length; i++) { 746 if (props[i].getName().equals(propName)) { 747 try { 748 props[i].setValue(getNewPropertyValue()); 749 } 750 catch (Exception ex) { ex.printStackTrace(); 752 } 753 break; 754 } 755 } 756 } 757 } 758 759 private void undoEventHandlerAddition() { 760 Event event = getComponentEvent(); 761 if (event == null) 762 return; 763 764 addToInterestList(FormModelEvent.this); 765 766 getFormModel().getFormEvents().detachEvent(event, getEventHandler()); 767 768 removeFromInterestList(FormModelEvent.this); 769 770 Node.Property prop = getComponent().getPropertyByName(event.getId()); 772 if (prop != null) { 773 try { 774 if (getEventHandler().equals(prop.getValue())) 775 prop.setValue(null); 776 } 777 catch (Exception ex) { ex.printStackTrace(); 779 } 780 } 781 } 782 783 private void redoEventHandlerAddition() { 784 Event event = getComponentEvent(); 785 if (event == null) 786 return; 787 788 getFormModel().getFormEvents().attachEvent( 789 event, 790 getEventHandler(), 791 getOldEventHandlerContent()); 793 Node.Property prop = getComponent().getPropertyByName(event.getId()); 795 if (prop != null) { 796 try { 797 prop.setValue(getEventHandler()); 798 } 799 catch (Exception ex) { ex.printStackTrace(); 801 } 802 } 803 } 804 805 private void undoEventHandlerRemoval() { 806 Event event = getComponentEvent(); 807 if (event == null) 808 return; 809 810 getFormModel().getFormEvents().attachEvent( 811 event, 812 getEventHandler(), 813 getOldEventHandlerContent()); 815 Node.Property prop = getComponent().getPropertyByName(event.getId()); 817 if (prop != null) { 818 try { 819 prop.setValue(getEventHandler()); 820 } 821 catch (Exception ex) { ex.printStackTrace(); 823 } 824 } 825 } 826 827 private void redoEventHandlerRemoval() { 828 Event event = getComponentEvent(); 829 if (event == null) 830 return; 831 832 addToInterestList(FormModelEvent.this); 833 834 getFormModel().getFormEvents().detachEvent(event, getEventHandler()); 835 836 removeFromInterestList(FormModelEvent.this); 837 838 Node.Property prop = getComponent().getPropertyByName(event.getId()); 840 if (prop != null) { 841 try { 842 if (getEventHandler().equals(prop.getValue())) 843 prop.setValue(null); 844 } 845 catch (Exception ex) { ex.printStackTrace(); 847 } 848 } 849 } 850 851 private void undoEventHandlerRenaming() { 852 FormEvents formEvents = getFormModel().getFormEvents(); 853 854 formEvents.renameEventHandler(getNewEventHandler(), 855 getOldEventHandler()); 856 857 Event[] events = formEvents.getEventsForHandler( 858 getOldEventHandler()); 859 for (int i=0 ; i < events.length; i++) { 860 Node.Property prop = events[i].getComponent() 861 .getPropertyByName(events[i].getId()); 862 if (prop != null) { 863 try { 864 prop.setValue(getOldEventHandler()); 865 } 866 catch (Exception ex) { ex.printStackTrace(); 868 } 869 } 870 } 871 } 872 873 private void redoEventHandlerRenaming() { 874 FormEvents formEvents = getFormModel().getFormEvents(); 875 876 formEvents.renameEventHandler(getOldEventHandler(), 877 getNewEventHandler()); 878 879 Event[] events = formEvents.getEventsForHandler( 880 getNewEventHandler()); 881 for (int i=0 ; i < events.length; i++) { 882 Node.Property prop = events[i].getComponent() 883 .getPropertyByName(events[i].getId()); 884 if (prop != null) { 885 try { 886 prop.setValue(getNewEventHandler()); 887 } 888 catch (Exception ex) { ex.printStackTrace(); 890 } 891 } 892 } 893 } 894 } 895 } 896 | Popular Tags |