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.gses.webui.form.GridForm.java

License:Mozilla Public License

void buildControls(final FieldTree.Entry entry, int level) {
    switch (entry.type) {
    case ITEM://from   w  w  w .  ja  va 2s  .  com
    case BLOCK:
        if (!entry.readable)
            break; // ?   ? ? ?,       
        if (isNotBlank(entry.caption)) {
            Label caption = new Label(entry.caption);
            caption.setStyleName("right");
            if (entry.type == FieldTree.Type.BLOCK) {
                caption.addStyleName("bold");
            }
            caption.setWidth(300, UNITS_PIXELS);
            caption.setHeight(100, UNITS_PERCENTAGE);
            gridLayout.addComponent(caption, level, entry.index, valueColumn - 1, entry.index);
            gridLayout.setComponentAlignment(caption, Alignment.TOP_RIGHT);
        }
        final Component sign = entry.sign;
        if (sign != null) {
            gridLayout.addComponent(sign, valueColumn + 1, entry.index);
            gridLayout.setComponentAlignment(sign, Alignment.TOP_LEFT);
            if (!entry.readOnly) {
                entry.field.addListener(new ValueChangeListener() {
                    @Override
                    public void valueChange(Property.ValueChangeEvent event) {
                        entry.field.removeListener(this);
                        gridLayout.removeComponent(sign);
                        entry.sign = null;
                    }
                });
            }
        }
        // ???  
        addField(entry.path, entry.field);
        break;
    case CONTROLS:
        HorizontalLayout layout = new HorizontalLayout();
        layout.setImmediate(true);
        layout.setSpacing(true);
        layout.setMargin(false, false, true, false);
        Button plus = createButton("+");
        Button minus = createButton("-");
        layout.addComponent(plus);
        layout.addComponent(minus);
        FieldTree.Entry block = getBlock(entry);
        plus.addListener(new AppendAction(entry, minus));
        minus.addListener(new RemoveAction(entry, plus));
        if (block.field != null) {
            final StringBuilder sb = new StringBuilder();
            if (!isBlank(block.caption)) {
                sb.append(' ').append('\'').append(block.caption).append('\'');
            }
            if (block.field.getDescription() != null) {
                sb.append(' ').append('(').append(block.field.getDescription()).append(')');
            }
            plus.setDescription("" + sb);
            minus.setDescription("" + sb);
        }
        updateCloneButtons(plus, minus, block);
        gridLayout.addComponent(layout, valueColumn, entry.index, valueColumn, entry.index);
        break;
    case CLONE:
        int y = entry.index;
        int dy = entry.getControlsCount() - 1;
        Label cloneCaption = new Label(entry.cloneIndex + ")");
        cloneCaption.setWidth(20, UNITS_PIXELS);
        cloneCaption.setStyleName("right");
        cloneCaption.addStyleName("bold");
        gridLayout.addComponent(cloneCaption, level - 1, y, level - 1, y + dy);
        gridLayout.setComponentAlignment(cloneCaption, Alignment.TOP_RIGHT);
        break;
    case ROOT:
        break;
    default:
        throw new IllegalStateException(
                "??? ?  ? " + entry.type);
    }

    if (entry.items != null) { //  ?  ?
        if (entry.type == FieldTree.Type.BLOCK) {
            level++;
        }
        for (FieldTree.Entry child : entry.items) {
            buildControls(child, level);
        }
    }
}

From source file:ru.codeinside.gses.webui.supervisor.ConfirmWindow.java

License:Mozilla Public License

public ConfirmWindow(String confirmMessage) {
    setCaption("!");
    setWidth("30%");
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();//  w  ww .  jav a 2  s  . co m
    vl.setSpacing(true);
    Label messageLabel = new Label(confirmMessage);
    messageLabel.setStyleName("h1");
    vl.addComponent(messageLabel);
    HorizontalLayout hl = new HorizontalLayout();
    hl.setSizeFull();
    hl.setSpacing(true);
    Button okButton = new Button("");
    Button noButton = new Button("?");
    okButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            fireEvent(new ConfirmOkEvent(event.getComponent()));
            close();
        }
    });
    noButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            close();
        }
    });
    hl.addComponent(okButton);
    hl.addComponent(noButton);
    hl.setExpandRatio(okButton, 0.99f);
    vl.addComponent(hl);
    addComponent(vl);
    center();
}

From source file:ru.codeinside.gses.webui.supervisor.SupervisorWorkplace.java

License:Mozilla Public License

private void buildListPanel() {
    controlledTasksTable.setHeight("255px");
    controlledTasksTable.setWidth("100%");
    controlledTasksTable.setImmediate(true);
    controlledTasksTable.setSelectable(true);
    controlledTasksTable.setSortDisabled(true);
    controlledTasksTable.addContainerProperty("id", Component.class, null);
    controlledTasksTable.addContainerProperty("dateCreated", String.class, null);
    controlledTasksTable.addContainerProperty("task", String.class, null);
    controlledTasksTable.addContainerProperty("procedure", String.class, null);
    controlledTasksTable.addContainerProperty("declarant", String.class, null);
    controlledTasksTable.addContainerProperty("version", String.class, null);
    controlledTasksTable.addContainerProperty("status", String.class, null);
    controlledTasksTable.addContainerProperty("employee", String.class, null);
    controlledTasksTable.addContainerProperty("priority", String.class, null);
    controlledTasksTable.addContainerProperty("bidDays", String.class, null);
    controlledTasksTable.addContainerProperty("taskDays", String.class, null);
    controlledTasksTable.setVisibleColumns(new Object[] { "id", "dateCreated", "task", "procedure", "declarant",
            "version", "status", "employee", "bidDays", "taskDays" });
    controlledTasksTable.setColumnHeaders(new String[] { "?", "  ?",
            "", "", "?", "??", "?",
            "?", "..", ".?." });
    controlledTasksTable.setColumnExpandRatio("id", 0.05f);
    controlledTasksTable.setColumnExpandRatio("dateCreated", 0.15f);
    controlledTasksTable.setColumnExpandRatio("task", 0.2f);
    controlledTasksTable.setColumnExpandRatio("procedure", 0.25f);
    controlledTasksTable.setColumnExpandRatio("declarant", 0.1f);
    controlledTasksTable.setColumnExpandRatio("version", 0.05f);
    controlledTasksTable.setColumnExpandRatio("status", 0.1f);
    controlledTasksTable.setColumnExpandRatio("employee", 0.1f);
    controlledTasksTable.setCellStyleGenerator(new TaskStylist(controlledTasksTable));
    listPanel.addComponent(controlledTasksTable);
    final Button assignButton = new Button("? ??");
    controlledTasksTable.addListener(new Property.ValueChangeListener() {
        @Override//from   w  w  w.  j  a  v a 2 s.  c o m
        public void valueChange(Property.ValueChangeEvent event) {
            Table table = (Table) event.getProperty();
            Item item = table.getItem(table.getValue());

            if (item != null && item.getItemProperty("id") != null) {
                final String taskId = item.getItemProperty("taskId").getValue().toString();
                final Component procedureHistoryPanel = new ProcedureHistoryPanel(taskId);
                procedureHistoryPanel.addListener(new Listener() {
                    @Override
                    public void componentEvent(Event event) {
                        HistoricTaskInstance historicTaskInstance = ((ProcedureHistoryPanel.HistoryStepClickedEvent) event)
                                .getHistoricTaskInstance();
                        Date endDateTime = historicTaskInstance.getEndTime();
                        if (endDateTime == null) {
                            taskIdToAssign = findTaskByHistoricInstance(historicTaskInstance);
                            if (taskIdToAssign == null) {
                                alreadyGone();
                                return;
                            }
                            assignButton.setVisible(true);
                        } else {
                            assignButton.setVisible(false);
                        }
                    }
                });
                ((VerticalLayout) item1).removeAllComponents();
                Task task = Flash.flash().getProcessEngine().getTaskService().createTaskQuery().taskId(taskId)
                        .singleResult();
                Bid bid = Flash.flash().getAdminService().getBidByTask(taskId);
                String executionId = task.getExecutionId();
                final ProcessDefinition def = ActivitiBean.get()
                        .getProcessDefinition(task.getProcessDefinitionId(), Flash.login());
                final ShowDiagramComponentParameterObject param = new ShowDiagramComponentParameterObject();
                param.changer = bidChanger;
                param.processDefinitionId = def.getId();
                param.executionId = executionId;
                param.height = "300px";
                param.width = null;
                param.windowHeader = bid == null ? ""
                        : bid.getProcedure().getName() + " v. " + bid.getVersion();
                Button showDiagram = new Button("");
                showDiagram.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        Execution execution = Flash.flash().getProcessEngine().getRuntimeService()
                                .createExecutionQuery().executionId(param.executionId).singleResult();
                        if (execution == null) {
                            alreadyGone();
                            return;
                        }
                        ShowDiagramComponent showDiagramComponent = new ShowDiagramComponent(param);
                        VerticalLayout layout = 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) {
                                bidChanger.back();
                            }
                        });
                        layout.addComponent(back);
                        layout.setSpacing(true);
                        layout.addComponent(showDiagramComponent);
                        bidChanger.set(layout, "showDiagram");
                        bidChanger.change(layout);
                    }
                });

                Button deleteBidButton = new Button(" ?");
                deleteBidButton.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        final Window mainWindow = getWindow();
                        final Window rejectWindow = new Window();
                        rejectWindow.setWidth("38%");
                        rejectWindow.center();
                        rejectWindow.setCaption("!");
                        final VerticalLayout verticalLayout = new VerticalLayout();
                        verticalLayout.setSpacing(true);
                        verticalLayout.setMargin(true);
                        final Label messageLabel = new Label(
                                "  ? ?");
                        messageLabel.setStyleName("h2");
                        final TextArea textArea = new TextArea();
                        textArea.setSizeFull();
                        HorizontalLayout buttons = new HorizontalLayout();
                        buttons.setSpacing(true);
                        buttons.setSizeFull();
                        final Button ok = new Button("Ok");
                        Button cancel = new Button("Cancel");

                        buttons.addComponent(ok);
                        buttons.addComponent(cancel);
                        buttons.setExpandRatio(ok, 0.99f);
                        verticalLayout.addComponent(messageLabel);
                        verticalLayout.addComponent(textArea);
                        verticalLayout.addComponent(buttons);
                        verticalLayout.setExpandRatio(textArea, 0.99f);
                        rejectWindow.setContent(verticalLayout);
                        mainWindow.addWindow(rejectWindow);

                        Button.ClickListener ok1 = new Button.ClickListener() {
                            @Override
                            public void buttonClick(Button.ClickEvent event) {
                                ok.setEnabled(false);
                                verticalLayout.removeComponent(messageLabel);
                                verticalLayout.removeComponent(textArea);
                                final byte[] block;
                                final String textAreaValue = (String) textArea.getValue();
                                if (textAreaValue != null) {
                                    block = textAreaValue.getBytes();
                                } else {
                                    block = null;
                                }
                                Label reason = new Label(textAreaValue);
                                reason.setCaption(" :");
                                verticalLayout.addComponent(reason, 0);
                                event.getButton().removeListener(this);

                                SignApplet signApplet = new SignApplet(new SignAppletListener() {

                                    @Override
                                    public void onLoading(SignApplet signApplet) {

                                    }

                                    @Override
                                    public void onNoJcp(SignApplet signApplet) {
                                        verticalLayout.removeComponent(signApplet);
                                        ReadOnly field = new ReadOnly(
                                                "   ?? ?? ?  JCP",
                                                false);
                                        verticalLayout.addComponent(field);

                                    }

                                    @Override
                                    public void onCert(SignApplet signApplet, X509Certificate certificate) {
                                        boolean ok = false;
                                        String errorClause = null;
                                        try {
                                            boolean link = AdminServiceProvider
                                                    .getBoolProperty(CertificateVerifier.LINK_CERTIFICATE);
                                            if (link) {
                                                byte[] x509 = AdminServiceProvider.get()
                                                        .withEmployee(Flash.login(), new CertificateReader());
                                                ok = Arrays.equals(x509, certificate.getEncoded());
                                            } else {
                                                ok = true;
                                            }
                                            CertificateVerifyClientProvider.getInstance()
                                                    .verifyCertificate(certificate);
                                        } catch (CertificateEncodingException e) {
                                        } catch (CertificateInvalid err) {
                                            errorClause = err.getMessage();
                                            ok = false;
                                        }
                                        if (ok) {
                                            signApplet.block(1, 1);
                                        } else {
                                            NameParts subject = X509.getSubjectParts(certificate);
                                            String fieldValue = (errorClause == null)
                                                    ? " " + subject.getShortName()
                                                            + " "
                                                    : errorClause;
                                            ReadOnly field = new ReadOnly(fieldValue, false);
                                            verticalLayout.addComponent(field, 0);
                                        }
                                    }

                                    @Override
                                    public void onBlockAck(SignApplet signApplet, int i) {
                                        logger().fine("AckBlock:" + i);
                                        signApplet.chunk(1, 1, block);
                                    }

                                    @Override
                                    public void onChunkAck(SignApplet signApplet, int i) {
                                        logger().fine("AckChunk:" + i);
                                    }

                                    @Override
                                    public void onSign(SignApplet signApplet, byte[] sign) {
                                        final int i = signApplet.getBlockAck();
                                        logger().fine("done block:" + i);
                                        if (i < 1) {
                                            signApplet.block(i + 1, 1);
                                        } else {
                                            verticalLayout.removeComponent(signApplet);
                                            NameParts subjectParts = X509
                                                    .getSubjectParts(signApplet.getCertificate());
                                            Label field2 = new Label(subjectParts.getShortName());
                                            field2.setCaption("? ?:");
                                            verticalLayout.addComponent(field2, 0);
                                            ok.setEnabled(true);
                                        }
                                    }

                                    private Logger logger() {
                                        return Logger.getLogger(getClass().getName());
                                    }
                                });
                                byte[] x509 = AdminServiceProvider.get().withEmployee(Flash.login(),
                                        new CertificateReader());
                                if (x509 != null) {
                                    signApplet.setSignMode(x509);
                                } else {
                                    signApplet.setUnboundSignMode();
                                }
                                verticalLayout.addComponent(signApplet, 0);

                                ok.addListener(new Button.ClickListener() {
                                    @Override
                                    public void buttonClick(Button.ClickEvent event) {
                                        Task result = Flash.flash().getProcessEngine().getTaskService()
                                                .createTaskQuery().taskId(taskId).singleResult();
                                        if (result == null) {
                                            alreadyGone();
                                            return;
                                        }
                                        ActivitiBean.get().deleteProcessInstance(taskId, textAreaValue);
                                        AdminServiceProvider.get().createLog(Flash.getActor(), "activiti.task",
                                                taskId, "remove", " ?", true);
                                        fireTaskChangedEvent(taskId, SupervisorWorkplace.this);
                                        infoChanger.change(infoComponent);
                                        controlledTasksTable.setValue(null);
                                        controlledTasksTable.refresh();
                                        mainWindow.removeWindow(rejectWindow);
                                    }
                                });
                            }
                        };
                        ok.addListener(ok1);

                        cancel.addListener(new Button.ClickListener() {
                            @Override
                            public void buttonClick(Button.ClickEvent event) {

                                controlledTasksTable.refresh();
                                mainWindow.removeWindow(rejectWindow);
                            }
                        });
                    }
                });

                HorizontalLayout hl = new HorizontalLayout();
                hl.setSizeFull();
                hl.setSpacing(true);
                hl.addComponent(showDiagram);
                hl.addComponent(deleteBidButton);
                hl.setExpandRatio(showDiagram, 0.99f);
                hl.setExpandRatio(deleteBidButton, 0.01f);

                ((VerticalLayout) item1).addComponent(hl);
                ((VerticalLayout) item1).addComponent(procedureHistoryPanel);
                assignButton.setVisible(false);
                assignButton.addListener(new Button.ClickListener() {
                    @Override
                    public void buttonClick(Button.ClickEvent event) {
                        ((Layout) item3).removeAllComponents();
                        if (taskIdToAssign != null) {
                            ((Layout) item3).addComponent(createAssignerToTaskComponent(taskIdToAssign,
                                    (ProcedureHistoryPanel) procedureHistoryPanel, controlledTasksTable));
                            bidChanger.change(item3);
                        } else {
                            alreadyGone();
                        }
                    }
                });
                ((VerticalLayout) item1).addComponent(assignButton);
                infoChanger.change(bidComponent);
                bidChanger.change(item1);
            } else {
                ((VerticalLayout) item1).removeAllComponents();
            }
        }
    });
}

From source file:ru.codeinside.gses.webui.supervisor.SupervisorWorkplace.java

License:Mozilla Public License

private Component createAssignerToTaskComponent(final String taskId,
        final ProcedureHistoryPanel procedureHistoryPanel, final ControlledTasksTable table) {
    final Task task = Flash.flash().getProcessEngine().getTaskService().createTaskQuery().taskId(taskId)
            .singleResult();//  w w w.  j  a  va2s.  co  m
    final VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setSizeFull();
    verticalLayout.setSpacing(true);
    Button backButton = new Button("?");
    backButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            bidChanger.back();
        }
    });
    verticalLayout.addComponent(backButton);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setSizeFull();
    horizontalLayout.setSpacing(true);

    LazyLoadingContainer2 orgGroupsLazyQueryContainer = new LazyLoadingContainer2(
            new GroupsQuery(GroupsQueryDefinition.Mode.ORG, Flash.login()));
    final FilterTable orgGroupsTable = new FilterTable();
    orgGroupsTable.setFilterBarVisible(true);
    orgGroupsTable.setSizeFull();
    orgGroupsTable.setImmediate(true);
    orgGroupsTable.setSelectable(true);
    orgGroupsTable.setFilterDecorator(new FilterDecorator_());
    orgGroupsTable.setFilterGenerator(new FilterGenerator_());
    orgGroupsLazyQueryContainer.addContainerProperty("name", String.class, null);
    orgGroupsLazyQueryContainer.addContainerProperty("title", String.class, null);
    orgGroupsTable.setContainerDataSource(orgGroupsLazyQueryContainer);
    orgGroupsTable.setHeight("150px");
    orgGroupsTable.setCaption("?  ");
    orgGroupsTable.setColumnHeaders(new String[] { " ", "? " });

    LazyLoadingContainer2 empGroupsLazyQueryContainer = new LazyLoadingContainer2(
            new GroupsQuery(GroupsQueryDefinition.Mode.EMP, Flash.login()));
    final FilterTable empGroupsTable = new FilterTable();
    empGroupsTable.setFilterBarVisible(true);
    empGroupsTable.setSizeFull();
    empGroupsTable.setImmediate(true);
    empGroupsTable.setSelectable(true);
    empGroupsTable.setFilterDecorator(new FilterDecorator_());
    empGroupsTable.setFilterGenerator(new FilterGenerator_());
    empGroupsLazyQueryContainer.addContainerProperty("name", String.class, null);
    empGroupsLazyQueryContainer.addContainerProperty("title", String.class, null);
    empGroupsTable.setContainerDataSource(empGroupsLazyQueryContainer);
    empGroupsTable.setCaption("?  ?");
    empGroupsTable.setHeight("150px");
    empGroupsTable.setColumnHeaders(new String[] { " ", "? " });

    final Table employeesTable = new Table();
    employeesTable.setSizeFull();
    employeesTable.setSelectable(true);
    employeesTable.setHeight("150px");
    employeesTable.setCaption(
            "? ? ? ?, ?   ");
    employeesTable.addContainerProperty("login", String.class, null);
    employeesTable.addContainerProperty("fio", String.class, null);
    employeesTable.setColumnHeaders(new String[] { "", "" });
    employeesTable.setVisible(false);

    orgGroupsTable.addListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (task == null) {
                alreadyGone();
                return;
            }
            empGroupsTable.select(null);
            employeesTable.setVisible(true);
            String groupName = event.getItem().getItemProperty("name") != null
                    ? (String) event.getItem().getItemProperty("name").getValue()
                    : "";
            GroupMembersQueryDefinition groupMembersQueryDefinition = new GroupMembersQueryDefinition(groupName,
                    GroupMembersQuery.Mode.ORG);
            LazyQueryContainer groupMembersContainer = new LazyQueryContainer(groupMembersQueryDefinition,
                    new GroupMembersFactory(task.getId()));
            employeesTable.setContainerDataSource(groupMembersContainer);
        }
    });

    empGroupsTable.addListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (task == null) {
                alreadyGone();
                return;
            }
            orgGroupsTable.select(null);
            employeesTable.setVisible(true);
            String groupName = event.getItem().getItemProperty("name") != null
                    ? (String) event.getItem().getItemProperty("name").getValue()
                    : "";
            GroupMembersQueryDefinition groupMembersQueryDefinition = new GroupMembersQueryDefinition(groupName,
                    GroupMembersQuery.Mode.SOC);
            LazyQueryContainer groupMembersContainer = new LazyQueryContainer(groupMembersQueryDefinition,
                    new GroupMembersFactory(task.getId()));
            employeesTable.setContainerDataSource(groupMembersContainer);
        }
    });

    final VerticalLayout assignButtonLayout = new VerticalLayout();

    employeesTable.addListener(new ItemClickEvent.ItemClickListener() {
        @Override
        public void itemClick(ItemClickEvent event) {
            if (task == null) {
                alreadyGone();
                return;
            }
            final String assigneeLogin = event.getItem().getItemProperty("login").getValue().toString();
            final String taskName = task.getName();
            Button assignButton = new Button("?");
            assignButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    final String error = ActivitiBean.get().claim(taskId, assigneeLogin, Flash.login(), true);
                    if (!StringUtils.isEmpty(error)) {
                        getWindow().showNotification(
                                "??  " + assigneeLogin
                                        + "  ? " + taskName,
                                Window.Notification.TYPE_WARNING_MESSAGE);
                        AdminServiceProvider.get().createLog(Flash.getActor(), "activiti task", taskId, "claim",
                                "Fail claim to =>" + assigneeLogin, false);
                    } else {
                        getWindow().showNotification(
                                "? " + assigneeLogin + "  ? " + taskName);
                        AdminServiceProvider.get().createLog(Flash.getActor(), "activiti task", taskId, "claim",
                                "Claim to =>" + assigneeLogin, true);
                        fireTaskChangedEvent(taskId, SupervisorWorkplace.this);
                    }
                    procedureHistoryPanel.refresh();
                    table.refresh();
                    bidChanger.change(item1);
                }
            });
            assignButtonLayout.removeAllComponents();
            assignButtonLayout.addComponent(assignButton);
        }
    });

    horizontalLayout.addComponent(orgGroupsTable);
    horizontalLayout.addComponent(empGroupsTable);
    verticalLayout.addComponent(horizontalLayout);
    verticalLayout.addComponent(employeesTable);
    verticalLayout.addComponent(assignButtonLayout);
    return verticalLayout;
}

From source file:ru.codeinside.gses.webui.supervisor.TaskFilter.java

License:Mozilla Public License

private void buildMainLayout() {
    final ServiceQueryDefinition administrativeServiceQueryDefinition = new ServiceQueryDefinition(
            ProcedureType.Administrative);
    final LazyQueryContainer administrativeServiceQueryContainer = new LazyQueryContainer(
            administrativeServiceQueryDefinition, new ServiceQueryFactory(true));
    final ProcedureQueryDefinition administrativeProcedureQueryDefinition = new ProcedureQueryDefinition(
            ProcedureType.Administrative);
    final LazyQueryContainer administrativeProcedureQueryContainer = new LazyQueryContainer(
            administrativeProcedureQueryDefinition, new ProcedureQueryFactory(Flash.login(), true));
    final ProcedureQueryDefinition interdepartmentalProcedureQueryDefinition = new ProcedureQueryDefinition(
            ProcedureType.Interdepartmental);
    final LazyQueryContainer interdepartmentalProcedureQueryContainer = new LazyQueryContainer(
            interdepartmentalProcedureQueryDefinition, new ProcedureQueryFactory(Flash.login(), true));
    final ServiceQueryDefinition interdepartmentalServiceQueryDefinition = new ServiceQueryDefinition(
            ProcedureType.Interdepartmental);
    final LazyQueryContainer interdepartmentalQueryContainer = new LazyQueryContainer(
            interdepartmentalServiceQueryDefinition, new ServiceQueryFactory(true));
    final GroupsQueryDefinition orgGroupsQueryDefinition = new GroupsQueryDefinition(Flash.login(),
            GroupsQueryDefinition.Mode.ORG);
    final LazyQueryContainer orgGroupsQueryContainer = new LazyQueryContainer(orgGroupsQueryDefinition,
            new GroupsQueryFactory());
    final GroupsQueryDefinition empGroupsQueryDefinition = new GroupsQueryDefinition(Flash.login(),
            GroupsQueryDefinition.Mode.EMP);
    final LazyQueryContainer empGroupsQueryContainer = new LazyQueryContainer(empGroupsQueryDefinition,
            new GroupsQueryFactory());
    //    LazyLoadingContainer2 orgGroupsQueryContainer = new LazyLoadingContainer2(new GroupsQuery(GroupsQueryDefinition.Mode.ORG, Flash.login()));
    //    LazyLoadingContainer2 empGroupsQueryContainer = new LazyLoadingContainer2(new GroupsQuery(GroupsQueryDefinition.Mode.EMP, Flash.login()));

    final String comboBoxWidth = "250px";

    PopupDateField popupFromDate = getFromDateField();
    PopupDateField popupToDate = getToDateField();
    ComboBox procedureTypeBox = getProcedureTypeField(comboBoxWidth);
    final ComboBox serviceBox = getServiceField(administrativeServiceQueryContainer, comboBoxWidth);
    final ComboBox procedureBox = getProcedureField(administrativeProcedureQueryContainer, comboBoxWidth);
    final ComboBox taskBox = getTaskField(comboBoxWidth);
    final ComboBox declarantTypeBox = getDeclarantTypeField(comboBoxWidth);
    CheckBox overdueBox = getOverdueField(comboBoxWidth);
    TextField numberTextField = getBidNumberField(comboBoxWidth);
    TextField requesterTextField = getRequesterLoginField(comboBoxWidth);
    final ListSelect orgGroups = getControlledOrgGroups(orgGroupsQueryContainer, comboBoxWidth);
    final ListSelect empGroups = getControlledEmployeeGroups(empGroupsQueryContainer, comboBoxWidth);
    orgGroups.setVisible(mode == Mode.Supervisor);
    empGroups.setVisible(mode == Mode.Supervisor);

    addField("fromDate", popupFromDate);
    addField("toDate", popupToDate);
    addField("procedureType", procedureTypeBox);
    addField("serviceId", serviceBox);
    addField("procedureName", procedureBox);
    addField("taskName", taskBox);
    addField("declarantType", declarantTypeBox);
    addField("bidId", numberTextField);
    addField("requester", requesterTextField);
    addField("overdue", overdueBox);
    addField("controlledOrgGroups", orgGroups);
    addField("controlledEmpGroups", empGroups);

    /* ? ?  ??*//*from  w ww  .j  a v a  2s  .  c om*/
    procedureTypeBox.addListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null || prop.getValue().equals(ADMINISTRATIVE_PROCEDURE)) {
                serviceBox.setContainerDataSource(administrativeServiceQueryContainer);
                procedureBox.setContainerDataSource(administrativeProcedureQueryContainer);
                serviceBox.select(null);
                procedureBox.select(null);
                taskBox.select(null);
                declarantTypeBox.select(null);
            } else {
                serviceBox.setContainerDataSource(interdepartmentalQueryContainer);
                procedureBox.setContainerDataSource(interdepartmentalProcedureQueryContainer);
                procedureBox.select(null);
                procedureBox.select(null);
                taskBox.select(null);
                declarantTypeBox.select(null);
            }
        }
    });

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

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                administrativeProcedureQueryDefinition.setServiceId(-1);
            } else {
                administrativeProcedureQueryDefinition.setServiceId((Long) administrativeServiceQueryContainer
                        .getItem(prop.getValue()).getItemProperty("id").getValue());
            }
            procedureBox.select(null);
            administrativeProcedureQueryContainer.refresh();
        }
    });

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

        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            final Property prop = event.getProperty();
            if (prop.getValue() == null) {
                taskBox.setEnabled(false);
            } else {
                taskBox.setEnabled(true);
                String id = procedureBox.getItem(prop.getValue()).getItemProperty("id").toString();
                final ProcessTaskQueryDefinition tSQ = new ProcessTaskQueryDefinition(Long.parseLong(id));
                final LazyQueryContainer tSC = new LazyQueryContainer(tSQ, new ProcessTaskQueryFactory());
                taskBox.setContainerDataSource(tSC);
                taskBox.setItemCaptionPropertyId("name");
            }
        }
    });

    Button actionFilter = new Button("");
    actionFilter.addShortcutListener(new Button.ClickShortcut(actionFilter, ShortcutAction.KeyCode.ENTER));
    actionFilter.addListener(new Button.ClickListener() {
        private static final long serialVersionUID = 7234774931167363716L;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            Object overdue = getField("overdue").getValue();
            controlledTasksQuery.setOverdue(Boolean.TRUE.equals(overdue));

            Object fromDate = getField("fromDate").getValue();
            controlledTasksQuery.setFromDate(fromDate != null ? (Date) fromDate : null);

            Object toDate = getField("toDate").getValue();
            controlledTasksQuery.setToDate(toDate != null ? (Date) toDate : null);

            Object requester = getField("requester").getValue();
            controlledTasksQuery.setRequester(requester != null ? requester.toString() : null);

            Object bidId = getField("bidId").getValue();
            String bidIdString = null;
            if (bidId != null) {
                bidIdString = bidId.toString();
                try {
                    Long.parseLong(bidIdString);
                } catch (NumberFormatException e) {
                    bidIdString = null;
                }
            }
            controlledTasksQuery.setBidId(bidIdString);

            Object type = getField("procedureType").getValue();
            controlledTasksQuery.setProcedureType(type != null ? type.toString() : null);

            Object serviceIdValue = getField("serviceId").getValue();
            Item serviceItem = serviceIdValue != null ? serviceBox.getItem(serviceIdValue) : null;
            String serviceId = null;
            if (serviceItem != null && serviceItem.getItemProperty("id") != null) {
                serviceId = serviceItem.getItemProperty("id").toString();
            }
            controlledTasksQuery.setServiceId(serviceId);

            Object procedureValue = getField("procedureName").getValue();
            Item procedureItem = procedureValue != null ? procedureBox.getItem(procedureValue) : null;
            String procedureId = null;
            if (procedureItem != null && procedureItem.getItemProperty("id") != null) {
                procedureId = procedureItem.getItemProperty("id").toString();
            }
            controlledTasksQuery.setProcedureId(procedureId);

            Object taskValue = getField("taskName").getValue();
            Item taskValueItem = taskValue != null ? taskBox.getItem(taskValue) : null;
            String taskKey = null;
            if (taskValue != null) {
                taskKey = taskValueItem.getItemProperty("taskDefKey") != null
                        ? taskValueItem.getItemProperty("taskDefKey").toString()
                        : null;
            }
            controlledTasksQuery.setTaskKey(taskKey);

            Object declarantTypeValue = getField("declarantType").getValue();
            Item declarantTypeValueItem = declarantTypeValue != null
                    ? declarantTypeBox.getItem(declarantTypeValue)
                    : null;
            String name = null;
            String val = null;
            if (declarantTypeValue != null) {
                name = declarantTypeValueItem.getItemProperty("name") != null
                        ? declarantTypeValueItem.getItemProperty("name").toString()
                        : null;
                val = declarantTypeValueItem.getItemProperty("value") != null
                        ? declarantTypeValueItem.getItemProperty("value").toString()
                        : null;
            }
            controlledTasksQuery.setDeclarantTypeName(name);
            controlledTasksQuery.setDeclarantTypeValue(val);

            Collection controlledOrgGroups = (Collection) getField("controlledOrgGroups").getValue();
            List<String> selectedOrgGroups = new ArrayList<String>();
            if (controlledOrgGroups.size() > 0) {
                Iterator iterator = controlledOrgGroups.iterator();
                while (iterator.hasNext()) {
                    selectedOrgGroups
                            .add(orgGroups.getItem(iterator.next()).getItemProperty("name").toString());
                }
            }
            if (mode == Mode.Supervisor) {
                controlledTasksQuery
                        .setControlledOrgGroups(controlledOrgGroups.size() != 0 ? selectedOrgGroups : null);
            }

            Collection controlledEmpGroups = (Collection) getField("controlledEmpGroups").getValue();
            List<String> selectedEmpGroups = new ArrayList<String>();
            if (controlledEmpGroups.size() > 0) {
                Iterator iterator = controlledEmpGroups.iterator();
                while (iterator.hasNext()) {
                    selectedEmpGroups
                            .add(empGroups.getItem(iterator.next()).getItemProperty("name").toString());
                }
            }
            if (mode == Mode.Supervisor) {
                controlledTasksQuery
                        .setControlledEmpGroups(controlledEmpGroups.size() != 0 ? selectedEmpGroups : null);
            }
            controlledTasksTable.refresh();

            if (executionTasksQuery != null) {
                executionTasksQuery.setFromDate(fromDate != null ? (Date) fromDate : null);
                executionTasksQuery.setToDate(toDate != null ? (Date) toDate : null);
                executionTasksQuery.setRequester(requester != null ? requester.toString() : null);
                executionTasksQuery.setBidId(bidIdString);
                executionTasksQuery.setProcedureType(type != null ? type.toString() : null);
                executionTasksQuery.setServiceId(serviceId);
                executionTasksQuery.setProcedureId(procedureId);
                executionTasksQuery.setTaskKey(taskKey);
                executionTasksQuery.setDeclarantTypeName(name);
                executionTasksQuery.setDeclarantTypeValue(val);
                executionTasksQuery.setOverdue(Boolean.TRUE.equals(overdue));
            }
            if (executionTasksTable != null) {
                executionTasksTable.refresh();
            }
        }
    });

    Button resetFilter = new Button("? ");
    resetFilter.addListener(new Button.ClickListener() {

        private static final long serialVersionUID = 7234774931167363717L;

        @Override
        public void buttonClick(Button.ClickEvent event) {

            Field overdue = getField("overdue");
            overdue.setValue(false);
            controlledTasksQuery.setOverdue(false);

            Field fromDate = getField("fromDate");
            fromDate.setValue(null);
            controlledTasksQuery.setFromDate(null);

            Field toDate = getField("toDate");
            toDate.setValue(null);
            controlledTasksQuery.setToDate(null);

            getField("requester").setValue("");
            controlledTasksQuery.setRequester(null);

            getField("bidId").setValue("");
            controlledTasksQuery.setBidId(null);

            getField("procedureType").setValue(null);
            controlledTasksQuery.setProcedureType(null);

            getField("serviceId").setValue(null);
            controlledTasksQuery.setServiceId(null);

            getField("procedureName").setValue(null);
            controlledTasksQuery.setProcedureId(null);

            getField("taskName").setValue(null);
            controlledTasksQuery.setTaskKey(null);

            getField("declarantType").setValue(null);
            controlledTasksQuery.setDeclarantTypeName(null);
            controlledTasksQuery.setDeclarantTypeValue(null);

            getField("controlledOrgGroups").setValue(null);
            if (mode == Mode.Supervisor) {
                controlledTasksQuery.setControlledOrgGroups(null);
            }

            getField("controlledEmpGroups").setValue(null);
            if (mode == Mode.Supervisor) {
                controlledTasksQuery.setControlledEmpGroups(null);
            }
            controlledTasksTable.refresh();
            if (executionTasksQuery != null) {
                executionTasksQuery.setFromDate(null);
                executionTasksQuery.setToDate(null);
                executionTasksQuery.setRequester(null);
                executionTasksQuery.setBidId(null);
                executionTasksQuery.setProcedureType(null);
                executionTasksQuery.setServiceId(null);
                executionTasksQuery.setProcedureId(null);
                executionTasksQuery.setTaskKey(null);
                executionTasksQuery.setDeclarantTypeName(null);
                executionTasksQuery.setDeclarantTypeValue(null);
                executionTasksQuery.setOverdue(false);
            }
            if (executionTasksTable != null) {
                executionTasksTable.refresh();
            }
        }
    });

    final HorizontalLayout footer = (HorizontalLayout) getFooter();
    footer.setSpacing(true);
    Button refreshLists = new Button(" ?? ?", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Flash.fire(new TaskChanged(TaskFilter.this, ""));
        }
    });
    refreshLists.setImmediate(true);
    footer.addComponent(refreshLists);
    footer.addComponent(actionFilter);
    footer.addComponent(resetFilter);
}

From source file:ru.codeinside.gses.webui.utils.Components.java

License:Mozilla Public License

public static Button createButton(final String name, ClickListener listener) {
    Button result = new Button(name);
    result.setStyleName(BaseTheme.BUTTON_LINK);
    result.addListener(listener);
    return result;
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.configeditor.ValueComponentListEditor.java

License:Open Source License

/**
 * Creates a new ValueListEditor./*  w  w  w . j  a  v a 2 s  .c o m*/
 *
 * @param valueEditModel The config value edit model representing a specific config value.
 * @param valueComponent The component to edit a list of.
 */
public ValueComponentListEditor(APSConfigValueEditModel valueEditModel, ValueComponent valueComponent) {
    this.valueEditModel = valueEditModel;

    // Setup component gui.
    this.editLine = valueComponent;
    this.editLine.enableNullValues();
    this.editLine.getComponent().setWidth("100%");
    this.editLine.getComponent().setEnabled(true);
    this.editLine.setComponentValue("", false);
    this.editLine.addListener(this.editLineListener);
    addComponent(this.editLine.getComponent());

    this.values = new ListSelect();
    this.values.setRows(4); // With the exception of 1 , 2 and 3 will give 4!
    this.values.setWidth("100%");
    this.values.setNullSelectionAllowed(false);
    this.values.setEnabled(false);
    this.values.setImmediate(true);
    this.values.addListener(this.valuesListener);
    addComponent(this.values);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    {
        Button addButton = new Button(" + ");
        addButton.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                addValue();
            }
        });
        buttonsLayout.addComponent(addButton);

        this.removeButton = new Button(" - ");
        this.removeButton.addListener(new ClickListener() {
            @Override
            public void buttonClick(ClickEvent event) {
                removeValue();
            }
        });
        this.removeButton.setEnabled(false);
        buttonsLayout.addComponent(this.removeButton);

        this.sizeLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;[ ]", Label.CONTENT_XHTML);
        this.sizeLabel.setStyleName(CSS.APS_MANYVALUE_COUNT_LABEL);
        buttonsLayout.addComponent(this.sizeLabel);
    }
    addComponent(buttonsLayout);
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEditor.java

License:Open Source License

/**
 * Builds the gui of this component./*from   w  ww  . j av  a 2 s .c o m*/
 * <p/>
 * The code in this method builds the base gui, the static parts that is only created once. It ends by calling
 * loadCurrentNodeData() to do a first time load of the root node of the ConfigNavigator.
 */
private void setupGUI() {
    this.setStyleName(CSS.APS_CONFIGID_LABEL);
    setSizeFull();

    VerticalLayout mainLayout = new VerticalLayout();
    {
        mainLayout.setSpacing(true);
        mainLayout.setMargin(true);
        mainLayout.setStyleName(CSS.APS_CONTENT_PANEL);
        mainLayout.setSizeFull();

        this.editForConfigEnvSelect = new ConfigEnvSelector();
        this.editForConfigEnvSelect.setDataSource(this.configAdminService.getConfigEnvAdmin());
        this.editForConfigEnvSelect.addListener(new ConfigEnvChangeListener() {
            @Override
            public void configEnvironmentChanged(ConfigEnvChangeEvent event) {
                handleChangedConfigEnv(event.getSelectedConfigEnvironment());
            }
        });
        mainLayout.addComponent(this.editForConfigEnvSelect);
        mainLayout.setExpandRatio(this.editForConfigEnvSelect, 1.0f);

        HorizontalLine hr = new HorizontalLine();
        mainLayout.addComponent(hr);
        mainLayout.setExpandRatio(hr, 1.0f);

        HorizontalLayout contentLayout = new HorizontalLayout();
        {
            contentLayout.setSpacing(true);
            contentLayout.setSizeFull();

            ConfigNode configNode = new ConfigNode(this.editedConfigAdmin.getConfigModel());
            if (!configNode.getNodeChildren().isEmpty()) {

                VerticalLayout nodesAndButtonsLayout = new VerticalLayout();
                {
                    nodesAndButtonsLayout.setWidth(null);
                    nodesAndButtonsLayout.setHeight("100%");
                    nodesAndButtonsLayout.setMargin(false);
                    nodesAndButtonsLayout.setSpacing(false);

                    this.nodeSelector = new NodeSelector();
                    this.nodeSelector.setHeight("100%");
                    this.nodeSelector.setWidth(null);
                    this.nodeSelector.setScrollable(true);
                    this.nodeSelector.setDataSource(this.nodeSelectorDataSource);
                    this.nodeSelector.addListener(new NodeSelectionListener() {
                        @Override
                        public void nodeSelected(NodeSelectedEvent event) {
                            selectCurrentNode(event.getSelectedModel(), event.getIndex());
                        }
                    });
                    nodesAndButtonsLayout.addComponent(this.nodeSelector);
                    nodesAndButtonsLayout.setExpandRatio(this.nodeSelector, 92.0f); // This works for iPad screen
                                                                                    // size and upp.
                    HorizontalLayout buttonsLayout = new HorizontalLayout();
                    {
                        buttonsLayout.setMargin(false);
                        buttonsLayout.setSpacing(false);
                        buttonsLayout.setHeight("100%");

                        this.addNodeButton = new Button(" + ");
                        this.addNodeButton.setEnabled(false);
                        this.addNodeButton.addListener(new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                addNodeInstance();
                            }
                        });
                        buttonsLayout.addComponent(this.addNodeButton);

                        this.removeNodeButton = new Button(" - ");
                        this.removeNodeButton.setEnabled(false);
                        this.removeNodeButton.addListener(new ClickListener() {
                            @Override
                            public void buttonClick(ClickEvent event) {
                                removeNodeInstance();
                            }
                        });
                        buttonsLayout.addComponent(this.removeNodeButton);
                    }
                    nodesAndButtonsLayout.addComponent(buttonsLayout);
                    nodesAndButtonsLayout.setExpandRatio(buttonsLayout, 8.0f);

                }
                contentLayout.addComponent(nodesAndButtonsLayout);
                contentLayout.setExpandRatio(nodesAndButtonsLayout, 1.0f);
            }

            this.configNodeValuesEditor = new ConfigNodeValuesEditor();
            {
                this.configNodeValuesEditor.setScrollable(true);
                this.configNodeValuesEditor.setWidth("100%");
                this.configNodeValuesEditor.setHeight("100%");

                this.configNodeValuesEditor.setDataSource(this.configNodeValueEditorDataSource);
            }
            contentLayout.addComponent(this.configNodeValuesEditor);
            contentLayout.setExpandRatio(this.configNodeValuesEditor, 99.0f);
        }
        mainLayout.addComponent(contentLayout);
        mainLayout.setExpandRatio(contentLayout, 96.0f);

        hr = new HorizontalLine();
        mainLayout.addComponent(hr);
        mainLayout.setExpandRatio(hr, 1.0f);

        HorizontalLayout saveCancelButtonsLayout = new HorizontalLayout();
        {
            saveCancelButtonsLayout.setSpacing(true);

            Button saveButton = new Button("Save");
            saveButton.addListener(new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    saveEdit();
                }
            });
            saveCancelButtonsLayout.addComponent(saveButton);

            Button cancelButton = new Button("Cancel");
            cancelButton.addListener(new ClickListener() {
                @Override
                public void buttonClick(ClickEvent event) {
                    cancelEdit();
                }
            });
            saveCancelButtonsLayout.addComponent(cancelButton);
        }
        mainLayout.addComponent(saveCancelButtonsLayout);
        mainLayout.setExpandRatio(saveCancelButtonsLayout, 1.0f);
    }

    setContent(mainLayout);

    refresh();
    if (this.nodeSelector != null) {
        this.nodeSelector.refreshData();
    }
}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEnvEditor.java

License:Open Source License

/**
 * Setup for editing.//  w ww .  jav  a2 s  . c  o  m
 */
private void initForEdit() {
    if (this.configEnv == null) {
        setCaption("Creating new config environment");
    } else {
        this.origName = this.configEnv.getName();
        setCaption("Editing config environment '" + this.configEnv.getName() + "'");
    }
    this.setStyleName(CSS.APS_EDITING_TEXT);

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    this.nameTextField = new TextField("Config environment name");
    if (configEnv != null) {
        this.nameTextField.setValue(this.configEnv.getName());
    }
    this.nameTextField.setColumns(30);
    this.nameTextField.setImmediate(true);
    this.nameTextField.setEnabled(
            configEnv != null && configEnv.equals(this.configEnvAdmin.getActiveConfigEnvironment()) ? false
                    : true);

    verticalLayout.addComponent(this.nameTextField);

    this.descriptionTextArea = new TextArea("Description of config environment.");
    this.descriptionTextArea.setRows(3);
    this.descriptionTextArea.setColumns(60);
    this.descriptionTextArea.setImmediate(true);
    if (configEnv != null) {
        this.descriptionTextArea.setValue(this.configEnv.getDescription());
    }
    verticalLayout.addComponent(this.descriptionTextArea);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    verticalLayout.addComponent(horizontalLayout);
    horizontalLayout.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            saveConfigEnv();
        }
    });
    horizontalLayout.addComponent(saveButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            cancel();
        }
    });
    horizontalLayout.addComponent(cancelButton);

    setContent(verticalLayout);

}

From source file:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEnvEditor.java

License:Open Source License

/**
 * Setup for deleting.//from w  w w .  j a  va  2 s.c  om
 */
private void initForDelete() {
    setCaption("Deleting config environment '" + this.configEnv.getName() + "'");
    setStyleName("aps-editing-text");

    VerticalLayout verticalLayout = new VerticalLayout();
    verticalLayout.setMargin(true);
    verticalLayout.setSpacing(true);
    verticalLayout.setStyleName(CSS.APS_EDITING_TEXT + " " + CSS.APS_CONTENT_PANEL);

    Label nameLabel = new Label("Config environment name:");
    verticalLayout.addComponent(nameLabel);
    Panel confNamePanel = new Panel();
    Label nameValue = new Label(this.configEnv.getName());
    confNamePanel.addComponent(nameValue);
    verticalLayout.addComponent(confNamePanel);

    Label descLabel = new Label("Description of config environment:");
    verticalLayout.addComponent(descLabel);
    Panel confNameDescPanel = new Panel();
    Label descValue = new Label(this.configEnv.getDescription());
    confNameDescPanel.addComponent(descValue);
    verticalLayout.addComponent(confNameDescPanel);

    HorizontalLayout horizontalLayout = new HorizontalLayout();
    horizontalLayout.setMargin(false);
    horizontalLayout.setSpacing(true);
    verticalLayout.addComponent(horizontalLayout);

    Button deleteButton = new Button("Delete");
    deleteButton.addListener(new ClickListener() {
        /** click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            deleteConfigEnv();
        }
    });
    if (this.configEnv.equals(this.configEnvAdmin.getActiveConfigEnvironment())) {
        deleteButton.setEnabled(false);
    }
    horizontalLayout.addComponent(deleteButton);

    Button cancelButton = new Button("Cancel");
    cancelButton.addListener(new ClickListener() {
        /** Click handling. */
        @Override
        public void buttonClick(ClickEvent event) {
            cancel();
        }
    });
    horizontalLayout.addComponent(cancelButton);

    setContent(verticalLayout);

}