1 16 package com.blandware.atleap.model.core; 17 18 import java.util.ArrayList ; 19 import java.util.Comparator ; 20 import java.util.HashMap ; 21 import java.util.Iterator ; 22 import java.util.List ; 23 import java.util.Map ; 24 25 26 66 public class MenuItem extends BaseObject { 67 68 71 public static final byte VISIBILITY_HERITABLE = 0; 72 75 public static final byte VISIBILITY_VISIBLE = 1; 76 79 public static final byte VISIBILITY_INVISIBLE = 2; 80 81 85 public static final String ALIGN_LEFT = "left"; 86 public static final String ALIGN_RIGHT = "right"; 87 public static final String ALIGN_ABS_BOTTOM = "absBottom"; 88 public static final String ALIGN_ABS_MIDDLE = "absMiddle"; 89 public static final String ALIGN_BASELINE = "baseline"; 90 public static final String ALIGN_BOTTOM = "bottom"; 91 public static final String ALIGN_MIDDLE = "middle"; 92 public static final String ALIGN_TEXT_TOP = "textTop"; 93 public static final String ALIGN_TOP = "top"; 94 95 98 public static final Comparator POSITION_COMPARATOR = new Comparator () { 99 public int compare(Object o1, Object o2) { 100 if ( !(o1 instanceof MenuItem) || !(o2 instanceof MenuItem) ) { 101 throw new ClassCastException ("Cannot compare instance of " + o1.getClass().getName() + " to the instance of " + o2.getClass().getName()); 102 } 103 MenuItem item1 = (MenuItem) o1; 104 MenuItem item2 = (MenuItem) o2; 105 return item1.getPosition().compareTo(item2.getPosition()); 106 } 107 }; 108 109 111 114 protected Long id; 115 116 119 protected MenuItem parentItem; 120 121 124 protected List childItems = new ArrayList (); 125 126 130 protected String identifier; 131 132 135 protected String align; 136 137 140 protected String style; 141 142 145 protected String styleClass; 146 147 150 protected String styleId; 151 152 155 protected String image; 156 157 160 protected String altImage; 161 162 165 protected String action; 166 167 170 protected String forward; 171 172 175 protected String location; 176 177 180 protected Boolean externalLocation = Boolean.FALSE; 181 182 185 protected String anchor; 186 187 190 protected String target; 191 192 196 protected Byte visibility; 197 198 201 protected Integer position; 202 203 206 protected String onclick; 207 208 211 protected String onmouseover; 212 213 216 protected String onmouseout; 217 218 221 protected List roles = new ArrayList (); 222 223 226 protected MenuItem origItem; 227 228 231 protected List redefinitionItems = new ArrayList (); 232 233 236 protected Localizable owner; 237 238 240 243 protected Map title = new HashMap (); 244 245 248 protected Map toolTip = new HashMap (); 249 250 253 protected Long version; 254 255 258 protected List linkedPages = new ArrayList (); 259 260 263 protected List linkedResources = new ArrayList (); 264 265 266 268 276 public Long getId() { 277 return id; 278 } 279 280 285 public void setId(Long id) { 286 this.id = id; 287 } 288 289 295 public MenuItem getParentItem() { 296 return parentItem; 297 } 298 299 304 public void setParentItem(MenuItem parentItem) { 305 this.parentItem = parentItem; 306 } 307 308 316 public List getChildItems() { 317 return childItems; 318 } 319 320 325 public void setChildItems(List childItems) { 326 this.childItems = childItems; 327 } 328 329 336 public String getIdentifier() { 337 return identifier; 338 } 339 340 345 public void setIdentifier(String identifier) { 346 this.identifier = identifier; 347 } 348 349 357 public String getAlign() { 358 return align; 359 } 360 361 366 public void setAlign(String align) { 367 this.align = align; 368 } 369 370 371 379 public String getStyle() { 380 return style; 381 } 382 383 388 public void setStyle(String style) { 389 this.style = style; 390 } 391 392 400 public String getStyleClass() { 401 return styleClass; 402 } 403 404 409 public void setStyleClass(String styleClass) { 410 this.styleClass = styleClass; 411 } 412 413 421 public String getStyleId() { 422 return styleId; 423 } 424 425 430 public void setStyleId(String styleId) { 431 this.styleId = styleId; 432 } 433 434 442 public String getImage() { 443 return image; 444 } 445 446 451 public void setImage(String image) { 452 this.image = image; 453 } 454 455 463 public String getAltImage() { 464 return altImage; 465 } 466 467 472 public void setAltImage(String altImage) { 473 this.altImage = altImage; 474 } 475 476 477 484 public String getAction() { 485 return action; 486 } 487 488 493 public void setAction(String action) { 494 this.action = action; 495 } 496 497 504 public String getForward() { 505 return forward; 506 } 507 508 513 public void setForward(String forward) { 514 this.forward = forward; 515 } 516 517 525 public String getLocation() { 526 return location; 527 } 528 529 534 public void setLocation(String location) { 535 this.location = location; 536 } 537 538 544 public Boolean getExternalLocation() { 545 return externalLocation; 546 } 547 548 553 public void setExternalLocation(Boolean externalLocation) { 554 this.externalLocation = externalLocation; 555 } 556 557 564 public String getAnchor() { 565 return anchor; 566 } 567 568 573 public void setAnchor(String anchor) { 574 this.anchor = anchor; 575 } 576 577 578 586 public String getTarget() { 587 return target; 588 } 589 590 595 public void setTarget(String target) { 596 this.target = target; 597 } 598 599 600 608 public Byte getVisibility() { 609 return visibility; 610 } 611 612 617 public void setVisibility(Byte visibility) { 618 this.visibility = visibility; 619 } 620 621 626 public boolean isVisible() { 627 return visibility.byteValue() == VISIBILITY_VISIBLE; 628 } 629 630 635 public boolean isInvisible() { 636 return visibility.byteValue() == VISIBILITY_INVISIBLE; 637 } 638 639 644 public boolean isVisibilityHeritable() { 645 return visibility.byteValue() == VISIBILITY_HERITABLE; 646 } 647 648 649 657 public Integer getPosition() { 658 return position; 659 } 660 661 667 public void setPosition(Integer position) { 668 this.position = position; 669 } 670 671 678 public String getOnclick() { 679 return onclick; 680 } 681 682 687 public void setOnclick(String onclick) { 688 this.onclick = onclick; 689 } 690 691 698 public String getOnmouseover() { 699 return onmouseover; 700 } 701 702 707 public void setOnmouseover(String onmouseover) { 708 this.onmouseover = onmouseover; 709 } 710 711 718 public String getOnmouseout() { 719 return onmouseout; 720 } 721 722 727 public void setOnmouseout(String onmouseout) { 728 this.onmouseout = onmouseout; 729 } 730 731 741 public List getRoles() { 742 return roles; 743 } 744 745 750 public String getRolesAsString() { 751 StringBuffer roles = new StringBuffer (); 752 if ( this.roles != null && this.roles.size() > 0 ) { 753 for ( Iterator i = this.roles.iterator(); i.hasNext(); ) { 754 Role role = (Role) i.next(); 755 roles.append(role.getTitle()); 756 if ( i.hasNext() ) { 757 roles.append(", "); 758 } 759 } 760 } 761 return roles.toString(); 762 } 763 764 769 public void setRoles(List roles) { 770 this.roles = roles; 771 } 772 773 778 public void addRole(Role role) { 779 if ( !role.getMenuItems().contains(this) ) { 780 role.getMenuItems().add(this); 781 } 782 if ( !getRoles().contains(role) ) { 783 getRoles().add(role); 784 } 785 } 786 787 792 public void removeRole(Role role) { 793 role.getMenuItems().remove(this); 794 getRoles().remove(role); 795 } 796 797 803 public MenuItem getOrigItem() { 804 return origItem; 805 } 806 807 812 public void setOrigItem(MenuItem origItem) { 813 this.origItem = origItem; 814 } 815 816 824 protected List getRedefinitionItems() { 825 return redefinitionItems; 826 } 827 828 833 protected void setRedefinitionItems(List redefinitionItems) { 834 this.redefinitionItems = redefinitionItems; 835 } 836 837 842 public boolean isRedefinition() { 843 return this.origItem != null; 844 } 845 846 847 854 public Localizable getOwner() { 855 return owner; 856 } 857 858 863 public void setOwner(Localizable owner) { 864 this.owner = owner; 865 } 866 867 873 public boolean isDynamic() { 874 return this.owner != null; 875 } 876 877 878 886 public List getLinkedPages() { 887 return linkedPages; 888 } 889 890 895 public void setLinkedPages(List linkedPages) { 896 this.linkedPages = linkedPages; 897 } 898 899 904 public void addLinkedPage(Page page) { 905 if ( !page.getLinkedMenuItems().contains(this) ) { 906 page.getLinkedMenuItems().add(this); 907 } 908 if ( !getLinkedPages().contains(page) ) { 909 getLinkedPages().add(page); 910 } 911 } 912 913 918 public void removeLinkedPage(Page page) { 919 page.getLinkedMenuItems().remove(this); 920 getLinkedPages().remove(page); 921 } 922 923 924 932 public List getLinkedResources() { 933 return linkedResources; 934 } 935 936 941 public void setLinkedResources(List linkedContentResources) { 942 this.linkedResources = linkedContentResources; 943 } 944 945 950 public void addLinkedResource(ContentResource resource) { 951 if ( !resource.getLinkedMenuItems().contains(this) ) { 952 resource.getLinkedMenuItems().add(this); 953 } 954 if ( !getLinkedPages().contains(resource) ) { 955 getLinkedPages().add(resource); 956 } 957 } 958 959 964 public void removeLinkedResource(ContentResource resource) { 965 resource.getLinkedMenuItems().remove(this); 966 getLinkedResources().remove(resource); 967 } 968 969 970 980 public Map getTitle() { 981 return title; 982 } 983 984 989 public void setTitle(Map title) { 990 this.title = title; 991 } 992 993 1003 public Map getToolTip() { 1004 return toolTip; 1005 } 1006 1007 1012 public void setToolTip(Map toolTip) { 1013 this.toolTip = toolTip; 1014 } 1015 1016 1023 public Long getVersion() { 1024 return version; 1025 } 1026 1027 1032 public void setVersion(Long version) { 1033 this.version = version; 1034 } 1035 1036 public boolean equals(Object o) { 1037 if ( this == o ) { 1038 return true; 1039 } 1040 if ( !(o instanceof MenuItem) ) { 1041 return false; 1042 } 1043 1044 final MenuItem menuItem = (MenuItem) o; 1045 1046 if ( identifier != null ? !identifier.equals(menuItem.identifier) : menuItem.identifier != null ) { 1047 return false; 1048 } 1049 if ( owner != null ? !owner.equals(menuItem.owner) : menuItem.owner != null ) { 1050 return false; 1051 } 1052 if ( parentItem != null ? !parentItem.equals(menuItem.parentItem) : menuItem.parentItem != null ) { 1053 return false; 1054 } 1055 1056 return true; 1057 } 1058 1059 public int hashCode() { 1060 int result; 1061 result = (parentItem != null ? parentItem.hashCode() : 0); 1062 result = 29 * result + (identifier != null ? identifier.hashCode() : 0); 1063 result = 29 * result + (owner != null ? owner.hashCode() : 0); 1064 return result; 1065 } 1066 1067 1068} 1069 | Popular Tags |