Skip to content

Instantly share code, notes, and snippets.

@smee
Created November 30, 2009 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save smee/245506 to your computer and use it in GitHub Desktop.
Save smee/245506 to your computer and use it in GitHub Desktop.
import java.util.Collections;
import org.apache.wicket.ResourceReference;
public class MoveDownButton extends EditorButton {
public MoveDownButton(final String id) {
super(id, new ResourceReference(MoveDownButton.class, "images/down.png"));
}
@Override
public boolean isEnabled() {
return getEditor().canMoveDown(getItem());
}
@Override
public void onSubmit() {
final int idx = getItem().getIndex();
final int itemCount = getItem().getParent().size();
if (idx < itemCount - 1 && itemCount > 1) {
Collections.swap(getList(), idx, idx + 1);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment