List of usage examples for com.google.gwt.view.client SingleSelectionModel getSelectedObject
public T getSelectedObject()
From source file:org.picketlink.as.console.client.ui.federation.idp.TrustDomainTable.java
License:Open Source License
private SingleSelectionModel<TrustDomain> createSelectionModel() { final SingleSelectionModel<TrustDomain> selectionModel = new SingleSelectionModel<TrustDomain>(); Handler selectionHandler = new SelectionChangeEvent.Handler() { @Override/* w w w .j a va 2 s. c o m*/ public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) { SingleSelectionModel<TrustDomain> selection = (SingleSelectionModel<TrustDomain>) event.getSource(); selectedTrustedDomain = selection.getSelectedObject(); } }; selectionModel.addSelectionChangeHandler(selectionHandler); return selectionModel; }
From source file:org.picketlink.as.console.client.ui.federation.keystore.KeyTable.java
License:Open Source License
private SingleSelectionModel<Key> createSelectionModel() { final SingleSelectionModel<Key> selectionModel = new SingleSelectionModel<Key>(); Handler selectionHandler = new Handler() { @Override//from w w w. j a va 2s .com public void onSelectionChange(SelectionChangeEvent event) { SingleSelectionModel<Key> selection = (SingleSelectionModel<Key>) event.getSource(); selectedKey = selection.getSelectedObject(); } }; selectionModel.addSelectionChangeHandler(selectionHandler); return selectionModel; }
From source file:org.picketlink.as.console.client.ui.federation.sp.ServiceProviderHandlerParameterTable.java
License:Open Source License
private SingleSelectionModel<ServiceProviderHandlerParameter> createSelectionModel() { final SingleSelectionModel<ServiceProviderHandlerParameter> selectionModel = new SingleSelectionModel<ServiceProviderHandlerParameter>(); Handler selectionHandler = new SelectionChangeEvent.Handler() { @Override/*www .j av a 2 s. co m*/ public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) { SingleSelectionModel<ServiceProviderHandlerParameter> selection = (SingleSelectionModel<ServiceProviderHandlerParameter>) event .getSource(); selectedHandler = selection.getSelectedObject(); } }; selectionModel.addSelectionChangeHandler(selectionHandler); return selectionModel; }
From source file:org.picketlink.as.console.client.ui.federation.sp.ServiceProviderHandlerTable.java
License:Open Source License
private SingleSelectionModel<ServiceProviderHandler> createSelectionModel() { final SingleSelectionModel<ServiceProviderHandler> selectionModel = new SingleSelectionModel<ServiceProviderHandler>(); Handler selectionHandler = new SelectionChangeEvent.Handler() { @Override// w ww . ja v a2 s. c o m public void onSelectionChange(com.google.gwt.view.client.SelectionChangeEvent event) { SingleSelectionModel<ServiceProviderHandler> selection = (SingleSelectionModel<ServiceProviderHandler>) event .getSource(); selectedHandler = selection.getSelectedObject(); List<ServiceProviderHandlerWrapper> handlers = selectedServiceProvider.getHandlers(); for (ServiceProviderHandlerWrapper handlerWrapper : handlers) { if (handlerWrapper.getHandler().getClassName().equals(selectedHandler.getClassName())) { parametersTable.getDataProvider().setList(handlerWrapper.getParameters()); } } handlersTabEditor.doUpdateSelection(selectedHandler); } }; selectionModel.addSelectionChangeHandler(selectionHandler); return selectionModel; }
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 w ww . ja v a 2 s . c o m*/ 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:parceirosDaEstrada.web.client.paineis.PainelLocalizarCaronas.java
License:Open Source License
/** * @wbp.parser.entryPoint//from www.j a v a 2s .c om */ public LayoutPanel carregaPainel() { List<Carona> Caronas = new ArrayList<Carona>(); try { Caronas = SistemaWebMain.getSistema().localizarCarona("", ""); } catch (Exception e1) { // TODO Auto-generated catch block e1.printStackTrace(); } DateCell dateCell = new DateCell(); layoutLocalizarCaronas = new LayoutPanel(); final SingleSelectionModel<Carona> selectionModel = new SingleSelectionModel<Carona>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Carona selected = selectionModel.getSelectedObject(); if (selected != null) { PainelOpcoesDeCarona painel = new PainelOpcoesDeCarona(selected, idUsuarioLogado, PainelLocalizarCaronas.this); layoutLocalizarCaronas.clear(); layoutLocalizarCaronas.add(painel.carregaPainelDadosDaCarona()); painel.onModuleLoad(); } } }); ScrollPanel scrollPanel = new ScrollPanel(); layoutLocalizarCaronas.add(scrollPanel); layoutLocalizarCaronas.setWidgetLeftWidth(scrollPanel, 45.0, Unit.PX, 679.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(scrollPanel, 110.0, Unit.PX, 410.0, Unit.PX); scrollPanel.setSize("675px", "410px"); // Cria a CellTable que mostra a lista de caronas ao usuario final CellTable<Carona> table = new CellTable<Carona>(); scrollPanel.setWidget(table); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); TextColumn<Carona> origemColumn = new TextColumn<Carona>() { @Override public String getValue(Carona object) { return object.getOrigem(); } }; // Coluna origem table.addColumn(origemColumn, "Origem"); // Coluna data Column<Carona, Date> dateColumn = new Column<Carona, Date>(dateCell) { @SuppressWarnings("deprecation") @Override public Date getValue(Carona object) { String[] data = object.getData().split("/"); return new Date(Integer.parseInt(data[2]) - 1900, Integer.parseInt(data[1]) - 1, Integer.parseInt(data[0])); } }; table.addColumn(dateColumn, "Data"); // Coluna destino TextColumn<Carona> destinoColumn = new TextColumn<Carona>() { @Override public String getValue(Carona object) { return object.getDestino(); } }; table.addColumn(destinoColumn, "Destino"); // Coluna vagas TextColumn<Carona> vagasColumn = new TextColumn<Carona>() { @Override public String getValue(Carona object) { return object.getVagas(); } }; table.addColumn(vagasColumn, "Vagas"); table.setSelectionModel(selectionModel); table.setRowCount(Caronas.size(), true); // Push the data into the widget. table.setRowData(Caronas); table.setSize("688px", "420px"); campoOrigem = new TextBox(); // tabPanel.add(campoOrigem); layoutLocalizarCaronas.add(campoOrigem); layoutLocalizarCaronas.setWidgetLeftWidth(campoOrigem, 101.0, Unit.PX, 253.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(campoOrigem, 17.0, Unit.PX, 32.0, Unit.PX); campoDestino = new TextBox(); layoutLocalizarCaronas.add(campoDestino); layoutLocalizarCaronas.setWidgetLeftWidth(campoDestino, 439.0, Unit.PX, 253.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(campoDestino, 17.0, Unit.PX, 32.0, Unit.PX); Label origemText = new Label("Origem:"); layoutLocalizarCaronas.add(origemText); origemText.setSize("60px", "21px"); layoutLocalizarCaronas.setWidgetLeftWidth(origemText, 35.0, Unit.PX, 60.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(origemText, 28.0, Unit.PX, 21.0, Unit.PX); Label destinoText = new Label("Destino:"); layoutLocalizarCaronas.add(destinoText); destinoText.setSize("60px", "21px"); layoutLocalizarCaronas.setWidgetLeftWidth(destinoText, 377.0, Unit.PX, 60.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(destinoText, 28.0, Unit.PX, 21.0, Unit.PX); Button buscarCaronaButton = new Button("New button"); buscarCaronaButton.setText("Buscar Carona"); layoutLocalizarCaronas.add(buscarCaronaButton); layoutLocalizarCaronas.setWidgetLeftWidth(buscarCaronaButton, 574.0, Unit.PX, 118.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(buscarCaronaButton, 65.0, Unit.PX, 24.0, Unit.PX); // determina acao ao clicar o botato de buscar carona buscarCaronaButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { try { List<Carona> Caronas = SistemaWebMain.getSistema().localizarCarona(campoOrigem.getText(), campoDestino.getText()); table.setRowData(Caronas); } catch (Exception e) { Window.alert(e.getMessage() + "!"); } } }); // Push the data into the widget. table.setRowData(Caronas); Label infoMsg = new Label("Clique na carona desejada para ver mais detalhes e solicitar uma vaga."); layoutLocalizarCaronas.add(infoMsg); infoMsg.setSize("460px", "21px"); layoutLocalizarCaronas.setWidgetLeftRight(infoMsg, 47.0, Unit.PX, 267.0, Unit.PX); layoutLocalizarCaronas.setWidgetTopHeight(infoMsg, 77.0, Unit.PX, 21.0, Unit.PX); layoutLocalizarCaronas.setSize("759px", "542px"); return layoutLocalizarCaronas; }
From source file:parceirosDaEstrada.web.client.ParceirosDaEstrada.java
License:Open Source License
public LayoutPanel carregaPainelCaronas() throws Exception { LayoutPanel painelDeCaronas = new LayoutPanel(); painelDeCaronas.setSize("590px", "490px"); final List<Carona> CONTACTS = SistemaWebMain.getSistema().localizarCarona("", ""); DateCell dateCell = new DateCell(); TabPanel tabPanel = new TabPanel(); tabPanel.setSize("586px", "485px"); CellTable<Carona> table = new CellTable<Carona>(); table.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.ENABLED); final SingleSelectionModel<Carona> selectionModel = new SingleSelectionModel<Carona>(); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { Carona selected = selectionModel.getSelectedObject(); if (selected != null) { Window.alert(selected.toString() + "\n Cadastre agora mesmo e solicite uma vaga!"); }//from w ww . j ava2 s .c o m } }); TextColumn<Carona> nameColumn = new TextColumn<Carona>() { @Override public String getValue(Carona object) { return object.getOrigem(); } }; table.addColumn(nameColumn, "Origem"); Column<Carona, Date> dateColumn = new Column<Carona, Date>(dateCell) { @SuppressWarnings("deprecation") @Override public Date getValue(Carona object) { String[] data = object.getData().split("/"); return new Date(Integer.parseInt(data[2]) - 1900, Integer.parseInt(data[1]) - 1, Integer.parseInt(data[0])); } }; table.addColumn(dateColumn, "Data"); TextColumn<Carona> addressColumn = new TextColumn<Carona>() { @Override public String getValue(Carona object) { return object.getDestino(); } }; table.addColumn(addressColumn, "Destino"); table.setSelectionModel(selectionModel); tabPanel.add(table, "Proximas Caronas", false); table.setRowCount(CONTACTS.size(), true); table.setRowData(0, CONTACTS); table.setSize("572px", "446px"); tabPanel.add((new PainelOProjeto()).carregaPainel(), "O Projeto", false); tabPanel.selectTab(0); painelDeCaronas.add(tabPanel); return painelDeCaronas; }
From source file:simplejcqrs.gae.client.CwCellList.java
License:Apache License
/** * Initialize this example.//from w w w . j av a 2 s .co m */ 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, 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>( 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); pagerPanel.setDisplay(cellList); rangeLabelPager.setDisplay(cellList); reloadButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { ContactDatabase.get().loadContacts(); } }); final CreateDialog createDialog = new CreateDialog(); createButton.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { createDialog.showNew(); } }); ContactDatabase.get().loadContacts(); return widget; }
From source file:thothbot.parallax.demo.client.Demo.java
License:Open Source License
public void onModuleLoad() { GWT.setUncaughtExceptionHandler(new GWT.UncaughtExceptionHandler() { public void onUncaughtException(Throwable throwable) { Log.error("Uncaught exception", throwable); if (!GWT.isScript()) { String text = "Uncaught exception: "; while (throwable != null) { StackTraceElement[] stackTraceElements = throwable.getStackTrace(); text += throwable.toString() + "\n"; for (int i = 0; i < stackTraceElements.length; i++) text += " at " + stackTraceElements[i] + "\n"; throwable = throwable.getCause(); if (throwable != null) text += "Caused by: "; }//www. j a v a 2 s . co m DialogBox dialogBox = new DialogBox(true); DOM.setStyleAttribute(dialogBox.getElement(), "backgroundColor", "#ABCDEF"); text = text.replaceAll(" ", " "); dialogBox.setHTML("<pre>" + text + "</pre>"); dialogBox.center(); } } }); // Generate the source code for examples GWT.create(GenerateSourceSignal.class); // Generate the demo file GWT.create(GenerateFacebookSignal.class); resources.css().ensureInjected(); // Create the application shell. final SingleSelectionModel<ContentWidget> selectionModel = new SingleSelectionModel<ContentWidget>(); final DataModel treeModel = new DataModel(selectionModel); Set<ContentWidget> contentWidgets = treeModel.getAllContentWidgets(); index = new Index(); // Hide loading panel RootPanel.get("loading").getElement().getStyle().setVisibility(Visibility.HIDDEN); // Attach index panel RootLayoutPanel.get().add(index); index.getTabIndex().addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { displayIndex(); } }); indexWidget = new IndexWidget(treeModel); shell = new DemoShell(treeModel, index); // 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) { index.setContentWidget(shell); History.newItem("!" + selected.getContentWidgetToken(), 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().replaceFirst("!", "")); 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; } } // Display the content widget. displayContentWidget(contentWidget); //Add GA statistics trackPageview(Window.Location.getHref()); // Select the node in the tree. selectionModel.setSelected(contentWidget, true); } }; History.addValueChangeHandler(historyHandler); // Show the initial example. if (History.getToken().length() > 0) History.fireCurrentHistoryState(); // Use the first token available. else displayIndex(); // Generate a site map. createSiteMap(contentWidgets); }
From source file:uk.ac.ebi.fg.annotare2.web.gwt.user.client.view.SubmissionListViewImpl.java
License:Apache License
public SubmissionListViewImpl() { isCurator = false;// www .j av a 2s. c o m dataGrid = new CustomDataGrid<SubmissionRow>(Integer.MAX_VALUE, false); dataGrid.addColumn(new TextColumn<SubmissionRow>() { @Override public String getValue(SubmissionRow object) { return formatDate(object.getCreated()); } }, new TextHeader("Created on")); /* TODO: uncomment when we have array submissions dataGrid.addColumn(new TextColumn<SubmissionRow>() { @Override public String getValue(SubmissionRow object) { return object.getType().getTitle(); } }, new TextHeader("Type")); */ dataGrid.addColumn(new TextColumn<SubmissionRow>() { @Override public String getValue(SubmissionRow object) { return object.getAccession(); } }, new TextHeader("Accession")); dataGrid.addColumn(new TextColumn<SubmissionRow>() { @Override public String getValue(SubmissionRow object) { if (object.getType().isImported() && null == object.getTitle()) { return "UNPROCESSED IMPORTED SUBMISSION"; } return object.getTitle(); } }, new TextHeader("Title")); dataGrid.addColumn(new TextColumn<SubmissionRow>() { @Override public String getValue(SubmissionRow object) { return object.getStatus().getTitle(); } }, new TextHeader("Status")); Column<SubmissionRow, ImageResource> editIconColumn = new Column<SubmissionRow, ImageResource>( new ClickableImageResourceCell()) { @Override public ImageResource getValue(SubmissionRow object) { return resourceBundle.editIcon(); } }; editIconColumn.setFieldUpdater(new FieldUpdater<SubmissionRow, ImageResource>() { public void update(int index, SubmissionRow row, ImageResource value) { SubmissionType type = row.getType(); if (type.isImported()) { presenter.onImportSubmission(row.getId()); } else { presenter.onEditSubmission(row.getId()); } } }); dataGrid.addColumn(editIconColumn); dataGrid.setColumnWidth(0, 11, Style.Unit.EM); dataGrid.setColumnWidth(1, 11, Style.Unit.EM); dataGrid.setColumnWidth(3, 14, Style.Unit.EM); dataGrid.setColumnWidth(4, 5, Style.Unit.EM); final SingleSelectionModel<SubmissionRow> selectionModel = new SingleSelectionModel<SubmissionRow>( new ProvidesKey<SubmissionRow>() { public Object getKey(SubmissionRow item) { return item.getId(); } }); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { public void onSelectionChange(SelectionChangeEvent event) { SubmissionRow row = selectionModel.getSelectedObject(); if (null != row) { presenter.onSubmissionSelected(row.getId()); } } }); //todo create column black list dynamically dataGrid.setSelectionModel(selectionModel, DefaultSelectionEventManager.<SubmissionRow>createBlacklistManager(4)); dataGrid.addStyleName("no-cell-borders"); dataProvider = new ListDataProvider<SubmissionRow>(); dataProvider.addDataDisplay(dataGrid); Binder uiBinder = GWT.create(Binder.class); initWidget(uiBinder.createAndBindUi(this)); }