All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.sf.wcfart.wcf.changeorder.package.html Maven / Gradle / Ivy

The newest version!



Generates buttons to change the order of elements in a list or tree.

There are 2 user interfaces available: forward/backward buttons and cut/paste buttons. The UI is choosen by ChangeOrderMgr.setCutPasteMode(boolean), default is forward/backward.

Forward/Backward mode

Every node gets buttons for "move forward" and "move backward". Allows the user to move a node for one position with each click. This is easy for small amount of nodes, but requires many clicks for larger amount.

Appends "move-button" elements to the DOM with "style" attribute "fwd" or "bwd", e.g. <move-button id="wcf.e5f8fbfc" style="bwd"/>

Cut/Paste mode

Every node has a "cut" button. When the user selects a node by pressing that button, the ChangeOrderMgr goes into paste mode and renders paste buttons for those nodes that share the same parent (aka scope) with the selected node. If the user clicks on a paste button, the node is moved to that posision. If he clicks elsewhere (e.g. collapses a tree node), the ChangeOrderMgr goes back into cut mode.

Appends "move-button" elements to the DOM with "style" attribute "cut", "paste" or "uncut", e.g. <move-button id="wcf.e5f8fbfc" style="cut"/>

Usage pattern

class MyComponent implements Component {

  public void initialize(RequestContext context, Environment env) {
    ...
    changeOrderMgr = new ChangeOrderMgr(dispatcher, env, model);
    changeOrderMgr.setCutPasteMode(true);
  }
  
  public Document render(RequestContext context) throws Exception {
    Document document = XmlUtils.createDocument();
    changeOrderMgr.startRendering(context);
    for (int nodeIndex = 0; nodeIndex < nodeCount; nodeIndex++) {
      Object node = ...
      Object parent = getParent(node);
      Element elem = renderElement(node);
      changeOrderMgr.renderButton(element, parent, node, nodeIndex, nodeCount);
    }
    changeOrderMgr.stopRendering();
    return document;
  }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy