List of usage examples for com.google.gwt.user.client.ui TreeItem TreeItem
public TreeItem()
From source file:org.onecmdb.ui.gwt.itil.client.main.screen.navigation.NavigationScreen.java
License:Apache License
private TreeItem addItem(TreeItem parentItem, ScreenMenuItem widget) { TreeItem childItem = new TreeItem(); childItem.setWidget(widget);//from w w w .j a va 2s. c o m parentItem.addItem(childItem); widget.addClickListener(this); return (childItem); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.screen.navigation.NavigationScreen.java
License:Apache License
public NavigationScreen() { TreeItem root = new TreeItem(); initWidget(treePanel); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.screen.navigation.NavigationScreen.java
License:Apache License
protected void addItem(TreeItem parentItem, ScreenMenuItem widget) { TreeItem childItem = new TreeItem(); childItem.setWidget(widget);/* ww w.j a v a 2 s.c om*/ parentItem.addItem(childItem); widget.addClickListener(this); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.tree.CITreeWidget.java
License:Open Source License
protected TreeItem newTreeItem(Object data, final boolean root) { Widget w = this.control.getWidget(data); final TreeItem item = new TreeItem(); item.setUserObject(data);//from w w w . j ava2 s.c o m item.setWidget(w); // Need to this here since we call the auto open and that // need to have the tree callback setup. if (root) { tree.addItem(item); } this.control.getChildCount(data, 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); item.addItem(countItem); // Always open root item. if (root && control.isRootState()) { System.out.println("Default open root Tree Item! '" + item.getUserObject() + "'"); item.setState(true, true); } } } } }); return (item); }
From source file:org.opendatakit.aggregate.client.AggregateUI.java
License:Apache License
/*********************************** ***** INITIALIZATION ******// www. ja v a 2 s . co m ***********************************/ private AggregateUI() { /* * CRITICAL NOTE: Do not do **anything** in this constructor that might * cause something underneath to call AggregateUI.get() * * The singleton is not yet assigned!!! */ singleton = null; timer = new RefreshTimer(this); // define the not-secure message info... notSecureMsgLabel = new Label(); notSecureMsgLabel.setStyleName("not_secure_message"); notSecurePanel = new FlowPanel(); notSecurePanel.add(notSecureMsgLabel); notSecurePanel.setVisible(false); // define the error message info... errorMsgLabel = new Label(); errorMsgLabel.setStyleName("error_message"); // put the not-secure and error messages in an error panel errorPanel = new FlowPanel(); errorPanel.add(errorMsgLabel); errorPanel.setVisible(false); // create tab datastructures tabMap = new HashMap<Tabs, AggregateTabBase>(); tabPosition = new ArrayList<Tabs>(); wrappingLayoutPanel = new FlowPanel(); // vertical wrappingLayoutPanel.setStylePrimaryName(UIConsts.VERTICAL_FLOW_PANEL_STYLENAME); layoutPanel = new HorizontalPanel(); mainNav = new DecoratedTabPanel(); mainNav.getElement().setId("mainNav"); mainNav.addSelectionHandler(new RefreshSelectionHandler<Integer>()); // add to layout layoutPanel.add(mainNav); layoutPanel.getElement().setId("layout_panel"); wrappingLayoutPanel.add(layoutPanel); helpPanel = new ScrollPanel(); // Create help panel Tree helpTree = new Tree(); rootItem = new TreeItem(); helpTree.addItem(rootItem); helpTree.addOpenHandler(new RefreshOpenHandler<TreeItem>()); helpTree.addCloseHandler(new RefreshCloseHandler<TreeItem>()); helpTree.getElement().setId("help_tree"); helpPanel.add(helpTree); helpPanel.getElement().setId("help_panel"); helpPanel.setVisible(false); wrappingLayoutPanel.add(helpPanel); settingsBar = new NavLinkBar(); RootPanel.get("not_secure_content").add(notSecurePanel); RootPanel.get("error_content").add(errorPanel); RootPanel.get("dynamic_content").add( new HTML("<img src=\"images/odk_color.png\" id=\"odk_aggregate_logo\" class=\"gwt-Image\" />")); RootPanel.get("dynamic_content").add(settingsBar); RootPanel.get("dynamic_content").add(wrappingLayoutPanel); }
From source file:org.optaplanner.workbench.screens.solver.client.editor.TerminationConfigForm.java
License:Apache License
public void addNewTerminationType(String terminationType, TerminationTreeItemContent treeItemContent) { TreeItem nestedTreeItem = new TreeItem(); insertTreeItem(treeItemContent.getTreeItem(), nestedTreeItem, TerminationConfigOption.valueOf(terminationType)); treeItemContent.getTreeItem().setState(true); TerminationConfigOption terminationConfigOption = TerminationConfigOption.valueOf(terminationType); final TerminationConfigModel terminationConfigModel; if (terminationConfigOption == TerminationConfigOption.NESTED) { TerminationConfigModel childTerminationConfigModel = new TerminationConfigModel(); if (treeItemContent.getModel().getTerminationConfigList() == null) { treeItemContent.getModel().setTerminationConfigList(new ArrayList<>(1)); }//from w ww. ja v a2 s. c om treeItemContent.getModel().getTerminationConfigList().add(childTerminationConfigModel); terminationConfigModel = childTerminationConfigModel; } else { terminationConfigModel = treeItemContent.getModel(); } TerminationTreeItemContent terminationTreeItemContent = createTerminationTreeItemContent( terminationConfigOption, nestedTreeItem, terminationConfigModel); terminationTreeItemContent.setNewValue(terminationConfigOption); treeItemContent.removeDropDownOption(TerminationConfigOption.valueOf(terminationType)); view.displayEmptyTreeLabel(rootTreeItem.getChildCount() == 0); view.refreshTree(); }
From source file:org.optaplanner.workbench.screens.solver.client.editor.TerminationConfigForm.java
License:Apache License
private void initTerminationTree(TerminationConfigModel terminationConfigModel) { this.rootTreeItem = new TreeItem(); initTerminationTreeItemHierarchy(terminationConfigModel, rootTreeItem); view.initTree(rootTreeItem);//from w ww.j av a 2 s.com rootTreeItem.setState(true); view.displayEmptyTreeLabel(rootTreeItem.getChildCount() == 0); view.refreshTree(); }
From source file:org.optaplanner.workbench.screens.solver.client.editor.TerminationConfigForm.java
License:Apache License
private void initTerminationTreeItemHierarchy(TerminationConfigModel terminationConfigModel, TreeItem treeItem) {//from w w w . ja v a 2 s . c o m TerminationTreeItemContent terminationTreeItemContent = createTerminationTreeItemContent( TerminationConfigOption.NESTED, treeItem, terminationConfigModel); TerminationConfigOption timeSpentTerminationOption = null; boolean timeSpentInserted = false; boolean unimprovedTimeSpentInserted = false; outer: for (TerminationConfigOption terminationConfigOption : TerminationConfigOption.values()) { timeSpentTerminationOption = null; Object terminationValue = getTerminationValue(terminationConfigModel, terminationConfigOption); if (terminationConfigOption == TerminationConfigOption.TERMINATION_COMPOSITION_STYLE) { TerminationTreeItemContent parentTreeItemContent = (TerminationTreeItemContent) treeItem .getUserObject(); parentTreeItemContent.setExistingValue(terminationValue, TerminationConfigOption.TERMINATION_COMPOSITION_STYLE); continue; } if (terminationValue != null) { if (timeSpentInserted && (terminationConfigOption == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.DAYS_SPENT_LIMIT)) { for (int i = 0; i < treeItem.getChildCount(); i++) { TerminationTreeItemContent treeItemContent = (TerminationTreeItemContent) treeItem .getChild(i).getUserObject(); if (treeItemContent .getTerminationConfigOption() == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.SECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.MINUTES_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.HOURS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.DAYS_SPENT_LIMIT) { treeItemContent .setTerminationConfigOption(TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); treeItemContent.setExistingValue(terminationValue, TerminationConfigOption.MILLISECONDS_SPENT_LIMIT); continue outer; } } } else { if (terminationConfigOption == TerminationConfigOption.MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.DAYS_SPENT_LIMIT) { timeSpentTerminationOption = TerminationConfigOption.MILLISECONDS_SPENT_LIMIT; timeSpentInserted = true; } } } if (terminationValue != null) { if (unimprovedTimeSpentInserted && (terminationConfigOption == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT)) { for (int i = 0; i < treeItem.getChildCount(); i++) { TerminationTreeItemContent treeItemContent = (TerminationTreeItemContent) treeItem .getChild(i).getUserObject(); if (treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || treeItemContent .getTerminationConfigOption() == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT) { treeItemContent.setTerminationConfigOption( TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT); treeItemContent.setExistingValue(terminationValue, TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT); continue outer; } } } else { if (terminationConfigOption == TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_SECONDS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_MINUTES_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_HOURS_SPENT_LIMIT || terminationConfigOption == TerminationConfigOption.UNIMPROVED_DAYS_SPENT_LIMIT) { timeSpentTerminationOption = TerminationConfigOption.UNIMPROVED_MILLISECONDS_SPENT_LIMIT; unimprovedTimeSpentInserted = true; } } } if (terminationValue != null && !TerminationConfigOption.NESTED.equals(terminationConfigOption)) { TreeItem nestedTreeItem = new TreeItem(); if (timeSpentTerminationOption != null) { terminationConfigOption = timeSpentTerminationOption; } insertTreeItem(treeItem, nestedTreeItem, terminationConfigOption); terminationTreeItemContent.removeDropDownOption(terminationConfigOption); TerminationTreeItemContent nestedTerminationTreeItemContent = createTerminationTreeItemContent( terminationConfigOption, nestedTreeItem, terminationConfigModel); nestedTerminationTreeItemContent.setExistingValue(terminationValue, terminationConfigOption); } } if (terminationConfigModel.getTerminationConfigList() != null) { for (TerminationConfigModel nestedTerminationConfigModel : terminationConfigModel .getTerminationConfigList()) { TreeItem nestedTreeItem = new TreeItem(); treeItem.addItem(nestedTreeItem); initTerminationTreeItemHierarchy(nestedTerminationConfigModel, nestedTreeItem); nestedTreeItem.setState(true); } } }
From source file:org.pentaho.gwt.widgets.client.filechooser.TreeBuilder.java
License:Open Source License
public static Tree buildSolutionTree(RepositoryFileTree fileTree, boolean showHiddenFiles, boolean showLocalizedFileNames, FileFilter filter) { // build a tree structure to represent the document Tree repositoryTree = new Tree(); // get document root item RepositoryFile rootFile = fileTree.getFile(); TreeItem rootItem = new TreeItem(); rootItem.setText(rootFile.getPath()); rootItem.setUserObject(fileTree);//from w w w . j av a2s. c o m repositoryTree.addItem(rootItem); // default file filter that accepts anything if (filter == null) { filter = new DefaultFileFilter(); } buildSolutionTree(rootItem, fileTree, showHiddenFiles, showLocalizedFileNames, filter); return repositoryTree; }
From source file:org.pentaho.gwt.widgets.client.filechooser.TreeBuilder.java
License:Open Source License
private static void buildSolutionTree(TreeItem parentTreeItem, RepositoryFileTree fileTree, boolean showHiddenFiles, boolean showLocalizedFileNames, FileFilter filter) { for (RepositoryFileTree repositoryFileTree : fileTree.getChildren()) { RepositoryFile file = repositoryFileTree.getFile(); boolean isVisible = !file.isHidden(); boolean isDirectory = file.isFolder(); if (isVisible || showHiddenFiles) { String fileTitle = file.getTitle(), fileName = file.getName(); if (filter.accept(fileName, isDirectory, (isVisible || showHiddenFiles)) == false) { continue; }/*from ww w . j a v a 2 s . c o m*/ TreeItem childTreeItem = new TreeItem(); // TODO There is no concept of filename and a localized filename in the repository. Do we need this ? if (showLocalizedFileNames) { childTreeItem.setText(fileTitle); childTreeItem.setTitle(fileTitle); } else { childTreeItem.setText(fileTitle); childTreeItem.setTitle(fileTitle); } // ElementUtils.preventTextSelection(childTreeItem.getElement()); childTreeItem.setUserObject(repositoryFileTree); // find the spot in the parentTreeItem to insert the node (based on showLocalizedFileNames) if (parentTreeItem.getChildCount() == 0) { parentTreeItem.addItem(childTreeItem); } else { // this does sorting boolean inserted = false; for (int j = 0; j < parentTreeItem.getChildCount(); j++) { TreeItem kid = (TreeItem) parentTreeItem.getChild(j); if (showLocalizedFileNames) { if (childTreeItem.getText().compareTo(kid.getText()) <= 0) { // leave all items ahead of the insert point // remove all items between the insert point and the end // add the new item // add back all removed items List<TreeItem> removedItems = new ArrayList<TreeItem>(); for (int x = j; x < parentTreeItem.getChildCount(); x++) { TreeItem removedItem = (TreeItem) parentTreeItem.getChild(x); removedItems.add(removedItem); } for (TreeItem removedItem : removedItems) { parentTreeItem.removeItem(removedItem); } parentTreeItem.addItem(childTreeItem); inserted = true; for (TreeItem removedItem : removedItems) { parentTreeItem.addItem(removedItem); } break; } } else { parentTreeItem.addItem(childTreeItem); } } if (!inserted) { parentTreeItem.addItem(childTreeItem); } } if (isDirectory) { buildSolutionTree(childTreeItem, repositoryFileTree, showHiddenFiles, showLocalizedFileNames, filter); } } } }