1 package org.jahia.layout; 2 3 15 16 import java.util.Enumeration ; 17 import java.util.Vector ; 18 19 import org.jahia.exceptions.JahiaException; 20 import org.jahia.utils.JahiaConsole; 21 22 public class PortletBeanSpanningGrid extends PortletBeanGrid { 23 24 41 private Grid2D portletTable = new Grid2D(); 42 43 49 private void addToTable(PortletBean portlet) 50 throws JahiaException { 51 int row = portlet.getPortletRow(); 52 int col = portlet.getPortletColumn(); 53 int height = portlet.getPortletH(); 54 int width = portlet.getPortletW(); 55 60 if ((row < 0) || (col < 0)) { 62 throw new JahiaException("PortletBeanSpanningGrid.addToTable", 63 "Portlet coordinates are invalid. (" + Integer.toString(row) + ", " + Integer.toString(col) + " )", 64 JahiaException.PAGE_ERROR, 65 JahiaException.ERROR_SEVERITY); 66 } 67 68 boolean isFree = true; 70 for (int i = 0; i < height; i++) { 71 for (int j = 0; j < width; j++) { 72 try { 73 PortletBean curPortlet = (PortletBean) portletTable.getElementAt(row + i, col + j); 74 if (curPortlet != null) { 75 isFree = false; 76 } 77 } catch (ArrayIndexOutOfBoundsException aioobe) { 78 } 79 } 80 } 81 if (!isFree) { 82 throw new JahiaException("PortletBeanSpanningGrid.addToTable", 83 "A portlet is already occupying that position", 84 JahiaException.PAGE_ERROR, 85 JahiaException.ERROR_SEVERITY); 86 } 87 for (int i = 0; i < height; i++) { 90 for (int j = 0; j < width; j++) { 91 portletTable.setElementAt(row+i, col+j, portlet); 92 } 93 } 94 } 95 96 100 private void rebuildGridTable() throws JahiaException { 101 JahiaConsole.println("PortletBeanSpanningGrid.rebuildGridTable", 102 "Rebuilding reference table for " + 103 Integer.toString(this.size()) + " portlets..."); 104 portletTable.clear(); 106 for (int i=0; i < this.size(); i++) { 107 PortletBean portlet = (PortletBean) this.elementAt(i); 108 if (portlet != null) { 109 this.addToTable(portlet); 110 } 111 } 112 this.debugDisplayGrid(); 113 } 114 115 public PortletBeanSpanningGrid() { 116 } 117 118 122 public PortletBeanSpanningGrid(PortletBeanSet sourceSet) 123 throws JahiaException { 124 Enumeration sourceElements = sourceSet.elements(); 125 while (sourceElements.hasMoreElements()) { 126 PortletBean portlet = (PortletBean) sourceElements.nextElement(); 127 this.add(portlet); 128 } 129 } 130 131 141 public void resetPortlets(int nbColumns) throws JahiaException { 142 Enumeration sourceElements = this.elements(); 143 int row = 0; 144 int column = 0; 145 while (sourceElements.hasMoreElements()) { 146 PortletBean portlet = (PortletBean) sourceElements.nextElement(); 147 portlet.setPortletH(1); 148 portlet.setPortletW(1); 149 portlet.setPortletRow(row); 150 portlet.setPortletColumn(column); 151 column++; 152 if (column == nbColumns) { 153 column = 0; 154 row++; 155 } 156 } 157 rebuildGridTable(); 158 } 159 160 170 public boolean add(PortletBean portlet) { 171 if ((portlet.getPortletH() == 0) || (portlet.getPortletW() == 0)) { 174 portlet.setPortletH(1); 175 portlet.setPortletW(1); 176 } 177 if ((portlet.getPortletRow() < 0) || (portlet.getPortletColumn() < 0)) { 179 int maxRow = getRowCount(); 181 int oldRow = portlet.getPortletRow(); 182 int oldCol = portlet.getPortletColumn(); 183 portlet.setPortletRow(maxRow); 184 portlet.setPortletColumn(0); 185 JahiaConsole.println("PortletBeanSpanningGrid.add", "Correcting invalid coordinates (" + 186 oldRow + ", " + oldCol + ") to (" + 187 portlet.getPortletRow() + ", " + portlet.getPortletColumn() + ")"); 188 189 } 190 191 192 PortletBean testPortlet = null; 194 try { 195 testPortlet = (PortletBean) portletTable.getElementAt(portlet.getPortletRow(), portlet.getPortletColumn()); 196 } catch (ArrayIndexOutOfBoundsException aioobe) { 197 } 199 200 if (testPortlet != null) { 201 int maxRow = getRowCount(); 203 portlet.setPortletRow(maxRow); 204 portlet.setPortletColumn(0); 205 JahiaConsole.println("PortletBeanSpanningGrid.add", "Conflict found, modifying new portlet position to row=" + maxRow + " column=0"); 206 } 207 208 boolean parentResult = super.add(portlet); 209 try { 210 addToTable(portlet); 211 } catch (JahiaException je) { 212 return false; 213 } 214 return parentResult; 215 } 216 217 236 public PortletBean getPortletFromRefTable(int row, int column) { 237 PortletBean portlet = (PortletBean) this.portletTable.getElementAt(row, column); 238 return portlet; 239 } 240 241 248 public int getColumnCount() { 249 columnCount = 0; 250 Enumeration portletBeanEnum = this.elements(); 251 while (portletBeanEnum.hasMoreElements()) { 252 PortletBean portlet = (PortletBean) portletBeanEnum.nextElement(); 253 if (portlet.getPortletColumn() + portlet.getPortletW() > columnCount) { 254 columnCount = portlet.getPortletColumn() + portlet.getPortletW(); 255 } 256 } 257 return columnCount; 258 } 259 260 267 public int getColumnCount (int rowID) throws JahiaException { 268 rebuildGridTable(); 269 int resultColumnCount = 0; 270 if ((rowID < 0) || (rowID >= getRowCount())) { 271 275 return 0; 276 } 277 for (int i = 0; i < portletTable.getColumnCount(); i++) { 278 PortletBean curPortlet = (PortletBean) portletTable.getElementAt(rowID, i); 279 if (curPortlet != null) { 280 if (i+1 > resultColumnCount) { 281 resultColumnCount = i+1; 282 } 283 } 284 } 285 return resultColumnCount; 286 } 287 288 296 public int getRowCount() { 297 rowCount = 0; 298 Enumeration portletBeanEnum = this.elements(); 299 while (portletBeanEnum.hasMoreElements()) { 300 PortletBean portlet = (PortletBean) portletBeanEnum.nextElement(); 301 if (portlet.getPortletRow() + portlet.getPortletH() > rowCount) { 302 rowCount = portlet.getPortletRow() + portlet.getPortletH(); 303 } 304 } 305 return rowCount; 306 } 307 308 315 public int getRowCount(int columnID) throws JahiaException { 316 return this.getRowCountWithoutPortlet(columnID, -1); 317 } 318 319 329 public int getRowCountWithoutPortlet(int columnID, int portletIDToIgnore) 330 throws JahiaException { 331 rebuildGridTable(); 332 int resultRowCount = 0; 333 if ((columnID < 0) || (columnID >= getColumnCount())) { 334 338 return 0; 339 } 340 for (int i = 0; i < portletTable.getRowCount(); i++) { 341 PortletBean curPortlet = (PortletBean) portletTable.getElementAt(i, columnID); 342 if (curPortlet != null) { 343 if ( (curPortlet.getPortletID() != portletIDToIgnore) || 344 (portletIDToIgnore == -1) ) { 345 if ( (i+1) > resultRowCount ) { 346 resultRowCount = i+1; 347 } 348 } 349 } 350 } 351 return resultRowCount; 352 } 353 354 363 private Vector markedColumnList = null; 364 365 374 private void debugDisplayMarkedList(String message, Vector markedList) { 375 if (markedList == null) { 376 JahiaConsole.println("PortletBeanSpanningGrid.debugDisplayMarkedList", 377 message + " markedList is null"); 378 return; 379 } 380 381 for (int i=0; i < markedList.size(); i++) { 382 MarkEntry curEntry = (MarkEntry) markedList.elementAt(i); 383 JahiaConsole.println("PortletBeanSpanningGrid.debugDisplayMarkedList", 384 message + "[" + i + "]" + 385 " mark start=" + curEntry.getMarkStart() + 386 " processed=" + curEntry.getProcessedState()); 387 } 388 } 389 390 391 398 private void findHorizontalEdgeForMoving(int column, int startingRow) 399 throws JahiaException { 400 JahiaConsole.println("PortletBeanSpanningGrid.findHorizontalEdgeForMoving", 401 "Building horizontal edge"); 402 if (markedColumnList == null) { 403 markedColumnList = new Vector (); 404 for (int i = 0; i < this.getColumnCount(); i++) { 406 markedColumnList.add(new MarkEntry()); 407 } 408 } 409 410 if ( (column >= this.getColumnCount()) || (column < 0) ) { 411 return; 412 } 413 414 MarkEntry thisColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(column); 415 if (thisColumnMarkEntry == null) { 416 throw new JahiaException("PortletBeanSpanningGrid.findHorizontalEdgeForMoving", 418 "Invalid markedColumnList, probably a problem during initialization...", 419 JahiaException.TEMPLATE_ERROR, 420 JahiaException.ERROR_SEVERITY); 421 } 422 int markerStart = -1; 426 for (int i=startingRow; i < getRowCount(column); i++) { 427 PortletBean portlet = (PortletBean) this.portletTable.getElementAt(i, column); 428 if (portlet != null) { 429 markerStart = i; 430 break; 431 } 432 } 433 if (markerStart == -1) { 434 return; 435 } 436 thisColumnMarkEntry.setMarkStart(markerStart); 437 442 recursiveHorizontalEdgeMarking(column, startingRow); 443 } 444 445 456 private int recursiveHorizontalEdgeMarking(int column, int startingRow) 457 throws JahiaException { 458 int numberOfNewMarks = 0; 459 MarkEntry thisColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(column); 460 if (thisColumnMarkEntry == null) { 461 throw new JahiaException("PortletBeanSpanningGrid.recursiveHorizontalEdgeMarking", 462 "Invalid markedColumnList, probably a problem during initialization...", 463 JahiaException.TEMPLATE_ERROR, 464 JahiaException.ERROR_SEVERITY); 465 } 466 if (thisColumnMarkEntry.getProcessedState() == true) { 467 return numberOfNewMarks; 469 } 470 for (int i=startingRow; i < this.getRowCount(column); i++) { 471 PortletBean portlet = (PortletBean) this.portletTable.getElementAt(i, column); 472 if (portlet != null) { 473 if ( (portlet.getPortletW() > 1) ) { 474 482 for (int j=portlet.getPortletColumn(); j < portlet.getPortletColumn() + portlet.getPortletW(); j++) { 483 MarkEntry curColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(j); 486 if (curColumnMarkEntry == null) { 487 494 throw new JahiaException("PortletBeanSpanningGrid.recursiveHorizontalEdgeMarking", 495 "Invalid markedColumnList, probably a problem during initialization...", 496 JahiaException.TEMPLATE_ERROR, 497 JahiaException.ERROR_SEVERITY); 498 } 499 if ((curColumnMarkEntry.getMarkStart() == -1) || 500 (curColumnMarkEntry.getMarkStart() > i) ) { 501 curColumnMarkEntry.setMarkStart(i); 505 numberOfNewMarks++; 506 } 507 } 508 if ( (portlet.getPortletRow() == i) && 509 (portlet.getPortletColumn() == column) ) { 510 } else { 512 } 514 } else { 515 520 } 521 } else { 522 } 523 } 524 MarkEntry curColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(column); 527 if (curColumnMarkEntry != null) { 528 curColumnMarkEntry.setProcessedState(true); 529 } else { 530 536 throw new JahiaException("PortletBeanSpanningGrid.recursiveHorizontalEdgeMarking", 537 "Invalid markedColumnList, probably a problem during initialization...", 538 JahiaException.TEMPLATE_ERROR, 539 JahiaException.ERROR_SEVERITY); 540 } 541 if ( (column-1) >= 0) { 543 MarkEntry previousColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(column-1); 544 if ( (previousColumnMarkEntry.getProcessedState() == false) && 545 (previousColumnMarkEntry.getMarkStart() != -1 ) ) { 546 recursiveHorizontalEdgeMarking(column-1, previousColumnMarkEntry.getMarkStart()); 547 } 548 } 549 if ( (column + 1) < this.getColumnCount() ) { 551 MarkEntry nextColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(column+1); 552 if ( (nextColumnMarkEntry.getProcessedState() == false) && 553 (nextColumnMarkEntry.getMarkStart() != -1 ) ) { 554 recursiveHorizontalEdgeMarking(column+1, nextColumnMarkEntry.getMarkStart()); 555 } 556 } 557 return numberOfNewMarks; 558 } 559 560 567 private void moveColumnsDown(int increment) 568 throws JahiaException { 569 for (int i=0; i < this.getColumnCount(); i++) { 570 MarkEntry curColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(i); 571 if (curColumnMarkEntry == null) { 572 throw new JahiaException("PortletBeanSpanningGrid.moveColumnsDown", 573 "Invalid markedColumnList, probably a problem during initialization...", 574 JahiaException.TEMPLATE_ERROR, 575 JahiaException.ERROR_SEVERITY); 576 } 577 if (curColumnMarkEntry.getMarkStart() != -1) { 578 for (int j = this.getRowCount(i)-1; j >= curColumnMarkEntry.getMarkStart(); j--) { 581 PortletBean portlet = (PortletBean) this.getPosPortlet(j, i); 582 if (portlet != null) { 583 portlet.setPortletRow(portlet.getPortletRow()+increment); 584 } 585 } 586 } 587 } 588 589 rebuildGridTable(); 590 markedColumnList = null; 591 } 592 593 604 private void moveColumnsUp(int increment, int startingColumn) 605 throws JahiaException { 606 611 612 if ((startingColumn < 0) || (startingColumn >= this.getColumnCount())) { 613 return; 614 } 615 616 MarkEntry startColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(startingColumn); 617 if (startColumnMarkEntry == null) { 618 throw new JahiaException("PortletBeanSpanningGrid.moveColumnsUp", 619 "Invalid markedColumnList, probably a problem during initialization...", 620 JahiaException.TEMPLATE_ERROR, 621 JahiaException.ERROR_SEVERITY); 622 } 623 int startingRow = startColumnMarkEntry.getMarkStart(); 624 625 if (startingRow == -1) { 626 return; 628 } 629 630 for (int i = startingRow; i < this.getRowCount(); i++) { 631 634 if (startingColumn > 0) { 635 for (int j = startingColumn-1; j >= 0; j--) { 636 MarkEntry curColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(j); 637 if (curColumnMarkEntry == null) { 638 throw new JahiaException("PortletBeanSpanningGrid.moveColumnsUp", 639 "Invalid markedColumnList, probably a problem during initialization...", 640 JahiaException.TEMPLATE_ERROR, 641 JahiaException.ERROR_SEVERITY); 642 } 643 if (curColumnMarkEntry.getMarkStart() != -1) { 644 PortletBean portlet = (PortletBean) this.getPosPortlet(i, j); 645 if (portlet != null) { 646 boolean hasSpace = true; 649 for (int k=0; k < increment; k++) { 650 for (int l=0; l < portlet.getPortletW(); l++) { 651 PortletBean posPortlet = (PortletBean) this.getPosPortlet(portlet.getPortletRow() - increment+k, portlet.getPortletColumn() + l); 652 if (posPortlet != null) { 653 hasSpace = false; 654 } 655 } 656 } 657 if (hasSpace) { 658 portlet.setPortletRow(portlet.getPortletRow()-increment); 659 } 660 } 661 } 662 } 663 } 664 665 for (int j = startingColumn; j < this.getColumnCount(); j++) { 666 MarkEntry curColumnMarkEntry = (MarkEntry) markedColumnList.elementAt(j); 667 if (curColumnMarkEntry == null) { 668 throw new JahiaException("PortletBeanSpanningGrid.moveColumnsUp", 669 "Invalid markedColumnList, probably a problem during initialization...", 670 JahiaException.TEMPLATE_ERROR, 671 JahiaException.ERROR_SEVERITY); 672 } 673 if (curColumnMarkEntry.getMarkStart() != -1) { 674 PortletBean portlet = (PortletBean) this.getPosPortlet(i, j); 675 if (portlet != null) { 676 boolean hasSpace = true; 679 for (int k=0; k < increment; k++) { 680 for (int l=0; l < portlet.getPortletW(); l++) { 681 PortletBean posPortlet = (PortletBean) this.getPosPortlet(portlet.getPortletRow() - increment+k, portlet.getPortletColumn() + l); 682 if (posPortlet != null) { 683 hasSpace = false; 684 } 685 } 686 } 687 if (hasSpace) { 688 portlet.setPortletRow(portlet.getPortletRow()-increment); 689 } 690 } 691 } 692 } 693 } 694 695 rebuildGridTable(); 696 markedColumnList = null; 697 } 698 699 703 704 713 private Vector markedRowList = null; 714 715 722 private void findVerticalEdgeForMoving(int row, int startingColumn) 723 throws JahiaException { 724 725 if (markedRowList == null) { 726 markedRowList = new Vector (); 727 for (int i = 0; i < this.getRowCount(); i++) { 729 markedRowList.add(new MarkEntry()); 730 } 731 } 732 733 if ( (row >= this.getRowCount()) || (row < 0) ) { 734 return; 735 } 736 737 MarkEntry thisRowMarkEntry = (MarkEntry) markedRowList.elementAt(row); 738 if (thisRowMarkEntry == null) { 739 throw new JahiaException("PortletBeanSpanningGrid.findVerticalEdgeForMoving", 741 "Invalid markedRowList, probably a problem during initialization...", 742 JahiaException.TEMPLATE_ERROR, 743 JahiaException.ERROR_SEVERITY); 744 } 745 int markerStart = -1; 749 for (int i=startingColumn; i < getColumnCount(row); i++) { 750 PortletBean portlet = (PortletBean) this.portletTable.getElementAt(row, i); 751 if (portlet != null) { 752 markerStart = i; 753 break; 754 } 755 } 756 if (markerStart == -1) { 757 return; 758 } 759 thisRowMarkEntry.setMarkStart(markerStart); 760 765 recursiveVerticalEdgeMarking(row, startingColumn); 766 } 767 768 779 private int recursiveVerticalEdgeMarking(int row, int startingColumn) 780 throws JahiaException { 781 int numberOfNewMarks = 0; 782 MarkEntry thisRowMarkEntry = (MarkEntry) markedRowList.elementAt(row); 783 if (thisRowMarkEntry == null) { 784 throw new JahiaException("PortletBeanSpanningGrid.recursiveVerticalEdgeMarking", 785 "Invalid markedRowList, probably a problem during initialization...", 786 JahiaException.TEMPLATE_ERROR, 787 JahiaException.ERROR_SEVERITY); 788 } 789 if (thisRowMarkEntry.getProcessedState() == true) { 790 return numberOfNewMarks; 792 } 793 for (int i=startingColumn; i < this.getColumnCount(row); i++) { 794 PortletBean portlet = (PortletBean) this.portletTable.getElementAt(row, i); 795 if (portlet != null) { 796 if ( (portlet.getPortletH() > 1) ) { 797 805 for (int j=portlet.getPortletRow(); j < portlet.getPortletRow() + portlet.getPortletH(); j++) { 806 MarkEntry curRowMarkEntry = (MarkEntry) markedRowList.elementAt(j); 809 if (curRowMarkEntry == null) { 810 817 throw new JahiaException("PortletBeanSpanningGrid.recursiveVerticalEdgeMarking", 818 "Invalid markedRowList, probably a problem during initialization...", 819 JahiaException.TEMPLATE_ERROR, 820 JahiaException.ERROR_SEVERITY); 821 } 822 if ((curRowMarkEntry.getMarkStart() == -1) || 823 (curRowMarkEntry.getMarkStart() > i) ) { 824 curRowMarkEntry.setMarkStart(i); 828 numberOfNewMarks++; 829 } 830 } 831 if ( (portlet.getPortletRow() == row) && 832 (portlet.getPortletColumn() == i) ) { 833 } else { 835 } 837 } else { 838 843 } 844 } else { 845 } 846 } 847 MarkEntry curRowMarkEntry = (MarkEntry) markedRowList.elementAt(row); 850 if (curRowMarkEntry != null) { 851 curRowMarkEntry.setProcessedState(true); 852 } else { 853 859 throw new JahiaException("PortletBeanSpanningGrid.recursiveVerticalEdgeMarking", 860 "Invalid markedRowList, probably a problem during initialization...", 861 JahiaException.TEMPLATE_ERROR, 862 JahiaException.ERROR_SEVERITY); 863 } 864 if ( (row-1) >= 0) { 865 MarkEntry previousRowMarkEntry = (MarkEntry) markedRowList.elementAt(row-1); 866 if ( (previousRowMarkEntry.getProcessedState() == false) && 867 (previousRowMarkEntry.getMarkStart() != -1 ) ) { 868 recursiveVerticalEdgeMarking(row-1, previousRowMarkEntry.getMarkStart()); 869 } 870 } 871 if ( (row + 1) < this.getRowCount() ) { 872 MarkEntry nextRowMarkEntry = (MarkEntry) markedRowList.elementAt(row+1); 873 if ( (nextRowMarkEntry.getProcessedState() == false) && 874 (nextRowMarkEntry.getMarkStart() != -1 ) ) { 875 recursiveVerticalEdgeMarking(row+1, nextRowMarkEntry.getMarkStart()); 876 } 877 } 878 return numberOfNewMarks; 879 } 880 881 888 private void moveRowsRight(int increment) 889 throws JahiaException { 890 for (int i=0; i < this.getRowCount(); i++) { 891 MarkEntry curRowMarkEntry = (MarkEntry) markedRowList.elementAt(i); 892 if (curRowMarkEntry == null) { 893 throw new JahiaException("PortletBeanSpanningGrid.moveRowsRight", 894 "Invalid markedRowList, probably a problem during initialization...", 895 JahiaException.TEMPLATE_ERROR, 896 JahiaException.ERROR_SEVERITY); 897 } 898 if (curRowMarkEntry.getMarkStart() != -1) { 899 for (int j = this.getColumnCount(i)-1; j >= curRowMarkEntry.getMarkStart(); j--) { 902 PortletBean portlet = (PortletBean) this.getPosPortlet(i, j); 903 if (portlet != null) { 904 portlet.setPortletColumn(portlet.getPortletColumn()+increment); 905 } 906 } 907 } 908 } 909 910 rebuildGridTable(); 911 markedRowList = null; 912 } 913 914 925 private void moveRowsLeft(int increment, int startingRow) 926 throws JahiaException { 927 932 933 if ((startingRow < 0) || (startingRow >= getRowCount())) { 934 return; 935 } 936 937 MarkEntry startRowMarkEntry = (MarkEntry) markedRowList.elementAt(startingRow); 938 if (startRowMarkEntry == null) { 939 throw new JahiaException("PortletBeanSpanningGrid.moveColumnsUp", 940 "Invalid markedColumnList, probably a problem during initialization...", 941 JahiaException.TEMPLATE_ERROR, 942 JahiaException.ERROR_SEVERITY); 943 } 944 int startingColumn = startRowMarkEntry.getMarkStart(); 945 946 if (startingColumn == -1) { 947 return; 949 } 950 951 for (int i = startingColumn; i < this.getColumnCount(); i++) { 952 955 if (startingRow > 0) { 956 for (int j = startingRow-1; j >= 0; j--) { 957 MarkEntry curRowMarkEntry = (MarkEntry) markedRowList.elementAt(j); 958 if (curRowMarkEntry == null) { 959 throw new JahiaException("PortletBeanSpanningGrid.moveRowsLeft", 960 "Invalid markedRowList, probably a problem during initialization...", 961 JahiaException.TEMPLATE_ERROR, 962 JahiaException.ERROR_SEVERITY); 963 } 964 if (curRowMarkEntry.getMarkStart() != -1) { 965 PortletBean portlet = (PortletBean) this.getPosPortlet(j, i); 966 if (portlet != null) { 967 boolean hasSpace = true; 970 for (int k=0; k < increment; k++) { 971 for (int l=0; l < portlet.getPortletH(); l++) { 972 PortletBean posPortlet = (PortletBean) this.getPosPortlet(portlet.getPortletRow() + l, portlet.getPortletColumn() - increment+k); 973 if (posPortlet != null) { 974 hasSpace = false; 975 } 976 } 977 } 978 if (hasSpace) { 979 portlet.setPortletColumn(portlet.getPortletColumn()-increment); 980 } 981 } 982 } 983 } 984 } 985 986 for (int j = startingRow; j < this.getRowCount(); j++) { 987 MarkEntry curRowMarkEntry = (MarkEntry) markedRowList.elementAt(j); 988 if (curRowMarkEntry == null) { 989 throw new JahiaException("PortletBeanSpanningGrid.moveRowsLeft", 990 "Invalid markedRowList, probably a problem during initialization...", 991 JahiaException.TEMPLATE_ERROR, 992 JahiaException.ERROR_SEVERITY); 993 } 994 if (curRowMarkEntry.getMarkStart() != -1) { 995 PortletBean portlet = (PortletBean) this.getPosPortlet(j, i); 996 if (portlet != null) { 997 boolean hasSpace = true; 1000 for (int k=0; k < increment; k++) { 1001 for (int l=0; l < portlet.getPortletH(); l++) { 1002 PortletBean posPortlet = 1003 (PortletBean) this.getPortletFromRefTable( 1004 portlet.getPortletRow() + l, 1005 portlet.getPortletColumn() - increment+k); 1006 if (posPortlet != null) { 1007 hasSpace = false; 1008 } 1009 } 1010 } 1011 if (hasSpace) { 1012 portlet.setPortletColumn(portlet.getPortletColumn()-increment); 1013 } 1014 } 1015 } 1016 } 1017 } 1018 1019 rebuildGridTable(); 1020 markedRowList = null; 1021 } 1022 1023 1036 public void movePortletUp(int portletID) 1037 throws JahiaException { 1038 PortletBean targetPortlet = findPortlet(portletID); 1039 int currentWidth = targetPortlet.getPortletW(); 1040 int currentHeight = targetPortlet.getPortletH(); 1041 int oldRow = targetPortlet.getPortletRow(); 1042 int oldColumn = targetPortlet.getPortletColumn(); 1043 if (targetPortlet.getPortletRow() == 0) { 1044 } else { 1046 1047 if (swapPortletUp(portletID)) { 1048 return; 1049 } 1050 boolean enoughFreeSpace = true; 1055 for (int i=0; i < currentWidth; i++) { 1056 PortletBean tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() - 1, 1057 targetPortlet.getPortletColumn()+i); 1058 if (tempPortlet != null) { 1059 enoughFreeSpace = false; 1060 } 1061 } 1062 if (!enoughFreeSpace) { 1063 1069 int destRowColumnCount = 0; 1072 for (int i=0; i < currentHeight; i++) { 1073 if (this.getColumnCount(targetPortlet.getPortletRow()-1+i) > destRowColumnCount) { 1074 destRowColumnCount = this.getColumnCount(targetPortlet.getPortletRow()-1+i); 1075 } 1076 } 1077 targetPortlet.setPortletRow(targetPortlet.getPortletRow()-1); 1078 targetPortlet.setPortletColumn(destRowColumnCount); 1079 } else { 1080 targetPortlet.setPortletRow(targetPortlet.getPortletRow()-1); 1081 } 1082 rebuildGridTable(); 1083 for (int i=0; i < currentWidth; i++) { 1086 1087 PortletBean tempPortlet = null; 1088 if (areCoordinatesValid(oldRow + currentHeight - 1, targetPortlet.getPortletColumn() + i) ) { 1089 tempPortlet = (PortletBean) portletTable.getElementAt(oldRow + currentHeight -1 , 1090 targetPortlet.getPortletColumn()+i); 1091 if (tempPortlet == null) { 1092 this.findHorizontalEdgeForMoving(targetPortlet.getPortletColumn()+i, oldRow + currentHeight -1); 1093 this.moveColumnsUp(1, targetPortlet.getPortletColumn()+i); 1094 } 1095 } 1096 } 1097 rebuildGridTable(); 1098 } 1099 } 1100 1101 1106 public void movePortletDown(int portletID) 1107 throws JahiaException { 1108 PortletBean targetPortlet = findPortlet(portletID); 1109 int currentWidth = targetPortlet.getPortletW(); 1110 int currentHeight = targetPortlet.getPortletH(); 1111 if (targetPortlet.getPortletRow() + targetPortlet.getPortletH() == this.getRowCount(targetPortlet.getPortletColumn())) { 1112 rowCount++; 1114 portletTable.setEmptyElementAt(targetPortlet.getPortletRow()+1, targetPortlet.getPortletColumn()); 1115 } 1116 1117 if (swapPortletDown(portletID)) { 1118 return; 1119 } 1120 boolean enoughFreeSpace = true; 1125 for (int i=0; i < currentWidth; i++) { 1126 PortletBean tempPortlet = null; 1127 if (areCoordinatesValid(targetPortlet.getPortletRow() + targetPortlet.getPortletH(), 1128 targetPortlet.getPortletColumn()+i) ) { 1129 tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + targetPortlet.getPortletH(), 1130 targetPortlet.getPortletColumn()+i); 1131 } 1132 if (tempPortlet != null) { 1133 enoughFreeSpace = false; 1134 } 1135 } 1136 if (!enoughFreeSpace) { 1137 for (int i=0; i < currentWidth; i++) { 1138 PortletBean tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + 1, 1139 targetPortlet.getPortletColumn()+i); 1140 if (tempPortlet != null) { 1141 this.findHorizontalEdgeForMoving(targetPortlet.getPortletColumn()+i, targetPortlet.getPortletRow() + currentHeight); 1142 this.moveColumnsDown(1); 1143 } 1144 } 1145 targetPortlet.setPortletRow(targetPortlet.getPortletRow()+1); 1146 } else { 1147 targetPortlet.setPortletRow(targetPortlet.getPortletRow()+1); 1148 } 1149 rebuildGridTable(); 1152 } 1153 1154 1161 public void movePortletLeft(int portletID) 1162 throws JahiaException { 1163 PortletBean targetPortlet = findPortlet(portletID); 1164 int oldRow = targetPortlet.getPortletRow(); 1165 int oldColumn = targetPortlet.getPortletColumn(); 1166 if (targetPortlet.getPortletColumn() == 0) { 1167 1171 } else { 1172 1173 1175 int insertionRow = targetPortlet.getPortletRow(); 1176 int insertionColumn = targetPortlet.getPortletColumn() - 1; 1177 1181 if (targetPortlet.getPortletRow() >= getRowCountWithoutPortlet(targetPortlet.getPortletColumn() - 1, targetPortlet.getPortletID()) ) { 1182 insertionRow = getRowCountWithoutPortlet(targetPortlet.getPortletColumn() - 1, targetPortlet.getPortletID()); 1183 } else { 1184 PortletBean testPortlet = (PortletBean) this.portletTable.getElementAt(targetPortlet.getPortletRow(), 1185 targetPortlet.getPortletColumn()-1); 1186 if (testPortlet != null) { 1187 if (testPortlet.getPortletRow() == targetPortlet.getPortletRow() ) { 1188 if (testPortlet.getPortletColumn() != targetPortlet.getPortletColumn() - 1) { 1192 insertionColumn = testPortlet.getPortletColumn(); 1195 } 1196 } else { 1197 insertionRow = testPortlet.getPortletRow() + testPortlet.getPortletH(); 1200 } 1202 } 1203 1204 } 1205 1206 boolean enoughFreeSpace = true; 1208 for (int i=0; i < targetPortlet.getPortletH(); i++) { 1209 PortletBean tempPortlet = (PortletBean) portletTable.getElementAt(insertionRow + i, 1210 targetPortlet.getPortletColumn()-1); 1211 if (tempPortlet != null) { 1212 enoughFreeSpace = false; 1213 } 1214 } 1215 if (!enoughFreeSpace) { 1216 this.findHorizontalEdgeForMoving(insertionColumn, insertionRow); 1217 debugDisplayMarkedList("markedColumnList", markedColumnList); 1218 this.moveColumnsDown(targetPortlet.getPortletH()); 1219 } 1220 1221 targetPortlet.setPortletRow(insertionRow); 1223 targetPortlet.setPortletColumn(targetPortlet.getPortletColumn()-1); 1224 1225 rebuildGridTable(); 1226 1227 1229 if (oldColumn + targetPortlet.getPortletW() <= getColumnCount() ) { 1230 this.findHorizontalEdgeForMoving(oldColumn + targetPortlet.getPortletW() -1, oldRow); 1231 debugDisplayMarkedList("markedColumnList", markedColumnList); 1232 this.moveColumnsUp(targetPortlet.getPortletH(), oldColumn + targetPortlet.getPortletW() -1 ); 1233 } 1234 1235 rebuildGridTable(); 1236 1237 } 1238 } 1239 1240 1247 public void movePortletRight(int portletID) 1248 throws JahiaException { 1249 1250 PortletBean targetPortlet = findPortlet(portletID); 1251 int oldRow = targetPortlet.getPortletRow(); 1252 int oldColumn = targetPortlet.getPortletColumn(); 1253 if (oldColumn + targetPortlet.getPortletW() == getColumnCount()) { 1254 columnCount++; 1257 portletTable.setEmptyElementAt(targetPortlet.getPortletRow(), targetPortlet.getPortletColumn()+1); 1258 } 1259 1260 1262 int insertionRow = targetPortlet.getPortletRow(); 1263 int insertionColumn = targetPortlet.getPortletColumn() + 1; 1264 1268 if (targetPortlet.getPortletRow() >= getRowCountWithoutPortlet(targetPortlet.getPortletColumn() + 1, targetPortlet.getPortletID()) ) { 1269 insertionRow = getRowCountWithoutPortlet(targetPortlet.getPortletColumn() + 1, targetPortlet.getPortletID()); 1270 } else { 1271 PortletBean testPortlet = null; 1272 if ( areCoordinatesValid(targetPortlet.getPortletRow(), 1273 targetPortlet.getPortletColumn()+targetPortlet.getPortletW())) { 1274 testPortlet = (PortletBean) this.portletTable.getElementAt(targetPortlet.getPortletRow(), 1275 targetPortlet.getPortletColumn()+targetPortlet.getPortletW()); 1276 } 1277 if (testPortlet != null) { 1278 if (testPortlet.getPortletRow() == targetPortlet.getPortletRow() ) { 1279 if (testPortlet.getPortletColumn() != targetPortlet.getPortletColumn() + 1) { 1283 insertionColumn = testPortlet.getPortletColumn(); 1286 } 1287 } else { 1288 insertionRow = testPortlet.getPortletRow() + testPortlet.getPortletH(); 1291 } 1293 } 1294 1295 } 1296 1297 boolean enoughFreeSpace = true; 1299 for (int i=0; i < targetPortlet.getPortletH(); i++) { 1300 PortletBean tempPortlet = null; 1301 if ( areCoordinatesValid(insertionRow + i, 1302 targetPortlet.getPortletColumn()+targetPortlet.getPortletW()) ) { 1303 tempPortlet = (PortletBean) portletTable.getElementAt(insertionRow + i, 1304 targetPortlet.getPortletColumn()+targetPortlet.getPortletW()); 1305 } 1306 if (tempPortlet != null) { 1307 enoughFreeSpace = false; 1308 break; 1309 } 1310 } 1311 if (!enoughFreeSpace) { 1312 1313 for (int i=0; i < targetPortlet.getPortletW(); i++) { 1314 this.findHorizontalEdgeForMoving(insertionColumn+i, insertionRow); 1315 } 1316 this.moveColumnsDown(targetPortlet.getPortletH()); 1317 } 1318 1319 targetPortlet.setPortletRow(insertionRow); 1321 targetPortlet.setPortletColumn(targetPortlet.getPortletColumn()+1); 1322 1323 rebuildGridTable(); 1324 1325 1327 if (oldColumn < getColumnCount() ) { 1328 this.findHorizontalEdgeForMoving(oldColumn, oldRow + targetPortlet.getPortletH()); 1329 this.debugDisplayMarkedList("markedColumnList", markedColumnList); 1330 this.moveColumnsUp(targetPortlet.getPortletH(), oldColumn); 1331 } 1332 1333 rebuildGridTable(); 1334 } 1335 1336 1340 1343 1344 1350 public boolean canSwapPortletUp(int portletID) { 1351 PortletBean targetPortlet = null; 1352 try { 1353 targetPortlet = findPortlet(portletID); 1354 } catch (JahiaException je) { 1355 return false; 1356 } 1357 if (targetPortlet.getPortletRow() == 0) { 1358 return false; 1360 } 1361 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() - 1, 1362 targetPortlet.getPortletColumn()); 1363 if (portletToSwap != null) { 1364 if ( (portletToSwap.getPortletRow() == targetPortlet.getPortletRow() - portletToSwap.getPortletH()) && 1367 (portletToSwap.getPortletColumn() == targetPortlet.getPortletColumn()) ) { 1368 if (targetPortlet.getPortletW() == portletToSwap.getPortletW() ) { 1370 return true; 1371 } 1372 } 1373 } 1374 return false; 1375 } 1376 1377 1383 public boolean canSwapPortletDown(int portletID) { 1384 PortletBean targetPortlet = null; 1385 try { 1386 targetPortlet = findPortlet(portletID); 1387 if (targetPortlet.getPortletRow() + targetPortlet.getPortletH() == this.getRowCount(targetPortlet.getPortletColumn())) { 1388 return false; 1390 } 1391 } catch (JahiaException je) { 1392 return false; 1393 } 1394 1395 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + targetPortlet.getPortletH(), 1396 targetPortlet.getPortletColumn()); 1397 if (portletToSwap != null) { 1398 if (targetPortlet.getPortletW() == portletToSwap.getPortletW() ) { 1401 return true; 1402 } 1403 } 1404 return false; 1405 } 1406 1407 1413 public boolean canSwapPortletLeft(int portletID) { 1414 PortletBean targetPortlet = null; 1415 try { 1416 targetPortlet = findPortlet(portletID); 1417 } catch (JahiaException je) { 1418 return false; 1419 } 1420 if (targetPortlet.getPortletColumn() == 0) { 1421 return false; 1423 } 1424 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow(), 1425 targetPortlet.getPortletColumn() -1); 1426 if (portletToSwap != null) { 1427 if ( (portletToSwap.getPortletColumn() == targetPortlet.getPortletColumn() - portletToSwap.getPortletW()) && 1430 (portletToSwap.getPortletRow() == targetPortlet.getPortletRow()) ) { 1431 if (targetPortlet.getPortletH() == portletToSwap.getPortletH() ) { 1433 return true; } 1435 } 1436 } 1437 return false; 1438 } 1439 1440 1446 public boolean canSwapPortletRight(int portletID) { 1447 PortletBean targetPortlet = null; 1448 try { 1449 targetPortlet = findPortlet(portletID); 1450 if (targetPortlet.getPortletColumn() + targetPortlet.getPortletW() == this.getColumnCount(targetPortlet.getPortletRow())) { 1451 return false; 1453 } 1454 } catch (JahiaException je) { 1455 return false; 1456 } 1457 1458 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow(), 1459 targetPortlet.getPortletColumn() + targetPortlet.getPortletW()); 1460 if (portletToSwap != null) { 1461 if (targetPortlet.getPortletH() == portletToSwap.getPortletH() ) { 1465 return true; 1466 } 1467 } 1468 return false; 1469 } 1470 1471 1478 public boolean swapPortletLeft(int portletID) 1479 throws JahiaException { 1480 if (!canSwapPortletLeft(portletID)) { 1481 return false; 1482 } 1483 PortletBean targetPortlet = findPortlet(portletID); 1484 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow(), 1485 targetPortlet.getPortletColumn() - 1); 1486 int swapColumn = portletToSwap.getPortletColumn(); 1487 portletToSwap.setPortletColumn(swapColumn + targetPortlet.getPortletW()); 1488 targetPortlet.setPortletColumn(swapColumn); 1489 rebuildGridTable(); 1490 return true; 1491 1492 } 1493 1494 1501 public boolean swapPortletRight(int portletID) 1502 throws JahiaException { 1503 if (!canSwapPortletRight(portletID)) { 1504 return false; 1505 } 1506 PortletBean targetPortlet = findPortlet(portletID); 1507 1508 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow(), 1509 targetPortlet.getPortletColumn() + targetPortlet.getPortletW()); 1510 int swapColumn = targetPortlet.getPortletColumn(); 1511 portletToSwap.setPortletColumn(swapColumn); 1512 targetPortlet.setPortletColumn(swapColumn + targetPortlet.getPortletW()); 1513 rebuildGridTable(); 1514 return true; 1515 } 1516 1517 1524 public boolean swapPortletUp(int portletID) 1525 throws JahiaException { 1526 if (!canSwapPortletUp(portletID)) { 1527 return false; 1528 } 1529 PortletBean targetPortlet = findPortlet(portletID); 1530 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() - 1, 1531 targetPortlet.getPortletColumn()); 1532 int swapRow = portletToSwap.getPortletRow(); 1533 portletToSwap.setPortletRow(swapRow + targetPortlet.getPortletH()); 1534 targetPortlet.setPortletRow(swapRow); 1535 rebuildGridTable(); 1536 return true; 1537 } 1538 1539 1546 public boolean swapPortletDown(int portletID) 1547 throws JahiaException { 1548 if (!canSwapPortletDown(portletID)) { 1549 return false; 1550 } 1551 PortletBean targetPortlet = findPortlet(portletID); 1552 PortletBean portletToSwap = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + targetPortlet.getPortletH(), 1553 targetPortlet.getPortletColumn()); 1554 int swapRow = targetPortlet.getPortletRow(); 1555 portletToSwap.setPortletRow(swapRow); 1556 targetPortlet.setPortletRow(swapRow + targetPortlet.getPortletH()); 1557 rebuildGridTable(); 1558 return true; 1559 } 1560 1561 1566 public void IncreaseHeight(int portletID) 1567 throws JahiaException { 1568 PortletBean targetPortlet = findPortlet(portletID); 1569 int currentHeight = targetPortlet.getPortletH(); 1570 int currentWidth = targetPortlet.getPortletW(); 1571 boolean enoughFreeSpace = true; 1575 if (targetPortlet.getPortletRow() + currentHeight < getRowCount() ) { 1576 for (int i=0; i < currentWidth; i++) { 1579 PortletBean tempPortlet = null; 1580 if ( areCoordinatesValid(targetPortlet.getPortletRow() + currentHeight, 1581 targetPortlet.getPortletColumn()+i) ) { 1582 tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + currentHeight, 1583 targetPortlet.getPortletColumn()+i); 1584 } 1585 if (tempPortlet != null) { 1586 enoughFreeSpace = false; 1587 this.findHorizontalEdgeForMoving(targetPortlet.getPortletColumn()+i, 1588 targetPortlet.getPortletRow() + currentHeight); 1589 } 1590 } 1591 } 1592 if (!enoughFreeSpace) { 1593 debugDisplayMarkedList("markedColumnList", markedColumnList); 1594 this.moveColumnsDown(1); 1595 } 1596 targetPortlet.setPortletH(currentHeight + 1); 1598 this.rebuildGridTable(); 1599 } 1600 1601 1606 public void DecreaseHeight(int portletID) 1607 throws JahiaException { 1608 PortletBean targetPortlet = findPortlet(portletID); 1609 int currentHeight = targetPortlet.getPortletH(); 1610 int currentWidth = targetPortlet.getPortletW(); 1611 if (currentHeight > 0) { 1612 targetPortlet.setPortletH(currentHeight - 1); 1613 } 1614 this.rebuildGridTable(); 1615 for (int i=0; i < currentWidth; i++) { 1617 PortletBean tempPortlet = null; 1618 if ( areCoordinatesValid(targetPortlet.getPortletRow() + currentHeight, 1619 targetPortlet.getPortletColumn()+ i) ) { 1620 tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + currentHeight, 1621 targetPortlet.getPortletColumn()+i); 1622 if (tempPortlet != null) { 1623 this.findHorizontalEdgeForMoving(targetPortlet.getPortletColumn()+i, 1624 targetPortlet.getPortletRow() + currentHeight); 1625 this.moveColumnsUp(1, targetPortlet.getPortletColumn()+i); 1626 } 1627 } 1628 } 1629 this.rebuildGridTable(); 1630 } 1631 1632 1637 public void IncreaseWidth(int portletID) 1638 throws JahiaException { 1639 PortletBean targetPortlet = findPortlet(portletID); 1640 int currentHeight = targetPortlet.getPortletH(); 1641 int currentWidth = targetPortlet.getPortletW(); 1642 boolean enoughFreeSpace = true; 1646 if (targetPortlet.getPortletColumn() + currentWidth < getColumnCount() ) { 1647 for (int i=0; i < currentHeight; i++) { 1649 PortletBean tempPortlet = null; 1650 if ( areCoordinatesValid(targetPortlet.getPortletRow() + i, 1651 targetPortlet.getPortletColumn()+ currentWidth) ) { 1652 tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + i, 1653 targetPortlet.getPortletColumn()+ currentWidth); 1654 } 1655 if (tempPortlet != null) { 1656 enoughFreeSpace = false; 1657 this.findVerticalEdgeForMoving(targetPortlet.getPortletRow() +i, 1658 targetPortlet.getPortletColumn()+ currentWidth); 1659 } 1660 } 1661 } 1662 if (!enoughFreeSpace) { 1663 debugDisplayMarkedList("markedRowList", markedRowList); 1664 this.moveRowsRight(1); 1665 } 1666 targetPortlet.setPortletW(currentWidth + 1); 1668 this.rebuildGridTable(); 1669 1670 } 1671 1672 1677 public void DecreaseWidth(int portletID) 1678 throws JahiaException { 1679 PortletBean targetPortlet = findPortlet(portletID); 1680 int currentHeight = targetPortlet.getPortletH(); 1681 int currentWidth = targetPortlet.getPortletW(); 1682 if (currentWidth > 0) { 1683 targetPortlet.setPortletW(currentWidth - 1); 1684 } 1685 rebuildGridTable(); 1686 for (int i=0; i < currentHeight; i++) { 1689 if (areCoordinatesValid(targetPortlet.getPortletRow()+i, 1690 targetPortlet.getPortletColumn() + currentWidth) ) { 1691 PortletBean tempPortlet = (PortletBean) portletTable.getElementAt(targetPortlet.getPortletRow() + i, 1692 targetPortlet.getPortletColumn()+ currentWidth); 1693 if (tempPortlet != null) { 1694 this.findVerticalEdgeForMoving(targetPortlet.getPortletRow() + i, 1695 targetPortlet.getPortletColumn()+ currentWidth); 1696 this.debugDisplayMarkedList("markedRowList", markedRowList); 1697 this.moveRowsLeft(1, targetPortlet.getPortletRow()+i); 1698 } 1699 } 1700 } 1701 this.rebuildGridTable(); 1702 } 1703 1704 1705 1712 public void debugDisplayGrid() { 1713 String separatorLine = new String (); 1714 for (int j=0; j < this.getColumnCount(); j++) { 1715 separatorLine = separatorLine + "+-----"; 1716 } 1717 1718 StringBuffer curLine; 1719 String idStr = ""; 1720 for (int i=0; i < this.getRowCount(); i++) { 1721 curLine = new StringBuffer (); 1722 curLine = new StringBuffer (); 1723 for (int j=0; j < this.getColumnCount(); j++) { 1724 PortletBean curPortlet = this.getPortletFromRefTable(i, j); 1725 curLine.append("�"); 1726 if (curPortlet != null) { 1727 idStr = Integer.toString(curPortlet.getPortletID()); 1728 while (idStr.length() < 5) { 1729 idStr = " " + idStr; 1730 } 1731 } else { 1732 idStr = " null"; 1733 } 1734 curLine.append(idStr); 1735 } 1736 JahiaConsole.println("PortletBeanGrid.debugDisplayGrid", separatorLine); 1737 JahiaConsole.println("PortletBeanGrid.debugDisplayGrid", 1738 curLine.toString()); 1739 } 1740 } 1741 1742 1743 1751 private boolean areCoordinatesValid(int row, int column) { 1752 if (isRowCoordinateValid(row) && isColumnCoordinateValid(column) ) { 1753 return true; 1754 } 1755 return false; 1756 } 1757 1758 1765 private boolean isRowCoordinateValid(int row) { 1766 if ((row >= 0) && (row < portletTable.getRowCount())) { 1767 return true; 1768 } 1769 return false; 1770 } 1771 1772 1779 private boolean isColumnCoordinateValid(int column) { 1780 if ((column >= 0) && (column < portletTable.getColumnCount())) { 1781 return true; 1782 } 1783 return false; 1784 } 1785 1786 1787} | Popular Tags |