Example usage for com.google.gwt.view.client NoSelectionModel NoSelectionModel

List of usage examples for com.google.gwt.view.client NoSelectionModel NoSelectionModel

Introduction

In this page you can find the example usage for com.google.gwt.view.client NoSelectionModel NoSelectionModel.

Prototype

public NoSelectionModel(ProvidesKey<T> keyProvider) 

Source Link

Document

Constructs a NoSelectionModel with the given key provider.

Usage

From source file:com.google.gwt.sample.expenses.client.MobileReportList.java

License:Apache License

public MobileReportList(final Listener listener, final ExpensesRequestFactory requestFactory,
        EmployeeProxy employee) {/*  w ww. ja va 2s.c o m*/
    this.listener = listener;
    this.requestFactory = requestFactory;
    this.employee = employee;

    EntityProxyKeyProvider<ReportProxy> keyProvider = new EntityProxyKeyProvider<ReportProxy>();

    reportDataProvider = new AsyncDataProvider<ReportProxy>(keyProvider) {
        @Override
        protected void onRangeChanged(HasData<ReportProxy> view) {
            requestReports();
        }
    };

    reportList = new CellList<ReportProxy>(new AbstractCell<ReportProxy>() {
        @Override
        public void render(Context context, ReportProxy value, SafeHtmlBuilder sb) {
            sb.appendHtmlConstant("<div class='item'>");
            sb.appendEscaped(value.getPurpose());
            sb.appendHtmlConstant("</div>");
        }
    });
    reportList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    reportSelection = new NoSelectionModel<ReportProxy>(keyProvider);
    reportSelection.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            listener.onReportSelected(reportSelection.getLastSelectedObject());
        }
    });

    reportList.setSelectionModel(reportSelection);
    reportDataProvider.addDataDisplay(reportList);

    initWidget(reportList);
    onRefresh(false);
}

From source file:com.novartis.pcs.ontology.webapp.client.view.AddRelationshipPopup.java

License:Apache License

protected void setupTable(CellTable<Term> table) {
    table.setWidth("100%");
    table.addStyleName("gwt-CellTable");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    table.setSelectionModel(new NoSelectionModel<Term>(keyProvider));

    table.addColumn(new OntologyColumn(), "Ontology");
    table.addColumn(new TermColumn(), "Term");
}

From source file:com.novartis.pcs.ontology.webapp.client.view.ApproveRejectComposite.java

License:Apache License

@SuppressWarnings("unchecked")
protected void setupTable() {
    table.setWidth("100%");
    table.addStyleName("gwt-CellTable");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    /* getValue gets called during update. Need to combine objects
     * and include a flag that is set when update starts. Using default
     * functionality with Shit key is better anyway and have include
     * note to user so they are aware of it. See addWidgets below.  
    Header<Boolean> checkHeader = new Header<Boolean>(new CheckboxCell()) {
      @Override//from   w  ww  .  j ava  2s  . c om
      public Boolean getValue() {
    return false; //selection.getSelectedSet().containsAll(table.getVisibleItems());
            
      }
    };
            
    checkHeader.setUpdater(new ValueUpdater<Boolean>() {
      @Override
      public void update(Boolean value) {
    List<T> displayedItems = table.getVisibleItems();
    for (T pending : displayedItems) {
       selection.setSelected(pending, value);
    }
      }
    });
    */

    if (curator != null && curator.isAuthorised(entity)) {
        Column<T, Boolean> checkColumn = new Column<T, Boolean>(new DisableableCheckboxCell(true, false)) {
            @Override
            public Boolean getValue(T object) {
                return !object.getCreatedBy().equals(curator) ? selection.isSelected(object) : null;
            }
        };

        table.addColumn(checkColumn);
        table.setColumnWidth(checkColumn, 16, Unit.PX);

        table.setSelectionModel(selection, DefaultSelectionEventManager.<T>createCheckboxManager(0));
    } else {
        table.setSelectionModel(new NoSelectionModel<T>(keyProvider));
    }

    addTableColumns(table);
    table.addColumn(new CreatedDateColumn(), "Created");
    table.addColumn(new CreatedByColumn(), "Created By");

    if (curator != null) {
        IconActionCell.Delegate<T> delegate = new IconActionCell.Delegate<T>() {
            @Override
            public void execute(T entity) {
                editView.setEntity(entity);
                editView.show();
            }
        };

        Column<T, T> editColumn = new Column<T, T>(
                new IconActionCell<T>(ImageResources.INSTANCE.editIcon(), delegate)) {
            @Override
            public T getValue(T entity) {
                return entity;
            }
        };
        editColumn.setCellStyleNames("icon-action");
        table.addColumn(editColumn, SafeHtmlUtils.fromSafeConstant("&nbsp;"));
    }

    if (curator != null) {
        IconActionCell.Delegate<T> delegate = new IconActionCell.Delegate<T>() {
            @Override
            public void execute(final T entity) {
                if (entity != null && curator.equals(entity.getCreatedBy())) {
                    if (errorLabel.isVisible()) {
                        errorLabel.setVisible(false);
                    }
                    if (selection != null) {
                        selection.setSelected(entity, false);
                    }
                    processing.add(entity);
                    busyIndicator.busy();
                    service.delete(entity, new AsyncCallback<Void>() {
                        @Override
                        public void onFailure(Throwable caught) {
                            GWT.log("Failed to delete pending item", caught);
                            processing.remove(entity);
                            busyIndicator.idle();
                            if (caught instanceof InvalidEntityException) {
                                InvalidEntityException e = (InvalidEntityException) caught;
                                errorLabel.setText(e.getMessage() + ": " + e.getEntity());
                                errorLabel.setVisible(true);
                            } else {
                                ErrorView.instance().onUncaughtException(caught);
                            }
                        }

                        @Override
                        public void onSuccess(Void nothing) {
                            processing.remove(entity);
                            dataProvider.getList().remove(entity);
                            busyIndicator.idle();
                            fireDeleteEvent(entity);
                        }
                    });
                }
            }
        };

        Column<T, T> deleteColumn = new Column<T, T>(
                new IconActionCell<T>(ImageResources.INSTANCE.deleteIcon(), delegate)) {
            @Override
            public T getValue(T entity) {
                return curator.equals(entity.getCreatedBy()) ? entity : null;
            }
        };
        deleteColumn.setCellStyleNames("icon-action");
        table.addColumn(deleteColumn, SafeHtmlUtils.fromSafeConstant("&nbsp;"));
    }

    ListHandler<T> sortHandler = new ListHandler<T>(dataProvider.getList());
    for (int i = 0; i < table.getColumnCount(); i++) {
        Column<T, ?> column = table.getColumn(i);
        if (column.isSortable() && column instanceof Comparator<?>) {
            sortHandler.setComparator(column, (Comparator<T>) column);
        }
    }
    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(table.getColumn(curator != null && curator.isAuthorised(entity) ? 2 : 1));
}

From source file:com.novartis.pcs.ontology.webapp.client.view.ControlledVocabularyTermLinksView.java

License:Apache License

@SuppressWarnings("unchecked")
private void addTableColumns() {

    table.setWidth("100%");
    table.setPageSize(10);/*from   w  ww. java2  s .  co  m*/
    table.addStyleName("gwt-CellTable");
    table.addStyleName("spaced-vert");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    table.setSelectionModel(new NoSelectionModel<ControlledVocabularyTermLink>(keyProvider));

    table.addColumn(new NameColumn(), "Linked Term");
    table.addColumn(new DomainColumn(), "Domain");
    table.addColumn(new ContextColumn(), "Context");
    table.addColumn(new SourceColumn(), "Source");
    table.addColumn(new UsageColumn(), "Usage");

    ListHandler<ControlledVocabularyTermLink> sortHandler = new ListHandler<ControlledVocabularyTermLink>(
            dataProvider.getList());
    for (int i = 1; i < table.getColumnCount(); i++) {
        Column<ControlledVocabularyTermLink, ?> column = table.getColumn(i);
        if (column.isSortable() && column instanceof Comparator<?>) {
            sortHandler.setComparator(column, (Comparator<ControlledVocabularyTermLink>) column);
        }
    }

    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(table.getColumn(table.getColumnCount() - 1));
    // Second time to reverse sort order
    table.getColumnSortList().push(table.getColumn(table.getColumnCount() - 1));
}

From source file:com.novartis.pcs.ontology.webapp.client.view.CreateChildTermPopup.java

License:Apache License

private void addDialogWidgets() {
    VerticalPanel dialogVPanel = new VerticalPanel();
    HorizontalPanel buttonsHPanel = new HorizontalPanel();
    HorizontalPanel relshipTypeHPanel = new HorizontalPanel();
    Button cancelButton = new Button("Cancel");

    TextColumn<ControlledVocabularyTerm> synonymTypeColumn = new TextColumn<ControlledVocabularyTerm>() {
        @Override//  ww w .  j a  v  a 2  s.  c o  m
        public String getValue(ControlledVocabularyTerm term) {
            return synonymType != null ? synonymType.toString() : Synonym.Type.RELATED.toString();
        }
    };

    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            nameField.setValue(null);
            nameError.setText(null);
            definitionField.setValue(null);
            urlField.setValue(null);
            urlError.setText(null);
            commentsField.setValue(null);
            sourceDropBox.setSelectedIndex(0);
            referenceIdField.setEnabled(false);
            referenceIdField.setValue(null);
            synonymError.setText(null);
            createButton.setEnabled(false);

            dialogBox.hide();
        }
    });

    relshipTypeHPanel.add(typeDropBox);
    relshipTypeHPanel.add(parentTermLabel);
    parentTermLabel.getElement().getStyle().setMarginLeft(12, Unit.PX);
    parentTermLabel.getElement().getStyle().setVerticalAlign(VerticalAlign.MIDDLE);
    parentTermLabel.getElement().getStyle().setFontWeight(FontWeight.BOLD);

    buttonsHPanel.add(createButton);
    buttonsHPanel.add(cancelButton);
    buttonsHPanel.addStyleName("dialog-buttons");

    dialogVPanel.setHorizontalAlignment(VerticalPanel.ALIGN_LEFT);
    dialogVPanel.add(new Label("Name:"));
    dialogVPanel.add(nameField);
    dialogVPanel.add(nameError);
    dialogVPanel.add(new Label("Definition:"));
    dialogVPanel.add(definitionField);
    dialogVPanel.add(definitionError);
    dialogVPanel.add(new Label("URL:"));
    dialogVPanel.add(urlField);
    dialogVPanel.add(urlError);
    dialogVPanel.add(new Label("Comments:"));
    dialogVPanel.add(commentsField);
    dialogVPanel.add(commentsError);
    dialogVPanel.add(new Label("Source:"));
    dialogVPanel.add(sourceDropBox);
    dialogVPanel.add(sourceError);
    dialogVPanel.add(new Label("Reference Id:"));
    dialogVPanel.add(referenceIdField);
    dialogVPanel.add(referenceIdError);

    synonymTable.setWidth("100%");
    synonymTable.addStyleName("gwt-CellTable");
    synonymTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    synonymTable
            .setSelectionModel(new NoSelectionModel<ControlledVocabularyTerm>(synonymTable.getKeyProvider()));

    synonymTable.addColumn(new NameColumn(), "Synonym");
    synonymTable.addColumn(synonymTypeColumn, "Type");
    synonymTable.addColumn(new SourceColumn(), "Source");
    dialogVPanel.add(synonymTable);
    dialogVPanel.add(synonymError);

    dialogVPanel.add(new Label("Relationship:"));
    //dialogVPanel.add(typeDropBox);
    dialogVPanel.add(relshipTypeHPanel);
    dialogVPanel.add(typeError);

    dialogVPanel.add(buttonsHPanel);
    dialogVPanel.setCellHorizontalAlignment(buttonsHPanel, VerticalPanel.ALIGN_CENTER);

    for (Widget widget : dialogVPanel) {
        if (widget instanceof Label) {
            Label label = (Label) widget;
            if (label.getText().length() != 0) {
                label.addStyleName("dialog-label");
            } else {
                label.addStyleName("dialog-error");
            }
        }
    }

    dialogBox.setWidget(dialogVPanel);
}

From source file:com.novartis.pcs.ontology.webapp.client.view.CrossRefPopup.java

License:Apache License

@SuppressWarnings("unchecked")
private void addTableColumns() {
    /*/*from   w w  w  .j  ava 2s  . c om*/
     List<String> typeNames = new ArrayList<String>();
     for(Synonym.Type type : Synonym.Type.values()) {
       typeNames.add(type.name());
    }
             
     Column<ControlledVocabularyTerm, String> typeColumn = 
     new Column<ControlledVocabularyTerm, String>(new SelectionCell(typeNames)) {
        @Override
        public String getValue(ControlledVocabularyTerm term) {
     Synonym.Type type = term.getSynonymType();
    if(type == null) {
       type = Synonym.Type.RELATED; 
    }
             
     return type.name();
        }
     };
             
     typeColumn.setFieldUpdater(new FieldUpdater<ControlledVocabularyTerm, String>() {
        @Override
        public void update(int index, ControlledVocabularyTerm term, String typeName) {
     Synonym.Type type = Synonym.Type.valueOf(typeName);  
    term.setSynonymType(type);
        }
     });
     */

    IconActionCell.Delegate<ControlledVocabularyTerm> delegate = new IconActionCell.Delegate<ControlledVocabularyTerm>() {
        @Override
        public void execute(ControlledVocabularyTerm term) {
            eventBus.fireEvent(new SearchEvent(term.getName()));

            if (selection != null) {
                selection.clear();
                selection.setSelected(term, true);
            }
        }
    };

    Column<ControlledVocabularyTerm, ControlledVocabularyTerm> searchColumn = new Column<ControlledVocabularyTerm, ControlledVocabularyTerm>(
            new IconActionCell<ControlledVocabularyTerm>(ImageResources.INSTANCE.searchIcon(), delegate)) {
        @Override
        public ControlledVocabularyTerm getValue(ControlledVocabularyTerm term) {
            return term;
        }
    };
    searchColumn.setCellStyleNames("icon-action");
    /*              
    Column<ControlledVocabularyTerm, ControlledVocabularyTerm> addColumn = 
     new Column<ControlledVocabularyTerm, ControlledVocabularyTerm>(new IconActionCell<ControlledVocabularyTerm>(ImageResources.INSTANCE.addIcon(), this)) {
       @Override
       public ControlledVocabularyTerm getValue(ControlledVocabularyTerm term) {
     return term;
       }
    };
    addColumn.setCellStyleNames("icon-action");
            
    // colspans the table header if we use the same Header object
    Header<String> actionHeader = new Header<String>(new TextCell()) {
      @Override
      public String getValue() {
    return "Action";
      }
    };
    */
    table.setWidth("100%");
    table.setPageSize(10);
    table.addStyleName("gwt-CellTable");
    table.addStyleName("spaced-vert");
    //table.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    if (curator != null) {
        Column<ControlledVocabularyTerm, Boolean> checkColumn = new Column<ControlledVocabularyTerm, Boolean>(
                new CheckboxCell(true, false)) {
            @Override
            public Boolean getValue(ControlledVocabularyTerm term) {
                return selection.isSelected(term);
            }
        };

        table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("&nbsp;"));
        table.setColumnWidth(checkColumn, 16, Unit.PX);

        table.setSelectionModel(selection,
                DefaultSelectionEventManager.<ControlledVocabularyTerm>createCheckboxManager(0));
    } else {
        table.setSelectionModel(new NoSelectionModel<ControlledVocabularyTerm>(keyProvider));
    }

    NameColumn nameColumn = new NameColumn();
    nameColumn.setFieldUpdater(new FieldUpdater<ControlledVocabularyTerm, String>() {
        @Override
        public void update(int index, ControlledVocabularyTerm term, String value) {
            linkedTermsView.show(term);
        }
    });
    nameColumn.setCellStyleNames("clickable-text");

    table.addColumn(searchColumn, SafeHtmlUtils.fromSafeConstant("&nbsp;"));
    table.addColumn(nameColumn, "Unmapped Term");
    table.addColumn(new ContextColumn(), "Context");
    table.addColumn(new SourceColumn(), "Source");
    table.addColumn(new UsageColumn(), "Usage");
    // table.addColumn(typeColumn, "Type");

    ListHandler<ControlledVocabularyTerm> sortHandler = new ListHandler<ControlledVocabularyTerm>(
            dataProvider.getList());
    for (int i = 1; i < table.getColumnCount(); i++) {
        Column<ControlledVocabularyTerm, ?> column = table.getColumn(i);
        if (column.isSortable() && column instanceof Comparator<?>) {
            sortHandler.setComparator(column, (Comparator<ControlledVocabularyTerm>) column);
        }
    }

    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(table.getColumn(table.getColumnCount() - 1));
    // Second time to reverse sort order
    table.getColumnSortList().push(table.getColumn(table.getColumnCount() - 1));
}

From source file:com.novartis.pcs.ontology.webapp.client.view.HistoryPopup.java

License:Apache License

@SuppressWarnings("unchecked")
protected void setupTable() {
    table.setWidth("100%");
    table.addStyleName("gwt-CellTable");
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    table.setSelectionModel(new NoSelectionModel<CuratorAction>(keyProvider));

    table.addColumn(new ActionDateColumn(), "Date");
    table.addColumn(new CuratorColumn(), "Curator");
    table.addColumn(new ActionColumn(), "Action");
    table.addColumn(new EntityColumn(), "Entity");
    table.addColumn(new OntologyColumn(), "Ontology/Codelist");
    table.addColumn(new TermColumn(), "Term");
    table.addColumn(new EntityValueColumn(), "Relationship/Synonym");
    table.addColumn(new CommentsColumn(), "Comments");

    ListHandler<CuratorAction> sortHandler = new ListHandler<CuratorAction>(dataProvider.getList());
    for (int i = 0; i < table.getColumnCount(); i++) {
        Column<CuratorAction, ?> column = table.getColumn(i);
        if (column.isSortable() && column instanceof Comparator<?>) {
            sortHandler.setComparator(column, (Comparator<CuratorAction>) column);
        }/* w  ww . j  a v  a  2  s . co m*/
    }
    table.addColumnSortHandler(sortHandler);
    table.getColumnSortList().push(table.getColumn(0));
}

From source file:fr.mncc.gwttoolbox.datagrid.client.Grid.java

License:Open Source License

/**
 * Add a single row selection model to the grid.
 *//*  w ww.j a va  2  s.c o  m*/
public void addSelectionModel() {
    final NoSelectionModel<T> selectionModel = new NoSelectionModel<T>(Grid.<T>createKeyProvider());
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent event) {
            Grid.this.onSelectionChanged(selectionModel.getLastSelectedObject());
        }
    });
    setSelectionModel(selectionModel);
}

From source file:org.rstudio.studio.client.workbench.views.environment.view.EnvironmentObjectList.java

License:Open Source License

public EnvironmentObjectList(EnvironmentObjectDisplay.Host host, EnvironmentObjectsObserver observer,
        String environmentName) {
    super(host, observer, environmentName);
    setTableBuilder(new EnvironmentObjectTableBuilder(this));

    // disable persistent and transient row selection (currently necessary
    // because we emit more than one row per object and the DataGrid selection
    // behaviors aren't designed to work that way)
    setSelectionModel(new NoSelectionModel<RObjectEntry>(RObjectEntry.KEY_PROVIDER));
    setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);

    createColumns();/*ww  w. j a  v  a2s . co  m*/
    addColumn(objectExpandColumn_);
    addColumn(objectNameColumn_);
    addColumn(objectDescriptionColumn_);
    setSkipRowHoverCheck(true);
    style_ = ((Resources) GWT.create(Resources.class)).style();
    style_.ensureInjected();
    addStyleName(style_.objectList());
}