Example #1
0
 private static void updateSelectionListener(final Tree tree) throws IOException {
   Boolean newValue = Boolean.valueOf(SelectionEvent.hasListener(tree));
   String prop = PROP_SELECTION_LISTENERS;
   if (WidgetLCAUtil.hasChanged(tree, prop, newValue, Boolean.FALSE)) {
     JSWriter writer = JSWriter.getWriterFor(tree);
     writer.set("selectionListeners", newValue);
   }
 }
Example #2
0
 public void renderChanges(final Widget widget) throws IOException {
   Tree tree = (Tree) widget;
   ControlLCAUtil.writeChanges(tree);
   updateSelectionListener(tree);
   writeHeaderHeight(tree);
   writeHeaderVisible(tree);
   writeColumnOrder(tree);
   writeScrollLeft(tree);
   writeOverflow(tree);
   WidgetLCAUtil.writeCustomVariant(tree);
 }
Example #3
0
 public void readData(final Widget widget) {
   Tree tree = (Tree) widget;
   readSelection(tree);
   readScrollPosition(tree);
   processWidgetSelectedEvent(tree);
   processWidgetDefaultSelectedEvent(tree);
   ControlLCAUtil.processMouseEvents(tree);
   ControlLCAUtil.processKeyEvents(tree);
   ControlLCAUtil.processMenuDetect(tree);
   WidgetLCAUtil.processHelp(tree);
 }
Example #4
0
 private static void readScrollPosition(final Tree tree) {
   String left = WidgetLCAUtil.readPropertyValue(tree, "scrollLeft");
   String top = WidgetLCAUtil.readPropertyValue(tree, "scrollTop");
   if (left != null && top != null) {
     Object adapter = tree.getAdapter(ITreeAdapter.class);
     final ITreeAdapter treeAdapter = (ITreeAdapter) adapter;
     final int newScrollLeft = parsePosition(left);
     final int newScrollTop = parsePosition(top);
     final int oldScrollTop = treeAdapter.getScrollTop();
     treeAdapter.setScrollLeft(newScrollLeft);
     treeAdapter.setScrollTop(newScrollTop);
     if (oldScrollTop != newScrollTop) {
       ProcessActionRunner.add(
           new Runnable() {
             public void run() {
               treeAdapter.checkAllData(tree);
             }
           });
     }
   }
 }
Example #5
0
 private static void processWidgetDefaultSelectedEvent(final Tree tree) {
   HttpServletRequest request = ContextProvider.getRequest();
   String eventName = JSConst.EVENT_WIDGET_DEFAULT_SELECTED;
   if (WidgetLCAUtil.wasEventSent(tree, eventName)) {
     String itemId = request.getParameter(eventName + ".item");
     Item treeItem = (Item) WidgetUtil.find(tree, itemId);
     int eventType = SelectionEvent.WIDGET_DEFAULT_SELECTED;
     SelectionEvent event = new SelectionEvent(tree, treeItem, eventType);
     event.stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER);
     event.processEvent();
   }
 }
Example #6
0
 private static void writeOverflow(final Tree tree) throws IOException {
   boolean hasHChanged =
       WidgetLCAUtil.hasChanged(tree, PROP_HAS_H_SCROLL_BAR, hasHScrollBar(tree), Boolean.TRUE);
   boolean hasVChanged =
       WidgetLCAUtil.hasChanged(tree, PROP_HAS_V_SCROLL_BAR, hasVScrollBar(tree), Boolean.TRUE);
   if (hasHChanged || hasVChanged) {
     boolean scrollX = hasHScrollBar(tree).booleanValue();
     boolean scrollY = hasVScrollBar(tree).booleanValue();
     String overflow;
     if (scrollX && scrollY) {
       overflow = "scroll";
     } else if (scrollX) {
       overflow = "scrollX";
     } else if (scrollY) {
       overflow = "scrollY";
     } else {
       overflow = "hidden";
     }
     JSWriter writer = JSWriter.getWriterFor(tree);
     writer.set("treeOverflow", overflow);
   }
 }
Example #7
0
 private void writeColumnOrder(final Tree tree) throws IOException {
   JSWriter writer = JSWriter.getWriterFor(tree);
   int[] values = tree.getColumnOrder();
   if (values.length > 0) {
     Integer[] newValue = new Integer[values.length];
     for (int i = 0; i < values.length; i++) {
       newValue[i] = new Integer(values[i]);
     }
     if (WidgetLCAUtil.hasChanged(tree, PROP_COLUMN_ORDER, newValue, new Integer[] {})) {
       writer.set(PROP_COLUMN_ORDER, "columnOrder", newValue, null);
     }
   }
 }
Example #8
0
 private static void processWidgetSelectedEvent(final Tree tree) {
   HttpServletRequest request = ContextProvider.getRequest();
   String eventName = JSConst.EVENT_WIDGET_SELECTED;
   if (WidgetLCAUtil.wasEventSent(tree, eventName)) {
     Rectangle bounds = new Rectangle(0, 0, 0, 0);
     String itemId = request.getParameter(eventName + ".item");
     Item treeItem = (Item) WidgetUtil.find(tree, itemId);
     String detailStr = request.getParameter(eventName + ".detail");
     int detail = "check".equals(detailStr) ? SWT.CHECK : SWT.NONE;
     int eventType = SelectionEvent.WIDGET_SELECTED;
     int stateMask = EventLCAUtil.readStateMask(JSConst.EVENT_WIDGET_SELECTED_MODIFIER);
     SelectionEvent event =
         new SelectionEvent(tree, treeItem, eventType, bounds, stateMask, null, true, detail);
     event.processEvent();
   }
 }
Example #9
0
 public void preserveValues(final Widget widget) {
   Tree tree = (Tree) widget;
   ControlLCAUtil.preserveValues((Control) widget);
   IWidgetAdapter adapter = WidgetUtil.getAdapter(tree);
   adapter.preserve(PROP_SELECTION_LISTENERS, Boolean.valueOf(SelectionEvent.hasListener(tree)));
   adapter.preserve(PROP_HEADER_HEIGHT, new Integer(tree.getHeaderHeight()));
   adapter.preserve(PROP_HEADER_VISIBLE, Boolean.valueOf(tree.getHeaderVisible()));
   int[] values = tree.getColumnOrder();
   Integer[] columnOrder = new Integer[values.length];
   for (int i = 0; i < values.length; i++) {
     columnOrder[i] = new Integer(values[i]);
   }
   adapter.preserve(PROP_COLUMN_ORDER, columnOrder);
   adapter.preserve(PROP_SCROLL_LEFT, getScrollLeft(tree));
   adapter.preserve(PROP_HAS_H_SCROLL_BAR, hasHScrollBar(tree));
   adapter.preserve(PROP_HAS_V_SCROLL_BAR, hasVScrollBar(tree));
   WidgetLCAUtil.preserveCustomVariant(tree);
 }
Example #10
0
 private static void readSelection(final Tree tree) {
   String value = WidgetLCAUtil.readPropertyValue(tree, "selection");
   if (value != null) {
     String[] values = value.split(",");
     TreeItem[] selectedItems = new TreeItem[values.length];
     boolean validItemFound = false;
     for (int i = 0; i < values.length; i++) {
       selectedItems[i] = (TreeItem) WidgetUtil.find(tree, values[i]);
       if (selectedItems[i] != null) {
         validItemFound = true;
       }
     }
     if (!validItemFound) {
       selectedItems = new TreeItem[0];
     }
     tree.setSelection(selectedItems);
   }
 }