Example usage for com.vaadin.ui HorizontalLayout addComponent

List of usage examples for com.vaadin.ui HorizontalLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout addComponent.

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java

License:Open Source License

@SuppressWarnings("serial")
@Override/*from  w  ww  .  j  ava2 s  .c  o  m*/
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    actionBtn = new MenuBar();
    actionBtn.addStyleName("menu-button-action");
    actionBtn.setVisible(false); //initially hidden
    MenuItem actions = actionBtn.addItem("", new ThemeResource("../icons/popup-menu.png"), null);

    final ViewAction refreshTodos = new ViewAction() {

        @Override
        public void invoke() {
            toggleSelectionMode(false);
            container.refresh();
        }
    };

    actions.addItem(ui.getMessage("action.lock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            lock();
        }
    });
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoAnnotation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(getSelectedTodoIds(), refreshTodos));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(getSelectedTodoIds(), refreshTodos));
        }
    });

    selectBtn = new Button(ui.getMessage("action.select"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(true);
        }
    });
    selectBtn.addStyleName("menu-button");

    cancelBtn = new Button(ui.getMessage("action.cancel"), new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            toggleSelectionMode(false);
        }
    });
    cancelBtn.setVisible(false); //initially hidden
    cancelBtn.addStyleName("menu-button");

    titleComponent.addStyleName("l-content-title");

    HorizontalLayout layout = new HorizontalLayout();
    HorizontalLayout btnLayout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.addComponent(btnLayout);
    layout.setSpacing(true);
    btnLayout.addComponent(actionBtn);
    btnLayout.addComponent(cancelBtn);
    btnLayout.addComponent(selectBtn);
    layout.setComponentAlignment(btnLayout, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:com.lst.deploymentautomation.vaadin.page.TodoView.java

License:Open Source License

@SuppressWarnings("serial")
@Override/*from ww w .j a v  a  2  s.  c o m*/
protected Component createHeader(Component titleComponent) {
    LspsUI ui = (LspsUI) getUI();

    MenuBar menu = new MenuBar();
    menu.addStyleName("menu-button-action");
    MenuItem actions = menu.addItem("", new ThemeResource("../icons/popup-menu.png"), null);

    final ViewAction closeView = new ViewAction() {

        @Override
        public void invoke() {
            close(); //maybe close only if the to-do is not allocated to the user anymore
        }
    };
    final ViewAction refreshAnnotations = new ViewAction() {

        @Override
        public void invoke() {
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            refreshAnnotations(todo);
        }
    };

    actions.addItem(ui.getMessage("action.info"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            //get fresh info
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            getUI().addWindow(new TodoDetails(todo));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.annotate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            //get fresh info
            Todo todo = todoService.getTodo(todoHolder.getTodo().getId());
            getUI().addWindow(new TodoAnnotation(todo, refreshAnnotations));
        }
    });
    actions.addSeparator();
    actions.addItem(ui.getMessage("action.unlock"), new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            unlock();
        }
    });
    actions.addItem(ui.getMessage("action.reject") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoRejection(todoHolder.getTodo().getId(), closeView));
        }
    });
    actions.addItem(ui.getMessage("action.delegate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoDelegation(todoHolder.getTodo().getId(), closeView));
        }
    });
    actions.addItem(ui.getMessage("action.escalate") + "...", new Command() {

        @Override
        public void menuSelected(MenuItem selectedItem) {
            getUI().addWindow(new TodoEscalation(todoHolder.getTodo().getId(), closeView));
        }
    });

    HorizontalLayout layout = new HorizontalLayout();
    layout.setWidth("100%");
    layout.addComponent(titleComponent);
    layout.setExpandRatio(titleComponent, 1);
    layout.addComponent(menu);
    layout.setComponentAlignment(menu, Alignment.MIDDLE_RIGHT);
    return layout;
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoAnnotation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/* ww w . jav  a2 s .c  o m*/
    setCaption(ui.getMessage("todo.annotationTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.annotationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    priorityField = new TextField(ui.getMessage("todo.priority"), priority);
    //TODO forbid negative priorities
    priorityField.setConverter(Integer.class);
    priorityField.setConversionError(ui.getMessage("app.invalidValueMessage"));
    priorityField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    layout.addComponent(priorityField);

    TextArea notesField = new TextArea(ui.getMessage("todo.notes"), notes);
    notesField.setMaxLength(1024);
    notesField.setNullRepresentation("");
    priorityField.setNullSettingAllowed(true);
    notesField.setSizeFull();
    layout.addComponent(notesField);
    layout.setExpandRatio(notesField, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button submitButton = new Button(ui.getMessage("action.annotate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            annotate();
        }
    });
    buttons.addComponent(submitButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDelegation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/*from   ww  w  .jav  a  2 s  .c  o  m*/
    setCaption(ui.getMessage("todo.delegationTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.delegationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    Collection<Person> allUsers = new ArrayList<Person>(
            personService.findPersons(new PersonCriteria()).getData());
    Set<Person> substitutes = ui.getUser().getPerson().getDirectSubstitutes();
    Set<String> substitutesIds = new HashSet<String>();
    for (Person p : substitutes) {
        substitutesIds.add(p.getId());
    }

    delegates = new OptionGroup(ui.getMessage("todo.delegates"));
    delegates.setMultiSelect(true);
    delegates.addStyleName("ui-spacing");
    delegates.setRequired(true);
    delegates.setSizeFull();
    for (Person p : allUsers) {
        delegates.addItem(p.getId());
        delegates.setItemCaption(p.getId(), p.getFullName());
    }
    delegates.setValue(substitutesIds);
    layout.addComponent(delegates);
    layout.setExpandRatio(delegates, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button delegateButton = new Button(ui.getMessage("action.delegate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            delegate();
        }
    });
    buttons.addComponent(delegateButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoEscalation.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();/*from w w w  .  j a v a 2 s.  co m*/
    setCaption(ui.getMessage("todo.escalationTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.escalationHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    reason = new TextArea(ui.getMessage("todo.escalationReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button submitButton = new Button(ui.getMessage("action.escalate"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            escalate();
        }
    });
    buttons.addComponent(submitButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoRejection.java

License:Open Source License

@Override
public void attach() {
    super.attach();

    LspsUI ui = (LspsUI) getUI();//  w  w w .  j av  a 2s .c o  m
    setCaption(ui.getMessage("todo.rejectionTitle"));

    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);
    layout.setSpacing(true);
    layout.setSizeFull();
    setContent(layout);

    Label help = new Label(ui.getMessage("todo.rejectionHelp"));
    help.setStyleName("form-help");
    layout.addComponent(help);

    reason = new TextArea(ui.getMessage("todo.rejectionReason"));
    reason.setMaxLength(1024);
    reason.setRequired(true);
    reason.setSizeFull();
    layout.addComponent(reason);
    layout.setExpandRatio(reason, 1);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    layout.addComponent(buttons);

    @SuppressWarnings("serial")
    Button rejectButton = new Button(ui.getMessage("action.reject"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            reject();
        }
    });
    buttons.addComponent(rejectButton);

    @SuppressWarnings("serial")
    Button cancelButton = new Button(ui.getMessage("action.cancel"), new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            close();
        }
    });
    buttons.addComponent(cancelButton);
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds library screen. This method overrides an existing
 * method.//from   w  w w  .j  ava 2 s.c om
 * 
 * @see com.m4gik.views.component.ViewScreen#build()
 */
@Override
public Layout build() {
    HorizontalLayout root = new HorizontalLayout();
    root.setSizeFull();
    root.setCaption("Media Library");
    root.setHeight("200%");
    root.setWidth("100%");

    this.content = new VerticalLayout();
    content.setSizeFull();
    root.addComponent(content);

    final GridLayout grid = new GridLayout(4, 1);
    Panel top = new Panel("Music Collection", grid);
    top.setSizeFull();
    top.addStyleName(Runo.PANEL_LIGHT);
    grid.setWidth("100%");
    grid.setMargin(true);
    grid.addStyleName(Runo.LAYOUT_DARKER);
    content.addComponent(top);
    content.setExpandRatio(top, 1);

    grid.addLayoutClickListener(new LayoutClickListener() {

        private static final long serialVersionUID = -1864555729437118182L;

        @Override
        public void layoutClick(LayoutClickEvent event) {
            for (Iterator<Component> it = grid.iterator(); it.hasNext();) {
                Component c = it.next();
                c.removeStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);

            }

            if (event.getChildComponent() != null) {
                event.getChildComponent().addStyleName(Runo.CSSLAYOUT_SELECTABLE_SELECTED);
            }
        }
    });

    buildAudioLibrary(grid, null);

    return root;

}

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method adds for spacer between texts.
 * /* w  ww .  j  a v a 2 s  . c o m*/
 * @param texts
 *            Texts to add.
 */
private void addSpacer(HorizontalLayout texts) {
    Label text = new Label("");
    text.setWidth("20px");
    texts.addComponent(text);
}

From source file:com.m4gik.views.component.LicenseScreen.java

/**
 * Method adds Text to the layout.//from ww  w  .j  a  v a 2 s . co m
 * 
 * @param texts
 *            The layout to add texts.
 * @param string
 *            The text to add to the layout.
 */
private void addText(HorizontalLayout texts, String string, String style) {
    addSpacer(texts);

    Label text = new Label(string, Label.CONTENT_XHTML);

    if (style != null) {
        text.setStyleName(style);
    }

    texts.addComponent(text);
    texts.setExpandRatio(text, 1);
}

From source file:com.mcparland.john.vaadin_mvn_arch.samples.crud.SampleCrudView.java

License:Apache License

public HorizontalLayout createTopBar() {
    TextField filter = new TextField();
    filter.setStyleName("filter-textfield");
    filter.setInputPrompt("Filter");
    ResetButtonForTextField.extend(filter);
    filter.setImmediate(true);/*  w  w  w .  ja  va 2  s .  co m*/
    filter.addTextChangeListener(new FieldEvents.TextChangeListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            table.setFilter(event.getText());
        }
    });

    newProduct = new Button("New product");
    newProduct.addStyleName(ValoTheme.BUTTON_PRIMARY);
    newProduct.setIcon(FontAwesome.PLUS_CIRCLE);
    newProduct.addClickListener(new ClickListener() {
        /**
         * The serialVersionUID.
         */
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            viewLogic.newProduct();
        }
    });

    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setWidth("100%");
    topLayout.addComponent(filter);
    topLayout.addComponent(newProduct);
    topLayout.setComponentAlignment(filter, Alignment.MIDDLE_LEFT);
    topLayout.setExpandRatio(filter, 1);
    topLayout.setStyleName("top-bar");
    return topLayout;
}