Example usage for com.vaadin.ui Label setWidth

List of usage examples for com.vaadin.ui Label setWidth

Introduction

In this page you can find the example usage for com.vaadin.ui Label setWidth.

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

From source file:ru.codeinside.adm.ui.employee.TableEmployee.java

License:Mozilla Public License

public static MaskedTextField addMaskedTextField(AbstractComponentContainer container, String widthColumn,
        String content) {//ww  w. j  av  a2  s.  c o  m
    HorizontalLayout l;
    l = new HorizontalLayout();
    Label label = new Label(content);
    label.setWidth(widthColumn);
    l.addComponent(label);
    l.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    final MaskedTextField field = new MaskedTextField();
    l.addComponent(field);
    container.addComponent(l);
    return field;
}

From source file:ru.codeinside.adm.ui.employee.TableEmployee.java

License:Mozilla Public License

public static PasswordField addPasswordField(AbstractComponentContainer container, String widthColumn,
        String content) {//from  www.j av  a2 s .  c  om
    HorizontalLayout l;
    l = new HorizontalLayout();
    Label label = new Label(content);
    label.setWidth(widthColumn);
    l.addComponent(label);
    l.setComponentAlignment(label, Alignment.MIDDLE_LEFT);
    final PasswordField field = new PasswordField();
    l.addComponent(field);
    container.addComponent(l);
    return field;
}

From source file:ru.codeinside.adm.ui.employee.TableEmployee.java

License:Mozilla Public License

protected void edit(final CustomTable table) {
    final Item item = table.getItem(table.getValue());
    final String login = (String) item.getItemProperty("login").getValue();
    final UserItem userItem = AdminServiceProvider.get().getUserItem(login);
    final Pattern snilsPattern = Pattern.compile("\\d{11}");
    final Pattern splitSnilsPattern = Pattern.compile("(\\d{3})(\\d{3})(\\d{3})(\\d{2})");

    final Panel layout = new Panel();
    ((Layout.SpacingHandler) layout.getContent()).setSpacing(true);
    layout.setSizeFull();//from w ww .j  a v a  2 s.  c  o  m
    layout.addComponent(new Label("? ? " + login));

    String widthColumn = "100px";

    final PasswordField fieldPass = addPasswordField(layout, widthColumn, "");
    final PasswordField fieldPassRepeat = addPasswordField(layout, widthColumn,
            " ?");
    fieldPassRepeat.addValidator(new RepeatPasswordValidator(fieldPass));
    final MaskedTextField fieldSnils = addMaskedTextField(layout, widthColumn, "?");
    fieldSnils.setMask("###-###-### ##");
    final TextField fieldFIO = addTextField(layout, widthColumn, "");
    final String snils = userItem.getSnils() == null ? "" : userItem.getSnils();
    final Matcher maskMatcher = snilsPattern.matcher(snils);
    final Matcher splitMatcher = splitSnilsPattern.matcher(snils);
    if (maskMatcher.matches()) {
        String maskedSnils = splitMatcher.replaceAll("$1-$2-$3 $4");
        fieldSnils.setValue(maskedSnils);
    }
    fieldFIO.setValue(userItem.getFio());

    HorizontalLayout l1 = new HorizontalLayout();
    Label labelRole = new Label("");
    labelRole.setWidth(widthColumn);
    l1.addComponent(labelRole);
    l1.setComponentAlignment(labelRole, Alignment.MIDDLE_LEFT);
    final OptionGroup roleOptionGroup = TableEmployee.createRoleOptionGroup(null);
    roleOptionGroup.setValue(userItem.getRoles());
    l1.addComponent(roleOptionGroup);
    layout.addComponent(l1);

    final CertificateBlock certificateBlock = new CertificateBlock(userItem);
    layout.addComponent(certificateBlock);

    final ExecutorGroupsBlock executorGroupsBlock = new ExecutorGroupsBlock(userItem);
    layout.addComponent(executorGroupsBlock);

    final HorizontalLayout supervisorGroupsEmp = new HorizontalLayout();
    supervisorGroupsEmp.setMargin(true, true, true, false);
    supervisorGroupsEmp.setSpacing(true);
    supervisorGroupsEmp
            .setCaption("?  ? ? ?");
    final FilterTable allSupervisorGroupsEmp = new FilterTable();
    allSupervisorGroupsEmp.setCaption("?");
    table(supervisorGroupsEmp, allSupervisorGroupsEmp);
    final FilterTable currentSupervisorGroupsEmp = new FilterTable();
    currentSupervisorGroupsEmp.setCaption("");
    table(supervisorGroupsEmp, currentSupervisorGroupsEmp);
    for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) {
        for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) {
            if (userItem.getEmployeeGroups().contains(groupName)) {
                currentSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            } else {
                allSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            }
        }
    }
    addListener(allSupervisorGroupsEmp, currentSupervisorGroupsEmp);
    addListener(currentSupervisorGroupsEmp, allSupervisorGroupsEmp);
    layout.addComponent(supervisorGroupsEmp);

    final HorizontalLayout supervisorGroupsOrg = new HorizontalLayout();
    supervisorGroupsOrg.setMargin(true, true, true, false);
    supervisorGroupsOrg.setSpacing(true);
    supervisorGroupsOrg
            .setCaption("?   ? ?");
    final FilterTable allSupervisorGroupsOrg = new FilterTable();
    allSupervisorGroupsOrg.setCaption("?");
    table(supervisorGroupsOrg, allSupervisorGroupsOrg);
    final FilterTable currentSupervisorGroupsOrg = new FilterTable();
    currentSupervisorGroupsOrg.setCaption("");
    table(supervisorGroupsOrg, currentSupervisorGroupsOrg);
    for (String groupName : AdminServiceProvider.get().getOrgGroupNames()) {
        for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) {
            if (userItem.getOrganizationGroups().contains(groupName)) {
                currentSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            } else {
                allSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            }
        }
    }
    addListener(allSupervisorGroupsOrg, currentSupervisorGroupsOrg);
    addListener(currentSupervisorGroupsOrg, allSupervisorGroupsOrg);
    layout.addComponent(supervisorGroupsOrg);

    setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp,
            supervisorGroupsOrg);
    roleOptionGroup.addListener(new Listener() {
        private static final long serialVersionUID = 1L;

        public void componentEvent(Event event) {
            setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock, supervisorGroupsEmp,
                    supervisorGroupsOrg);
        }
    });

    Button cancel = new Button("", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            removeComponent(layout);
            addComponent(table);
            table.setValue(null);
            if (hr != null) {
                hr.setVisible(true);
            }
            setExpandRatio(table, 1f);
        }
    });

    Button apply = new Button("", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String password = (String) fieldPass.getValue();
            String passwordRepeat = (String) fieldPassRepeat.getValue();
            if (!fieldPassRepeat.isValid() || !(password.equals(passwordRepeat))) {
                getWindow().showNotification(
                        "?   ? ?  ?",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            String snilsFieldValue = fieldSnils.getValue() == null ? "" : (String) fieldSnils.getValue();
            String snilsValue = snilsFieldValue.replaceAll("\\D+", "");
            Matcher snilsMatcher = snilsPattern.matcher(snilsValue);

            if (!snilsFieldValue.isEmpty() && !snilsMatcher.matches()) {
                getWindow().showNotification("?  ",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            if (!AdminServiceProvider.get().isUniqueSnils(login, snilsValue)) {
                getWindow().showNotification(" ?  ",
                        Window.Notification.TYPE_ERROR_MESSAGE);
                return;
            }

            String fio = (String) fieldFIO.getValue();
            Set<Role> roles = (Set) roleOptionGroup.getValue();

            TreeSet<String> groupExecutor = executorGroupsBlock.getGroups();
            TreeSet<String> groupSupervisorEmp = new TreeSet<String>(
                    (Collection<String>) currentSupervisorGroupsEmp.getItemIds());
            TreeSet<String> groupSupervisorOrg = new TreeSet<String>(
                    (Collection<String>) currentSupervisorGroupsOrg.getItemIds());

            boolean modified = false;

            if (certificateBlock.isCertificateWasRemoved()) {
                userItem.setX509(null);
                modified = true;
            }

            if (!password.equals("") && password.equals(passwordRepeat)) {
                userItem.setPassword1(password);
                userItem.setPassword2(passwordRepeat);
                modified = true;
            }
            if (!fio.trim().equals("") && !fio.equals(userItem.getFio())) {
                userItem.setFio(fio);
                userItem.setX509(null);
                modified = true;
            }
            if (!snilsValue.equals(userItem.getSnils())) {
                userItem.setSnils(snilsValue);
                modified = true;
            }
            if (!roles.equals(userItem.getRoles())) {
                userItem.setRoles(roles);
                modified = true;
            }
            if (!groupExecutor.equals(userItem.getGroups())) {
                userItem.setGroups(groupExecutor);
                modified = true;
            }
            if (!groupSupervisorEmp.equals(userItem.getEmployeeGroups())) {
                userItem.setEmployeeGroups(groupSupervisorEmp);
                modified = true;
            }
            if (!groupSupervisorOrg.equals(userItem.getOrganizationGroups())) {
                userItem.setOrganizationGroups(groupSupervisorOrg);
                modified = true;
            }

            if (modified) {
                // TODO :  userInfoPanel
                // if (getApplication().getUser().equals(login)) {
                // ((AdminApp) getApplication()).getUserInfoPanel().setRole(
                // userItem.getRoles().toString());
                // }
                AdminServiceProvider.get().setUserItem(login, userItem);
                final Container container = table.getContainerDataSource();
                if (container instanceof LazyLoadingContainer2) {
                    ((LazyLoadingContainer2) container).fireItemSetChange();
                }
                getWindow().showNotification(" " + login + " ");
            } else {
                getWindow().showNotification(" ");
            }

            removeComponent(layout);
            addComponent(table);
            table.setValue(null);
            if (hr != null) {
                hr.setVisible(true);
            }
            setExpandRatio(table, 1f);
            refresh(table);
        }
    });

    cancel.setClickShortcut(KeyCode.ESCAPE, 0);
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(apply);
    buttons.addComponent(cancel);
    layout.addComponent(buttons);
    removeComponent(table);
    addComponent(layout);
    setExpandRatio(layout, 1f);
}

From source file:ru.codeinside.adm.ui.TreeTableOrganization.java

License:Mozilla Public License

private Component buttonCreateEmployee(final Long id) {
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from   ww  w  .  ja  v a  2s .  co m*/
    buttons.setMargin(false, true, false, false);
    addComponent(buttons);
    Button createUser = new Button(" ?", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            showOrganizationLabelsAndButtons(id);
            final VerticalLayout layout = new VerticalLayout();
            layout.setMargin(true);
            layout.setSpacing(true);
            layout.setSizeFull();
            panel.addComponent(layout);

            String widthColumn = "100px";
            final TextField fieldLogin = TableEmployee.addTextField(layout, widthColumn, "");
            final PasswordField fieldPass = TableEmployee.addPasswordField(layout, widthColumn, "");
            final PasswordField fieldPassRepeat = TableEmployee.addPasswordField(layout, widthColumn,
                    " ");
            final MaskedTextField fieldSnils = TableEmployee.addMaskedTextField(layout, widthColumn,
                    "?");
            fieldSnils.setMask("###-###-### ##");
            fieldPassRepeat.addValidator(new RepeatPasswordValidator(fieldPass));
            final TextField fieldFIO = TableEmployee.addTextField(layout, widthColumn, "");
            HorizontalLayout l1 = new HorizontalLayout();
            Label labelRole = new Label("");
            labelRole.setWidth(widthColumn);
            l1.addComponent(labelRole);
            l1.setComponentAlignment(labelRole, Alignment.MIDDLE_LEFT);
            final OptionGroup roleOptionGroup = TableEmployee.createRoleOptionGroup(null);
            l1.addComponent(roleOptionGroup);
            layout.addComponent(l1);

            UserItem emptyItem = new UserItem();
            emptyItem.setGroups(ImmutableSet.<String>of());

            final CertificateBlock certificateBlock = new CertificateBlock(emptyItem);
            layout.addComponent(certificateBlock);

            final ExecutorGroupsBlock executorGroupsBlock = new ExecutorGroupsBlock(emptyItem);
            layout.addComponent(executorGroupsBlock);

            final HorizontalLayout supervisorGroupsEmp = new HorizontalLayout();
            supervisorGroupsEmp.setMargin(true, true, true, false);
            supervisorGroupsEmp.setSpacing(true);
            supervisorGroupsEmp.setCaption(
                    "?  ? ? ?");
            final FilterTable allSupervisorGroupsEmp = new FilterTable();
            allSupervisorGroupsEmp.setCaption("?");
            TableEmployee.table(supervisorGroupsEmp, allSupervisorGroupsEmp);
            final FilterTable currentSupervisorGroupsEmp = new FilterTable();
            currentSupervisorGroupsEmp.setCaption("");
            TableEmployee.table(supervisorGroupsEmp, currentSupervisorGroupsEmp);
            for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) {
                for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) {
                    allSupervisorGroupsEmp.addItem(new Object[] { groupName, group.getTitle() }, groupName);
                }
            }
            TableEmployee.addListener(allSupervisorGroupsEmp, currentSupervisorGroupsEmp);
            TableEmployee.addListener(currentSupervisorGroupsEmp, allSupervisorGroupsEmp);
            layout.addComponent(supervisorGroupsEmp);

            final HorizontalLayout supervisorGroupsOrg = new HorizontalLayout();
            supervisorGroupsOrg.setMargin(true, true, true, false);
            supervisorGroupsOrg.setSpacing(true);
            supervisorGroupsOrg.setCaption(
                    "?   ? ?");
            final FilterTable allSupervisorGroupsOrg = new FilterTable();
            allSupervisorGroupsOrg.setCaption("?");
            TableEmployee.table(supervisorGroupsOrg, allSupervisorGroupsOrg);
            final FilterTable currentSupervisorGroupsOrg = new FilterTable();
            currentSupervisorGroupsOrg.setCaption("");
            TableEmployee.table(supervisorGroupsOrg, currentSupervisorGroupsOrg);
            for (String groupName : AdminServiceProvider.get().getOrgGroupNames()) {
                for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) {
                    allSupervisorGroupsOrg.addItem(new Object[] { groupName, group.getTitle() }, groupName);
                }
            }
            TableEmployee.addListener(allSupervisorGroupsOrg, currentSupervisorGroupsOrg);
            TableEmployee.addListener(currentSupervisorGroupsOrg, allSupervisorGroupsOrg);
            layout.addComponent(supervisorGroupsOrg);

            TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock,
                    supervisorGroupsEmp, supervisorGroupsOrg);
            roleOptionGroup.addListener(new Listener() {
                private static final long serialVersionUID = 1L;

                public void componentEvent(Event event) {
                    TableEmployee.setRolesEnabled(roleOptionGroup, certificateBlock, executorGroupsBlock,
                            supervisorGroupsEmp, supervisorGroupsOrg);
                }
            });

            HorizontalLayout l2 = new HorizontalLayout();
            Label labelPrint = new Label("?  ?");
            labelPrint.setWidth(widthColumn);
            l2.addComponent(labelPrint);
            l2.setComponentAlignment(labelPrint, Alignment.MIDDLE_LEFT);
            final CheckBox checkBoxPrint = new CheckBox();
            checkBoxPrint.setDescription("?  ?");
            l2.addComponent(checkBoxPrint);
            layout.addComponent(l2);

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

            Button buttonUserForm = new Button("", new Button.ClickListener() {

                private static final long serialVersionUID = -7193894183022375021L;

                public void buttonClick(ClickEvent event) {
                    if (!fieldPassRepeat.isValid()) {
                        return;
                    }

                    String snilsFieldValue = fieldSnils.getValue() == null ? ""
                            : (String) fieldSnils.getValue();
                    String snilsValue = snilsFieldValue.replaceAll("\\D+", "");
                    Pattern snilsPattern = Pattern.compile("\\d{11}");
                    Matcher snilsMatcher = snilsPattern.matcher(snilsValue);

                    if (!snilsFieldValue.isEmpty() && !snilsMatcher.matches()) {
                        getWindow().showNotification("?  ",
                                Window.Notification.TYPE_ERROR_MESSAGE);
                        return;
                    }

                    String loginUser = (String) fieldLogin.getValue();

                    if (!AdminServiceProvider.get().isUniqueSnils(loginUser, snilsValue)) {
                        getWindow().showNotification(" ?  ",
                                Window.Notification.TYPE_ERROR_MESSAGE);
                        return;
                    }

                    String password = (String) fieldPass.getValue();
                    String passwordRepeat = (String) fieldPassRepeat.getValue();
                    String fio = (String) fieldFIO.getValue();
                    Set<Role> roles = (Set) roleOptionGroup.getValue();
                    TreeSet<String> groupExecutor = executorGroupsBlock.getGroups();
                    TreeSet<String> groupSupervisorEmp = new TreeSet<String>(
                            (Collection<String>) currentSupervisorGroupsEmp.getItemIds());
                    TreeSet<String> groupSupervisorOrg = new TreeSet<String>(
                            (Collection<String>) currentSupervisorGroupsOrg.getItemIds());

                    if (loginUser.equals("") || password.equals("") || passwordRepeat.equals("")
                            || fio.equals("")) {
                        getWindow().showNotification(" ? ?!",
                                Notification.TYPE_WARNING_MESSAGE);
                    } else if (!(password.equals(passwordRepeat))) {
                        getWindow().showNotification("  ?!",
                                Notification.TYPE_WARNING_MESSAGE);
                    } else if (AdminServiceProvider.get().findEmployeeByLogin(loginUser) == null) {
                        if (roles.contains(Role.SuperSupervisor)) {
                            groupSupervisorEmp = new TreeSet<String>(
                                    AdminServiceProvider.get().selectGroupNamesBySocial(true));
                            groupSupervisorOrg = new TreeSet<String>(
                                    AdminServiceProvider.get().selectGroupNamesBySocial(false));
                        }
                        String creator = getApplication().getUser().toString();
                        AdminServiceProvider.get().createEmployee(loginUser, password, fio, snilsValue, roles,
                                creator, id, groupExecutor, groupSupervisorEmp, groupSupervisorOrg);
                        showOrganization(id);
                        getWindow().showNotification(" " + loginUser + " ?");
                        if (checkBoxPrint.booleanValue()) {
                            // Create a window that contains what you want to print
                            Window window = new Window();
                            window.addComponent(new Label("<h1>: " + loginUser + "</h1>\n"
                                    + "<h1>: " + password + "</h1>\n", Label.CONTENT_XHTML));
                            getApplication().addWindow(window);
                            getWindow().open(new ExternalResource(window.getURL()), "_blank", 500, 200, // Width and
                                    // height
                                    Window.BORDER_NONE);
                            window.executeJavaScript("print();");
                            window.executeJavaScript("self.close();");
                        }
                    } else {
                        getWindow().showNotification(" ?!",
                                Notification.TYPE_WARNING_MESSAGE);
                    }

                }
            });
            layoutButton.addComponent(buttonUserForm);
            Button buttonCancel = new Button("", new Button.ClickListener() {

                private static final long serialVersionUID = 1L;

                public void buttonClick(ClickEvent event) {
                    showOrganization(id);
                }
            });
            layoutButton.addComponent(buttonCancel);
            layout.addComponent(layoutButton);

        }

    });
    createUser.addListener(this);
    buttons.addComponent(createUser);
    return buttons;
}

From source file:ru.codeinside.gses.manager.processdefeniton.ProcessDefenitionQuery.java

License:Mozilla Public License

PropertysetItem createItem(final ProcedureProcessDefinition p) {
    PropertysetItem item = new PropertysetItem();

    ClickListener listener = new ClickListener() {

        private static final long serialVersionUID = -8900212370037948964L;

        @Override/*  ww  w.j ava2  s  . c o  m*/
        public void buttonClick(ClickEvent event) {
            Window mainWin = event.getButton().getApplication().getMainWindow();

            ProcessDefinition processDefinition = Functions.withRepository(Flash.login(),
                    new Function<RepositoryService, ProcessDefinition>() {
                        public ProcessDefinition apply(RepositoryService srv) {
                            return srv.createProcessDefinitionQuery()
                                    .processDefinitionId(p.getProcessDefinitionId()).singleResult();
                        }
                    });

            String caption = "?? " + df.format(p.getVersion());
            Window win = Components.createWindow(mainWin, caption);
            win.center();
            ContentWindowChanger changer = new ContentWindowChanger(win);
            ProcessDefinitionShowUi putComponent = new ProcessDefinitionShowUi(processDefinition, changer);
            changer.set(putComponent, caption);
        }

    };
    ObjectProperty<Component> versionProperty = Components.buttonProperty(df.format(p.getVersion()), listener);
    item.addItemProperty("version", versionProperty);

    HorizontalLayout ll = new HorizontalLayout();
    ll.setSpacing(true);
    DefinitionStatus status = p.getStatus();
    final Label label = new Label(status.getLabelName());
    label.setWidth("100px");
    ll.addComponent(label);

    final ComboBox comboBox = new ComboBox();
    comboBox.setWidth("100px");
    comboBox.setNullSelectionAllowed(false);
    for (DefinitionStatus s : status.getAvailableStatus()) {
        comboBox.addItem(s.getLabelName());
        comboBox.setValue(s.getLabelName());
    }
    if (!status.equals(DefinitionStatus.PathToArchive) && !status.getAvailableStatus().isEmpty()) {
        ll.addComponent(comboBox);
        Button c = new Button("ok");
        c.addListener(new ClickListener() {

            private static final long serialVersionUID = 2966059295049064338L;

            @Override
            public void buttonClick(ClickEvent event) {
                Object value = comboBox.getValue();
                final String newValue = value.toString();
                final DefinitionStatus newStatus = DefinitionStatus.getStatusByLabelName(newValue);

                if (DefinitionStatus.Work.equals(newStatus)) {
                    final List<ProcedureProcessDefinition> works = ManagerService.get()
                            .getProcessDefenitionWithStatus(p, DefinitionStatus.Work);
                    if (!works.isEmpty()) {
                        final Window thisWindow = event.getButton().getWindow();
                        comfirmAction(thisWindow, p, label, newValue, newStatus, works);
                        return;

                    }
                }

                ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(), newStatus);

                label.setValue(null);
                label.setCaption(newValue);
                paramLazyLoadingContainer.fireItemSetChange();
                proceduresContainer.fireItemSetChange();
            }

            private void comfirmAction(final Window thisWindow, final ProcedureProcessDefinition p,
                    final Label label, final String newValue, final DefinitionStatus newStatus,
                    final List<ProcedureProcessDefinition> works) {

                final Window window = new Window();
                window.setModal(true);
                window.setContent(new HorizontalLayout());
                window.setCaption(" ? " + df.format(works.get(0).getVersion())
                        + "       ?   ??  ");
                Button save = new Button("");
                save.addListener(new ClickListener() {

                    private static final long serialVersionUID = 3229924940535642819L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(),
                                newStatus);
                        label.setValue(null);
                        label.setCaption(newValue);
                        paramLazyLoadingContainer.fireItemSetChange();
                        proceduresContainer.fireItemSetChange();
                        closeWindow(thisWindow, window);
                    }

                });

                window.addComponent(save);
                Button c2 = new Button("?");
                c2.addListener(new ClickListener() {

                    private static final long serialVersionUID = 4502614143261892063L;

                    @Override
                    public void buttonClick(ClickEvent event) {
                        closeWindow(thisWindow, window);
                    }
                });
                window.addComponent(c2);
                thisWindow.addWindow(window);
            }
        });
        ll.addComponent(c);
    }
    item.addItemProperty("status", new ObjectProperty<Component>(ll));
    item.addItemProperty("date", Components.stringProperty(formatter.format(p.getDateCreated())));
    Employee creator = p.getCreator();
    item.addItemProperty("user", Components.stringProperty(creator == null ? null : creator.getLogin()));

    Button b = new Button("");

    b.addListener(new ClickListener() {

        private static final long serialVersionUID = 1362078893385574138L;

        @Override
        public void buttonClick(ClickEvent event) {
            StreamSource streamSource = new StreamSource() {

                private static final long serialVersionUID = 456334952891567271L;

                public InputStream getStream() {
                    return Functions.withEngine(new PF<InputStream>() {
                        private static final long serialVersionUID = 1L;

                        public InputStream apply(ProcessEngine s) {
                            return s.getRepositoryService().getProcessModel(p.getProcessDefinitionId());
                        }
                    });
                }
            };
            final Application application = event.getButton().getApplication();
            StreamResource resource = new StreamResource(streamSource, "test" + ".xml", application) {
                private static final long serialVersionUID = -3869546661105572851L;

                public DownloadStream getStream() {
                    final StreamSource ss = getStreamSource();
                    if (ss == null) {
                        return null;
                    }
                    final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename());
                    ds.setBufferSize(getBufferSize());
                    ds.setCacheTime(getCacheTime());
                    ds.setParameter("Content-Disposition", "attachment; filename=" + getFilename());
                    return ds;
                }
            };
            Window window = event.getButton().getWindow();
            window.open(resource);
        }
    });
    item.addItemProperty("getRoute", new ObjectProperty<Component>(b));

    ObjectProperty<Component> buttonProperty = null;

    if (status.equals(DefinitionStatus.Debugging)) {
        DeploymentUploadReceiver receiver = new DeploymentUploadReceiver();

        DeploymentSucceededListener succeededListener = new DeploymentSucceededListener(receiver, procedureId,
                p.getProcessDefinitionId());
        succeededListener.addLoadingContainer(paramLazyLoadingContainer);
        succeededListener.addLoadingContainer(proceduresContainer);
        DeploymentAddUi addUi = new DeploymentAddUi(new DeploymentStartListener(), receiver, succeededListener);

        addUi.setSizeFull();
        buttonProperty = new ObjectProperty<Component>(addUi);
    } else {
        ClickListener l = new ClickListener() {

            private static final long serialVersionUID = 1362078893385574138L;

            @Override
            public void buttonClick(ClickEvent event) {

            }
        };
        buttonProperty = Components.buttonProperty("", l);
    }

    item.addItemProperty("download", buttonProperty);
    return item;
}

From source file:se.natusoft.osgi.aps.apsadminweb.app.gui.vaadin.LogoPanel.java

License:Open Source License

public LogoPanel(Button.ClickListener clickListener) {
    super();/*from   w w  w  .ja  v a  2  s .  co  m*/
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setMargin(true, true, false, true);
    setContent(topLayout);
    setStyleName(Reindeer.PANEL_LIGHT);

    ThemeResource logo = new ThemeResource("images/app-platform-services.png");
    Label logoLabel = new Label();
    logoLabel.setWidth("300px");
    logoLabel.setIcon(logo);

    addComponent(logoLabel);

    Label textLabel = new Label("<font size='+1'><b>Admin Web</b></font>");
    textLabel.setContentMode(Label.CONTENT_XHTML);
    addComponent(textLabel);

    Button refreshButton = new Button("Refresh", clickListener);
    refreshButton.setStyleName(BaseTheme.BUTTON_LINK);
    addComponent(refreshButton);
}

From source file:steps.SummaryRegisterStep.java

License:Open Source License

public SummaryRegisterStep() {
    main = new VerticalLayout();
    main.setMargin(true);//from  www  . j a  v a2 s.  c om
    main.setSpacing(true);
    Label header = new Label("Sample Registration");
    main.addComponent(Styles.questionize(header,
            "Here you can download a spreadsheet of the samples in your experiment "
                    + "and register your project in the database. "
                    + "Registering samples may take a few seconds.",
            "Sample Registration"));

    summary = new ExperimentSummaryTable();

    summaryComponent = new CustomVisibilityComponent(Styles.questionize(summary,
            "This is a summary of samples for Sample Sources/Patients, Tissue Extracts and "
                    + "samples that will be measured.",
            "Experiment Summary"));
    summaryComponent.setVisible(false);
    main.addComponent(summaryComponent.getInnerComponent());

    downloadTSV = new Button("Download Spreadsheet");
    downloadTSV.setEnabled(false);
    HorizontalLayout tsvInfo = new HorizontalLayout();
    tsvInfo.addComponent(downloadTSV);
    main.addComponent(Styles.questionize(tsvInfo,
            "You can download a technical spreadsheet to register your samples at a later time instead. More informative spreadsheets are available in the next step.",
            "TSV Download"));

    Container cont = new IndexedContainer();
    cont.addContainerProperty("caption", String.class, "");
    cont.getContainerProperty(cont.addItem(), "caption").setValue(paidOption);
    cont.getContainerProperty(cont.addItem(), "caption").setValue(freeOption);
    optionGroup = new FlexibleOptionGroup(cont);
    optionGroup.setItemCaptionPropertyId("caption");

    optionLayout = new VerticalLayout();
    Iterator<FlexibleOptionGroupItemComponent> iter;
    iter = optionGroup.getItemComponentIterator();
    while (iter.hasNext()) {
        FlexibleOptionGroupItemComponent fogItemComponent = iter.next();
        Label caption = new Label(fogItemComponent.getCaption());
        caption.setWidth("400px");
        optionLayout.addComponent(new HorizontalLayout(fogItemComponent, caption));
    }

    main.addComponent(optionLayout);
    optionGroup.addValueChangeListener(new ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            testRegEnabled();
        }
    });

    register = new Button("Register All Samples");
    register.setEnabled(false);
    main.addComponent(register);

    registerInfo = new Label();
    bar = new ProgressBar();
    main.addComponent(registerInfo);
    main.addComponent(bar);
}

From source file:views.StandaloneTSVImport.java

License:Open Source License

private Component createTSVDownloadComponent(DesignType type, String info) {
    VerticalLayout v = new VerticalLayout();
    v.setSpacing(true);/*from  w  w  w  . j  av  a  2 s  . c o m*/
    Label l = new Label(info);
    l.setWidth("300px");
    v.addComponent(l);
    Button button = new Button("Download Example");
    v.addComponent(button);

    String basepath = VaadinService.getCurrent().getBaseDirectory().getAbsolutePath();
    FileDownloader tsvDL = new FileDownloader(
            new FileResource(new File(basepath + "/WEB-INF/files/" + type.getFileName())));
    tsvDL.extend(button);

    return v;
}