/** * ctor */ public EditRowSpecCommand(FormComponent form, int row, RowSpec rowspec, RowSpec oldspec) { super(form); m_row = row; m_rowspec = rowspec; /** * note that you must create a copy of the oldspec here because the * reference passed to the constructor is probabaly bound to the view * and will change */ m_oldspec = new RowSpec(oldspec.getDefaultAlignment(), oldspec.getSize(), oldspec.getResizeWeight()); }
/** * Updates the rowspec for the given row * * @param rowspec * the new rowpsec * @param row * the row */ public void setRowSpec(int row, RowSpec rowspec) { FormLayout layout = getFormLayout(); RowSpec newspec = new RowSpec(rowspec.getDefaultAlignment(), rowspec.getSize(), rowspec.getResizeWeight()); layout.setRowSpec(row, newspec); m_form.revalidate(); fireGridEvent(new GridViewEvent(this, GridViewEvent.ROW_SPEC_CHANGED)); }
public void actionPerformed(ActionEvent evt) { GridComponent gc = getCurrentEditor().getSelectedComponent(); if (gc != null) { GridView view = gc.getParentView(); if (view != null) { int row = gc.getRow(); RowSpec oldspec = view.getFormLayout().getRowSpec(row); float resize_weight = m_growable ? 1.0f : 0.0f; RowSpec newspec = new RowSpec(RowSpec.FILL, oldspec.getSize(), resize_weight); EditRowSpecCommand cmd = new EditRowSpecCommand(view.getParentForm(), row, newspec, oldspec); CommandUtils.invoke(cmd, getCurrentEditor()); } } } }