Example usage for com.vaadin.ui VerticalLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:com.jorambarrez.PropertyPanel.java

License:Apache License

protected void initTrashIcon() {
    Embedded trashIcon = new Embedded(null, Images.MODELER_TRASH);
    trashIcon.setWidth(63, UNITS_PIXELS);
    trashIcon.setHeight(61, UNITS_PIXELS);
    trashIcon.setType(Embedded.TYPE_IMAGE);

    VerticalLayout trashLayout = new VerticalLayout();
    trashLayout.setWidth(120, UNITS_PIXELS);
    trashLayout.setHeight(120, UNITS_PIXELS);
    trashLayout.addComponent(trashIcon);
    trashLayout.setComponentAlignment(trashIcon, Alignment.MIDDLE_CENTER);

    DragAndDropWrapper dragAndDropWrapper = new DragAndDropWrapper(trashLayout);
    dragAndDropWrapper.setDragStartMode(DragStartMode.NONE);
    dragAndDropWrapper.setSizeUndefined();
    addComponent(dragAndDropWrapper);/*from   ww w.  j ava2 s.  c om*/
    setComponentAlignment(dragAndDropWrapper, Alignment.BOTTOM_CENTER);

    dragAndDropWrapper.setDropHandler(new DropHandler() {
        private static final long serialVersionUID = 1L;

        public AcceptCriterion getAcceptCriterion() {
            return AcceptAll.get();
        }

        public void drop(DragAndDropEvent event) {
            WrapperTransferable wrapperTransferable = (WrapperTransferable) event.getTransferable();
            Node srcNode = (Node) wrapperTransferable.getSourceComponent();

            // TODO: use eventrouter!
            ModelerApp.get().getFlowEditor().removeNode(srcNode);
        }
    });
}

From source file:com.karus.EnglishCheckerUI.java

License:Apache License

@Override
protected void init(VaadinRequest request) {

    VaadinServiceSession.getCurrent().setErrorHandler(this);
    setSizeFull();//  w w  w. j  ava  2  s . c om

    try {
        DiscoveryNavigator navigator = new DiscoveryNavigator(this, getContent());
        navigator.navigateTo(UI.getCurrent().getPage().getFragment());
    }
    /**
     * Exception on page load
     */
    catch (AccessDeniedException e) {
        Label label = new Label(e.getMessage());
        label.setWidth(-1, Unit.PERCENTAGE);

        Link goToMain = new Link("Go to login page", new ExternalResource("/login/"));

        VerticalLayout layout = new VerticalLayout();
        layout.addComponent(label);
        layout.addComponent(goToMain);
        layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);
        layout.setComponentAlignment(goToMain, Alignment.MIDDLE_CENTER);

        VerticalLayout mainLayout = new VerticalLayout();
        mainLayout.setSizeFull();
        mainLayout.addComponent(layout);
        mainLayout.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);

        setContent(mainLayout);
        Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE);
    }
}

From source file:com.klwork.explorer.project.MyCalendarView.java

License:Apache License

private void createCalendarEventPopup() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*from  ww w  . j  a v  a 2s  .  c  om*/
    layout.setSpacing(true);

    scheduleEventPopup = new Window(null, layout);
    scheduleEventPopup.setWidth("400px");
    scheduleEventPopup.setModal(true);
    scheduleEventPopup.center();

    layout.addComponent(scheduleEventFieldLayout);

    applyEventButton = new Button("?", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                commitCalendarEvent();
            } catch (CommitException e) {
                e.printStackTrace();
            }
        }
    });
    Button cancel = new Button("?", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            discardCalendarEvent();
        }
    });
    deleteEventButton = new Button("", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            deleteCalendarEvent();
        }
    });
    scheduleEventPopup.addCloseListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(Window.CloseEvent e) {
            discardCalendarEvent();
        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(applyEventButton);
    buttons.addComponent(cancel);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
}

From source file:com.klwork.explorer.ui.base.AbstractMainGridPage.java

License:Apache License

protected void addSelectComponent() {
    VerticalLayout vLayout = new VerticalLayout();
    vLayout.addStyleName("sidebar");
    vLayout.addStyleName("menu");
    vLayout.addStyleName("tasks");
    vLayout.setMargin(new MarginInfo(true, false, false, false));
    vLayout.setSizeFull();//  ww  w  .j  ava2 s  .  c  o m

    HorizontalLayout tableHeadLayout = createSelectHead();
    vLayout.addComponent(tableHeadLayout);
    vLayout.setComponentAlignment(tableHeadLayout, Alignment.MIDDLE_LEFT);

    AbstractSelect select = createSelectComponent();
    vLayout.addComponent(select);
    vLayout.setExpandRatio(select, 1.0f);
    if (select != null) {
        grid.addComponent(vLayout, 1, 0);
    }
}

From source file:com.klwork.explorer.ui.base.AbstractSecondMainPage.java

License:Apache License

protected void addSelectComponent() {
    VerticalLayout secondMenuLayout = new VerticalLayout();
    secondMenuLayout.addStyleName("sidebar");
    secondMenuLayout.addStyleName("menu");
    //secondMenuLayout.setMargin(new MarginInfo(true,false,false,false));
    secondMenuLayout.setSpacing(true);/*  w w w.  j av a2  s .c  o m*/
    secondMenuLayout.setSizeFull();

    HorizontalLayout tableHeadLayout = new HorizontalLayout();
    tableHeadLayout.setStyleName("tableHead");
    tableHeadLayout.setHeight("20px");
    Label nameLabel = new Label("hello,word");
    tableHeadLayout.addComponent(nameLabel);
    tableHeadLayout.setComponentAlignment(nameLabel, Alignment.BOTTOM_CENTER);

    secondMenuLayout.addComponent(tableHeadLayout);
    //secondMenuLayout.setExpandRatio(tableHeadLayout, 0.1f);
    //table
    AbstractSelect select = createSelectComponent();
    secondMenuLayout.addComponent(select);
    secondMenuLayout.setExpandRatio(select, 1.0f);
    if (select != null) {
        grid.addComponent(secondMenuLayout, 0, 0);
    }
}

From source file:com.klwork.explorer.ui.business.project.MyCalendarView.java

License:Apache License

private void createCalendarEventPopup() {
    VerticalLayout layout = new VerticalLayout();
    layout.setMargin(true);/*  w  w w  .j  av a2 s .c  o  m*/
    layout.setSpacing(true);
    layout.addStyleName("social");

    scheduleEventPopup = new Window(null, layout);
    scheduleEventPopup.setWidth("400px");
    scheduleEventPopup.setModal(true);
    scheduleEventPopup.center();

    layout.addComponent(scheduleEventFieldLayout);

    applyEventButton = new Button("?", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                commitCalendarEvent();
            } catch (CommitException e) {
                e.printStackTrace();
            }
        }
    });
    Button cancel = new Button("?", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            discardCalendarEvent();
        }
    });
    deleteEventButton = new Button("", new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            deleteCalendarEvent();
        }
    });
    scheduleEventPopup.addCloseListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void windowClose(Window.CloseEvent e) {
            discardCalendarEvent();
        }
    });

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(deleteEventButton);
    buttons.addComponent(applyEventButton);
    buttons.addComponent(cancel);
    layout.addComponent(buttons);
    layout.setComponentAlignment(buttons, Alignment.BOTTOM_RIGHT);
}

From source file:com.klwork.explorer.ui.content.file.ImageAttachmentRenderer.java

License:Apache License

@Override
public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();/*from w  w  w  .j  a va2 s.  co  m*/
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);

    // Image
    TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();

    String mimeType = extractMineType(attachment.getType());

    InputStream imageStream = ImageUtil.resizeImage(taskService.getAttachmentContent(attachment.getId()),
            mimeType, 900, 550);
    Resource resource = new StreamResource(new InputStreamStreamSource(imageStream),
            attachment.getName() + extractExtention(attachment.getType()));
    Embedded image = new Embedded(null, resource);
    verticalLayout.addComponent(image);

    // Linke
    HorizontalLayout LinkLayout = new HorizontalLayout();
    LinkLayout.setSpacing(true);
    verticalLayout.addComponent(LinkLayout);
    verticalLayout.setComponentAlignment(LinkLayout, Alignment.MIDDLE_CENTER);

    Label fullSizeLabel = new Label(
            ViewToolManager.getI18nManager().getMessage(Messages.RELATED_CONTENT_SHOW_FULL_SIZE));
    LinkLayout.addComponent(fullSizeLabel);

    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(
                new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
                attachment.getName() + extractExtention(attachment.getType()));

        link = new Link(attachment.getName(), res);
    }

    link.setIcon(Images.RELATED_CONTENT_PICTURE);
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    LinkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.klwork.explorer.ui.content.GenericAttachmentRenderer.java

License:Apache License

public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeUndefined();/*from   w  ww .  java2 s  . co m*/
    verticalLayout.setSpacing(true);
    verticalLayout.setMargin(true);

    Label description = new Label(attachment.getDescription());
    description.setSizeUndefined();
    verticalLayout.addComponent(description);

    HorizontalLayout linkLayout = new HorizontalLayout();
    linkLayout.setSpacing(true);
    verticalLayout.addComponent(linkLayout);

    // Image
    linkLayout.addComponent(new Embedded(null, getImage(attachment)));

    // Link
    Link link = null;
    if (attachment.getUrl() != null) {
        link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    } else {
        TaskService taskService = ProcessEngines.getDefaultProcessEngine().getTaskService();
        Resource res = new StreamResource(
                new InputStreamStreamSource(taskService.getAttachmentContent(attachment.getId())),
                attachment.getName() + extractExtention(attachment.getType()));

        link = new Link(attachment.getName(), res);
    }

    // Set generic image and external window 
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    linkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.klwork.explorer.ui.content.url.UrlAttachmentRenderer.java

License:Apache License

public Component getDetailComponent(Attachment attachment) {
    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSpacing(true);/*from   w  ww.jav  a  2s .  c  om*/
    verticalLayout.setMargin(true);

    verticalLayout.addComponent(new Label(attachment.getDescription()));

    HorizontalLayout linkLayout = new HorizontalLayout();
    linkLayout.setSpacing(true);
    verticalLayout.addComponent(linkLayout);

    // Icon
    linkLayout.addComponent(new Embedded(null, Images.RELATED_CONTENT_URL));

    // Link
    Link link = new Link(attachment.getUrl(), new ExternalResource(attachment.getUrl()));
    link.setTargetName(ExplorerLayout.LINK_TARGET_BLANK);
    linkLayout.addComponent(link);

    return verticalLayout;
}

From source file:com.klwork.explorer.ui.main.views.AuthenticatedView.java

License:Apache License

@PostConstruct
public void PostConstruct() {
    setSizeFull();// w w  w  .j  a va 2 s.com
    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);

    layout.addComponent(new Label("@RequiresAuthentication"));
    layout.addComponent(new Link("Go back", new ExternalResource("#!" + MainView.NAME)));

    setContent(layout);
}