Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

  • firebet
    started a topic Re-ordering clauses in FilterBuilder

    Re-ordering clauses in FilterBuilder

    SmartClient Version: v11.1p_2018-03-28/Pro Deployment (built 2018-08-04)

    We persist the state of FilterBuilders to use as templates for other FilterBuilders. Occasionally our users want to update the templates with new clauses, but because the templates can sometimes be large and complex, they want to add clauses to specific places to 'fit' with other (similar) fields for visual purposes. At the moment they have to add new clauses to the end of the filter section that the clause applies to, and there doesn't seem to be a way of re-ordering a filter section without deleting it and re-creating in the 'right' order.

    Is filter clause 're-ordering' supported in FilterBuilder?

  • Isomorphic
    replied
    Wow!

    A VStack of FilterBuilders would have been simpler, faster, easier to maintain, and could be made to look and behave exactly the same. That's still the approach we'd recommend for anyone reading this thread.

    Leave a comment:


  • firebet
    replied
    For anyone else looking for a solution, my eventual approach was to use MouseOverEvent and a tree-walking Visitor pattern, checking canvases with Canvas.containsPoint(x,y) to identify which FilterClause in the FilterBuilder the user is currently selecting. You can get the FilterClause by examining the Canvas types returned by FilterBuilder.getClauseStack().getMembers(). While hovering, I keep track of the current canvas member number/position.

    To visually aid the user which clause is currently selected, I highlight the background of the FilterClause form for clarity as the user moves the mouse over the FilterBuilder.

    For deciding which action to take, rather than modifying the AutoChildren with additional controls, I use a right-click event which opens a "Up/Down" context menu on FilterBuilder. When the user selects an action, do a boundary check on the current position, based on the underlying FilterBuilder.getCriteria().getCriteria() array and then if the move can be made, get the Criterion array from the selected FilterBuilder, swap the selected position in the array with the adjacent position and call setCriteria() on the target FilterBuilder with the modified Criterion array.

    I went for a context menu approach as it's extensible (allows me to create additional actions like "To Top", "To End") without cluttering the display with additional controls.

    It isn't the fastest solution, as it has to effectively rebuild the FilterBuilder to redisplay it, but it works consistently. The solution also has a reliance on the underlying component types of FilterBuilder, which may change between releases, so YMMV.

    Leave a comment:


  • Isomorphic
    replied
    There is no built-in UI for this. The simplest approach would be Feature Sponsorship to add reorder controls. Other approaches would be using a stack of FilterBuilders with your own reorder controls, or subclassing FilterBuilder to add them by placing them next to the AutoChildren it creates.

    Leave a comment:

Working...
X