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

The following examples show how to use com.google.gwt.user.client.ui.TreeItem#getChildCount() . 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: 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 2
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 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 5 votes vote down vote up
/**
 * Prevents folder incosistences between server ( multi user deletes folder ) and tree
 * nodes drawed
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}
	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 5
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder incosistences between server ( multi user deletes folder ) and tree
 * nodes drawed
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}

	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 6
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder inconsistences between server ( multi user deletes folder ) and tree
 * nodes drawn
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}

	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 7
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder incosistences between server ( multi user deletes folder ) and tree
 * nodes drawed
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}

	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 8
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hides all items on a brach
 *
 * @param actualItem The actual item active
 */
public void hideAllBranch(TreeItem actualItem) {
	int i = 0;
	int count = actualItem.getChildCount();

	for (i = 0; i < count; i++) {
		actualItem.getChild(i).setVisible(false);
	}
}
 
Example 9
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder incosistences between server ( multi user deletes folder ) and tree
 * nodes drawed
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}

	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 10
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hides all items on a brach
 *
 * @param actualItem The actual item active
 */
public void hideAllBranch(TreeItem actualItem) {
	int i = 0;
	int count = actualItem.getChildCount();

	for (i = 0; i < count; i++) {
		actualItem.getChild(i).setVisible(false);
	}
}
 
Example 11
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder incosistences between server ( multi user deletes folder ) and tree
 * nodes drawed
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}
	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 12
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hides all items on a brach
 *
 * @param actualItem The actual item active
 */
public void hideAllBranch(TreeItem actualItem) {
	int i = 0;
	int count = actualItem.getChildCount();

	for (i = 0; i < count; i++) {
		actualItem.getChild(i).setVisible(false);
	}
}
 
Example 13
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Prevents folder inconsistences between server ( multi user deletes folder ) and tree
 * nodes drawn
 *
 * @param item The tree node
 */
public void preventFolderInconsitences(TreeItem item) {
	GWTFolder folderItem = (GWTFolder) item.getUserObject();

	// Case that must remove all items node
	if (item.getChildCount() > 0 && !folderItem.isHasChildren()) {
		while (item.getChildCount() > 0) {
			item.getChild(0).remove();
		}
	}

	if (item.getChildCount() < 1 && !folderItem.isHasChildren()) {
		folderItem.setHasChildren(false);
	}
}
 
Example 14
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Change recursivelly all the childs path
 *
 * @param oldPath
 *            The old path
 * @param newPath
 *            The new path
 * @param itemToChange
 *            The tree item to change the path
 */
public void changePathBeforeRenaming(String oldPath, String newPath, TreeItem itemToChange) {
	for (int i = 0; i < itemToChange.getChildCount(); i++) {
		TreeItem tmpItem = itemToChange.getChild(i);
		GWTFolder gwtFolder = ((GWTFolder) tmpItem.getUserObject());
		gwtFolder.setPath(gwtFolder.getPath().replaceAll(oldPath, newPath));
		gwtFolder.setParentPath(gwtFolder.getParentPath().replaceAll(oldPath, newPath));
		if (tmpItem.getChildCount() > 0) {
			changePathBeforeRenaming(oldPath, newPath, tmpItem);
		}
	}
}
 
Example 15
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Hides all items on a brach
 *
 * @param actualItem The actual item active
 */
public void hideAllBranch(TreeItem actualItem) {
	int i = 0;
	int count = actualItem.getChildCount();

	for (i = 0; i < count; i++) {
		actualItem.getChild(i).setVisible(false);
	}
}
 
Example 16
Source File: SubsetJSONPropertyEditor.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
private void toggleChildren(TreeItem item, Boolean checked) {
  for (int i = 0; i <item.getChildCount(); ++i) {
    TreeItem childItem = item.getChild(i);
    ((CheckBox)childItem.getWidget()).setValue(checked, false);
    if (childItem.getChildCount() > 0) {
      toggleChildren(childItem, checked);
    }
  }
}
 
Example 17
Source File: SubsetJSONPropertyEditor.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private void loadComponents(JSONObject jsonObj) {
  // TODO: Review JSON format. There has to be a better way to store and retrieve this info.
  JSONObject shownComponents = jsonObj.get("shownComponentTypes").isObject();
  JSONObject shownComponentBlocks = jsonObj.get("shownBlockTypes").isObject().get("ComponentBlocks").isObject();
  for (int i = 0; i < componentTree.getItemCount(); ++i) {
    TreeItem componentCatItem = componentTree.getItem(i);
    CheckBox componentCatCb = (CheckBox)componentCatItem.getWidget();
    String catName = componentCatCb.getName().toUpperCase();
    if (shownComponents.containsKey(catName)) {
      JSONArray jsonComponentCat = shownComponents.get(catName).isArray();
      if (jsonComponentCat.size() > 0) {
        componentCatCb.setValue(true, false);
        HashMap<String, String> jsonComponentHash = new HashMap<String, String>();
        for (int j = 0; j < jsonComponentCat.size(); ++j) {
          JSONValue jsonComponentHashCat = jsonComponentCat.get(j);
          if (jsonComponentHashCat != null) {
            jsonComponentHash.put(jsonComponentHashCat.isObject().get("type").isString().stringValue(), "type");
          }
        }
        for (int j = 0; j < componentCatItem.getChildCount(); ++j) {
          TreeItem componentItem = componentCatItem.getChild(j);
          CheckBox componentCb = (CheckBox) componentItem.getWidget();
          if (jsonComponentHash.get(componentCb.getName()) != null) {
            componentCb.setValue(true, false);
            JSONArray jsonComponentBlockProps = shownComponentBlocks.get(componentCb.getName()).isArray();
            HashMap<String, String> componentPropHash = new HashMap<String, String>();
            for (int k = 0; k < jsonComponentBlockProps.size(); ++k) {
              JSONObject jsonComponentBlockType = jsonComponentBlockProps.get(k).isObject();
              String componentBlockType = jsonComponentBlockType.get("type").isString().stringValue();
              if ("component_set_get".equals(componentBlockType)) {
                componentPropHash.put(jsonComponentBlockType.get("mutatorNameToValue").isObject().get("property_name").isString().stringValue(), "PROP");
              } else if ("component_event".equals(componentBlockType)) {
                JSONValue mutatorValue = jsonComponentBlockType.get("mutatorNameToValue");
                JSONValue event_name = mutatorValue.isObject().get("event_name");
                componentPropHash.put(event_name.isString().stringValue(), "EVENT");
              } else if ("component_method".equals(componentBlockType)) {
                componentPropHash.put(jsonComponentBlockType.get("mutatorNameToValue").isObject().get("method_name").isString().stringValue(), "METHOD");
              }
            }
            for (int k = 0; k < componentItem.getChildCount(); ++k) {
              TreeItem componentPropItem = componentItem.getChild(k);
              CheckBox componentPropCb = (CheckBox) componentPropItem.getWidget();
              if (componentPropHash.get(componentPropCb.getText()) != null) {
                componentPropCb.setValue(true, false);
              } else {
                componentPropCb.setValue(false, false);
              }
            }

          } else {
            componentCb.setValue(false, false);
            toggleChildren(componentItem, false);
          }
        }
      } else {
        componentCatCb.setValue(false, false);
        toggleChildren(componentCatItem, false);
      }
    } else {
      componentCatCb.setValue(false, false);
      toggleChildren(componentCatItem, false);
    }
  }
}
 
Example 18
Source File: UniTimeMobileMenu.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void openedNodes(List<String> ret, TreeItem item, String prefix) {
	if (item.getState()) ret.add((prefix == null ? "" : prefix + " ") + item.getText());
	for (int i = 0; i < item.getChildCount(); i++)
		openedNodes(ret, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}
 
Example 19
Source File: UniTimeMobileMenu.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void openNodes(Set<String> nodes, TreeItem item, String prefix) {
	if (nodes.contains((prefix == null ? "" : prefix + " ") + item.getText())) item.setState(true);
	for (int i = 0; i < item.getChildCount(); i++)
		openNodes(nodes, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}
 
Example 20
Source File: UniTimeSideBar.java    From unitime with Apache License 2.0 4 votes vote down vote up
private void openedNodes(List<String> ret, TreeItem item, String prefix) {
	if (item.getState()) ret.add((prefix == null ? "" : prefix + " ") + item.getText());
	for (int i = 0; i < item.getChildCount(); i++)
		openedNodes(ret, item.getChild(i), (prefix == null ? "" : prefix + " ") + item.getText());
}