Пример #1
0
  private void BuildList(String Filter) {

    Iterator<Entry<String, pojoMethod>> it = this.methodList.entrySet().iterator();

    int i = 0;
    this._MenuStack.clear();
    this._MenuStack.removeAllRows();

    // this._MenuStack.setHeight(height)
    // We need to set Height of the parent panel dynamically based on the number of items
    // We need to add a hidden field with a unique id
    while (it.hasNext()) {
      // Use of final to allow access to it in the clickHandlers
      final int index = i; // This keeps track of which item we are looking at
      Entry<String, pojoMethod> tmpEntry = it.next();
      final pojoMethod tmpMethod = tmpEntry.getValue();
      //
      String comp1 = tmpMethod.getMethodName().toLowerCase();
      String comp2 = Filter.toLowerCase();
      if (comp1.contains(comp2)) {
        final Label titleLabel = new Label();
        titleLabel.setText(tmpMethod.getMethodName());
        titleLabel.addStyleName("menuMethodName");
        final int _i = i;
        // _edit.setStyleName("btnEditMethod");
        titleLabel.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent event) {

                // set selected style/should shuffle as well
                setActiveMenu(tmpMethod.getMethodID());
                eventBus.fireEvent(
                    new DragEvent(titleLabel.getText(), "EditMethod", index, (IPojo) tmpMethod));
              }
            });

        // this._MenuStack.setWidget(i,0,tmpItem.asWidget());
        this._MenuStack.setWidget(i, 0, titleLabel);
        // this._MenuStack.setWidget(i,1,_edit);
        Hidden tmpHidden = new Hidden();
        tmpHidden.setValue(tmpMethod.getMethodID());
        this._MenuStack.setWidget(i, 1, tmpHidden);
        _MenuStack.getFlexCellFormatter()
            .getElement(i, 0)
            .setAttribute("style", "border-right:Solid 1px #ccc;");
        // _MenuStack.getFlexCellFormatter().getElement(i, 1).setAttribute("style",
        // "padding-left:5px;");
        i++;
      }
    }

    _MenuStack.setCellPadding(0);
    _MenuStack.setCellSpacing(0);
    int newHeight = _MenuStack.getRowCount() * 30;
    this._MenuStack.setHeight(newHeight + "px");
  }
Пример #2
0
  /*
   * (non-Javadoc)
   * @see monbulk.shared.Services.MethodService.MethodServiceHandler#onReadMethodList(java.util.ArrayList)
   */
  @Override
  public void onReadMethodList(ArrayList<pojoMethod> arrMethods) {
    try {
      Iterator<pojoMethod> it = arrMethods.iterator();
      SearchWidget _SearchWidget = new SearchWidget(this);
      this._searchPanel.add(_SearchWidget.getHeaderWidget());
      int i = 0;

      while (it.hasNext()) {
        // Use of final to allow access to it in the clickHandlers
        final int index = i; // This keeps track of which item we are looking at
        final pojoMethod tmpMethod = it.next();
        this.methodList.put(tmpMethod.getMethodID(), tmpMethod);

        final Label titleLabel = new Label();
        titleLabel.setText(tmpMethod.getMethodName());
        titleLabel.addStyleName("menuMethodName");
        // titleLabel.setWidth("150px");

        //	PushButton _clone = new PushButton();
        //	_clone.setStyleName("btnCloneMethod");
        //	_clone.addClickHandler(new ClickHandler()
        //	{

        //		@Override
        //		public void onClick(ClickEvent event) {
        //			setActiveMenu(titleLabel.getText());
        //			eventBus.fireEvent(new
        // DragEvent(titleLabel.getText(),"CloneMethod",index,(IPojo)tmpMethod));
        //
        //		}
        //
        //	});

        /// PushButton _edit = new PushButton();
        // _edit.setStyleName("btnEditMethod");
        titleLabel.addClickHandler(
            new ClickHandler() {

              @Override
              public void onClick(ClickEvent event) {

                // set selected style/should shuffle as well
                setActiveMenu(tmpMethod.getMethodID());
                eventBus.fireEvent(
                    new DragEvent(titleLabel.getText(), "EditMethod", index, (IPojo) tmpMethod));
              }
            });
        // this._MenuStack.setWidget(i,0,tmpItem.asWidget());
        this._MenuStack.setWidget(i, 0, titleLabel);

        // this._MenuStack.setWidget(i,1,_edit);
        Hidden tmpHidden = new Hidden();
        tmpHidden.setValue(tmpMethod.getMethodID());
        this._MenuStack.setWidget(i, 1, tmpHidden);
        if (tmpMethod.getMethodName().length() > 38) {
          _MenuStack.getFlexCellFormatter().setStyleName(i, 0, "long");
        }
        _MenuStack.getFlexCellFormatter().getElement(i, 0).setAttribute("style", "");
        // _MenuStack.getFlexCellFormatter().getElement(i, 1).setAttribute("style",
        // "padding-left:5px;");
        i++;
      }

      _MenuStack.setCellPadding(0);
      _MenuStack.setCellSpacing(0);
    } catch (Exception ex) {
      GWT.log(
          "Error occurs @ MethodList.onReadMethodList"
              + ex.getMessage()
              + ex.getStackTrace().toString());
    }
  }