Example usage for com.vaadin.ui VerticalLayout setMargin

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

Introduction

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

Prototype

@Override
    public void setMargin(boolean enabled) 

Source Link

Usage

From source file:com.mycollab.mobile.module.project.ui.TimeLogEditView.java

License:Open Source License

private void constructRemainTimeEntryPanel() {
    final VerticalLayout updateLayout = new VerticalLayout();
    updateLayout.setMargin(new MarginInfo(false, true, false, true));
    updateLayout.setWidth("100%");

    final Label lbTimeInstructTotal = new Label(
            UserUIContext.getMessage(TimeTrackingI18nEnum.OPT_REMAINING_WORK_HOURS));
    updateLayout.addComponent(lbTimeInstructTotal);
    remainTimeLbl = new ELabel("_").withStyleName("h2");
    updateLayout.addComponent(this.remainTimeLbl);

    headerPanel.addComponent(updateLayout);
}

From source file:com.mycollab.mobile.module.project.view.bug.BugFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.setWidth("100%");
    layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(BugI18nEnum.SINGLE)));

    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 14);
    layout.addComponent(informationLayout.getLayout());
    layout.setComponentAlignment(informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    layout.setExpandRatio(informationLayout.getLayout(), 1.0f);
    return layout;
}

From source file:com.mycollab.mobile.module.project.view.milestone.MilestoneFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setMargin(false);
    layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(MilestoneI18nEnum.SINGLE)));

    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 8);
    layout.addComponent(informationLayout.getLayout());
    return layout;
}

From source file:com.mycollab.mobile.module.project.view.task.TaskFormLayoutFactory.java

License:Open Source License

@Override
public ComponentContainer getLayout() {
    final VerticalLayout layout = new VerticalLayout();
    layout.setMargin(false);
    layout.addComponent(FormSectionBuilder.build(AppContext.getMessage(TaskI18nEnum.M_FORM_READ_TITLE)));

    informationLayout = GridFormLayoutHelper.defaultFormLayoutHelper(1, 9);
    layout.addComponent(informationLayout.getLayout());
    layout.setComponentAlignment(informationLayout.getLayout(), Alignment.BOTTOM_CENTER);
    return layout;
}

From source file:com.mycollab.mobile.ui.ConfirmDialog.java

License:Open Source License

private void constructUI(final String message, final String okCaption, final String cancelCaption) {
    VerticalLayout layout = new VerticalLayout();
    layout.setWidth("100%");
    layout.setHeightUndefined();/*from  ww w.j a v a2  s. c o  m*/
    layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);

    VerticalLayout messageWrapper = new VerticalLayout();
    messageWrapper.setStyleName("message-wrapper");
    messageWrapper.setWidth("100%");
    messageWrapper.setMargin(true);

    final Label messageDisplay = new Label(message);
    messageDisplay.setWidth("100%");
    messageWrapper.addComponent(messageDisplay);
    layout.addComponent(messageWrapper);

    HorizontalLayout controlBtn = new HorizontalLayout();
    controlBtn.setWidth("100%");

    final Button okBtn = new Button(okCaption);
    okBtn.setWidth("100%");
    okBtn.setHeight("35px");
    final Button cancelBtn = new Button(cancelCaption);
    cancelBtn.setWidth("100%");
    cancelBtn.setHeight("35px");

    ClickListener listener = (clickEvent) -> {
        ConfirmDialog.this.setConfirmed(clickEvent.getButton() == okBtn);
        if (ConfirmDialog.this.getListener() != null) {
            ConfirmDialog.this.getListener().onClose(ConfirmDialog.this);
        }
        close();
    };

    okBtn.addClickListener(listener);
    cancelBtn.addClickListener(listener);

    controlBtn.addComponent(cancelBtn);
    controlBtn.addComponent(okBtn);

    layout.addComponent(controlBtn);
    this.setContent(layout);
}

From source file:com.mycollab.module.project.view.bug.AssignBugWindow.java

License:Open Source License

AssignBugWindow(SimpleBug bug) {
    super(UserUIContext.getMessage(BugI18nEnum.OPT_ASSIGN_BUG, bug.getName()));
    this.bug = bug;

    VerticalLayout contentLayout = new VerticalLayout();
    EditForm editForm = new EditForm();
    contentLayout.addComponent(editForm);
    editForm.setBean(bug);/*from   www .jav  a 2  s  .  c o m*/
    contentLayout.setMargin(new MarginInfo(false, false, true, false));

    this.withWidth("750px").withResizable(false).withModal(true).withContent(contentLayout).withCenter();
}

From source file:com.mycollab.module.project.view.bug.ResolvedInputWindow.java

License:Open Source License

public ResolvedInputWindow(SimpleBug bugValue) {
    super(UserUIContext.getMessage(BugI18nEnum.OPT_RESOLVE_BUG, bugValue.getName()));
    ResolvedInputForm editForm = new ResolvedInputForm(bugValue) {
        @Override/*from   ww  w.  j  ava 2 s.c  o m*/
        protected void postExecution() {
            close();
        }
    };
    VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setMargin(new MarginInfo(false, false, true, false));
    contentLayout.addComponent(editForm);
    withWidth("900px").withModal(true).withResizable(false).withContent(contentLayout).withCenter();
}

From source file:com.mycollab.module.user.ui.components.ImagePreviewCropWindow.java

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super(UserUIContext.getMessage(ShellI18nEnum.OPT_PREVIEW_EDIT_IMAGE));
    MVerticalLayout content = new MVerticalLayout();
    withModal(true).withResizable(false).withWidth("700px").withCenter().withContent(content);

    try {/* www . j  a v  a  2 s . c o m*/
        originalImage = ImageIO.read(new ByteArrayInputStream(imageData));
    } catch (IOException e) {
        throw new UserInvalidInputException("Invalid image type");
    }
    originalImage = ImageUtil.scaleImage(originalImage, 650, 650);

    MHorizontalLayout previewBox = new MHorizontalLayout().withMargin(new MarginInfo(false, true, true, false))
            .withFullWidth();

    previewPhoto = new VerticalLayout();
    previewPhoto.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER);
    previewPhoto.setWidth("100px");

    previewBox.with(previewPhoto).withAlign(previewPhoto, Alignment.TOP_LEFT);

    VerticalLayout previewBoxTitle = new VerticalLayout();
    previewBoxTitle.setMargin(new MarginInfo(false, true, false, true));
    previewBoxTitle
            .addComponent(ELabel.html(UserUIContext.getMessage(ShellI18nEnum.OPT_IMAGE_EDIT_INSTRUCTION)));

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton acceptBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_ACCEPT), clickEvent -> {
        if (scaleImageData != null && scaleImageData.length > 0) {
            try {
                BufferedImage image = ImageIO.read(new ByteArrayInputStream(scaleImageData));
                imageSelectionCommand.process(image);
                close();
            } catch (IOException e) {
                throw new MyCollabException("Error when saving user avatar", e);
            }
        }
    }).withIcon(FontAwesome.CHECK).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlBtns = new MHorizontalLayout(acceptBtn, cancelBtn);

    previewBoxTitle.addComponent(controlBtns);
    previewBoxTitle.setComponentAlignment(controlBtns, Alignment.TOP_LEFT);
    previewBox.with(previewBoxTitle).expand(previewBoxTitle);

    CssLayout cropBox = new CssLayout();
    cropBox.setWidth("100%");
    VerticalLayout currentPhotoBox = new VerticalLayout();
    Resource resource = new ByteArrayImageResource(ImageUtil.convertImageToByteArray(originalImage),
            "image/png");
    CropField cropField = new CropField(resource);
    cropField.setImmediate(true);
    cropField.setSelectionAspectRatio(1.0f);
    cropField.addValueChangeListener(valueChangeEvent -> {
        VCropSelection newSelection = (VCropSelection) valueChangeEvent.getProperty().getValue();
        int x1 = newSelection.getXTopLeft();
        int y1 = newSelection.getYTopLeft();
        int x2 = newSelection.getXBottomRight();
        int y2 = newSelection.getYBottomRight();
        if (x2 > x1 && y2 > y1) {
            BufferedImage subImage = originalImage.getSubimage(x1, y1, (x2 - x1), (y2 - y1));
            ByteArrayOutputStream outStream = new ByteArrayOutputStream();
            try {
                ImageIO.write(subImage, "png", outStream);
                scaleImageData = outStream.toByteArray();
                displayPreviewImage();
            } catch (IOException e) {
                LOG.error("Error while scale image: ", e);
            }
        }
    });
    currentPhotoBox.setWidth("520px");
    currentPhotoBox.setHeight("470px");
    currentPhotoBox.addComponent(cropField);
    cropBox.addComponent(currentPhotoBox);

    content.with(previewBox, ELabel.hr(), cropBox);
    displayPreviewImage();
}

From source file:com.mycompany.filmupo.Graficos.java

/**
 * Metodo de inicializacion de la clase//from  w w w .  ja va 2 s.  co m
 *
 * @param vaadinRequest VaadinRequest
 */
@Override
protected void init(VaadinRequest vaadinRequest) {
    try {

        HorizontalLayout v2h2 = new HorizontalLayout();
        v2h2.setMargin(true);

        final VerticalLayout v2h1 = new VerticalLayout();
        v2h1.setMargin(true);

        final VerticalSplitPanel v2 = new VerticalSplitPanel();
        v2.addComponent(v2h2);
        v2.addComponent(v2h1);
        v2.setSplitPosition(22, Unit.PERCENTAGE);
        v2.setLocked(true);

        VerticalLayout v1 = new VerticalLayout();
        v1.setMargin(true);

        HorizontalSplitPanel layout = new HorizontalSplitPanel();
        layout.addComponent(v1);
        layout.addComponent(v2);
        layout.setSplitPosition(28, Unit.PERCENTAGE);

        setContent(layout);

        //Creamos los 3 links de navegacion de la aplicacion y loa aadimos al layout declarado al principio del codigo
        Link pri = new Link("Principal", new ExternalResource("/Principal"));
        Link est = new Link("Graficos", new ExternalResource("/Graficos"));
        Link adm = new Link("Administracin", new ExternalResource("/Admin"));
        v2h2.addComponent(pri);
        v2h2.addComponent(new Label(" / "));
        v2h2.addComponent(est);
        v2h2.addComponent(new Label(" / "));
        v2h2.addComponent(adm);

        final DAO dao = new DAO();
        dao.abrirConexion();

        final List<Pelicula> listaPeliculas = dao.consultarPeliculas();
        final List<Director> listaDirectores = dao.consultarDirectores();
        final List<Actor> listaActores = dao.consultarActores();

        //Creamos un unico arbol que contiene el acceso a las 4 graficas que hemos creado:
        //  - Peliculas segun su duracion
        //  - Peliculas segun su genero
        //  - Numero de peliculas segun actor
        //  - Numero de peliculas segun director
        Tree tree = new Tree("");
        String a = "Estadisticas";
        tree.addItem(a);
        String aa = "Peliculas segn su duracin";
        tree.addItem(aa);
        tree.setParent(aa, a);
        tree.setChildrenAllowed(aa, false);
        String ab = "Peliculas segn su gnero";
        tree.addItem(ab);
        tree.setParent(ab, a);
        tree.setChildrenAllowed(ab, false);
        String ac = "Numero de peliculas segn actor";
        tree.addItem(ac);
        tree.setParent(ac, a);
        tree.setChildrenAllowed(ac, false);
        String ad = "Numero de peliculas segn director";
        tree.addItem(ad);
        tree.setParent(ad, a);
        tree.setChildrenAllowed(ad, false);

        tree.setSelectable(true);
        tree.addValueChangeListener(new Property.ValueChangeListener() {
            @Override
            public void valueChange(Property.ValueChangeEvent event) {
                v2h1.removeAllComponents();
                //Grafica de las peliculas segun su duracion
                if (event.getProperty().getValue().toString().contains("duracin")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Peliculas");
                    conf.setSubTitle("Segn su duracin en minutos");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Pelicula p : listaPeliculas) {
                        series.add(new DataSeriesItem(p.getTitulo(), p.getDuracion()));
                    }
                    conf.addSeries(series);
                    v2h1.addComponent(chart);
                    //Grafica de las peliculas segun su genero
                } else if (event.getProperty().getValue().toString().contains("gnero")) {
                    Chart chart = new Chart(ChartType.COLUMN);
                    chart.setWidth("400px");
                    chart.setHeight("300px");
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Peliculas");
                    conf.setSubTitle("Agrupadas segn su gnero");

                    PlotOptionsLine plotOptions = new PlotOptionsLine();
                    plotOptions.setMarker(new Marker(false));
                    conf.setPlotOptions(plotOptions);

                    ListSeries series = new ListSeries("Numero de peliculas");
                    int i1 = 0, i2 = 0, i3 = 0, i4 = 0, i5 = 0;
                    try {
                        dao.abrirConexion();
                        i1 = dao.numGeneros("Accin");
                        i2 = dao.numGeneros("Ciencia Ficcin");
                        i3 = dao.numGeneros("Drama");
                        i4 = dao.numGeneros("Romance");
                        i5 = dao.numGeneros("Novela de Suspense");
                    } catch (IllegalAccessException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (SQLException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    } catch (InstantiationException ex) {
                        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                    }
                    series.addData(i1);
                    series.addData(i2);
                    series.addData(i3);
                    series.addData(i4);
                    series.addData(i5);

                    conf.addSeries(series);

                    XAxis xaxis = new XAxis();
                    xaxis.setTitle("Gnero");
                    xaxis.setCategories("Accin", "Ciencia Ficcin", "Drama", "Romance",
                            "Novela de suspense");
                    conf.addxAxis(xaxis);

                    YAxis yayis = new YAxis();
                    yayis.setTitle("Nmero de peliculas");
                    conf.addyAxis(yayis);

                    v2h1.addComponent(chart);

                    //Grafica de las peliculas segun actor
                } else if (event.getProperty().getValue().toString().contains("actor")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Actores");
                    conf.setSubTitle("Nmero de peliculas que tienen");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Actor a : listaActores) {
                        int i = 0;
                        try {
                            dao.abrirConexion();
                            i = dao.numPeliculasA(a.getIdActor());
                        } catch (InstantiationException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        series.add(new DataSeriesItem(a.getNombreCompleto(), i));
                    }
                    conf.addSeries(series);

                    v2h1.addComponent(chart);

                    //Grafica del numero de peliculas segun director
                } else if (event.getProperty().getValue().toString().contains("director")) {
                    Chart chart = new Chart(ChartType.PIE);
                    Configuration conf = chart.getConfiguration();
                    conf.setTitle("Directores");
                    conf.setSubTitle("Nmero de peliculas que tienen");

                    PlotOptionsPie options = new PlotOptionsPie();
                    options.setInnerSize(0);
                    options.setSize("75%");
                    options.setCenter("50%", "50%");
                    conf.setPlotOptions(options);

                    DataSeries series = new DataSeries();
                    for (Director d : listaDirectores) {
                        int i = 0;
                        try {
                            dao.abrirConexion();
                            i = dao.numPeliculasD(d.getIdDirector());
                        } catch (InstantiationException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (IllegalAccessException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        } catch (SQLException ex) {
                            Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
                        }
                        series.add(new DataSeriesItem(d.getNombreCompleto(), i));
                    }
                    conf.addSeries(series);

                    v2h1.addComponent(chart);
                }
            }
        });

        v1.addComponent(tree);

        dao.cerrarConexion();
    } catch (SQLException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    } catch (InstantiationException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    } catch (IllegalAccessException ex) {
        Logger.getLogger(Graficos.class.getName()).log(Level.SEVERE, null, ex);
    }
}

From source file:com.mycompany.project.components.ContactDetails.java

public ContactDetails() {
    //        setCaption("Contact Details");

    VerticalLayout mainVLayout = new VerticalLayout();
    mainVLayout.setMargin(true);
    mainVLayout.setSpacing(true);//from  ww  w  .  j  a v  a  2 s. c  om

    setContent(mainVLayout);

    tfName.setSizeFull();
    tfAddress.setSizeFull();
    tfPhone.setSizeFull();
    tfEmail.setSizeFull();

    Panel panel = new Panel("Grupos");
    panel.setWidth("100%");
    panel.setHeight("50px");
    panel.setContent(groupsHLayout);

    mainVLayout.addComponent(tfName);
    mainVLayout.addComponent(tfAddress);
    mainVLayout.addComponent(tfPhone);
    mainVLayout.addComponent(tfEmail);
    mainVLayout.addComponent(groupsHLayout);

    Button btnUpdate = new Button("Actualizar");
    mainVLayout.addComponent(btnUpdate);

    btnUpdate.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            //invoke business logic
            BusinessLogic bl = ((MyVaadinUI) getUI()).getBusinessLogic();

            String name = tfName.getValue();
            String address = tfAddress.getValue();
            String phone = tfPhone.getValue();
            String email = tfEmail.getValue();

            ArrayList<String> selectedGroupIds = new ArrayList<String>();
            Set<String> groupIdSet = groupsMap.keySet();
            for (String groupId : groupIdSet) {
                CheckBox cb = groupsMap.get(groupId);
                if (cb.getValue()) {
                    selectedGroupIds.add(groupId);
                }
            }

            boolean success = bl.updateContact(selectedContactId, name, address, phone, email,
                    selectedGroupIds);
            if (success) {
                load(selectedContactId);
                Notification.show("Informacion", "Contacto Actualizado", Notification.Type.TRAY_NOTIFICATION);
            } else {
                Notification.show("Error", "\nSomething bad happened", Notification.Type.ERROR_MESSAGE);
            }
        }
    });

    ContactDetails.this.setVisible(false);
}