List of usage examples for com.vaadin.ui Tree addShortcutListener
public Registration addShortcutListener(ShortcutListener shortcut)
From source file:org.hip.vif.admin.groupadmin.ui.GroupContentView.java
License:Open Source License
/** View constructor * //from ww w . j a v a 2 s .com * @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$ }