Example usage for com.vaadin.ui VerticalLayout setExpandRatio

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

Introduction

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

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

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

License:Mozilla Public License

private Panel createMilTaskConfigPanel() {
    VerticalLayout mailConfig = new VerticalLayout();
    mailConfig.setSpacing(true);// www  . java  2s . c  om
    mailConfig.setMargin(true);
    mailConfig.setSizeFull();
    Panel emailTaskPanel = new Panel("?? SMTP ? Email Task", mailConfig);
    emailTaskPanel.setSizeFull();

    final TextField mtDefaultFrom = new TextField("email  :");
    mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM));
    mtDefaultFrom.setRequired(true);
    mtDefaultFrom.setReadOnly(true);
    mtDefaultFrom.addValidator(new EmailValidator("  e-mail ?"));

    final TextField mtSenderLoginField = new TextField(" ?:");
    mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN));
    mtSenderLoginField.setRequired(true);
    mtSenderLoginField.setReadOnly(true);

    final PasswordField mtPasswordField = new PasswordField(":");
    mtPasswordField.setValue(API.MT_PASSWORD);
    mtPasswordField.setRequired(true);
    mtPasswordField.setReadOnly(true);

    final TextField mtHostField = new TextField("SMTP ?:");
    String host = get(API.MT_HOST);
    mtHostField.setValue(host == null ? "" : host);
    mtHostField.setRequired(true);
    mtHostField.setReadOnly(true);

    final TextField mtPortField = new TextField(":");
    String port = get(API.MT_PORT);
    mtPortField.setValue(port == null ? "" : port);
    mtPortField.setRequired(true);
    mtPortField.setReadOnly(true);
    mtPortField.addValidator(new IntegerValidator(" "));

    final CheckBox mtTls = new CheckBox("? TLS",
            AdminServiceProvider.getBoolProperty(API.MT_TLS));
    mtTls.setReadOnly(true);

    final Button save = new Button("");
    save.setVisible(false);
    final Button cancel = new Button("");
    cancel.setVisible(false);
    final Button change = new Button("");

    change.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            mtSenderLoginField.setReadOnly(false);
            mtDefaultFrom.setReadOnly(false);
            mtPasswordField.setReadOnly(false);
            mtHostField.setReadOnly(false);
            mtPortField.setReadOnly(false);
            mtTls.setReadOnly(false);

            change.setVisible(false);
            save.setVisible(true);
            cancel.setVisible(true);
        }
    });
    save.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (StringUtils.isEmpty((String) mtSenderLoginField.getValue())
                    || StringUtils.isEmpty((String) mtDefaultFrom.getValue())
                    || StringUtils.isEmpty((String) mtPasswordField.getValue())
                    || StringUtils.isEmpty((String) mtHostField.getValue()) || mtPortField.getValue() == null) {
                mtSenderLoginField.getWindow().showNotification(" ?",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
                return;
            }
            boolean errors = false;
            try {
                mtDefaultFrom.validate();
            } catch (Validator.InvalidValueException ignore) {
                errors = true;
            }
            try {
                mtPortField.validate();
            } catch (Validator.InvalidValueException ignore) {
                errors = true;
            }
            if (errors) {
                return;
            }
            set(API.MT_SENDER_LOGIN, mtSenderLoginField.getValue());
            set(API.MT_DEFAULT_FROM, mtDefaultFrom.getValue());
            set(API.MT_PASSWORD, mtPasswordField.getValue());
            set(API.MT_HOST, mtHostField.getValue());
            set(API.MT_PORT, mtPortField.getValue());
            set(API.MT_TLS, mtTls.getValue());

            mtSenderLoginField.setReadOnly(true);
            mtDefaultFrom.setReadOnly(true);
            mtPasswordField.setReadOnly(true);
            mtHostField.setReadOnly(true);
            mtPortField.setReadOnly(true);
            mtTls.setReadOnly(true);

            save.setVisible(false);
            cancel.setVisible(false);
            change.setVisible(true);
            mtSenderLoginField.getWindow().showNotification("?? ?",
                    Window.Notification.TYPE_HUMANIZED_MESSAGE);
        }
    });
    cancel.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN));
            mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM));
            mtPasswordField.setValue(get(API.MT_PASSWORD));
            mtHostField.setValue(get(API.MT_HOST));
            mtPortField.setValue(get(API.MT_PORT));
            mtTls.setValue(AdminServiceProvider.getBoolProperty(API.MT_TLS));

            mtSenderLoginField.setReadOnly(true);
            mtDefaultFrom.setReadOnly(true);
            mtPasswordField.setReadOnly(true);
            mtHostField.setReadOnly(true);
            mtPortField.setReadOnly(true);
            mtTls.setReadOnly(true);

            save.setVisible(false);
            cancel.setVisible(false);
            change.setVisible(true);
        }
    });

    FormLayout leftFields = new FormLayout();
    leftFields.setSizeFull();
    leftFields.addComponent(mtSenderLoginField);
    leftFields.addComponent(mtDefaultFrom);
    leftFields.addComponent(mtPasswordField);
    leftFields.addComponent(mtHostField);
    leftFields.addComponent(mtPortField);

    FormLayout rightFields = new FormLayout();
    rightFields.setSizeFull();
    rightFields.addComponent(mtTls);

    HorizontalLayout fieldsLayout = new HorizontalLayout();
    fieldsLayout.setSpacing(true);
    fieldsLayout.setSizeFull();
    fieldsLayout.addComponent(leftFields);
    fieldsLayout.addComponent(rightFields);
    fieldsLayout.setExpandRatio(leftFields, 0.6f);
    fieldsLayout.setExpandRatio(rightFields, 0.4f);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(change);
    buttons.addComponent(save);
    buttons.addComponent(cancel);

    Label label = new Label("?? Email Task");
    label.addStyleName(Reindeer.LABEL_H2);
    mailConfig.addComponent(label);
    mailConfig.addComponent(fieldsLayout);
    mailConfig.addComponent(buttons);
    mailConfig.setExpandRatio(fieldsLayout, 1f);
    return emailTaskPanel;
}

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

License:Mozilla Public License

public BusinessCalendar() {
    Upload upload = new Upload();
    upload.setImmediate(false);/*from   www.j a  v  a2  s  .c om*/
    upload.setButtonCaption("  ");
    upload.setReceiver(this);
    upload.addListener(this);

    datesTable = new BusinessDatesTable();
    removeButton = createButton("");

    VerticalLayout vr = new VerticalLayout();
    vr.setSizeFull();
    vr.setSpacing(true);
    vr.setMargin(true);

    HorizontalLayout horLayout = new HorizontalLayout();
    horLayout.setSizeFull();
    horLayout.setSpacing(true);
    horLayout.setMargin(true);
    horLayout.addComponent(upload);
    horLayout.addComponent(removeButton);
    vr.addComponent(horLayout);
    vr.addComponent(datesTable);

    addComponent(vr);
    vr.setExpandRatio(horLayout, .1f);
    vr.setExpandRatio(datesTable, .9f);
    datesTable.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            removeButton.setVisible(event.getProperty().getValue() != null);
        }
    });
    setSizeFull();
}

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

License:Mozilla Public License

public ExecutorGroupsBlock(UserItem userItem) {
    HorizontalLayout executorGroups = new HorizontalLayout();
    executorGroups.setMargin(true, false, true, false);
    executorGroups.setSpacing(true);/*from  ww  w.  ja  v a2  s . co  m*/
    executorGroups.setCaption(" ?:");
    FilterTable allExecutorGroups = new FilterTable();
    allExecutorGroups.setCaption("?:");
    TableEmployee.table(executorGroups, allExecutorGroups);
    currentExecutorGroups = new FilterTable();
    currentExecutorGroups
            .setCaption(",    :");
    TableEmployee.table(executorGroups, currentExecutorGroups);
    for (String groupName : AdminServiceProvider.get().getEmpGroupNames()) {
        for (Group group : AdminServiceProvider.get().findGroupByName(groupName)) {
            if (userItem.getGroups().contains(groupName)) {
                currentExecutorGroups.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            } else {
                allExecutorGroups.addItem(new Object[] { groupName, group.getTitle() }, groupName);
            }
        }
    }
    TableEmployee.addListener(allExecutorGroups, currentExecutorGroups);
    TableEmployee.addListener(currentExecutorGroups, allExecutorGroups);

    VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setSizeFull();

    layout.addComponent(executorGroups);
    layout.setExpandRatio(executorGroups, 1f);

    setCompositionRoot(layout);
    setWidth(100f, UNITS_PERCENTAGE);
}

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

License:Mozilla Public License

private void showGroupTab(TabSheet t, final String typeGroup) {
    VerticalLayout l = new VerticalLayout();
    l.setSizeFull();//  www.j  a v  a  2  s  .  c o  m
    TableGroup tableGroup = new TableGroup(typeGroup);
    ButtonCreateGroup buttonCreateGroup = new ButtonCreateGroup(typeGroup, tableGroup);
    l.addComponent(buttonCreateGroup);
    l.addComponent(tableGroup);
    l.setExpandRatio(buttonCreateGroup, 0.1f);
    l.setExpandRatio(tableGroup, 100f);
    t.addTab(l, typeGroup);
}

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

License:Mozilla Public License

LogSettings() {

    logErrors = new OptionGroup("? ? :", Arrays.asList(Status.FAILURE.name()));
    logErrors.setItemCaption(Status.FAILURE.name(), "");
    logErrors.setImmediate(true);//w  ww  . jav a2 s  .c o m
    logErrors.setMultiSelect(true);

    logStatus = new OptionGroup("?  ?  '':", statusKeys());
    logStatus.setItemCaption(Status.REQUEST.name(), "?");
    logStatus.setItemCaption(Status.RESULT.name(), "");
    logStatus.setItemCaption(Status.PING.name(), "?");
    logStatus.setMultiSelect(true);
    logStatus.setImmediate(true);

    ipSet = new TextArea("? IP ?:");
    ipSet.setWordwrap(true);
    ipSet.setNullRepresentation("");
    ipSet.setWidth(100f, UNITS_PERCENTAGE);
    ipSet.setRows(10);

    tf = new TextField(" , :");
    tf.setRequired(true);
    tf.addValidator(new Validator() {
        public void validate(Object value) throws InvalidValueException {
            if (!isValid(value)) {
                throw new InvalidValueException(
                        "  ? ");
            }
        }

        public boolean isValid(Object value) {
            return value instanceof String && ((String) value).matches("[1-9][0-9]*");
        }
    });

    b1 = new Block("") {

        @Override
        void onLayout(Layout layout) {
            layout.addComponent(logErrors);
            layout.addComponent(logStatus);
        }

        @Override
        void onChange() {
            logErrors.setReadOnly(false);
            logStatus.setReadOnly(false);
        }

        @Override
        void onRefresh() {
            boolean _logErrors = AdminServiceProvider.getBoolProperty(API.LOG_ERRORS);
            if (_logErrors) {
                logErrors.setReadOnly(false);
                logErrors.setValue(Arrays.asList(Status.FAILURE.name()));
            } else {
                logErrors.setValue(Collections.emptySet());
            }
            logErrors.setReadOnly(true);

            String _logStatus = AdminServiceProvider.get().getSystemProperty(API.LOG_STATUS);
            if (_logStatus != null) {
                Set<String> set = new HashSet<String>();
                for (String key : statusKeys()) {
                    if (_logStatus.contains(key)) {
                        set.add(key);
                    }
                }
                logStatus.setReadOnly(false);
                logStatus.setValue(set);
            } else {
                logStatus.setValue(Collections.emptySet());
            }
            logStatus.setReadOnly(true);
        }

        @Override
        void onApply() {
            Collection logErrorsValue = (Collection) logErrors.getValue();
            boolean errorsEnabled = logErrorsValue.contains(Status.FAILURE.name());
            AdminServiceProvider.get().saveSystemProperty(API.LOG_ERRORS, Boolean.toString(errorsEnabled));
            LogCustomizer.setShouldWriteServerLogErrors(errorsEnabled);

            Collection logStatusValue = (Collection) logStatus.getValue();

            Set<Status> statuses = new TreeSet<Status>();

            if (logStatusValue.contains(Status.REQUEST.name())) {
                statuses.add(Status.REQUEST);
                statuses.add(Status.ACCEPT);
                statuses.add(Status.CANCEL);
            }

            if (logStatusValue.contains(Status.RESULT.name())) {
                statuses.add(Status.RESULT);
                statuses.add(Status.REJECT);
                statuses.add(Status.STATE);
                statuses.add(Status.NOTIFY);
            }

            if (logStatusValue.contains(Status.PING.name())) {
                statuses.add(Status.PING);
                statuses.add(Status.PROCESS);
                statuses.add(Status.PACKET);
            }

            StringBuilder statusBuilder = new StringBuilder();
            for (Status status : statuses) {
                if (statusBuilder.length() > 0) {
                    statusBuilder.append(", ");
                }
                statusBuilder.append(status);
            }
            String status = statusBuilder.toString();

            AdminServiceProvider.get().saveSystemProperty(API.LOG_STATUS, status);
            LogCustomizer.setServerLogStatus(status);

            boolean enabled = !status.isEmpty();
            LogCustomizer.setShouldWriteServerLog(enabled);
            AdminServiceProvider.get().saveSystemProperty(API.ENABLE_CLIENT_LOG, Boolean.toString(enabled));
        }
    };

    b2 = new Block("? ") {
        @Override
        void onLayout(Layout layout) {
            layout.addComponent(ipSet);
        }

        @Override
        void onRefresh() {
            String ips = AdminServiceProvider.get().getSystemProperty(API.SKIP_LOG_IPS);
            ipSet.setReadOnly(false);
            ipSet.setValue(ips);
            ipSet.setReadOnly(true);
        }

        @Override
        void onChange() {
            ipSet.setReadOnly(false);
        }

        @Override
        void onApply() {
            String value = (String) ipSet.getValue();
            TreeSet<String> items = new TreeSet<String>();
            if (value != null) {
                for (String item : value.split("[,;\\s]+")) {
                    items.add(item);
                }
                StringBuilder sb = new StringBuilder();
                for (String item : items) {
                    if (sb.length() > 0) {
                        sb.append(", ");
                    }
                    sb.append(item);
                }
                value = sb.toString();
            }
            AdminServiceProvider.get().saveSystemProperty(API.SKIP_LOG_IPS, value);
            LogCustomizer.setIgnoreSet(items);
        }
    };

    b3 = new Block("?   ") {
        @Override
        void onButtons(Layout layout) {
            layout.addComponent(new Button("? ", new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    LogScheduler.cleanLog();
                    getWindow().showNotification("?? ",
                            Window.Notification.TYPE_HUMANIZED_MESSAGE);
                }
            }));
        }

        @Override
        void onLayout(Layout layout) {
            layout.addComponent(tf);
        }

        @Override
        void onRefresh() {
            String logDepth = AdminServiceProvider.get().getSystemProperty(API.LOG_DEPTH);
            tf.setReadOnly(false);
            if (logDepth != null && logDepth.matches("[1-9][0-9]*")) {
                tf.setValue(logDepth);
            } else {
                tf.setValue(String.valueOf(API.DEFAULT_LOG_DEPTH));
            }
            tf.setReadOnly(true);
        }

        @Override
        void onChange() {
            tf.setReadOnly(false);
        }

        @Override
        void onApply() {
            tf.validate();
            AdminServiceProvider.get().saveSystemProperty(API.LOG_DEPTH, tf.getValue().toString());
        }
    };

    final CheckBox logSpSign = new CheckBox(" ? ");
    logSpSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_SP_SIGN)));
    logSpSign.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            AdminServiceProvider.get().saveSystemProperty(API.LOG_SP_SIGN,
                    String.valueOf(valueChangeEvent.getProperty().getValue()));
            notifySuccess();
        }
    });
    logSpSign.setImmediate(true);

    final CheckBox logOvSign = new CheckBox(" ? ");
    logOvSign.setValue(Boolean.valueOf(AdminServiceProvider.get().getSystemProperty(API.LOG_OV_SIGN)));
    logOvSign.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            AdminServiceProvider.get().saveSystemProperty(API.LOG_OV_SIGN,
                    String.valueOf(valueChangeEvent.getProperty().getValue()));
            notifySuccess();
        }
    });
    logOvSign.setImmediate(true);

    Label userSignsLabel = new Label("? ?");
    userSignsLabel.addStyleName(Reindeer.LABEL_H2);

    VerticalLayout userSignsVl = new VerticalLayout();
    userSignsVl.setMargin(true);
    userSignsVl.setSpacing(true);
    userSignsVl.addComponent(userSignsLabel);
    userSignsVl.addComponent(logSpSign);
    userSignsVl.addComponent(logOvSign);

    Panel userSingsWrapper = new Panel();
    userSingsWrapper.setScrollable(true);
    userSingsWrapper.setContent(userSignsVl);
    userSingsWrapper.setSizeFull();

    VerticalLayout vl = new VerticalLayout();
    vl.addComponent(b1);
    vl.addComponent(userSingsWrapper);
    vl.setExpandRatio(b1, 0.7f);
    vl.setExpandRatio(userSingsWrapper, 0.3f);
    vl.setSizeFull();

    HorizontalLayout layout = new HorizontalLayout();
    layout.setSpacing(true);
    layout.addComponent(vl);
    layout.addComponent(b2);
    layout.addComponent(b3);
    layout.setSizeFull();
    layout.setExpandRatio(vl, 0.333f);
    layout.setExpandRatio(b2, 0.333f);
    layout.setExpandRatio(b3, 0.333f);

    Panel wrapper = new Panel(" ", layout);
    wrapper.addStyleName(Reindeer.PANEL_LIGHT);
    wrapper.setSizeFull();

    setCompositionRoot(wrapper);
    setSizeFull();
}

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

License:Mozilla Public License

public TreeTableOrganization() {
    setSizeFull();/*from  w  w  w  .jav a 2s  .c  om*/
    treetable = new TreeTable();
    treetable.setSizeFull();
    treetable.setSelectable(true);
    treetable.setMultiSelect(false);
    treetable.addListener(this);
    treetable.setImmediate(true);
    treetable.setValue(null);
    setMargin(true);
    // Add Table columns
    treetable.addContainerProperty(NAME_PROPERTY, String.class, "");

    fillTable(treetable);

    treetable.addListener(new ExpandListener() {

        private static final long serialVersionUID = 1L;

        public void nodeExpand(ExpandEvent event) {
            if (lockExpandListener) {
                return;
            }
            Object valuePropertyEvent = event.getItemId();
            Organization org = AdminServiceProvider.get().findOrganizationById((Long) valuePropertyEvent);
            Set<Organization> childs = org.getOrganizations();
            if (!(childs.isEmpty())) {
                treetable.setChildrenAllowed((Long) valuePropertyEvent, true);

                for (Organization o : childs) {
                    treetable.addItem(new Object[] { o.getName() }, o.getId());
                    treetable.setCollapsed(o.getId(), true);
                }

                for (Organization o : childs) {
                    treetable.setParent(o.getId(), (Long) valuePropertyEvent);
                }

                for (Organization o : childs) {
                    treetable.setChildrenAllowed(o.getId(), !(o.getOrganizations().isEmpty()));
                }
            }

        }
    });

    treetable.addListener(new CollapseListener() {

        private static final long serialVersionUID = 1L;

        public void nodeCollapse(CollapseEvent event) {
            if (lockExpandListener) {
                return;
            }
            Set<Object> delete = new HashSet<Object>();
            Collection<?> children = treetable.getChildren(event.getItemId());
            if (children != null) {
                for (Object child : children) {
                    removeRecursively(child, delete);
                }
            }
            for (Object o : delete) {
                treetable.setCollapsed(o, true);
                treetable.removeItem(o);
            }
        }

        private void removeRecursively(Object object, Set<Object> delete) {
            Collection<?> children = treetable.getChildren(object);
            if (children != null) {
                for (Object child : children) {
                    removeRecursively(child, delete);
                }
            }
            delete.add(object);
        }
    });

    panel.setStyleName(Reindeer.PANEL_LIGHT);
    panel.setSizeFull();
    panel.addComponent(new ButtonCreateOrganization(treetable));

    final HorizontalSplitPanel horiz = new HorizontalSplitPanel();
    horiz.setSplitPosition(25); // percent
    horiz.setSizeFull();
    addComponent(horiz);
    TextField orgFilter = new TextField();
    orgFilter.setImmediate(true);
    orgFilter.setWidth(100, UNITS_PERCENTAGE);
    orgFilter.setInputPrompt("  ");
    orgFilter.addListener(new FieldEvents.TextChangeListener() {

        List<Organization> organizations;
        List<Long> organizationIds;

        @Override
        public void textChange(FieldEvents.TextChangeEvent event) {
            String name = StringUtils.trimToNull(event.getText());
            if (name != null) {
                lockExpandListener = true;
                organizations = AdminServiceProvider.get().findOrganizationIdsByName(name);
                treetable.removeAllItems();
                organizationIds = new ArrayList<Long>();
                for (Organization org : organizations) {
                    for (Organization o1 : getPath(org)) {
                        if (!treetable.containsId(o1.getId())) {
                            treetable.addItem(new Object[] { o1.getName() }, o1.getId());
                            if (o1.getParent() != null) {
                                treetable.setParent(o1.getId(), o1.getParent().getId());
                            }
                            treetable.setChildrenAllowed(o1.getId(), !(o1.getOrganizations().isEmpty()));
                            treetable.setCollapsed(o1.getId(), false);
                        }
                    }
                    organizationIds.add(org.getId());
                }

                treetable.setCellStyleGenerator(new Table.CellStyleGenerator() {
                    @Override
                    public String getStyle(Object itemId, Object propertyId) {
                        if (propertyId == null) {
                            if (!organizationIds.contains(itemId)) {
                                return "gray";
                            }
                        }
                        return null;
                    }
                });

            } else {
                lockExpandListener = false;
                treetable.removeAllItems();
                fillTable(treetable);
                treetable.setCellStyleGenerator(new Table.CellStyleGenerator() {
                    @Override
                    public String getStyle(Object itemId, Object propertyId) {
                        return null;
                    }
                });
            }
        }

        private List<Organization> getPath(Organization org) {
            List<Organization> list = new LinkedList<Organization>();
            while (org != null) {
                list.add(0, org);
                org = org.getParent();
            }
            return list;
        }
    });
    VerticalLayout vl = new VerticalLayout();
    vl.setSpacing(true);
    vl.setSizeFull();
    vl.addComponent(orgFilter);
    vl.addComponent(treetable);
    vl.setExpandRatio(treetable, 0.9f);
    horiz.addComponent(vl);
    horiz.addComponent(panel);
}

From source file:ru.codeinside.gses.webui.CertificateSelection.java

License:Mozilla Public License

public CertificateSelection(String userLogin, CertificateListener certificateListener) {
    this.certificateListener = certificateListener;

    String userName = StringUtils
            .trimToNull(Flash.flash().getAdminService().findEmployeeByLogin(userLogin).getFio());
    if (userName == null) {
        userName = userLogin;/* w ww .ja va2s.  c o  m*/
    }

    Label header = new Label(" ?");
    header.setStyleName(Reindeer.LABEL_H1);

    Label hint = new Label("<b>" + userName
            + "</b>, ? ?   ? ?? ? "
            + "   ?,     ??? ? "
            + "<a target='_blank' href='http://ru.wikipedia.org/wiki/"
            + "%D0%AD%D0%BB%D0%B5%D0%BA%D1%82%D1%80%D0%BE%D0%BD%D0%BD%D0%B0%D1%8F_%D0%BF%D0%BE%D0%B4%D0%BF%D0%B8%D1%81%D1%8C'"
            + ">? ?</a></i> ??  .",
            Label.CONTENT_XHTML);

    SignApplet applet = new SignApplet(new Protocol());
    applet.setName(" ?");
    applet.setCaption(null);
    applet.setBindingMode();

    appletHint = new Label("??  <b>Java</b>  "
            + Flash.getActor().getBrowser() + "   <b> JCP</b>.<br/> "
            + "   ?  ?  ?? "
            + "   <a target='_blank' href='http://ca.oep-penza.ru/'"
            + ">??  ?   ?</a>.",
            Label.CONTENT_XHTML);

    Button logout = new Button(" ( ?   )",
            new Logout());
    logout.setStyleName(Reindeer.BUTTON_SMALL);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.setMargin(true);
    buttons.addComponent(logout);

    VerticalLayout flow = new VerticalLayout();
    flow.setSizeUndefined();
    flow.setMargin(true);
    flow.setSpacing(true);
    flow.addComponent(header);
    flow.addComponent(hint);
    flow.addComponent(applet);
    flow.addComponent(appletHint);
    flow.addComponent(buttons);

    Panel panel = new Panel();
    panel.setSizeUndefined();
    panel.setContent(flow);

    VerticalLayout center = new VerticalLayout();
    center.addComponent(panel);
    center.setExpandRatio(panel, 1f);
    center.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    center.setSizeFull();

    setCompositionRoot(center);

    setSizeFull();
}

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

License:Mozilla Public License

private void buildLayout(final String taskId) {
    final Task task = Flash.flash().getProcessEngine().getTaskService().createTaskQuery().taskId(taskId)
            .singleResult();//from  w  w  w. ja v a2  s.c  o  m
    final String tag = Flash.flash().getAdminService().getBidByTask(taskId).getTag();
    String procedureName = Flash.flash().getExecutorService()
            .getProcedureNameByDefinitionId(task.getProcessDefinitionId());
    if (!tag.isEmpty()) {
        procedureName = tag + " - " + procedureName;
    }
    ProcessDefinitionEntity def = Functions.withRepository(Flash.login(),
            new Function<RepositoryService, ProcessDefinitionEntity>() {
                public ProcessDefinitionEntity apply(final RepositoryService srv) {
                    RepositoryServiceImpl impl = (RepositoryServiceImpl) srv;
                    return (ProcessDefinitionEntity) impl
                            .getDeployedProcessDefinition(task.getProcessDefinitionId());
                }
            });
    Label procLabel = new Label(": " + procedureName);
    Label taskLabel = new Label(": " + task.getName());
    Label versionLabel = new Label("??: " + def.getVersion());
    Panel bidPanel = new Panel("?? ?? ?");
    addComponent(bidPanel);
    VerticalLayout bidLayout = new VerticalLayout();
    bidLayout.setSizeFull();
    bidLayout.setSpacing(true);
    bidPanel.addComponent(bidLayout);
    bidLayout.addComponent(procLabel);
    bidLayout.addComponent(taskLabel);
    bidLayout.addComponent(versionLabel);

    historyTable = Components.createTable(null, null);
    final String pid = task.getProcessInstanceId();
    HistoricTaskInstancesQueryDefinition queryDefinition = new HistoricTaskInstancesQueryDefinition(pid,
            taskId);
    LazyQueryContainer container = new LazyQueryContainer(queryDefinition,
            new HistoricTaskInstancesQueryFactory());
    historyTable.setContainerDataSource(container);
    historyTable.setPageLength(0);
    historyTable.setWidth("100%");
    historyTable.setSortDisabled(true);
    historyTable.setSelectable(true);
    historyTable.addContainerProperty("id", String.class, null);
    historyTable.addContainerProperty("name", String.class, null);
    historyTable.addContainerProperty("startDate", String.class, null);
    historyTable.addContainerProperty("endDate", String.class, null);
    historyTable.addContainerProperty("assignee", String.class, null);
    historyTable.addContainerProperty("form", Component.class, null);
    historyTable.setColumnExpandRatio("id", 0.05f);
    historyTable.setColumnExpandRatio("startDate", 0.1f);
    historyTable.setColumnExpandRatio("endDate", 0.1f);
    historyTable.setColumnExpandRatio("name", 0.1f);
    historyTable.setColumnExpandRatio("assignee", 0.1f);
    historyTable.setColumnExpandRatio("form", 0.1f);
    historyTable.addStyleName("disable-scroll");
    historyTable.setVisibleColumns(new String[] { "id", "name", "startDate", "endDate", "assignee", "form" });
    historyTable.setColumnHeaders(new String[] { "?", "", "?",
            "", "?", "" });
    historyTable.addListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            HistoricTaskInstance i = (HistoricTaskInstance) event.getItem().getItemProperty("hid").getValue();
            fireEvent(new HistoryStepClickedEvent(event.getComponent(), i));
        }
    });
    bidLayout.addComponent(historyTable);
    bidLayout.setExpandRatio(procLabel, 0.01f);
    bidLayout.setExpandRatio(taskLabel, 0.01f);
    bidLayout.setExpandRatio(versionLabel, 0.01f);
    bidLayout.setExpandRatio(historyTable, 0.97f);
}

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  a 2  s .  co  m*/
    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.declarant.DeclarantFactory.java

License:Mozilla Public License

public static Component create() {

    // TODO: ??   ??!
    final ServiceQueryDefinition amSQ = new ServiceQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amSC = new LazyQueryContainer(amSQ, new ServiceQueryFactory(false));
    final ProcedureQueryDefinition amPQ = new ProcedureQueryDefinition(ProcedureType.Administrative);
    final LazyQueryContainer amPC = new LazyQueryContainer(amPQ,
            new ProcedureQueryFactory(Flash.login(), false));

    final ProcedureQueryDefinition mmQ = new ProcedureQueryDefinition(ProcedureType.Interdepartmental);
    final LazyQueryContainer mmC = new LazyQueryContainer(mmQ, new ProcedureQueryFactory(Flash.login(), false));

    final VerticalLayout layout = new VerticalLayout();
    layout.setSizeFull();//w ww  .j  a  v a2s. c  om
    layout.setMargin(true);
    final Label header = new Label(
            " ?  ?? ?? ?");
    header.addStyleName("h1");
    layout.addComponent(header);

    final Select amS = new Select("", amPC);
    String selectWidth = "400px";
    amS.setWidth(selectWidth);
    amS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amS.setItemCaptionPropertyId("name");
    amS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amS.setNullSelectionAllowed(true);
    amS.setNewItemsAllowed(false);
    amS.setImmediate(true);

    final Select amSS = new Select("?", amSC);
    amSS.setWidth(selectWidth);
    amSS.setItemCaptionMode(AbstractSelect.ITEM_CAPTION_MODE_PROPERTY);
    amSS.setItemCaptionPropertyId("name");
    amSS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    amSS.setNullSelectionAllowed(true);
    amSS.setNewItemsAllowed(false);
    amSS.setImmediate(true);

    final FormLayout amLayout = new FormLayout();

    final Panel amPanel = new Panel();
    amLayout.addComponent(amSS);
    amLayout.addComponent(amS);
    amPanel.addComponent(amLayout);

    final Select mmS = new Select("", mmC);
    mmS.setFilteringMode(Select.FILTERINGMODE_OFF);
    mmS.setWidth(selectWidth);
    mmS.setItemCaptionPropertyId("name");
    mmS.setFilteringMode(AbstractSelect.Filtering.FILTERINGMODE_CONTAINS);
    mmS.setNullSelectionAllowed(true);
    mmS.setNewItemsAllowed(false);
    mmS.setImmediate(true);

    final FormLayout mmLayout = new FormLayout();
    final Panel mmPanel = new Panel();
    //    mmLayout.addComponent(mmSS);
    mmLayout.addComponent(mmS);
    mmPanel.addComponent(mmLayout);

    final VerticalLayout amWrapper = new VerticalLayout();
    amWrapper.setSizeFull();
    amWrapper.addComponent(amPanel);

    final VerticalLayout imWrapper = new VerticalLayout();
    imWrapper.setSizeFull();
    imWrapper.addComponent(mmPanel);

    final TabSheet typeSheet = new TabSheet();
    typeSheet.setSizeFull();
    typeSheet.addTab(amWrapper, "?? ");
    typeSheet.addTab(imWrapper, "? ");
    layout.addComponent(typeSheet);
    layout.setExpandRatio(typeSheet, 1);

    // 

    amSS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                amPQ.serviceId = -1;
            } else {
                amPQ.serviceId = (Long) amSC.getItem(prop.getValue()).getItemProperty("id").getValue();
            }
            amS.select(null);
            amPC.refresh();
        }
    });

    final ProcedureSelectListener administrativeProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (amWrapper.getComponentCount() > 1) {
                amWrapper.removeComponent(amWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    amWrapper.addComponent(cmp);
                    amWrapper.setExpandRatio(cmp, 1f);
                } else {
                    amS.select(null);
                    amPC.refresh();
                    amSC.refresh();
                }
            }
        }
    };
    final ProcedureSelectListener interdepartamentalProcedureSelectListener = new ProcedureSelectListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void selectProcedure(long id) {
            if (imWrapper.getComponentCount() > 1) {
                imWrapper.removeComponent(imWrapper.getComponent(1));
            }
            if (id > 0) {
                final Component cmp = createStartEventForm(id, this, layout);
                if (cmp != null) {
                    imWrapper.addComponent(cmp);
                    imWrapper.setExpandRatio(cmp, 1f);
                }
            }
        }
    };
    amS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) amPC.getItem(itemId).getItemProperty("id").getValue();
            administrativeProcedureSelectListener.selectProcedure(procedureId);
        }
    });
    mmS.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            final Object itemId = event.getProperty().getValue();
            final long procedureId = itemId == null ? -1
                    : (Long) mmC.getItem(itemId).getItemProperty("id").getValue();
            interdepartamentalProcedureSelectListener.selectProcedure(procedureId);
        }
    });

    return layout;
}