/** * Inserts an empty row at the specified position in the grid. * * @param row * Index of the row before which the new row will be inserted. * The leftmost row has index 0. */ public void insertRow(int row) { if (row > getRows()) { throw new IllegalArgumentException("Cannot insert row at " + row + " in a gridlayout with height " + getRows()); } for (ChildComponentData existingArea : getState().childData.values()) { // Areas ending below the row needs to be moved down or stretched if (existingArea.row2 >= row) { existingArea.row2++; // Stretch areas that span over the selected row if (existingArea.row1 >= row) { existingArea.row1++; } } } if (cursorY >= row) { cursorY++; } setRows(getRows() + 1); markAsDirty(); }
|| row2 >= getRows()) { throw new OutOfBoundsException(area);
@Override public void beforeClientResponse(boolean initial) { super.beforeClientResponse(initial); getState().colExpand = new float[getColumns()]; float colSum = getExpandRatioSum(columnExpandRatio); if (colSum == 0) { // no cols have been expanded for (int i = 0; i < getColumns(); i++) { getState().colExpand[i] = 1f; } } else { for (int i = 0; i < getColumns(); i++) { getState().colExpand[i] = getColumnExpandRatio(i); } } getState().rowExpand = new float[getRows()]; float rowSum = getExpandRatioSum(rowExpandRatio); if (rowSum == 0) { // no rows have been expanded for (int i = 0; i < getRows(); i++) { getState().rowExpand[i] = 1f; } } else { for (int i = 0; i < getRows(); i++) { getState().rowExpand[i] = getRowExpandRatio(i); } } }
setColumns(cursorX + 1); if (cursorY >= getRows()) { setRows(cursorY + 1);
/** * {@inheritDoc} * <p> * After reading the design, cursorY is set to point to a row outside of the * GridLayout area. CursorX is reset to 0. */ @Override public void readDesign(Element design, DesignContext designContext) { super.readDesign(design, designContext); setMargin(readMargin(design, getMargin(), designContext)); if (design.childNodeSize() > 0) { // Touch content only if there is some content specified. This is // needed to be able to use extended GridLayouts which add // components in the constructor (e.g. Designs based on GridLayout). readChildComponents(design.children(), designContext); } // Set cursor position explicitly setCursorY(getRows()); setCursorX(0); }
for (int col = componentArea.getColumn1(); col <= componentArea .getColumn2(); col++) { for (int row = 0; row < gl.getRows(); row++) { Component c = gl.getComponent(col, row); if (c != null) {
private void clearCurrentEditors() { while (mainLayout.getRows() > 1) { mainLayout.removeRow(1); } }
public int createRow() { if (layout == null) return 0; int rows = layout.getRows(); layout.setRows(rows+1); return rows; }
@Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { recreateCells(Integer.valueOf(valueChangeEvent.getProperty().getValue().toString()), m_gridLayout.getRows()); } });
@Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { recreateCells(Integer.valueOf(valueChangeEvent.getProperty().getValue().toString()), m_gridLayout.getRows()); } });
valueField.setWidth("95%"); listLayout.insertRow(listLayout.getRows()); listLayout.addComponent(valueLabel, 0, listLayout.getRows() -2); listLayout.addComponent(valueField, 1, listLayout.getRows() -2); listLayout.addComponent(removeButton, 2, listLayout.getRows() -2); listLayout.addComponent(addButton, 0, listLayout.getRows() -1);
/** * Updates the preview images on timeframe changes. */ private void updatePreview() { /** * getting the timeframe values */ int timeFrameValue; int timeFrameType; try { timeFrameValue = Integer.parseInt(m_timeFrameValue.getValue().toString()); } catch (NumberFormatException numberFormatException) { timeFrameValue = 1; } try { timeFrameType = Integer.parseInt(m_timeFrameType.getValue().toString()); } catch (NumberFormatException numberFormatException) { timeFrameType = Calendar.HOUR; } for (int y = 0; y < m_gridLayout.getRows(); y++) { for (int x = 0; x < m_gridLayout.getColumns(); x++) { if (m_gridLayout.getComponent(x, y) != null) { ((RrdGraphEntry) m_gridLayout.getComponent(x, y)).setPreviewTimeFrame(timeFrameType, timeFrameValue); } } } }
/** * Updates the preview images on timeframe changes. */ private void updatePreview() { /** * getting the timeframe values */ int timeFrameValue; int timeFrameType; try { timeFrameValue = Integer.parseInt(m_timeFrameValue.getValue().toString()); } catch (NumberFormatException numberFormatException) { timeFrameValue = 1; } try { timeFrameType = Integer.parseInt(m_timeFrameType.getValue().toString()); } catch (NumberFormatException numberFormatException) { timeFrameType = Calendar.HOUR; } for (int y = 0; y < m_gridLayout.getRows(); y++) { for (int x = 0; x < m_gridLayout.getColumns(); x++) { if (m_gridLayout.getComponent(x, y) != null) { ((RrdGraphEntry) m_gridLayout.getComponent(x, y)).setPreviewTimeFrame(timeFrameType, timeFrameValue); } } } }
valueField.setWidth("95%"); mapLayout.insertRow(mapLayout.getRows()); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() -2); mapLayout.addComponent(keyField, 1, mapLayout.getRows() -2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() -2); mapLayout.addComponent(valueField, 3, mapLayout.getRows() -2); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() -2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() -1);
public void addAttribute(String name, String value) { grid.setRows(grid.getRows()+1); grid.addComponent(new Label(name)); grid.addComponent(new Label(value)); }
for (int y = 0; y < m_gridLayout.getRows(); y++) { for (int x = 0; x < m_gridLayout.getColumns(); x++) { RrdGraphEntry rrdGraphEntry = (RrdGraphEntry) m_gridLayout.getComponent(x, y);
public void addComposite(LayoutComposite composite,Component layout) { if (currentComponent == null) return; int row = 0; if (composite.getOffset() > 0 && currentComponent.getGrid() != null) { row = currentComponent.getGrid().getRows()-1; } else { row = currentComponent.createRow(); } log().i("add comp",composite.getOffset(),row,composite.getOffset()+composite.getColumns()-1,row); currentComponent.addComponent(composite,layout,composite.getOffset(),row,composite.getOffset()+composite.getColumns()-1,row); }