Example usage for com.vaadin.ui Window Window

List of usage examples for com.vaadin.ui Window Window

Introduction

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

Prototype

public Window() 

Source Link

Document

Creates a new, empty window.

Usage

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

License:Mozilla Public License

private Component buttonCreateEmployee(final Long id) {
    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);/*from  ww  w.j av  a2  s  .c  o m*/
    buttons.setMargin(false, true, false, false);
    addComponent(buttons);
    Button createUser = new Button(" ?", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

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

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

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

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

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

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

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

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

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

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

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

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

                private static final long serialVersionUID = -7193894183022375021L;

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

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

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

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

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

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

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

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

                private static final long serialVersionUID = 1L;

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

        }

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

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

License:Mozilla Public License

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

    ClickListener listener = new ClickListener() {

        private static final long serialVersionUID = -8900212370037948964L;

        @Override//www. j  a va2  s  . co  m
        public void buttonClick(ClickEvent event) {
            Window mainWin = event.getButton().getApplication().getMainWindow();

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

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

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

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

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

            private static final long serialVersionUID = 2966059295049064338L;

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

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

                    }
                }

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

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

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

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

                    private static final long serialVersionUID = 3229924940535642819L;

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

                });

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

                    private static final long serialVersionUID = 4502614143261892063L;

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

    Button b = new Button("");

    b.addListener(new ClickListener() {

        private static final long serialVersionUID = 1362078893385574138L;

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

                private static final long serialVersionUID = 456334952891567271L;

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

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

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

    ObjectProperty<Component> buttonProperty = null;

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

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

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

            private static final long serialVersionUID = 1362078893385574138L;

            @Override
            public void buttonClick(ClickEvent event) {

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

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

From source file:ru.codeinside.gses.webui.executor.ArchiveFactory.java

License:Mozilla Public License

static Window createFormWindow(Component su, ActivityImpl ac, String id) {
    VerticalLayout content = new VerticalLayout();
    content.setMargin(true);/*from  ww  w .j a  va 2 s.c  om*/
    content.addComponent(su);
    Window window = new Window();
    window.setWidth(800 + 50, Sizeable.UNITS_PIXELS);
    window.setHeight(600 + 100, Sizeable.UNITS_PIXELS);
    window.center();
    window.setContent(content);
    window.setCaption(" ? " + ac.getId() + "  ? #" + id);
    if (su instanceof JsonFormIntegration || su instanceof ExpandRequired) {
        content.setSizeFull();
        content.setExpandRatio(su, 1f);
    } else {
        window.setResizable(false); //  ?  
    }
    return window;
}

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 ww .  j  av  a 2  s.  co  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:ui.button.ShowAchievementsButton.java

License:Apache License

private void showOnWindow() {
    final Window window = new Window();
    window.setWidth("95%");
    window.setHeight("95%");
    window.center();/*from   w ww .  j ava2s.c  o m*/
    window.setResizable(true);
    window.setModal(true);
    window.addCloseListener(new Window.CloseListener() {

        @Override
        public void windowClose(Window.CloseEvent e) {
            window.close();
        }
    });
    window.setContent(new UserTabSheet(userId, language));
    getUI().addWindow(window);
    window.setStyleName("window");
}