Example usage for com.vaadin.ui Tree focus

List of usage examples for com.vaadin.ui Tree focus

Introduction

In this page you can find the example usage for com.vaadin.ui Tree focus.

Prototype

@Override
    public void focus() 

Source Link

Usage

From source file:org.hip.vif.admin.groupadmin.ui.GroupContentView.java

License:Open Source License

/** View constructor
 * /* ww w . j  av a 2  s  . c  o  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$
}