0001: // @@
0002: // @@
0003: /*
0004: * Wi.Ser Framework
0005: *
0006: * Version: 1.8.1, 20-September-2007
0007: * Copyright (C) 2005 Dirk von der Weiden <dvdw@imail.de>
0008: *
0009: * This library is free software; you can redistribute it and/or
0010: * modify it under the terms of the GNU Lesser General Public
0011: * License as published by the Free Software Foundation; either
0012: * version 2 of the License, or (at your option) any later version.
0013: *
0014: * This library is distributed in the hope that it will be useful,
0015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
0016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
0017: * Lesser General Public License for more details.
0018: *
0019: * You should have received a copy of the GNU Lesser General Public
0020: * License along with this library located in LGPL.txt in the
0021: * license directory; if not, write to the
0022: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0023: * Boston, MA 02111-1307, USA.
0024: *
0025: * If this agreement does not cover your requirements, please contact us
0026: * via email to get detailed information about the commercial license
0027: * or our service offerings!
0028: *
0029: */
0030: // @@
0031: package de.ug2t.channel.markup.generic;
0032:
0033: import java.util.*;
0034:
0035: import de.ug2t.channel.ho.*;
0036: import de.ug2t.channel.markup.html.renderer.*;
0037: import de.ug2t.connector.*;
0038: import de.ug2t.kernel.*;
0039: import de.ug2t.unifiedGui.*;
0040: import de.ug2t.unifiedGui.interfaces.*;
0041:
0042: public final class MuGenericTable extends MuGenericComponent implements
0043: IUnTable, IKePoolable {
0044: private ArrayList pem_rowCollect = null;
0045:
0046: private IKeView pem_view = new HtmlTableRenderer();
0047:
0048: protected int pdm_spacing = 0;
0049: protected int pdm_padding = 0;
0050: protected int pdm_tableBorder = 1;
0051: protected boolean pdm_sel = false;
0052: protected boolean pdm_nsSel = false;
0053: protected int pdm_locked = -1;
0054:
0055: protected boolean pdm_multiSelection = false;
0056: protected HoGenericDataContainer pdm_container = null;
0057: protected ArrayList pdm_selectors = null;
0058: private IUnGuiEventListener pem_msListener = null;
0059: protected MuGenericScrollController pdm_scrCrt = null;
0060: private IKeExecutable pem_cHandler = null;
0061:
0062: protected class MuTableMultiSelectListener implements
0063: IUnGuiEventListener {
0064: public void pcmf_execListener(UnComponent xParam)
0065: throws Exception {
0066: if (((MuGenericCheckBox) xParam).pcmf_getValue().equals(
0067: "CHECKED")) {
0068: String l_row = Integer
0069: .toString(MuGenericTable.this .pdm_selectors
0070: .indexOf(xParam));
0071: if (MuGenericTable.this .pdm_container
0072: .pcmf_contains(l_row) == false)
0073: MuGenericTable.this .pdm_container
0074: .pcmf_addValue(l_row);
0075: } else
0076: MuGenericTable.this .pdm_container
0077: .pcmf_removeValue(Integer
0078: .toString(MuGenericTable.this .pdm_selectors
0079: .indexOf(xParam)));
0080:
0081: MuGenericTable.this .pcmf_setRefresh();
0082:
0083: if (MuGenericTable.this .pcmf_getDifferentialRepaint()) {
0084: MuGenericTable.this .pdmf_setPropChanged(true);
0085: MuGenericTable.this
0086: .pcmf_refreshMultiValue(MuGenericTable.this .pdm_container);
0087: } else
0088: MuGenericTable.this .pcmf_setPropChanged(true);
0089:
0090: if (!xParam.pcmf_getAppl().pcmf_isEventBubbling())
0091: MuGenericTable.this .pcmf_dispatchEvent();
0092:
0093: return;
0094: }
0095: }
0096:
0097: public boolean pcmf_setMultiSelection(boolean xMulti) {
0098: boolean l_old = this .pdm_multiSelection;
0099:
0100: if (this .pdm_container == null && xMulti == true) {
0101: this .pdm_container = new HoGenericDataContainer();
0102: this .pdm_selectors = new ArrayList();
0103: this .pem_msListener = new MuTableMultiSelectListener();
0104: }
0105: ;
0106:
0107: this .pdm_multiSelection = xMulti;
0108:
0109: return (l_old);
0110: };
0111:
0112: public boolean pcmf_isMultiSelection() {
0113: return (this .pdm_multiSelection);
0114: }
0115:
0116: public HoGenericDataContainer pcmf_getValues() {
0117: return (this .pdm_container);
0118: }
0119:
0120: public void pcmf_setValues(HoGenericDataContainer xValues) {
0121: this .pcmf_setValue(xValues);
0122: }
0123:
0124: public boolean pcmf_isNonScrollingSelectors() {
0125: return (this .pdm_nsSel);
0126: }
0127:
0128: public void pcmf_setNonScrollingSelectors(boolean xNsSel) {
0129: this .pdm_nsSel = xNsSel;
0130: }
0131:
0132: public MuGenericTable(String xName, Collection xRows, boolean xSel,
0133: ACoDataGetter xTplGetter, Object xTplName,
0134: MuGenericApplication xAppl) throws Exception {
0135: super (xName, xTplGetter, xTplName, xAppl);
0136: this .pdm_scrCrt = new MuGenericScrollController("myscrcrt",
0137: this );
0138:
0139: pem_rowCollect = new ArrayList();
0140: pdm_sel = xSel;
0141:
0142: this .pcmf_setView(pem_view);
0143: this .pcmf_setValue("0");
0144: this .pcmf_setBgColor("white");
0145: this .pcmf_setFill(true, true);
0146: this .pdm_getMaxSpace = true;
0147:
0148: if (xRows != null) {
0149: Iterator rowIt = xRows.iterator();
0150: MuGenericTableRow newrow = null;
0151: Collection oldrow = null;
0152:
0153: while (rowIt.hasNext()) {
0154: Iterator cellIt = null;
0155:
0156: oldrow = (Collection) rowIt.next();
0157: newrow = new MuGenericTableRow(new ArrayList(), this
0158: .pcmf_getBgColor(), "", "");
0159:
0160: cellIt = oldrow.iterator();
0161:
0162: while (cellIt.hasNext())
0163: newrow.pem_items.add(new MuGenericTableCell(cellIt
0164: .next(), this .pcmf_getBgColor(), this
0165: .pcmf_getFgColor(), null, ""));
0166:
0167: pem_rowCollect.add(newrow);
0168: }
0169: ;
0170:
0171: this .pcmf_commitTable();
0172: }
0173: ;
0174:
0175: return;
0176: };
0177:
0178: // @@
0179:
0180: public int pcmf_getSpacing() {
0181: return (this .pdm_spacing);
0182: }
0183:
0184: public void pcmf_setSpacing(int xSpace) {
0185: if (this .pdm_spacing == xSpace)
0186: return;
0187:
0188: pdm_spacing = xSpace;
0189: this .pcmf_setPropChanged(true);
0190:
0191: return;
0192: };
0193:
0194: public void pcmf_setCellBgColor(int xRow, int xCol, String xColor) {
0195: try {
0196: MuGenericTableCell l_cell = this .pcmf_getCell(xRow, xCol);
0197: Object l_obj = l_cell.pcmf_getItem();
0198: if (l_obj instanceof IUnLabel)
0199: ((IUnLabel) l_obj).pcmf_setBgColor(xColor);
0200:
0201: l_cell.pcmf_setBgColor(xColor);
0202: this .pcmf_setPropChanged(true);
0203: } catch (Exception e) {
0204: KeLog.pcmf_logException("ug2t", e, e);
0205: }
0206: }
0207:
0208: public void pcmf_setCellCssClass(int xRow, int xCol, String xClass) {
0209: try {
0210: MuGenericTableCell l_cell = this .pcmf_getCell(xRow, xCol);
0211: l_cell.pcmf_setClass(xClass);
0212:
0213: this .pcmf_setPropChanged(true);
0214: } catch (Exception e) {
0215: KeLog.pcmf_logException("ug2t", e, e);
0216: }
0217: }
0218:
0219: public void pcmf_setCellFgColor(int xRow, int xCol, String xColor) {
0220: try {
0221: MuGenericTableCell l_cell = this .pcmf_getCell(xRow, xCol);
0222: Object l_obj = l_cell.pcmf_getItem();
0223: if (l_obj instanceof IUnLabel)
0224: ((IUnLabel) l_obj).pcmf_setBgColor(xColor);
0225:
0226: l_cell.pcmf_setFgColor(xColor);
0227: this .pcmf_setPropChanged(true);
0228: } catch (Exception e) {
0229: KeLog.pcmf_logException("ug2t", e, e);
0230: }
0231: }
0232:
0233: private void pemf_unlock(int xCol) {
0234: try {
0235: int l_len = this .pem_rowCollect.size();
0236: for (int i = 0; i < l_len; i++) {
0237: MuGenericTableCell l_cell = this .pcmf_getCell(i, xCol);
0238: l_cell.pcmf_setXDirStatic(false);
0239: }
0240: } catch (Exception e) {
0241: KeLog.pcmf_log("ug2t", "error unlocking column: "
0242: + this .pdm_locked + " it is not available", this ,
0243: KeLog.MESSAGE);
0244: }
0245: }
0246:
0247: private void pemf_lock() {
0248: try {
0249: if (this .pdm_locked == -1)
0250: return;
0251:
0252: int l_len = this .pem_rowCollect.size();
0253: for (int i = 0; i < l_len; i++) {
0254: MuGenericTableCell l_cell = this .pcmf_getCell(i,
0255: this .pdm_locked);
0256: l_cell.pcmf_setXDirStatic(true);
0257: }
0258: } catch (Exception e) {
0259: KeLog.pcmf_log("ug2t", "cannot lock column: "
0260: + this .pdm_locked + " it is not available", this ,
0261: KeLog.DEBUG);
0262: }
0263: }
0264:
0265: public void pcmf_lockColumn(int xCol, boolean xLock) {
0266: if (xLock)
0267: this .pcmf_setNonScrollingSelectors(true);
0268:
0269: if (this .pdm_locked != -1)
0270: this .pemf_unlock(this .pdm_locked);
0271:
0272: if (xLock)
0273: this .pdm_locked = xCol;
0274: else
0275: this .pdm_locked = -1;
0276: }
0277:
0278: public void pcmf_setCellBorder(int xRow, int xCol, int xDir,
0279: String xColor, int xWidth, int xStyle) {
0280: try {
0281: this .pcmf_getCell(xRow, xCol).pcmf_getCreateBoxStyle()
0282: .pcmf_setBorder(xDir, xColor, xWidth, xStyle);
0283: this .pcmf_setPropChanged(true);
0284: } catch (Exception e) {
0285: KeLog.pcmf_logException("ug2t", e, e);
0286: }
0287: }
0288:
0289: public void pcmf_setCellPadding(int xRow, int xCol, int xDir,
0290: int xWidth) {
0291: try {
0292: this .pcmf_getCell(xRow, xCol).pcmf_getCreateBoxStyle()
0293: .pcmf_setPadding(xDir, xWidth);
0294: this .pcmf_setPropChanged(true);
0295: } catch (Exception e) {
0296: KeLog.pcmf_logException("ug2t", e, e);
0297: }
0298: }
0299:
0300: public void pcmf_setCellMargin(int xRow, int xCol, int xDir,
0301: int xWidth) {
0302: try {
0303: this .pcmf_getCell(xRow, xCol).pcmf_getCreateBoxStyle()
0304: .pcmf_setMargin(xDir, xWidth);
0305: this .pcmf_setPropChanged(true);
0306: } catch (Exception e) {
0307: KeLog.pcmf_logException("ug2t", e, e);
0308: }
0309: }
0310:
0311: public void pcmf_setCellAlign(int xRow, int xCol, String xAlign) {
0312: try {
0313: this .pcmf_getCell(xRow, xCol).pcmf_getCreateBoxStyle()
0314: .pcmf_setAlign(xAlign);
0315: this .pcmf_setPropChanged(true);
0316: } catch (Exception e) {
0317: KeLog.pcmf_logException("ug2t", e, e);
0318: }
0319: }
0320:
0321: public int pcmf_getPadding() {
0322: return (this .pdm_padding);
0323: }
0324:
0325: public void pcmf_setPadding(int xPad) {
0326: if (this .pdm_padding == xPad)
0327: return;
0328:
0329: pdm_padding = xPad;
0330: this .pcmf_setPropChanged(true);
0331:
0332: return;
0333: };
0334:
0335: public int pcmf_getTableBorder() {
0336: return (this .pdm_tableBorder);
0337: }
0338:
0339: public void pcmf_setTableBorder(int xBorder) {
0340: if (this .pdm_tableBorder == xBorder)
0341: return;
0342:
0343: pdm_tableBorder = xBorder;
0344: this .pcmf_setPropChanged(true);
0345:
0346: return;
0347: };
0348:
0349: public int pcmf_getRowCount() {
0350: return (this .pem_rowCollect.size());
0351: }
0352:
0353: public Iterator pcmf_getRows() {
0354: return (this .pem_rowCollect.iterator());
0355: };
0356:
0357: public MuGenericTableRow pcmf_getRow(int xRow) {
0358: return ((MuGenericTableRow) pem_rowCollect.get(xRow));
0359: };
0360:
0361: public void pcmf_hideRow(int xRow) {
0362: ((MuGenericTableRow) pem_rowCollect.get(xRow)).pem_hide = true;
0363: this .pcmf_setPropChanged(true);
0364: };
0365:
0366: public boolean pcmf_isHiddenRow(int xRow) {
0367: return (((MuGenericTableRow) pem_rowCollect.get(xRow)).pem_hide);
0368: }
0369:
0370: public void pcmf_unHideRow(int xRow) {
0371: ((MuGenericTableRow) pem_rowCollect.get(xRow)).pem_hide = false;
0372: this .pcmf_setPropChanged(true);
0373: };
0374:
0375: public MuGenericTableCell pcmf_getCell(int xRow, int xCol) {
0376: MuGenericTableRow l_tabRow = (MuGenericTableRow) pem_rowCollect
0377: .get(xRow);
0378: MuGenericTableCell l_obj = null;
0379: ArrayList l_row = l_tabRow.pem_items;
0380:
0381: l_obj = (MuGenericTableCell) l_row.get(xCol);
0382:
0383: return (l_obj);
0384: };
0385:
0386: public Object pcmf_getCellValue(int xRow, int xCol) {
0387: MuGenericTableRow l_tabRow = (MuGenericTableRow) pem_rowCollect
0388: .get(xRow);
0389: MuGenericTableCell l_obj = null;
0390: ArrayList l_row = l_tabRow.pem_items;
0391:
0392: l_obj = (MuGenericTableCell) l_row.get(xCol);
0393:
0394: return (l_obj.pdm_item);
0395: };
0396:
0397: public void pcmf_setRowsOnly(Collection xRows) {
0398: Iterator l_it = this .pcmf_getValueArray(true).iterator();
0399: ArrayList l_new = new ArrayList();
0400:
0401: l_new.add(l_it.next());
0402: l_new.addAll(xRows);
0403:
0404: this .pcmf_refresh(l_new);
0405:
0406: return;
0407: }
0408:
0409: public void pcmf_addRows(Collection xRow) {
0410: ArrayList l_new = null;
0411:
0412: if (this .pem_rowCollect == null) {
0413: l_new = new ArrayList();
0414: } else {
0415: l_new = this .pcmf_getValueArray(true);
0416: }
0417: l_new.addAll(xRow);
0418:
0419: this .pcmf_refresh(l_new);
0420:
0421: return;
0422: }
0423:
0424: public void pcmf_setRowsOnly(KeTable xRows) {
0425: Iterator l_it = this .pcmf_getValueArray(true).iterator();
0426: ArrayList l_new = new ArrayList();
0427:
0428: l_new.add(l_it.next());
0429: l_new.addAll(xRows.pcmf_getTableValues());
0430:
0431: this .pcmf_refresh(l_new);
0432:
0433: return;
0434: }
0435:
0436: public void pcmf_setHeader(Collection xHead) {
0437: Collection l_rows = this .pcmf_getRowsOnly();
0438: ArrayList l_new = new ArrayList();
0439: l_new.add(xHead);
0440:
0441: if (l_rows != null)
0442: l_new.addAll(l_rows);
0443:
0444: this .pcmf_refresh(l_new);
0445:
0446: return;
0447: }
0448:
0449: public Collection pcmf_getRowsOnly() {
0450: return (this .pcmf_getRowsOnly(true));
0451: }
0452:
0453: public Collection pcmf_getRowsOnly(boolean xHidden) {
0454: if (this .pem_rowCollect == null)
0455: return (null);
0456:
0457: Iterator l_it = this .pcmf_getValueArray(xHidden).iterator();
0458: ArrayList l_res = new ArrayList();
0459:
0460: if (l_it.hasNext())
0461: l_it.next();
0462:
0463: while (l_it.hasNext())
0464: l_res.add(l_it.next());
0465:
0466: return (l_res);
0467: }
0468:
0469: public Collection pcmf_getHeader() {
0470: if (this .pem_rowCollect == null)
0471: return (null);
0472:
0473: Iterator l_it = this .pcmf_getValueArray(true).iterator();
0474:
0475: if (l_it.hasNext())
0476: return (new ArrayList((Collection) l_it.next()));
0477: else
0478: return (null);
0479: }
0480:
0481: public ArrayList pcmf_getValueArray(boolean xHidden) {
0482: if (this .pem_rowCollect == null)
0483: return (null);
0484:
0485: ArrayList l_ret = new ArrayList();
0486: Iterator l_itr = this .pem_rowCollect.iterator();
0487: Iterator l_itc = null;
0488: ArrayList l_newRow = null;
0489: MuGenericTableRow l_row = null;
0490: MuGenericTableCell l_cell = null;
0491:
0492: while (l_itr.hasNext()) {
0493: l_row = (MuGenericTableRow) l_itr.next();
0494: if (!xHidden && l_row.pem_hide)
0495: continue;
0496:
0497: l_itc = l_row.pem_items.iterator();
0498: l_newRow = new ArrayList();
0499: while (l_itc.hasNext()) {
0500: l_cell = (MuGenericTableCell) l_itc.next();
0501: l_newRow.add(l_cell.pdm_item);
0502: }
0503: l_ret.add(l_newRow);
0504: }
0505: return (l_ret);
0506: };
0507:
0508: public void pcmf_refresh(Collection xRows) {
0509: this .pcmf_cleanRows();
0510:
0511: if (xRows != null) {
0512: Iterator rowIt = xRows.iterator();
0513: Collection oldrow = null;
0514:
0515: while (rowIt.hasNext()) {
0516: oldrow = (Collection) rowIt.next();
0517: this .pcmf_addRow(oldrow);
0518: }
0519: ;
0520: }
0521: ;
0522: this .pcmf_commitTable();
0523: };
0524:
0525: public void pcmf_addRow(Collection xRow) {
0526: MuGenericTableRow newrow = new MuGenericTableRow(
0527: new ArrayList(), this .pcmf_getBgColor(), "", "");
0528: Iterator cellIt = xRow.iterator();
0529:
0530: while (cellIt.hasNext()) {
0531: Object l_obj = cellIt.next();
0532: if (l_obj instanceof String)
0533: l_obj = KeTools.pcmf_deRefObj(l_obj.toString());
0534:
0535: if (l_obj instanceof UnComponent) {
0536: UnComponent l_bgobj = (UnComponent) l_obj;
0537: this .pcmf_addNode(l_bgobj.pcmf_getName(), l_bgobj);
0538: }
0539: ;
0540: newrow.pem_items.add(new MuGenericTableCell(l_obj, this
0541: .pcmf_getBgColor(), this .pcmf_getFgColor(), null,
0542: ""));
0543: }
0544: ;
0545:
0546: pem_rowCollect.add(newrow);
0547:
0548: return;
0549: };
0550:
0551: public void pcmf_cleanRows() {
0552: Object[] l_rows = pem_rowCollect.toArray();
0553:
0554: for (int i = 0; i < l_rows.length; i++) {
0555: Collection l_col = ((MuGenericTableRow) l_rows[i]).pem_items;
0556: if (l_col != null) {
0557: Iterator l_it = l_col.iterator();
0558: while (l_it.hasNext()) {
0559: MuGenericTableCell l_cell = (MuGenericTableCell) l_it
0560: .next();
0561: if (l_cell.pdm_item instanceof UnComponent)
0562: this
0563: .pcmf_removeNode(((UnComponent) l_cell.pdm_item));
0564: }
0565: ;
0566: }
0567: ;
0568: }
0569: ;
0570: this .pem_rowCollect = new ArrayList();
0571: }
0572:
0573: public void pcmf_addRow(Collection xRow, int xIdx) {
0574: this .pem_rowCollect.add(xIdx, new Vector(xRow));
0575:
0576: return;
0577: };
0578:
0579: public Collection pcmf_removeRow(int xIdx) {
0580: Collection l_col = ((MuGenericTableRow) pem_rowCollect
0581: .remove(xIdx)).pem_items;
0582: if (l_col != null) {
0583: Iterator l_it = l_col.iterator();
0584: while (l_it.hasNext()) {
0585: MuGenericTableCell l_cell = (MuGenericTableCell) l_it
0586: .next();
0587: if (l_cell.pdm_item instanceof UnComponent)
0588: this
0589: .pcmf_removeNode(((UnComponent) l_cell.pdm_item));
0590: }
0591: ;
0592: }
0593: ;
0594: return (l_col);
0595: }
0596:
0597: public Object pcmf_modCell(int xRow, int xCol, Object xObj) {
0598: MuGenericTableRow l_tabRow = (MuGenericTableRow) pem_rowCollect
0599: .get(xRow);
0600: Object l_obj = null;
0601: MuGenericTableCell l_cell = null;
0602:
0603: l_obj = l_tabRow.pem_items.remove(xCol);
0604: l_cell = (MuGenericTableCell) l_obj;
0605:
0606: if (l_cell.pdm_item instanceof UnComponent)
0607: this .pcmf_removeNode(((UnComponent) l_cell.pdm_item));
0608:
0609: l_tabRow.pem_items.add(xCol, new MuGenericTableCell(xObj, this
0610: .pcmf_getBgColor(), this .pcmf_getFgColor(), null, ""));
0611: if (xObj instanceof UnComponent)
0612: this .pcmf_addNode(((UnComponent) xObj).pcmf_getName(),
0613: (UnComponent) xObj);
0614:
0615: this .pcmf_setPropChanged(true);
0616:
0617: return (l_obj);
0618: };
0619:
0620: public void pcmf_selfRefresh() {
0621: int rowcnt = 0;
0622: Collection newrow = null;
0623: Object rawrow = null;
0624:
0625: if (this .pdm_callback == null)
0626: return;
0627:
0628: this .pem_rowCollect.clear();
0629:
0630: while (true) {
0631: try {
0632: rawrow = this .pdm_callback.pcmf_getObj(rowcnt++);
0633: } catch (Exception e) {
0634: rawrow = null;
0635: }
0636: ;
0637: if (rawrow == null)
0638: break;
0639:
0640: if (rawrow instanceof Collection)
0641: newrow = (Collection) rawrow;
0642: else {
0643: newrow = new ArrayList();
0644: newrow.add(rawrow);
0645: }
0646: ;
0647:
0648: this .pcmf_addRow(newrow);
0649: }
0650: ;
0651:
0652: if (this .pdm_doRefresh)
0653: this .pcmf_setRefresh();
0654:
0655: this .pcmf_commitTable();
0656:
0657: return;
0658: };
0659:
0660: public void pcmf_setCommitHandler(IKeExecutable xHandler) {
0661: this .pem_cHandler = xHandler;
0662: }
0663:
0664: public void pcmf_clearCommitHandler() {
0665: this .pem_cHandler = null;
0666: }
0667:
0668: public void pcmf_commitTable() {
0669: if (this .pem_cHandler != null)
0670: this .pem_cHandler.pcmf_execObj(this );
0671:
0672: if (this .pdm_multiSelection) {
0673: try {
0674: Iterator l_it = this .pdm_selectors.iterator();
0675: while (l_it.hasNext()) {
0676: ((MuGenericCheckBox) l_it.next()).pcmf_delete();
0677: }
0678: } catch (Exception e) {
0679: KeLog.pcmf_logException("ug2t", this , e);
0680: }
0681:
0682: this .pdm_selectors.clear();
0683: this .pdm_container.pcmf_clearValues();
0684:
0685: MuGenericCheckBox l_cb = null;
0686: int l_rowcnt = this .pem_rowCollect.size() - 1;
0687: for (int i = 0; i < l_rowcnt; i++) {
0688: l_cb = (MuGenericCheckBox) this .pcmf_getAppl()
0689: .pcmf_getComponentFactory()
0690: .pcmf_createCheckBox(UnComponentFactory.MARKUP,
0691: "NOTCHECKED", "", this .pcmf_getAppl());
0692:
0693: this .pdm_selectors.add(l_cb);
0694: l_cb.pcmf_addListener(this .pem_msListener);
0695:
0696: if (this .pcmf_isSubmit())
0697: l_cb.pcmf_enableSubmit();
0698: }
0699: }
0700:
0701: this .pemf_lock();
0702: this .pcmf_setPropChanged(true);
0703:
0704: return;
0705: };
0706:
0707: public void pcmf_clearSelection() {
0708: if (this .pdm_multiSelection)
0709: this .pdm_container.pcmf_clearValues();
0710:
0711: if (this .pdm_multiSelection && this .pdm_selectors != null) {
0712: Iterator l_it = this .pdm_selectors.iterator();
0713: MuGenericCheckBox l_cb = null;
0714: while (l_it.hasNext()) {
0715: l_cb = (MuGenericCheckBox) l_it.next();
0716: l_cb.pcmf_setValue("NOTCHECKED");
0717: }
0718: }
0719: ;
0720:
0721: super .pcmf_setValue("");
0722: }
0723:
0724: public void pcmf_setValue(Object xObj) {
0725: if (xObj == null || xObj.toString().equals("")) {
0726: this .pcmf_clearSelection();
0727: return;
0728: }
0729:
0730: if (xObj instanceof HoGenericDataContainer
0731: && this .pdm_multiSelection) {
0732: this .pdm_container.pcmf_copy((HoGenericDataContainer) xObj);
0733: } else if (this .pdm_multiSelection
0734: && xObj instanceof HoGenericDataContainer == false) {
0735: if (this .pdm_container.pcmf_contains(xObj) == false)
0736: this .pdm_container.pcmf_addValue(xObj.toString());
0737: }
0738: if (this .pdm_multiSelection) {
0739: if (this .pdm_container.pcmf_size() > 0)
0740: xObj = this .pdm_container
0741: .pcmf_getValueAt(this .pdm_container.pcmf_size() - 1);
0742: else
0743: xObj = "0";
0744:
0745: Iterator l_it = this .pdm_selectors.iterator();
0746: MuGenericCheckBox l_cb = null;
0747: int i = 0;
0748: while (l_it.hasNext()) {
0749: l_cb = (MuGenericCheckBox) l_it.next();
0750: if (this .pdm_container.pcmf_contains(Integer
0751: .toString(i++)))
0752: l_cb.pcmf_setValue("CHECKED");
0753: else
0754: l_cb.pcmf_setValue("NOTCHECKED");
0755: }
0756: }
0757: ;
0758: super .pcmf_setValue(xObj);
0759: }
0760:
0761: public void pcmf_refreshMultiValue(Object xObj) {
0762: this .pdm_container.pcmf_copy((HoGenericDataContainer) xObj);
0763:
0764: if (this .pdm_container.pcmf_size() > 0)
0765: xObj = this .pdm_container
0766: .pcmf_getValueAt(this .pdm_container.pcmf_size() - 1);
0767: else
0768: xObj = "0";
0769:
0770: super .pcmf_refreshValue(xObj);
0771: }
0772:
0773: public void pcmf_setComplete(KeTable xTable) {
0774: this .pcmf_refresh(xTable.pcmf_getHeaderAndTableValues());
0775: if (xTable.pcmf_hasHiddenRows()) {
0776: int l_size = this .pem_rowCollect.size();
0777: for (int i = 1; i < l_size; i++)
0778: if (xTable.pcmf_isHiddenRow(i - 1))
0779: this .pcmf_hideRow(i);
0780: }
0781: }
0782:
0783: public ArrayList pcmf_getCol(int xCol) {
0784: Iterator l_it = this .pem_rowCollect.iterator();
0785: ArrayList l_ret = new ArrayList(this .pcmf_getColCount());
0786: while (l_it.hasNext())
0787: l_ret.add(((MuGenericTableRow) l_it.next()).pem_items
0788: .get(xCol));
0789:
0790: return (l_ret);
0791: }
0792:
0793: public KeTable pcmf_getComplete() {
0794: ArrayList l_vect = this .pcmf_getValueArray(true);
0795: if (l_vect == null)
0796: return (null);
0797:
0798: KeTable l_ret = new KeTable();
0799: Iterator l_it = l_vect.iterator();
0800: int l_row = 0;
0801:
0802: if (l_it.hasNext())
0803: l_ret
0804: .pcmf_setHeader(new ArrayList((Collection) l_it
0805: .next()));
0806:
0807: while (l_it.hasNext()) {
0808: l_row++;
0809: l_ret.pcmf_addRowArrayList(new ArrayList((Collection) l_it
0810: .next()));
0811: if (this .pcmf_isHiddenRow(l_row))
0812: l_ret.pcmf_hideRow(l_row - 1);
0813: }
0814:
0815: return (l_ret);
0816: }
0817:
0818: public void pcmf_scrollXRel(int xPx) {
0819: this .pdm_scrCrt.pcmf_scrollXRel(xPx);
0820: }
0821:
0822: public void pcmf_scrollXAbs(int xPx) {
0823: this .pdm_scrCrt.pcmf_scrollXAbs(xPx);
0824: }
0825:
0826: public void pcmf_scrollYRel(int xPy) {
0827: this .pdm_scrCrt.pcmf_scrollYRel(xPy);
0828: }
0829:
0830: public void pcmf_scrollYAbs(int xPy) {
0831: this .pdm_scrCrt.pcmf_scrollYAbs(xPy);
0832: }
0833:
0834: public int pcmf_getXScroll() {
0835: return (this .pdm_scrCrt.pcmf_getX());
0836: }
0837:
0838: public int pcmf_getYScroll() {
0839: return (this .pdm_scrCrt.pcmf_getY());
0840: }
0841:
0842: public ArrayList pcmf_getSelectedTableRow() {
0843: String l_value = this .pcmf_getValue().toString();
0844: int l_idx = Integer.parseInt(l_value);
0845:
0846: return ((ArrayList) this .pcmf_getValueArray(true)
0847: .get(l_idx + 1));
0848: }
0849:
0850: public ArrayList pcmf_getSelectedTableRows() {
0851: ArrayList l_ret = new ArrayList();
0852: HoGenericDataContainer l_rows = this .pcmf_getValues();
0853:
0854: if (l_rows == null)
0855: return (l_ret);
0856:
0857: Iterator l_it = l_rows.pcmf_getValueIt();
0858: int l_idx = 0;
0859:
0860: while (l_it.hasNext()) {
0861: l_idx = Integer.parseInt(l_it.next().toString());
0862: l_ret.add((ArrayList) this .pcmf_getValueArray(true).get(
0863: l_idx + 1));
0864: }
0865:
0866: return (l_ret);
0867: }
0868:
0869: public MuGenericScrollController pcmf_getScrollCrt() {
0870: return (this .pdm_scrCrt);
0871: }
0872:
0873: public Object pcmf_getSelectedObject() {
0874: return (this .pcmf_getSelectedTableRow());
0875: }
0876:
0877: public Object pcmf_setSelectedRow(int xRow) {
0878: this .pcmf_setSelected(xRow);
0879: return (this .pcmf_getSelectedTableRow());
0880: }
0881:
0882: public ArrayList pcmf_setSelectedRows(int[] xRows) {
0883: this .pcmf_setSelected(xRows);
0884: return (this .pcmf_getSelectedTableRows());
0885: }
0886:
0887: public void pcmf_setSelected(int xRow) {
0888: this .pcmf_setValue(Integer.toString(xRow));
0889: }
0890:
0891: public void pcmf_setSelected(int[] xRows) {
0892: HoGenericDataContainer l_cont = this .pcmf_getValues();
0893: for (int i = 0; i < xRows.length; i++) {
0894: l_cont.pcmf_clearValues();
0895: l_cont.pcmf_addValue(Integer.toString(xRows[i]));
0896: }
0897: this .pcmf_setValues(l_cont);
0898: }
0899:
0900: public int pcmf_getSelectedRow() {
0901: try {
0902: return (Integer.parseInt(this .pcmf_getValue().toString()));
0903: } catch (Exception e) {
0904: return (-1);
0905: }
0906: }
0907:
0908: public int pcmf_getColCount() {
0909: if (this .pem_rowCollect.size() < 1)
0910: return (0);
0911:
0912: return (((MuGenericTableRow) this .pem_rowCollect.get(0)).pem_items
0913: .size());
0914: }
0915:
0916: public void pcmf_clearTableBody() {
0917: this .pcmf_setRowsOnly(new ArrayList());
0918: }
0919:
0920: public boolean pcmf_isSelectable() {
0921: return (this .pdm_sel);
0922: }
0923:
0924: public ArrayList pcmf_getSelectors() {
0925: return (this .pdm_selectors);
0926: }
0927:
0928: public void pcmf_delete() throws Exception {
0929: if (this .pdm_deleted == true)
0930: return;
0931:
0932: this .pdm_scrCrt.pcmf_delete();
0933: if (this .pdm_container != null)
0934: this .pdm_container.pcmf_delete();
0935:
0936: super .pcmf_delete();
0937: }
0938:
0939: public void pcmf_setPartialRenderLineLimit(int xLimit) {
0940: // @@
0941: }
0942:
0943: // @@
0944:
0945: public Object pcmf_execView() {
0946: // Do this to refresh cbs
0947: if (this .pcmf_getPropChanged() && this .pcmf_isMultiSelection()
0948: && !this .pcmf_getDifferentialRepaint())
0949: this .pcmf_setValue(this .pdm_container);
0950:
0951: return (super .pcmf_execView());
0952: };
0953:
0954: public void pcmf_relockCol() {
0955: return;
0956: }
0957:
0958: public void pcmf_setSpan(int xRow, int xColumn, int xRowSpan,
0959: int xColumnSpan) {
0960: xRow++;
0961:
0962: int l_rc = this .pcmf_getRowCount();
0963: int l_cc = this .pcmf_getColCount();
0964: if (l_rc <= xRow || l_cc <= xColumn)
0965: return;
0966:
0967: MuGenericTableCell l_cell = this .pcmf_getCell(xRow, xColumn);
0968: l_cell.pdm_span = new UnTableCellSpan(xRow, xColumn, xRowSpan,
0969: xColumnSpan);
0970:
0971: int x = xColumn;
0972: int y = xRow;
0973: int xMax = x + l_cell.pdm_span.pcmf_getColumnSpan() - 1;
0974: int yMax = y + l_cell.pdm_span.pcmf_getRowSpan() - 1;
0975: for (; x <= xMax; x++) {
0976: for (; y <= yMax; y++) {
0977: if (l_rc <= y || l_cc <= x)
0978: continue;
0979:
0980: MuGenericTableCell l_sCell = this .pcmf_getCell(y, x);
0981: if (l_sCell != null)
0982: l_sCell.pdm_isSpaned = true;
0983: }
0984:
0985: y = xRow;
0986: }
0987: }
0988:
0989: public void pcmf_removeSpan(int xRow, int xColumn) {
0990: xRow++;
0991:
0992: int l_rc = this .pcmf_getRowCount();
0993: int l_cc = this .pcmf_getColCount();
0994: if (l_rc <= xRow || l_cc <= xColumn)
0995: return;
0996:
0997: MuGenericTableCell l_cell = this .pcmf_getCell(xRow, xColumn);
0998: l_cell.pdm_span = null;
0999:
1000: int x = xColumn;
1001: int y = xRow;
1002: int xMax = x + l_cell.pdm_span.pcmf_getColumnSpan() - 1;
1003: int yMax = y + l_cell.pdm_span.pcmf_getRowSpan() - 1;
1004: for (; x <= xMax; x++) {
1005: for (; y <= yMax; y++) {
1006: if (l_rc <= y || l_cc <= x)
1007: continue;
1008:
1009: MuGenericTableCell l_sCell = this .pcmf_getCell(y, x);
1010: if (l_sCell != null)
1011: l_sCell.pdm_isSpaned = false;
1012: }
1013:
1014: y = xRow;
1015: }
1016: }
1017:
1018: public void pcmf_removeSelected() {
1019: if (this .pcmf_isMultiSelection()) {
1020: try {
1021: Collection l_all = this .pcmf_getRowsOnly();
1022: l_all.removeAll(this .pcmf_getSelectedTableRows());
1023:
1024: this .pcmf_setRowsOnly(l_all);
1025: } catch (Exception e) {
1026: KeLog.pcmf_log("ug2t",
1027: "cannot remove row - invalid index: "
1028: + this .pcmf_getValue(), this ,
1029: KeLog.DEBUG);
1030: }
1031: } else {
1032: try {
1033: this .pcmf_removeRow(Integer.parseInt(this
1034: .pcmf_getValue().toString()) + 1);
1035: } catch (Exception e) {
1036: KeLog.pcmf_log("ug2t",
1037: "cannot remove row - invalid index: "
1038: + this.pcmf_getValue(), this,
1039: KeLog.DEBUG);
1040: }
1041: }
1042: this.pcmf_clearSelection();
1043: }
1044: }
|