Example usage for com.vaadin.ui VerticalLayout setComponentAlignment

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

Introduction

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

Prototype

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

Source Link

Usage

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserListViewImpl.java

License:Open Source License

private Component generateMemberBlock(final SimpleUser member) {
    CssLayout memberBlock = new CssLayout();
    memberBlock.addStyleName("member-block");

    VerticalLayout blockContent = new VerticalLayout();
    HorizontalLayout blockTop = new HorizontalLayout();
    blockTop.setSpacing(true);//from  ww  w .j a  v a 2  s  .c om
    Image memberAvatar = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(member.getAvatarid(), 100);
    blockTop.addComponent(memberAvatar);

    VerticalLayout memberInfo = new VerticalLayout();

    HorizontalLayout layoutButtonDelete = new HorizontalLayout();
    layoutButtonDelete.setVisible(AppContext.canWrite(RolePermissionCollections.ACCOUNT_USER));
    layoutButtonDelete.setWidth("100%");

    Label emptylb = new Label("");
    layoutButtonDelete.addComponent(emptylb);
    layoutButtonDelete.setExpandRatio(emptylb, 1.0f);

    Button deleteBtn = new Button();
    deleteBtn.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            ConfirmDialogExt.show(UI.getCurrent(),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_TITLE, SiteConfiguration.getSiteName()),
                    AppContext.getMessage(GenericI18Enum.DIALOG_DELETE_SINGLE_ITEM_MESSAGE),
                    AppContext.getMessage(GenericI18Enum.BUTTON_YES),
                    AppContext.getMessage(GenericI18Enum.BUTTON_NO), new ConfirmDialog.Listener() {
                        private static final long serialVersionUID = 1L;

                        @Override
                        public void onClose(ConfirmDialog dialog) {
                            if (dialog.isConfirmed()) {
                                UserService userService = ApplicationContextUtil
                                        .getSpringBean(UserService.class);
                                userService.pendingUserAccounts(Arrays.asList(member.getUsername()),
                                        AppContext.getAccountId());
                                EventBusFactory.getInstance()
                                        .post(new UserEvent.GotoList(UserListViewImpl.this, null));
                            }
                        }
                    });
        }
    });
    deleteBtn.setIcon(FontAwesome.TRASH_O);
    deleteBtn.addStyleName(UIConstants.BUTTON_ICON_ONLY);
    layoutButtonDelete.addComponent(deleteBtn);

    memberInfo.addComponent(layoutButtonDelete);

    ButtonLink userAccountLink = new ButtonLink(member.getDisplayName());
    userAccountLink.addClickListener(new ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            EventBusFactory.getInstance()
                    .post(new UserEvent.GotoRead(UserListViewImpl.this, member.getUsername()));
        }
    });
    userAccountLink.setWidth("100%");
    userAccountLink.setHeight("100%");

    memberInfo.addComponent(userAccountLink);

    Label memberEmailLabel = new Label(
            "<a href='mailto:" + member.getUsername() + "'>" + member.getUsername() + "</a>", ContentMode.HTML);
    memberEmailLabel.addStyleName("member-email");
    memberEmailLabel.setWidth("100%");
    memberInfo.addComponent(memberEmailLabel);

    Label memberSinceLabel = new Label("Member since: " + AppContext.formatDate(member.getRegisteredtime()));
    memberSinceLabel.addStyleName("member-email");
    memberSinceLabel.setWidth("100%");
    memberInfo.addComponent(memberSinceLabel);

    if (RegisterStatusConstants.SENT_VERIFICATION_EMAIL.equals(member.getRegisterstatus())) {
        final VerticalLayout waitingNotLayout = new VerticalLayout();
        Label infoStatus = new Label("Waiting for accept invitation");
        infoStatus.addStyleName("member-email");
        waitingNotLayout.addComponent(infoStatus);

        ButtonLink resendInvitationLink = new ButtonLink("Resend Invitation", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                UserService userService = ApplicationContextUtil.getSpringBean(UserService.class);
                userService.updateUserAccountStatus(member.getUsername(), member.getAccountId(),
                        RegisterStatusConstants.VERIFICATING);
                waitingNotLayout.removeAllComponents();
                Label statusEmail = new Label("Sending invitation email");
                statusEmail.addStyleName("member-email");
                waitingNotLayout.addComponent(statusEmail);
            }
        });
        resendInvitationLink.setStyleName("link");
        resendInvitationLink.addStyleName("member-email");
        waitingNotLayout.addComponent(resendInvitationLink);
        memberInfo.addComponent(waitingNotLayout);
    } else if (RegisterStatusConstants.ACTIVE.equals(member.getRegisterstatus())) {
        Label lastAccessTimeLbl = new Label("Logged in "
                + DateTimeUtils.getPrettyDateValue(member.getLastaccessedtime(), AppContext.getUserLocale()));
        lastAccessTimeLbl.addStyleName("member-email");
        memberInfo.addComponent(lastAccessTimeLbl);
    } else if (RegisterStatusConstants.VERIFICATING.equals(member.getRegisterstatus())) {
        Label infoStatus = new Label("Sending invitation email");
        infoStatus.addStyleName("member-email");
        memberInfo.addComponent(infoStatus);
    }

    blockTop.addComponent(memberInfo);
    blockTop.setExpandRatio(memberInfo, 1.0f);
    blockTop.setWidth("100%");
    blockContent.addComponent(blockTop);

    if (member.getRoleid() != null) {
        String memberRoleLinkPrefix = "<a href=\""
                + AccountLinkBuilder.generatePreviewFullRoleLink(member.getRoleid()) + "\"";
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        if (member.getIsAccountOwner() != null && member.getIsAccountOwner()) {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        } else {
            memberRole.setValue(memberRoleLinkPrefix + "style=\"color:gray;font-size:12px;\">"
                    + member.getRoleName() + "</a>");
        }
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else if (member.getIsAccountOwner() != null && member.getIsAccountOwner() == Boolean.TRUE) {
        Label memberRole = new Label();
        memberRole.setContentMode(ContentMode.HTML);
        memberRole.setValue("<a style=\"color: #B00000;\">" + "Account Owner" + "</a>");
        memberRole.setSizeUndefined();
        blockContent.addComponent(memberRole);
        blockContent.setComponentAlignment(memberRole, Alignment.MIDDLE_RIGHT);
    } else {
        Label lbl = new Label();
        lbl.setHeight("10px");
        blockContent.addComponent(lbl);
    }
    blockContent.setWidth("100%");

    memberBlock.addComponent(blockContent);

    return memberBlock;
}

From source file:com.esofthead.mycollab.module.user.accountsettings.team.view.UserReadViewImpl.java

License:Open Source License

private void displayUserAvatar() {
    this.userAvatar.removeAllComponents();
    final Image cropField = UserAvatarControlFactory.createUserAvatarEmbeddedComponent(user.getAvatarid(), 100);
    userAvatar.addComponent(cropField);/* w  w w.  ja v  a  2s .c om*/

    this.avatarAndPass.removeAllComponents();
    avatarAndPass.addComponent(userAvatar);

    final VerticalLayout basicLayout = new VerticalLayout();
    basicLayout.setSpacing(true);
    final HorizontalLayout userWrapper = new HorizontalLayout();

    String nickName = user.getNickname();

    final Label userName = new Label(
            user.getDisplayName() + (StringUtils.isEmpty(nickName) ? "" : (" ( " + nickName + " )")));
    userName.setStyleName("h1");
    userWrapper.addComponent(userName);

    basicLayout.addComponent(userWrapper);
    basicLayout.setComponentAlignment(userWrapper, Alignment.MIDDLE_LEFT);

    Component role;
    if (user.getIsAccountOwner() != null && user.getIsAccountOwner() == Boolean.TRUE) {
        role = new DefaultViewField("Account Owner");
    } else {
        role = new LinkViewField(user.getRoleName(),
                AccountLinkBuilder.generatePreviewFullRoleLink(user.getRoleid()));
    }
    MHorizontalLayout roleWrapper = new MHorizontalLayout();
    roleWrapper.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_ROLE) + ": "));
    roleWrapper.addComponent(role);

    basicLayout.addComponent(roleWrapper);

    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_BIRTHDAY) + ": "
            + AppContext.formatDate(user.getDateofbirth())));
    basicLayout.addComponent(
            new MHorizontalLayout().add(new Label(AppContext.getMessage(UserI18nEnum.FORM_EMAIL) + ": "))
                    .add(new LabelLink(user.getEmail(), "mailto:" + user.getEmail())));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_TIMEZONE) + ": "
            + TimezoneMapper.getTimezone(user.getTimezone()).getDisplayName()));
    basicLayout.addComponent(new Label(AppContext.getMessage(UserI18nEnum.FORM_LANGUAGE) + ": "
            + AppContext.getMessage(LangI18Enum.class, user.getLanguage())));

    avatarAndPass.addComponent(basicLayout);
    avatarAndPass.setComponentAlignment(basicLayout, Alignment.TOP_LEFT);
    avatarAndPass.setExpandRatio(basicLayout, 1.0f);
}

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

License:Open Source License

public ImagePreviewCropWindow(final ImageSelectionCommand imageSelectionCommand, final byte[] imageData) {
    super("Preview and modify image");
    setModal(true);/*from   w  ww .  ja v  a  2s  .  c  o  m*/
    setResizable(false);
    setWidth("700px");
    center();

    MVerticalLayout content = new MVerticalLayout();
    setContent(content);

    try {
        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().withSpacing(true)
            .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));
    Label lbPreview = new Label("<p style='margin: 0px;'><strong>To the bottom is what your profile photo will "
            + "look like.</strong></p>"
            + "<p style='margin-top: 0px;'>To make adjustment, you can drag around and resize the selection square below. "
            + "When you are happy with your photo, click the &ldquo;Accept&ldquo; button.</p>",
            ContentMode.HTML);
    previewBoxTitle.addComponent(lbPreview);

    MHorizontalLayout controlBtns = new MHorizontalLayout();
    controlBtns.setSizeUndefined();

    Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);

    Button acceptBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ACCEPT),
            new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    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);
                        }
                    }
                }
            });
    acceptBtn.setStyleName(UIConstants.BUTTON_ACTION);
    acceptBtn.setIcon(FontAwesome.CHECK);

    controlBtns.with(acceptBtn, cancelBtn).alignAll(Alignment.MIDDLE_LEFT);

    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(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            VCropSelection newSelection = (VCropSelection) event.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.esofthead.mycollab.vaadin.ui.BeanList.java

License:Open Source License

public void loadItems(List<T> currentListData) {
    contentLayout.removeAllComponents();

    try {//from   w  ww. j av  a  2 s  .c  o m
        if (CollectionUtils.isEmpty(currentListData) && isDisplayEmptyListText) {
            Label noItemLbl = new Label(AppContext.getMessage(GenericI18Enum.EXT_NO_ITEM));
            final VerticalLayout widgetFooter = new VerticalLayout();
            widgetFooter.addStyleName("widget-footer");
            widgetFooter.setWidth("100%");
            widgetFooter.addComponent(noItemLbl);
            widgetFooter.setComponentAlignment(noItemLbl, Alignment.MIDDLE_CENTER);
            contentLayout.addComponent(widgetFooter);
        } else {
            int i = 0;
            for (T item : currentListData) {
                RowDisplayHandler<T> rowHandler = constructRowDisplayHandler();

                Component row = rowHandler.generateRow(item, i);
                if (row != null) {
                    row.setWidth("100%");
                    contentLayout.addComponent(row);
                }

                i++;
            }
        }

    } catch (Exception e) {
        LOG.error("Error while generate column display", e);
    }
}

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

License:Open Source License

public NotPresentedView() {
    this.setHeight("370px");
    this.setWidth("100%");
    VerticalLayout layoutWapper = new VerticalLayout();
    layoutWapper.setWidth("100%");

    VerticalLayout layout = new VerticalLayout();
    final Label titleIcon = new Label(FontAwesome.EXCLAMATION_CIRCLE.getHtml(), ContentMode.HTML);
    titleIcon.setStyleName("warning-icon");
    titleIcon.setSizeUndefined();// www .j  a  va 2s . com
    layout.addComponent(titleIcon);
    layout.setComponentAlignment(titleIcon, Alignment.MIDDLE_CENTER);

    Label label = new Label("The feature is not presented for this edition");
    label.setStyleName("h2_community");
    layout.addComponent(label);
    layout.setComponentAlignment(label, Alignment.MIDDLE_CENTER);

    layoutWapper.addComponent(layout);
    layoutWapper.setComponentAlignment(layout, Alignment.MIDDLE_CENTER);
    this.addComponent(layoutWapper);
    this.setComponentAlignment(layoutWapper, Alignment.MIDDLE_CENTER);
}

From source file:com.esofthead.mycollab.vaadin.ui.table.CustomizedTableWindow.java

License:Open Source License

public CustomizedTableWindow(final String viewId, final AbstractPagedBeanTable<?, ?> table) {
    super("Customize View");
    this.viewId = viewId;
    this.addStyleName("customize-table-window");
    this.setWidth("400px");
    this.setResizable(false);
    this.setModal(true);
    this.center();

    this.tableItem = table;
    customViewStoreService = ApplicationContextUtil.getSpringBean(CustomViewStoreService.class);

    final VerticalLayout contentLayout = new VerticalLayout();
    contentLayout.setSpacing(true);//from w ww. ja va  2s  .  c o m
    contentLayout.setMargin(true);
    this.setContent(contentLayout);

    this.listBuilder = new ListBuilder();
    this.listBuilder.setImmediate(true);
    this.listBuilder.setColumns(0);
    this.listBuilder.setLeftColumnCaption("Available Columns");
    this.listBuilder.setRightColumnCaption("View Columns");
    this.listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);

    this.listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    this.listBuilder.setContainerDataSource(container);
    Iterator<TableViewField> iterator = getAvailableColumns().iterator();
    while (iterator.hasNext()) {
        TableViewField field = iterator.next();
        this.listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey()));
    }
    this.setSelectedViewColumns();
    contentLayout.addComponent(this.listBuilder);
    contentLayout.setComponentAlignment(listBuilder, Alignment.MIDDLE_CENTER);

    Button restoreLink = new Button("Restore to default", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @SuppressWarnings("unchecked")
        @Override
        public void buttonClick(ClickEvent event) {
            List<TableViewField> defaultSelectedColumns = tableItem.getDefaultSelectedColumns();
            if (defaultSelectedColumns != null) {
                final List<TableViewField> selectedColumns = new ArrayList<>();
                final BeanItemContainer<TableViewField> container = (BeanItemContainer<TableViewField>) CustomizedTableWindow.this.listBuilder
                        .getContainerDataSource();
                final Collection<TableViewField> itemIds = container.getItemIds();

                for (TableViewField column : defaultSelectedColumns) {
                    for (final TableViewField viewField : itemIds) {
                        if (column.getField().equals(viewField.getField())) {
                            selectedColumns.add(viewField);
                        }
                    }
                }

                CustomizedTableWindow.this.listBuilder.setValue(selectedColumns);
            }

        }
    });
    restoreLink.setStyleName("link");
    contentLayout.addComponent(restoreLink);
    contentLayout.setComponentAlignment(restoreLink, Alignment.MIDDLE_RIGHT);

    final HorizontalLayout buttonControls = new HorizontalLayout();
    buttonControls.setSpacing(true);
    final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void buttonClick(final ClickEvent event) {
                    final List<TableViewField> selectedColumns = (List<TableViewField>) CustomizedTableWindow.this.listBuilder
                            .getValue();
                    table.setDisplayColumns(selectedColumns);
                    CustomizedTableWindow.this.close();

                    // Save custom table view def
                    CustomViewStore viewDef = new CustomViewStore();
                    viewDef.setSaccountid(AppContext.getAccountId());
                    viewDef.setCreateduser(AppContext.getUsername());
                    viewDef.setViewid(viewId);
                    viewDef.setViewinfo(XStreamJsonDeSerializer.toJson(new ArrayList<>(selectedColumns)));
                    customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);
                }
            });
    saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    saveBtn.setIcon(FontAwesome.SAVE);
    buttonControls.addComponent(saveBtn);

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

                @Override
                public void buttonClick(final ClickEvent event) {
                    CustomizedTableWindow.this.close();
                }
            });
    cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK);
    buttonControls.addComponent(cancelBtn);

    contentLayout.addComponent(buttonControls);
    contentLayout.setComponentAlignment(buttonControls, Alignment.MIDDLE_CENTER);
}

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

License:Open Source License

public ResultView(final DataGenApplication dataGenApplication, ArrayList<GeneratorBean> rowList) {
    log.debug("ResultView constructor start");
    VerticalLayout layout = (VerticalLayout) this.getContent();
    layout.setMargin(false);//  w w w .  j av a2 s.  co  m
    layout.setSpacing(false);
    layout.setHeight("500px");
    layout.setWidth("600px");

    Button close = new Button("Close", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Close Button clicked");
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    close.setIcon(DataGenConstant.CLOSE_ICON);

    String dataOption = dataGenApplication.generateType.getValue().toString();
    Generator genrator = null;
    if (dataOption.equalsIgnoreCase("xml")) {
        genrator = new XmlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("sql")) {
        genrator = new SqlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("csv")) {
        genrator = new CsvDataGenerator();
    }

    if (genrator == null) {
        log.info("ResultView - genrator object is null");
        dataGenApplication.getMainWindow().removeWindow(this);
        return;
    }

    //Data generated from respective command class and shown in the modal window
    final TextArea message = new TextArea();
    message.setSizeFull();
    message.setHeight("450px");
    message.setWordwrap(false);
    message.setStyleName("noResizeTextArea");
    message.setValue(genrator.generate(dataGenApplication, rowList));
    layout.addComponent(message);

    Button copy = new Button("Copy", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Copy Button clicked");
            //As on Unix environment, it gives headless exception we need to handle it
            try {
                //StringSelection stringSelection = new StringSelection(message.getValue().toString());
                Transferable tText = new StringSelection(message.getValue().toString());
                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(tText, null);
            } catch (HeadlessException e) {
                dataGenApplication.getMainWindow()
                        .showNotification("Due to some problem Text could not be copied.");
                e.printStackTrace();
            }
        }
    });
    copy.setIcon(DataGenConstant.COPY_ICON);

    Button execute = new Button("Execute", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Execute Button clicked");
            dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.executor);
            dataGenApplication.executor.setScript(message.getValue().toString());
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    execute.setIcon(DataGenConstant.EXECUTOR_ICON);

    Button export = new Button("Export to File", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Export to File Button clicked");
            String dataOption = dataGenApplication.generateType.getValue().toString();
            DataGenStreamUtil resource = null;
            try {
                if (dataOption.equalsIgnoreCase("xml")) {
                    File tempFile = File.createTempFile("tmp", ".xml");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.xml", "text/xml", tempFile);
                } else if (dataOption.equalsIgnoreCase("csv")) {
                    File tempFile = File.createTempFile("tmp", ".csv");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.csv", "text/csv", tempFile);
                } else if (dataOption.equalsIgnoreCase("sql")) {
                    File tempFile = File.createTempFile("tmp", ".sql");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.sql", "text/plain", tempFile);
                }
                getWindow().open(resource, "_self");
            } catch (FileNotFoundException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (Exception e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            }
        }
    });
    export.setIcon(DataGenConstant.EXPORT_ICON);

    HorizontalLayout bttnBar = new HorizontalLayout();
    if (dataOption.equalsIgnoreCase("sql")) {
        bttnBar.addComponent(execute);
    }
    bttnBar.addComponent(export);
    bttnBar.addComponent(copy);
    bttnBar.addComponent(close);
    layout.addComponent(bttnBar);
    layout.setComponentAlignment(bttnBar, Alignment.MIDDLE_CENTER);
    log.debug("ResultView constructor end");
}

From source file:com.etest.view.notification.NotificationMainUI.java

Table populateNoficationTable() {
    notificationTable.removeAllItems();/*from w w  w  .j av  a 2s .  c  o  m*/
    int i = 0;
    for (EtestNotification en : ns.getAllNotificationByUser(
            CommonUtilities.convertStringToInt(VaadinSession.getCurrent().getAttribute("userId").toString()))) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button read = new Button();
        read.setWidthUndefined();
        read.setCaption((en.getStatus() == 0) ? "unread" : "read");
        read.setData(en.getNotificationId());
        read.setIcon(FontAwesome.VIDEO_CAMERA);
        read.addStyleName(ValoTheme.BUTTON_LINK);
        read.addStyleName(ValoTheme.BUTTON_TINY);
        read.addStyleName(ValoTheme.BUTTON_QUIET);
        read.addStyleName("button-container");
        read.addClickListener(buttonClickListener);
        v.addComponent(read);
        v.setComponentAlignment(read, Alignment.MIDDLE_LEFT);

        message.setContentMode(ContentMode.HTML);

        String[] split = en.getNotice().split(" ");
        int cellCaseId;
        if (split[0].equals("CellCaseID")) {
            message.setCaption(en.getRemarks() + en.getNotice());
            cellCaseId = CommonUtilities.convertStringToInt(split[1].replace("#", ""));
        } else {
            cellCaseId = cis.getCellItemById(CommonUtilities.convertStringToInt(split[1].replace("#", "")))
                    .getCellCaseId();
            message.setCaption(en.getRemarks() + en.getNotice() + " from CellCaseID #" + cellCaseId);
        }

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (ccs.getCellCaseById(cellCaseId).getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        notificationTable.addItem(new Object[] { message.getCaption().toString(),
                ss.getUsernameById(en.getSenderId()), en.getNoteDate(), v }, i);
        i++;
    }
    notificationTable.setPageLength(0);
    notificationTable.setHeight("100%");

    return notificationTable;
}

From source file:com.etest.view.systemadministration.HousekeepingMainUI.java

Table populateDataTable() {
    table.removeAllItems();/*from w w  w  . ja v  a 2 s. c  o m*/
    int i = 0;
    for (CellItem ci : hs.getAllItemsFromArchive()) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button recycle = new Button("recycle");
        recycle.setWidthUndefined();
        recycle.setData(ci.getCellItemId());
        recycle.setIcon(FontAwesome.RECYCLE);
        recycle.addStyleName(ValoTheme.BUTTON_LINK);
        recycle.addStyleName(ValoTheme.BUTTON_TINY);
        recycle.addStyleName(ValoTheme.BUTTON_QUIET);
        recycle.addStyleName("button-container");
        v.addComponent(recycle);
        v.setComponentAlignment(recycle, Alignment.MIDDLE_LEFT);

        Button view = new Button("view");
        view.setWidthUndefined();
        view.setData(ci.getCellItemId());
        view.setIcon(FontAwesome.COFFEE);
        view.addStyleName(ValoTheme.BUTTON_LINK);
        view.addStyleName(ValoTheme.BUTTON_TINY);
        view.addStyleName(ValoTheme.BUTTON_QUIET);
        view.addStyleName("button-container");
        view.addClickListener(buttonClickListener);
        v.addComponent(view);
        v.setComponentAlignment(view, Alignment.MIDDLE_LEFT);

        table.addItem(new Object[] { ci.getCellItemId(), ci.getItem(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}

From source file:com.etest.view.testbank.CellCaseMainUI.java

Table populateDataTable() {
    table.removeAllItems();/*w w w . j  a v  a2 s .  c  o  m*/
    int i = 0;
    for (CellCase cc : ccs.getCellCaseByTopic(getSyllabusId())) {
        VerticalLayout v = new VerticalLayout();
        v.setWidth("100%");

        Button edit = new Button("modify");
        edit.setSizeFull();
        edit.setData(cc.getCellCaseId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName(ValoTheme.BUTTON_QUIET);
        edit.addStyleName("button-container");
        edit.addClickListener(modifyBtnClickListener);
        v.addComponent(edit);
        v.setComponentAlignment(edit, Alignment.MIDDLE_LEFT);

        Button approve = new Button("status");
        approve.setSizeFull();
        approve.setData(cc.getCellCaseId());
        approve.addStyleName(ValoTheme.BUTTON_LINK);
        approve.addStyleName(ValoTheme.BUTTON_TINY);
        approve.addStyleName(ValoTheme.BUTTON_QUIET);
        approve.addStyleName("button-container");
        v.addComponent(approve);
        v.setComponentAlignment(approve, Alignment.MIDDLE_LEFT);

        if (cc.getApprovalStatus() == 0) {
            approve.setIcon(FontAwesome.THUMBS_DOWN);
        } else {
            approve.setIcon(FontAwesome.THUMBS_UP);
        }

        Button stem = new Button("stems");
        stem.setSizeFull();
        stem.setData(cc.getCellCaseId());
        stem.setIcon(FontAwesome.BRIEFCASE);
        stem.addStyleName(ValoTheme.BUTTON_LINK);
        stem.addStyleName(ValoTheme.BUTTON_TINY);
        stem.addStyleName(ValoTheme.BUTTON_QUIET);
        stem.addStyleName("button-container");
        stem.addClickListener(stemBtnClickListener);
        v.addComponent(stem);
        v.setComponentAlignment(stem, Alignment.MIDDLE_LEFT);

        Label label = new Label(cc.getCaseTopic(), ContentMode.HTML);
        label.setStyleName("label-padding");

        table.addItem(new Object[] { cc.getCellCaseId(), label, cc.getUsername_(), cc.getDateCreated(), v }, i);
        i++;
    }
    table.setPageLength(table.size());

    return table;
}