Example usage for com.google.gwt.user.cellview.client CellTable CellTable

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

Introduction

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

Prototype

public CellTable() 

Source Link

Document

Constructs a table with a default page size of 15.

Usage

From source file:org.jboss.gwt.circuit.sample.todo.client.views.TodoView.java

License:Open Source License

public TodoView() {

    VerticalPanel layout = new VerticalPanel();
    layout.getElement().setAttribute("style", "padding:20px;width:100%");

    users = new ListBox();
    users.addChangeHandler(new ChangeHandler() {
        @Override/*from   w  w  w  . j  a  v a 2 s .c om*/
        public void onChange(com.google.gwt.event.dom.client.ChangeEvent changeEvent) {
            dispatcher.dispatch(new SelectUser(users.getValue(users.getSelectedIndex())));
        }
    });

    layout.add(users);

    table = new CellTable<Todo>();
    table.getElement().setAttribute("style", "width:90%");
    table.setEmptyTableWidget(new HTML("No Todo items found!"));

    final SingleSelectionModel<Todo> selectionModel = new SingleSelectionModel<Todo>();
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        @Override
        public void onSelectionChange(SelectionChangeEvent selectionChangeEvent) {
            dispatcher.dispatch(new SelectTodo(selectionModel.getSelectedObject()));
        }
    });

    table.setSelectionModel(selectionModel);

    dataProvider = new ListDataProvider<Todo>();
    dataProvider.addDataDisplay(table);

    Column<Todo, SafeHtml> nameColumn = new Column<Todo, SafeHtml>(new SafeHtmlCell()) {
        @Override
        public SafeHtml getValue(Todo object) {
            String css = object.isDone() ? "todo-done" : "none";
            SafeHtmlBuilder html = new SafeHtmlBuilder();
            html.appendHtmlConstant("<div class=" + css + ">");
            html.appendEscaped(object.getName());
            html.appendHtmlConstant("</div>");
            return html.toSafeHtml();
        }
    };
    table.addColumn(nameColumn, "Todo");

    TextColumn<Todo> userColumn = new TextColumn<Todo>() {
        @Override
        public String getValue(Todo object) {
            return object.getUser();
        }
    };
    table.addColumn(userColumn, "Assignment");

    layout.add(table);

    Button addButton = new Button("Add", new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {

            Dialog.askFor("Please provide a description:", new AsyncCallback<String>() {
                @Override
                public void onFailure(Throwable throwable) {
                }

                @Override
                public void onSuccess(String s) {
                    dispatcher.dispatch(new SaveTodo(new Todo(s)));
                }
            });
        }
    });

    removeButton = new Button("Remove", new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            dispatcher.dispatch(new RemoveTodo(selectionModel.getSelectedObject()));
        }
    });
    removeButton.setEnabled(false); // enabled by selection

    doneButton = new Button("Done", new ClickHandler() {
        @Override
        public void onClick(ClickEvent clickEvent) {
            Todo todo = selectionModel.getSelectedObject();
            todo.setDone(true);
            dispatcher.dispatch(new ResolveTodo(todo));
        }
    });
    doneButton.setEnabled(false); // enabled by selection

    HorizontalPanel tools = new HorizontalPanel();
    tools.add(addButton);
    tools.add(removeButton);
    tools.add(doneButton);

    layout.add(tools);

    initWidget(layout);
}

From source file:org.kie.guvnor.guided.dtable.client.widget.auditlog.AuditLogViewImpl.java

License:Apache License

@Override
public Widget getContent() {
    for (Map.Entry<String, Boolean> e : auditLog.getAuditLogFilter().getAcceptedTypes().entrySet()) {
        lstEventTypes.add(makeEventTypeCheckBox(e.getKey(), e.getValue()));
    }//from w  ww .  ja  v a 2 s  .  c o  m

    events = new CellTable<AuditLogEntry>();

    final ListDataProvider<AuditLogEntry> dlp = new ListDataProvider<AuditLogEntry>(
            filterDeletedEntries(auditLog));
    dlp.addDataDisplay(events);

    AuditLogEntrySummaryColumn summaryColumn = new AuditLogEntrySummaryColumn();
    AuditLogEntryCommentColumn commentColumn = new AuditLogEntryCommentColumn();

    events.addColumn(summaryColumn);
    events.addColumn(commentColumn);

    events.setColumnWidth(summaryColumn, 50.0, Unit.PCT);
    events.setColumnWidth(commentColumn, 50.0, Unit.PCT);

    //If the current user is not an Administrator include the delete comment column
    if (!identity.hasRole(AppRoles.ADMIN)) {

        AuditLogEntryDeleteCommentColumn deleteCommentColumn = new AuditLogEntryDeleteCommentColumn();
        deleteCommentColumn.setFieldUpdater(new FieldUpdater<AuditLogEntry, ImageResource>() {

            public void update(int index, AuditLogEntry row, ImageResource value) {
                row.setDeleted(true);
                dlp.setList(filterDeletedEntries(auditLog));
                dlp.refresh();
            }

        });
        events.addColumn(deleteCommentColumn);
        events.setColumnWidth(commentColumn, 45.0, Unit.PCT);
        events.setColumnWidth(deleteCommentColumn, 5.0, Unit.PCT);
    }

    events.setEmptyTableWidget(new Label(Constants.INSTANCE.DecisionTableAuditLogNoEntries()));
    events.setKeyboardPagingPolicy(KeyboardPagingPolicy.CHANGE_PAGE);
    events.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    events.setPageSize(5);

    GuvnorSimplePager gsp = new GuvnorSimplePager();
    gsp.setPageSize(5);
    gsp.setDisplay(events);

    VerticalPanel vp = new VerticalPanel();
    vp.add(gsp);
    vp.add(events);

    spEvents.setAlwaysShowScrollBars(false);
    spEvents.add(vp);

    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            fixWidgetSizes();
        }

    });

    return this.popupContent;
}

From source file:org.kie.guvnor.guided.scorecard.client.editor.GuidedScoreCardEditor.java

License:Apache License

private Widget addAttributeCellTable(final DirtyableFlexTable cGrid, final Characteristic characteristic) {
    final CellTable<Attribute> attributeCellTable = new CellTable<Attribute>();
    final List<String> operators = new ArrayList<String>();
    String dataType;//  w ww. ja  v a2s  .c o  m
    if (characteristic == null) {
        dataType = "String";
    } else {
        dataType = characteristic.getDataType();
    }

    if ("String".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(stringOperators));
    } else if ("boolean".equalsIgnoreCase(dataType)) {
        operators.addAll(Arrays.asList(booleanOperators));
    } else {
        operators.addAll(Arrays.asList(numericOperators));
    }

    //Operators column
    final DynamicSelectionCell categoryCell = new DynamicSelectionCell(operators);
    final Column<Attribute, String> operatorColumn = new Column<Attribute, String>(categoryCell) {
        public String getValue(final Attribute object) {
            return object.getOperator();
        }
    };
    operatorColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setOperator(value);
            attributeCellTable.redraw();
        }
    });

    //Value column
    final Column<Attribute, String> valueColumn = new Column<Attribute, String>(new CustomEditTextCell()) {
        public String getValue(final Attribute attribute) {
            return attribute.getValue();
        }
    };
    valueColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setValue(value);
            attributeCellTable.redraw();
        }
    });

    //Partial Score column
    final EditTextCell partialScoreCell = new EditTextCell();
    final Column<Attribute, String> partialScoreColumn = new Column<Attribute, String>(partialScoreCell) {
        public String getValue(final Attribute attribute) {
            return "" + attribute.getPartialScore();
        }
    };
    partialScoreColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            try {
                double d = Double.parseDouble(value);
                object.setPartialScore(d);
            } catch (Exception e1) {
                partialScoreCell.clearViewData(object);
            }
            attributeCellTable.redraw();
        }
    });

    //Reason Code column
    final Column<Attribute, String> reasonCodeColumn = new Column<Attribute, String>(new EditTextCell()) {
        public String getValue(final Attribute attribute) {
            return attribute.getReasonCode();
        }
    };
    reasonCodeColumn.setFieldUpdater(new FieldUpdater<Attribute, String>() {
        public void update(int index, Attribute object, String value) {
            object.setReasonCode(value);
            attributeCellTable.redraw();
        }
    });

    final ActionCell.Delegate<Attribute> delegate = new ActionCell.Delegate<Attribute>() {
        public void execute(final Attribute attribute) {
            if (Window.confirm(Constants.INSTANCE.promptDeleteAttribute())) {
                final List<Attribute> list = characteristicsAttrMap.get(cGrid).getList();
                list.remove(attribute);
                ((ListBox) cGrid.getWidget(2, 0)).setEnabled(list.size() == 0);
                ((ListBox) cGrid.getWidget(2, 1)).setEnabled(list.size() == 0);
                ((Button) cGrid.getWidget(0, 3)).setEnabled(list.size() != 2);
                attributeCellTable.redraw();
            }
        }
    };

    final Cell<Attribute> actionCell = new ActionCell<Attribute>(Constants.INSTANCE.remove(), delegate);
    final Column<Attribute, String> actionColumn = new IdentityColumn(actionCell);

    // Add the columns.
    attributeCellTable.addColumn(operatorColumn, Constants.INSTANCE.operator());
    attributeCellTable.addColumn(valueColumn, Constants.INSTANCE.value());
    attributeCellTable.addColumn(partialScoreColumn, Constants.INSTANCE.partialScore());
    attributeCellTable.addColumn(reasonCodeColumn, Constants.INSTANCE.reasonCode());
    attributeCellTable.addColumn(actionColumn, Constants.INSTANCE.actions());
    attributeCellTable.setWidth("100%", true);

    attributeCellTable.setColumnWidth(operatorColumn, 5.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(valueColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(partialScoreColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(reasonCodeColumn, 10.0, Style.Unit.PCT);
    attributeCellTable.setColumnWidth(actionColumn, 5.0, Style.Unit.PCT);

    ListDataProvider<Attribute> dataProvider = new ListDataProvider<Attribute>();
    dataProvider.addDataDisplay(attributeCellTable);
    characteristicsAttrMap.put(cGrid, dataProvider);
    return (attributeCellTable);
}

From source file:org.mklab.taskit.client.ui.admin.AbstractEntityEditorView.java

License:Apache License

/**
 * {@inheritDoc}//from   w ww  . ja v a2 s .c  o m
 */
@Override
protected final Widget initContent() {
    this.table = new CellTable<E>();
    initTable();
    return binder.createAndBindUi(this);
}

From source file:org.mklab.taskit.client.ui.CheckInListViewImpl.java

License:Apache License

/**
 * {@inheritDoc}/*from   w w w  . ja va 2  s. co  m*/
 */
@Override
protected Widget initContent() {
    final Messages messages = getClientFactory().getMessages();
    this.table = new CellTable<CheckMapProxy>();
    this.table.addColumn(new Column<CheckMapProxy, String>(new TextCell()) {

        @Override
        public String getValue(CheckMapProxy object) {
            return object.getId();
        }
    }, messages.userIdLabel());
    this.table.addColumn(new Column<CheckMapProxy, String>(new TextCell()) {

        @Override
        public String getValue(CheckMapProxy object) {
            return object.getStudent().getId();
        }
    }, messages.studentLabel());
    this.table.addColumn(new Column<CheckMapProxy, String>(new TextCell()) {

        private final DateTimeFormat format = DateTimeFormat.getFormat(PredefinedFormat.DATE_TIME_MEDIUM);

        @Override
        public String getValue(CheckMapProxy object) {
            final Date date = object.getDate();
            return this.format.format(date);
        }
    }, messages.checkInTimeLabel());

    final Widget widget = binder.createAndBindUi(this);
    this.reloadButton.setText(messages.reloadLabel());
    return widget;
}

From source file:org.mklab.taskit.client.ui.HelpCallListViewImpl.java

License:Apache License

/**
 * {@inheritDoc}//  w w w  .j a  v  a2  s. co  m
 */
@Override
protected Widget initContent() {
    this.table = new CellTable<HelpCallListViewImpl.HelpCallListItem>();
    initColumns();
    listenSelectionEvent();

    final Widget widget = binder.createAndBindUi(this);
    this.checkInListButton.setText(getClientFactory().getMessages().checkInListLabel());

    return widget;
}

From source file:org.quartz.GWTQuartzManager.client.QuartzManager.java

License:Open Source License

public void onModuleLoad() {
    //catch exception
    GWT.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
        public void onUncaughtException(Throwable e) {
            log.log(Level.SEVERE, e.getMessage(), e);
        }/*w  w  w.  j  a v a  2 s. c om*/
    });
    Logger.getLogger("").addHandler(new ErrorDialog().getHandler());

    eventBus.addHandler(TriggerJobEvent.TYPE, new TriggerJobEvent.Handler() {
        @Override
        public void fireTrigger(GWTJobDetail jobDetail) {
            scheduler.triggerJob(jobDetail.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }
    });

    eventBus.addHandler(DeleteJobEvent.TYPE, new DeleteJobEvent.Handler() {

        @Override
        public void deleteJob(GWTJobDetail jobDetail) {
            scheduler.deleteJob(jobDetail.getKey(), new AsyncCallback<Boolean>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Boolean result) {
                    updateJobs();
                }
            });
        }
    });

    eventBus.addHandler(EditTriggerEvent.TYPE, new EditTriggerEvent.Handler() {

        @Override
        public void startEdit(GWTTrigger trigger) {
            //TODO in the future, there may be some subclasses of GWTTrigger other than WGTCronTrigger.
            //do instanceof check
            EditCronTriggerWorkflow newTriggerWorkflow = new EditCronTriggerWorkflow(scheduler);
            newTriggerWorkflow.edit((GWTCronTrigger) trigger);
        }
    });

    eventBus.addHandler(ToggleTriggerStateEvent.TYPE, new ToggleTriggerStateEvent.Handler() {

        @Override
        public void resume(GWTTrigger trigger) {
            scheduler.resumeTrigger(trigger.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }

        @Override
        public void pause(GWTTrigger trigger) {
            scheduler.pauseTrigger(trigger.getKey(), new GWTQuartzScheduler.nopAsynCallback<Void>());
        }
    });

    eventBus.addHandler(EditJobEvent.TYPE, new EditJobEvent.Handler() {

        @Override
        public void editJob(GWTJobDetail jobDetail, boolean create) {
            new EditJobDetailWorkflow(scheduler, create).edit(jobDetail);
        }
    });

    RootPanel rootPanel = RootPanel.get();
    rootPanel.setSize("100%", "100%");

    DockPanel dockPanel = new DockPanel();
    rootPanel.add(dockPanel);
    dockPanel.setSize("", "100%");

    SimplePanel simplePanel = new SimplePanel();
    simplePanel.add(new SchedulerAdminButtonsWidget(scheduler));
    dockPanel.add(simplePanel, DockPanel.NORTH);

    SimplePanel simplePanel_1 = new SimplePanel();
    dockPanel.add(simplePanel_1, DockPanel.EAST);
    dockPanel.setCellWidth(simplePanel_1, "20%");
    simplePanel_1.setWidth("");

    executedJobsTable = new CellTable<GWTQuartzJobExecutionContext>();
    simplePanel_1.setWidget(executedJobsTable);
    executedJobsTable.setSize("100%", "100%");
    executedJobsTable.setTableLayoutFixed(false);

    TextColumn<GWTQuartzJobExecutionContext> ejJobName = new TextColumn<GWTQuartzJobExecutionContext>() {
        @Override
        public String getValue(GWTQuartzJobExecutionContext object) {
            return object.getJobKey().getName();
        }
    };
    executedJobsTable.addColumn(ejJobName, "job name");

    TextColumn<GWTQuartzJobExecutionContext> ejTriggerName = new TextColumn<GWTQuartzJobExecutionContext>() {
        @Override
        public String getValue(GWTQuartzJobExecutionContext object) {
            return object.getTriggerKey().getName();
        }
    };
    executedJobsTable.addColumn(ejTriggerName, "trigger name");

    Column<GWTQuartzJobExecutionContext, Number> ejRunTime = new Column<GWTQuartzJobExecutionContext, Number>(
            new NumberCell()) {
        @Override
        public Number getValue(GWTQuartzJobExecutionContext object) {
            return new Long(object.getJobRunTime());
        }
    };
    executedJobsTable.addColumn(ejRunTime, "run time");
    jobExecuationContextsProvider.addDataDisplay(executedJobsTable);

    final TabPanel tabPanel = new TabPanel();
    dockPanel.add(tabPanel, DockPanel.CENTER);
    dockPanel.setCellHeight(tabPanel, "100%");
    tabPanel.setSize("100%", "100%");
    VerticalPanel verticalPanel = new VerticalPanel();
    tabPanel.add(verticalPanel, "Jobs", false);
    verticalPanel.setSize("100%", "100%");
    tabPanel.selectTab(0);

    HorizontalPanel horizontalPanel_1 = new HorizontalPanel();
    verticalPanel.add(horizontalPanel_1);
    verticalPanel.setCellHeight(horizontalPanel_1, "22");
    verticalPanel.setCellWidth(horizontalPanel_1, "100%");

    Label lblNewLabel = new Label("Job Group");
    horizontalPanel_1.add(lblNewLabel);
    lblNewLabel.setWidth("67px");

    cbGroupName = new ListBox();
    horizontalPanel_1.add(cbGroupName);

    cbGroupName.addItem(ALL_GROUPS);
    cbGroupName.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            updateJobs();
        }
    });

    final SimplePanel jobPanel = new SimplePanel();
    verticalPanel.add(jobPanel);
    verticalPanel.setCellHeight(jobPanel, "100%");
    verticalPanel.setCellWidth(jobPanel, "100%");
    jobPanel.setSize("100%", "");
    jobPanel.setStyleName("boxed");
    final JobsTable jobsTable = new JobsTable(jobsProvider, eventBus);
    jobPanel.add(jobsTable);
    jobsTable.setSize("100%", "397px");

    VerticalPanel verticalPanel_1 = new VerticalPanel();
    tabPanel.add(verticalPanel_1, "triggers", false);
    verticalPanel_1.setSize("100%", "100%");

    HorizontalPanel horizontalPanel_2 = new HorizontalPanel();
    verticalPanel_1.add(horizontalPanel_2);
    verticalPanel_1.setCellWidth(horizontalPanel_2, "100%");
    verticalPanel_1.setCellHeight(horizontalPanel_2, "22");

    Label lblGroup = new Label("Trigger Group");
    horizontalPanel_2.add(lblGroup);

    cbTriggerGroup = new ListBox();
    cbTriggerGroup.addItem(ALL_GROUPS);
    cbTriggerGroup.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            updateTriggers();
        }
    });

    horizontalPanel_2.add(cbTriggerGroup);

    Button btnPauseAll = new Button("Pause All");
    btnPauseAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            scheduler.pauseAll(new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnPauseAll);
    horizontalPanel_2.setCellHorizontalAlignment(btnPauseAll, HasHorizontalAlignment.ALIGN_RIGHT);

    Button btnResumeAll = new Button("Resume All");
    btnResumeAll.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            scheduler.resumeAll(new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnResumeAll);

    Button btnPauseGroup = new Button("Pause Group");
    btnPauseGroup.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String selectedGroup = cbTriggerGroup.getItemText(cbTriggerGroup.getSelectedIndex());
            scheduler.pauseTriggers(selectedGroup, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnPauseGroup);

    Button btnResumeGroup = new Button("Resume Group");
    btnResumeGroup.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            String selectedGroup = cbTriggerGroup.getItemText(cbTriggerGroup.getSelectedIndex());
            scheduler.resumeTriggers(selectedGroup, new AsyncCallback<Void>() {

                @Override
                public void onFailure(Throwable caught) {
                    // TODO Auto-generated method stub

                }

                @Override
                public void onSuccess(Void result) {
                    // TODO Auto-generated method stub

                }
            });
        }
    });
    horizontalPanel_2.add(btnResumeGroup);

    SimplePanel triggerPanel = new SimplePanel();
    verticalPanel_1.add(triggerPanel);
    triggerPanel.setSize("100%", "390px");
    TriggersTable triggersTable = new TriggersTable(eventBus, triggersProvider);
    triggerPanel.add(triggersTable);
    triggersTable.setSize("100%", "100%");

    scheduler.getJobGroupNames(new AsyncCallback<ArrayList<String>>() {

        @Override
        public void onSuccess(ArrayList<String> result) {
            for (String name : result) {
                cbGroupName.addItem(name);
            }
            updateJobs();
        }

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }
    });

    //polling jobs, triggers and job executions status
    new com.google.gwt.user.client.Timer() {
        @Override
        public void run() {

            updateJobs();

            updateTriggers();

            updateJobExecutionContexts();
            this.schedule(2000);
        }
    }.schedule(2000);

    scheduler.getTriggerGroupNames(new AsyncCallback<List<String>>() {

        @Override
        public void onFailure(Throwable caught) {
            // TODO Auto-generated method stub

        }

        @Override
        public void onSuccess(List<String> result) {
            for (String group : result) {
                cbTriggerGroup.addItem(group);
            }
            updateTriggers();
        }
    });

    //update trigger group combo box

}

From source file:org.staticioc.samples.gwt.client.view.ContactsReportingViewImpl.java

License:Apache License

private void buildCellTable() {
    contactsTable = new CellTable<Contact>();
    contactsTable.setTableLayoutFixed(false);
    contactsTable.setFocus(false);//from  w  w  w. jav a2 s .  c  o m
    contactsTable.setPageSize(10);
}

From source file:org.staticioc.samples.gwt.client.view.ContactsViewImpl.java

License:Apache License

private void buildCellTable() {
    contactsTable = new CellTable<Contact>();
    contactsTable.setTableLayoutFixed(false);
    contactsTable.setFocus(false);//from   www.j a v a2s.c om
    contactsTable.setPageSize(10);

    // Set-up selected contact selection model
    final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>();
    contactsTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);
    contactsTable.setSelectionModel(selectionModel);

    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Contact selected = selectionModel.getSelectedObject();
            selectedItem = selected;
        }
    });
}

From source file:org.t3as.snomedct.gwt.client.SnomedCoderUi.java

License:Open Source License

public void onModuleLoad() {
    // create the widgets
    final Button analyseButton = new Button(messages.sendButton());
    final Button configureButton = new Button(messages.configureButton());
    final TextArea mainTextArea = new TextArea();
    mainTextArea.setCharacterWidth(80);/*from w  ww  .j av  a 2 s.c o  m*/
    mainTextArea.setVisibleLines(15);
    final Label errorLabel = new Label();
    final CellTable<SnomedConcept> resultsTable = new CellTable<>();

    // add them to the root panel
    RootPanel.get("mainTextArea").add(mainTextArea);
    RootPanel.get("analyseButton").add(analyseButton);
    RootPanel.get("configureButton").add(configureButton);
    RootPanel.get("status").add(errorLabel);
    RootPanel.get("snomedCodes").add(resultsTable);

    // set the focus to the text area
    mainTextArea.setFocus(true);

    // initialise the SNOMED code results table
    final List<SnomedConcept> conceptList = configSnomedTable(resultsTable);

    // add the handlers
    final List<SemanticType> types = new ArrayList<>();
    final Map<String, String> typeCodeToDescription = new HashMap<>();
    analyseButton.addClickHandler(
            new AnalyseHandler(mainTextArea, errorLabel, conceptList, types, typeCodeToDescription));
    configureButton.addClickHandler(new ConfigureHandler(types, typeCodeToDescription));
}