Example usage for com.google.gwt.user.cellview.client Column setFieldUpdater

List of usage examples for com.google.gwt.user.cellview.client Column setFieldUpdater

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client Column setFieldUpdater.

Prototype

public void setFieldUpdater(FieldUpdater<T, C> fieldUpdater) 

Source Link

Document

Set the FieldUpdater used for updating values in the column.

Usage

From source file:tn.spindox.client.ui.CellTableFieldUpdaterExample.java

License:Apache License

public CellTable<Person> getTable() {

    // Create a CellTable with a key provider.
    final CellTable<Person> table = new CellTable<Person>(KEY_PROVIDER);
    table.setWidth("100%", false);

    // Add a date column to show the birthday.
    CheckboxCell checkBoxCell = new CheckboxCell();
    Column<Person, Boolean> SelectedColumn = new Column<Person, Boolean>(checkBoxCell) {
        @Override/*from  w w w  .  j  a  v  a2 s  . c o  m*/
        public Boolean getValue(Person object) {
            return object.selected;
        }
    };

    TextColumn<Person> firstNameColumn = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            // Return the name as the value of this column.
            return object.firstName;
        }
    };
    TextColumn<Person> lastNameColumn = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            // Return the name as the value of this column.
            return object.lastName;
        }
    };
    TextColumn<Person> birthDateColumn = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            // Return the name as the value of this column.
            return object.birthDate;
        }
    };
    TextColumn<Person> RegionColumn = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            // Return the name as the value of this column.
            return object.region;
        }
    };
    TextColumn<Person> emailColumn = new TextColumn<Person>() {
        @Override
        public String getValue(Person object) {
            // Return the name as the value of this column.
            return object.email;
        }
    };

    // Add a field updater to be notified when the user enters a new name.
    SelectedColumn.setFieldUpdater(new FieldUpdater<Person, Boolean>() {

        @Override
        public void update(int index, Person person, Boolean value) {

            if (value) {
                person.selected = true;
            } else {
                person.selected = false;
            }
        }

    });

    ButtonCell editCell = new ButtonCell();
    Column<Person, String> editColumn = new Column<Person, String>(editCell) {
        @Override
        public String getValue(Person object) {
            return "edit";
        }
    };

    editColumn.setFieldUpdater(new FieldUpdater<Person, String>() {

        @Override
        public void update(int index, Person object, String value) {

            System.out.println("-----------> clicked");

            callLoginDialogBox();
        }

        protected void callLoginDialogBox() {
            EditPersonBox editPersonBox = new EditPersonBox();

            editPersonBox.show();
        }

    });

    ButtonCell deleteCell = new ButtonCell();
    Column<Person, String> deleteColumn = new Column<Person, String>(deleteCell) {
        @Override
        public String getValue(Person object) {
            return "delete";
        }
    };

    deleteColumn.setFieldUpdater(new FieldUpdater<Person, String>() {

        @Override
        public void update(int index, Person person, String value) {

            System.out.println("-----------> delete clicked");

            Employee e = new Employee();
            e.setId_pers(person.id);
            e.setFirstName(person.firstName);
            e.setLastName(person.lastName);
            e.setBirthDate(person.birthDate);
            e.setRegion(person.region);
            e.setEmail(person.email);

            serverPerson.delete(e, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    System.out.println("---> Error while deleting employee");
                }

                @Override
                public void onSuccess(Void result) {
                    System.out.println("---> deleting success !!! ");
                    table.redraw();
                }

            });

        }

    });

    table.addColumn(SelectedColumn, "");
    table.addColumn(firstNameColumn, "First Name");
    table.addColumn(lastNameColumn, "Last Name");
    table.addColumn(birthDateColumn, "Birth Date");
    table.addColumn(RegionColumn, "Region");
    table.addColumn(emailColumn, "Email");
    table.addColumn(editColumn, "");
    table.addColumn(deleteColumn, "");

    // Push the data into the widget.
    // table.setRowData(CONTACTS);

    final EmployeeServiceAsync server = GWT.create(EmployeeService.class);
    server.getListEmployees(new AsyncCallback<List<Employee>>() {

        @Override
        public void onFailure(Throwable caught) {
            System.out.println("---> Pb in retrieveing persons...");

        }

        @Override
        public void onSuccess(List<Employee> result) {

            List<Person> persons = new ArrayList<Person>();

            for (Employee e : result) {
                Person contact = new Person(false, e.getId_pers(), e.getLastName(), e.getFirstName(),
                        e.getBirthDate(), e.getRegion(), e.getEmail());
                persons.add(contact);
            }
            // Push the data into the widget.
            table.setRowData(persons);
        }

    });

    return table;
}

From source file:ua.oilukraine.client.TabelView.java

/**
 * Add the columns to the table.//from   w ww.j  a  va  2  s  . com
 */
private void initTableColumns(final SelectionModel<DebtorsData> selectionModel,
        ColumnSortEvent.ListHandler<DebtorsData> sortHandler) {
    // Checkbox column. This table will uses a checkbox column for selection.
    // Alternatively, you can call cellTable.setSelectionEnabled(true) to enable
    // mouse selection.
    Column<DebtorsData, Boolean> checkColumn = new Column<DebtorsData, Boolean>(new CheckboxCell(true, false)) {
        @Override
        public Boolean getValue(DebtorsData object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
        }
    };
    cellTable.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
    cellTable.setColumnWidth(checkColumn, 40, Unit.PX);

    // Firm name.
    Column<DebtorsData, String> FirmNameColumn = new Column<DebtorsData, String>(new TextCell()) {
        @Override
        public String getValue(DebtorsData object) {
            return object.getName();
        }
    };
    FirmNameColumn.setSortable(true);
    sortHandler.setComparator(FirmNameColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getName().compareTo(o2.getName());
        }
    });
    cellTable.addColumn(FirmNameColumn, "");
    //        FirmNameColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setName(value);
    //                //    ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    cellTable.setColumnWidth(FirmNameColumn, 20, Unit.PCT);

    // OKPO
    Column<DebtorsData, String> okpoColumn = new Column<DebtorsData, String>(new TextCell()) {
        @Override
        public String getValue(DebtorsData object) {
            return object.getOkpo();
        }
    };
    okpoColumn.setSortable(true);
    sortHandler.setComparator(okpoColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getOkpo().compareTo(o2.getOkpo());
        }
    });
    cellTable.addColumn(okpoColumn, "");
    //        okpoColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setOkpo(value);
    //                //    ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    cellTable.setColumnWidth(okpoColumn, 20, Unit.PCT);

    // Name Buh
    Column<DebtorsData, String> nameBuhColumn = new Column<DebtorsData, String>(new TextCell()) {
        @Override
        public String getValue(DebtorsData object) {
            return object.getName_buh();
        }
    };
    nameBuhColumn.setSortable(true);
    sortHandler.setComparator(nameBuhColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getName_buh().compareTo(o2.getName_buh());
        }
    });
    cellTable.addColumn(nameBuhColumn, "");
    //        okpoColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setOkpo(value);
    //                //    ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    cellTable.setColumnWidth(nameBuhColumn, 20, Unit.PCT);

    // Phone Work Buh
    Column<DebtorsData, String> phoneWorkBuhColumn = new Column<DebtorsData, String>(new TextCell()) {
        @Override
        public String getValue(DebtorsData object) {
            return object.getPhone_work();
        }
    };
    phoneWorkBuhColumn.setSortable(true);
    sortHandler.setComparator(phoneWorkBuhColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getPhone_work().compareTo(o2.getPhone_work());
        }
    });
    cellTable.addColumn(phoneWorkBuhColumn, " ");
    //        okpoColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setOkpo(value);
    //                //    ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    cellTable.setColumnWidth(phoneWorkBuhColumn, 20, Unit.PCT);

    // Phone Mob Buh
    Column<DebtorsData, String> phoneMobBuhColumn = new Column<DebtorsData, String>(new TextCell()) {
        @Override
        public String getValue(DebtorsData object) {
            return object.getPhone_mob();
        }
    };
    phoneMobBuhColumn.setSortable(true);
    sortHandler.setComparator(phoneMobBuhColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getPhone_mob().compareTo(o2.getPhone_mob());
        }
    });
    cellTable.addColumn(phoneMobBuhColumn, " ");
    //        okpoColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setOkpo(value);
    //                //    ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    cellTable.setColumnWidth(phoneMobBuhColumn, 20, Unit.PCT);

    // Date Info
    DateCell dateCell = new DateCell();
    Column<DebtorsData, Date> dateColumn = new Column<DebtorsData, Date>(dateCell) {
        @Override
        public Date getValue(DebtorsData object) {
            return object.getDate_info();
        }
    };
    dateColumn.setSortable(true);
    dateColumn.setDefaultSortAscending(false);
    sortHandler.setComparator(dateColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getDate_info().compareTo(o2.getDate_info());
        }
    });
    cellTable.addColumn(dateColumn, " ");
    dateColumn.setFieldUpdater(new FieldUpdater<DebtorsData, Date>() {
        @Override
        public void update(int index, DebtorsData object, Date value) {
            // Called when the user changes the value.
            object.setDate_info(value);
            //    ContactDatabase.get().refreshDisplays();
        }
    });

    // DatePickerCell.
    DateTimeFormat dateFormat = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_MEDIUM);
    DatePickerCell datePicCell = new DatePickerCell(dateFormat);

    Column<DebtorsData, Date> datePicColumn = new Column<DebtorsData, Date>(datePicCell) {
        @Override
        public Date getValue(DebtorsData object) {
            return object.getDate_info();
        }
    };
    dateColumn.setSortable(true);
    dateColumn.setDefaultSortAscending(false);
    sortHandler.setComparator(dateColumn, new Comparator<DebtorsData>() {
        @Override
        public int compare(DebtorsData o1, DebtorsData o2) {
            return o1.getDate_info().compareTo(o2.getDate_info());
        }
    });
    cellTable.addColumn(dateColumn, "  Pic");

    //        addColumn(new DatePickerCell(dateFormat), "DatePicker", new GetValue<Date>() {
    //            @Override
    //            public Date getValue(ContactInfo contact) {
    //                return contact.getBirthday();
    //            }
    //        }, new FieldUpdater<ContactInfo, Date>() {
    //            @Override
    //            public void update(int index, ContactInfo object, Date value) {
    //                pendingChanges.add(new BirthdayChange(object, value));
    //            }
    //        });
    //        /**
    //         * Add a column with a header.
    //         *
    //         * @param <C> the cell type
    //         * @param cell the cell used to render the column
    //         * @param headerText the header string
    //         * @param getter the value getter for the cell
    //         */
    //    private <C> Column<ContactInfo, C> addColumn(Cell<C> cell, String headerText,
    //            final GetValue<C> getter, FieldUpdater<ContactInfo, C> fieldUpdater) {
    //        Column<ContactInfo, C> column = new Column<ContactInfo, C>(cell) {
    //            @Override
    //            public C getValue(ContactInfo object) {
    //                return getter.getValue(object);
    //            }
    //        };
    //        column.setFieldUpdater(fieldUpdater);
    //        if (cell instanceof AbstractEditableCell<?, ?>) {
    //            editableCells.add((AbstractEditableCell<?, ?>) cell);
    //        }
    //        contactList.addColumn(column, headerText);
    //        return column;
    //    }
    ///////////////////////////////////////////////////////////////////////
    //        // Address.
    //        Column<DebtorsData, String> addressColumn = new Column<DebtorsData, String>(
    //                new TextCell()) {
    //            @Override
    //            public String getValue(DebtorsData object) {
    //                return object.getAddress();
    //            }
    //        };
    //        addressColumn.setSortable(true);
    //        addressColumn.setDefaultSortAscending(false);
    //        sortHandler.setComparator(addressColumn, new Comparator<DebtorsData>() {
    //            @Override
    //            public int compare(DebtorsData o1, DebtorsData o2) {
    //                return o1.getAddress().compareTo(o2.getAddress());
    //            }
    //        });
    //        cellTable.addColumn(addressColumn, constants.cwCellTableColumnAddress());
    //        cellTable.setColumnWidth(addressColumn, 60, Unit.PCT);
    //
    //        ///////////////////////////////////////////////////////////////////////
    //        // Last name.
    //        Column<DebtorsData, String> lastNameColumn = new Column<DebtorsData, String>(
    //                new EditTextCell()) {
    //            @Override
    //            public String getValue(DebtorsData object) {
    //                return object.getLastName();
    //            }
    //        };
    //        lastNameColumn.setSortable(true);
    //        sortHandler.setComparator(lastNameColumn, new Comparator<DebtorsData>() {
    //            @Override
    //            public int compare(DebtorsData o1, DebtorsData o2) {
    //                return o1.getLastName().compareTo(o2.getLastName());
    //            }
    //        });
    //        cellTable.addColumn(lastNameColumn, constants.cwCellTableColumnLastName());
    //        lastNameColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                // Called when the user changes the value.
    //                object.setLastName(value);
    //                ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    //        cellTable.setColumnWidth(lastNameColumn, 20, Unit.PCT);
    //
    //        // Category.
    //        final Category[] categories = ContactDatabase.get().queryCategories();
    //        List<String> categoryNames = new ArrayList<String>();
    //        for (Category category : categories) {
    //            categoryNames.add(category.getDisplayName());
    //        }
    //        SelectionCell categoryCell = new SelectionCell(categoryNames);
    //        Column<DebtorsData, String> categoryColumn = new Column<DebtorsData, String>(
    //                categoryCell) {
    //            @Override
    //            public String getValue(DebtorsData object) {
    //                return object.getCategory().getDisplayName();
    //            }
    //        };
    //        cellTable.addColumn(categoryColumn, constants.cwCellTableColumnCategory());
    //        categoryColumn.setFieldUpdater(new FieldUpdater<DebtorsData, String>() {
    //            @Override
    //            public void update(int index, DebtorsData object, String value) {
    //                for (Category category : categories) {
    //                    if (category.getDisplayName().equals(value)) {
    //                        object.setCategory(category);
    //                    }
    //                }
    //                ContactDatabase.get().refreshDisplays();
    //            }
    //        });
    //        cellTable.setColumnWidth(categoryColumn, 130, Unit.PX);
    //
    //        // Address.
    //        Column<DebtorsData, String> addressColumn = new Column<DebtorsData, String>(
    //                new TextCell()) {
    //            @Override
    //            public String getValue(DebtorsData object) {
    //                return object.getAddress();
    //            }
    //        };
    //        addressColumn.setSortable(true);
    //        addressColumn.setDefaultSortAscending(false);
    //        sortHandler.setComparator(addressColumn, new Comparator<DebtorsData>() {
    //            @Override
    //            public int compare(DebtorsData o1, DebtorsData o2) {
    //                return o1.getAddress().compareTo(o2.getAddress());
    //            }
    //        });
    //        cellTable.addColumn(addressColumn, constants.cwCellTableColumnAddress());
    //        cellTable.setColumnWidth(addressColumn, 60, Unit.PCT);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.common.client.view.DataFileListPanel.java

License:Apache License

public DataFileListPanel() {
    grid = new CustomDataGrid<>(MAX_FILES, false);
    grid.addStyleName("gwt-DataGrid");
    grid.setWidth("100%");
    grid.setHeight("100%");

    selectionModel = new MultiSelectionModel<>(new ProvidesKey<DataFileRow>() {
        @Override//from  w ww. j a  va  2s  .c  om
        public Object getKey(DataFileRow item) {
            return item.getIdentity();
        }
    });
    grid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<DataFileRow>createCheckboxManager());
    Column<DataFileRow, Boolean> checkboxColumn = new Column<DataFileRow, Boolean>(
            new CheckboxCell(true, false)) {
        @Override
        public Boolean getValue(DataFileRow object) {
            return grid.getSelectionModel().isSelected(object);
        }
    };

    checkboxHeader = new CheckboxHeader();
    checkboxHeader.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            selectAllRows(event.getValue());
        }
    });

    grid.addColumn(checkboxColumn, checkboxHeader);
    grid.setColumnWidth(checkboxColumn, 40, Style.Unit.PX);

    emptyTableWidget = new HTML(
            "<br><br><br>Drag files here to start upload<br>or press \"Upload Files\" button<br>to open selection dialog...");
    emptyTableWidget.addStyleName("empty");

    final EditSuggestCell nameCell = new EditSuggestCell(null) {
        @Override
        public boolean validateInput(String value, int rowIndex) {
            if (null == value || trimValue(value).isEmpty()) {
                NotificationPopupPanel.error("Empty file name is not permitted.", true, false);
                return false;
            }
            if (!value.matches("^[_a-zA-Z0-9\\-\\.]+$")) {
                NotificationPopupPanel.error(
                        "File name should only contain alphanumeric characters, underscores and dots.", true,
                        false);
                return false;
            }
            if (isDuplicated(value, rowIndex)) {
                NotificationPopupPanel.error("File with the name '" + value + "' already exists.", true, false);
                return false;
            }
            return true;
        }
    };

    Column<DataFileRow, String> nameColumn = new Column<DataFileRow, String>(nameCell) {

        @Override
        public String getValue(DataFileRow row) {
            return row.getName();
        }
    };
    nameColumn.setFieldUpdater(new FieldUpdater<DataFileRow, String>() {
        @Override
        public void update(int index, DataFileRow row, String value) {
            final String oldName = row.getName();
            String newName = trimValue(value);
            presenter.renameFile(row, newName, new AsyncCallback<Void>() {
                @Override
                public void onFailure(Throwable throwable) {
                    NotificationPopupPanel.error("Unable to rename file '" + oldName + "'", true, false);
                }

                @Override
                public void onSuccess(Void aVoid) {

                }
            });
        }
    });
    grid.addColumn(nameColumn, "Name");

    Column<DataFileRow, Date> dateColumn = new Column<DataFileRow, Date>(
            new DateCell(DateTimeFormat.getFormat("dd/MM/yy HH:mm"))) {
        @Override
        public Date getValue(DataFileRow object) {
            return object.getCreated();
        }
    };
    grid.addColumn(dateColumn, "Date");
    grid.setColumnWidth(dateColumn, 110, Style.Unit.PX);

    Column<DataFileRow, DataFileRow> statusText = new Column<DataFileRow, DataFileRow>(
            new DownloadLinkStatusCell(this)) {
        @Override
        public DataFileRow getValue(DataFileRow object) {
            return object;
        }
    };
    statusText.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    grid.addColumn(statusText, "Status");
    grid.setColumnWidth(statusText, 100, Style.Unit.PX);

    dataProvider = new ListDataProvider<>();
    dataProvider.addDataDisplay(grid);

    grid.setLoadingIndicator(new LoadingIndicator());
    grid.setEmptyTableWidget(emptyTableWidget);
    add(grid);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.DataAssignmentViewImpl.java

License:Apache License

private void addDataFileColumn(final int columnIndex, String columnName) {
    Column<DataAssignmentRow, String> column = new Column<DataAssignmentRow, String>(
            new DynSelectionCell<String>(new DynSelectionCell.ListProvider<String>() {
                @Override//from  ww w.  jav a 2 s.co m
                public List<DynSelectionCell.Option<String>> getOptions() {
                    return dataAssignment.getOptions(columns.get(columnIndex));
                }

                @Override
                public DynSelectionCell.Option<String> getDefault() {
                    return new DynSelectionCell.Option<String>() {
                        @Override
                        public String getValue() {
                            return NONE;
                        }

                        @Override
                        public String getText() {
                            return NONE;
                        }
                    };
                }
            })) {
        @Override
        public String getValue(DataAssignmentRow row) {
            FileRef file = columns.get(columnIndex).getFileRef(row);
            return null == file ? NONE : file.getName();
        }
    };
    column.setCellStyleNames("app-SelectionCell");
    column.setFieldUpdater(new FieldUpdater<DataAssignmentRow, String>() {
        @Override
        public void update(int index, DataAssignmentRow row, String value) {
            columns.get(columnIndex).setFileRef(row,
                    NONE.equals(value) ? null : dataAssignment.getFileRef(value));
            dataAssignment.update(columns.get(columnIndex));
            updateColumn(columns.get(columnIndex));
            gridView.redraw();
        }
    });
    gridView.addColumn(columnName, column, null, 200, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ExtractAttributesViewImpl.java

License:Apache License

private void addColumn(final ExtractAttribute attr) {
    Cell<String> cell = attr.hasOptions() ? new SelectionCell(attr.getOptions()) : new EditTextCell();
    Column<ExtractAttributesRow, String> column = new Column<ExtractAttributesRow, String>(cell) {
        @Override//  w w w.jav  a 2  s.  c  o  m
        public String getValue(ExtractAttributesRow row) {
            String value = row.getValue(attr);
            return value == null ? "" : attr.hasOptions() ? attr.getOption(value) : value;
        }
    };
    column.setCellStyleNames("app-SelectionCell");
    column.setFieldUpdater(new FieldUpdater<ExtractAttributesRow, String>() {
        @Override
        public void update(int index, ExtractAttributesRow row, String value) {
            row.setValue(attr.hasOptions() ? attr.getValue(value) : value, attr);
            if (LIBRARY_LAYOUT.equals(attr) && !isPairedLayout(value)) {
                row.setValue("", NOMINAL_LENGTH);
                row.setValue("", NOMINAL_SDEV);
                row.setValue("", ORIENTATION);
            }
            updateRow(row);
        }
    });
    gridView.addPermanentColumn(attr.getTitle(), column, null, 150, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ExtractAttributesViewImpl.java

License:Apache License

private void addColumnForPairedLayout(final ExtractAttribute attr) {
    Cell<String> cell = attr.hasOptions() ? new SelectionCell(attr.getOptions()) : new EditTextCell();

    Column<ExtractAttributesRow, String> column = new ConditionalColumn<ExtractAttributesRow>(cell) {
        @Override//from   w  ww .  j  a  v  a2s .co  m
        public String getValue(ExtractAttributesRow row) {
            String value = row.getValue(attr);
            return value == null ? "" : attr.hasOptions() ? attr.getOption(value) : value;
        }

        @Override
        public boolean isEditable(ExtractAttributesRow row) {
            return isPairedLayout(row.getValue(LIBRARY_LAYOUT));
        }
    };
    column.setCellStyleNames("app-SelectionCell");
    column.setFieldUpdater(new FieldUpdater<ExtractAttributesRow, String>() {
        @Override
        public void update(int index, ExtractAttributesRow row, String value) {
            row.setValue(attr.hasOptions() ? attr.getValue(value) : value, attr);
            updateRow(row);
        }
    });
    gridView.addPermanentColumn(attr.getTitle(), column, null, 150, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ProtocolsViewImpl.java

License:Apache License

private void addNameColumn() {
    final EditSuggestCell nameCell = new EditSuggestCell(null) {
        @Override//  w  w  w. j a  v a  2 s  .  c  om
        public boolean validateInput(String value, int rowIndex) {
            if (value == null || trimValue(value).isEmpty()) {
                NotificationPopupPanel.error("Protocol with empty name is not permitted.", true, false);
                return false;
            }
            if (!isNameUnique(value, rowIndex)) {
                NotificationPopupPanel.error("Protocol with the name '" + value + "' already exists.", true,
                        false);
                return false;
            }
            return true;
        }
    };

    Column<ProtocolRow, String> column = new Column<ProtocolRow, String>(nameCell) {
        @Override
        public String getValue(ProtocolRow row) {
            String v = row.getName();
            return v == null ? "" : v;
        }
    };

    column.setFieldUpdater(new FieldUpdater<ProtocolRow, String>() {
        @Override
        public void update(int index, ProtocolRow row, String value) {
            row.setName(trimValue(value));
            updateRow(row);
        }
    });

    column.setSortable(true);
    Comparator<ProtocolRow> comparator = new Comparator<ProtocolRow>() {
        @Override
        public int compare(ProtocolRow o1, ProtocolRow o2) {
            if (o1 == o2) {
                return 0;
            }
            String v1 = o1.getName();
            String v2 = o2.getName();
            return v1.compareTo(v2);
        }
    };

    gridView.addPermanentColumn("Name", column, comparator, 150, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ProtocolsViewImpl.java

License:Apache License

private void addAssignmentColumn() {
    Column<ProtocolRow, String> column = new Column<ProtocolRow, String>(new ButtonCell() {
        @Override/*  w  w  w  .jav a  2  s  . c  o m*/
        public void render(Context context, SafeHtml data, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<button type=\"button\" tabindex=\"-1\">");
            sb.append(data);
            sb.appendHtmlConstant("</button>");
        }
    }) {
        @Override
        public String getValue(ProtocolRow row) {
            return "Assign...";
        }
    };
    column.setFieldUpdater(new FieldUpdater<ProtocolRow, String>() {
        @Override
        public void update(int index, ProtocolRow row, String value) {
            final boolean isRowAssignable = row.isAssignable();
            final String protocolType = row.getProtocolType().getLabel();
            presenter.getAssignmentProfileAsync(row.getId(),
                    new ReportingAsyncCallback<ProtocolAssignmentProfile>(
                            FailureMessage.UNABLE_TO_LOAD_PROTOCOL_ASSIGNMENTS) {
                        @Override
                        public void onSuccess(ProtocolAssignmentProfile result) {
                            if (!isRowAssignable) {
                                NotificationPopupPanel
                                        .warning("Protocol '" + protocolType + "' is always assigned to all "
                                                + result.getProtocolSubjectType() + "s.", true, false);
                                return;
                            } else if (result.getNames().isEmpty()) {
                                NotificationPopupPanel.warning("You do not have any "
                                        + result.getProtocolSubjectType() + "s to assign protocols to.", true,
                                        false);
                                return;
                            }
                            new ProtocolAssignmentDialog(result,
                                    new DialogCallback<ProtocolAssignmentProfileUpdates>() {
                                        @Override
                                        public boolean onOk(ProtocolAssignmentProfileUpdates profileUpdates) {
                                            updateProtocolAssignments(profileUpdates);
                                            return true;
                                        }
                                    }).show();
                        }
                    });
        }
    });
    gridView.addPermanentColumn("Assign protocols to materials/data files", column, null, 300, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ProtocolsViewImpl.java

License:Apache License

private void addDescriptionColumn() {
    Column<ProtocolRow, String> column = new Column<ProtocolRow, String>(new EditTextCell()) {
        @Override/* w  w  w  . j a  v  a2s  .  c o  m*/
        public String getValue(ProtocolRow row) {
            String v = row.getDescription();
            return v == null ? "" : v;
        }
    };
    column.setFieldUpdater(new FieldUpdater<ProtocolRow, String>() {
        @Override
        public void update(int index, ProtocolRow row, String value) {
            row.setDescription(value);
            updateRow(row);
        }
    });
    gridView.addPermanentColumn("Description", column, null, 150, Style.Unit.PX);
}

From source file:uk.ac.ebi.fg.annotare2.web.gwt.editor.client.view.experiment.design.ProtocolsViewImpl.java

License:Apache License

private void addParametersColumn() {
    Column<ProtocolRow, List<String>> column = new Column<ProtocolRow, List<String>>(new EditListCell()) {
        @Override/*  w w w.j  a v a  2 s.  co m*/
        public List<String> getValue(ProtocolRow row) {
            return row.getParameters();
        }
    };
    column.setFieldUpdater(new FieldUpdater<ProtocolRow, List<String>>() {
        @Override
        public void update(int index, ProtocolRow row, List<String> value) {
            row.setParameters(value);
            updateRow(row);
        }
    });
    gridView.addPermanentColumn("Parameters", column, null, 150, Style.Unit.PX);
}