Example usage for com.vaadin.ui GridLayout setComponentAlignment

List of usage examples for com.vaadin.ui GridLayout setComponentAlignment

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout setComponentAlignment.

Prototype

@Override
    public void setComponentAlignment(Component childComponent, Alignment alignment) 

Source Link

Usage

From source file:annis.gui.controlpanel.CorpusListPanel.java

License:Apache License

public void initCorpusBrowser(String topLevelCorpusName, final Button l) {

    AnnisCorpus c = ui.getQueryState().getAvailableCorpora().getItem(topLevelCorpusName).getBean();
    MetaDataPanel meta = new MetaDataPanel(c.getName());

    CorpusBrowserPanel browse = new CorpusBrowserPanel(c, ui.getQueryController());
    GridLayout infoLayout = new GridLayout(2, 2);
    infoLayout.setSizeFull();//from  w  w  w  . j av a2s  .c  o m

    String corpusURL = Helper.generateCorpusLink(Sets.newHashSet(topLevelCorpusName));
    Label lblLink = new Label("Link to corpus: <a href=\"" + corpusURL + "\">" + corpusURL + "</a>",
            ContentMode.HTML);
    lblLink.setHeight("-1px");
    lblLink.setWidth("-1px");

    infoLayout.addComponent(meta, 0, 0);
    infoLayout.addComponent(browse, 1, 0);
    infoLayout.addComponent(lblLink, 0, 1, 1, 1);

    infoLayout.setRowExpandRatio(0, 1.0f);
    infoLayout.setColumnExpandRatio(0, 0.5f);
    infoLayout.setColumnExpandRatio(1, 0.5f);
    infoLayout.setComponentAlignment(lblLink, Alignment.MIDDLE_CENTER);

    Window window = new Window("Corpus information for " + c.getName() + " (ID: " + c.getId() + ")",
            infoLayout);
    window.setWidth(70, UNITS_EM);
    window.setHeight(45, UNITS_EM);
    window.setResizable(true);
    window.setModal(false);
    window.setResizeLazy(true);

    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            l.setEnabled(true);
        }
    });

    UI.getCurrent().addWindow(window);
    window.center();
}

From source file:ch.bfh.ti.soed.hs16.srs.black.view.reservationView.ReservationView.java

License:Open Source License

public ReservationView() {
    reservationMakeView = new ReservationMakeView();
    reservationTableView = new ReservationTableView();

    VerticalLayout makeViewLayoutVL = reservationMakeView.getMakeViewLayout();
    VerticalLayout listReservationsVL = reservationTableView.getListReservations();

    GridLayout grid = new GridLayout(2, 1);
    grid.addComponent(makeViewLayoutVL, 0, 0);
    grid.addComponent(listReservationsVL, 1, 0);
    grid.setComponentAlignment(makeViewLayoutVL, Alignment.TOP_CENTER);
    grid.setComponentAlignment(listReservationsVL, Alignment.TOP_CENTER);
    grid.setSizeUndefined();// w  w w.j  a  va2 s  .  co m

    setSizeFull();
    addComponent(grid);
    setComponentAlignment(grid, Alignment.TOP_CENTER);
}

From source file:com.bellkenz.modules.PersonalInformation.java

public ComponentContainer personalInformation() {
    employeeInformationDAO = new EmployeeInformationDAO(getEmployeeId());
    employeePersonalInformation = new EmployeePersonalInformation();

    GridLayout glayout = new GridLayout(5, 9);
    glayout.setSpacing(true);/*from  w  ww .ja v a  2 s . c o m*/
    glayout.setMargin(true);

    final Panel imagePanel = new Panel();
    imagePanel.setStyleName("light");
    AbstractLayout panelLayout = (AbstractLayout) imagePanel.getContent();
    panelLayout.setMargin(false);
    imagePanel.setSizeFull();

    employeeImage = new Embedded(null, new ThemeResource("../myTheme/images/ronnie.jpg"));
    employeeImage.setImmediate(true);
    employeeImage.setWidth(90, Sizeable.UNITS_PIXELS);
    employeeImage.setHeight(90, Sizeable.UNITS_PIXELS);
    employeeImage.setStyleName("logo-img");
    imagePanel.addComponent(employeeImage);
    glayout.addComponent(employeeImage, 0, 0, 0, 1);
    glayout.setComponentAlignment(imagePanel, Alignment.MIDDLE_CENTER);

    firstname = createTextField("Firstname: ");
    glayout.addComponent(firstname, 1, 0, 2, 0);

    final TextField middlename = createTextField("Middlename: ");
    glayout.addComponent(middlename, 3, 0);

    final TextField lastname = createTextField("Lastname: ");
    glayout.addComponent(lastname, 4, 0);

    final TextField houseNo = createTextField("No: ");
    houseNo.setWidth("40px");
    glayout.addComponent(houseNo, 1, 1);

    final TextField street = createTextField("Street: ");
    street.setWidth("118");
    glayout.addComponent(street, 2, 1);

    final TextField city = createTextField("City: ");
    glayout.addComponent(city, 3, 1);

    final TextField zipCode = createTextField("Zip Code:");
    glayout.addComponent(zipCode, 4, 1);

    final TextField nickname = createTextField("Nickname: ");
    nickname.setWidth("90px");
    glayout.addComponent(nickname, 0, 2);

    final TextField permanentAddress = createTextField("Permanent/Provincial Address: ");
    permanentAddress.setWidth("533px");
    glayout.addComponent(permanentAddress, 1, 2, 4, 2);

    Button uploadPicture = new Button("Upload...");
    uploadPicture.setWidth("100%");
    uploadPicture.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (employeeId == null) {
                getWindow().showNotification("You did not select and Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window uploadImage = new UploadImage(imagePanel, employeeImage, employeeId);
            uploadImage.setWidth("450px");
            if (uploadImage.getParent() == null) {
                getWindow().addWindow(uploadImage);
            }
            uploadImage.setModal(true);
            uploadImage.center();
        }
    });
    glayout.addComponent(uploadPicture, 0, 3);

    final TextField landline = createTextField("Landline #: ");
    glayout.addComponent(landline, 1, 3, 2, 3);

    final TextField mobileNo = createTextField("Mobile #: ");
    glayout.addComponent(mobileNo, 3, 3);

    final TextField age = createTextField("Age: ");
    glayout.addComponent(age, 4, 3);

    final TextField emailAddress = createTextField("Email Address: ");
    glayout.addComponent(emailAddress, 1, 4, 2, 4);

    final PopupDateField dob = (PopupDateField) createDateField("Date of Birth: ");
    glayout.addComponent(dob, 3, 4);

    final TextField height = createTextField("Height: ");
    glayout.addComponent(height, 4, 4);

    final ComboBox civilStatus = new ComboBox("Civil Status: ");
    civilStatus.setWidth("100%");
    dropDownBoxList.populateCivilStatusList(civilStatus);
    glayout.addComponent(civilStatus, 1, 5, 2, 5);

    final ComboBox gender = new ComboBox("Gender: ");
    gender.setWidth("100%");
    dropDownBoxList.populateGenderList(gender);
    glayout.addComponent(gender, 3, 5);

    final TextField weight = createTextField("Weigth: ");
    glayout.addComponent(weight, 4, 5);

    final TextField driversLicenseNo = createTextField("Drivers License: ");
    glayout.addComponent(driversLicenseNo, 1, 6, 2, 6);

    final TextField restrictionCode = createTextField("Restriction Code: ");
    glayout.addComponent(restrictionCode, 3, 6);

    final TextField religion = createTextField("Religion: ");
    glayout.addComponent(religion, 4, 6);

    final ComboBox division = new ComboBox("Division: ");
    division.setWidth("100%");
    dropDownBoxList.populateBranchComboBox(division);
    glayout.addComponent(division, 1, 7, 2, 7);

    final ComboBox department = dropDownBoxList.populateDepartment(new ComboBox());
    department.setWidth("100%");
    division.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            if (division.getValue() == null) {
            } else {
                divisionId = branchDAO.getBranchId(division.getValue().toString());
            }
        }

    });
    glayout.addComponent(department, 3, 7);

    final TextField position = createTextField("Position: ");
    glayout.addComponent(position, 4, 7);
    //glayout.setComponentAlignment(position, Alignment.BOTTOM_LEFT);

    Button transferButton = new Button("Transfer Employee");
    transferButton.setWidth("100%");
    transferButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (getEmployeeId() == null) {
                getWindow().showNotification("You did not select an Employee!",
                        Window.Notification.TYPE_WARNING_MESSAGE);
                return;
            }

            Window subWindow = transferEmployee(getEmployeeId(), division, department, position);
            if (subWindow.getParent() == null) {
                getWindow().addWindow(subWindow);
            }
            subWindow.setModal(true);
            subWindow.center();
        }
    });
    glayout.addComponent(transferButton, 1, 8, 2, 8);
    glayout.setComponentAlignment(transferButton, Alignment.BOTTOM_CENTER);

    if (employeeId != null) {
        epiList = employeeInformationDAO.employeePersonalInformation();
        for (EmployeePersonalInformation epi : epiList) {
            final byte[] image = epi.getImage();
            if (image != null) {
                StreamResource.StreamSource imageSource = new StreamResource.StreamSource() {

                    @Override
                    public InputStream getStream() {
                        return new ByteArrayInputStream(image);
                    }

                };

                StreamResource imageResource = new StreamResource(imageSource, epi.getFirstname() + ".jpg",
                        getApplication());
                imageResource.setCacheTime(0);
                employeeImage.setSource(imageResource);
            }
            firstname.setValue(epi.getFirstname());
            middlename.setValue(epi.getMiddlename());
            lastname.setValue(epi.getLastname());
            houseNo.setValue(epi.getHouseNumber());

            street.setValue(epi.getStreet());
            city.setValue(epi.getStreet());
            zipCode.setValue(epi.getZipCode());
            nickname.setValue(epi.getNickname());
            permanentAddress.setValue(epi.getPermanentAddress());
            landline.setValue(epi.getLandlineNumber());
            mobileNo.setValue(epi.getMobileNumber());
            age.setValue(epi.getAge());
            emailAddress.setValue(epi.getEmailAddress());

            if (epi.getDob() != null) {
                dob.setValue(conUtil.parsingDate(epi.getDob()));
            } else {
                dob.setValue(null);
            }

            height.setValue(epi.getHeight());

            if (epi.getCivilStatus() != null) {
                Object civilStatusId = civilStatus.addItem();
                civilStatus.setItemCaption(civilStatusId, epi.getCivilStatus());
                civilStatus.setValue(civilStatusId);
            }

            if (epi.getGender() != null) {
                Object genderId = gender.addItem();
                gender.setItemCaption(genderId, epi.getGender());
                gender.setValue(genderId);
            }

            weight.setValue(epi.getWeight());
            driversLicenseNo.setValue(epi.getDriversLicense());
            restrictionCode.setValue(epi.getRestrictionCode());
            religion.setValue(epi.getReligion());
            position.setValue(epi.getPosition());

            Object divisionObjectId = division.addItem();
            division.setItemCaption(divisionObjectId, epi.getDivision());
            division.setValue(divisionObjectId);

            Object departmentObjectId = department.addItem();
            department.setItemCaption(departmentObjectId, epi.getDepartment());
            department.setValue(departmentObjectId);
        }
    }

    firstname.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            employeePersonalInformation.setFirstname(event.getProperty().getValue().toString());
        }
    });
    firstname.setImmediate(true);
    setInformation(employeePersonalInformation);

    return glayout;
}

From source file:com.compomics.sigpep.webapp.MyVaadinApplication.java

License:Apache License

@Override
public void init() {
    iApplication = this;
    iSigPepSessionFactory = ApplicationLocator.getInstance().getApplication().getSigPepSessionFactory();

    //add theme/*  w  w w.j  a  v  a  2  s.  c  om*/
    setTheme("sigpep");

    //add main window
    Window lMainwindow = new Window("Sigpep Application");
    setMainWindow(lMainwindow);
    lMainwindow.addStyleName("v-app-my");

    //add notification component
    iNotifique = new Notifique(Boolean.FALSE);
    CustomOverlay lCustomOverlay = new CustomOverlay(iNotifique, getMainWindow());
    getMainWindow().addComponent(lCustomOverlay);

    //add form help
    iFormHelp = new FormHelp();
    iFormHelp.setFollowFocus(Boolean.TRUE);
    this.getMainWindow().getContent().addComponent(iFormHelp);

    //add panels
    iCenterLeft = new Panel();
    iCenterLeft.addStyleName(Reindeer.PANEL_LIGHT);
    iCenterLeft.setHeight("400px");
    iCenterLeft.setWidth("100%");

    iCenterRight = new Panel();
    iCenterRight.addStyleName(Reindeer.PANEL_LIGHT);
    iCenterRight.setHeight("400px");
    iCenterRight.setWidth("75%");

    //add form tabs
    iFormTabSheet = new FormTabSheet(this);
    iCenterLeft.addComponent(iFormTabSheet);

    iBottomLayoutResults = new VerticalLayout();

    if (PropertiesConfigurationHolder.showTestDemoFolder()) {
        Button lButton = new Button("load test data");
        lButton.addListener(new Button.ClickListener() {
            public void buttonClick(Button.ClickEvent event) {
                new BackgroundThread().run();
            }
        });
        iBottomLayoutResults.addComponent(lButton);
    }

    // Add the selector component
    iSelectionComponent = new TransitionSelectionComponent(MyVaadinApplication.this);
    iCenterRight.addComponent(iSelectionComponent);

    iHeaderLayout = new HorizontalLayout();
    iHeaderLayout.setSizeFull();
    iHeaderLayout.setHeight("100px");
    iHeaderLayout.addStyleName("v-header");

    VerticalLayout lVerticalLayout = new VerticalLayout();

    GridLayout lGridLayout = new GridLayout(2, 1);
    lGridLayout.setSpacing(true);
    lGridLayout.setSizeFull();

    lGridLayout.addComponent(iCenterLeft, 0, 0);
    lGridLayout.setComponentAlignment(iCenterLeft, Alignment.TOP_LEFT);

    lGridLayout.addComponent(iCenterRight, 1, 0);
    lGridLayout.setComponentAlignment(iCenterRight, Alignment.TOP_CENTER);

    lVerticalLayout.addComponent(iHeaderLayout);
    lVerticalLayout.addComponent(lGridLayout);
    lVerticalLayout.addComponent(iBottomLayoutResults);

    lVerticalLayout.setComponentAlignment(iHeaderLayout, Alignment.MIDDLE_CENTER);
    lVerticalLayout.setComponentAlignment(lGridLayout, Alignment.MIDDLE_CENTER);
    lVerticalLayout.setComponentAlignment(iBottomLayoutResults, Alignment.MIDDLE_CENTER);

    lMainwindow.addComponent(lVerticalLayout);
    lMainwindow.addComponent(pusher);

    // Create a tracker for vaadin.com domain.
    String lDomainName = PropertiesConfigurationHolder.getInstance().getString("analytics.domain");
    String lPageId = PropertiesConfigurationHolder.getInstance().getString("analytics.page");

    GoogleAnalyticsTracker tracker = new GoogleAnalyticsTracker("UA-26252212-1", lDomainName);
    lMainwindow.addComponent(tracker);
    tracker.trackPageview(lPageId);

    /**
     * Sets an UncaughtExceptionHandler and executes the thread by the ExecutorsService
     */
    Thread.setDefaultUncaughtExceptionHandler(new MyUncaughtExceptionHandler());

    parseSessionId();
}

From source file:com.esofthead.mycollab.vaadin.ui.MailFormWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);//ww  w. j  a va 2s  .c  o  m
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();
    tokenFieldMailTo.setRequired(true);

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {
                        tokenFieldMailTo.addToken(mail);
                    }
                } else {
                    tokenFieldMailTo.addToken(mail);
                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

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

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    controlsLayout.addComponent(uploadExt);
    controlsLayout.setExpandRatio(uploadExt, 1.0f);

    controlsLayout.setSpacing(true);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    MailFormWindow.this.close();
                }
            });

    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn = new Button("Send", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
                NotificationUtil.showErrorNotification(
                        "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
                return;
            }
            if (AppContext.getSession().getEmail() != null && AppContext.getSession().getEmail().length() > 0) {
                ExtMailService systemMailService = ApplicationContextUtil.getSpringBean(ExtMailService.class);

                List<File> listFile = attachments.getListFile();
                List<EmailAttachementSource> emailAttachmentSource = null;
                if (listFile != null && listFile.size() > 0) {
                    emailAttachmentSource = new ArrayList<EmailAttachementSource>();
                    for (File file : listFile) {
                        emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                }

                systemMailService.sendHTMLMail(AppContext.getSession().getEmail(),
                        AppContext.getSession().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                        tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                        subject.getValue().toString(), noteArea.getValue().toString(), emailAttachmentSource);
                MailFormWindow.this.close();
            } else {
                NotificationUtil.showErrorNotification(
                        "Your email is empty value, please fulfil it before sending email!");
            }
        }
    });
    sendBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.MailFormWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*w  w w  .ja  v a  2s.  c o m*/
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {

                    }
                } else {

                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

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

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments);
    uploadExt.addComponent(attachments);

    controlsLayout.addComponent(uploadExt);
    controlsLayout.setExpandRatio(uploadExt, 1.0f);

    controlsLayout.setSpacing(true);

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    MailFormWindow.this.close();
                }
            });

    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);
    controlsLayout.addComponent(cancelBtn);
    controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);

    Button sendBtn = new Button("Send", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
                NotificationUtil.showErrorNotification(
                        "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
                return;
            }
            if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) {
                ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class);

                List<File> listFile = attachments.files();
                List<EmailAttachmentSource> emailAttachmentSource = null;
                if (listFile != null && listFile.size() > 0) {
                    emailAttachmentSource = new ArrayList<>();
                    for (File file : listFile) {
                        emailAttachmentSource.add(new FileEmailAttachmentSource(file));
                    }
                }

                systemMailService.sendHTMLMail(AppContext.getUser().getEmail(),
                        AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                        tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                        subject.getValue(), noteArea.getValue(), emailAttachmentSource);
                MailFormWindow.this.close();
            } else {
                NotificationUtil.showErrorNotification(
                        "Your email is empty value, please fulfil it before sending email!");
            }
        }
    });
    sendBtn.setIcon(FontAwesome.SEND);
    sendBtn.setStyleName(UIConstants.BUTTON_ACTION);
    controlsLayout.addComponent(sendBtn);
    controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT);
    mainLayout.addComponent(controlsLayout, 0, 2);

    this.setContent(mainLayout);
}

From source file:com.esspl.datagen.ui.SettingsView.java

License:Open Source License

public SettingsView(DataGenApplication application) {
    setModal(true);/*from ww w  .j  a  v  a 2s. c  om*/
    setResizable(false);
    setCaption("Settings");
    setWidth("620px");
    setHeight("440px");
    dataGenApplication = application;

    GridLayout layout = createMainLayout();
    setContent(layout);

    Component bottom = createBottomBar(dataGenApplication);
    layout.addComponent(bottom, 0, 1);
    layout.setComponentAlignment(bottom, Alignment.MIDDLE_RIGHT);
    layout.setRowExpandRatio(0, 1);

    //Context Help added
    contextHelp = new ContextHelp();
    layout.addComponent(contextHelp);

    refreshDetails();
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from   w  ww  .j  av  a  2  s. c o m*/
    form.setSpacing(true);

    CellItem ci = cis.getCellItemById(getCellItemId());
    if (ci.getCellItemId() == 0) {
        ci = hs.getCellItemById(getCellItemId());
    }

    keyList = k.getAllItemKey(getCellItemId());
    keyIndexSize = keyList.size();
    if (keyList.isEmpty()) {
        ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
        return null;
    }
    stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");

    label.setValue("<b>STEM</b>: " + getStem());
    label.setContentMode(ContentMode.HTML);
    form.addComponent(label);

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

    OptionGroup options = new OptionGroup();
    options.addItems(ci.getOptionA(), ci.getOptionB(), ci.getOptionC(), ci.getOptionD());
    options.addValueChangeListener((Property.ValueChangeEvent event) -> {
        boolean result = k.isAnswerCorrect(getCellItemId(), getItemKey(),
                CommonUtilities.escapeSingleQuote(event.getProperty().getValue()));
        if (result) {
            Notification.show("Correct Answer!", Notification.Type.TRAY_NOTIFICATION);
        } else {
            Notification.show("Wrong Answer", Notification.Type.TRAY_NOTIFICATION);
        }
    });
    h1.addComponent(options);
    h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);
    form.addComponent(h1);

    GridLayout g = new GridLayout(2, 2);
    g.setWidth("100%");
    g.setSpacing(true);

    prev = new Button();
    prev.setWidth("50px");
    prev.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT);
    prev.addStyleName(ValoTheme.BUTTON_PRIMARY);
    prev.addStyleName(ValoTheme.BUTTON_SMALL);
    prev.addClickListener(prevBtnClickListener);
    g.addComponent(prev, 0, 0);
    g.setComponentAlignment(prev, Alignment.MIDDLE_LEFT);

    next = new Button();
    next.setWidth("50px");
    next.setIcon(FontAwesome.ANGLE_DOUBLE_RIGHT);
    next.addStyleName(ValoTheme.BUTTON_PRIMARY);
    next.addStyleName(ValoTheme.BUTTON_SMALL);
    next.addClickListener(nextBtnClickListener);
    g.addComponent(next, 1, 0);
    g.setComponentAlignment(next, Alignment.MIDDLE_RIGHT);

    if (getKeyIndexSize() == 1) {
        prev.setEnabled(false);
        next.setEnabled(false);
    }

    populateDataTable();
    g.addComponent(table, 0, 1, 1, 1);
    g.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
    form.addComponent(g);

    return form;
}

From source file:com.etest.view.tq.reports.ReportGeneratorUI.java

public ReportGeneratorUI() {
    setWidth("100%");
    setMargin(true);//  w w w  .  j  ava2s . c om
    setSpacing(true);

    Label lineSeparator1 = new Label();
    lineSeparator1.setContentMode(ContentMode.HTML);
    lineSeparator1.setStyleName("line-separator");

    Label lineSeparator2 = new Label();
    lineSeparator2.setContentMode(ContentMode.HTML);
    lineSeparator2.setStyleName("line-separator");

    Label lineSeparator3 = new Label();
    lineSeparator3.setContentMode(ContentMode.HTML);
    lineSeparator3.setStyleName("line-separator");

    searchSubject1.addValueChangeListener(dropDownChangeListener);
    searchSubject1.setEnabled(false);
    searchApproveTq1.setWidth("100%");
    searchApproveTq1.setInputPrompt("Search Approved TQ");
    searchApproveTq1.setEnabled(false);
    searchApproveTq1.addStyleName(ValoTheme.COMBOBOX_SMALL);

    searchSubject2.addValueChangeListener(dropDownChangeListener);
    searchSubject2.setEnabled(false);
    searchApproveTq2.setWidth("100%");
    searchApproveTq2.setInputPrompt("Search TQ Ticket No.");
    searchApproveTq2.setEnabled(false);
    searchApproveTq2.addStyleName(ValoTheme.COMBOBOX_SMALL);

    GridLayout g1 = new GridLayout(3, 1);
    g1.setWidth("70%");
    g1.setSpacing(true);

    VerticalLayout v1 = new VerticalLayout();
    v1.setWidth("5px");

    reportType1.addItem("Test Questionnaire");
    reportType1.setWidth("200px");
    reportType1.addValueChangeListener(optionChangeListener);
    reportType1.setImmediate(true);
    v1.addComponent(reportType1);
    v1.setExpandRatio(reportType1, 1);
    g1.addComponent(v1, 0, 0);
    g1.addComponent(searchSubject1, 1, 0);
    g1.addComponent(searchApproveTq1, 2, 0);

    addComponent(g1);

    addComponent(lineSeparator1);

    GridLayout g2 = new GridLayout(3, 1);
    g2.setWidth("70%");
    g2.setSpacing(true);

    VerticalLayout v2 = new VerticalLayout();
    v2.setWidth("5px");

    reportType2.addItem("Item Analysis");
    reportType2.setWidth("200px");
    reportType2.addValueChangeListener(optionChangeListener);
    reportType2.setImmediate(true);
    v2.addComponent(reportType2);
    v2.setExpandRatio(reportType2, 1);
    g2.addComponent(v2, 0, 0);
    g2.addComponent(searchSubject2, 1, 0);
    g2.addComponent(searchApproveTq2, 2, 0);

    addComponent(g2);

    addComponent(lineSeparator2);

    GridLayout g3 = new GridLayout(3, 1);
    g3.setWidth("70%");
    g3.setSpacing(true);

    VerticalLayout v3 = new VerticalLayout();
    v3.setWidth("5px");

    reportType3.addItem("Test Bank Inventory");
    reportType3.setWidth("200px");
    reportType3.addValueChangeListener(optionChangeListener);
    reportType3.setImmediate(true);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setSpacing(true);

    testBankInventory.addItem("Summary: Case vs Items");
    testBankInventory.addItem("Summary: Items Group according to the Revised Blooms Taxonomy");
    testBankInventory.setImmediate(true);
    testBankInventory.select("Summary: Case vs Items");

    testBankInventory.setEnabled(false);
    v.addComponent(testBankInventory);

    v3.addComponent(reportType3);
    v3.setExpandRatio(reportType3, 1);
    g3.addComponent(v3, 0, 0);
    g3.setComponentAlignment(v3, Alignment.TOP_LEFT);
    g3.addComponent(v, 1, 0);
    addComponent(g3);

    //        addComponent(new Label("<HR>", ContentMode.HTML));
    addComponent(lineSeparator3);

    Button button = new Button("Calculate & Generate");
    button.addClickListener(reportBtnClickListener);
    button.setWidth("300px");

    addComponent(button);
    setComponentAlignment(button, Alignment.MIDDLE_LEFT);
}

From source file:com.hack23.cia.web.impl.ui.application.views.common.menufactory.impl.AbstractMenuItemFactoryImpl.java

License:Apache License

protected final void createButtonLink(final GridLayout panelContent, final String linkText, final Resource icon,
        final ClickListener command, final String description) {
    final GridLayout grid = new GridLayout(2, 1);
    grid.setWidth(100, Unit.PERCENTAGE);
    grid.setHeight(100, Unit.PERCENTAGE);
    grid.setColumnExpandRatio(0, 1);/*from   ww  w.  j ava  2  s  .  c om*/
    grid.setColumnExpandRatio(1, 2);

    final Button b = new Button(linkText);
    b.setStyleName("link");
    b.addClickListener(command);
    b.setWidth(100, Unit.PERCENTAGE);

    b.setIcon(icon);
    b.setWidth(100, Unit.PERCENTAGE);

    grid.addComponent(b, 0, 0);
    grid.setComponentAlignment(b, Alignment.MIDDLE_LEFT);

    final Label descriptionLabel = new Label(description);
    descriptionLabel.setWidth(100, Unit.PERCENTAGE);
    grid.addComponent(descriptionLabel, 1, 0);
    grid.setComponentAlignment(descriptionLabel, Alignment.MIDDLE_LEFT);

    panelContent.addComponent(grid);
    panelContent.setComponentAlignment(grid, Alignment.MIDDLE_LEFT);
}