List of usage examples for com.vaadin.ui Tree Tree
public Tree()
From source file:com.etest.valo.Trees.java
License:Apache License
public Trees() { setMargin(true);//from w w w. j a va2s. c o m Label h1 = new Label("Trees"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Tree tree = new Tree(); tree.setSelectable(true); tree.setMultiSelect(true); Container generateContainer = MainUI.generateContainer(10, true); tree.setContainerDataSource(generateContainer); tree.setDragMode(TreeDragMode.NODE); row.addComponent(tree); tree.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); tree.setItemIconPropertyId(MainUI.ICON_PROPERTY); tree.expandItem(generateContainer.getItemIds().iterator().next()); tree.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); // Add actions (context menu) tree.addActionHandler(MainUI.getActionHandler()); }
From source file:com.github.peholmst.springsecuritydemo.ui.CategoryBrowser.java
License:Apache License
/** * Creates the category browser component. *//*from w w w .j a va 2s .co m*/ @SuppressWarnings("serial") private void createComponent() { categoryContainer = new CategoryContainer(getCategoryService()); categoryContainer.refresh(); /* * The tree will show all the categories returned from the category * service. */ categoryTree = new Tree(); { categoryTree.setSizeFull(); categoryTree.setContainerDataSource(categoryContainer); categoryTree.setItemCaptionPropertyId("name"); categoryTree.setImmediate(true); } /* * The form for editing categories is hidden by default and is shown * when the user clicks the edit or add button. */ categoryForm = new CategoryForm(); /* * The toolbar will be placed at the bottom of the browser and contains * buttons for refreshing the category tree, and adding, editing and * removing categories. */ final HorizontalLayout toolbar = new HorizontalLayout(); { /* * Button: Refresh the category browser */ refreshButton = new Button(); refreshButton.setIcon(new ThemeResource("icons/16/refresh.png")); refreshButton.setStyleName("small"); refreshButton.setDescription(getI18nProvider().getMessage("categories.refresh.descr")); refreshButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionRefresh(); } }); toolbar.addComponent(refreshButton); /* * Button: Add a new category. The currently selected category will * be used as parent. */ addButton = new Button(); addButton.setIcon(new ThemeResource("icons/16/add.png")); addButton.setStyleName("small"); addButton.setDescription(getI18nProvider().getMessage("categories.add.descr")); addButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionAdd(); } }); toolbar.addComponent(addButton); /* * Button: Edit the selected category */ editButton = new Button(); editButton.setIcon(new ThemeResource("icons/16/pencil.png")); editButton.setStyleName("small"); editButton.setDescription(getI18nProvider().getMessage("categories.edit.descr")); editButton.setEnabled(false); editButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionEdit(); } }); toolbar.addComponent(editButton); /* * Button: Delete the selected category */ deleteButton = new Button(); deleteButton.setIcon(new ThemeResource("icons/16/delete.png")); deleteButton.setStyleName("small"); deleteButton.setDescription(getI18nProvider().getMessage("categories.delete.descr")); deleteButton.setEnabled(false); deleteButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionDelete(); } }); toolbar.addComponent(deleteButton); /* * Button: Show/edit the access control list for the selected * category */ aclButton = new Button(); aclButton.setIcon(new ThemeResource("icons/16/lock_edit.png")); aclButton.setStyleName("small"); aclButton.setDescription(getI18nProvider().getMessage("categories.acl.descr")); aclButton.setEnabled(false); aclButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionACL(); } }); toolbar.addComponent(aclButton); /* * Button: Show the audit log for the selected category */ auditButton = new Button(); auditButton.setIcon(new ThemeResource("icons/16/key.png")); auditButton.setStyleName("small"); auditButton.setDescription(getI18nProvider().getMessage("categories.audit.descr")); auditButton.setEnabled(false); auditButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { actionAudit(); } }); toolbar.addComponent(auditButton); } /* * The browser layout contains the category tree and the toolbar. */ browserComponent = new VerticalLayout(); browserComponent.setSizeFull(); browserComponent.addComponent(categoryTree); browserComponent.addComponent(categoryForm.getComponent()); browserComponent.addComponent(toolbar); browserComponent.setExpandRatio(categoryTree, 1.0f); browserComponent.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER); /* * Register a listener that updates the enablement state every time the * selection changes. */ categoryTree.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { updateEnablementState(); Long newCategoryId = (Long) event.getProperty().getValue(); Category newCategory = null; if (newCategoryId != null) { BeanItem<Category> item = categoryContainer.getItem(newCategoryId); if (item != null) { newCategory = item.getBean(); } } fireCategorySelectionChanged(newCategory); } }); }
From source file:com.kelt.disk.db.web.DiskDBApplication.java
License:Apache License
private void setUpWindow(Window window) { Tree tree = new Tree(); fillTreeComponent(tree, createTestNodes(), null); window.addComponent(tree); }
From source file:com.klwork.explorer.project.PublicProjectListPage.java
License:Apache License
Layout buildTree() { CssLayout margin = new CssLayout(); margin.setWidth("100%"); //margin.setMargin(new MarginInfo(true, false, true, true)); // Spacing/*from ww w . ja v a2s .c om*/ margin.addComponent(new Label(" ", ContentMode.HTML)); Label text = new Label("hello,word"); text.addStyleName(Runo.LABEL_SMALL); margin.addComponent(text); text.setWidth("90%"); Tree t = new Tree(); String itemId = "?"; t.addItem(itemId); t.select(itemId); t.setItemIcon(itemId, new ThemeResource("icons/16/calendar.png")); createTreeItem(t, "(5000)", itemId); t.expandItem(itemId); String itemId2 = ""; t.addItem(itemId2); t.setItemIcon(itemId2, new ThemeResource("icons/16/document.png")); createTreeItem(t, "?(300)", itemId2); createTreeItem(t, "log", itemId2); t.expandItem(itemId2); String itemId3 = "?"; t.addItem(itemId3); t.setItemIcon(itemId3, new ThemeResource("icons/16/document.png")); createTreeItem(t, "?(3009)", itemId3); createTreeItem(t, "(40000)", itemId3); t.expandItem(itemId3); margin.addComponent(t); return margin; }
From source file:com.mcparland.john.AdjustableLayout.java
License:Apache License
/** * Create the menu.//from ww w . j av a2 s . co m * * @return the menu. */ private Tree createMenu() { Tree menu = new Tree(); for (int i = 1; i < 6; i++) { String item = "item" + i; String childItem = "subitem" + i; menu.addItem(item); menu.addItem(childItem); menu.setParent(childItem, item); menu.setChildrenAllowed(childItem, false); } return menu; }
From source file:com.mycollab.module.file.view.AbstractResourceMovingWindow.java
License:Open Source License
private void constructBody() { MVerticalLayout contentLayout = new MVerticalLayout(); new Restrain(contentLayout).setMaxHeight("600px"); this.setContent(contentLayout); folderTree = new Tree(); folderTree.setMultiSelect(false);//from w ww.ja va 2 s .c o m folderTree.setSelectable(true); folderTree.setImmediate(true); folderTree.setSizeFull(); folderTree.addExpandListener(expandEvent -> { final Folder expandFolder = (Folder) expandEvent.getItemId(); // load externalResource if currentExpandFolder is rootFolder if (baseFolder.getPath().equals(expandFolder.getPath())) { List<ExternalDrive> externalDrives = externalDriveService .getExternalDrivesOfUser(UserUIContext.getUsername()); for (ExternalDrive externalDrive : externalDrives) { ExternalFolder externalMapFolder = new ExternalFolder("/"); externalMapFolder.setStorageName(externalDrive.getStoragename()); externalMapFolder.setExternalDrive(externalDrive); externalMapFolder.setName(externalDrive.getFoldername()); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(externalDrive.getCreatedtime()); externalMapFolder.setCreated(cal); expandFolder.addChild(externalMapFolder); folderTree.addItem(externalMapFolder); folderTree.setItemIcon(externalMapFolder, FontAwesome.DROPBOX); folderTree.setItemCaption(externalMapFolder, externalMapFolder.getName()); folderTree.setParent(externalMapFolder, expandFolder); } } if (expandFolder instanceof ExternalFolder) { List<ExternalFolder> subFolders = externalResourceService .getSubFolders(((ExternalFolder) expandFolder).getExternalDrive(), expandFolder.getPath()); for (final Folder subFolder : subFolders) { expandFolder.addChild(subFolder); folderTree.addItem(subFolder); folderTree.setItemIcon(subFolder, FontAwesome.DROPBOX); folderTree.setItemCaption(subFolder, subFolder.getName()); folderTree.setParent(subFolder, expandFolder); } } else { final List<Folder> subFolders = resourceService.getSubFolders(expandFolder.getPath()); folderTree.setItemIcon(expandFolder, FontAwesome.FOLDER_OPEN); if (subFolders != null) { for (final Folder subFolder : subFolders) { String subFolderName = subFolder.getName(); if (!subFolderName.startsWith(".")) { expandFolder.addChild(subFolder); folderTree.addItem(subFolder); folderTree.setItemIcon(subFolder, FontAwesome.FOLDER); folderTree.setItemCaption(subFolder, subFolderName); folderTree.setParent(subFolder, expandFolder); } } } } }); folderTree.addCollapseListener(new Tree.CollapseListener() { private static final long serialVersionUID = 1L; @Override public void nodeCollapse(final CollapseEvent event) { final Folder collapseFolder = (Folder) event.getItemId(); if (collapseFolder instanceof ExternalFolder) { folderTree.setItemIcon(collapseFolder, FontAwesome.DROPBOX); } else { folderTree.setItemIcon(collapseFolder, FontAwesome.FOLDER); } collapseFolder.getChilds().forEach(this::recursiveRemoveSubItem); } private void recursiveRemoveSubItem(Folder collapseFolder) { List<Folder> childFolders = collapseFolder.getChilds(); if (childFolders.size() > 0) { childFolders.forEach(this::recursiveRemoveSubItem); folderTree.removeItem(collapseFolder); } else { folderTree.removeItem(collapseFolder); } } }); folderTree.addItemClickListener(itemClickEvent -> baseFolder = (Folder) itemClickEvent.getItemId()); CssLayout treeWrapper = new CssLayout(folderTree); treeWrapper.setSizeFull(); contentLayout.addComponent(treeWrapper); displayFiles(); MButton moveBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_MOVE), clickEvent -> { if (!CollectionUtils.isEmpty(movedResources)) { boolean checkingFail = false; for (Resource res : movedResources) { try { resourceMover.moveResource(res, baseFolder, UserUIContext.getUsername(), MyCollabUI.getAccountId()); } catch (Exception e) { checkingFail = true; LOG.error("Error", e); } } close(); displayAfterMoveSuccess(baseFolder, checkingFail); } }).withIcon(FontAwesome.ARROWS).withStyleName(WebThemes.BUTTON_ACTION); MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL), clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION); MHorizontalLayout controlGroupBtnLayout = new MHorizontalLayout(cancelBtn, moveBtn); contentLayout.with(controlGroupBtnLayout).withAlign(controlGroupBtnLayout, Alignment.MIDDLE_RIGHT); }
From source file:com.mycollab.module.file.view.components.AbstractResourceMovingWindow.java
License:Open Source License
private void constructBody() { MVerticalLayout contentLayout = new MVerticalLayout(); new Restrain(contentLayout).setMaxHeight("600px"); this.setContent(contentLayout); folderTree = new Tree(); folderTree.setMultiSelect(false);// w w w . ja v a 2s . c om folderTree.setSelectable(true); folderTree.setImmediate(true); folderTree.setSizeFull(); folderTree.addExpandListener(new Tree.ExpandListener() { private static final long serialVersionUID = 1L; @Override public void nodeExpand(final ExpandEvent event) { final Folder expandFolder = (Folder) event.getItemId(); // load externalResource if currentExpandFolder is rootFolder if (baseFolder.getPath().equals(expandFolder.getPath())) { List<ExternalDrive> externalDrives = externalDriveService .getExternalDrivesOfUser(AppContext.getUsername()); for (ExternalDrive externalDrive : externalDrives) { ExternalFolder externalMapFolder = new ExternalFolder("/"); externalMapFolder.setStorageName(externalDrive.getStoragename()); externalMapFolder.setExternalDrive(externalDrive); externalMapFolder.setName(externalDrive.getFoldername()); Calendar cal = GregorianCalendar.getInstance(); cal.setTime(externalDrive.getCreatedtime()); externalMapFolder.setCreated(cal); expandFolder.addChild(externalMapFolder); folderTree.addItem(externalMapFolder); folderTree.setItemIcon(externalMapFolder, FontAwesome.DROPBOX); folderTree.setItemCaption(externalMapFolder, externalMapFolder.getName()); folderTree.setParent(externalMapFolder, expandFolder); } } if (expandFolder instanceof ExternalFolder) { List<ExternalFolder> subFolders = externalResourceService.getSubFolders( ((ExternalFolder) expandFolder).getExternalDrive(), expandFolder.getPath()); for (final Folder subFolder : subFolders) { expandFolder.addChild(subFolder); folderTree.addItem(subFolder); folderTree.setItemIcon(subFolder, FontAwesome.DROPBOX); folderTree.setItemCaption(subFolder, subFolder.getName()); folderTree.setParent(subFolder, expandFolder); } } else { final List<Folder> subFolders = resourceService.getSubFolders(expandFolder.getPath()); folderTree.setItemIcon(expandFolder, FontAwesome.FOLDER_OPEN); if (subFolders != null) { for (final Folder subFolder : subFolders) { String subFolderName = subFolder.getName(); if (!subFolderName.startsWith(".")) { expandFolder.addChild(subFolder); folderTree.addItem(subFolder); folderTree.setItemIcon(subFolder, FontAwesome.FOLDER); folderTree.setItemCaption(subFolder, subFolderName); folderTree.setParent(subFolder, expandFolder); } } } } } }); folderTree.addCollapseListener(new Tree.CollapseListener() { private static final long serialVersionUID = 1L; @Override public void nodeCollapse(final CollapseEvent event) { final Folder collapseFolder = (Folder) event.getItemId(); if (collapseFolder instanceof ExternalFolder) { folderTree.setItemIcon(collapseFolder, FontAwesome.DROPBOX); } else { folderTree.setItemIcon(collapseFolder, FontAwesome.FOLDER); } for (Folder folder : collapseFolder.getChilds()) { recursiveRemoveSubItem(folder); } } private void recursiveRemoveSubItem(Folder collapseFolder) { List<Folder> childFolders = collapseFolder.getChilds(); if (childFolders.size() > 0) { for (Folder subFolder : childFolders) { recursiveRemoveSubItem(subFolder); } folderTree.removeItem(collapseFolder); } else { folderTree.removeItem(collapseFolder); } } }); folderTree.addItemClickListener(new ItemClickEvent.ItemClickListener() { private static final long serialVersionUID = 1L; @Override public void itemClick(final ItemClickEvent event) { baseFolder = (Folder) event.getItemId(); } }); CssLayout treeWrapper = new CssLayout(folderTree); treeWrapper.setSizeFull(); contentLayout.addComponent(treeWrapper); displayFiles(); MHorizontalLayout controlGroupBtnLayout = new MHorizontalLayout(); Button moveBtn = new Button("Move", new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (!CollectionUtils.isEmpty(movedResources)) { boolean checkingFail = false; for (Resource res : movedResources) { try { resourceMover.moveResource(res, baseFolder, AppContext.getUsername(), AppContext.getAccountId()); } catch (Exception e) { checkingFail = true; LOG.error("Error", e); } } close(); displayAfterMoveSuccess(baseFolder, checkingFail); } } }); moveBtn.setIcon(FontAwesome.ARROWS); moveBtn.addStyleName(UIConstants.BUTTON_ACTION); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { close(); } }); cancelBtn.addStyleName(UIConstants.BUTTON_OPTION); controlGroupBtnLayout.with(cancelBtn, moveBtn); contentLayout.with(controlGroupBtnLayout).withAlign(controlGroupBtnLayout, Alignment.MIDDLE_RIGHT); }
From source file:com.oodrive.nuage.webui.component.VvrTreeComponent.java
License:Apache License
@SuppressWarnings({ "serial" }) @Override//from w ww.ja va2 s .co m public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) { vvrTree = new Tree(); vvrTree.setChildrenAllowed(vvrTree, true); vvrTree.setSizeFull(); vvrTree.setImmediate(true); vvrTree.addStyleName(BaseTheme.TREE_CONNECTORS); // Add snapshots on the tree final Set<UUID> snapshotUuidList = model.getSnapshotsList(); for (final UUID snapshotUuid : snapshotUuidList) { addSnapshot(handler.createSnapshotModel(model, snapshotUuid)); } // Add devices on the tree final Set<UUID> deviceUuidList = model.getDevicesList(); for (final UUID deviceUuid : deviceUuidList) { addDevice(handler.createDeviceModel(model, deviceUuid)); } vvrTree.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final Object id = vvrTree.getValue(); if (id != null) { if (id instanceof SnapshotModel) { final SnapshotModel snapshotModel = (SnapshotModel) id; treeItemlayout.removeAllComponents(); selectedItem = new SnapshotItemComponent(snapshotModel); treeItemlayout.addComponent(selectedItem.init()); } else if (id instanceof DeviceModel) { final DeviceModel deviceModel = (DeviceModel) id; treeItemlayout.removeAllComponents(); selectedItem = new DeviceItemComponent(deviceModel); treeItemlayout.addComponent(selectedItem.init()); } } else { // Delete all treeItemlayout.removeAllComponents(); } } }); return vvrTree; }
From source file:com.rex.components.valo.Trees.java
License:Apache License
public Trees() { setMargin(true);/*from w ww . j a v a 2s . c om*/ Label h1 = new Label("Trees"); h1.addStyleName("h1"); addComponent(h1); HorizontalLayout row = new HorizontalLayout(); row.addStyleName("wrapping"); row.setSpacing(true); addComponent(row); Tree tree = new Tree(); tree.setSelectable(true); tree.setMultiSelect(true); Container generateContainer = ReportEngineUI.generateContainer(10, true); tree.setContainerDataSource(generateContainer); tree.setDragMode(TreeDragMode.NODE); row.addComponent(tree); tree.setItemCaptionPropertyId(ReportEngineUI.CAPTION_PROPERTY); tree.setItemIconPropertyId(ReportEngineUI.ICON_PROPERTY); tree.expandItem(generateContainer.getItemIds().iterator().next()); tree.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); // Add actions (context menu) tree.addActionHandler(ReportEngineUI.getActionHandler()); }
From source file:com.vaushell.treetasker.application.tree.TTWtree.java
License:Open Source License
private void init() { navigationTree = new Tree(); HierarchicalContainer container = new HierarchicalContainer(); navigationTree.setContainerDataSource(container); navigationTree.setDragMode(Tree.TreeDragMode.NODE); navigationTree.setDropHandler(new TreeSortDropHandler(navigationTree, controller)); navigationTree.setMultiSelect(true); currentNode = null;// w ww .j a v a 2s .c o m taskToNodeMap = new HashMap<TT_Task, TaskNode>(); setSizeUndefined(); addComponent(navigationTree); initListeners(); }