Permalink
Browse files

[InMethod Grid] fix for LinkColumns to correctly display links on Edi…

…tableDataGrids after a selection for update

javadoc additions/corrections
  • Loading branch information...
1 parent 13cb6eb commit e2e7d2d71e1cbd3dc86ca47e4dcbe733ce38462f =Tom B committed Oct 22, 2012
@@ -7,14 +7,10 @@
import org.apache.wicket.markup.repeater.data.IDataProvider;
/**
- * Created by IntelliJ IDEA.
- * User: Tom B.
- * Date: 9/20/11
- * Time: 11:13 AM
+ * extends the functionality of {@link DataProviderAdapter} to
+ * make the DataProvider Appendable
*
- * @author Tom B.
- *
- * TODO: make generic
+ * @author Tom Burton
*/
public class AppendableDataProviderAdapter<T>
extends DataProviderAdapter<T> implements IAppendableDataSource<T>
@@ -1,12 +1,10 @@
package com.inmethod.grid;
/**
- * Created by IntelliJ IDEA.
- * User: Tom B.
- * Date: 9/20/11
- * Time: 10:56 AM
+ * Extends the {@link IDataSource} interface with methods necessary to support
+ * dynamically adding data to the provider
*
- * @author Tom B.
+ * @author Tom Burton
*/
public interface IAppendableDataSource<T> extends IDataSource<T>
{
@@ -16,5 +14,10 @@
*/
public void InsertRow(int index, T item);
+ /**
+ * Function for removing Data from the Provider at the specified index
+ * @param index the index value to remove the data at
+ * @param item Item to remove from the provider. (for confirmation)
+ */
public void DeleteRow(int index, T item);
}
@@ -2,31 +2,44 @@
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.WebMarkupContainer;
+import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.PropertyModel;
import com.inmethod.grid.IRenderable;
+import com.inmethod.grid.datagrid.DataGrid;
/**
- * Column to display links in the DataGrid
- * Created by IntelliJ IDEA.
- * User: Tom Burton
- * Date: 1/3/12
- * Time: 2:07 PM
+ * Abstract column for displaying links in a {@link DataGrid}
*
* @author Tom Burton
*/
public abstract class LinkColumn<M, I> extends AbstractColumn<M, I>
{
private String propertyLabel;
+ /**
+ * Create a new Link Column
+ * @param columnId column id (must be unique within the grid)
+ * @param propertyLabel Label to display for the Link,
+ * gotten from the model object itself ala {@link PropertyModel}
+ * @param headerModel model object for the column header
+ */
public LinkColumn(String columnId, String propertyLabel,
IModel<String> headerModel)
{
super(columnId, headerModel);
this.propertyLabel = propertyLabel;
}
+ /**
+ * Create a new Link Column
+ * @param columnId column id (must be unique within the grid)
+ * @param propertyLabel Label to display for the Link,
+ * gotten from the model object itself ala {@link PropertyModel}
+ * @param headerModel model object for the column header
+ * @param sortProperty property to sort the column by
+ */
public LinkColumn(String columnId, String propertyLabel,
IModel<String> headerModel, String sortProperty)
{
@@ -67,11 +80,17 @@ public void onClick()
};
}
+ /** @return row model object property name for the link Text */
public String getPropertyLabel() { return propertyLabel; }
+ /** @param propertyLabel row model object property name for the link Text */
public void setPropertyLabel(String propertyLabel)
{ this.propertyLabel = propertyLabel; }
- //TODO: should this work Like Page link? instead?
+ /**
+ * Called when a link is clicked.
+ * @see Link#onClick()
+ * @param rowModel Model Object for the DataGridRow being passed to the link
+ */
public abstract void onClick(IModel<I> rowModel);
}
@@ -7,10 +7,7 @@
import org.apache.wicket.model.IModel;
/**
- * Created by IntelliJ IDEA.
- * User: Tom Burton
- * Date: 1/3/12
- * Time: 2:11 PM
+ * Backing Panel to display the actual link used by {@link LinkColumn}
*
* @author Tom Burton
* Panel for Displaying a Link in a cell.
@@ -19,14 +16,25 @@
{
private String label;
- /** @see Component#Component(String) */
+ /**
+ * Creates a new LinkPanel
+ * @param id Panel Id
+ * @param Label link display text
+ * @see Component#Component(String)
+ */
public LinkPanel(String id, String Label)
{
super(id);
label = Label;
}
- /** @see Component#Component(String, IModel) */
+ /**
+ * Creates a new LinkPanel
+ * @param id Panel Id
+ * @param Label link display text
+ * @param model backing model used by the panel
+ * @see Component#Component(String, IModel)
+ */
public LinkPanel(String id, String Label, IModel<I> model)
{
super(id, model);
@@ -35,31 +43,24 @@ public LinkPanel(String id, String Label, IModel<I> model)
/**
* Called just before a component is rendered.
- * <p>
- * <strong>NOTE</strong>: If you override this, you *must* call
- * super.onBeforeRender() within
- * your implementation.
- *
- * Because this method is responsible for cascading {@link #onBeforeRender()}
- * call to its
- * children it is strongly recommended that super call is made at the end of
- * the override.
- * </p>
- *
- * @ see Component#callOnBeforeRenderIfNotVisible()
+ * {@inheritDoc}
*/
@Override
protected void onBeforeRender()
- {
- this.add(new Link<Void>("link")
- {
- /** Called when a link is clicked. */
- @Override
- public void onClick()
+ { //TODO: should this be moved to the constructor or onInitialize()?
+ Link link = new Link<Void>("link")
{
- LinkPanel.this.onClick();
- }
- }.add(new Label("label",label)));
+ /** Called when a link is clicked. */
+ @Override
+ public void onClick()
+ {
+ LinkPanel.this.onClick();
+ }
+ };
+ link.add(new Label("label",label));
+
+ if ( null != get("link") ) { this.replace(link); }
+ else { this.add(link); }
super.onBeforeRender();
}
@@ -86,5 +87,4 @@ public void render(IModel rowModel, Response response)
/** override this function to do the actual work when a link is clicked. */
public abstract void onClick(); // { }
-
}
@@ -5,13 +5,12 @@
import org.apache.wicket.request.cycle.RequestCycle;
/**
- * Created by IntelliJ IDEA.
- * User: Tom Burton
- * Date: 1/3/12
- * Time: 3:50 PM
+ * Concrete example implementation of {@link LinkColumn}
+ * that links to a specific page
*
* @author Tom Burton
- * To change this template use File | Settings | File Templates.
+ *
+ * TODO: should PageParameters support be added?
*/
public class PageLinkColumn<M, I> extends LinkColumn<M, I>
{
@@ -36,8 +35,6 @@ public PageLinkColumn(String columnId, String propertyLabel,
@Override
public void onClick(IModel<I> rowModel)
{
- //To change body of implemented methods use File | Settings | File
- // Templates.
RequestCycle.get().setResponsePage(page);
}
@@ -13,16 +13,20 @@
import com.inmethod.icon.Icon;
/**
- * Created by IntelliJ IDEA.
- * User: Tom Burton
- * Date: 12/27/11
- * Time: 1:15 PM
+ * extends {@link SubmitCancelColumn} with a third button, Delete
*
- * @author Tom Burton
- * To change this template use File | Settings | File Templates.
+ * @param <M> grid model object type
+ * @param <I> row/item model object type
+ *
+ * @author Tom Burton
*/
public class AddDeleteColumn<M, I> extends SubmitCancelColumn<M, I>
{
+
+ /** Create a new AddDeleteColumn
+ * @param columnId column identifier - must be unique within the grid
+ * @param headerModel model for column title
+ */
public AddDeleteColumn(String columnId, IModel<String> headerModel)
{
super(columnId, headerModel);
@@ -38,7 +42,7 @@ public Component newCell(WebMarkupContainer parent, String componentId,
private static final long serialVersionUID = 1L;
private WebMarkupContainer getRowComponent()
- { return getGrid().findParentRow(this); };
+ { return getGrid().findParentRow(this); }
@Override
protected void onCancel(AjaxRequestTarget target)
@@ -9,12 +9,8 @@
import com.inmethod.icon.IconImage;
/**
- * Panel for the AddDeleteColumn displays: Add, Cancel, and Delete buttons
- *
- * Created by IntelliJ IDEA.
- * User: Tom Burton
- * Date: 12/27/11
- * Time: 12:01 PM
+ * Backing Panel for {@link AddDeleteColumn}
+ * displays: Add, Cancel, and Delete buttons
*
* @author Tom Burton
*/
@@ -9,9 +9,11 @@
import com.inmethod.grid.column.AbstractColumn;
/**
+ * Backing Panel for {@link CheckBoxPropertyColumn}
* Panel with a Checkbox that updates the property of the row immediately after
* user leaves the field.
* based on(read: copy-paste-modify) {@link TextFieldPanel} By Matej Knopp
+ *
* @author Tom Burton
*/
public class CheckBoxPanel<M, I> extends EditableCellPanel<M, I, Boolean>
@@ -116,7 +116,8 @@ protected DateTextField newDateTextField(final String id, final IModel model,
@Override
- public FormComponent getEditComponent() {
+ public FormComponent getEditComponent()
+ {
return (FormComponent) get(DateTextField_ID);
}
}
@@ -15,11 +15,10 @@
import com.inmethod.grid.column.AbstractColumn;
/**
- * Panel with a DropDownChoice that updates the property of the row immediately after
- * user leaves the field.
+ * Backing Panel for {@link DropDownChoiceColumn} with a {@link DropDownChoice}
+ * that updates the property of the row immediately after the user leaves the field.
*
* @author Tom Burton
- * TODO: make Generic
*/
public class DropDownChoicePanel<M, I, P> extends EditableCellPanel<M, I, P>
{ //Does serialVersionUID really need to be explicitly set

0 comments on commit e2e7d2d

Please sign in to comment.