List of usage examples for com.google.gwt.user.cellview.client CellList CellList
public CellList(final Cell<T> cell, ProvidesKey<T> keyProvider)
From source file:cc.kune.gspace.client.i18n.I18nCellList.java
License:Apache License
/** * Instantiates a new i18n cell list.// www.j a v a 2s. c o m * * @param data * the data * @param i18n * the i18n * @param saver * the saver */ @Inject public I18nCellList(final I18nTranslationDataProvider data, final I18nUITranslationService i18n, final I18nTranslatorSaver saver) { this.data = data; final TranslationCell cell = new TranslationCell(); // Set a key provider that provides a unique key for each contact. If key is // used to identify translations when fields change. cellList = new CellList<I18nTranslationDTO>(cell, I18nTranslationDTO.KEY_PROVIDER); cellList.setPageSize(30); cellList.setEmptyListMessage(SafeHtmlUtils .fromTrustedString("<span style='padding: 10px; font-style: italic;'>Empty list</span>")); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); final SingleSelectionModel<I18nTranslationDTO> selectionModel = new SingleSelectionModel<I18nTranslationDTO>( I18nTranslationDTO.KEY_PROVIDER); // Add a selection model so we can select cells. cellList.setSelectionModel(selectionModel); // Create the UiBinder. final Binder uiBinder = GWT.create(Binder.class); initWidget(uiBinder.createAndBindUi(this)); translatorForm.init(data, i18n, saver); cellList.setValueUpdater(new ValueUpdater<I18nTranslationDTO>() { @Override public void update(final I18nTranslationDTO value) { // save(value); } }); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(final SelectionChangeEvent event) { translatorForm.setInfo(selectionModel.getSelectedObject()); Scheduler.get().scheduleEntry(new ScheduledCommand() { @Override public void execute() { translatorForm.focusToTranslate(); } }); } }); // cellList.sinkEvents(com.google.gwt.user.client.Event.KEYEVENTS); data.addDataDisplay(cellList); data.setSelectionMode(selectionModel); data.setLoadCallback(new SimpleCallback() { @Override public void onCallback() { translatorForm.focusToTranslate(); NotifyUser.hideProgress(); } }); // Set the cellList as the display of the pagers. // pagerPanel is a scrollable pager that extends the range when the // user scrolls to the bottom. rangeLabelPager is a pager that displays the // current range, but does not have any controls to change the range. pagerPanel.setDisplay(cellList); // pagerPanel.setStyleName("k-i18n-trans-list"); rangeLabelPager.setDisplay(cellList); }
From source file:cimav.visorglass.client.widgets.PanelesLayout.java
License:Apache License
public PanelesLayout(GWTServiceAsync gwtServiceAsync) { initWidget(uiBinder.createAndBindUi(this)); this.gwtServiceAsync = gwtServiceAsync; // Crea el Modelo arbolModel = new ArbolModel(); // Crea el node Root TreeItem root = new TreeItem(SafeHtmlUtils.fromString("<h2>La Root</h2>")); // Cambia Recursos del Arbol CellTree.Resources cellTreeResources = GWT.create(ICellTreeResources.class); CellTree.CellTreeMessages cellTreeMsgs = GWT.<CellTree.CellTreeMessages>create(ICellTreeMessages.class); // Crea el arbol cellArbol = new CellTree(arbolModel, root, cellTreeResources, cellTreeMsgs); cellArbol.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED); // agrega el arbol a su Panel //flowPanelArbol.add(cellArbol); cellArbol.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); cellArbol.getElement().getStyle().setTop(10, Style.Unit.PX); cellArbol.getElement().getStyle().setLeft(0, Style.Unit.PX); cellArbol.getElement().getStyle().setBottom(0, Style.Unit.PX); cellArbol.getElement().getStyle().setRight(0, Style.Unit.PX); scrollPanelArbol.add(cellArbol);/*from w ww . j a v a2 s. co m*/ /* Inyectarle style absolute al Abuelo para que funcione el scroll del cellArbol */ Element divAbue2 = cellArbol.getElement().getParentElement().getParentElement(); divAbue2.getStyle().setPosition(Style.Position.ABSOLUTE); divAbue2.getStyle().setTop(0, Style.Unit.PX); divAbue2.getStyle().setLeft(0, Style.Unit.PX); divAbue2.getStyle().setBottom(0, Style.Unit.PX); divAbue2.getStyle().setRight(0, Style.Unit.PX); // Crea CellList de Documentos, sus resources, su Celda, su SelectionModel y su Listener. documentoSelectionModel = new SingleSelectionModel<Documento>(); CellList.Resources cellListResources = GWT.create(ICellListResources.class); documentosCellList = new CellList<Documento>(new DocumentoCell(documentoSelectionModel), cellListResources); documentosCellList.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.ENABLED); documentosCellList.setSelectionModel(documentoSelectionModel); documentosCellList.setPageSize(500); // listener documentoSelectionModel.addSelectionChangeHandler(new DocumentoSelectionHandler()); // Style absolute documentosCellList.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); documentosCellList.getElement().getStyle().setTop(0, Style.Unit.PX); documentosCellList.getElement().getStyle().setLeft(0, Style.Unit.PX); documentosCellList.getElement().getStyle().setBottom(0, Style.Unit.PX); documentosCellList.getElement().getStyle().setRight(0, Style.Unit.PX); // Agregarlo a su panel scrollPanelDocumentos.add(documentosCellList); /* Inyectarle style absolute al Abuelo para que funcione el scroll del cellList */ Element divAbue = documentosCellList.getElement().getParentElement().getParentElement(); divAbue.getStyle().setPosition(Style.Position.ABSOLUTE); divAbue.getStyle().setTop(0, Style.Unit.PX); divAbue.getStyle().setLeft(0, Style.Unit.PX); divAbue.getStyle().setBottom(0, Style.Unit.PX); divAbue.getStyle().setRight(0, Style.Unit.PX); // Listener de los Botones de Paneles btnArbol.addClickHandler(new BtnArbolClickHandler()); btnDocumentos.addClickHandler(new BtnDocumentosClickHandler()); btnVisor.addClickHandler(new BtnVisorClickHandler()); // Arega etiquetas flotantes y sus listeners Label arbolLabel = new Label("Arbol"); arbolLabel.setStyleName("jsfiddle_label"); arbolLabel.addMouseOverHandler(new JSFiddlerMouseOver()); arbolLabel.addMouseOutHandler(new JSFiddlerMouseOut()); flowPanelArbol.add(arbolLabel); documentosLabel = new Label("Documentos"); documentosLabel.setStyleName("jsfiddle_label"); documentosLabel.addMouseOverHandler(new JSFiddlerMouseOver()); documentosLabel.addMouseOutHandler(new JSFiddlerMouseOut()); flowPanelDecoratorDocumentos.add(documentosLabel); Label visorLabel = new Label("Visor"); visorLabel.setStyleName("jsfiddle_label"); visorLabel.addMouseOverHandler(new JSFiddlerMouseOver()); visorLabel.addMouseOutHandler(new JSFiddlerMouseOut()); flowPanelDecoratorVisor.add(visorLabel); frameDocViewer.addLoadHandler(new FrameLoadHandler()); reloadIcon = new Icon(IconType.ROTATE_RIGHT); reloadIcon.setSize(IconSize.LARGE); reloadIcon.setMuted(false); reloadIcon.setSpin(false); reloadIcon.getElement().getStyle().setPosition(Style.Position.ABSOLUTE); reloadIcon.getElement().getStyle().setTop(3, Style.Unit.PX); reloadIcon.getElement().getStyle().setLeft(3, Style.Unit.PX); reloadIcon.getElement().getStyle().setColor("gray"); reloadIcon.getElement().getStyle().setCursor(Style.Cursor.POINTER); reloadIcon.addDomHandler(new ReloadGoogleDocMouseDownHandler(), MouseDownEvent.getType()); // flowPanelDecoratorVisor.add(reloadIcon); // NOTE Quitar documentos btnDocumentos.setVisible(false); }
From source file:com.arcbees.gquery.tooltip.client.contactcell.ContactCellList.java
License:Apache License
private CellList<ContactInfo> initCellList(AbstractDataProvider<ContactInfo> dataProvider) { ContactCell contactCell = new ContactCell(); CellList<ContactInfo> cellList = new CellList<ContactInfo>(contactCell, ContactDatabase.ContactInfo.KEY_PROVIDER); cellList.setPageSize(30);/*www. j a va 2s.c o m*/ cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); dataProvider.addDataDisplay(cellList); return cellList; }
From source file:com.google.appinventor.client.wizards.TemplateUploadWizard.java
License:Open Source License
/** * Creates the scrollable list of cells each of which serves as a link to a template. * * @param list an ArrayList of TemplateInfo * @return A CellList widget/* w ww .ja v a 2 s. c o m*/ */ public CellList<TemplateInfo> makeTemplateSelector(ArrayList<TemplateInfo> list) { TemplateCell templateCell = new TemplateCell(list.get(0), templateHostUrl); CellList<TemplateInfo> templateCellList = new CellList<TemplateInfo>(templateCell, TemplateInfo.KEY_PROVIDER); templateCellList.setPageSize(list.size() + 10); templateCellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); templateCellList.setWidth("250px"); templateCellList.setHeight("400px"); templateCellList.setVisible(true); // Add a selection model to handle user selection. final SingleSelectionModel<TemplateInfo> selectionModel = new SingleSelectionModel<TemplateInfo>( TemplateInfo.KEY_PROVIDER); templateCellList.setSelectionModel(selectionModel); selectionModel.setSelected(list.get(0), true); final TemplateUploadWizard wizard = this; selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { TemplateInfo selected = selectionModel.getSelectedObject(); if (selected != null) { selectedTemplateNAME = selected.name; TemplateWidget.setTemplate(selected, wizard.getTemplateUrlHost()); } } }); // 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. templateCellList.setRowCount(list.size(), true); // Push the data into the widget. templateCellList.setRowData(0, list); return templateCellList; }
From source file:com.google.gwt.examples.view.KeyProviderExample.java
License:Apache License
public void onModuleLoad() { /*/*w w w .j av a 2 s . c o m*/ * Define a key provider for a Contact. We use the unique ID as the key, * which allows to maintain selection even if the name changes. */ ProvidesKey<Contact> keyProvider = new ProvidesKey<Contact>() { public Object getKey(Contact item) { // Always do a null check. return (item == null) ? null : item.id; } }; // Create a CellList using the keyProvider. CellList<Contact> cellList = new CellList<Contact>(new ContactCell(), keyProvider); // Push data into the CellList. cellList.setRowCount(CONTACTS.size(), true); cellList.setRowData(0, CONTACTS); // Add a selection model using the same keyProvider. SelectionModel<Contact> selectionModel = new SingleSelectionModel<Contact>(keyProvider); cellList.setSelectionModel(selectionModel); /* * Select a contact. The selectionModel will select based on the ID because * we used a keyProvider. */ Contact sarah = CONTACTS.get(3); selectionModel.setSelected(sarah, true); // Modify the name of the contact. sarah.name = "Sara"; /* * Redraw the CellList. Sarah/Sara will still be selected because we * identify her by ID. If we did not use a keyProvider, Sara would not be * selected. */ cellList.redraw(); // Add the widgets to the root panel. RootPanel.get().add(cellList); }
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java
License:Apache License
/** * Construct a new {@link MobileWebAppShellDesktop}. *//*from ww w.j a va 2 s. c om*/ public MobileWebAppShellDesktop(EventBus bus, TaskChartPresenter pieChart, final PlaceController placeController, TaskListView taskListView, TaskEditView taskEditView, TaskReadView taskReadView) { // Initialize the main menu. Resources resources = GWT.create(Resources.class); mainMenu = new CellList<MainMenuItem>(new MainMenuItem.Cell(), resources); mainMenu.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); // We don't expect to have more than 30 menu items. mainMenu.setVisibleRange(0, 30); // Add items to the main menu. final List<MainMenuItem> menuItems = new ArrayList<MainMenuItem>(); menuItems.add(new MainMenuItem("Task List", new TaskListPlace(false)) { @Override public boolean mapsToPlace(Place p) { // Map to all TaskListPlace instances. return p instanceof TaskListPlace; } }); menuItems.add(new MainMenuItem("Add Task", TaskPlace.getTaskCreatePlace())); mainMenu.setRowData(menuItems); // Choose a place when a menu item is selected. final SingleSelectionModel<MainMenuItem> selectionModel = new SingleSelectionModel<MainMenuItem>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { MainMenuItem selected = selectionModel.getSelectedObject(); if (selected != null && !selected.mapsToPlace(placeController.getWhere())) { placeController.goTo(selected.getPlace()); } } }); mainMenu.setSelectionModel(selectionModel); // Update selection based on the current place. bus.addHandler(PlaceChangeEvent.TYPE, new PlaceChangeEvent.Handler() { public void onPlaceChange(PlaceChangeEvent event) { Place place = event.getNewPlace(); for (MainMenuItem menuItem : menuItems) { if (menuItem.mapsToPlace(place)) { // We found a match in the main menu. selectionModel.setSelected(menuItem, true); return; } } // We didn't find a match in the main menu. selectionModel.setSelected(null, true); } }); // Initialize this widget. initWidget(uiBinder.createAndBindUi(this)); // Initialize the pie chart. String chartUrlValue = Window.Location.getParameter(CHART_URL_ATTRIBUTE); if (chartUrlValue != null && chartUrlValue.startsWith("f")) { // Chart manually disabled. leftNav.remove(1); // Pie Chart. leftNav.remove(0); // Pie chart legend. } else if (pieChart == null) { // Chart not supported. pieChartContainer.setWidget(new Label("Try upgrading to a modern browser to enable charts.")); } else { // Chart supported. Widget pieWidget = pieChart.asWidget(); pieWidget.setWidth("90%"); pieWidget.setHeight("90%"); pieWidget.getElement().getStyle().setMarginLeft(5.0, Unit.PCT); pieWidget.getElement().getStyle().setMarginTop(5.0, Unit.PCT); pieChartContainer.setWidget(pieChart); } /* * Add all views to the DeckLayoutPanel so we can animate between them. * Using a DeckLayoutPanel here works because we only have a few views, and * we always know that the task views should animate in from the right side * of the screen. A more complex app will require more complex logic to * figure out which direction to animate. */ contentContainer.add(taskListView); contentContainer.add(taskReadView); contentContainer.add(taskEditView); contentContainer.setAnimationDuration(800); // Show a tutorial when the help link is clicked. helpLink.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { showTutorial(); } }); }
From source file:com.google.gwt.sample.mobilewebapp.client.mobile.MobileTaskListView.java
License:Apache License
/** * Construct a new {@link MobileTaskListView}. *//* w ww . ja v a 2 s. c o m*/ public MobileTaskListView() { // Create the CellList. CellListResources cellListRes = GWT.create(CellListResources.class); taskList = new CellList<TaskProxy>(new TaskProxyCell(), cellListRes); taskList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); /* * Inform the presenter when the user selects a task from the task list. We * use a NoSelectionModel because we don't want the task to remain selected, * we just want to be notified of the selection event. */ final NoSelectionModel<TaskProxy> selectionModel = new NoSelectionModel<TaskProxy>(); taskList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { // Edit the task. if (presenter != null) { presenter.selectTask(selectionModel.getLastSelectedObject()); } } }); // Initialize the widget. initWidget(uiBinder.createAndBindUi(this)); }
From source file:com.google.gwt.sample.showcase.client.content.cell.CwCellList.java
License:Apache License
/** * Initialize this example./*from ww w . j ava 2 s . co m*/ */ @ShowcaseSource @Override public Widget onInitialize() { Images images = GWT.create(Images.class); // Create a CellList. ContactCell contactCell = new ContactCell(images.contact()); // Set a key provider that provides a unique key for each contact. If key is // used to identify contacts when fields (such as the name and address) // change. cellList = new CellList<ContactInfo>(contactCell, ContactDatabase.ContactInfo.KEY_PROVIDER); cellList.setPageSize(30); cellList.setKeyboardPagingPolicy(KeyboardPagingPolicy.INCREASE_RANGE); cellList.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.BOUND_TO_SELECTION); // Add a selection model so we can select cells. final SingleSelectionModel<ContactInfo> selectionModel = new SingleSelectionModel<ContactInfo>( ContactDatabase.ContactInfo.KEY_PROVIDER); cellList.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { contactForm.setContact(selectionModel.getSelectedObject()); } }); // Create the UiBinder. Binder uiBinder = GWT.create(Binder.class); Widget widget = uiBinder.createAndBindUi(this); // Add the CellList to the data provider in the database. ContactDatabase.get().addDataDisplay(cellList); // Set the cellList as the display of the pagers. This example has two // pagers. pagerPanel is a scrollable pager that extends the range when the // user scrolls to the bottom. rangeLabelPager is a pager that displays the // current range, but does not have any controls to change the range. pagerPanel.setDisplay(cellList); rangeLabelPager.setDisplay(cellList); // Handle events from the generate button. generateButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ContactDatabase.get().generateContacts(50); } }); return widget; }
From source file:com.gsr.myschool.back.client.web.application.settings.popup.NiveauEtudeInfosView.java
License:Apache License
@Inject protected NiveauEtudeInfosView(EventBus eventBus, final Binder uiBinder, final ValidationErrorPopup errorPopup, final SharedMessageBundle sharedMessageBundle, final PieceJustificatifEditor pieceEditor, final MatiereExamenEditor matiereEditor, final DetailsListStyle listStyle, final ModalHeader modalHeader) { super(eventBus, errorPopup); this.modalHeader = modalHeader; this.pieceEditor = pieceEditor; this.matiereEditor = matiereEditor; this.dataProviderMatieres = new ListDataProvider<MatiereExamenProxy>(); this.dataProviderPieces = new ListDataProvider<PieceJustifProxy>(); this.matiereExamenList = new CellList(new MatiereExamenRenderer(), listStyle); this.pieceJustifList = new CellList(new PieceJustifRenderer(), listStyle); dataProviderMatieres.addDataDisplay(matiereExamenList); dataProviderPieces.addDataDisplay(pieceJustifList); pieceJustifList.setEmptyListWidget(new EmptyResult(sharedMessageBundle.noResultFound(), AlertType.WARNING)); matiereExamenList/*from w w w .ja v a2s . c om*/ .setEmptyListWidget(new EmptyResult(sharedMessageBundle.noResultFound(), AlertType.WARNING)); initWidget(uiBinder.createAndBindUi(this)); initializeEvents(); modalHeader.addCloseHandler(new ClickHandler() { @Override public void onClick(ClickEvent clickEvent) { hide(); } }); }
From source file:com.gsr.myschool.back.client.web.application.settings.SettingsView.java
License:Apache License
@Inject public SettingsView(final Binder uiBinder, final TabsListStyle listStyle) { CellList<SettingsType> tabsCell = new CellList<SettingsType>(new EnumCell<SettingsType>(), listStyle); tabs = new ValuePicker<SettingsType>(tabsCell); initWidget(uiBinder.createAndBindUi(this)); tabs.setAcceptableValues(Arrays.asList(SettingsType.values())); tabs.setValue(SettingsType.GLOBAL, false); settingsIndexedPanel.showWidget(SettingsType.GLOBAL.ordinal()); }