Java 类com.vaadin.ui.TableFieldFactory 实例源码

项目:incubator-openaz    文件:EnumerationEditorComponent.java   
private void initializeTable() {
    //
    // Add the current enumeration values into the
    // bean container.
    //
    for (ConstraintValue value : this.attribute.getConstraintValues()) {
        if (value.getProperty().equals("Enumeration")) {
            this.beanContainer.addBean(value);
        }
    }
    //
    // Now hook the bean container to the table
    //
    this.tableEnumerations.setContainerDataSource(beanContainer);
    //
    // We have to manually create the text field because we need
    // to set a validator.
    //
    this.tableEnumerations.setTableFieldFactory(new TableFieldFactory() {
        private static final long serialVersionUID = 1L;

        @Override
        public Field<?> createField(Container container, Object itemId,
                Object propertyId, Component uiContext) {
            if (propertyId.toString().equals("value")) {
                final TextField text = new TextField();
                text.setImmediate(true);
                text.setNullRepresentation("");
                text.setNullSettingAllowed(false);
                text.setRequired(true);
                text.setRequiredError("Cannot have empty enumeration values.");
                text.addValidator(self);
                return text;
            }
            return null;
        }
    });
    //
    // Finish setting up the table.
    //
    this.tableEnumerations.setVisibleColumns(new Object[] {"value"});
    this.tableEnumerations.setColumnHeaders(new String[] {"Enumeration Value"});
    this.tableEnumerations.setSelectable(true);
    this.tableEnumerations.setEditable(true);
    this.tableEnumerations.setImmediate(true);
    if (this.tableEnumerations.size() == 0) {
        this.tableEnumerations.setPageLength(3);
    } else {
        this.tableEnumerations.setPageLength(this.tableEnumerations.size() + 1);
    }
    //
    // As the user select items, enable/disable buttons
    //
    this.tableEnumerations.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.buttonRemove.setEnabled(self.tableEnumerations.getValue() != null);
        }

    });
}
项目:XACML    文件:EnumerationEditorComponent.java   
private void initializeTable() {
    //
    // Add the current enumeration values into the
    // bean container.
    //
    for (ConstraintValue value : this.attribute.getConstraintValues()) {
        if (value.getProperty().equals("Enumeration")) {
            this.beanContainer.addBean(value);
        }
    }
    //
    // Now hook the bean container to the table
    //
    this.tableEnumerations.setContainerDataSource(beanContainer);
    //
    // We have to manually create the text field because we need
    // to set a validator.
    //
    this.tableEnumerations.setTableFieldFactory(new TableFieldFactory() {
        private static final long serialVersionUID = 1L;

        @Override
        public Field<?> createField(Container container, Object itemId,
                Object propertyId, Component uiContext) {
            if (propertyId.toString().equals("value")) {
                final TextField text = new TextField();
                text.setImmediate(true);
                text.setNullRepresentation("");
                text.setNullSettingAllowed(false);
                text.setRequired(true);
                text.setRequiredError("Cannot have empty enumeration values.");
                text.addValidator(self);
                return text;
            }
            return null;
        }
    });
    //
    // Finish setting up the table.
    //
    this.tableEnumerations.setVisibleColumns(new Object[] {"value"});
    this.tableEnumerations.setColumnHeaders(new String[] {"Enumeration Value"});
    this.tableEnumerations.setSelectable(true);
    this.tableEnumerations.setEditable(true);
    this.tableEnumerations.setImmediate(true);
    if (this.tableEnumerations.size() == 0) {
        this.tableEnumerations.setPageLength(3);
    } else {
        this.tableEnumerations.setPageLength(this.tableEnumerations.size() + 1);
    }
    //
    // As the user select items, enable/disable buttons
    //
    this.tableEnumerations.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            self.buttonRemove.setEnabled(self.tableEnumerations.getValue() != null);
        }

    });
}
项目:konekti    文件:CalendarView.java   
private void initView() {
    // initialize Slide View Organization View
    dgCalendar.setImmediate(true);      

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {
        dgCalendar.setBindingSource(bsCalendar);
        dgCalendar.setVisibleColumns(new String[] { "name", "description", "calendarType.description", "calendarFromDate", "calendarToDate", "observation", "active" } );       
        dgCalendar.setColumnHeaders(new String[] { "Nombre", "Descripción", "Tipo", "Fecha Inicio", "Fecha Fin", "Observaciones", "Activo" } );
        dgCalendar.setEditable(true);
        dgCalendar.setTableFieldFactory(new TableFieldFactory() {                   
            @Override
            public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
                if("active".equals(propertyId)) {                       
                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);                        
                    return field;
                }

                return null;
            }
        });

        dgCalendar.setColumnCollapsed("observation", true);
    }
    catch(Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Organization View
    navigationToolbar = new NavigationToolbar(0, bsCalendar, viewContainer);
    editionToolbar = new EditionToolbar(1, bsCalendar);
    boxToolbar = new BoxToolbar(2, bsCalendar);

    navigationToolbar.addListenerDownButton(this);
    navigationToolbar.addListenerRefreshButton(this);       

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);
    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);

}
项目:konekti    文件:JobView.java   
private void initView() {
    // initialize Slide View Organization View
    dgJob.setImmediate(true);

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {
        dgJob.setBindingSource(bsJob);
        dgJob.addGeneratedColumn(JobNameColumn.JOB_NAME_COLUMN_ID, new JobNameColumn());
        dgJob.addGeneratedColumn(JobTriggerTypeColumn.JOB_TRIGGER_TYPE_DESCRIPTION_COLUMN_ID, new JobTriggerTypeColumn());
        dgJob.setVisibleColumns(new String[] {JobNameColumn.JOB_NAME_COLUMN_ID, "jobName", "jobGroup", "description", JobTriggerTypeColumn.JOB_TRIGGER_TYPE_DESCRIPTION_COLUMN_ID, "jobTriggerPriority",
                "startTime", "endTime", "jobInterval", "repeatCount", "jobCalendar", "future", "future_time", "cronExpression", "lastExecution", "error", "active" });
        dgJob.setColumnHeaders(new String[] { "Ubicación", "Nombre", "Grupo", "Descripción", "Tipo Disparador", "Prioridad Disparador", "Fecha Comienzo", "Fecha Fin",
                "Intervalo [s]", "Repetición", "Calendario", "Futuro", "Fecha Futuro", "Expresión Cron", "Ultima Ejecución", "Error", "Activa"});           
        dgJob.setEditable(true);

        dgJob.setColumnCollapsed("jobTriggerType.description", true);
        dgJob.setColumnCollapsed("jobTriggerPriority", true);
        //dgJob.setColumnCollapsed("startTime", true);
        //dgJob.setColumnCollapsed("endTime", true);
        dgJob.setColumnCollapsed("jobInterval", true);
        dgJob.setColumnCollapsed("repeatCount", true);
        dgJob.setColumnCollapsed("jobCalendar", true);
        dgJob.setColumnCollapsed("future", true);
        dgJob.setColumnCollapsed("future_time", true);
        dgJob.setColumnCollapsed("cronExpression", true);

        dgJob.setTableFieldFactory(new TableFieldFactory() {                    
            @Override
            public Field createField(Container container, Object itemId,
                    Object propertyId, Component uiContext) {
                if("active".equals(propertyId) || "error".equals(propertyId) || "future".equals(propertyId)) {                      
                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);                        
                    return field;
                }

                return null;
            }
        });

    } catch (Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Employee Agent View
    navigationToolbar = new NavigationToolbar(0, bsJob, viewContainer);
    editionToolbar = new EditionToolbar(1, bsJob);
    boxToolbar = new BoxToolbar(2, bsJob);      
    jobToolbar = new JobToolbar(3, bsJob, viewContainer);

    navigationToolbar.addListenerRefreshButton(this);
    navigationToolbar.addListenerUpButton(this);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);
    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);

    jobToolbar.addListenerStartJobButton(this);
    jobToolbar.addListenerStopJobButton(this);

    dgJob.addListenerAddButton(this);
    dgJob.addListenerEditButton(this);
    dgJob.addListenerDeleteButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);
    addToolbar(jobToolbar);

}
项目:konekti    文件:ClientView.java   
private void initView() {
    // initialize Slide View Organization View
    dgClient.setImmediate(true);
    dgClient.setSelectable(true);

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {
        // add nested columns
        bsClient.addNestedContainerProperty("address.street");

        // bind datasource
        dgClient.setBindingSource(bsClient);

        // add visible and collapsed columns
        dgClient.setVisibleColumns(new String[] { "agentId", "code", "name", "description", "vat", "comment", "clientType.description", "clientGroup.description", "address.street", "active" });
        dgClient.setColumnHeaders(new String[] { "Id", "Código", "Nombre", "Descripción", "VAT", "Comentarios", "Tipo", "Grupo", "Dirección", "Activo" });              
        dgClient.setEditable(true);
        dgClient.setTableFieldFactory(new TableFieldFactory() {
            @Override
            public Field createField(Container container, Object itemId,
                    Object propertyId, Component uiContext) {
                if ("active".equals(propertyId)) {
                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);
                    return field;
                }

                return null;
            }
        });

        dgClient.setColumnCollapsed("agentId", true);
        dgClient.setColumnCollapsed("address.street", true);
    } catch (Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Employee Agent View
    navigationToolbar = new NavigationToolbar(0, bsClient, viewContainer);
    editionToolbar = new EditionToolbar(1, bsClient);
    boxToolbar = new BoxToolbar(2, bsClient);

    navigationToolbar.addListenerRefreshButton(this);
    navigationToolbar.setUpButton(false);
    navigationToolbar.setDownButton(false);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);

    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.setImportButton(true);

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);    
    boxToolbar.addListenerImportButton(this);       

    dgClient.addListenerAddButton(this);
    dgClient.addListenerEditButton(this);
    dgClient.addListenerDeleteButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);

}
项目:konekti    文件:ReportView.java   
private void initView() {
    // initialize Slide View Organization View
    dgReport.setImmediate(true);
    dgReport.setSelectable(true);

    refreshBindindSource();

    try {
        bsReport.addNestedContainerProperty("organization.description");

        dgReport.setBindingSource(bsReport);
        dgReport.setVisibleColumns(new String[] { "reportId", "organization.description", "code", "description", "active" });
        dgReport.setColumnHeaders(new String[] { "Id", "Organización", "Codigo", "Descripción", "Activo" });                
        dgReport.setEditable(true);
        dgReport.setTableFieldFactory(new TableFieldFactory() {
            @Override
            public Field createField(Container container, Object itemId,
                    Object propertyId, Component uiContext) {
                if ("active".equals(propertyId)) {
                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);
                    return field;
                }

                return null;
            }
        });

        dgReport.setColumnCollapsed("reportId", true);
    } catch (Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Employee Agent View
    navigationToolbar = new NavigationToolbar(0, bsReport, viewContainer);
    editionToolbar = new EditionToolbar(1, bsReport);
    boxToolbar = new BoxToolbar(2, bsReport);
    reportToolbar = new ReportToolbar(3, bsReport);

    navigationToolbar.addListenerRefreshButton(this);
    navigationToolbar.setUpButton(false);
    navigationToolbar.setDownButton(false);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);
    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);        

    reportToolbar.addListenerExecuteReportButton(this);

    dgReport.addListenerAddButton(this);
    dgReport.addListenerEditButton(this);
    dgReport.addListenerDeleteButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);
    //addToolbar(reportToolbar);

}
项目:konekti    文件:ProductView.java   
private void initView() {
    // initialize Slide View Organization View
    dgProduct.setImmediate(true);

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {           
        bsProduct.addNestedContainerProperty("supplier.name");

        dgProduct.setBindingSource(bsProduct);

        dgProduct.setVisibleColumns(new String[] { "code", "name", "description", "hasLote", "hasSerialNumber", "hasExpeditionDate", "averagePrice", "productType.description", "supplier.name", "productActive" } );       
        dgProduct.setColumnHeaders(new String[] { "Código", "Nombre", "Descripción", "Con Lote", "Con Númnero Serie", "Con Fecha Caducidad", "Precio Medio", "Tipo", "Proveedor", "Activo" } );
        dgProduct.setEditable(true);
        dgProduct.setTableFieldFactory(new TableFieldFactory() {                    
            @Override
            public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
                if("hasLote".equals(propertyId) || "hasSerialNumber".equals(propertyId) || "hasExpeditionDate".equals(propertyId) || "productActive".equals(propertyId)) {

                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);
                    return field;
                }

                return null;
            }
        });

        dgProduct.setColumnCollapsed("code", true);
    }
    catch(Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Employee Agent View
    navigationToolbar = new NavigationToolbar(0, bsProduct, viewContainer);
    editionToolbar = new EditionToolbar(1, bsProduct);
    boxToolbar = new BoxToolbar(2, bsProduct);

    navigationToolbar.addListenerRefreshButton(this);
    navigationToolbar.setUpButton(false);
    navigationToolbar.setDownButton(false);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);
    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);
    boxToolbar.addListenerImportButton(this);

    boxToolbar.setImportButton(true);

    dgProduct.addListenerAddButton(this);
    dgProduct.addListenerEditButton(this);
    dgProduct.addListenerDeleteButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);

}
项目:konekti    文件:SupplierView.java   
private void initView() {
    // initialize Slide View Organization View
    dgSupplier.setImmediate(true);

    refreshBindindSource();

    // STEP 01: create grid view for slide Organization View
    try {
        // add nested columns
        bsSupplier.addNestedContainerProperty("address.street");

        // bind datasource
        dgSupplier.setBindingSource(bsSupplier);

        // add visible and collapsed columns
        dgSupplier.setVisibleColumns(new String[] { "agentId", "code", "name", "description", "vat", "comment", "supplierType.description", "supplierGroup.description", "address.street", "active" });
        dgSupplier.setColumnHeaders(new String[] { "Id", "Código", "Nombre", "Descripción", "VAT", "Comentarios", "Tipo", "Grupo", "Dirección", "Activo" });        
        dgSupplier.setEditable(true);
        dgSupplier.setTableFieldFactory(new TableFieldFactory() {
            @Override
            public Field createField(Container container, Object itemId,
                    Object propertyId, Component uiContext) {
                if ("active".equals(propertyId)) {
                    CheckBox field = new CheckBox();
                    field.setReadOnly(true);
                    return field;
                }

                return null;
            }
        });

        dgSupplier.setColumnCollapsed("agentId", true);
        dgSupplier.setColumnCollapsed("address.street", true);

    } catch (Exception ex) {
        ex.getMessage();
    }

    // STEP 02: create toolbar for slide Employee Agent View
    navigationToolbar = new NavigationToolbar(0, bsSupplier, viewContainer);
    editionToolbar = new EditionToolbar(1, bsSupplier);
    boxToolbar = new BoxToolbar(2, bsSupplier);

    navigationToolbar.addListenerRefreshButton(this);
    navigationToolbar.setUpButton(false);
    navigationToolbar.setDownButton(false);

    editionToolbar.addListenerAddButton(this);
    editionToolbar.addListenerEditButton(this);
    editionToolbar.addListenerDeleteButton(this);

    editionToolbar.setPermission(context.getUser(), viewContainer.getModule().getSymbolicName(), viewContainer.getModule().getVersion());

    boxToolbar.addListenerFilterButton(this);
    boxToolbar.addListenerPrintButton(this);
    boxToolbar.addListenerImportButton(this);

    boxToolbar.setImportButton(true);

    dgSupplier.addListenerAddButton(this);
    dgSupplier.addListenerEditButton(this);
    dgSupplier.addListenerDeleteButton(this);

    removeAllToolbar();

    addToolbar(navigationToolbar);
    addToolbar(editionToolbar);
    addToolbar(boxToolbar);

}