Example usage for com.vaadin.ui Button addListener

List of usage examples for com.vaadin.ui Button addListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

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

License:Mozilla Public License

protected void view(final AbstractSelect table) {
    final String login = (String) table.getItem(table.getValue()).getItemProperty("login").getValue();
    Button cancel = new Button("?");
    EmployeeInfo info = new EmployeeInfo(login, cancel);
    cancel.addListener(new BackAction(info, table));
    cancel.setClickShortcut(KeyCode.ESCAPE, 0);
    addComponent(info);/*from   ww w .j a  v a2 s . c o  m*/
    setExpandRatio(info, 1f);
    removeComponent(table);
}

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);/*  w w  w. j  a v a2s  .c  o 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.apservice.ApServiceForm.java

License:Mozilla Public License

private Button createCreateButton() {
    Button createProcedure = new Button("");
    createProcedure.addListener(new ClickListener() {
        private static final long serialVersionUID = -7774602726746226851L;

        @Override/* w  w  w  .ja v a2  s  .  co m*/
        public void buttonClick(ClickEvent event) {
            Field fieldName = createForm.getField(NAME);
            Field fieldCode = createForm.getField(CODE);
            try {
                fieldName.setValue(fieldName.getValue().toString().trim());
                createForm.commit();
            } catch (InvalidValueException e) {
                return;
            }
            String creatorLogin = getApplication().getUser().toString();
            String name = createForm.getField(NAME).getValue().toString();
            List<String> declarantTypes = getDeclarantTypes(
                    (ListSelect) createForm.getField(DeclarantService.DECLARANT_TYPES));
            Long code = null;
            if (fieldCode.getValue() != null) {
                Iterator<Validator> i = fieldCode.getValidators().iterator();
                i.next();// ?  ?
                final FilteredLongValidator flv = (FilteredLongValidator) i.next();
                code = flv.toLong(fieldCode.getValue().toString());
            }
            long apService = ManagerService.get().createApService(name, code, creatorLogin, declarantTypes);
            if (apService == 0) {
                getWindow()
                        .showNotification("? ?    ??");
            } else {
                for (LazyLoadingContainer2 d : dependentContainers) {
                    d.fireItemSetChange();
                }
                getWindow().showNotification("? " + name + " ?");
                createForm.getField(NAME).setValue("");
                createForm.getField(CODE).setValue("");
                createForm.setValidationVisible(false);
                cleanForm();
            }
        }
    });
    return createProcedure;
}

From source file:ru.codeinside.gses.apservice.ApServiceForm.java

License:Mozilla Public License

private Button createUpdateButton() {
    Button updateProcedure = new Button("");
    updateProcedure.addListener(new ClickListener() {
        private static final long serialVersionUID = 7102711218014031544L;

        @Override//from www.j av  a 2  s .  co  m
        public void buttonClick(ClickEvent event) {
            Field fieldName = editForm.getField(NAME);
            Field fieldCode = editForm.getField(CODE);
            try {
                fieldName.setValue(fieldName.getValue().toString().trim());
                editForm.commit();
            } catch (InvalidValueException e) {
                return;
            }
            String id = editForm.getField(ID).getValue().toString();
            String name = editForm.getField(NAME).getValue().toString();
            List<String> declarantTypes = getDeclarantTypes(
                    (ListSelect) editForm.getField(DeclarantService.DECLARANT_TYPES));
            Long code = null;
            if (fieldCode.getValue() != null) {
                Iterator<Validator> i = fieldCode.getValidators().iterator();
                i.next();// ?  ?
                final FilteredLongValidator flv = (FilteredLongValidator) i.next();
                code = flv.toLong(fieldCode.getValue().toString());
            }
            if (ManagerService.get().updateApservice(id, name, code, declarantTypes)) {
                getWindow()
                        .showNotification("? ?    ??");
            } else {
                for (LazyLoadingContainer2 d : dependentContainers) {
                    d.fireItemSetChange();
                }
                cleanForm();
                getWindow().showNotification("? " + name + " ");
            }
        }
    });
    return updateProcedure;

}

From source file:ru.codeinside.gses.apservice.ApServiceForm.java

License:Mozilla Public License

private Button createCancelButton(final Form form) {
    Button cancelButton = new Button("");
    cancelButton.addListener(new ClickListener() {

        private static final long serialVersionUID = 3836238707161959082L;

        @Override//from www . j  a va  2s  . c  o m
        public void buttonClick(ClickEvent event) {
            cleanForm();
        }
    });
    return cancelButton;
}

From source file:ru.codeinside.gses.manager.ProcedureForm.java

License:Mozilla Public License

private Button createUpdateButton() {
    Button updateProcedure = new Button("");
    updateProcedure.addListener(new ClickListener() {

        private static final long serialVersionUID = -8265937205484323504L;

        @Override/*ww w.  j av a  2s  . c o  m*/
        public void buttonClick(ClickEvent event) {
            Field fieldName = createUpdateForm.getField(NAME);
            Field fieldDescription = createUpdateForm.getField(DESCRIPTION);
            Field fieldCode = createUpdateForm.getField(CODE);
            try {
                // form.validate();
                fieldName.setValue(fieldName.getValue().toString().trim());
                fieldDescription.setValue(fieldDescription.getValue().toString().trim());
                createUpdateForm.commit();
            } catch (InvalidValueException e) {
                return;
            }
            String id = createUpdateForm.getField(ID).getValue().toString();
            String creatorLogin = getApplication().getUser().toString();
            String name = fieldName.getValue().toString();
            String description = fieldDescription.getValue().toString();
            Long code = null;
            if (fieldCode.getValue() != null) {
                Iterator<Validator> i = fieldCode.getValidators().iterator();
                i.next();// ?  ?
                final FilteredLongValidator flv = (FilteredLongValidator) i.next();
                code = flv.toLong(fieldCode.getValue().toString());
            }
            String serviceId = type == ProcedureType.Administrative
                    ? createUpdateForm.getField(SERVICE_ID).getValue().toString()
                    : null;
            try {
                Procedure procedure;
                if (StringUtils.isEmpty(id)) {
                    if (type == ProcedureType.Administrative) {
                        procedure = ManagerService.get().createProcedure(name, description, serviceId, code,
                                creatorLogin, type);
                    } else {
                        procedure = ManagerService.get().createProcedure(name, description, null, code,
                                creatorLogin, type);
                    }
                } else {
                    ManagerService.get().updateProcedure(id, name, description, serviceId, code);
                    procedure = ManagerService.get().getProcedure(id);
                }
                dependentContainer.fireItemSetChange();
                if (procedure != null) {
                    activateProcedureInfo(changer, procedureLayout, procedure);
                }
                getWindow().showNotification(" '" + name + "' ?");
            } catch (RuntimeException e) {
                Throwable cause = e;
                String message = "";
                while (cause instanceof RuntimeException) {
                    Throwable root = cause.getCause();
                    if (root == null) {
                        break;
                    }
                    if (root.getMessage() != null) {
                        message = root.getMessage();
                    }
                    cause = root;
                }
                getWindow().showNotification(
                        StringUtils.isNotEmpty(message) ? message
                                : " ?    ??",
                        Window.Notification.TYPE_ERROR_MESSAGE);
            }
        }
    });
    return updateProcedure;
}

From source file:ru.codeinside.gses.manager.ProcedureForm.java

License:Mozilla Public License

private Button createCancelButton() {
    Button cancelButton = new Button("");
    cancelButton.addListener(new ClickListener() {
        private static final long serialVersionUID = 3836238707161959082L;

        @Override/*from   w  w w  . ja  va2s.  c  o  m*/
        public void buttonClick(ClickEvent event) {
            if (changer.getPrevious() != null && changer.getPrevious().equals(createUpdateForm)
                    && !createUpdateForm.getField(ID).getValue().toString().isEmpty()) {
                editProcButton.setVisible(true);
            }
            changer.back();
        }
    });
    return cancelButton;
}

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//w w  w  .j  ava2 s. com
        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:ru.codeinside.gses.webui.components.ProcessDefinitionShowUi.java

License:Mozilla Public License

private Component buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();/*from  w  w  w.  ja  v a2 s  . c  om*/
    layout.setSpacing(true);
    layout.setMargin(true);

    Label label = new Label();
    String name = getProcessDefinitionById(processDefinitionId).getName();
    label.setCaption(name);
    label.setStyleName(Reindeer.LABEL_H2);

    Button showScheme = new Button("");
    showScheme.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = -5911713385519847639L;

        @Override
        public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
            VerticalLayout imageLayout = new VerticalLayout();
            Button back = new Button("?");
            back.addListener(new Button.ClickListener() {
                private static final long serialVersionUID = 4154712522487297925L;

                @Override
                public void buttonClick(com.vaadin.ui.Button.ClickEvent event) {
                    changer.back();
                }
            });
            imageLayout.addComponent(back);
            imageLayout.setMargin(true);
            imageLayout.setSpacing(true);
            imageLayout.setWidth(1100, Sizeable.UNITS_PIXELS);
            imageLayout.setHeight(600, Sizeable.UNITS_PIXELS);
            final Panel panel = new Panel();
            panel.getContent().setSizeUndefined();
            TaskGraph tg = new TaskGraph(processDefinitionId, null);
            panel.addComponent(tg);
            panel.setSizeFull();
            panel.setScrollable(true);
            imageLayout.addComponent(panel);
            imageLayout.setExpandRatio(back, 0.01f);
            imageLayout.setExpandRatio(panel, 0.99f);
            changer.change(imageLayout);
        }
    });
    layout.addComponent(showScheme);

    Table table = new Table();
    table.setSizeFull();
    table.setImmediate(true);
    table.setSelectable(true);
    table.setSortDisabled(true);
    table.setPageLength(0);
    table.setSelectable(false);
    table.addContainerProperty("id", String.class, null);
    table.addContainerProperty("name", String.class, null);
    table.addContainerProperty("accessPermissions", Component.class, null);
    table.addContainerProperty("formProperties", Component.class, null);
    table.addContainerProperty("other", String.class, null);
    table.setColumnHeaders(new String[] { " ?", "?",
            /*" ?",*/ " ?", "? ",
            "? " });
    table.setColumnExpandRatio("id", 0.1f);
    table.setColumnExpandRatio("name", 0.1f);
    table.setColumnExpandRatio("accessPermissions", 0.1f);
    table.setColumnExpandRatio("formProperties", 0.4f);
    table.setColumnExpandRatio("other", 0.2f);
    fillTable(table);

    layout.addComponent(label);
    layout.setExpandRatio(label, 1);

    layout.addComponent(table);
    layout.setExpandRatio(table, 40);

    return layout;
}

From source file:ru.codeinside.gses.webui.components.UserInfoPanel.java

License:Mozilla Public License

public UserInfoPanel(final String userLogin) {
    setMargin(true);/*  w w  w .ja v  a 2 s  .  c  o m*/
    setWidth("100%");
    Button logoutLink = new Button("");
    logoutLink.setStyleName(BaseTheme.BUTTON_LINK);
    logoutLink.addListener(new Logout());

    addComponent(new EmployeeInfo(userLogin, logoutLink));
}