List of usage examples for com.vaadin.ui Tree.ExpandListener Tree.ExpandListener
Tree.ExpandListener
From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttTreeTable.java
License:Open Source License
public GanttTreeTable(final GanttExt gantt) { super();/* w ww.j a v a 2s. c o m*/ this.gantt = gantt; this.setWidth("800px"); this.setBuffered(true); beanContainer = gantt.getBeanContainer(); this.setContainerDataSource(beanContainer); this.setVisibleColumns("ganttIndex", "name", "startDate", "endDate", "duration", "percentageComplete", "predecessors", "assignUser"); this.setColumnHeader("ganttIndex", ""); this.setColumnWidth("ganttIndex", 25); this.setColumnHeader("name", "Task"); this.setColumnExpandRatio("name", 1.0f); this.setHierarchyColumn("name"); this.setColumnHeader("startDate", "Start"); this.setColumnWidth("startDate", 90); this.setColumnHeader("endDate", "End"); this.setColumnWidth("endDate", 90); this.setColumnHeader("duration", "Duration"); this.setColumnWidth("duration", 65); this.setColumnHeader("predecessors", "Predecessors"); this.setColumnWidth("predecessors", 100); this.setColumnHeader("percentageComplete", "% Complete"); this.setColumnWidth("percentageComplete", 75); this.setColumnHeader("assignUser", "Assignee"); this.setColumnWidth("assignUser", 80); this.setColumnCollapsingAllowed(true); this.setColumnCollapsed("assignUser", true); this.setEditable(true); this.setNullSelectionAllowed(false); this.addGeneratedColumn("ganttIndex", new ColumnGenerator() { @Override public Object generateCell(Table table, Object itemId, Object columnId) { GanttItemWrapper item = (GanttItemWrapper) itemId; return new ELabel("" + item.getGanttIndex()).withStyleName(ValoTheme.LABEL_SMALL); } }); this.setTableFieldFactory(new TableFieldFactory() { @Override public Field<?> createField(Container container, Object itemId, final Object propertyId, Component uiContext) { Field field = null; final GanttItemWrapper ganttItem = (GanttItemWrapper) itemId; if ("name".equals(propertyId)) { field = new AssignmentNameCellField(ganttItem.getType()); } else if ("percentageComplete".equals(propertyId)) { field = new TextField(); ((TextField) field).setNullRepresentation("0"); ((TextField) field).setImmediate(true); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks() || ganttItem.isMilestone()) { field.setEnabled(false); ((TextField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } else if ("startDate".equals(propertyId) || "endDate".equals(propertyId)) { field = new DateField(); field.addStyleName(ValoTheme.DATEFIELD_SMALL); ((DateField) field).setConverter(new LocalDateConverter()); ((DateField) field).setImmediate(true); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((DateField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } else if ("assignUser".equals(propertyId)) { field = new ProjectMemberSelectionField(); } else if ("predecessors".equals(propertyId)) { field = new DefaultViewField(""); ((DefaultViewField) field).setConverter(new PredecessorConverter()); return field; } else if ("duration".equals(propertyId)) { field = new TextField(); ((TextField) field).setConverter(new HumanTimeConverter()); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((TextField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } if (field != null) { field.setBuffered(true); field.setWidth("100%"); if (ganttItem.isMilestone()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isTask()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isBug()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else { throw new MyCollabException( "Do not support gantt item type " + ganttItem.getTask().getType()); } if (field instanceof FieldEvents.BlurNotifier) { ((FieldEvents.BlurNotifier) field).addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { Object o = event.getSource(); if (o instanceof Field) { Field f = (Field) o; if (f.isModified()) { f.commit(); EventBusFactory.getInstance().post(new GanttEvent.AddGanttItemUpdateToQueue( GanttTreeTable.this, ganttItem)); GanttTreeTable.this.refreshRowCache(); } } } }); } } return field; } }); this.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent expandEvent) { GanttItemWrapper item = (GanttItemWrapper) expandEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); insertSubSteps(item, subTasks); } }); this.addCollapseListener(new Tree.CollapseListener() { @Override public void nodeCollapse(Tree.CollapseEvent collapseEvent) { GanttItemWrapper item = (GanttItemWrapper) collapseEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); removeSubSteps(item, subTasks); } }); this.setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(Table source, Object itemId, Object propertyId) { GanttItemWrapper item = (GanttItemWrapper) itemId; if (item.isMilestone()) { return "root"; } else if (item.isTask()) { return ""; } return ""; } }); final GanttContextMenu contextMenu = new GanttContextMenu(); contextMenu.setAsContextMenuOf(this); contextMenu.setOpenAutomatically(false); ContextMenu.ContextMenuOpenedListener.TableListener tableListener = new ContextMenu.ContextMenuOpenedListener.TableListener() { public void onContextMenuOpenFromRow(ContextMenu.ContextMenuOpenedOnTableRowEvent event) { GanttItemWrapper item = (GanttItemWrapper) event.getItemId(); contextMenu.displayContextMenu(item); contextMenu.open(GanttTreeTable.this); } public void onContextMenuOpenFromHeader(ContextMenu.ContextMenuOpenedOnTableHeaderEvent event) { } public void onContextMenuOpenFromFooter(ContextMenu.ContextMenuOpenedOnTableFooterEvent event) { } }; contextMenu.addContextMenuTableListener(tableListener); gantt.setVerticalScrollDelegateTarget(this); this.setPageLength(currentPageLength); }
From source file:com.haulmont.cuba.web.app.folders.CubaFoldersPane.java
License:Apache License
protected void collapseItemInTree(Tree tree, final String foldersCollapse) { String s = userSettingService.loadSetting(foldersCollapse); List<UUID> idFolders = strToIds(s); //noinspection unchecked, RedundantCast for (AbstractSearchFolder folder : (Collection<AbstractSearchFolder>) tree.getItemIds()) { if (idFolders.contains(folder.getId())) { tree.collapseItem(folder);/*w w w . j a va 2s . c o m*/ } } tree.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent event) { if (event.getItemId() instanceof AbstractSearchFolder) { UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId(); String str = userSettingService.loadSetting(foldersCollapse); userSettingService.saveSetting(foldersCollapse, removeIdInStr(str, uuid)); } } }); tree.addCollapseListener(new Tree.CollapseListener() { @Override public void nodeCollapse(Tree.CollapseEvent event) { if (event.getItemId() instanceof AbstractSearchFolder) { UUID uuid = ((AbstractSearchFolder) event.getItemId()).getId(); String str = userSettingService.loadSetting(foldersCollapse); userSettingService.saveSetting(foldersCollapse, addIdInStr(str, uuid)); } } }); }
From source file:com.haulmont.cuba.web.app.folders.CubaFoldersPane.java
License:Apache License
protected Component createAppFoldersPane() { List<AppFolder> appFolders = foldersService.loadAppFolders(); if (appFolders.isEmpty()) return null; appFoldersTree = new CubaTree(); appFoldersTree.setCubaId("appFoldersTree"); appFoldersTree.setSelectable(true);/*from w w w .j ava2s.com*/ appFoldersTree.setItemStyleGenerator(new FolderTreeStyleProvider()); appFoldersTree.addShortcutListener( new ShortcutListener("applyAppFolder", ShortcutAction.KeyCode.ENTER, (int[]) null) { @Override public void handleAction(Object sender, Object target) { if (target == appFoldersTree) { AbstractSearchFolder folder = (AbstractSearchFolder) appFoldersTree.getValue(); if (folder != null) { openFolder(folder); } } } }); appFoldersTree.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent event) { AppFolder folder = (AppFolder) event.getItemId(); if (StringUtils.isBlank(folder.getQuantityScript())) { folder.setQuantity(null); folder.setItemStyle(null); setFolderTreeItemCaption(appFoldersTree, folder); } } }); appFoldersTree.addCollapseListener(new Tree.CollapseListener() { @Override public void nodeCollapse(Tree.CollapseEvent event) { AppFolder folder = (AppFolder) event.getItemId(); if (StringUtils.isBlank(folder.getQuantityScript())) { reloadSingleParentFolder(folder, null); setFolderTreeItemCaption(appFoldersTree, folder); } } }); appFoldersRoot = messages.getMainMessage("folders.appFoldersRoot"); fillTree(appFoldersTree, appFolders, isNeedRootAppFolder() ? appFoldersRoot : null); appFoldersTree.addItemClickListener(new FolderClickListener()); appFoldersTree.addActionHandler(new AppFolderActionsHandler()); for (Object itemId : appFoldersTree.rootItemIds()) { appFoldersTree.expandItemsRecursively(itemId); } return appFoldersTree; }
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.jav 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:org.opennms.features.vaadin.dashboard.dashlets.GraphSelectionWindow.java
License:Open Source License
/** * Constructor for creating new instances. * * @param nodeDao the node dao instance * @param rrdGraphHelper the rrd graph helper instance * @param rrdGraphEntry the entry to be edited *//*w ww.j a v a2 s . c o m*/ public GraphSelectionWindow(final NodeDao nodeDao, final RrdGraphHelper rrdGraphHelper, final RrdGraphEntry rrdGraphEntry) { /** * Setting the title */ super("Select RRD graph"); /** * setting up the component */ setModal(true); setClosable(false); setResizable(false); setWidth(50, Unit.PERCENTAGE); setHeight(70, Unit.PERCENTAGE); /** * setting up the container */ final HierarchicalContainer hierarchicalContainer = new HierarchicalContainer(); hierarchicalContainer.addContainerProperty("id", String.class, null); hierarchicalContainer.addContainerProperty("label", String.class, null); hierarchicalContainer.addContainerProperty("type", String.class, null); hierarchicalContainer.addContainerProperty("nodeId", String.class, null); hierarchicalContainer.addContainerProperty("nodeLabel", String.class, null); hierarchicalContainer.addContainerProperty("resourceId", String.class, null); hierarchicalContainer.addContainerProperty("resourceLabel", String.class, null); hierarchicalContainer.addContainerProperty("resourceTypeId", String.class, null); hierarchicalContainer.addContainerProperty("resourceTypeLabel", String.class, null); hierarchicalContainer.addContainerProperty("graphId", String.class, null); hierarchicalContainer.addContainerProperty("graphLabel", String.class, null); hierarchicalContainer.addContainerProperty("graphUrl", String.class, null); /** * filling the container with node data */ List<OnmsNode> onmsNodeList = nodeDao.findAll(); for (OnmsNode onmsNode : onmsNodeList) { Item item = hierarchicalContainer.addItem(onmsNode.getId().toString()); item.getItemProperty("label").setValue(onmsNode.getLabel() + " (" + onmsNode.getId() + ")"); item.getItemProperty("id").setValue(onmsNode.getId().toString()); item.getItemProperty("type").setValue("node"); item.getItemProperty("nodeId").setValue(onmsNode.getId().toString()); } /** * creating a panel for the tree component */ Panel panel = new Panel(); m_tree = new Tree(); m_tree.setCaption("Graph"); m_tree.setSizeFull(); m_tree.setItemCaptionMode(AbstractSelect.ItemCaptionMode.PROPERTY); m_tree.setItemCaptionPropertyId("label"); m_tree.setContainerDataSource(hierarchicalContainer); m_tree.setMultiSelect(false); m_tree.setNewItemsAllowed(false); m_tree.setImmediate(true); /** * adding en expand listener for lazy loading the resourceType and resource data */ m_tree.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent expandEvent) { String itemToExpandId = String.valueOf(expandEvent.getItemId()); /** * if the data has already been loaded, return */ if (m_tree.hasChildren(itemToExpandId)) { return; } Item itemToExpand = m_tree.getItem(expandEvent.getItemId()); String type = itemToExpand.getItemProperty("type").getValue().toString(); /** * a node is selected */ if ("node".equals(type)) { Map<OnmsResourceType, List<OnmsResource>> resourceTypeMap = rrdGraphHelper .getResourceTypeMapForNodeId( String.valueOf(itemToExpand.getItemProperty("id").getValue())); for (Map.Entry<OnmsResourceType, List<OnmsResource>> resourceTypeMapEntry : resourceTypeMap .entrySet()) { String newResourceTypeItemId = "node[" + itemToExpandId + "]." + resourceTypeMapEntry.getKey().getName(); Item newResourceTypeItem = hierarchicalContainer.addItem(newResourceTypeItemId); newResourceTypeItem.getItemProperty("label") .setValue(resourceTypeMapEntry.getKey().getLabel()); newResourceTypeItem.getItemProperty("type").setValue("resourceType"); newResourceTypeItem.getItemProperty("nodeId").setValue(itemToExpandId); newResourceTypeItem.getItemProperty("nodeLabel") .setValue(itemToExpand.getItemProperty("label").getValue()); newResourceTypeItem.getItemProperty("resourceTypeId").setValue(newResourceTypeItemId); newResourceTypeItem.getItemProperty("resourceTypeLabel") .setValue(resourceTypeMapEntry.getKey().getLabel()); m_tree.setParent(newResourceTypeItemId, itemToExpandId); m_tree.setChildrenAllowed(newResourceTypeItemId, true); for (OnmsResource onmsResource : resourceTypeMapEntry.getValue()) { String newResourceItemId = null; try { newResourceItemId = URLDecoder.decode(onmsResource.getId(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Item newResourceItem = hierarchicalContainer.addItem(newResourceItemId); newResourceItem.getItemProperty("label").setValue(onmsResource.getLabel()); newResourceItem.getItemProperty("type").setValue("resource"); newResourceItem.getItemProperty("nodeId").setValue(itemToExpandId); newResourceItem.getItemProperty("nodeLabel") .setValue(itemToExpand.getItemProperty("label").getValue()); newResourceItem.getItemProperty("resourceId").setValue(newResourceItemId); newResourceItem.getItemProperty("resourceLabel").setValue(onmsResource.getLabel()); newResourceItem.getItemProperty("resourceTypeId").setValue(newResourceTypeItemId); newResourceItem.getItemProperty("resourceTypeLabel") .setValue(newResourceTypeItem.getItemProperty("label").getValue()); m_tree.setParent(newResourceItemId, newResourceTypeItemId); m_tree.setChildrenAllowed(newResourceItemId, true); } } } /** * a resource is selected */ if ("resource".equals(type)) { Map<String, String> map = rrdGraphHelper.getGraphResultsForResourceId(itemToExpandId); Map<String, String> titleNameMapping = rrdGraphHelper .getGraphTitleNameMappingForResourceId(itemToExpandId); for (Map.Entry<String, String> entry : titleNameMapping.entrySet()) { String newGraphItemId = itemToExpandId + "." + entry.getKey(); /* if (hierarchicalContainer.containsId(newGraphItemId)) { continue; } */ Item newGraphItem = hierarchicalContainer.addItem(newGraphItemId); newGraphItem.getItemProperty("label").setValue(entry.getKey()); newGraphItem.getItemProperty("type").setValue("graph"); newGraphItem.getItemProperty("nodeId") .setValue(String.valueOf(itemToExpand.getItemProperty("nodeId").getValue())); newGraphItem.getItemProperty("nodeLabel") .setValue(String.valueOf(itemToExpand.getItemProperty("nodeLabel").getValue())); newGraphItem.getItemProperty("resourceId") .setValue(String.valueOf(itemToExpand.getItemProperty("resourceId").getValue())); newGraphItem.getItemProperty("resourceLabel") .setValue(String.valueOf(itemToExpand.getItemProperty("resourceLabel").getValue())); newGraphItem.getItemProperty("resourceTypeId").setValue( String.valueOf(itemToExpand.getItemProperty("resourceTypeId").getValue())); newGraphItem.getItemProperty("resourceTypeLabel").setValue( String.valueOf(itemToExpand.getItemProperty("resourceTypeLabel").getValue())); newGraphItem.getItemProperty("graphId").setValue(newGraphItemId); newGraphItem.getItemProperty("graphLabel").setValue(entry.getKey()); newGraphItem.getItemProperty("graphUrl").setValue(map.get(entry.getValue())); m_tree.setParent(newGraphItemId, itemToExpandId); m_tree.setChildrenAllowed(newGraphItemId, false); } } } }); /** * adding button to a horizontal layout */ HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(true); buttonLayout.setSpacing(true); buttonLayout.setWidth("100%"); final Button cancel = new Button("Cancel"); cancel.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { close(); } }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); buttonLayout.addComponent(cancel); buttonLayout.setExpandRatio(cancel, 1); buttonLayout.setComponentAlignment(cancel, Alignment.TOP_RIGHT); /** * ...and the OK button */ final Button ok = new Button("Select"); ok.setEnabled(false); ok.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (m_tree.getValue() != null) { /** * saving the data */ Item selectedItem = m_tree.getItem(m_tree.getValue()); rrdGraphEntry.setGraphId(String.valueOf(selectedItem.getItemProperty("graphId").getValue())); rrdGraphEntry.setResourceTypeId( String.valueOf(selectedItem.getItemProperty("resourceTypeId").getValue())); rrdGraphEntry .setResourceId(String.valueOf(selectedItem.getItemProperty("resourceId").getValue())); rrdGraphEntry.setNodeId(String.valueOf(selectedItem.getItemProperty("nodeId").getValue())); rrdGraphEntry .setGraphLabel(String.valueOf(selectedItem.getItemProperty("graphLabel").getValue())); rrdGraphEntry.setResourceTypeLabel( String.valueOf(selectedItem.getItemProperty("resourceTypeLabel").getValue())); rrdGraphEntry.setResourceLabel( String.valueOf(selectedItem.getItemProperty("resourceLabel").getValue())); rrdGraphEntry .setNodeLabel(String.valueOf(selectedItem.getItemProperty("nodeLabel").getValue())); rrdGraphEntry.setGraphUrl(String.valueOf(selectedItem.getItemProperty("graphUrl").getValue())); rrdGraphEntry.update(); } close(); } }); ok.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttonLayout.addComponent(ok); /** * if data is available expand the required nodes */ if (rrdGraphEntry.getNodeId() != null) { m_tree.expandItem(rrdGraphEntry.getNodeId()); if (rrdGraphEntry.getResourceTypeId() != null) { m_tree.expandItem(rrdGraphEntry.getResourceTypeId()); if (rrdGraphEntry.getResourceId() != null) { m_tree.expandItem(rrdGraphEntry.getResourceId()); /** * and select the specified entry */ if (rrdGraphEntry.getGraphId() != null) { m_tree.select(rrdGraphEntry.getGraphId()); } } } } /** * adding a value change listener that checks if leaf node is selected */ m_tree.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (valueChangeEvent.getProperty().getValue() != null) { Item selectedItem = m_tree.getItem(valueChangeEvent.getProperty().getValue()); Object object = selectedItem.getItemProperty("graphId").getValue(); ok.setEnabled(object != null); } } }); /** * creating the layout and setting the content */ panel.setContent(m_tree); panel.setCaption("Graph"); panel.setSizeFull(); VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setSizeFull(); verticalLayout.setMargin(true); verticalLayout.addComponent(panel); verticalLayout.setExpandRatio(panel, 1.0f); verticalLayout.addComponent(buttonLayout); setContent(verticalLayout); }