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:com.adamantium.company.gwtp.client.application.list.ListView.java

License:Apache License

@Inject
ListView(Binder uiBinder) {
    // Create a CellTable.
    cellTable = new CellTable<CompanyTableInfo>();
    buildColumns(cellTable);//from   w  ww . j  a  va2 s.  c  o m
    // Add a selection model to handle user selection.
    final SingleSelectionModel<CompanyTableInfo> selectionModel = new SingleSelectionModel<CompanyTableInfo>();
    cellTable.setSelectionModel(selectionModel);
    //        selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
    //            public void onSelectionChange(SelectionChangeEvent event) {
    //                CompanyTableInfo selected = selectionModel.getSelectedObject();
    //                if (selected != null) {
    //                    Window.alert("You selected: " + selected.getName());
    //                }
    //            }
    //        });
    buildPager();
    initWidget(uiBinder.createAndBindUi(this));
}

From source file:com.appspot.socialinquirer.client.view.ActivityViewImpl.java

License:Apache License

/**
 * Instantiates a new activity view impl.
 *
 * @param constants the constants/*www  .j  a  v a  2 s . co m*/
 * @param master the master
 */
public ActivityViewImpl(final EverScribeConstants constants, final boolean master) {
    this.constants = constants;
    activitiesTable = new CellTable<NamedBean>();
    SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class);
    activitiesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true);
    activitiesPaginator.setDisplay(activitiesTable);
    activitiesPaginator.setPageSize(5);
    activitiesTable.setPageSize(5);

    final SelectionModel<NamedBean> activitiesSelectionModel = new SingleSelectionModel<NamedBean>(
            new KeyProvider<NamedBean>());
    activitiesTable.setSelectionModel(activitiesSelectionModel,
            DefaultSelectionEventManager.<NamedBean>createCheckboxManager());
    initTableColumns(activitiesTable, activitiesSelectionModel);

    initWidget(uiBinder.createAndBindUi(ActivityViewImpl.this));
}

From source file:com.appspot.socialinquirer.client.view.HomeViewImpl.java

License:Apache License

/**
 * Instantiates a new home view impl.//w  w w.  j  a  va  2s . com
 *
 * @param constants the constants
 * @param oracle the oracle
 */
public HomeViewImpl(final EverScribeConstants constants, SingleWordSuggestOracle oracle) {
    this.constants = constants;
    questionsTable = new CellTable<Question>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    questionsPaginator.setDisplay(questionsTable);
    final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>(
            new KeyProvider<Question>());
    questionsTable.setSelectionModel(questionsSelectionModel,
            DefaultSelectionEventManager.<Question>createCheckboxManager());
    initTableColumns(questionsTable, questionsSelectionModel);
    questionsSearchBox = new SuggestBox(oracle);
    templatesTable = new CellTable<Message>();
    SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class);
    templatesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true);
    templatesPaginator.setPageSize(5);
    templatesTable.setPageSize(5);
    templatesPaginator.setDisplay(templatesTable);
    //       final SelectionModel<Message> linkedHubConnectionsSelectionModel = new MultiSelectionModel<Message>(
    //               new KeyProvider<Message>());
    //       templatesTable.setSelectionModel(linkedHubConnectionsSelectionModel,
    //               DefaultSelectionEventManager.<Message>createCheckboxManager());
    initTableColumns(templatesTable);

    initWidget(uiBinder.createAndBindUi(this));
    searchResults.setVisible(false);
    introduction.setVisible(true);
    feeds.setVisible(false);

    viewMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onViewClicked(getSelectedQuestion());
        }
    });

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(getSelectedQuestion());
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(getSelectedQuestion());
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(getSelectedQuestion());
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(getSelectedQuestion());
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(getSelectedQuestion());
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(getSelectedQuestion());
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(getSelectedQuestion());
        }
    });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(getSelectedQuestion(), language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }
}

From source file:com.appspot.socialinquirer.client.view.NetworkViewImpl.java

License:Apache License

/**
 * Instantiates a new network view impl.
 *
 * @param constants the constants/*from  w  ww .  j  a  v  a 2 s .c  om*/
 */
public NetworkViewImpl(EverScribeConstants constants) {
    this.constants = constants;
    GWT.runAsync(new RunAsyncCallback() {
        public void onFailure(Throwable caught) {
            Window.alert("Code download failed");
        }

        public void onSuccess() {
            connectionsTable = new CellTable<User>();
            SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class);
            connectionsPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0,
                    true);
            connectionsPaginator.setDisplay(connectionsTable);
            final SelectionModel<User> linkedHubConnectionsSelectionModel = new SingleSelectionModel<User>(
                    new KeyProvider<User>());
            connectionsTable.setSelectionModel(linkedHubConnectionsSelectionModel,
                    DefaultSelectionEventManager.<User>createCheckboxManager());
            initTableColumns(connectionsTable, linkedHubConnectionsSelectionModel);

            initWidget(uiBinder.createAndBindUi(NetworkViewImpl.this));
        }
    });

}

From source file:com.appspot.socialinquirer.client.view.PagesViewImpl.java

License:Apache License

/**
 * Instantiates a new pages view impl.//from  www. j  a  v  a  2  s  .c  om
 *
 * @param constants the constants
 * @param master the master
 */
public PagesViewImpl(final EverScribeConstants constants, final boolean master) {
    this.constants = constants;
    templatesTable = new CellTable<Page>();
    SimplePager.Resources linkedHubPagerResources = GWT.create(SimplePager.Resources.class);
    templatesPaginator = new SimplePager(TextLocation.CENTER, linkedHubPagerResources, false, 0, true);
    templatesPaginator.setPageSize(5);
    templatesTable.setPageSize(5);
    templatesPaginator.setDisplay(templatesTable);
    final SelectionModel<Page> linkedHubConnectionsSelectionModel = new MultiSelectionModel<Page>(
            new KeyProvider<Page>());
    templatesTable.setSelectionModel(linkedHubConnectionsSelectionModel,
            DefaultSelectionEventManager.<Page>createCheckboxManager());
    initTableColumns(templatesTable, linkedHubConnectionsSelectionModel);

    initWidget(uiBinder.createAndBindUi(PagesViewImpl.this));
}

From source file:com.appspot.socialinquirer.client.view.QuestionsViewImpl.java

License:Apache License

/**
 * Instantiates a new questions view impl.
 *
 * @param constants the constants/*from www  .  j  a va  2s  .com*/
 */
public QuestionsViewImpl(final EverScribeConstants constants) {
    this.constants = constants;
    questionsTable = new CellTable<Question>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    questionsPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    questionsPaginator.setDisplay(questionsTable);
    final SelectionModel<Question> questionsSelectionModel = new SingleSelectionModel<Question>(
            new KeyProvider<Question>());
    questionsTable.setSelectionModel(questionsSelectionModel,
            DefaultSelectionEventManager.<Question>createCheckboxManager());
    initTableColumns(questionsTable, questionsSelectionModel);
    initWidget(uiBinder.createAndBindUi(this));

    // menu commands
    viewMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onViewClicked(getSelectedQuestion());
        }
    });

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(getSelectedQuestion());
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(getSelectedQuestion());
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(getSelectedQuestion());
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(getSelectedQuestion());
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(getSelectedQuestion());
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(getSelectedQuestion());
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(getSelectedQuestion());
        }
    });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(getSelectedQuestion(), language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }
}

From source file:com.appspot.socialinquirer.client.view.QuestionViewImpl.java

License:Apache License

/**
 * Instantiates a new question view impl.
 *
 * @param constants the constants/*from w  w  w . ja  va  2  s. c  o m*/
 */
public QuestionViewImpl(final EverScribeConstants constants) {
    this.constants = constants;
    answersTable = new CellTable<Answer>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    answersPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    answersPaginator.setDisplay(answersTable);
    final SelectionModel<Answer> answerSelectionModel = new SingleSelectionModel<Answer>(
            new KeyProvider<Answer>());
    answersTable.setSelectionModel(answerSelectionModel,
            DefaultSelectionEventManager.<Answer>createCheckboxManager());
    initTableColumns(answersTable, answerSelectionModel);

    initWidget(uiBinder.createAndBindUi(this));

    //       followMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowClicked(question);
    //         }
    //      });
    analyzeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onAnalyzeClicked(question);
        }
    });
    summarizeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSummarizeClicked(question);
        }
    });
    suggestAnswerMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSuggestAnswerClicked(question);
        }
    });
    spellCheckMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpellCheckClicked(question);
        }
    });
    speakMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onSpeakClicked(question);
        }
    });
    runCodeMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onRunCodeClicked(question);
        }
    });

    followQuestionAuthorMenu.setCommand(new Command() {
        @Override
        public void execute() {
            presenter.onFollowUserClicked(questionAuthor.getText());
        }
    });

    //       followAnswerAuthorMenu.setCommand(new Command() {
    //         @Override
    //         public void execute() {
    //            presenter.onFollowUserClicked(answerAuthor.getText());
    //         }
    //      });

    for (final TextLanguage language : TextLanguage.values()) {
        MenuItem menuItem = new MenuItem(language.name(), new Command() {

            @Override
            public void execute() {
                presenter.onTranslateClicked(question, language);
            }
        });
        menuItem.setEnabled(true);
        languageBar.addItem(menuItem);
    }

    answers.setAnimationEnabled(true);
}

From source file:com.appspot.socialinquirer.client.view.QuizViewImpl.java

License:Apache License

/**
 * Instantiates a new quiz view impl.//from  ww  w  .  j  a v a 2 s  .  co m
 *
 * @param constants the constants
 */
public QuizViewImpl(final EverScribeConstants constants) {
    this.constants = constants;
    answersTable = new CellTable<Answer>();
    SimplePager.Resources ideasPagerResources = GWT.create(SimplePager.Resources.class);
    answersPaginator = new SimplePager(TextLocation.CENTER, ideasPagerResources, false, 0, true);
    answersPaginator.setDisplay(answersTable);
    final SelectionModel<Answer> answerSelectionModel = new SingleSelectionModel<Answer>(
            new KeyProvider<Answer>());
    answersTable.setSelectionModel(answerSelectionModel,
            DefaultSelectionEventManager.<Answer>createCheckboxManager());
    initTableColumns(answersTable, answerSelectionModel);

    initWidget(uiBinder.createAndBindUi(this));
}

From source file:com.google.appinventor.client.wizards.ComponentImportWizard.java

License:Open Source License

private CellTable createCompTable() {
    final SingleSelectionModel<Component> selectionModel = new SingleSelectionModel<Component>();

    CellTable<Component> compTable = new CellTable<Component>();
    compTable.setSelectionModel(selectionModel);

    Column<Component, Boolean> checkColumn = new Column<Component, Boolean>(new CheckboxCell(true, false)) {
        @Override//  ww w .ja v  a 2  s . c  o  m
        public Boolean getValue(Component comp) {
            return selectionModel.isSelected(comp);
        }
    };
    Column<Component, String> nameColumn = new Column<Component, String>(new TextCell()) {
        @Override
        public String getValue(Component comp) {
            return comp.getName();
        }
    };
    Column<Component, Number> versionColumn = new Column<Component, Number>(new NumberCell()) {
        @Override
        public Number getValue(Component comp) {
            return comp.getVersion();
        }
    };

    compTable.addColumn(checkColumn);
    compTable.addColumn(nameColumn, "Component");
    compTable.addColumn(versionColumn, "Version");

    return compTable;
}

From source file:com.google.gwt.examples.cellview.CellTableExample.java

License:Apache License

public void onModuleLoad() {
    // Create a CellTable.
    CellTable<Contact> table = new CellTable<Contact>();
    table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED);

    // Add a text column to show the name.
    TextColumn<Contact> nameColumn = new TextColumn<Contact>() {
        @Override/*from w ww  .ja v a2s.  c o  m*/
        public String getValue(Contact object) {
            return object.name;
        }
    };
    table.addColumn(nameColumn, "Name");

    // Add a date column to show the birthday.
    DateCell dateCell = new DateCell();
    Column<Contact, Date> dateColumn = new Column<Contact, Date>(dateCell) {
        @Override
        public Date getValue(Contact object) {
            return object.birthday;
        }
    };
    table.addColumn(dateColumn, "Birthday");

    // Add a text column to show the address.
    TextColumn<Contact> addressColumn = new TextColumn<Contact>() {
        @Override
        public String getValue(Contact object) {
            return object.address;
        }
    };
    table.addColumn(addressColumn, "Address");

    // Add a selection model to handle user selection.
    final SingleSelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>();
    table.setSelectionModel(selectionModel);
    selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() {
        public void onSelectionChange(SelectionChangeEvent event) {
            Contact selected = selectionModel.getSelectedObject();
            if (selected != null) {
                Window.alert("You selected: " + selected.name);
            }
        }
    });

    // Set the total row count. This isn't strictly necessary, but it affects
    // paging calculations, so its good habit to keep the row count up to date.
    table.setRowCount(CONTACTS.size(), true);

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

    // Add it to the root panel.
    RootPanel.get().add(table);
}