/** * ctor */ public EditColumnSpecCommand(FormComponent form, int col, ColumnSpec colspec, ColumnSpec oldspec) { super(form); m_col = col; m_columnspec = colspec; /** * 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 ColumnSpec(oldspec.getDefaultAlignment(), oldspec.getSize(), oldspec.getResizeWeight()); }
/** * Flips the default alignment of the given column specification and returns * a new column specification object with the flipped alignment and the same * size and growing behavior as the original. * * @param spec * the original column specification * @return the column specification with flipped default alignment */ private static ColumnSpec flipped(ColumnSpec spec) { DefaultAlignment alignment = spec.getDefaultAlignment(); if (alignment == ColumnSpec.LEFT) alignment = ColumnSpec.RIGHT; else if (alignment == ColumnSpec.RIGHT) alignment = ColumnSpec.LEFT; return new ColumnSpec(alignment, spec.getSize(), spec.getResizeWeight()); }
/** * Updates the columnspecrowspec for the given column * * @param colspec * the new columnspec * @param col * the column */ public void setColumnSpec(int col, ColumnSpec colspec) { FormLayout layout = getFormLayout(); ColumnSpec newspec = new ColumnSpec(colspec.getDefaultAlignment(), colspec.getSize(), colspec.getResizeWeight()); layout.setColumnSpec(col, newspec); m_form.revalidate(); fireGridEvent(new GridViewEvent(this, GridViewEvent.COLUMN_SPEC_CHANGED)); }
public void actionPerformed(ActionEvent evt) { GridComponent gc = getCurrentEditor().getSelectedComponent(); if (gc != null) { GridView view = gc.getParentView(); int col = gc.getColumn(); ColumnSpec oldspec = view.getFormLayout().getColumnSpec(col); ColumnSpec newspec = new ColumnSpec(oldspec.getDefaultAlignment(), Sizes.PREFERRED, oldspec.getResizeWeight()); EditColumnSpecCommand cmd = new EditColumnSpecCommand(view.getParentForm(), col, newspec, oldspec); CommandUtils.invoke(cmd, getCurrentEditor()); } } }
public void actionPerformed(ActionEvent evt) { GridComponent gc = getCurrentEditor().getSelectedComponent(); if (gc != null) { GridView view = gc.getParentView(); if (view != null) { int col = gc.getColumn(); ColumnSpec oldspec = view.getFormLayout().getColumnSpec(col); float resize_weight = m_growable ? 1.0f : 0.0f; ColumnSpec newspec = new ColumnSpec(oldspec.getDefaultAlignment(), oldspec.getSize(), resize_weight); EditColumnSpecCommand cmd = new EditColumnSpecCommand(view.getParentForm(), col, newspec, oldspec); CommandUtils.invoke(cmd, getCurrentEditor()); } } } }