List of usage examples for com.google.gwt.view.client SingleSelectionModel SingleSelectionModel
public SingleSelectionModel()
From source file:com.google.gwt.sample.showcase.client.Showcase.java
License:Apache License
/** * This is the entry point method./*from w ww.j a va 2 s .c o m*/ */ public void onModuleLoad() { // Generate the source code and css for the examples GWT.create(GeneratorInfo.class); // Inject global styles. injectThemeStyleSheet(); images.css().ensureInjected(); // Initialize the constants. ShowcaseConstants constants = GWT.create(ShowcaseConstants.class); // Create the application shell. final SingleSelectionModel<ContentWidget> selectionModel = new SingleSelectionModel<ContentWidget>(); final MainMenuTreeViewModel treeModel = new MainMenuTreeViewModel(constants, selectionModel); Set<ContentWidget> contentWidgets = treeModel.getAllContentWidgets(); shell = new ShowcaseShell(treeModel); RootLayoutPanel.get().add(shell); // Prefetch examples when opening the Category tree nodes. final List<Category> prefetched = new ArrayList<Category>(); final CellTree mainMenu = shell.getMainMenu(); mainMenu.addOpenHandler(new OpenHandler<TreeNode>() { public void onOpen(OpenEvent<TreeNode> event) { Object value = event.getTarget().getValue(); if (!(value instanceof Category)) { return; } Category category = (Category) value; if (!prefetched.contains(category)) { prefetched.add(category); Prefetcher.prefetch(category.getSplitPoints()); } } }); // Always prefetch. Prefetcher.start(); // Change the history token when a main menu item is selected. selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { ContentWidget selected = selectionModel.getSelectedObject(); if (selected != null) { History.newItem(getContentWidgetToken(selected), true); } } }); // Setup a history handler to reselect the associate menu item. final ValueChangeHandler<String> historyHandler = new ValueChangeHandler<String>() { public void onValueChange(ValueChangeEvent<String> event) { // Get the content widget associated with the history token. ContentWidget contentWidget = treeModel.getContentWidgetForToken(event.getValue()); if (contentWidget == null) { return; } // Expand the tree node associated with the content. Category category = treeModel.getCategoryForContentWidget(contentWidget); TreeNode node = mainMenu.getRootTreeNode(); int childCount = node.getChildCount(); for (int i = 0; i < childCount; i++) { if (node.getChildValue(i) == category) { node.setChildOpen(i, true, true); break; } } // Select the node in the tree. selectionModel.setSelected(contentWidget, true); // Display the content widget. displayContentWidget(contentWidget); } }; History.addValueChangeHandler(historyHandler); // Show the initial example. if (History.getToken().length() > 0) { History.fireCurrentHistoryState(); } else { // Use the first token available. TreeNode root = mainMenu.getRootTreeNode(); TreeNode category = root.setChildOpen(0, true); ContentWidget content = (ContentWidget) category.getChildValue(0); selectionModel.setSelected(content, true); } // Generate a site map. createSiteMap(contentWidgets); }
From source file:com.google.gwt.sample.stockwatcher.client.Cells.java
private Widget createCellList() { TextCell textCell = new TextCell(); CellList<String> cellList = new CellList<>(textCell); final List<String> DAYS = Arrays.asList("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); /*/*from ww w . j a v a 2s .c om*/ * Selection Model */ cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); //Add a selection model to handle user selection final SingleSelectionModel<String> selectionModel = new SingleSelectionModel<String>(); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { String selected = selectionModel.getSelectedObject(); if (selected != null) { Window.alert("You selected: " + selected); } } }); /* * Value updater */ // cellList.setValueUpdater(new ValueUpdater<String>() { // @Override // public void update(String value) { // Window.alert("New Value: " + value); // } // }); // 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. cellList.setRowCount(DAYS.size(), true); cellList.setRowData(0, DAYS); // Create a SimplePager. SimplePager pager = new SimplePager(); // Set the cellList as the display. pager.setDisplay(cellList); // Add the pager and list to the page. VerticalPanel vPanel = new VerticalPanel(); vPanel.add(pager); vPanel.add(cellList); return vPanel; }
From source file:com.gsr.myschool.back.client.web.application.settings.popup.NiveauEtudeInfosView.java
License:Apache License
private void initializeEvents() { final SingleSelectionModel<PieceJustifProxy> pieceModel = new SingleSelectionModel<PieceJustifProxy>(); pieceJustifList.setSelectionModel(pieceModel); pieceModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { pieceEditor.edit(getUiHandlers().loadPiece(pieceModel.getSelectedObject())); }//from w w w . j av a 2s .co m }); final SingleSelectionModel<MatiereExamenProxy> matiereModel = new SingleSelectionModel<MatiereExamenProxy>(); matiereExamenList.setSelectionModel(matiereModel); matiereModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { matiereEditor.edit(getUiHandlers().loadMatiere(matiereModel.getSelectedObject())); } }); pieceEditor.initSuggestions(); matiereEditor.initSuggestions(); }
From source file:com.gsr.myschool.back.client.web.application.settings.widget.EmailTemplateView.java
License:Apache License
@Inject public EmailTemplateView(final Binder uiBinder, final ValidationErrorPopup errorPopup, final SharedMessageBundle sharedMessageBundle, final EmailTemplateEditor emailTemplateEditor, final DetailsListStyle listStyle) { super(errorPopup); this.emailTemplateEditor = emailTemplateEditor; this.dataProvider = new ListDataProvider<EmailType>(Arrays.asList(EmailType.values())); this.templates = new CellList<EmailType>(new AbstractCell<EmailType>() { @Override//from w w w . j a v a 2 s . co m public void render(Context context, EmailType emailType, SafeHtmlBuilder safeHtmlBuilder) { safeHtmlBuilder.appendEscaped(emailType.toString()); } }, listStyle); initWidget(uiBinder.createAndBindUi(this)); dataProvider.addDataDisplay(templates); selectionModel = new SingleSelectionModel<EmailType>(); templates.setSelectionModel(selectionModel); templates.getSelectionModel().addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { EmailType code = selectionModel.getSelectedObject(); if (code != null) getUiHandlers().loadTemplate(code); } }); templates.setEmptyListWidget(new EmptyResult(sharedMessageBundle.noResultFound(), AlertType.WARNING)); selectionModel.setSelected(EmailType.REGISTRATION, true); }
From source file:com.gsr.myschool.back.client.web.application.valueList.ValueListView.java
License:Apache License
@Inject public ValueListView(final Binder uiBinder, final SharedMessageBundle sharedMessageBundle, final ValueListActionCellFactory actionCellFactory) { initWidget(uiBinder.createAndBindUi(this)); this.addValueList.setVisible(false); this.dataProvider = new ListDataProvider<ValueListProxy>(); this.valueListSelectionModel = new SingleSelectionModel<ValueListProxy>(); this.actionCellFactory = actionCellFactory; dataProvider.addDataDisplay(valueListTable); valueListTable.setSelectionModel(valueListSelectionModel); valueListTable.setEmptyTableWidget(new EmptyResult(sharedMessageBundle.noResultFound(), AlertType.WARNING)); initActions();/* w w w.ja v a 2 s.com*/ initDataGrid(); }
From source file:com.gsr.myschool.back.client.web.application.valueList.widget.ValueTypeView.java
License:Apache License
@Inject public ValueTypeView(final Binder uiBinder, final SharedMessageBundle sharedMessageBundle, final CellTableStyle cellTableStyle) { this.dataProvider = new ListDataProvider<ValueTypeProxy>(); this.valueTypeTable = new CellTable<ValueTypeProxy>(15, cellTableStyle); this.valueTypeSelectionModel = new SingleSelectionModel<ValueTypeProxy>(); initDataGrid();//from w w w.jav a2 s . c om initWidget(uiBinder.createAndBindUi(this)); dataProvider.addDataDisplay(valueTypeTable); valueTypeTable.setSelectionModel(valueTypeSelectionModel); valueTypeTable.setEmptyTableWidget(new EmptyResult(sharedMessageBundle.noResultFound(), AlertType.WARNING)); valueTypeSelectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { getUiHandlers().valueTypeChanged(valueTypeSelectionModel.getSelectedObject()); } }); }
From source file:com.gwt2go.dev.client.ui.table.DataGridImpl1.java
License:Apache License
public DataGridImpl1() { // Create a CellTable. DataGrid<Contact> table = new DataGrid<Contact>(); table.setWidth("100%"); table.setHeight("100px"); // table.setRowStyles(new RowStyles<DataGridImpl1.Contact>() { // @Override // public String getStyleNames(Contact row, int rowIndex) { // return "headcol"; // }/*from ww w .jav a2 s.com*/ // }); table.setEmptyTableWidget(new Label("No Information to show")); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); // Add a text column to show the name. TextColumn<Contact> nameColumn = new TextColumn<Contact>() { @Override 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); // -- END TABLE // viewPanel.getElement().appendChild(nameSpan); viewPanel.add(table); viewPanel.setSize("30em", "10em"); initWidget(viewPanel); }
From source file:com.gwtplatform.carstore.client.application.cars.CarsMobileView.java
License:Apache License
@Inject CarsMobileView(Binder uiBinder, CarCell carCell, MobileDataListStyle mobileDataListStyle) { pagerPanel = new ShowMorePagerPanel(PAGE_SIZE); carList = new CellList<CarDto>(carCell, mobileDataListStyle); selectionModel = new SingleSelectionModel<CarDto>(); initWidget(uiBinder.createAndBindUi(this)); pagerPanel.setDisplay(carList);// w ww.ja v a2 s .co m carList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(SelectionChangeEvent event) { getUiHandlers().onEdit(selectionModel.getSelectedObject()); } }); }
From source file:com.gwtplatform.carstore.client.application.manufacturer.ManufacturerMobileView.java
License:Apache License
@Inject ManufacturerMobileView(Binder uiBinder, ManufacturerCell manufacturerCell, MobileDataListStyle mobileDataListStyle) { manufacturerList = new CellList<ManufacturerDto>(manufacturerCell, mobileDataListStyle); initWidget(uiBinder.createAndBindUi(this)); manufacturerDataProvider = new ListDataProvider<ManufacturerDto>(); manufacturerDataProvider.addDataDisplay(manufacturerList); selectionModel = new SingleSelectionModel<ManufacturerDto>(); manufacturerList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override//from w w w . ja v a 2s .c om public void onSelectionChange(SelectionChangeEvent event) { getUiHandlers().onDetail(selectionModel.getSelectedObject()); } }); }
From source file:com.gwtplatform.carstore.client.application.rating.RatingMobileView.java
License:Apache License
@Inject RatingMobileView(Binder uiBinder, RatingCellFactory ratingCellFactory, MobileDataListStyle mobileDataListStyle) { ratingList = new CellList<RatingDto>(ratingCellFactory.create(setupRemoveAction()), mobileDataListStyle); initWidget(uiBinder.createAndBindUi(this)); ratingDataProvider = new ListDataProvider<RatingDto>(); ratingDataProvider.addDataDisplay(ratingList); selectionModel = new SingleSelectionModel<RatingDto>(); ratingList.setSelectionModel(selectionModel); }