com.google.gwt.event.logical.shared.OpenEvent Java Examples

The following examples show how to use com.google.gwt.event.logical.shared.OpenEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MaterialTreeItem.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void select() {
    // Fire selection event
    SelectionEvent.fire(getTree(), this);

    List<MaterialTreeItem> treeItems = getTreeItems();
    if (!treeItems.isEmpty()) {
        for (MaterialTreeItem treeItem : treeItems) {
            if (hide) {
                treeItem.setVisible(false);
            } else {
                treeItem.setVisible(true);
            }
        }
        // Firing of events based on the status of the tree item
        if (hide) {
            CloseEvent.fire(getTree(), this);
            hide = false;
        } else {
            OpenEvent.fire(getTree(), this);
            hide = true;
        }
    }
}
 
Example #2
Source File: MaterialTreeTest.java    From gwt-material-addins with Apache License 2.0 6 votes vote down vote up
public void testImageItems() {
    // given
    final String URL_OPEN = "open.png";
    final String URL_CLOSE = "close.png";
    MaterialTree tree = getWidget();

    // when / then
    tree.clear();
    assertEquals(0, tree.getWidgetCount());

    MaterialTreeItem item = new MaterialTreeItem();
    item.setText("Tree Item");
    tree.add(item);
    assertEquals(1, tree.getWidgetCount());

    // Check Open
    tree.addOpenHandler(openEvent -> openEvent.getTarget().setUrl(URL_OPEN));
    OpenEvent.fire(tree, item);
    assertEquals(URL_OPEN, item.getImage().getUrl());

    // Check Close
    tree.addCloseHandler(closeEvent -> closeEvent.getTarget().setUrl(URL_CLOSE));
    CloseEvent.fire(tree, item);
    assertEquals(URL_CLOSE, item.getImage().getUrl());
}
 
Example #3
Source File: TractionDialogBox.java    From gwt-traction with Apache License 2.0 6 votes vote down vote up
/**
    * Overrides show to call {@link #adjustGlassSize()} if the dialog
    * is already showing and fires an {@link OpenEvent} after the
    * normal show.
    */
   @Override
   public void show() {
boolean fireOpen = !isShowing();
super.show();

// adjust the size of the glass
if (isShowing()) {
    adjustGlassSize();
}

// fire the open event
if (fireOpen) {
    OpenEvent.fire(this, this);
}
   }
 
Example #4
Source File: CurriculaCourses.java    From unitime with Apache License 2.0 5 votes vote down vote up
public void addBlankLine() {
	List<Widget> line = new ArrayList<Widget>();

	HorizontalPanel hp = new HorizontalPanel();
	line.add(hp);

	CurriculaCourseSelectionBox cx = new CurriculaCourseSelectionBox();
	cx.setWidth("130px");
	cx.addCourseSelectionHandler(iCourseChangedHandler);
	if (cx.getCourseFinder() instanceof HasOpenHandlers)
		((HasOpenHandlers<PopupPanel>)cx.getCourseFinder()).addOpenHandler(new OpenHandler<PopupPanel>() {
			@Override
			public void onOpen(OpenEvent<PopupPanel> event) {
				iTable.clearHover();
			}
		});
	if (!iEditable) cx.setEnabled(false);
	line.add(cx);
	
	for (int col = 0; col < iClassifications.getClassifications().size(); col++) {
		ShareTextBox ex = new ShareTextBox(col, null, null);
		if (!iEditable) ex.setReadOnly(true);
		line.add(ex);
		EnrollmentLabel note = new EnrollmentLabel(col, null, null, null, null, null, null);
		line.add(note);
	}
	
	int row = iTable.addRow("", line);
	iTable.getRowFormatter().addStyleName(row, "unitime-NoPrint");
	if (iVisibleCourses != null) iTable.getRowFormatter().setVisible(row, false);
	for (int col = 0; col < line.size(); col++)
		if (!iTable.getCellFormatter().isVisible(0, col))
			iTable.getCellFormatter().setVisible(row, col, false);
}
 
Example #5
Source File: UniTimeDialogBox.java    From unitime with Apache License 2.0 5 votes vote down vote up
@Override
public void show() {
    boolean fireOpen = !isShowing();
    super.show();
    if (fireOpen) {
        OpenEvent.fire(this, this);
    }
}
 
Example #6
Source File: UniTimeDialogBox.java    From unitime with Apache License 2.0 4 votes vote down vote up
public HandlerRegistration addOpenHandler(OpenHandler<UniTimeDialogBox> handler) {
    return addHandler(handler, OpenEvent.getType());
}
 
Example #7
Source File: TractionDialogBox.java    From gwt-traction with Apache License 2.0 4 votes vote down vote up
@Override
   public HandlerRegistration addOpenHandler(OpenHandler<TractionDialogBox> handler) {
return addHandler(handler, OpenEvent.getType());
   }
 
Example #8
Source File: CellTreeNodeView.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Sets whether this item's children are displayed.
 *
 * @param open       whether the item is open
 * @param fireEvents true to fire events if the state changes
 * @return true if successfully opened, false otherwise.
 */
public boolean setOpen(boolean open, boolean fireEvents) {
  // Early out.
  if (this.open == open) {
    return this.open;
  }

  // If this node is a leaf node, do not call TreeViewModel.getNodeInfo().
  if (open && isLeaf()) {
    return false;
  }

  // The animation clears the innerHtml of the childContainer. If we reopen a
  // node as its closing, it is possible that the new data will be set
  // synchronously, so we have to cancel the animation before attaching the
  // data display to the node info.
  tree.cancelTreeNodeAnimation();
  this.animate = true;
  this.open = open;
  if (open) {
    if (!nodeInfoLoaded) {
      nodeInfoLoaded = true;
      nodeInfo = tree.getNodeInfo(value);

      // Sink events for the new node.
      if (nodeInfo != null) {
        Set<String> eventsToSink = new HashSet<String>();
        // Listen for focus and blur for keyboard navigation
        eventsToSink.add(BrowserEvents.FOCUS);
        eventsToSink.add(BrowserEvents.BLUR);

        Set<String> consumedEvents = nodeInfo.getCell().getConsumedEvents();
        if (consumedEvents != null) {
          eventsToSink.addAll(consumedEvents);
        }
        CellBasedWidgetImpl.get().sinkEvents(tree, eventsToSink);
      }
    }

    // If we don't have any nodeInfo, we must be a leaf node.
    if (nodeInfo != null) {
      // Add a loading message.
      ensureChildContainer();
      showOrHide(showMoreElem, false);
      showOrHide(emptyMessageElem, false);
      if (!isRootNode()) {
        setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), true);
      }
      ensureAnimationFrame().getStyle().setProperty("display", "");
      onOpen(nodeInfo);

      // Fire an event.
      if (fireEvents) {
        OpenEvent.fire(tree, getTreeNode());
      }
    }
    else {
      this.open = false;
    }
  }
  else {
    if (!isRootNode()) {
      setStyleName(getCellParent(), tree.getStyle().cellTreeOpenItem(), false);
    }
    cleanup(false);
    tree.maybeAnimateTreeNode(this);
    updateImage(false);

    // Keyboard select this node if the open node was a child.
    CellTreeNodeView<?> keySelected = tree.getKeyboardSelectedNode();
    while (keySelected != null) {
      if (keySelected == this) {
        tree.keyboardSelect(this, true);
        break;
      }
      keySelected = keySelected.getParentNode();
    }

    // Fire an event.
    if (fireEvents) {
      CloseEvent.fire(tree, getTreeNode());
    }
  }

  return this.open;
}
 
Example #9
Source File: CellBrowser.java    From consulo with Apache License 2.0 4 votes vote down vote up
/**
 * Update the state of a child node based on the keyboard selection of the
 * specified {@link BrowserCellList}. This method will open/close child
 * {@link TreeNode}s as needed.
 *
 * @param cellList the CellList that changed state.
 * @param fireEvents true to fireEvents
 * @return the open {@link TreeNode}, or null if not opened
 */
private <C> TreeNode updateChildState(BrowserCellList<C> cellList, boolean fireEvents) {
  /*
   * Verify that the specified list is still in the browser. It possible for
   * the list to receive deferred updates after it has been removed
   */
  if (cellList.isDestroyed) {
    return null;
  }

  // Get the key of the value to open.
  C newValue = cellList.getPresenter().getKeyboardSelectedRowValue();
  Object newKey = cellList.getValueKey(newValue);

  // Close the current open node.
  TreeNode closedNode = null;
  if (cellList.focusedKey != null && cellList.isFocusedOpen
      && !cellList.focusedKey.equals(newKey)) {
    // Get the node to close.
    closedNode =
            (treeNodes.size() > cellList.level + 1) ? treeNodes.get(cellList.level + 1) : null;

    // Close the node.
    trimToLevel(cellList.level);
  }

  // Open the new node.
  TreeNode openNode = null;
  boolean justOpenedNode = false;
  if (newKey != null) {
    if (newKey.equals(cellList.focusedKey)) {
      // The node is already open.
      openNode = cellList.isFocusedOpen ? treeNodes.get(cellList.level + 1) : null;
    } else {
      // Select this value.
      if (KeyboardSelectionPolicy.BOUND_TO_SELECTION == getKeyboardSelectionPolicy()) {
        cellList.setSelectedValue(newValue);
      }

      // Add the child node if this node has children.
      cellList.focusedKey = newKey;
      NodeInfo<?> childNodeInfo = isLeaf(newValue) ? null : getNodeInfo(newValue);
      if (childNodeInfo != null) {
        cellList.isFocusedOpen = true;
        justOpenedNode = true;
        openNode = appendTreeNode(childNodeInfo, newValue);
      }
    }
  }

  /*
   * Fire event. We fire events after updating the view in case user event
   * handlers modify the open state of nodes, which would interrupt the
   * process.
   */
  if (fireEvents) {
    if (closedNode != null) {
      CloseEvent.fire(this, closedNode);
    }
    if (openNode != null && justOpenedNode) {
      OpenEvent.fire(this, openNode);
    }
  }

  // Return the open node if it is still open.
  return (openNode == null || openNode.isDestroyed()) ? null : openNode;
}
 
Example #10
Source File: ContentBox.java    From core with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Override
public void onOpen(final OpenEvent<DisclosurePanel> event) {
    setIconClassname("icon-angle-down");
}