001package com.hfg.javascript.ext; 002 003 004import java.util.ArrayList; 005import java.util.HashMap; 006import java.util.List; 007import java.util.Map; 008 009import com.hfg.exception.ProgrammingException; 010import com.hfg.html.attribute.Align; 011import com.hfg.javascript.JsObjMap; 012import com.hfg.util.AttributeMgr; 013import com.hfg.util.BooleanUtil; 014import com.hfg.util.CompareUtil; 015import com.hfg.util.StringUtil; 016import com.hfg.util.collection.CollectionUtil; 017import com.hfg.xml.XMLAttribute; 018import com.hfg.xml.XMLTag; 019 020//------------------------------------------------------------------------------ 021/** 022 Definition for a column from an ExtJs grid. 023 <div> 024 @author J. Alex Taylor, hairyfatguy.com 025 </div> 026 */ 027//------------------------------------------------------------------------------ 028// com.hfg Library 029// 030// This library is free software; you can redistribute it and/or 031// modify it under the terms of the GNU Lesser General Public 032// License as published by the Free Software Foundation; either 033// version 2.1 of the License, or (at your option) any later version. 034// 035// This library is distributed in the hope that it will be useful, 036// but WITHOUT ANY WARRANTY; without even the implied warranty of 037// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 038// Lesser General Public License for more details. 039// 040// You should have received a copy of the GNU Lesser General Public 041// License along with this library; if not, write to the Free Software 042// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 043// 044// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com 045// jataylor@hairyfatguy.com 046//------------------------------------------------------------------------------ 047 048public class ExtGridCol implements Cloneable, Comparable 049{ 050 private String mText; 051 private String mTooltip; 052 private String mDataIndex; 053 private Integer mWidth; 054 private Integer mMinWidth; 055 private Integer mMaxWidth; 056 private Align mAlign; 057 private String mRenderer; 058 private String mEditor; 059 private String mItemId; 060 private Boolean mSortable; 061 private Boolean mHideable; 062 private Boolean mHidden; 063 private Boolean mLockable; 064 private Boolean mLocked; 065 private Boolean mDraggable; 066 private Boolean mGroupable; 067 private Boolean mResizable; 068 private Boolean mVariableRowHeight; 069 private String mFilter; 070 private Integer mFlex; 071 private String mXType; 072 private String mSortType; 073 private String mEmptyCellText; 074 075 private ExtFieldType mFieldType; 076 077 private List<ExtGridCol> mGroupCols; 078 private ExtGridCol mParentCol; 079 080 private Map<String, String> mCustomFields; 081 082 private AttributeMgr mAttributeMgr; 083 084 private enum Field 085 { 086 align, 087 columns, 088 dataIndex, 089 draggable, 090 editor, 091 emptyCellText, 092 flex, 093 filter, 094 groupable, 095 hidden, 096 hideable, 097 itemId, 098 lockable, 099 locked, 100 maxWidth, 101 minWidth, 102 renderer, 103 resizable, 104 sortable, 105 sortType, 106 text, 107 tooltip, 108 variaibleRowHeight, 109 width, 110 xtype 111 } 112 113 private static final String XML_TAG_NAME = "ExtGridCol"; 114 115 //########################################################################## 116 // CONSTRUCTORS 117 //########################################################################## 118 119 //-------------------------------------------------------------------------- 120 public ExtGridCol() 121 { 122 } 123 124 //-------------------------------------------------------------------------- 125 public ExtGridCol(JsObjMap inJson) 126 { 127 for (String key : inJson.keySet()) 128 { 129 try 130 { 131 Field field = Field.valueOf(key); 132 Object value = inJson.get(field.name()); 133 134 switch (field) 135 { 136 case align: 137 setAlign(Align.valueOf((String) value)); 138 break; 139 case columns: 140 for (JsObjMap subCol : (List<JsObjMap>) value) 141 { 142 addGroupColumn(new ExtGridCol(subCol)); 143 } 144 break; 145 case dataIndex: 146 setDataIndex((String) value); 147 break; 148 case draggable: 149 setDraggable((Boolean) value); 150 break; 151 case editor: 152 setEditor((String) value); 153 break; 154 case emptyCellText: 155 setEmptyCellText((String) value); 156 break; 157 case filter: 158 setFilter((String) value); 159 break; 160 case flex: 161 setFlex((Integer) value); 162 break; 163 case groupable: 164 setGroupable((Boolean) value); 165 break; 166 case hidden: 167 setHidden((Boolean) value); 168 break; 169 case hideable: 170 setHideable((Boolean) value); 171 break; 172 case itemId: 173 setItemId((String) value); 174 break; 175 case lockable: 176 setLockable((Boolean) value); 177 break; 178 case locked: 179 setLocked((Boolean) value); 180 break; 181 case minWidth: 182 setMinWidth((Integer) value); 183 break; 184 case maxWidth: 185 setMaxWidth((Integer) value); 186 break; 187 case renderer: 188 setRenderer((String) value); 189 break; 190 case resizable: 191 setResizable((Boolean) value); 192 break; 193 case sortable: 194 setSortable((Boolean) value); 195 break; 196 case sortType: 197 setSortType((String) value); 198 break; 199 case text: 200 setText((String) value); 201 break; 202 case tooltip: 203 setTooltip((String) value); 204 break; 205 case variaibleRowHeight: 206 setVariableRowHeight((Boolean) value); 207 break; 208 case width: 209 setWidth(value != null ? ((Number) value).intValue() : null); 210 break; 211 case xtype: 212 setXType((String) value); 213 break; 214 } 215 } 216 catch (Exception e) 217 { 218 // Ignore 219 } 220 } 221 } 222 223 //-------------------------------------------------------------------------- 224 public ExtGridCol(XMLTag inXMLTag) 225 { 226 this(); 227 228 inXMLTag.verifyTagName(XML_TAG_NAME); 229 230 for (XMLAttribute attr : inXMLTag.getAttributes()) 231 { 232 Field field = Field.valueOf(attr.getName()); 233 if (field != null) 234 { 235 String value = attr.getValue(); 236 237 switch (field) 238 { 239 case align: 240 setAlign(Align.valueOf(value)); 241 break; 242 case dataIndex: 243 setDataIndex(value); 244 break; 245 case draggable: 246 setDraggable(BooleanUtil.valueOf(value)); 247 break; 248 case editor: 249 setEditor(value); 250 break; 251 case emptyCellText: 252 setEmptyCellText(value); 253 break; 254 case filter: 255 setFilter(value); 256 break; 257 case flex: 258 setFlex(Integer.parseInt(value)); 259 break; 260 case groupable: 261 setGroupable(BooleanUtil.valueOf(value)); 262 break; 263 case hidden: 264 setHidden(BooleanUtil.valueOf(value)); 265 break; 266 case hideable: 267 setHideable(BooleanUtil.valueOf(value)); 268 break; 269 case itemId: 270 setItemId(value); 271 break; 272 case lockable: 273 setLockable(BooleanUtil.valueOf(value)); 274 break; 275 case locked: 276 setLocked(BooleanUtil.valueOf(value)); 277 break; 278 case minWidth: 279 setMinWidth(Integer.parseInt(value)); 280 break; 281 case maxWidth: 282 setMaxWidth(Integer.parseInt(value)); 283 break; 284 case renderer: 285 setRenderer(value); 286 break; 287 case resizable: 288 setResizable(BooleanUtil.valueOf(value)); 289 break; 290 case sortable: 291 setSortable(BooleanUtil.valueOf(value)); 292 break; 293 case sortType: 294 setSortType(value); 295 break; 296 case text: 297 setText(value); 298 break; 299 case tooltip: 300 setTooltip(value); 301 break; 302 case variaibleRowHeight: 303 setVariableRowHeight(BooleanUtil.valueOf(value)); 304 break; 305 case width: 306 setWidth(Integer.parseInt(value)); 307 break; 308 case xtype: 309 setXType(value); 310 break; 311 } 312 } 313 } 314 315 XMLTag columnsTag = inXMLTag.getOptionalSubtagByName(Field.columns.name()); 316 if (columnsTag != null) 317 { 318 for (XMLTag subtag : (List<XMLTag>) (Object) columnsTag.getSubtags()) 319 { 320 addGroupColumn(new ExtGridCol(subtag)); 321 } 322 } 323 } 324 325 //########################################################################## 326 // PUBLIC METHODS 327 //########################################################################## 328 329 //-------------------------------------------------------------------------- 330 @Override 331 public String toString() 332 { 333 return toJsObjMap().toJavascript(); 334 } 335 336 //-------------------------------------------------------------------------- 337 @Override 338 public boolean equals(Object inObj2) 339 { 340 return (0 == compareTo(inObj2)); 341 } 342 343 //-------------------------------------------------------------------------- 344 @Override 345 public int hashCode() 346 { 347 int hashCode = 1; 348 349 if (StringUtil.isSet(getDataIndex())) 350 { 351 hashCode += 31 * getDataIndex().hashCode(); 352 } 353 else if (StringUtil.isSet(getText())) 354 { 355 hashCode += getText().hashCode(); 356 } 357 358 return hashCode; 359 } 360 361 //-------------------------------------------------------------------------- 362 /** 363 * Currently compares just dataIndex values or text if the dataIndex isn't set. 364 * @param inObj2 the Object to compare to this ExtGridCol object. 365 * @return whether the specified object is less than, equal to, or greater than this object. 366 */ 367 public int compareTo(Object inObj2) 368 { 369 int result = -1; 370 371 if (inObj2 != null 372 && inObj2 instanceof ExtGridCol) 373 { 374 ExtGridCol col2 = (ExtGridCol) inObj2; 375 376 result = CompareUtil.compare(getDataIndex(), col2.getDataIndex()); 377 if (0 == result 378 && null == getDataIndex() 379 && getText() != null) 380 { 381 result = CompareUtil.compare(getText(), col2.getText()); 382 } 383 } 384 385 return result; 386 } 387 388 //-------------------------------------------------------------------------- 389 public ExtModelField toExtModelField() 390 { 391 ExtModelField modelField = null; 392 if (getDataIndex() != null) 393 { 394 modelField = new ExtModelField(getDataIndex()); 395 396 if (getSortType() != null) 397 { 398 modelField.setSortType(getSortType()); 399 } 400 401 if (getFieldType() != null) 402 { 403 modelField.setType(getFieldType()); 404 } 405 else if (getFilter() != null) 406 { 407 switch (getFilter()) 408 { 409 case "string": 410 modelField.setType(ExtFieldType.STRING); 411 break; 412 case "number": 413 modelField.setType(ExtFieldType.FLOAT); 414 break; 415 case "boolean": 416 modelField.setType(ExtFieldType.BOOLEAN); 417 break; 418 case "date": 419 modelField.setType(ExtFieldType.DATE); 420 modelField.setDateFormat("time"); 421 break; 422 } 423 } 424 else if (getXType() != null 425 && getXType().equalsIgnoreCase("booleancolumn")) 426 { 427 modelField.setType(ExtFieldType.BOOLEAN); 428 } 429 } 430 431 return modelField; 432 } 433 434 //-------------------------------------------------------------------------- 435 public JsObjMap toJsObjMap() 436 { 437 JsObjMap js = new JsObjMap(); 438 439 if (getText() != null) 440 { 441 js.put(Field.text.name(), getText()); 442 } 443 444 if (getDataIndex() != null) 445 { 446 js.put(Field.dataIndex.name(), getDataIndex()); 447 } 448 449 if (getTooltip() != null) 450 { 451 js.put(Field.tooltip.name(), getTooltip()); 452 } 453 454 if (getWidth() != null) 455 { 456 js.put(Field.width.name(), getWidth()); 457 } 458 459 if (getMinWidth() != null) 460 { 461 js.put(Field.minWidth.name(), getMinWidth()); 462 } 463 464 if (getMaxWidth() != null) 465 { 466 js.put(Field.maxWidth.name(), getMaxWidth()); 467 } 468 469 if (getAlign() != null) 470 { 471 js.put(Field.align.name(), getAlign()); 472 } 473 474 if (getSortable() != null) 475 { 476 js.put(Field.sortable.name(), getSortable()); 477 } 478/* 479 if (getSortType() != null) 480 { 481 js.put(Field.sortType.name(), getSortType()); 482 } 483*/ 484 if (getHidden() != null) 485 { 486 js.put(Field.hidden.name(), getHidden()); 487 } 488 489 if (getHideable() != null) 490 { 491 js.put(Field.hideable.name(), getHideable()); 492 } 493 494 if (getLocked() != null) 495 { 496 js.put(Field.locked.name(), getLocked()); 497 } 498 499 if (getLockable() != null) 500 { 501 js.put(Field.lockable.name(), getLockable()); 502 } 503 504 if (getDraggable() != null) 505 { 506 js.put(Field.draggable.name(), getDraggable()); 507 } 508 509 if (getGroupable() != null) 510 { 511 js.put(Field.groupable.name(), getGroupable()); 512 } 513 514 if (getResizable() != null) 515 { 516 js.put(Field.resizable.name(), getResizable()); 517 } 518 519 if (getVariableRowHeight() != null) 520 { 521 js.put(Field.variaibleRowHeight.name(), getVariableRowHeight()); 522 } 523 524 if (getRenderer() != null) 525 { 526 js.putUnquoted(Field.renderer.name(), getRenderer()); 527 } 528 529 if (getEditor() != null) 530 { 531 js.putUnquoted(Field.editor.name(), getEditor()); 532 } 533 534 if (getItemId() != null) 535 { 536 js.put(Field.itemId.name(), getItemId()); 537 } 538 539 if (getFilter() != null) 540 { 541 js.put(Field.filter.name(), getFilter()); 542 } 543 544 if (getFlex() != null) 545 { 546 js.put(Field.flex.name(), getFlex()); 547 } 548 549 if (getXType() != null) 550 { 551 js.put(Field.xtype.name(), getXType()); 552 } 553 554 if (getEmptyCellText() != null) 555 { 556 js.put(Field.emptyCellText.name(), getEmptyCellText()); 557 } 558 559 if (CollectionUtil.hasValues(mCustomFields)) 560 { 561 for (String key : mCustomFields.keySet()) 562 { 563 js.put(key, mCustomFields.get(key)); 564 } 565 } 566 567 if (CollectionUtil.hasValues(getGroupColumns())) 568 { 569 js.putUnquoted(Field.columns.name(), "[" + StringUtil.join(getGroupColumns(), ", ") + "]"); 570 } 571 572 return js; 573 } 574 575 //-------------------------------------------------------------------------- 576 public XMLTag toXMLTag() 577 { 578 XMLTag tag = new XMLTag(XML_TAG_NAME); 579 580 581 if (getText() != null) 582 { 583 tag.setAttribute(Field.text.name(), getText()); 584 } 585 586 if (getDataIndex() != null) 587 { 588 tag.setAttribute(Field.dataIndex.name(), getDataIndex()); 589 } 590 591 if (getTooltip() != null) 592 { 593 tag.setAttribute(Field.tooltip.name(), getTooltip()); 594 } 595 596 if (getWidth() != null) 597 { 598 tag.setAttribute(Field.width.name(), getWidth()); 599 } 600 601 if (getMinWidth() != null) 602 { 603 tag.setAttribute(Field.minWidth.name(), getMinWidth()); 604 } 605 606 if (getMaxWidth() != null) 607 { 608 tag.setAttribute(Field.maxWidth.name(), getMaxWidth()); 609 } 610 611 if (getAlign() != null) 612 { 613 tag.setAttribute(Field.align.name(), getAlign()); 614 } 615 616 if (getSortable() != null) 617 { 618 tag.setAttribute(Field.sortable.name(), getSortable()); 619 } 620 621 if (getSortType() != null) 622 { 623 tag.setAttribute(Field.sortType.name(), getSortType()); 624 } 625 626 if (getHidden() != null) 627 { 628 tag.setAttribute(Field.hidden.name(), getHidden()); 629 } 630 631 if (getHideable() != null) 632 { 633 tag.setAttribute(Field.hideable.name(), getHideable()); 634 } 635 636 if (getLocked() != null) 637 { 638 tag.setAttribute(Field.locked.name(), getLocked()); 639 } 640 641 if (getLockable() != null) 642 { 643 tag.setAttribute(Field.lockable.name(), getLockable()); 644 } 645 646 if (getDraggable() != null) 647 { 648 tag.setAttribute(Field.draggable.name(), getDraggable()); 649 } 650 651 if (getGroupable() != null) 652 { 653 tag.setAttribute(Field.groupable.name(), getGroupable()); 654 } 655 656 if (getResizable() != null) 657 { 658 tag.setAttribute(Field.resizable.name(), getResizable()); 659 } 660 661 if (getVariableRowHeight() != null) 662 { 663 tag.setAttribute(Field.variaibleRowHeight.name(), getVariableRowHeight()); 664 } 665 666 if (getRenderer() != null) 667 { 668 tag.setAttribute(Field.renderer.name(), getRenderer()); 669 } 670 671 if (getEditor() != null) 672 { 673 tag.setAttribute(Field.editor.name(), getEditor()); 674 } 675 676 if (getItemId() != null) 677 { 678 tag.setAttribute(Field.itemId.name(), getItemId()); 679 } 680 681 if (getFilter() != null) 682 { 683 tag.setAttribute(Field.filter.name(), getFilter()); 684 } 685 686 if (getFlex() != null) 687 { 688 tag.setAttribute(Field.flex.name(), getFlex()); 689 } 690 691 if (getXType() != null) 692 { 693 tag.setAttribute(Field.xtype.name(), getXType()); 694 } 695 696 if (getEmptyCellText() != null) 697 { 698 tag.setAttribute(Field.emptyCellText.name(), getEmptyCellText()); 699 } 700 701 if (CollectionUtil.hasValues(getGroupColumns())) 702 { 703 XMLTag columnsTag = new XMLTag(Field.columns.name()); 704 tag.addSubtag(columnsTag); 705 706 for (ExtGridCol groupCol : getGroupColumns()) 707 { 708 columnsTag.addSubtag(groupCol.toXMLTag()); 709 } 710 } 711 712 return tag; 713 } 714 715 //--------------------------------------------------------------------------- 716 @Override 717 public ExtGridCol clone() 718 { 719 ExtGridCol cloneObj; 720 try 721 { 722 cloneObj = (ExtGridCol) super.clone(); 723 } 724 catch (CloneNotSupportedException e) 725 { 726 throw new ProgrammingException(e); 727 } 728 729 if (mGroupCols != null) 730 { 731 cloneObj.mGroupCols = new ArrayList<>(mGroupCols.size()); 732 for (ExtGridCol groupCol : mGroupCols) 733 { 734 cloneObj.addGroupColumn(groupCol.clone()); 735 } 736 } 737 738 return cloneObj; 739 } 740 741 //-------------------------------------------------------------------------- 742 public List<ExtGridCol> getGroupColumns() 743 { 744 return mGroupCols; 745 } 746 747 //-------------------------------------------------------------------------- 748 public void addGroupColumn(ExtGridCol inValue) 749 { 750 if (null == mGroupCols) 751 { 752 mGroupCols = new ArrayList<>(20); 753 } 754 755 mGroupCols.add(inValue); 756 inValue.mParentCol = this; 757 } 758 759 //-------------------------------------------------------------------------- 760 public void setGroupColumn(int inIndex, ExtGridCol inValue) 761 { 762 if (null == mGroupCols) 763 { 764 mGroupCols = new ArrayList<>(20); 765 } 766 767 mGroupCols.set(inIndex, inValue); 768 inValue.mParentCol = this; 769 } 770 771 //-------------------------------------------------------------------------- 772 public void removeGroupColumn(ExtGridCol inValue) 773 { 774 if (mGroupCols != null) 775 { 776 mGroupCols.remove(inValue); 777 inValue.mParentCol = null; 778 } 779 } 780 781 //-------------------------------------------------------------------------- 782 public void clearGroupColumns() 783 { 784 if (mGroupCols != null) 785 { 786 for (ExtGridCol child : mGroupCols) 787 { 788 child.mParentCol = null; 789 } 790 791 mGroupCols.clear(); 792 } 793 } 794 795 //-------------------------------------------------------------------------- 796 public ExtGridCol getParentCol() 797 { 798 return mParentCol; 799 } 800 801 //-------------------------------------------------------------------------- 802 public ExtGridCol setCustomField(String inName, String inValue) 803 { 804 if (null == mCustomFields) 805 { 806 mCustomFields = new HashMap<>(5); 807 } 808 809 mCustomFields.put(inName, inValue); 810 811 return this; 812 } 813 814 //-------------------------------------------------------------------------- 815 public String getCustomField(String inName) 816 { 817 return (mCustomFields != null ? mCustomFields.get(inName) : null); 818 } 819 820 821 //-------------------------------------------------------------------------- 822 public ExtGridCol setText(String inValue) 823 { 824 mText = inValue; 825 return this; 826 } 827 828 //-------------------------------------------------------------------------- 829 public String getText() 830 { 831 return mText; 832 } 833 834 835 836 //-------------------------------------------------------------------------- 837 public ExtGridCol setEmptyCellText(String inValue) 838 { 839 mEmptyCellText = inValue; 840 return this; 841 } 842 843 //-------------------------------------------------------------------------- 844 public String getEmptyCellText() 845 { 846 return mEmptyCellText; 847 } 848 849 850 //-------------------------------------------------------------------------- 851 public ExtGridCol setTooltip(String inValue) 852 { 853 mTooltip = inValue; 854 return this; 855 } 856 857 //-------------------------------------------------------------------------- 858 public String getTooltip() 859 { 860 return mTooltip; 861 } 862 863 864 //-------------------------------------------------------------------------- 865 public ExtGridCol setDataIndex(ExtModelField inValue) 866 { 867 mDataIndex = inValue.name(); 868 return this; 869 } 870 871 //-------------------------------------------------------------------------- 872 public ExtGridCol setDataIndex(String inValue) 873 { 874 mDataIndex = inValue; 875 return this; 876 } 877 878 //-------------------------------------------------------------------------- 879 public String getDataIndex() 880 { 881 return mDataIndex; 882 } 883 884 885 //-------------------------------------------------------------------------- 886 public ExtGridCol setWidth(Integer inValue) 887 { 888 mWidth = inValue; 889 return this; 890 } 891 892 //-------------------------------------------------------------------------- 893 public Integer getWidth() 894 { 895 return mWidth; 896 } 897 898 899 //-------------------------------------------------------------------------- 900 public ExtGridCol setMinWidth(Integer inValue) 901 { 902 mMinWidth = inValue; 903 return this; 904 } 905 906 //-------------------------------------------------------------------------- 907 public Integer getMinWidth() 908 { 909 return mMinWidth; 910 } 911 912 913 //-------------------------------------------------------------------------- 914 public ExtGridCol setMaxWidth(Integer inValue) 915 { 916 mMaxWidth = inValue; 917 return this; 918 } 919 920 //-------------------------------------------------------------------------- 921 public Integer getMaxWidth() 922 { 923 return mMaxWidth; 924 } 925 926 927 //-------------------------------------------------------------------------- 928 public ExtGridCol setAlign(Align inValue) 929 { 930 mAlign = inValue; 931 return this; 932 } 933 934 //-------------------------------------------------------------------------- 935 public Align getAlign() 936 { 937 return mAlign; 938 } 939 940 941 //-------------------------------------------------------------------------- 942 /** 943 Specifies a method name or method definition for composing the display ov column fields. 944 @param inValue either a javascript method name or a definition of a javascript method 945 @return this ExtGridCol object - for method chaining 946 */ 947 public ExtGridCol setRenderer(String inValue) 948 { 949 mRenderer = inValue; 950 return this; 951 } 952 953 //-------------------------------------------------------------------------- 954 public String getRenderer() 955 { 956 return mRenderer; 957 } 958 959 960 //-------------------------------------------------------------------------- 961 public ExtGridCol setEditor(String inValue) 962 { 963 mEditor = inValue; 964 return this; 965 } 966 967 //-------------------------------------------------------------------------- 968 public String getEditor() 969 { 970 return mEditor; 971 } 972 973 974 //-------------------------------------------------------------------------- 975 public ExtGridCol setSortable(Boolean inValue) 976 { 977 mSortable = inValue; 978 return this; 979 } 980 981 //-------------------------------------------------------------------------- 982 public Boolean getSortable() 983 { 984 return mSortable; 985 } 986 987 988 //-------------------------------------------------------------------------- 989 /** 990 sortType isn't a true column property but is included here so that the 991 information can be transferred to the corresponding model field if desired. 992 * @param inValue name of the javascript SortType method. 993 * @return this grid column object to facilitate method chaining 994 */ 995 public ExtGridCol setSortType(String inValue) 996 { 997 mSortType = inValue; 998 return this; 999 } 1000 1001 //-------------------------------------------------------------------------- 1002 public String getSortType() 1003 { 1004 return mSortType; 1005 } 1006 1007 1008 //-------------------------------------------------------------------------- 1009 public ExtGridCol setHideable(Boolean inValue) 1010 { 1011 mHideable = inValue; 1012 return this; 1013 } 1014 1015 //-------------------------------------------------------------------------- 1016 public Boolean getHideable() 1017 { 1018 return mHideable; 1019 } 1020 1021 1022 //-------------------------------------------------------------------------- 1023 public ExtGridCol setHidden(Boolean inValue) 1024 { 1025 mHidden = inValue; 1026 return this; 1027 } 1028 1029 //-------------------------------------------------------------------------- 1030 public Boolean getHidden() 1031 { 1032 return mHidden; 1033 } 1034 1035 1036 //-------------------------------------------------------------------------- 1037 public ExtGridCol setLockable(Boolean inValue) 1038 { 1039 mLockable = inValue; 1040 return this; 1041 } 1042 1043 //-------------------------------------------------------------------------- 1044 public Boolean getLockable() 1045 { 1046 return mLockable; 1047 } 1048 1049 1050 //-------------------------------------------------------------------------- 1051 public ExtGridCol setLocked(Boolean inValue) 1052 { 1053 mLocked = inValue; 1054 return this; 1055 } 1056 1057 //-------------------------------------------------------------------------- 1058 public Boolean getLocked() 1059 { 1060 return mLocked; 1061 } 1062 1063 1064 //-------------------------------------------------------------------------- 1065 /** 1066 Specifies whether the column header can be reordered by dragging. 1067 @param inValue whether or not the column can be reordered 1068 @return this ExtGridCol object - for method chaining 1069 */ 1070 public ExtGridCol setDraggable(Boolean inValue) 1071 { 1072 mDraggable = inValue; 1073 return this; 1074 } 1075 1076 //-------------------------------------------------------------------------- 1077 public Boolean getDraggable() 1078 { 1079 return mDraggable; 1080 } 1081 1082 1083 //-------------------------------------------------------------------------- 1084 /** 1085 Specifies whether the grid can be grouped by the column dataIndex. 1086 @param inValue whether or not the column can be grouped 1087 @return this ExtGridCol object - for method chaining 1088 */ 1089 public ExtGridCol setGroupable(Boolean inValue) 1090 { 1091 mGroupable = inValue; 1092 return this; 1093 } 1094 1095 //-------------------------------------------------------------------------- 1096 public Boolean getGroupable() 1097 { 1098 return mGroupable; 1099 } 1100 1101 1102 //-------------------------------------------------------------------------- 1103 public ExtGridCol setResizable(Boolean inValue) 1104 { 1105 mResizable = inValue; 1106 return this; 1107 } 1108 1109 //-------------------------------------------------------------------------- 1110 public Boolean getResizable() 1111 { 1112 return mResizable; 1113 } 1114 1115 1116 //-------------------------------------------------------------------------- 1117 public ExtGridCol setVariableRowHeight(Boolean inValue) 1118 { 1119 mVariableRowHeight = inValue; 1120 return this; 1121 } 1122 1123 //-------------------------------------------------------------------------- 1124 public Boolean getVariableRowHeight() 1125 { 1126 return mVariableRowHeight; 1127 } 1128 1129 1130 //-------------------------------------------------------------------------- 1131 public ExtGridCol setItemId(String inValue) 1132 { 1133 mItemId = inValue; 1134 return this; 1135 } 1136 1137 //-------------------------------------------------------------------------- 1138 public String getItemId() 1139 { 1140 return mItemId; 1141 } 1142 1143 1144 //-------------------------------------------------------------------------- 1145 public ExtGridCol setFilter(String inValue) 1146 { 1147 mFilter = inValue; 1148 return this; 1149 } 1150 1151 //-------------------------------------------------------------------------- 1152 public String getFilter() 1153 { 1154 return mFilter; 1155 } 1156 1157 1158 //-------------------------------------------------------------------------- 1159 public ExtGridCol setFlex(Integer inValue) 1160 { 1161 mFlex = inValue; 1162 return this; 1163 } 1164 1165 //-------------------------------------------------------------------------- 1166 public Integer getFlex() 1167 { 1168 return mFlex; 1169 } 1170 1171 1172 //-------------------------------------------------------------------------- 1173 public ExtGridCol setXType(String inValue) 1174 { 1175 mXType = inValue; 1176 return this; 1177 } 1178 1179 //-------------------------------------------------------------------------- 1180 public String getXType() 1181 { 1182 return mXType; 1183 } 1184 1185 1186 //-------------------------------------------------------------------------- 1187 /** 1188 Specifies the field type to use for the column's model. 1189 * @param inValue the field type 1190 * @return this ExtGridCol object to enable method chaining 1191 */ 1192 public ExtGridCol setFieldType(ExtFieldType inValue) 1193 { 1194 mFieldType = inValue; 1195 return this; 1196 } 1197 1198 //-------------------------------------------------------------------------- 1199 public ExtFieldType getFieldType() 1200 { 1201 return mFieldType; 1202 } 1203 1204 1205 //-------------------------------------------------------------------------- 1206 public AttributeMgr getAttributeMgr() 1207 { 1208 if (null == mAttributeMgr) 1209 { 1210 mAttributeMgr = new AttributeMgr(); 1211 } 1212 1213 return mAttributeMgr; 1214 } 1215 1216 //-------------------------------------------------------------------------- 1217 public int getHeaderRowDepth() 1218 { 1219 return getHeaderRowDepth(1); 1220 } 1221 1222 //-------------------------------------------------------------------------- 1223 public int getTerminalColumnCount() 1224 { 1225 int colCount = 0; 1226 1227 if (CollectionUtil.hasValues(getGroupColumns())) 1228 { 1229 for (ExtGridCol col : getGroupColumns()) 1230 { 1231 colCount += col.getTerminalColumnCount(); 1232 } 1233 } 1234 else 1235 { 1236 colCount++; 1237 } 1238 1239 return colCount; 1240 } 1241 1242 //-------------------------------------------------------------------------- 1243 private int getHeaderRowDepth(int inInitialDepth) 1244 { 1245 int maxDepth = inInitialDepth; 1246 1247 if (CollectionUtil.hasValues(getGroupColumns())) 1248 { 1249 for (ExtGridCol col : getGroupColumns()) 1250 { 1251 int depth = col.getHeaderRowDepth(inInitialDepth + 1); 1252 if (depth > maxDepth) 1253 { 1254 maxDepth = depth; 1255 } 1256 } 1257 } 1258 1259 return maxDepth; 1260 } 1261}