Java Code Examples for com.google.gwt.user.client.ui.TreeItem#addItem()

The following examples show how to use com.google.gwt.user.client.ui.TreeItem#addItem() . 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: BlockSelectorBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a tree item for built-in blocks.
 *
 * @return tree item
 */
public TreeItem getBuiltInBlocksTree(MockForm form) {
  initBundledImages();
  TreeItem builtinNode = new TreeItem(new HTML("<span>" + MESSAGES.builtinBlocksLabel()
      + "</span>"));
  for (final String drawerName : getSubsetDrawerNames(form)) {
    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;
}
 
Example 2
Source File: BlockSelectorBox.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example 3
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 4
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 5
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 6
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 7
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 8
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 9
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example 10
Source File: AccessLogView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void updateTreee() {
    tree.removeItems();

    Iterator<String> keys = log.getKeys();

    while(keys.hasNext())
    {
        String token = keys.next();
        Set<String> addresses = log.getAddresses(token);

        SafeHtmlBuilder sh = new SafeHtmlBuilder();
        TreeItem parent = tree.addItem(sh.appendEscaped(token+" ("+addresses.size()+")").toSafeHtml());

        for(String address : addresses)
        {
            SafeHtmlBuilder sh2 = new SafeHtmlBuilder();
            parent.addItem(sh2.appendEscaped(address).toSafeHtml());
        }
    }
}
 
Example 11
Source File: ModelBrowserView.java    From core with GNU Lesser General Public License v2.1 6 votes vote down vote up
private void addChildrenTypes(ModelTreeItem rootItem, List<ModelNode> modelNodes) {

        rootItem.removeItems();

        final ChildInformation childInformation = parseChildrenTypes(modelNodes);

        for(String child : childInformation.getNames())
        {
            final ModelNode address = getNodeAddress(rootItem, child);

            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendHtmlConstant("<i class='icon-folder-close-alt'></i>&nbsp;");
            html.appendEscaped(child);
            TreeItem childItem = new ModelTreeItem(html.toSafeHtml(), child, address, childInformation.isSingleton(child));
            childItem.addItem(new PlaceholderItem());
            rootItem.addItem(childItem);
            rootItem.updateChildInfo(childInformation);
        }

        rootItem.setState(true);
    }
 
Example 12
Source File: MockContainer.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
@Override
protected TreeItem buildTree() {
  TreeItem itemNode = super.buildTree();

  // Recursively build the tree for child components
  for (MockComponent child : children) {
    itemNode.addItem(child.buildTree());
  }

  itemNode.setState(expanded);

  return itemNode;
}
 
Example 13
Source File: ConflictBasedStatisticsTree.java    From unitime with Apache License 2.0 5 votes vote down vote up
protected TreeItem generate(final CBSNode node) {
	P widget = new P("cbs-node");
	Label counter = new Label(); counter.setText(node.getCount() + " \u00D7");
	widget.add(counter);
	if (node.getHTML() != null) {
		HTML html = new HTML(node.getHTML());
		widget.add(html);
	} else {
		Label name = new Label(); name.setText(node.getName());
		if (node.getPref() != null && iProperties != null) {
			PreferenceInterface pref = iProperties.getPreference(node.getPref());
			if (pref != null)
				name.getElement().getStyle().setColor(pref.getColor());
		}
		widget.add(name);
	}
	widget.addClickHandler(new ClickHandler() {
		@Override
		public void onClick(ClickEvent event) {
			ConflictBasedStatisticsTree.this.onClick(event, node);
		}
	});
	TreeItem item = new TreeItem(widget);
	if (node.hasNodes()) {
		for (CBSNode child: node.getNodes()) {
			item.addItem(generate(child));
		}
	}
	return item;
}