List of usage examples for com.vaadin.ui Tree Tree
public Tree()
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
private Component getUserManagementTab() { VerticalLayout vl = new VerticalLayout(); HorizontalSplitPanel split = new HorizontalSplitPanel(); vl.addComponent(split);//from w ww .j av a 2 s . c o m //Create left side Tree users = new Tree(); //Menu VerticalLayout main = new VerticalLayout(); main.addComponent(users); HorizontalLayout hl = new HorizontalLayout(); Button addUser = new Button(TRANSLATOR.translate("add.user")); addUser.addClickListener(listener -> { VMUserServer user = new VMUserServer(new VmUser()); split.setSecondComponent(new UserComponent(user, true)); }); hl.addComponent(addUser); main.addComponent(hl); split.setFirstComponent(main); VMUserServer.getVMUsers().forEach(user -> { if (!Objects.equals(user.getId(), ((VMUI) UI.getCurrent()).getUser().getId())) { users.addItem(user.getEntity()); users.setItemCaption(user.getEntity(), user.toString()); users.setItemIcon(user.getEntity(), VaadinIcons.USER); users.setChildrenAllowed(user.getEntity(), false); } }); users.addValueChangeListener((Property.ValueChangeEvent event) -> { VmUser user = (VmUser) users.getValue(); split.setSecondComponent(new UserComponent(new VMUserServer(user), true)); }); vl.setSizeFull(); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.component.TemplateComponent.java
License:Apache License
private void init() { tree = new Tree(); tree.addItem(getTemplate());// w ww . jav a 2 s .co m tree.setItemIcon(getTemplate(), VaadinIcons.FILE_TREE); tree.setItemCaption(getTemplate(), getTemplate().getTemplateName()); if (getTemplate().getTemplateNodeList() != null) { getTemplate().getTemplateNodeList().forEach(node -> { if (node.getTemplateNode() == null) { //Only root folders addTemplateNode(node); } }); } //Select item on right click as well tree.addItemClickListener((ItemClickEvent event) -> { if (event.getSource() == tree && event.getButton() == MouseEventDetails.MouseButton.RIGHT) { if (event.getItem() != null) { Item clicked = event.getItem(); tree.select(event.getItemId()); } } }); //Add context menu ContextMenu menu = new ContextMenu(tree, true); if (edit) { tree.addItemClickListener((ItemClickEvent event) -> { if (event.getButton() == MouseEventDetails.MouseButton.RIGHT) { menu.removeItems(); if (tree.getValue() != null) { if (tree.getValue() instanceof Template) { Template t = (Template) tree.getValue(); if (t.getId() < 1_000) { return; } } MenuItem create = menu.addItem(TRANSLATOR.translate("general.add.child"), PROJECT_ICON, (MenuItem selectedItem) -> { displayChildCreationWizard(); }); MenuItem delete = menu.addItem(TRANSLATOR.translate("general.delete"), PROJECT_ICON, (MenuItem selectedItem) -> { displayChildDeletionWizard(); }); //Don't allow to delete the root node. delete.setEnabled(!tree.isRoot(tree.getValue())); } } }); } TextField nameField = new TextField(TRANSLATOR.translate("general.name")); VerticalLayout vl = new VerticalLayout(); BeanFieldGroup binder = new BeanFieldGroup(getTemplate().getClass()); binder.setItemDataSource(getTemplate()); binder.bind(nameField, "templateName"); nameField.addValueChangeListener(listener -> { getTemplate().setTemplateName(nameField.getValue()); }); nameField.setNullRepresentation(""); ComboBox type = new ComboBox(TRANSLATOR.translate("general.type")); BeanItemContainer<ProjectType> container = new BeanItemContainer<>(ProjectType.class, new ProjectTypeJpaController(DataBaseManager.getEntityManagerFactory()).findProjectTypeEntities()); type.setContainerDataSource(container); for (Object o : type.getItemIds()) { ProjectType id = ((ProjectType) o); type.setItemCaption(id, TRANSLATOR.translate(id.getTypeName())); } type.addValueChangeListener(listener -> { if (type.getValue() != null) { getTemplate().setProjectTypeId((ProjectType) type.getValue()); } }); binder.bind(type, "projectTypeId"); vl.addComponent(nameField); vl.addComponent(type); if (template.getId() != null) { vl.addComponent(tree); } binder.setReadOnly(!edit); setContent(vl); }
From source file:org.apache.openaz.xacml.admin.view.windows.ExpressionEditorWindow.java
License:Apache License
@AutoGenerated private VerticalLayout buildMainLayout() { // common part: create layout mainLayout = new VerticalLayout(); mainLayout.setImmediate(false);// w w w . j a va 2 s . c o m mainLayout.setWidth("-1px"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); // top-level component properties setWidth("-1px"); setHeight("-1px"); // comboBox comboBox = new ComboBox(); comboBox.setImmediate(false); comboBox.setWidth("-1px"); comboBox.setHeight("-1px"); mainLayout.addComponent(comboBox); // treeExpression treeExpression = new Tree(); treeExpression.setImmediate(false); treeExpression.setWidth("100.0%"); treeExpression.setHeight("-1px"); mainLayout.addComponent(treeExpression); mainLayout.setExpandRatio(treeExpression, 1.0f); return mainLayout; }
From source file:org.bull.examples.vaadin.osgi.portal.PortalOSGiApplication.java
License:Open Source License
@Override public void init(VaadinRequest request) { HorizontalSplitPanel split = new HorizontalSplitPanel(); split.setSizeFull();//from w w w.j ava 2 s.c o m split.setSplitPosition(250, Unit.PIXELS); tree = new Tree(); for (PortalModule module : getPortalModuleService().getModules()) { tree.addItem(module.getId()); tree.setItemCaption(module.getId(), module.getName()); } tree.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { PortalModule module = getPortalModuleService().getModule((String) event.getItemId()); Iterator<Component> it = tabs.iterator(); Component found = null; while (it.hasNext()) { Component c = it.next(); if (tabs.getTab(c).getCaption().equals(module.getName())) { found = c; break; } } if (found == null) { Tab addTab = tabs.addTab(module.createComponent(eventBus), module.getName()); addTab.setClosable(true); } else { tabs.setSelectedTab(found); } } }); tabs = new TabSheet(); tabs.setSizeFull(); split.setFirstComponent(tree); split.setSecondComponent(tabs); setContent(split); getPortalModuleService().addListener(this); }
From source file:org.escidoc.browser.ui.view.helpers.DragnDropHelper.java
License:Open Source License
protected void createDragComponents() throws EscidocClientException { tree = new Tree(); table = new Table("Drag from table to tree"); table.setWidth("100%"); tableDelete = new Table(); initializeTree(new SourceIs(table)); initializeTable(new SourceIs(tree)); Panel pn = new Panel(); pn.setHeight("100%"); VerticalLayout vlTree = new VerticalLayout(); vlTree.addComponent(new Label("Drag from Tree to Table to add new OU")); vlTree.addComponent(tf);//w w w. j a v a 2 s . c o m vlTree.addComponent(tree); HorizontalLayout hl = new HorizontalLayout(); pn.setContent(vlTree); hl.addComponent(pn); VerticalLayout vl = new VerticalLayout(); vl.setWidth("100%"); hl.addComponent(vl); vl.addComponent(table); if (canRemoveOperation()) { initializeDeleteTable(new SourceIs(table)); vl.addComponent(tableDelete); vl.setComponentAlignment(tableDelete, Alignment.TOP_RIGHT); } addComponent(hl); }
From source file:org.generationcp.breeding.manager.crossingmanager.SelectGermplasmListTreeComponent.java
License:Open Source License
private Tree createGermplasmListTree(Database database) { List<GermplasmList> germplasmListParent = new ArrayList<GermplasmList>(); try {/*from ww w . j av a2 s . c o m*/ germplasmListParent = this.germplasmListManager.getAllTopLevelListsBatched(BATCH_SIZE, database); } catch (MiddlewareQueryException e) { LOG.error(e.toString() + "\n" + e.getStackTrace()); e.printStackTrace(); if (getWindow() != null) { MessageNotifier.showWarning(getWindow(), messageSource.getMessage(Message.ERROR_DATABASE), messageSource.getMessage(Message.ERROR_IN_GETTING_TOP_LEVEL_FOLDERS), Notification.POSITION_CENTERED); } germplasmListParent = new ArrayList<GermplasmList>(); } Tree germplasmListTree = new Tree(); for (GermplasmList parentList : germplasmListParent) { germplasmListTree.addItem(parentList.getId()); germplasmListTree.setItemCaption(parentList.getId(), parentList.getName()); } germplasmListTree.addListener(new SelectListTreeExpandListener(this)); germplasmListTree.addListener(new SelectListItemClickListener(this)); return germplasmListTree; }
From source file:org.hip.vif.admin.groupadmin.ui.GroupContentView.java
License:Open Source License
/** View constructor * //from w w w. jav a 2 s . co m * @param inGroup {@link Group} * @param inQuestions {@link GroupContentContainer} * @param inTask {@link AdminQuestionListTask} */ public GroupContentView(final Group inGroup, final GroupContentContainer inQuestions, final AdminQuestionListTask inTask) { task = inTask; final VerticalLayout lLayout = new VerticalLayout(); setCompositionRoot(lLayout); final IMessages lMessages = Activator.getMessages(); lLayout.setStyleName("vif-table"); //$NON-NLS-1$ final String lTitle = lMessages.getFormattedMessage("ui.discussion.questions.view.title.page", //$NON-NLS-1$ BeanWrapperHelper.getLong(GroupHome.KEY_ID, inGroup), BeanWrapperHelper.getString(GroupHome.KEY_NAME, inGroup)); lLayout.addComponent( new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-pagetitle", lTitle), ContentMode.HTML)); //$NON-NLS-1$ //$NON-NLS-2$ final Label lSubtitle = new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-description", //$NON-NLS-1$ lMessages.getMessage("ui.discussion.questions.view.title.sub")), ContentMode.HTML); //$NON-NLS-1$ lLayout.addComponent(lSubtitle); final Tree lTree = new Tree(); lTree.focus(); lTree.setContainerDataSource(inQuestions); lLayout.addComponent(lTree); for (final GroupContentWrapper lNode : inQuestions.getExpandedNodes()) { lTree.expandItem(lNode); } lTree.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(final ItemClickEvent inEvent) { task.processSelection((GroupContentWrapper) inEvent.getItemId()); } }); lTree.addShortcutListener(new ExtendedShortcutListener("enter", KeyCode.ENTER)); //$NON-NLS-1$ }
From source file:org.hip.vif.forum.groups.ui.GroupContentView.java
License:Open Source License
/** Constructor * * @param inGroup {@link Group}/*from w w w. jav a2 s .c o m*/ * @param inContent {@link GroupContentContainer} * @param inTask {@link GroupShowTask} * @throws VException */ public GroupContentView(final Group inGroup, final GroupContentContainer inContent, final GroupShowTask inTask) throws VException { task = inTask; final VerticalLayout lLayout = new VerticalLayout(); setCompositionRoot(lLayout); lLayout.setStyleName("vif-table"); //$NON-NLS-1$ lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", //$NON-NLS-1$ Activator.getMessages().getFormattedMessage("ui.group.content.view.title.page", //$NON-NLS-1$ inGroup.get(GroupHome.KEY_NAME).toString())), ContentMode.HTML)); //$NON-NLS-1$ lLayout.addComponent(new Label( String.format(VIFViewHelper.TMPL_TITLE, "vif-description", //$NON-NLS-1$ inGroup.get(GroupHome.KEY_DESCRIPTION).toString()), ContentMode.HTML)); questionTree = new Tree(); questionTree.focus(); questionTree.setContainerDataSource(inContent); lLayout.addComponent(questionTree); for (final GroupContentWrapper lNode : inContent.getExpandedNodes()) { questionTree.expandItem(lNode); } questionTree.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(final ItemClickEvent inEvent) { task.processSelection((GroupContentWrapper) inEvent.getItemId()); } }); questionTree.addShortcutListener(new ExtendedShortcutListener("enter", KeyCode.ENTER)); //$NON-NLS-1$ }
From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java
License:BSD License
protected void createModuleTreePanel() { this.topologyTreePanel = new Panel(); this.topologyTreePanel.addStyleName(ValoTheme.PANEL_BORDERLESS); this.topologyTreePanel.setSizeFull(); this.moduleTree = new Tree(); this.moduleTree.setImmediate(true); this.moduleTree.setSizeFull(); this.moduleTree.addActionHandler(this); this.moduleTree.setDragMode(TreeDragMode.NODE); this.moduleTree.setItemStyleGenerator(new ItemStyleGenerator() { @Override/*from w w w. j av a2 s .co m*/ public String getStyle(Tree source, Object itemId) { if (itemId instanceof Flow) { Flow flow = (Flow) itemId; String state = flowStates.get(flow.getModule().getName() + "-" + flow.getName()); logger.info("State = " + state); if (state != null && state.equals(RUNNING)) { return "greenicon"; } else if (state != null && state.equals(RECOVERING)) { return "orangeicon"; } else if (state != null && state.equals(STOPPED)) { return "redicon"; } else if (state != null && state.equals(STOPPED_IN_ERROR)) { return "redicon"; } else if (state != null && state.equals(PAUSED)) { return "indigoicon"; } } return ""; } }); GridLayout layout = new GridLayout(1, 4); Label roleManagementLabel = new Label("Topology"); roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(roleManagementLabel, 0, 0); layout.setSpacing(true); layout.setWidth("100%"); this.treeViewBusinessStreamCombo = new ComboBox("Business Stream"); this.treeViewBusinessStreamCombo.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (event.getProperty() != null && event.getProperty().getValue() != null) { businessStream = (BusinessStream) event.getProperty().getValue(); logger.info("Value changed to business stream: " + businessStream.getName()); moduleTree.removeAllItems(); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && businessStream.getName().equals("All")) { List<Server> servers = TopologyViewPanel.this.topologyService.getAllServers(); for (Server server : servers) { Set<Module> modules = server.getModules(); TopologyViewPanel.this.moduleTree.addItem(server); TopologyViewPanel.this.moduleTree.setItemCaption(server, server.getName()); TopologyViewPanel.this.moduleTree.setChildrenAllowed(server, true); TopologyViewPanel.this.moduleTree.setItemIcon(server, VaadinIcons.SERVER); for (Module module : modules) { TopologyViewPanel.this.moduleTree.addItem(module); TopologyViewPanel.this.moduleTree.setItemCaption(module, module.getName()); TopologyViewPanel.this.moduleTree.setParent(module, server); TopologyViewPanel.this.moduleTree.setChildrenAllowed(module, true); TopologyViewPanel.this.moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); Set<Flow> flows = module.getFlows(); for (Flow flow : flows) { TopologyViewPanel.this.moduleTree.addItem(flow); TopologyViewPanel.this.moduleTree.setItemCaption(flow, flow.getName()); TopologyViewPanel.this.moduleTree.setParent(flow, module); TopologyViewPanel.this.moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { TopologyViewPanel.this.moduleTree.addItem(component); TopologyViewPanel.this.moduleTree.setParent(component, flow); TopologyViewPanel.this.moduleTree.setItemCaption(component, component.getName()); TopologyViewPanel.this.moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } else if (authentication != null && !authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && businessStream.getName().equals("All")) { List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams(); for (BusinessStream businessStream : businessStreams) { if (authentication.canAccessLinkedItem( PolicyLinkTypeConstants.BUSINESS_STREAM_LINK_TYPE, businessStream.getId())) { for (BusinessStreamFlow bsFlow : businessStream.getFlows()) { Server server = bsFlow.getFlow().getModule().getServer(); Module module = bsFlow.getFlow().getModule(); Flow flow = bsFlow.getFlow(); if (!moduleTree.containsId(server)) { moduleTree.addItem(server); moduleTree.setItemCaption(server, server.getName()); moduleTree.setChildrenAllowed(server, true); moduleTree.setItemIcon(server, VaadinIcons.SERVER); } moduleTree.addItem(module); moduleTree.setItemCaption(module, module.getName()); moduleTree.setParent(module, server); moduleTree.setChildrenAllowed(module, true); moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); moduleTree.addItem(flow); moduleTree.setItemCaption(flow, flow.getName()); moduleTree.setParent(flow, module); moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { moduleTree.addItem(component); moduleTree.setParent(component, flow); moduleTree.setItemCaption(component, component.getName()); moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } else { for (BusinessStreamFlow bsFlow : businessStream.getFlows()) { Server server = bsFlow.getFlow().getModule().getServer(); Module module = bsFlow.getFlow().getModule(); Flow flow = bsFlow.getFlow(); if (!moduleTree.containsId(server)) { moduleTree.addItem(server); moduleTree.setItemCaption(server, server.getName()); moduleTree.setChildrenAllowed(server, true); moduleTree.setItemIcon(server, VaadinIcons.SERVER); } moduleTree.addItem(module); moduleTree.setItemCaption(module, module.getName()); moduleTree.setParent(module, server); moduleTree.setChildrenAllowed(module, true); moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); moduleTree.addItem(flow); moduleTree.setItemCaption(flow, flow.getName()); moduleTree.setParent(flow, module); moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { moduleTree.addItem(component); moduleTree.setParent(component, flow); moduleTree.setItemCaption(component, component.getName()); moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } }); this.treeViewBusinessStreamCombo.setWidth("250px"); layout.addComponent(this.treeViewBusinessStreamCombo); Button discoverButton = new Button("Discover"); discoverButton.setStyleName(ValoTheme.BUTTON_SMALL); discoverButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); try { topologyService.discover(authentication); } catch (DiscoveryException e) { Notification.show("An error occurred trying to auto discover modules: " + e.getMessage(), Type.ERROR_MESSAGE); } Notification.show("Auto discovery complete!"); } }); Button refreshButton = new Button("Refresh"); refreshButton.setStyleName(ValoTheme.BUTTON_SMALL); refreshButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { refreshTree(); } }); Button newServerButton = new Button("New Server"); newServerButton.setStyleName(ValoTheme.BUTTON_SMALL); newServerButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new NewServerWindow(topologyService)); } }); GridLayout buttonLayout = new GridLayout(3, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(discoverButton); buttonLayout.addComponent(refreshButton); buttonLayout.addComponent(newServerButton); layout.addComponent(buttonLayout); layout.addComponent(this.moduleTree); this.topologyTreePanel.setContent(layout); }
From source file:org.lucidj.explorer.ExplorerView.java
License:Apache License
private void view_directory(Map<String, Object> entry) { String directory = (String) entry.get("directory"); String caption = (String) entry.get("iconTitle"); Tree tree = active_trees.get(directory); if (tree == null) { CustomFilesystemContainer fs = new CustomFilesystemContainer(Paths.get(directory)); tree = new Tree(); tree.addStyleName("x-explorerview"); tree.setContainerDataSource(fs); tree.setItemIconPropertyId(FilesystemContainer.PROPERTY_ICON); tree.setItemCaptionPropertyId(FilesystemContainer.PROPERTY_NAME); tree.setSelectable(false);/*from ww w . ja v a 2 s. com*/ tree.setImmediate(true); tree.setHeightUndefined(); tree.addItemClickListener(this); active_trees.put(directory, tree); } // Refresh the tree and switch over tree.setContainerDataSource(tree.getContainerDataSource()); browse_files.setContent(tree); browse_files.setCaption(caption); }