Example usage for com.vaadin.ui HorizontalLayout setSizeFull

List of usage examples for com.vaadin.ui HorizontalLayout setSizeFull

Introduction

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

Prototype

@Override
    public void setSizeFull() 

Source Link

Usage

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/*  ww w  . ja va2s  .  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();//from  w  w w .j a  va2  s.c o 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:se.natusoft.osgi.aps.apsconfigadminweb.gui.vaadin.components.ConfigEditor.java

License:Open Source License

/**
 * Builds the gui of this component./* ww  w.ja  v  a2 s .  co 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.apsuseradminweb.vaadin.components.editors.RoleEditor.java

License:Open Source License

/**
 * Creates a new RoleEditor instance./*from   w  ww. j ava2  s .  com*/
 *
 * @param userServiceAdmin The user admin service for editing the role.
 */
public RoleEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;

    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);

    // Role id, master and description.
    {
        HorizontalLayout horizLayout = new HorizontalLayout();
        horizLayout.setSpacing(true);

        this.idTextField = new TextField("Role id");
        this.idTextField.setColumns(30);
        this.idTextField.setImmediate(false);
        this.idTextField.setEnabled(true);
        horizLayout.addComponent(this.idTextField);

        this.masterRole = new CheckBox("Master Role");
        this.masterRole.setImmediate(false);
        this.masterRole.setEnabled(true);
        horizLayout.addComponent(this.masterRole);

        verticalLayout.addComponent(horizLayout);

        this.descriptionTextArea = new TextArea("Description of role");
        this.descriptionTextArea.setRows(3);
        this.descriptionTextArea.setColumns(60);
        this.descriptionTextArea.setImmediate(false);
        this.descriptionTextArea.setEnabled(true);
        verticalLayout.addComponent(this.descriptionTextArea);
    }

    // Roles
    {
        HorizontalLayout rolesLayout = new HorizontalLayout();
        rolesLayout.setSizeFull();

        // Available
        this.availableRoles = new Table("Available roles");
        this.availableRoles.setImmediate(true);
        this.availableRoles.setPageLength(10);
        this.availableRoles.setSortAscending(true);
        this.availableRoles.setSizeFull();
        this.availableRoles.setDragMode(Table.TableDragMode.ROW);
        this.availableRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                removeSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.availableRoles);
            }
        });
        VerticalLayout availableRolesFrame = new VerticalLayout();
        availableRolesFrame.setMargin(false, true, false, false);
        availableRolesFrame.addComponent(this.availableRoles);
        rolesLayout.addComponent(availableRolesFrame);

        // Selected
        this.selectedRoles = new Table("Selected sub roles of the role");
        this.selectedRoles.setImmediate(true);
        this.selectedRoles.setPageLength(10);
        this.selectedRoles.setSortAscending(true);
        this.selectedRoles.setSizeFull();
        this.selectedRoles.setDragMode(Table.TableDragMode.ROW);
        this.selectedRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                addSubRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(RoleEditor.this.selectedRoles);
            }
        });
        VerticalLayout selectedRolesFrame = new VerticalLayout();
        selectedRolesFrame.setMargin(false, false, false, true);
        selectedRolesFrame.addComponent(this.selectedRoles);
        rolesLayout.addComponent(selectedRolesFrame);

        rolesLayout.setExpandRatio(availableRolesFrame, 0.5f);
        rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f);

        verticalLayout.addComponent(rolesLayout);

        /* Help text for the role tables. */
        HelpText roleHelptext = new HelpText(
                "Drag and drop roles back and forth to set or remove a role. Also note that it is fully possible to "
                        + "create circular role dependencies. Don't!");
        verticalLayout.addComponent(roleHelptext);
    }

    // Save / Cancel
    {
        HorizontalLayout horizontalLayout = new HorizontalLayout();
        verticalLayout.addComponent(horizontalLayout);
        horizontalLayout.setSpacing(true);

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

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

    setContent(verticalLayout);
}

From source file:se.natusoft.osgi.aps.apsuseradminweb.vaadin.components.editors.UserEditor.java

License:Open Source License

/**
 * Creates a new UserEditor instance./*from   w  w w  .java2 s  .  co  m*/
 *
 * @param userServiceAdmin The user admin service for editing the user.
 */
public UserEditor(APSSimpleUserServiceAdmin userServiceAdmin) {
    this.userServiceAdmin = userServiceAdmin;

    this.setStyleName(CSS.APS_EDITING_TEXT);

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

    // User id & Auth
    {
        HorizontalLayout firstRowLayout = new HorizontalLayout();
        firstRowLayout.setSpacing(true);

        this.userId = new TextField("User id");
        this.userId.setColumns(30);
        this.userId.setImmediate(true);
        this.userId.setEnabled(true);

        firstRowLayout.addComponent(this.userId);

        this.authCurrent = new PasswordField("Current auth");
        this.authCurrent.setColumns(30);
        this.authCurrent.setImmediate(true);
        this.authCurrent.setEnabled(true);

        firstRowLayout.addComponent(this.authCurrent);

        verticalLayout.addComponent(firstRowLayout);

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

        this.authNewOne = new PasswordField("New auth");
        this.authNewOne.setColumns(30);
        this.authNewOne.setImmediate(true);
        this.authNewOne.setEnabled(true);

        secondRowLayout.addComponent(this.authNewOne);

        this.authNewTwo = new PasswordField("New auth confirm");
        this.authNewTwo.setColumns(30);
        this.authNewTwo.setImmediate(true);
        this.authNewTwo.setEnabled(true);

        secondRowLayout.addComponent(this.authNewTwo);

        verticalLayout.addComponent(secondRowLayout);
    }

    // User Properties
    {
        this.propertiesEditor = new Table();
        this.propertiesEditor.setSelectable(true);
        this.propertiesEditor.setCaption("User properties");
        this.propertiesEditor.setPageLength(8);
        this.propertiesEditor.setEditable(true);
        this.propertiesEditor.setSizeFull();
        this.propertiesEditor.setColumnExpandRatio(USER_PROPS_KEY, 0.3f);
        this.propertiesEditor.setColumnExpandRatio(USER_PROPS_VALUE, 0.7f);
        this.propertiesEditor.setTableFieldFactory(new EditFieldFactory());
        this.propertiesEditor.addListener(new ItemClickEvent.ItemClickListener() {
            @Override
            public void itemClick(ItemClickEvent event) {
                selectDeselectProperty(event.getItemId());
            }
        });
        verticalLayout.addComponent(this.propertiesEditor);

        // Buttons + info row
        {
            HorizontalLayout plusMinusRow = new HorizontalLayout();
            plusMinusRow.setSpacing(true);

            this.plusButton = new Button("+");
            this.plusButton.addListener(new Button.ClickListener() {
                @Override
                public void buttonClick(Button.ClickEvent event) {
                    addProperty();
                }
            });
            plusMinusRow.addComponent(this.plusButton);

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

            this.propsHelpText = new HelpText(
                    "Press + to add new property, select property and press - to delete.");
            plusMinusRow.addComponent(this.propsHelpText);

            verticalLayout.addComponent(plusMinusRow);
        }
    }

    // Roles
    {
        HorizontalLayout rolesLayout = new HorizontalLayout();
        rolesLayout.setSizeFull();

        // Available
        this.availableRoles = new Table("Available roles");
        this.availableRoles.setImmediate(true);
        this.availableRoles.setPageLength(10);
        this.availableRoles.setSortAscending(true);
        this.availableRoles.setSizeFull();
        this.availableRoles.setDragMode(Table.TableDragMode.ROW);
        this.availableRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                removeRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(UserEditor.this.availableRoles);
            }
        });
        VerticalLayout availableRolesFrame = new VerticalLayout();
        availableRolesFrame.setMargin(false, true, false, false);
        availableRolesFrame.addComponent(this.availableRoles);
        rolesLayout.addComponent(availableRolesFrame);

        // Selected
        this.selectedRoles = new Table("Selected roles");
        this.selectedRoles.setImmediate(true);
        this.selectedRoles.setPageLength(10);
        this.selectedRoles.setSortAscending(true);
        this.selectedRoles.setSizeFull();
        this.selectedRoles.setDragMode(Table.TableDragMode.ROW);
        this.selectedRoles.setDropHandler(new DropHandler() {
            @Override
            public void drop(DragAndDropEvent event) {
                DataBoundTransferable t = (DataBoundTransferable) event.getTransferable();
                Object itemId = t.getItemId();
                addRole(itemId);
            }

            @Override
            public AcceptCriterion getAcceptCriterion() {
                return new RoleAcceptCriterion(UserEditor.this.selectedRoles);
            }
        });
        VerticalLayout selectedRolesFrame = new VerticalLayout();
        selectedRolesFrame.setMargin(false, false, false, true);
        selectedRolesFrame.addComponent(this.selectedRoles);
        rolesLayout.addComponent(selectedRolesFrame);

        rolesLayout.setExpandRatio(availableRolesFrame, 0.5f);
        rolesLayout.setExpandRatio(selectedRolesFrame, 0.5f);

        verticalLayout.addComponent(rolesLayout);

        this.roleHelptext = new HelpText("Drag and drop roles back and forth to set or remove a role.");
        verticalLayout.addComponent(this.roleHelptext);
    }

    // Save & Cancel
    {
        HorizontalLayout saveCancelLayout = new HorizontalLayout();
        saveCancelLayout.setSpacing(true);

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

        Button cancelButton = new Button("Cancel");
        cancelButton.addListener(new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                cancel();
            }
        });
        saveCancelLayout.addComponent(cancelButton);

        verticalLayout.addComponent(saveCancelLayout);
    }

    setContent(verticalLayout);
}

From source file:ui.item.JobApplicationInfoView.java

public JobApplicationInfoView(Integer userId, String language, JobApplication jobApplication) {
    super(userId, language, jobApplication);
    // Title//from   www.  j av a  2 s .  c om
    getTitle().addComponent(new LifetimeLabel(String.valueOf(jobApplication.getJobOfferId())));
    // Body
    Label email = new LifetimeLabel(jobApplication.getEmailText(), ContentMode.HTML);
    HorizontalLayout contact = new HorizontalLayout(email);
    contact.setSpacing(true);
    contact.setSizeFull();
    getBody().addComponent(contact);
}

From source file:ui.item.OrganizationInfoView.java

public OrganizationInfoView(Integer userId, String language, Organization organization) {
    super(userId, language, organization);
    // Title/*  w ww .  java 2  s  . c o m*/
    getTitle().addComponent(new LifetimeLabel(String.valueOf(organization.getFullname())));
    // Body
    Label url = new LifetimeLabel(organization.getUrl(), ContentMode.HTML);
    HorizontalLayout urlLayout = new HorizontalLayout(url);
    urlLayout.setSpacing(true);
    urlLayout.setSizeFull();
    getBody().addComponent(urlLayout);
}

From source file:ui.wizard.CreateEmailStep.java

License:Apache License

@Override
public Component getContent() {
    HorizontalLayout view = new HorizontalLayout(email, output);
    view.setSpacing(true);// w  w  w  .  j  a v  a 2  s.co m
    view.setMargin(true);
    view.setSizeFull();
    return view;
}

From source file:ui.wizard.CreateLetterStep.java

License:Apache License

@Override
public Component getContent() {
    coverLetterComboBox = new CoverLetterComboBox(getLanguage());
    coverLetterComboBox.addValueChangeListener(this);
    pdfView = new PdfLayout(getUserId(), getLanguage());
    HorizontalLayout view = new HorizontalLayout(coverLetterComboBox, pdfView);
    view.setSpacing(true);//from w w w .  j  a v a 2 s . c  om
    view.setMargin(true);
    view.setSizeFull();
    return view;
}

From source file:ui.wizard.CVStep.java

License:Apache License

@Override
public Component getContent() {
    if (cvConfigForm == null) {
        cvConfigForm = new CVConfigForm(getUserId(), getLanguage());
        cvConfigForm.getCvType().addValueChangeListener(this);
        cvConfigForm.getStartDate().addValueChangeListener(this);
        cvConfigForm.getEndDate().addValueChangeListener(this);
    }/*from  w  ww .j a  va2  s  .  c  o  m*/
    if (pdfUtility == null) {

        pdfUtility = new PdfUtility(getUserId(), getLanguage(), cvConfigForm.getComparator(),
                cvConfigForm.getStartDate().getValue(), cvConfigForm.getEndDate().getValue());

        pdfUtility.createPdf();
    }
    if (pdfLayout == null) {
        pdfLayout = new PdfLayout(getUserId(), getLanguage());
        pdfLayout.addPdf(pdfUtility.getBytes());
    }
    HorizontalLayout view = new HorizontalLayout(cvConfigForm, pdfLayout);
    view.setSpacing(true);
    view.setMargin(true);
    view.setSizeFull();

    return view;
}