/** * Returns the column count. * * @return the column count */ public int getColumnCount() { return getColumnCount(false); }
protected int[] getColumnWidths() { int colCount = cm.getColumnCount(); int[] columnWidths = new int[colCount]; for (int i = 0; i < colCount; i++) { columnWidths[i] = cm.getColumnWidth(i); } return columnWidths; }
protected List<ColumnData> getColumnData() { int colCount = cm.getColumnCount(); List<ColumnData> cs = new ArrayList<ColumnData>(); for (int i = 0; i < colCount; i++) { String name = cm.getDataIndex(i); ColumnData data = new ColumnData(); data.name = name == null ? cm.getColumnId(i) : name; data.renderer = cm.getRenderer(i); data.id = cm.getColumnId(i); data.style = getColumnStyle(i, false); cs.add(data); } return cs; }
protected void renderWidgets(int startRow, int endRow) { if (grid.isViewReady()) { if (endRow == -1) { endRow = widgetList.size() - 1; } for (int i = startRow; i <= endRow; i++) { List<Widget> m = i < widgetList.size() ? widgetList.get(i) : null; if (m != null) { for (int j = 0; j < grid.getColumnModel().getColumnCount(); j++) { Widget w = j < m.size() ? m.get(j) : null; if (w != null) { Element cell = getWidgetCell(i, j); if (cell != null) { if (w.getElement().getParentElement() != cell) { fly(cell).removeChildren(); cell.appendChild(w.getElement()); } if (grid.isAttached()) { ComponentHelper.doAttach(w); } } } } } } } }
@Override public void componentSelected(MenuEvent ce) { List<ColumnConfig> columns = new ArrayList<ColumnConfig>(); ColumnConfig col; for (int i = 0; i < getColumnModel().getColumnCount(); i++) { col = getColumnModel().getColumn(i); if (col instanceof TolaGxtColumnConfig) { TolaGxtColumnConfig rcol = (TolaGxtColumnConfig) col; if (rcol.isParticipateInCsvGeneration()) { columns.add(rcol); } } } BaseModelToCsvConverter converter = new BaseModelToCsvConverter(getSelectionModel().getSelectedItems()); String csv = converter.convert(columns.toArray( new ColumnConfig[0])); Clipboard.setText(csv); } });
protected String renderRows(int startRow, int endRow) { int colCount = cm.getColumnCount(); if (ds.getCount() < 1) { return ""; } List<ColumnData> cs = getColumnData(); if (endRow == -1) { endRow = ds.getCount() - 1; } List<ModelData> rs = ds.getRange(startRow, endRow); return doRender(cs, rs, startRow, colCount, grid.isStripeRows()); }
protected void doUpdate() { if (grid == null || !grid.isViewReady() || !isBufferEnabled()) { return; } int count = getVisibleRowCount(); if (count > 0) { ColumnModel cm = grid.getColumnModel(); ListStore<ModelData> store = grid.getStore(); List<ColumnData> cs = getColumnData(); boolean stripe = grid.isStripeRows(); int[] vr = getVisibleRows(count); int cc = cm.getColumnCount(); for (int i = vr[0]; i <= vr[1]; i++) { // if row is NOT rendered and is visible, render it if (!isRowRendered(i)) { List<ModelData> list = new ArrayList<ModelData>(); list.add(store.getAt(i)); if (widgetList.size() > i) { widgetList.set(i, new ArrayList<Widget>()); } else { widgetList.add(i, new ArrayList<Widget>()); } String html = doRender(cs, list, i, cc, stripe, true); getRow(i).setInnerHTML(html); renderWidgets(i, i); } } clean(); } }
private void restrictMenu(Menu columns) { int count = 0; for (int i = 0, len = cm.getColumnCount(); i < len; i++) { if (!shouldNotCount(i, true)) { count++; } } if (count == 1) { for (Component item : columns.getItems()) { CheckMenuItem ci = (CheckMenuItem) item; if (ci.isChecked()) { ci.disable(); } } } else { for (Component item : columns.getItems()) { item.enable(); } } }
protected void doFocus(int colIndex) { if (isVisible()) { ColumnModel cm = this.grid.getColumnModel(); for (int i = colIndex, len = cm.getColumnCount(); i < len && i >= 0; i++) { ColumnConfig c = cm.getColumn(i); if (!c.isHidden() && c.getEditor() != null) { c.getEditor().getField().focus(); break; } } } }
protected int getTargetColumnIndex(Point pt) { for (int i = 0, j = 0; i < grid.getColumnModel().getColumnCount(); i++) { ColumnConfig c = grid.getColumnModel().getColumn(i); if (!c.isHidden()) { if (El.fly(grid.getView().getHeaderCell(i)).getRegion().right >= pt.x) { return j; } j++; } } return -1; }
protected void updateAllColumnWidths() { int tw = getTotalWidth(); int clen = cm.getColumnCount(); Stack<Integer> ws = new Stack<Integer>(); header.updateAllColumnWidths(); for (int i = 0; i < clen; i++) { ws.push(getColumnWidth(i)); if (footer != null) { footer.updateColumnWidth(i, cm.getColumnWidth(i)); } } NodeList<Element> ns = getRows(); for (int i = 0, len = ns.getLength(); i < len; i++) { Element row = ns.getItem(i); row.getStyle().setPropertyPx("width", tw); if (row.getFirstChild() != null) { row.getFirstChildElement().getStyle().setPropertyPx("width", tw); TableSectionElement e = row.getFirstChild().cast(); TableRowElement nodeList = e.getRows().getItem(0); for (int j = 0; j < clen; j++) { ((Element) nodeList.getChildNodes().getItem(j)).getStyle().setPropertyPx("width", ws.get(j)); } } } templateOnAllColumnWidthsUpdated(ws, tw); syncHScroll(); }
private Head getHead(int index, boolean back) { ColumnHeader header = grid.getView().getHeader(); int cols = grid.getColumnModel().getColumnCount(); if (!back) { for (int i = index; i < cols; i++) { ColumnConfig config = grid.getColumnModel().getColumn(i); if (!config.isHidden() && !config.ariaIgnore) { return header.getHead(i); } } } else { for (int i = index; i > -1; i--) { ColumnConfig config = grid.getColumnModel().getColumn(i); if (!config.isHidden() && !config.ariaIgnore) { return header.getHead(i); } } } return null; }
protected Cell walkCells(int row, int col, int step, Callback callback, boolean acceptNavs) { boolean first = true; int clen = cm.getColumnCount(); int rlen = store.getCount(); if (step < 0) {
public void updateColumnHeadings() { int cols = grid.getColumnModel().getColumnCount(); for (int i = 0; i < cols; i++) { ColumnConfig config = grid.getColumnModel().getColumn(i); if (!config.isHidden()) { ColumnHeader header = grid.getView().getHeader(); if (header != null) { Head h = header.getHead(i); if (h != null && h.isRendered()) { Filter f = getFilter(config.getDataIndex()); if (f != null) { h.el().setStyleName(filterStyle, f.isActive()); } } } } } }
public void handleEvent(GridEvent<RuleModel> be) { Dispatcher.forwardEvent(GeofenceEvents.SEND_INFO_MESSAGE, new String[]{"DEBUG","Resizing " + be.getGrid().getColumnModel().getColumnId(be.getColIndex())}); for (int i = 0; i < be.getGrid().getStore().getCount(); i++) { // there should be only 1 row // let's force a resize on all the columns for (int col = 0; col < be.getGrid().getColumnModel().getColumnCount(); col++) { // final Widget widget = be.getGrid().getView().getWidget(i, be.getColIndex()); final Widget widget = be.getGrid().getView().getWidget(i, col); // Dispatcher.forwardEvent(GeofenceEvents.SEND_INFO_MESSAGE, // new String[]{"DEBUG","Resizing " + widget.getClass().getName() + "--" + widget.getTitle()}); int colWidth = be.getGrid().getColumnModel().getColumn(col).getWidth(); if ((widget != null) && (widget instanceof BoxComponent)) { // ((BoxComponent) widget).setWidth(be.getWidth() - offset); ((BoxComponent) widget).setWidth(colWidth - offset); } } } } }
protected void onDragStart(DragEvent e) { headerDisabled = true; dragging = true; setStyleAttribute("borderLeft", "1px solid black"); setStyleAttribute("cursor", "default"); el().setStyleAttribute("opacity", "1"); el().setWidth(1); startX = e.getX(); int cols = cm.getColumnCount(); for (int i = 0, len = cols; i < len; i++) { if (cm.isHidden(i) || !cm.isResizable(i)) continue; Element hd = getHead(i).getElement(); if (hd != null) { Region rr = El.fly(hd).getRegion(); if (startX > rr.right - 5 && startX < rr.right + 5) { colIndex = heads.indexOf(getHead(i)); if (colIndex != -1) break; } } } if (colIndex > -1) { Element c = getHead(colIndex).getElement(); int x = startX; int minx = x - fly((com.google.gwt.user.client.Element) c).getX() - minColumnWidth; int maxx = (container.el().getX() + container.el().getWidth()) - e.getEvent().getClientX(); d.setXConstraint(minx, maxx); } }
protected void initFields() { ColumnModel cm = grid.getColumnModel(); for (int i = 0, len = cm.getColumnCount(); i < len; i++) { ColumnConfig c = cm.getColumn(i); CellEditor ed = c.getEditor(); Field<?> f = ed != null ? ed.getField() : new LabelField(); if (f instanceof TriggerField<?>) { ((TriggerField<? extends Object>) f).setMonitorTab(true); } f.setWidth(cm.getColumnWidth(i)); HBoxLayoutData ld = new HBoxLayoutData(); if (i == 0) { ld.setMargins(new Margins(0, 1, 2, 1)); } else if (i == len - 1) { ld.setMargins(new Margins(0, 0, 2, 1)); } else { ld.setMargins(new Margins(0, 1, 2, 2)); } f.setMessageTarget("tooltip"); f.addStyleName("x-row-editor-field"); // needed because we remove it from the celleditor clearParent(f); insert(f, i, ld); } initialized = true; }
protected void verifyLayout(boolean force) { if (initialized && (isVisible() || force)) { Element row = (Element) grid.getView().getRow(rowIndex); setSize(El.fly(row).getWidth(false), renderButtons ? btns.getHeight() : 0); syncSize(); ColumnModel cm = grid.getColumnModel(); for (int i = 0, len = cm.getColumnCount(); i < len; i++) { if (!cm.isHidden(i)) { Field<?> f = (Field<?>) getItem(i); f.show(); f.getElement().setAttribute("gxt-dindex", "" + cm.getDataIndex(i)); MarginData md = (MarginData) ComponentHelper.getLayoutData(f); f.setWidth(cm.getColumnWidth(i) - md.getMargins().left - md.getMargins().right); } else { getItem(i).hide(); } } layout(true); positionButtons(); } }
table.setCellSpacing(0); int cols = cm.getColumnCount(); for (int i = 0; i < cols; i++) { Foot f = new Foot(config, cm.getDataIndex(i));
int cols = cm.getColumnCount(); for (int i = 0; i < cols; i++) { if (shouldNotCount(i, false)) {