Java 类com.google.gwt.user.client.ui.TreeItem 实例源码

项目:DocIT    文件:TreePanel.java   
public TreePanel(GwtTree main) {
    this.main = main;

    this.addSelectionHandler(new SelectionHandler<TreeItem>() {

        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            Object obj = event.getSelectedItem().getUserObject();
            if (obj instanceof CompanyItem) {
                TreePanel.this.main.showCompany(((CompanyItem)obj).getId());
            } else if (obj instanceof DepartmentItem) {
                TreePanel.this.main.showDepartment(((DepartmentItem)obj).getId());
            } else if (obj instanceof EmployeeItem) {
                TreePanel.this.main.showEmployee(((EmployeeItem)obj).getId());
            }
        }
    });
}
项目:EasyML    文件:CopyOfModuleTree.java   
/**
 * Find the TreeItem for a category. If it not exists, create it.
 * TODO: reconstruct
 * @param category category of a moduleId
 * @return TreeItem of the moduleId corresponding to the category
 */
public TreeItem findTreeItem(String category) {
    // default return the system Tree
    if (category.equals(""))
        return getSysTree();

    TreeItem treeItem = sysTreeMap.get(category);
    if (treeItem == null) {
        // Category doesn't exist, create new TreeItems
        int splitIdx = category.lastIndexOf('>');
        String parentCategory = category.substring(0, splitIdx);
        String cateName = category.substring(splitIdx + 1, category.length());
        TreeItem parentItem = findTreeItem(parentCategory);

        //      treeItem = parentItem.addTextItem(cateName);
        treeItem = parentItem.addTextItem(Globalization.getI18NString(cateName));
        treeItem.setState(true);
        sysTreeMap.put(category, treeItem);
    }
    return treeItem;
}
项目:EasyML    文件:BaseTree.java   
public BaseTree() {
    super(new TreeImageResources(), true);

    this.addStyleName("bda-treedir");

    this.addSelectionHandler(new SelectionHandler<TreeItem>() {
        @Override
        public void onSelection(SelectionEvent<TreeItem> event) {
            TreeItem item = event.getSelectedItem();
            Boolean state = item.getState();
            // [GWT Issue 3660] to avoid pass invoke onSection two times
            TreeItem parent = item.getParentItem();
            item.getTree().setSelectedItem(parent, false);
            if (parent != null)
                parent.setSelected(false);
            item.setState(!state);
        }
    });
}
项目:appinventor-extensions    文件:AssetList.java   
private void refreshAssetList() {
  OdeLog.log("AssetList: refreshing for project " + projectId);
  assetList.clear();

  if (assetsFolder != null) {
    for (ProjectNode node : assetsFolder.getChildren()) {
      // Add the name to the tree. We need to enclose it in a span
      // because the CSS style for selection specifies a span.
      String nodeName = node.getName();
      if (nodeName.length() > 20)
        nodeName = nodeName.substring(0, 8) + "..." + nodeName.substring(nodeName.length() - 9,
            nodeName.length());
      TreeItem treeItem = new TreeItem(
          new HTML("<span>" + nodeName + "</span>"));
      // keep a pointer from the tree item back to the actual node
      treeItem.setUserObject(node);
      assetList.addItem(treeItem);
    }
  }
}
项目:appinventor-extensions    文件:BlockSelectorBox.java   
/**
 * Constructs a tree item for built-in blocks.
 *
 * @return tree item
 */
public TreeItem getBuiltInBlocksTree() {
  initBundledImages();
  TreeItem builtinNode = new TreeItem(new HTML("<span>" + MESSAGES.builtinBlocksLabel()
      + "</span>"));
  for (final String drawerName : BUILTIN_DRAWER_NAMES) {
    Image drawerImage = new Image(bundledImages.get(drawerName));
    TreeItem itemNode = new TreeItem(new HTML("<span>" + drawerImage
        + getBuiltinDrawerNames(drawerName) + "</span>"));
    SourceStructureExplorerItem sourceItem = new BlockSelectorItem() {
      @Override
      public void onSelected() {
        fireBuiltinDrawerSelected(drawerName);
      }
    };
    itemNode.setUserObject(sourceItem);
    builtinNode.addItem(itemNode);
  }
  builtinNode.setState(true);
  return builtinNode;
}
项目:appinventor-extensions    文件:BlockSelectorBox.java   
/**
 * Constructs a tree item for generic ("Advanced") component blocks for
 * component types that appear in form.
 *
 * @param form
 *          only component types that appear in this Form will be included
 * @return tree item for this form
 */
public TreeItem getGenericComponentsTree(MockForm form) {
  Map<String, String> typesAndIcons = Maps.newHashMap();
  form.collectTypesAndIcons(typesAndIcons);
  TreeItem advanced = new TreeItem(new HTML("<span>" + MESSAGES.anyComponentLabel() + "</span>"));
  List<String> typeList = new ArrayList<String>(typesAndIcons.keySet());
  Collections.sort(typeList);
  for (final String typeName : typeList) {
    TreeItem itemNode = new TreeItem(new HTML("<span>" + typesAndIcons.get(typeName)
        + MESSAGES.textAnyComponentLabel()
        + ComponentsTranslation.getComponentName(typeName) + "</span>"));
    SourceStructureExplorerItem sourceItem = new BlockSelectorItem() {
      @Override
      public void onSelected() {
        fireGenericDrawerSelected(typeName);
      }
    };
    itemNode.setUserObject(sourceItem);
    advanced.addItem(itemNode);
  }
  return advanced;
}
项目:LAS    文件:OutputPanel.java   
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
    DatasetWidget datasetWidget = datasetButton.getDatasetWidget();
    boolean isFromMyDatasetWidget = event.getSource().equals(datasetWidget);
    if (isFromMyDatasetWidget) {
        TreeItem item = event.getSelectedItem();
        Object variableUserObject = item.getUserObject();
        if (variableUserObject instanceof VariableSerializable) {
            VariableSerializable variable = (VariableSerializable) variableUserObject;
            // Remove extra variable UserLists before
            // applyVariableChange
            // TODO: Replace this with a higher level method or use
            // events
            variableControls.removeListBoxesExceptFirst();
            if ( variable.getAttributes().get("grid_type").equals(vizGalVariable.getAttributes().get("grid_type") )) {
                applyVariableChange(variable, true);
            } else {
                Window.alert("LAS cannot compare data on a grid with in-situ data.");
            }
        }
    }
}
项目:LAS    文件:DatasetWidget.java   
@Override
public void onSelection(SelectionEvent<TreeItem> event) {
    TreeItem item = event.getSelectedItem();
    currentlySelected = item;
    TreeItem child = item.getChild(0);
    if ( child != null && child.getText().equals(DatasetWidget.LOADING) ) {
        CategorySerializable cat = (CategorySerializable) item.getUserObject();
        Util.getRPCService().getCategories(cat.getID(), null, categoryCallback);
    }
    // Open the item.  Work around double firing bug.
    // http://code.google.com/p/google-web-toolkit/issues/detail?id=3660&q=Tree%20selection&colspec=ID%20Type%20Status%20Owner%20Milestone%20Summary%20Stars
    TreeItem selItem = event.getSelectedItem();
    TreeItem parent = selItem.getParentItem();
    selItem.getTree().setSelectedItem(parent, false); // null is ok
    if(parent != null)
        parent.setSelected(false);  // not compulsory
    selItem.setState(!selItem.getState(), false);

}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Adds folders to actual item if not exists or refreshes it values
 *
 * @param actualItem The actual item active
 * @param newItem New item to be added, or refreshed
 */
public void addFolder(TreeItem actualItem, TreeItem newItem) {
    int i = 0;
    boolean found = false;
    int count = actualItem.getChildCount();
    GWTFolder folder;
    GWTFolder newFolder = (GWTFolder) newItem.getUserObject();
    String folderPath = newFolder.getPath();

    for (i = 0; i < count; i++) {
        folder = (GWTFolder) actualItem.getChild(i).getUserObject();
        // If item is found actualizate values
        if ((folder).getPath().equals(folderPath)) {
            found = true;
            actualItem.getChild(i).setVisible(true);
            actualItem.getChild(i).setUserObject(newFolder);
            evaluesFolderIcon(actualItem.getChild(i));
        }
    }

    if (!found) {
        evaluesFolderIcon(newItem);
        actualItem.addItem(newItem);
    }
}
项目:document-management-system    文件:FolderSelectTree.java   
/**
 * Evalues actual folder icon to prevent other user interaction with the same folder
 * this ensures icon and object hasChildsValue are consistent
 */
public void evaluesFolderIcon(TreeItem item) {
    GWTFolder folderItem = (GWTFolder) item.getUserObject();
    preventFolderInconsitences(item);

    // Looks if must change icon on parent if now has no childs and properties with user security atention
    if ((folderItem.getPermissions() & GWTPermission.WRITE) == GWTPermission.WRITE) {
        if (folderItem.isHasChildren()) {
            item.setHTML(Util.imageItemHTML("img/menuitem_childs.gif", folderItem.getName(), "top"));
        } else {
            item.setHTML(Util.imageItemHTML("img/menuitem_empty.gif", folderItem.getName(), "top"));
        }
    } else {
        if (folderItem.isHasChildren()) {
            item.setHTML(Util.imageItemHTML("img/menuitem_childs_ro.gif", folderItem.getName(), "top"));
        } else {
            item.setHTML(Util.imageItemHTML("img/menuitem_empty_ro.gif", folderItem.getName(), "top"));
        }
    }
}
项目:document-management-system    文件:FolderTree.java   
/**
 * Remove folder from tree after deleted from repository ( normaly deleted
 * on file browser )
 *
 * @param path
 *            The folder
 */
public void removeDeleted(String path) {
    boolean found = false;
    int i = 0;

    while (!found && actualItem.getChildCount() > i) {
        TreeItem tmp = actualItem.getChild(i);

        if (((GWTFolder) tmp.getUserObject()).getPath().equals(path)) {
            actualItem.removeItem(tmp);
            found = true;
        }
        i++;
    }

    // Looks if must change icon on parent if now has no childs and
    // properties
    if (actualItem.getChildCount() < 1) {
        GWTFolder folderItem = (GWTFolder) actualItem.getUserObject();
        folderItem.setHasChildren(false);
    }

    evaluesFolderIcon(actualItem);
}
项目:document-management-system    文件:FolderTree.java   
/**
 * Get the child folder if folder child path exists on actual tree Item
 * selected
 *
 * @param path
 *            The path
 * @return
 */
public TreeItem getChildFolder(String path) {
    boolean found = false;
    int i = 0;
    TreeItem tmp;

    while (!found && actualItem.getChildCount() > i) {
        tmp = actualItem.getChild(i);

        if (((GWTFolder) tmp.getUserObject()).getPath().equals(path)) {
            found = true;
            return tmp;
        }
        i++;
    }

    return null;
}
项目:document-management-system    文件:FolderTree.java   
/**
 * Add temporary folder on creation
 */
public void addTmpFolderCreate() {
    if (folderAction == ACTION_NONE) {
        folderAction = ACTION_CREATE;
        FolderTextBox newFolder = new FolderTextBox();
        tmpFolder = new TreeItem();
        tmpFolder.setWidget(newFolder);
        tmpFolder.setStyleName("okm-TreeItem");
        newFolder.reset();
        newFolder.setText(Main.i18n("tree.folder.new"));
        actualItem.addItem(tmpFolder);
        actualItem.setState(true);
        actualItem.setSelected(false);
        tmpFolder.setSelected(true);
        actualItem = tmpFolder;
        // When we create a new folder we enables selection ( after it,
        // we'll return to disable) for a normal
        // use of the input (if not, cursor and selections not runs
        // propertly )
        rootItem.removeStyleName("okm-DisableSelect"); // Disables drag and
        // drop browser text
        // selection)
        newFolder.setFocus();
    }
}
项目:document-management-system    文件:FolderTree.java   
/**
 * Refresh tree iten values when tree folder is changed ( normally on file
 * browser, or by security ).
 *
 * @param folder
 *            The new folder values
 */
public void refreshChildValues(GWTFolder folder) {
    TreeItem tmpItem;
    GWTFolder gWTFolder;

    if (actualItem.getChildCount() > 0) {
        boolean found = false;
        int i = 0;

        while (!found && i < actualItem.getChildCount()) {
            tmpItem = actualItem.getChild(i);
            gWTFolder = (GWTFolder) tmpItem.getUserObject();
            if (folder.getPath().equals(gWTFolder.getPath())) {
                tmpItem.setUserObject(folder);
                evaluesFolderIcon(tmpItem);
                found = true;
            }
            i++;
        }
    }
}
项目:ephesoft    文件:ImportBatchClassView.java   
private void setImportFolderUI(final TreeItem treeItem, final Node rootNode, final Node newRootNode) {
    for (Node childNode : rootNode.getChildren()) {
        if (rootNode != null && rootNode.getLabel() != null && rootNode.getLabel().getDisplayName() != null
                && !rootNode.getLabel().getDisplayName().trim().isEmpty()) {
            Node node = new Node();
            node.getLabel().setDisplayName(childNode.getLabel().getDisplayName());
            node.getLabel().setKey(childNode.getLabel().getKey());
            node.setParent(childNode.getParent());
            CheckBox checkBox = new CheckBox();
            checkBox.setText(childNode.getLabel().getDisplayName().trim());
            TreeItem childTree = new TreeItem(checkBox);
            treeItem.addItem(childTree);
            createUI(childNode.getLabel().isMandatory(), checkBox, node, childTree);
            node.setParent(newRootNode);
            newRootNode.getChildren().add(node);
            if (childNode.getChildren() != null && !childNode.getChildren().isEmpty()) {
                setImportFolderUI(childTree, childNode, node);
            }
        }
    }
}
项目:ephesoft    文件:DocumentTree.java   
/**
 * @param docBean
 * @param docTitleLabel
 * @param docType
 * @param icon
 * @param docItem
 */
private void addDocDisplayItemsAndHandlers(final Document docBean, Label docTitleLabel, Label docType, Label icon,
        final TreeItem docItem) {
    String docDisplayProperty = getDocDisplayProperty(docBean, presenter.batchDTO.getDocDisplayName());
    DocumentTreeItem documentTreeItem = new DocumentTreeItem(docItem, docBean, icon, docDisplayProperty);
    addDocTreeItem(documentTreeItem);

    docItem.setTitle(documentTreeItem.documentTitle);
    docTitleLabel.setText(documentTreeItem.documentTitle);
    docType.setText(documentTreeItem.displayName);
    docTitleLabel.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent arg0) {
            if (docItem.getState()) {
                docItem.setState(Boolean.FALSE);
            } else {
                OpenEvent.fire(docTree, docItem);
            }
        }
    });
}
项目:synergynet3.1    文件:ExpressionView.java   
@Override
public void onSelection(SelectionEvent<TreeItem> event)
{
    TreeItem itemSelected = event.getSelectedItem();
    if (itemSelected.getUserObject() == null)
    {
        return;
    }
    String type = (String) itemSelected.getUserObject();
    if (type.equals("table"))
    {
        loadExpressionCollectionViewForTable(itemSelected.getText());
    }
    else if (type.equals("person"))
    {
        loadExpressionCollectionViewForPerson(itemSelected.getText());
    }
    else if (type.equals("target"))
    {
        loadExpressionCollectionViewForTarget(Double.parseDouble(itemSelected.getText()));
    }
}
项目:synergynet3.1    文件:ExpressionView.java   
/**
 * Load participant items.
 */
private void loadParticipantItems()
{
    NumberNetService.Util.getInstance().getAllParticipants(new AsyncCallback<List<Participant>>()
    {

        @Override
        public void onFailure(Throwable caught)
        {
            new MessageDialogBox(caught.getMessage()).show();
        }

        @Override
        public void onSuccess(List<Participant> result)
        {
            trtmByPerson.removeItems();
            for (Participant p : result)
            {
                TreeItem person = new TreeItem(SafeHtmlUtils.fromString(p.getName()));
                person.setUserObject("person");
                trtmByPerson.addItem(person);
            }
        }
    });
}
项目:aggregate    文件:AggregateUI.java   
/***********************************
 ****** HELP STUFF ******
 ***********************************/

private void changeHelpPanel(SubTabs subMenu) {
  // change root item
  rootItem.setText(subMenu + " Help");
  rootItem.removeItems();
  SubTabInterface subTabObj = getSubTab(subMenu);
  if (subTabObj != null) {
    HelpSliderConsts[] helpVals = subTabObj.getHelpSliderContent();
    if (helpVals != null) {
      for (int i = 0; i < helpVals.length; i++) {
        TreeItem helpItem = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getTitle()));
        TreeItem content = new TreeItem(SafeHtmlUtils.fromString(helpVals[i].getContent()));
        helpItem.setState(false);
        helpItem.addItem(content);
        rootItem.addItem(helpItem);
      }
    }
  }
  rootItem.setState(true);
  resize();
}
项目:gwtlib    文件:ShowcaseEntryPoint.java   
private void init(RootPanel root) {
  _deckPanel = new DeckPanel();
  _tree = createTree();
  _tree.addSelectionHandler(new SelectionHandler<TreeItem>() {
    public void onSelection(SelectionEvent<TreeItem> event) {
      TreeItem item = event.getSelectedItem();
      if(item.getUserObject() != null) {
        ContentWidget widget = (ContentWidget)item.getUserObject();
        widget.init();
        int i = _deckPanel.getWidgetIndex(widget);
        if(i != -1) _deckPanel.showWidget(i);
      }
    }
  });

  FlexTable table = new FlexTable();
  table.setWidget(0, 0, _tree);
  table.setWidget(0, 1, _deckPanel);
  table.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_TOP);

  root.add(table);
}
项目:optaplanner-wb    文件:TerminationConfigForm.java   
private void insertTreeItem(TreeItem treeItem,
                            TreeItem nestedTreeItem,
                            TerminationConfigOption terminationConfigOption) {
    if (treeItem.getChildCount() == 0) {
        treeItem.addItem(nestedTreeItem);
    } else {
        for (int i = 0; i < treeItem.getChildCount(); i++) {
            TerminationTreeItemContent childTreeItemContent = (TerminationTreeItemContent) treeItem.getChild(i).getUserObject();
            if (terminationConfigOption.ordinal() < childTreeItemContent.getTerminationConfigOption().ordinal()) {
                treeItem.insertItem(i,
                                    nestedTreeItem);
                break;
            }
            if (i == treeItem.getChildCount() - 1) {
                treeItem.addItem(nestedTreeItem);
                break;
            }
        }
    }
}
项目:optaplanner-wb    文件:TerminationConfigFormTest.java   
@Test
public void setModel() {
    TerminationConfigModel terminationConfigModel = new TerminationConfigModel();
    terminationConfigModel.setBestScoreFeasible(Boolean.TRUE);
    terminationConfigModel.setMillisecondsSpentLimit(10l);
    List<TerminationConfigModel> terminationConfigModelList = Arrays.asList(new TerminationConfigModel());
    terminationConfigModel.setTerminationConfigList(terminationConfigModelList);
    when(terminationTreeItemContentProvider.get()).thenReturn(terminationTreeItemContent);

    form.setModel(terminationConfigModel);

    ArgumentCaptor<TreeItem> treeItemArgumentCaptor = ArgumentCaptor.forClass(TreeItem.class);
    verify(view).initTree(treeItemArgumentCaptor.capture());

    TreeItem treeItem = treeItemArgumentCaptor.getValue();
    Assert.assertEquals(3,
                        treeItem.getChildCount());
}
项目:optaplanner-wb    文件:TerminationTreeItemContentTest.java   
@Test
public void removeTreeItem() {
    terminationTreeItemContent.setTreeItem(new TreeItem());
    terminationTreeItemContent.setTerminationConfigOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT);

    TreeItem rootTreeItem = mock(TreeItem.class);
    when(rootTreeItem.getChildCount()).thenReturn(0);
    when(terminationConfigForm.getRootTreeItem()).thenReturn(rootTreeItem);

    terminationTreeItemContent.removeTreeItem();

    verify(terminationConfigModel,
           times(1)).setMillisecondsSpentLimit(null);
    verify(view,
           times(1)).addDropDownOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT);
    verify(terminationConfigForm,
           times(1)).displayEmptyTreeLabel(true);
}
项目:che    文件:PreviewViewImpl.java   
private void checkParentState(TreeItem treeItem, Boolean value) {
  TreeItem parentItem = treeItem.getParentItem();

  if (parentItem == null) {
    return;
  }

  if (!(parentItem.getWidget() instanceof FlowPanel)) {
    return;
  }
  FlowPanel parentChangeContainer = (FlowPanel) parentItem.getWidget();

  if (!(parentChangeContainer.getWidget(0) instanceof CheckBox)) {
    return;
  }
  CheckBox parentCheckBox = (CheckBox) parentChangeContainer.getWidget(0);

  if (value && !parentCheckBox.getValue()) {
    parentCheckBox.setValue(true);
    checkParentState(parentItem, true);
  }
}
项目:che    文件:PreviewViewImpl.java   
private void checkChildrenState(TreeItem treeItem, Boolean value) {
  int childCount = treeItem.getChildCount();
  if (childCount == 0) {
    return;
  }

  for (int i = 0; i < childCount; i++) {
    TreeItem childItem = treeItem.getChild(i);
    if (!(childItem.getWidget() instanceof FlowPanel)) {
      return;
    }
    FlowPanel childItemContainer = (FlowPanel) childItem.getWidget();

    if (!(childItemContainer.getWidget(0) instanceof CheckBox)) {
      return;
    }
    CheckBox childCheckBox = (CheckBox) childItemContainer.getWidget(0);

    childCheckBox.setValue(value);
    checkChildrenState(childItem, value);
  }
}
项目:onecmdb    文件:CITreeWidget.java   
protected void updateCountItem(final TreeItem parent) {

    this.control.getChildCount(parent.getUserObject(), new AsyncCallback() {

        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        public void onSuccess(Object result) {
            if (result instanceof Integer) {
                int value = ((Integer)result).intValue();
                if (value > 0) {
                    TreeItem countItem = new TreeItem("Populating....");
                    countItem.setUserObject(result);    
                    parent.addItem(countItem);
                }

            }
        }

    });
}
项目:mvp4g-examples    文件:Mvp4gShowCase.java   
/**
 * This is the entry point method.
 */
public void onModuleLoad() {
  HorizontalPanel mainPanel = new HorizontalPanel();

  final MiddlePanel mPanel = new MiddlePanel();

  Tree menu = new Tree();
  menu.addSelectionHandler(new SelectionHandler<TreeItem>() {
    public void onSelection(SelectionEvent<TreeItem> event) {
      mPanel.set((MenuItem) event.getSelectedItem());
    }
  });

  initMenu(menu);
  mainPanel.add(menu);
  mainPanel.add(mPanel);
  menu.setSelectedItem(menu.getItem(0));
  mainPanel.setStyleName("mvp4gshowcase");
  RootPanel.get()
           .add(mainPanel);
}
项目:qafe-platform    文件:TreeRenderer.java   
void processChildren(TreeItem rootItem, TreeItemGVO[] children, String uuid, String parent, String context) {
    if (children != null) {
        for (int i = 0; i < children.length; i++) {
            TreeItemGVO componentGVO = children[i];
            UIObject uiObject = renderChildComponent(componentGVO, uuid, parent, context);
            if (uiObject instanceof QTreeItem) {
                QTreeItem treeItem = (QTreeItem) uiObject;
                treeItem.setState(componentGVO.getExpand().booleanValue());
                rootItem.addItem(treeItem);
                // TODO set Tree
                RendererHelper.fillIn(componentGVO, treeItem.getLabel(), uuid, parent, context);
                processChildren(treeItem, componentGVO.getChildren(), uuid, parent, context);
            }
            RendererHelper.fillIn(componentGVO, uiObject, uuid, parent, context);
        }
    }
}
项目:qafe-platform    文件:QTree.java   
private void createItemsFromKeyData(List itemList, String action, Object mapping) {
    if (itemList != null) {
        for (Object item : itemList) {
            String nodeKey = generateKey4Map(item, mapping);
            if (nodeKey != null) {                  
                Object parentItem = getParentItem(item, mapping);
                String parentKey = generateKey4Map(parentItem, mapping);

                TreeItem treeItem = createTreeItem(item, mapping);

                storeUIAndModel(nodeKey, treeItem, item);
                key2Parent.put(nodeKey, parentKey);
            }
        }   
    }
}
项目:qafe-platform    文件:QTree.java   
private void fireItemClickEvent(final SelectionEvent<TreeItem> event) {
    // When a qaml is listening to a tree with its id, and when clicks on parent tree , as the parent tree is also an item 
    // we dont have to do implicit click handling of item. otherwise 2 times the event will be executed.
    if (isRootItem(event.getSelectedItem())) {
        return;
    }

    if (rootItem instanceof QTreeItem) {
        final Label rootItemlabel =((QTreeItem)rootItem).getLabel();
        ClickEvent clickEvent = new ClickEvent() {
            // This is to make sure that we are making the item id and value available as src-id and src-value
            @Override
            public Object getSource() {
                if (event.getSelectedItem() instanceof QTreeItem) {
                    return ((QTreeItem)event.getSelectedItem()).getLabel();
                }
                return rootItemlabel;
            }
        };
        rootItemlabel.fireEvent(clickEvent);
    }
}
项目:qafe-platform    文件:QTree.java   
private void fillInAttributesFromRoot(String itemId, TreeItem treeItem) {
    String uuid = "";
    String appContext = "";
    String parent = "";

    String rootTreeId = RendererHelper.getComponentAttributeValue(this,  "id");
    itemId = itemId + rootTreeId.substring(rootTreeId.indexOf("|"));
    uuid = RendererHelper.getComponentPropertyValue(this, "uuid");
    appContext = RendererHelper.getComponentContext(this);
    parent = RendererHelper.getParentComponent(this);

    Label itemLabel = ((QTreeItem)treeItem).getLabel();
    DOM.setElementAttribute(itemLabel.getElement(), "id", itemId);
    DOM.setElementProperty(itemLabel.getElement(), "uuid", uuid);
    RendererHelper.setComponentContext(itemLabel, appContext);
    RendererHelper.setParentComponent(itemLabel, parent);
}
项目:qafe-platform    文件:TreeRenderer.java   
void processChildren(TreeItem rootItem, TreeItemGVO[] children, String uuid, String parent, String context) {
        if (children != null) {
            for (int i = 0; i < children.length; i++) {
                TreeItemGVO componentGVO = children[i];
                UIObject uiObject = renderChildComponent(componentGVO, null, uuid, parent, context, null);
//              if (uiObject instanceof QTreeItem) {
//                  QTreeItem treeItem = (QTreeItem) uiObject;
//                  treeItem.setState(componentGVO.getExpand().booleanValue());
//                  rootItem.addItem(treeItem);
//                  // TODO set Tree
//                  RendererHelper.fillIn(componentGVO, treeItem.getLabel(), uuid, parent, context);
//                  processChildren(treeItem, componentGVO.getChildren(), uuid, parent, context);
//              }
                RendererHelper.fillIn(componentGVO, uiObject, uuid, parent, context);
            }
        }
    }
项目:rest-describe-and-compile    文件:ResponseItem.java   
public ResponseItem(final MethodNode method, final TreeItem methodTreeItem) {
  HorizontalPanel containerPanel = new HorizontalPanel();    
  HTML response = new HTML(SyntaxHighlighter.highlight("<" + WadlXml.responseNode + ">"));
  containerPanel.add(response);    

  // remove response hyperlink
  Hyperlink removeResponseLink = new Hyperlink(GuiFactory.strings.remove(), true, "");
  removeResponseLink.addClickListener(new ClickListener() {
    public void onClick(Widget sender) {        
      method.removeResponse(method.getResponse());         
      listResponse(method, methodTreeItem);
    }
  });      
  containerPanel.add(removeResponseLink);

  initWidget(containerPanel);
}
项目:rest-describe-and-compile    文件:RequestItem.java   
public RequestItem(final MethodNode method, final TreeItem methodTreeItem) {
  HorizontalPanel containerPanel = new HorizontalPanel();    
  HTML request = new HTML(SyntaxHighlighter.highlight("<" + WadlXml.requestNode + ">"));
  containerPanel.add(request);

  // remove request hyperlink
  Hyperlink removeRequestLink = new Hyperlink(GuiFactory.strings.remove(), true, "");
  removeRequestLink.addClickListener(new ClickListener() {
    public void onClick(Widget sender) {        
      method.removeRequest(method.getRequest());         
      listRequest(method, methodTreeItem);
    }
  });      
  containerPanel.add(removeRequestLink);

  initWidget(containerPanel);
}