Example usage for com.vaadin.ui GridLayout addComponent

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

Introduction

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

Prototype

public void addComponent(Component component, int column1, int row1, int column2, int row2)
        throws OverlapsException, OutOfBoundsException 

Source Link

Document

Adds a component to the grid in the specified area.

Usage

From source file:at.peppol.webgui.app.components.InvoiceForm.java

License:Mozilla Public License

private void initElements() {

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();

    final Panel outerPanel = new Panel("Invoice Header");

    outerPanel.addComponent(grid);/* www.  j  a v  a  2 s.  c  o  m*/
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);
    setLayout(outerLayout);

    final Panel invoiceDetailsPanel = new Panel("Invoice Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    invoiceDetailsPanel.addComponent(createInvoiceTopForm());
    grid.addComponent(invoiceDetailsPanel, 0, 0, 3, 0);
    grid.setSizeUndefined();

    outerPanel.requestRepaintAll();
}

From source file:at.peppol.webgui.app.components.TabInvoiceMonetaryTotal.java

License:Mozilla Public License

private void initElements() {
    // monetaryTotal = parent.getInvoice().getLegalMonetaryTotal ();
    monetaryTotal = createMonetaryTotal();
    parent.getInvoice().setLegalMonetaryTotal(monetaryTotal);

    final GridLayout grid = new GridLayout(4, 4);
    final VerticalLayout outerLayout = new VerticalLayout();

    final Panel outerPanel = new Panel("Monetary Total");
    outerPanel.addComponent(grid);/*w  w  w . j  a va  2  s  .  c o  m*/
    outerPanel.setScrollable(true);
    outerLayout.addComponent(outerPanel);

    final Panel invoiceDetailsPanel = new Panel("Monetary Total Details");
    invoiceDetailsPanel.setStyleName("light");
    invoiceDetailsPanel.setSizeFull();
    invoiceMonetaryTotalTopForm = createInvoiceMonetaryTotalTopForm();
    invoiceDetailsPanel.addComponent(invoiceMonetaryTotalTopForm);
    //invoiceDetailsPanel.addComponent (createInvoiceMonetaryTotalTopForm ());
    grid.addComponent(invoiceDetailsPanel, 0, 0, 3, 0);
    grid.setSizeUndefined();

    //Add the Total Line Extension Amount Listener

    setLayout(outerLayout);
    outerPanel.requestRepaintAll();
}

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   ww w .j  a 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.javalego.ui.vaadin.component.util.MessageBox.java

License:Apache License

/**
 * Similar to/*from   w w w .j  a v  a2  s .  co  m*/
 * {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)}
 * , but the message component is defined explicitly. The component can be
 * even a composite of a layout manager and manager further Vaadin
 * components.
 * 
 * @param messageComponent
 *            a Vaadin component
 */
public MessageBox(String dialogCaption, Icon dialogIcon, Component messageComponent, Alignment buttonsAlignment,
        ButtonConfig... buttonConfigs) {

    super();

    setResizable(false);
    setClosable(false);

    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);

    mainLayout.setSizeUndefined();
    messageComponent.setSizeUndefined();

    // Add Content
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {

        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);

        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        //         Label icon = new Label();
        //         switch (dialogIcon) {
        //         case QUESTION:
        //            icon.setIcon(FontAwesome.QUESTION);
        //            break;
        //         case INFO:
        //            icon.setIcon(FontAwesome.INFO);
        //            break;
        //         case WARN:
        //            icon.setIcon(FontAwesome.WARNING);
        //            break;
        //         case ERROR:
        //            icon.setIcon(FontAwesome.STOP);
        //            break;
        //         default:
        //            break;
        //         }
        //         mainLayout.addComponent(icon, 0, 0);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    buttonLayout.setMargin(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);

    for (ButtonConfig buttonConfig : buttonConfigs) {

        ButtonExt button = new ButtonExt(buttonConfig.getCaption());

        //         if (buttonConfig.buttonType == ButtonType.YES || buttonConfig.buttonType == ButtonType.OK) {
        //            button.blue();
        //         }

        button.addClickListener(new ButtonClickListener(buttonConfig.getButtonType()));
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(5, 2);
    taskDetails.setWidth(100, UNITS_PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);// w w  w  . j  a va2 s .  c  om
    taskDetails.setMargin(new MarginInfo(false, false, true, false));

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(historicTask.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0, 4, 0);

    // Add due date
    PrettyTimeLabel dueDateLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_DUEDATE_SHORT),
            historicTask.getDueDate(), i18nManager.getMessage(Messages.TASK_DUEDATE_UNKNOWN), false);
    dueDateLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_DUEDATE);
    taskDetails.addComponent(dueDateLabel, 1, 1);

    // Add priority
    Integer lowMedHighPriority = convertPriority(historicTask.getPriority());
    Label priorityLabel = new Label();
    switch (lowMedHighPriority) {
    case 1:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_LOW));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_LOW);
        break;
    case 2:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_MEDIUM));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_MEDIUM);
        break;
    case 3:
    default:
        priorityLabel.setValue(i18nManager.getMessage(Messages.TASK_PRIORITY_HIGH));
        priorityLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_PRIORITY_HIGH);
    }
    taskDetails.addComponent(priorityLabel, 2, 1);

    // Add create date
    PrettyTimeLabel createLabel = new PrettyTimeLabel(i18nManager.getMessage(Messages.TASK_CREATED_SHORT),
            historicTask.getStartTime(), "", true);
    createLabel.addStyleName(ExplorerLayout.STYLE_TASK_HEADER_CREATE_TIME);
    taskDetails.addComponent(createLabel, 3, 1);

    // Add label to fill excess space
    Label spacer = new Label();
    spacer.setContentMode(Label.CONTENT_XHTML);
    spacer.setValue(" ");
    spacer.setSizeUndefined();
    taskDetails.addComponent(spacer);

    taskDetails.setColumnExpandRatio(1, 1.0f);
    taskDetails.setColumnExpandRatio(2, 1.0f);
    taskDetails.setColumnExpandRatio(3, 1.0f);
    taskDetails.setColumnExpandRatio(4, 1.0f);
    centralLayout.addComponent(taskDetails);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initHeader() {
    GridLayout taskDetails = new GridLayout(2, 2);
    taskDetails.setWidth(100, Unit.PERCENTAGE);
    taskDetails.addStyleName(ExplorerLayout.STYLE_TITLE_BLOCK);
    taskDetails.setSpacing(true);/*from  w  w  w.j  a  va  2 s.  c om*/
    taskDetails.setMargin(new MarginInfo(false, false, true, false));
    taskDetails.setColumnExpandRatio(1, 1.0f);
    centralLayout.addComponent(taskDetails);

    // Add image
    Embedded image = new Embedded(null, Images.TASK_50);
    //??
    taskDetails.addComponent(image, 0, 0, 0, 1);

    // Add task name
    Label nameLabel = new Label(task.getName());
    nameLabel.addStyleName(Reindeer.LABEL_H2);
    taskDetails.addComponent(nameLabel, 1, 0);
    taskDetails.setComponentAlignment(nameLabel, Alignment.MIDDLE_LEFT);

    // Properties
    HorizontalLayout propertiesLayout = new HorizontalLayout();//
    propertiesLayout.setSpacing(true);
    taskDetails.addComponent(propertiesLayout);

    propertiesLayout.addComponent(new DueDateComponent(task, i18nManager, taskService));
    propertiesLayout.addComponent(new PriorityComponent(task, i18nManager, taskService));
    //?
    initCreateTime(propertiesLayout);
}

From source file:com.scsb.crpro.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //w  w w.j av a2  s .  c  om
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:com.scsb.vaadin.composite.MessageBox.java

License:Apache License

/**
 * Similar to {@link #MessageBox(Window, String, Icon, String, Alignment, ButtonConfig...)},
 * but the message component is defined explicitly. The component can be even a composite
 * of a layout manager and manager further Vaadin components.
 * //from   ww w.  ja  va2s  .c  o  m
 * @param messageComponent a Vaadin component
 */
public MessageBox(String dialogWidth, String dialogHeight, String dialogCaption, Icon dialogIcon,
        Component messageComponent, Alignment buttonsAlignment, ButtonConfig... buttonConfigs) {
    super();
    setResizable(false);
    setClosable(false);
    setSizeUndefined();
    setWidth(dialogWidth);
    //setHeight(dialogHeight);
    setCaption(dialogCaption);

    GridLayout mainLayout = new GridLayout(2, 2);
    mainLayout.setMargin(true);
    mainLayout.setSpacing(true);
    mainLayout.setSizeUndefined();
    mainLayout.setWidth(GRID_DEFAULT_WIDTH1);

    // Add Content
    messageComponent.setSizeUndefined();
    messageComponent.setWidth(GRID_DEFAULT_WIDTH2);
    if (dialogIcon == null || Icon.NONE.equals(dialogIcon)) {
        mainLayout.addComponent(messageComponent, 0, 0, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(0, 1.0f);
    } else {
        mainLayout.addComponent(messageComponent, 1, 0);
        mainLayout.setRowExpandRatio(0, 1.0f);
        mainLayout.setColumnExpandRatio(1, 1.0f);

        Embedded icon = null;
        switch (dialogIcon) {
        case QUESTION:
            icon = new Embedded(null, new ThemeResource("./images/question.png"));
            break;
        case INFO:
            icon = new Embedded(null, new ThemeResource("./images/info.png"));
            break;
        case WARN:
            icon = new Embedded(null, new ThemeResource("./images/warn.png"));
            break;
        case ERROR:
            icon = new Embedded(null, new ThemeResource("./images/error.png"));
            break;
        }
        mainLayout.addComponent(icon, 0, 0);
        icon.setWidth(ICON_DEFAULT_SIZE);
        icon.setHeight(ICON_DEFAULT_SIZE);
    }

    // Add Buttons
    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setSpacing(true);
    mainLayout.addComponent(buttonLayout, 0, 1, 1, 1);
    mainLayout.setComponentAlignment(buttonLayout, buttonsAlignment);
    for (ButtonConfig buttonConfig : buttonConfigs) {
        Button button = new Button(buttonConfig.getCaption(),
                new ButtonClickListener(buttonConfig.getButtonType()));
        if (buttonConfig.getWidth() != null) {
            button.setWidth(buttonConfig.getWidth());
        }
        if (buttonConfig.getOptionalResource() != null) {
            button.setIcon(buttonConfig.getOptionalResource());
        } else {
            Resource icon = null;
            switch (buttonConfig.getButtonType()) {
            case ABORT:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CANCEL:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case CLOSE:
                icon = new ThemeResource("images/famfamfam/door.png");
                break;
            case HELP:
                icon = new ThemeResource("images/famfamfam/lightbulb.png");
                break;
            case OK:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case YES:
                icon = new ThemeResource("images/famfamfam/tick.png");
                break;
            case NO:
                icon = new ThemeResource("images/famfamfam/cross.png");
                break;
            case SAVE:
                icon = new ThemeResource("images/famfamfam/disk.png");
                break;
            case RETRY:
                icon = new ThemeResource("images/famfamfam/arrow_refresh.png");
                break;
            case IGNORE:
                icon = new ThemeResource("images/famfamfam/lightning_go.png");
                break;
            }
            button.setIcon(icon);
        }
        buttonLayout.addComponent(button);
    }

    setContent(mainLayout);
}

From source file:de.catma.ui.tagmanager.PropertyDefinitionDialog.java

License:Open Source License

private void initComponents(String caption) {
    setMargin(true);/*  w w w.  j a va2 s .co m*/
    setSpacing(true);

    GridLayout propPanel = new GridLayout(3, 3);
    propPanel.setSpacing(true);

    nameInput = new TextField("Name");
    nameInput.setRequired(true);
    if (propertyDefinition != null) {
        nameInput.setValue(propertyDefinition.getName());
    }
    propPanel.addComponent(nameInput, 0, 0, 2, 0);

    if (propertyDefinition != null) {
        valueInput = new ListSelect("Possible values",
                propertyDefinition.getPossibleValueList().getPropertyValueList().getValues());
    } else {
        valueInput = new ListSelect("Possible values");
    }
    valueInput.setWidth("100%");
    valueInput.setRequired(true);
    valueInput.setNullSelectionAllowed(false);

    propPanel.addComponent(valueInput, 0, 1, 2, 1);

    newValueInput = new TextField("Add possible value");
    propPanel.addComponent(newValueInput, 0, 2);

    btAdd = new Button("+");
    propPanel.addComponent(btAdd, 1, 2);
    propPanel.setComponentAlignment(btAdd, Alignment.BOTTOM_CENTER);

    btRemove = new Button("-");
    propPanel.addComponent(btRemove, 2, 2);
    propPanel.setComponentAlignment(btRemove, Alignment.BOTTOM_CENTER);

    addComponent(propPanel);

    HorizontalLayout buttonPanel = new HorizontalLayout();
    buttonPanel.setSpacing(true);

    btSave = new Button("Save");
    buttonPanel.addComponent(btSave);
    buttonPanel.setComponentAlignment(btSave, Alignment.MIDDLE_RIGHT);

    btCancel = new Button("Cancel");
    buttonPanel.addComponent(btCancel);
    buttonPanel.setComponentAlignment(btCancel, Alignment.MIDDLE_RIGHT);

    addComponent(buttonPanel);
    setComponentAlignment(buttonPanel, Alignment.MIDDLE_RIGHT);

    window = new Window(caption);
    window.setContent(this);
    window.setWidth("30%");
    window.setHeight("70%");
    window.center();
}

From source file:de.mendelson.comm.as2.webclient2.AboutDialog.java

/**Could be overwritten, contains the content to display*/
@Override/*from w w  w.j  a  v  a 2 s.c  o m*/
public AbstractComponent getContentPanel() {
    int maxX = 7;
    Panel panel = new Panel();
    GridLayout gridLayout = new GridLayout(maxX, 17);
    gridLayout.setSizeFull();
    Embedded logComm = new Embedded("", new ThemeResource("images/logocommprotocols.gif"));
    logComm.setType(Embedded.TYPE_IMAGE);
    VerticalLayout gapLayout = new VerticalLayout();
    gapLayout.setMargin(false, true, true, false);
    gapLayout.addComponent(logComm);
    gridLayout.addComponent(gapLayout, 0, 0, 1, 3);
    gridLayout.addComponent(
            new Label("<strong>" + AS2ServerVersion.getFullProductName() + "</strong>", Label.CONTENT_XHTML), 2,
            1, maxX - 1, 1);
    gridLayout.addComponent(new Label(AS2ServerVersion.getLastModificationDate()), 2, 2, maxX - 1, 2);
    gridLayout.addComponent(new Label("<hr/>", Label.CONTENT_XHTML), 0, 4, maxX - 1, 4);
    gridLayout.addComponent(new Label(Copyright.getCopyrightMessage(), Label.CONTENT_XHTML), 0, 5, maxX - 1, 5);
    gridLayout.addComponent(new Label(AS2ServerVersion.getStreet(), Label.CONTENT_XHTML), 0, 6, maxX - 1, 6);
    gridLayout.addComponent(new Label(AS2ServerVersion.getZip(), Label.CONTENT_XHTML), 0, 7, maxX - 1, 7);
    gridLayout.addComponent(new Label(AS2ServerVersion.getTelephone(), Label.CONTENT_XHTML), 0, 8, maxX - 1, 8);
    gridLayout.addComponent(new Label(AS2ServerVersion.getInfoEmail(), Label.CONTENT_XHTML), 0, 9, maxX - 1, 9);
    gridLayout.addComponent(new Label("<hr/>", Label.CONTENT_XHTML), 0, 10, 6, 10);
    gridLayout.addComponent(
            new Link("http://www.mendelson.de", new ExternalResource("http://www.mendelson.de")), 0, 11,
            maxX - 1, 11);
    gridLayout.addComponent(
            new Link("http://www.mendelson-e-c.com", new ExternalResource("http://www.mendelson-e-c.com")), 0,
            12, maxX - 1, 12);
    gridLayout.addComponent(new Label("<hr/>", Label.CONTENT_XHTML), 0, 13, maxX - 1, 13);
    gridLayout.addComponent(new Label("<br/>", Label.CONTENT_XHTML), 0, 14, maxX - 1, 14);
    gridLayout.addComponent(
            new Label("[Based on VAADIN " + com.vaadin.terminal.gwt.server.ApplicationServlet.VERSION + "]"), 0,
            16, maxX - 1, 16);
    panel.addComponent(gridLayout);
    return (panel);
}