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

The following examples show how to use com.google.gwt.user.client.ui.TreeItem#setUserObject() . 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: MockComponent.java    From appinventor-extensions with Apache License 2.0 6 votes vote down vote up
/**
 * Constructs a tree item for the component which will be displayed in the
 * source structure explorer.
 *
 * @return  tree item for this component
 */
protected TreeItem buildTree() {
  // Instantiate new tree item for this component
  // Note: We create a ClippedImagePrototype because we need something that can be
  // used to get HTML for the iconImage. AbstractImagePrototype requires
  // an ImageResource, which we don't necessarily have.
  TreeItem itemNode = new TreeItem(
      new HTML("<span>" + iconImage.getElement().getString() + SafeHtmlUtils.htmlEscapeAllowEntities(getName()) + "</span>")) {
    @Override
    protected Focusable getFocusable() {
      return nullFocusable;
    }
  };
  itemNode.setUserObject(sourceStructureExplorerItem);
  return itemNode;
}
 
Example 4
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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++;
		}
	}
}
 
Example 5
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onSuccess(GWTFolder result) {
	actualItem = actualItem.getParentItem(); // Restores the real
	// actualItem
	tmpFolder.setSelected(false);
	actualItem.setSelected(true);
	actualItem.setState(true);
	GWTFolder folder = result;
	GWTFolder folderItem = (GWTFolder) actualItem.getUserObject();
	folderItem.setHasChildren(true);
	actualItem.removeItem(tmpFolder);
	TreeItem newFolder = new TreeItem();
	newFolder.setHTML(Util.imageItemHTML("img/menuitem_empty.gif", folder.getName(),"top"));
	newFolder.setUserObject(folder);
	newFolder.setStyleName("okm-TreeItem");
	actualItem.addItem(newFolder);
	evaluesFolderIcon(newFolder);
	evaluesFolderIcon(actualItem);
	Main.get().mainPanel.desktop.navigator.status.unsetFlagCreate();
	if (Main.get().mainPanel.desktop.navigator.getStackIndex() != UIDesktopConstants.NAVIGATOR_CATEGORIES) {
		Main.get().mainPanel.desktop.browser.fileBrowser.status.setFlagFolderChilds();
		Main.get().mainPanel.desktop.browser.fileBrowser.addFolder(folder);
	}

	// Special case when we are creating a folder and selects other tree
	// item before removing tmp folder
	// must changing to the real item selected
	if (otherTreeItemSelected != null) {
		onTreeItemSelected(otherTreeItemSelected);
		otherTreeItemSelected = null;
	}

	folderAction = ACTION_NONE;
}
 
Example 6
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Refreshing when folder is renamed remotelly For example on file browser
 * view
 *
 * @param path
 *            The tree path ( last value )
 * @param newFolder
 *            The new object value
 */
public void renameRenamed(String path, GWTFolder newFolder) {
	boolean found = false;
	int i = 0;

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

		if (((GWTFolder) tmp.getUserObject()).getPath().equals(path)) {
			tmp.setUserObject(newFolder);
			// Evalues Folder Icon puts name and icon correct values from
			// object
			evaluesFolderIcon(tmp);
			found = true;
			String oldPath = path.substring(1); // deletes first character
			// "/" because parent path
			// not has and replace not
			// runs properly
			path = newFolder.getPath().substring(1); // deletes first
			// character "/"
			// because parent
			// path not has and
			// replace not runs
			// properly
			changePathBeforeRenaming(oldPath, path, tmp);
		}

		i++;
	}
}
 
Example 7
Source File: GalleryTreeViewImpl.java    From dashbuilder with Apache License 2.0 5 votes vote down vote up
private void populateNavigationTree(List<GalleryTreeNode> nodes, HasTreeItems items) {
    if (nodes == null) return;
    for (GalleryTreeNode node: nodes) {
        TreeItem ti = new TreeItem();
        ti.setText(node.getName());
        ti.setUserObject(node);
        ti.getElement().getStyle().setCursor(Style.Cursor.POINTER);
        items.addItem(ti);
        populateNavigationTree(node.getChildren(), ti);
    }
}
 
Example 8
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
}
 
Example 9
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
}
 
Example 10
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
}
 
Example 11
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
}
 
Example 12
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
	Main.get().mainPanel.desktop.navigator.thesaurusTree.thesaurusSelectPopup.thesaurusPanel.status.unsetFlagChilds();
}
 
Example 13
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
	Main.get().mainPanel.desktop.navigator.categoriesTree.categoriesSelectPopup.status.unsetFlagChilds();
}
 
Example 14
Source File: FolderSelectTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	boolean directAdd = true;

	// If has no childs directly add values is permited
	if (actualItem.getChildCount() > 0) {
		directAdd = false;
		// to prevent remote folder remove it disables all tree branch
		// items and after sequentially activate
		hideAllBranch(actualItem);
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (result.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = result.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// If has no childs directly add values is permited, else
		// evalues each node to refresh, remove or add
		if (directAdd) {
			evaluesFolderIcon(folderItem);
			actualItem.addItem(folderItem);
		} else {
			// sequentially activate items and refreshes values
			addFolder(actualItem, folderItem);
		}
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);
}
 
Example 15
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	List<GWTFolder> folderList = result;

	autoOpenFolder = actualItem.getState(); // Actual folder open state
	// Case first refreshing when (childcount = 0 or treeItem changed ) and results >0 must ensure enables auto open
	if ((actualItem.getChildCount() == 0 || treeItemChanged) && result.size() > 0) {
		autoOpenFolder = true;
	}

	// Remove all items
	if (actualItem.getChildCount() > 0) {
		actualItem.removeItems();
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (folderList.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = folderList.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// add values
		evaluesFolderIcon(folderItem);
		actualItem.addItem(folderItem);
	}
	// Evaluates special case has closed parent folder ( and selected folder was a child )
	if (!treeItemHasBeenClosed) {
		actualItem.setState(autoOpenFolder); // Enables auto open or close tree node
	} else {
		treeItemHasBeenClosed = false;
	}
	evaluesFolderIcon(actualItem);

	if (setTabFolderAfterRefresh) {
		// Refresh tab properties values on the last node
		showTabFolderProperties();
		setTabFolderAfterRefresh = false;
	}

	Main.get().mainPanel.desktop.navigator.status.unsetFlagChilds();
}
 
Example 16
Source File: FolderTree.java    From document-management-system with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onSuccess(List<GWTFolder> result) {
	List<GWTFolder> folderList = result;

	// Remove olders items
	if (actualItem.getChildCount() > 0) {
		actualItem.removeItems();
	}

	// On refreshing not refreshed the actual item values but must
	// ensure that has childs value is consistent
	if (folderList.isEmpty()) {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(false);
	} else {
		((GWTFolder) actualItem.getUserObject()).setHasChildren(true);
	}

	// Ads folders childs if exists
	for (Iterator<GWTFolder> it = folderList.iterator(); it.hasNext(); ) {
		GWTFolder folder = it.next();
		TreeItem folderItem = new TreeItem();
		folderItem.setHTML(folder.getName());
		folderItem.setUserObject(folder);
		folderItem.setStyleName("okm-TreeItem");

		// add values
		evaluesFolderIcon(folderItem);
		actualItem.addItem(folderItem);
	}

	actualItem.setState(true);
	evaluesFolderIcon(actualItem);

	if (!tmpAllPathFolder.isEmpty()) {
		int index = tmpAllPathFolder.size() - 1;
		String tmpPath = tmpAllPathFolder.get(index);
		tmpAllPathFolder.remove(index);
		if (index > 0) {
			setActiveNode(tmpPath, false, false);
		} else {
			setActiveNode(tmpPath, false, refreshFileBrowser);
		}
	} else {
		openingFldPath = false;
	}
}