List of usage examples for com.google.gwt.user.client.ui TreeItem addItem
public TreeItem addItem(Widget widget)
From source file:com.square.composant.ged.square.client.presenter.AssociationActionsDocumentsPresenter.java
License:Open Source License
@Override public void onBind() { // Construction de la liste arborescente des documents associs l'utilisateur view.getBoutonAnnuler().addClickHandler(new ClickHandler() { @Override//from ww w.j a v a2 s. c o m public void onClick(ClickEvent event) { view.fermer(); } }); view.getBoutonAjouter().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Ajout de l'entre slectionne la liste des documents associs. if (mapItemsDisponibles.containsKey(view.getArbreDocumentsClient().getSelectedItem())) { // Dj affect ? final DocumentModel docSelectionne = mapItemsDisponibles .get(view.getArbreDocumentsClient().getSelectedItem()); if (!mapIdItemsAssocies.containsKey( docSelectionne.getParent().getIdentifiant() + docSelectionne.getIdentifiant())) { // Ajout la liste & affichage if (!listeIdsDocumentsAction.contains(docSelectionne.getIdentifiant())) { listeIdsDocumentsAction.add(docSelectionne.getIdentifiant()); } // Ajout de l'lment final TreeItem parent = selectionneParentDyna(docSelectionne.getParent()); final TreeItem treeItem = new TreeItem(docSelectionne.getNom()); treeItem.addStyleName("elementArborescence"); parent.addItem(treeItem); mapIdItemsAssocies.put( docSelectionne.getParent().getIdentifiant() + docSelectionne.getIdentifiant(), treeItem); mapItemsAssocies.put(treeItem, docSelectionne); ouvrirParents(treeItem); } } } }); view.getBoutonEnlever().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { // Suppression de l'entite slectionne de la liste des documents associs. final TreeItem selectedItem = view.getArbreDocumentsAction().getSelectedItem(); if (mapItemsAssocies.containsKey(selectedItem)) { final DocumentModel document = mapItemsAssocies .get(view.getArbreDocumentsAction().getSelectedItem()); listeIdsDocumentsAction.remove(document.getIdentifiant()); final TreeItem parent = selectedItem.getParentItem(); selectedItem.remove(); mapItemsAssocies.remove(selectedItem); mapIdItemsAssocies.remove(document.getParent().getIdentifiant() + document.getIdentifiant()); nettoyerParents(parent); } } }); view.getBoutonAjouterDocument().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { if (ajoutDocumentPresenter == null) { ajoutDocumentPresenter = new AjoutDocumentPresenter(eventBus, numClient, idAction, new AjoutDocumentViewImpl(), documentService); ajoutDocumentPresenter.showPresenter(null); ajoutDocumentPresenter.addEventHandlerToLocalBus(AddDocumentEvent.TYPE, new AddDocumentEventHandler() { @Override public void onAddDocument(AddDocumentEvent event) { // Si un document a t ajout une action, on ferme la popup view.fermer(); fireEventLocalBus(new AssociationActionDocumentEvent()); } }); } else { ajoutDocumentPresenter.afficher(numClient, idAction); } } }); view.getBoutonEnregistrer().addClickHandler(new ClickHandler() { @Override public void onClick(ClickEvent event) { view.afficherLoadingPopup( new LoadingPopupConfiguration(view.getViewConstants().chargementDesDocumentsEnCours())); documentService.associerDocumentsAAction(idAction, listeIdsDocumentsAction, new AsyncCallback<Object>() { @Override public void onFailure(Throwable caught) { view.onRpcServiceFailure(caught); } @Override public void onSuccess(Object result) { view.onRpcServiceSuccess(); view.fermer(); fireEventLocalBus(new AssociationActionDocumentEvent()); } }); } }); }
From source file:com.square.composant.ged.square.client.presenter.AssociationActionsDocumentsPresenter.java
License:Open Source License
/** * Slectionne le parent (cre l'arborescence si besoin). * @param dossier le dossier parent a slectionner *//*from w w w . j ava 2 s . c o m*/ private TreeItem selectionneParentDyna(DossierDocumentModel dossier) { if (mapIdItemsDossierAssocies.containsKey(dossier.getIdentifiant())) { return mapIdItemsDossierAssocies.get(dossier.getIdentifiant()); } else { final TreeItem dossierItem = new TreeItem(dossier.getNom()); dossierItem.addStyleName("elementArborescence"); mapIdItemsDossierAssocies.put(dossier.getIdentifiant(), dossierItem); mapItemsDossiersAssocies.put(dossierItem, dossier); if (dossier.getParent() != null) { final TreeItem parent = selectionneParentDyna(dossier.getParent()); parent.addItem(dossierItem); } else { view.getArbreDocumentsAction().addItem(dossierItem); } return dossierItem; } }
From source file:com.square.composant.ged.square.client.presenter.AssociationActionsDocumentsPresenter.java
License:Open Source License
/** Remplissage d'un arbre. */ private TreeItem remplirArborescence(DossierDocumentModel dossier, Map<TreeItem, DocumentModel> mapCorrespondance, Map<String, TreeItem> mapCorrespondanceId, Map<TreeItem, DossierDocumentModel> mapCorrespondanceDossiers, Map<String, TreeItem> mapCorrespondanceDossierId) { final TreeItem treeItem = new TreeItem(dossier.getNom()); treeItem.addStyleName("elementArborescence"); for (DossierDocumentModel dossierEnfant : dossier.getDossiers()) { final TreeItem enfantItem = remplirArborescence(dossierEnfant, mapCorrespondance, mapCorrespondanceId, mapCorrespondanceDossiers, mapCorrespondanceDossierId); if (enfantItem != null) { treeItem.addItem(enfantItem); }// w w w.j a v a2 s .co m } for (DocumentModel document : dossier.getDocuments()) { final TreeItem itemDoc = new TreeItem(document.getNom()); itemDoc.addStyleName("elementArborescence"); mapCorrespondance.put(itemDoc, document); // La cl est le parent + le doc car un meme doc peut apparaitre dans plusieurs rubriques mapCorrespondanceId.put(document.getParent().getIdentifiant() + document.getIdentifiant(), itemDoc); treeItem.addItem(itemDoc); } // On ne renvoie que les documents ou les dossiers non vides if (treeItem.getChildCount() > 0) { mapCorrespondanceDossiers.put(treeItem, dossier); mapCorrespondanceDossierId.put(dossier.getIdentifiant(), treeItem); return treeItem; } else { return null; } }
From source file:com.sun.labs.aura.music.admin.client.WorkbenchPanel.java
License:Open Source License
private void addWorkers() { workerMenu.clear();/* w w w.ja v a 2 s. c om*/ TreeItem main = new TreeItem("main"); for (WorkbenchDescriptor worker : workers) { TreeItem item = new TreeItem(worker.getName()); item.setTitle(worker.getDescription()); item.setUserObject(worker); item.addStyleName("workerTreeItem"); main.addItem(item); } main.setState(true); workerMenu.addItem(main); }
From source file:com.xpn.xwiki.watch.client.ui.feedtree.FeedTreeWidget.java
License:Open Source License
/** * Creates the feed tree from scratch. It is called whenever a radical update of the tree has to be done, i.e. * {@link FeedTreeWidget#remakeTreeRequired()} returns true, or {@link FeedTreeWidget#updateFeedTree()} returns * false.//w w w . j ava 2 s . c om */ private void makeFeedTree() { // get the state of the tree items on first level -> the groups tree items HashMap itemsState = new HashMap(); for (int i = 0; i < this.groupTree.getItemCount(); i++) { TreeItem currentTreeItem = this.groupTree.getItem(i); // get user object ItemObject userObj = (ItemObject) currentTreeItem.getUserObject(); itemsState.put(userObj.getKey(), new Boolean(currentTreeItem.getState())); } // get the selected item to set it back when the tree is refreshed TreeItem selectedTreeItem = this.groupTree.getSelectedItem(); String selectedItemKey = null; if (selectedTreeItem != null) { ItemObject selectedItemObject = (ItemObject) selectedTreeItem.getUserObject(); if (selectedItemObject != null) { selectedItemKey = selectedItemObject.getKey(); } } // clear all trees groupTree.clear(); Map feedsbygroup = watch.getConfig().getFeedsByGroupList(); Map groups = watch.getConfig().getGroups(); List keys = new ArrayList(feedsbygroup.keySet()); Collections.sort(keys, new GroupComparator(groups, "All")); Iterator groupit = keys.iterator(); while (groupit.hasNext()) { final String groupname = (String) groupit.next(); Group currentGroup = (Group) groups.get(groupname); if (currentGroup == null) { currentGroup = new Group(); currentGroup.setName(groupname); } if ((groupname != null) && (!groupname.trim().equals(""))) { Map groupFeeds = (Map) feedsbygroup.get(groupname); TreeItem groupItemTree = new TreeItem(); // set the TreeItem's object GroupTreeItemObject groupObj = new GroupTreeItemObject(groupname, currentGroup); groupItemTree.setUserObject(groupObj); // check if selected boolean selected = false; if (selectedItemKey != null && groupname.equals(selectedItemKey)) { selected = true; selectedTreeItem = groupItemTree; } groupItemTree.setWidget(groupObj.getWidget(selected)); groupTree.addItem(groupItemTree); List feedList = new ArrayList(groupFeeds.keySet()); Collections.sort(feedList, new FeedComparator(groupFeeds, null)); Iterator feedgroupit = feedList.iterator(); while (feedgroupit.hasNext()) { String feedname = (String) feedgroupit.next(); Feed feed = (Feed) groupFeeds.get(feedname); // set it's userObject to the name of the group + name of the feed since a // feed can be part of multiple groups and we need to identify it uniquely. String itemTreeKey = groupname + "." + feed.getPageName(); ItemObject feedObj = new FeedTreeItemObject(itemTreeKey, feed); TreeItem feedItem = new TreeItem(); feedItem.setUserObject(feedObj); selected = false; if (selectedItemKey != null && itemTreeKey.equals(selectedItemKey)) { selected = true; selectedTreeItem = feedItem; } feedItem.setWidget(feedObj.getWidget(selected)); groupItemTree.addItem(feedItem); } // expand it if necessary Boolean state = (Boolean) itemsState.get(groupname); if (state != null) { groupItemTree.setState(state.booleanValue()); } groupTree.addItem(groupItemTree); } } // set the selected tree item this.groupTree.setSelectedItem(selectedTreeItem); }
From source file:de.knightsoftnet.navigation.client.ui.navigation.TreeNavigationView.java
License:Apache License
/** * create navigation in a recursive way. * * @param pitem the item to add new items * @param plist the list of the navigation entries * @param pactiveEntry the active entry/*from w w w . j a va2s . c o m*/ */ public void createRecursiveNavigation(final TreeItem pitem, final List<NavigationEntryInterface> plist, final NavigationEntryInterface pactiveEntry) { for (final NavigationEntryInterface navEntry : plist) { final TreeItem newItem; if (navEntry instanceof NavigationEntryFolder) { newItem = new TreeItem(navEntry.getMenuValue()); this.createRecursiveNavigation(newItem, ((NavigationEntryFolder) navEntry).getSubEntries(), pactiveEntry); newItem.setState(navEntry.isOpenOnStartup()); } else if (navEntry instanceof NavigationLink) { final Anchor link = ((NavigationLink) navEntry).getAnchor(); link.setStylePrimaryName(this.resources.navigationStyle().link()); newItem = new TreeItem(link); } else if (navEntry.getToken() == null) { newItem = null; } else { final InlineHyperlink entryPoint = GWT.create(InlineHyperlink.class); entryPoint.setHTML(navEntry.getMenuValue()); entryPoint.setTargetHistoryToken(navEntry.getFullToken()); entryPoint.setStylePrimaryName(this.resources.navigationStyle().link()); newItem = new TreeItem(entryPoint); this.navigationMap.put(newItem, navEntry); } if (newItem != null) { pitem.addItem(newItem); if (pactiveEntry != null && pactiveEntry.equals(navEntry)) { this.selectedItem = newItem; this.selectedItem.setSelected(true); } } } }
From source file:de.novanic.gwteventservice.demo.conversationapp.client.conversation.ui.GWTConversationChannelPanel.java
License:Open Source License
public boolean addContact(String aChannel, String aContactName) { boolean isContactAdded = false; final Iterator<TreeItem> theIterator = myChannelTree.treeItemIterator(); while (theIterator.hasNext()) { TreeItem theChannelTreeItem = theIterator.next(); if (isChannelItem(theChannelTreeItem)) { if (aChannel.equals(theChannelTreeItem.getText())) { if (!containsContact(theChannelTreeItem, aContactName)) { //adds the contact if the contact doesn't already exists in that channel theChannelTreeItem.addItem(aContactName); isContactAdded = true; }//from w w w. j a v a 2 s . c o m } } } return isContactAdded; }
From source file:de.spartusch.nasfvi.client.NResponseWidget.java
License:Apache License
/** * Creates and returns a visual representation for a subtree. * @param data Data of the subtree/* ww w. j a va 2s. c o m*/ * @param depth Depth of the subtree in the analysis * @return Visual representation of <code>data</code> */ private TreeItem getSubtree(final JSONArray data, final int depth) { TreeItem root = new TreeItem(); int subtrees = 0; for (int i = 0; i < data.size(); i++) { JSONArray array = data.get(i).isArray(); if (array == null) { // just a string root.addItem(data.get(i).isString().stringValue()); } else if (array.size() == 1 && array.get(0).isString() != null) { // array with a single string as an element root.addItem(array.get(0).isString().stringValue()); subtrees++; } else { // arrays TreeItem item = getSubtree(array, depth + 1); int x = (depth < LABELS.length) ? depth : LABELS.length - 2; int y = (subtrees < LABELS[x].length) ? subtrees : LABELS[x].length - 1; String label = LABELS[x][y]; if (label == null && item.getChildCount() > 0) { TreeItem first = item.getChild(0); label = first.getText(); item.removeItem(first); } item.setText(label); root.addItem(item); subtrees++; } } return root; }
From source file:edu.ycp.cs.netcoder.client.CourseAndProblemView.java
License:Open Source License
@Override public void eventOccurred(Object key, Publisher publisher, Object hint) { if (key == Session.Event.ADDED_OBJECT && hint instanceof Course[]) { Course[] courseList = (Course[]) hint; // Build the course tree courseTree = new Tree(); TreeItem curTermAndYearTreeItem = null; TermAndYear curTermAndYear = null; for (Course course : courseList) { TermAndYear courseTermAndYear = new TermAndYear(course.getTerm(), course.getYear()); if (curTermAndYear == null || !curTermAndYear.equals(courseTermAndYear)) { curTermAndYearTreeItem = new TreeItem(new TermAndYearNode(courseTermAndYear)); courseTree.addItem(curTermAndYearTreeItem); curTermAndYear = courseTermAndYear; }/* ww w. ja v a 2s . co m*/ curTermAndYearTreeItem.addItem(new CourseNode(course)); } // Handle selection events courseTree.addSelectionHandler(new SelectionHandler<TreeItem>() { @Override public void onSelection(SelectionEvent<TreeItem> event) { TreeItem treeItem = event.getSelectedItem(); Widget w = treeItem.getWidget(); if (w instanceof CourseNode) { getSession().get(CourseSelection.class).courseSelected(((CourseNode) w).getCourse()); } } }); getLayoutPanel().add(courseTree); doResize(); } else if (key == WindowResizeNotifier.WINDOW_RESIZED) { doResize(); } else if (key == CourseSelection.Event.COURSE_SELECTED) { final Course selectedCourse = (Course) hint; AsyncCallback<Problem[]> callback = new AsyncCallback<Problem[]>() { @Override public void onFailure(Throwable caught) { GWT.log("Could not load problems for course", caught); } @Override public void onSuccess(Problem[] result) { getSession().get(CourseSelection.class).courseLoaded(selectedCourse, result); } }; getCoursesAndProblemsService.getProblems(selectedCourse, callback); } else if (key == CourseSelection.Event.COURSE_LOADED) { showProblems(getSession().get(CourseSelection.class).getProblemList()); } }
From source file:eml.studio.client.ui.tree.DatasetTreeLoader.java
License:Open Source License
/** Add a program into the menu */ public static void addDatasetLeaf(final DatasetTree tree, final DatasetLeaf node, String userEmail) { Module m = node.getModule();/* w w w .j a v a2 s. c o m*/ String category = m.getCategory(); if ("0A0F402F-670F-4696-9D9C-42F0E0D665A11".equals(category) || "shared data".equals(category.toLowerCase()) || "?".equals(category)) { // add to shared programs tree.getSharedTree().addItem(node); } else if ("0A0F402F-670F-4696-9D9C-42F0E0D665A22".equals(category) || "my data".equals(category.toLowerCase()) || "?".equals(category)) { // add to my programs if (m.getOwner().equals(userEmail)) { tree.getMyTree().addItem(node); node.addMenuItem(DatasetDeleteMenu.create(node)); } } else if ("0A0F402F-670F-4696-9D9C-42F0E0D665A00".equals(category) || "system data".equals(category.toLowerCase()) || "?".equals(category)) { tree.getSysTree().addItem(node); node.addMenuItem(DatasetDeleteMenu.create(node)); } else if (category.contains(">")) { TreeItem treeItem = tree.findTreeItem(category); treeItem.addItem(node); } else { // add to system programs Category query = new Category(); query.setId(category); query.setType("data"); categorySrv.getCategory(query, "", new AsyncCallback<List<Category>>() { @Override public void onFailure(Throwable caught) { // TODO Auto-generated method stub Window.alert(caught.getMessage()); } @Override public void onSuccess(List<Category> result) { // TODO Auto-generated method stub if (result != null) { TreeItem treeItem; if (result.get(0).getPath().equals(null)) { treeItem = tree.findTreeItem(result.get(0).getName()); } else treeItem = tree.findTreeItem(result.get(0).getPath()); treeItem.addItem(node); } } }); } }