List of usage examples for com.google.gwt.place.shared PlaceController goTo
public void goTo(Place newPlace)
From source file:com.goodow.web.dev.client.ui.TreeNodeListView.java
License:Apache License
@Inject TreeNodeListView(final TreeNodeFactory f, final SingleSelectionModel<TreeNodeProxy> selectionModel, final PlaceController placeController, final Provider<BasePlace> place, final TreeNodeDataProvider dtatProvider) { this.placeController = placeController; this.place = place; this.dtatProvider = dtatProvider; this.f = f;//from w ww . j av a 2s . c o m grid = new DataGrid<TreeNodeProxy>(NUM_ROWS, GWT.<TableResources>create(TableResources.class)); grid.setSelectionModel(selectionModel); grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED); PathCol pathCol = new PathCol(); // ????? pathCol.setName("path"); pathCol.setSortable(true); grid.addColumn(pathCol, "Path"); grid.setColumnWidth(pathCol, "40ex"); NameCol nameCol = new NameCol(); nameCol.setName("name"); nameCol.setSortable(true); grid.addColumn(nameCol, "Name"); grid.setColumnWidth(nameCol, "25ex"); grid.addColumnSortHandler(new ColumnSortEvent.AsyncHandler(grid)); grid.setRowCount(NUM_ROWS, false); dtatProvider.addDataDisplay(grid); pager.setDisplay(grid); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override public void onSelectionChange(final SelectionChangeEvent event) { TreeNodeProxy proxy = selectionModel.getSelectedObject(); BasePlace newPlace = place.get().setParameter(state.getName(), f.getHistoryToken(proxy.stableId())); placeController.goTo(newPlace); } }); initWidget(binder.createAndBindUi(this)); }
From source file:com.goodow.web.ui.client.nav.TagsUi.java
License:Apache License
@Inject private TagsUi(final NavTreeViewModel treeViewModel, final SingleSelectionModel<com.goodow.web.mvp.shared.tree.TreeNodeProxy> selectionModel, final Resources resources, final PlaceController placeController, final Provider<TreeNodePlace> placeProvider) { this.placeController = placeController; logger.finest("init start"); this.treeViewModel = treeViewModel; this.selectionModel = selectionModel; this.resources = resources; // Listen for selection. We need to add this handler before the CellBrowser // adds its own handler. this.selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override/*from ww w. j ava2 s . com*/ public void onSelectionChange(final SelectionChangeEvent event) { com.goodow.web.mvp.shared.tree.TreeNodeProxy lastSelected = selectionModel.getSelectedObject(); TreeNodePlace place = placeProvider.get().setPath(lastSelected.getPath()); if (!place.equals(placeController.getWhere())) { placeController.goTo(place); } } }); initWidget(layout); if (LogConfiguration.loggingIsEnabled()) { logger.log(Level.FINEST, "init end"); } }
From source file:com.goodow.web.ui.client.nav.TopNavUi.java
License:Apache License
@Inject TopNavUi(final TreeNodeCell cell, final TopTreeNodeDataProvider dataProvider, final Provider<TreeNodePlace> placeProvider, final PlaceController placeController) { logger.finest("init start"); this.dataProvider = dataProvider; this.placeProvider = placeProvider; this.placeController = placeController; list = new CellList<TreeNodeProxy>(cell); list.setSelectionModel(selectionModel); selectionModel.addSelectionChangeHandler(new SelectionChangeEvent.Handler() { @Override/* w w w . ja va2 s. co m*/ public void onSelectionChange(final SelectionChangeEvent event) { TreeNodeProxy node = selectionModel.getSelectedObject(); if (fireEvent) { TreeNodePlace place = placeProvider.get().setPath(node.getPath()); placeController.goTo(place); } else { fireEvent = true; } } }); initWidget(list); dataProvider.addDataDisplay(list); logger.finest("init end"); }
From source file:com.google.gwt.sample.mobilewebapp.client.desktop.MobileWebAppShellDesktop.java
License:Apache License
/** * Construct a new {@link MobileWebAppShellDesktop}. *//*from w w w . ja v a 2 s.c o m*/ 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.retech.reader.web.client.home.TopBar.java
License:Apache License
@Inject public TopBar(final PlaceController placeController, final Provider<BasePlace> places) { WaveToolBar toolbar = this.addWaveToolBar(); ToolBarClickButton category = toolbar.addClickButton(); category.setText(CategoryProxy.CATEGORY_NAME); category.setVisualElement(createIcon(res.bookstore())); ToolBarClickButton myDownload = toolbar.addClickButton(); myDownload.setText(IssueProxy.ISSUE_DOWN_NAME); myDownload.setVisualElement(createIcon(res.bookshelf())); ToolBarClickButton libraryView = toolbar.addClickButton(); libraryView.setText(IssueProxy.MY_ISSUES_NAME); libraryView.setVisualElement(createIcon(res.collect())); myDownload.addClickHandler(new ClickHandler() { @Override/*w w w. j a va2s. co m*/ public void onClick(final ClickEvent event) { placeController.goTo(places.get().setPath(MyDownLoadPanel.class.getName())); } }); libraryView.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { placeController.goTo(places.get().setPath(LibraryView.class.getName())); } }); category.addClickHandler(new ClickHandler() { @Override public void onClick(final ClickEvent event) { placeController.goTo(places.get().setPath(CategoryListEditor.class.getName())); } }); }
From source file:com.retech.reader.web.client.labs.Labs.java
License:Apache License
@Inject Labs(final CellList.Resources resource, final PlaceController placeController, final Provider<BasePlace> base) { this.setWaveContent(binder.createAndBindUi(this)); setColor.setChangeElm(simplePanel.getElement()); minimize.setIconElement(//w ww. ja v a2s . c o m AbstractImagePrototype.create(WaveTitleResources.image().waveTitleMinimize()).createElement()); // add Data List<LabsIconDecorator> list = listDataProvider.getList(); LabsIconDecorator touch = new LabsIconDecorator(bunder.laboratory(), "", WaveTest.class); list.add(touch); LabsIconDecorator flip = new LabsIconDecorator(bunder.laboratory(), "3D", BookFlip.class); list.add(flip); LabsIconDecorator contact = new LabsIconDecorator(bunder.laboratory(), "??", ContactPanel.class); list.add(contact); LabsIconDecorator treeTest = new LabsIconDecorator(bunder.laboratory(), "TreeTest", TreeTest.class); list.add(treeTest); LabsIconDecorator search = new LabsIconDecorator(bunder.laboratory(), "?", SearchPanel.class); list.add(search); LabsIconDecorator blipTest = new LabsIconDecorator(bunder.laboratory(), "BlipTest", BlipTest.class); list.add(blipTest); LabsIconDecorator blipTree = new LabsIconDecorator(bunder.laboratory(), "NestedBlipTest", NestedBlipTest.class); list.add(blipTree); LabsIconDecorator settingsView = new LabsIconDecorator(bunder.laboratory(), "", SettingsView.class); list.add(settingsView); LabsIconDecorator contactPanel = new LabsIconDecorator(bunder.laboratory(), "", ContactPanel.class); list.add(contactPanel); server.add( new Anchor("Android", "https://build.phonegap.com/apps/95095/download/android", "_blank")); server.add( new Anchor("iOS", "https://build.phonegap.com/apps/95095/download/ios", "_blank")); server.add(new Anchor("Google Play?", "https://play.google.com/store/apps/details?id=com.goodow.web.mobile", "_blank")); server.add(new Anchor("SCM - Subversion", SERVER_URL + "/svn/retech", "_blank")); server.add(new Anchor("Files", SERVER_URL + "/files", "_blank")); server.add(new Anchor("Document", SERVER_URL + "/svn/retech/document", "_blank")); server.add(new Anchor("CI - Hudson", SERVER_URL + ":8080", "_blank")); server.add(new Anchor("Repository - Nexus", SERVER_URL + ":8081/nexus", "_blank")); // add cell List<HasCell<LabsIconDecorator, ?>> hasCells = new ArrayList<HasCell<LabsIconDecorator, ?>>(); hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() { LabsIconDecoratorCell cell = new LabsIconDecoratorCell( new LabsIconDecoratorCell.Delegate<LabsIconDecorator>() { @Override public void execute(final LabsIconDecorator object) { placeController.goTo(base.get().setPath(object.getClassName().getName())); } }); @Override public Cell<LabsIconDecorator> getCell() { return cell; } @Override public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() { return null; } @Override public LabsIconDecorator getValue(final LabsIconDecorator object) { return object; } }); hasCells.add(new HasCell<LabsIconDecorator, LabsIconDecorator>() { private TrangleButtonCell<LabsIconDecorator> tbc = new TrangleButtonCell<LabsIconDecorator>(); @Override public Cell<LabsIconDecorator> getCell() { return tbc; } @Override public FieldUpdater<LabsIconDecorator, LabsIconDecorator> getFieldUpdater() { return null; } @Override public LabsIconDecorator getValue(final LabsIconDecorator object) { return object; } }); compositeCell = new CompositeCell<LabsIconDecorator>(hasCells) { @Override public void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value, final SafeHtmlBuilder sb) { super.render(context, value, sb); } @Override protected Element getContainerElement(final Element parent) { return parent; } @Override protected <X> void render(final com.google.gwt.cell.client.Cell.Context context, final LabsIconDecorator value, final SafeHtmlBuilder sb, final HasCell<LabsIconDecorator, X> hasCell) { Cell<X> cell = hasCell.getCell(); cell.render(context, hasCell.getValue(value), sb); } }; // add cellList cellList = new CellList<LabsIconDecorator>(compositeCell, resource); // add cellPreviewHanler cellList.addCellPreviewHandler(new CellPreviewEvent.Handler<LabsIconDecorator>() { @Override public void onCellPreview(final CellPreviewEvent<LabsIconDecorator> event) { NativeEvent nativeEvent = event.getNativeEvent(); boolean isClick = nativeEvent.getType().equals(BrowserEvents.CLICK); if (isClick) { Element clickelm = cellList.getRowElement(event.getIndex()); Element eventTarget = Element.as(nativeEvent.getEventTarget()); if (clickelm.getFirstChildElement() == eventTarget) { if (Labs.this.lastElm == null) { Labs.this.lastElm = clickelm; } if (Labs.this.lastElm != clickelm) { Labs.this.lastElm.removeClassName(LabsResources.css().cellListSelectionItem()); clickelm.addClassName(LabsResources.css().cellListSelectionItem()); Labs.this.lastElm = clickelm; } else if (Labs.this.lastElm == clickelm) { clickelm.addClassName(LabsResources.css().cellListSelectionItem()); } } } } }); simplePanel.add(cellList); }
From source file:cz.cas.lib.proarc.webapp.client.Editor.java
License:Open Source License
private TreeGrid createMenu() { final TreeGrid menu = new TreeGrid(); menu.setAutoFitData(Autofit.VERTICAL); menu.setLeaveScrollbarGap(false);//from w w w . j a v a 2 s .c o m menu.setShowHeader(false); menu.setShowOpener(false); menu.setShowOpenIcons(false); menu.setCanCollapseGroup(false); menu.setSelectionType(SelectionStyle.NONE); menu.addFolderClosedHandler(new FolderClosedHandler() { @Override public void onFolderClosed(FolderClosedEvent event) { event.cancel(); } }); menu.addLeafClickHandler(new LeafClickHandler() { @Override public void onLeafClick(LeafClickEvent event) { for (Canvas parent = menu.getParentCanvas(); parent != null; parent = parent.getParentCanvas()) { if (GLOBAL_MENU_CONTAINER_ID.equals(parent.getID())) { parent.hide(); break; } } ClientUtils.fine(LOG, "menu.getSelectedPaths: %s\nmenu.getSelectedRecord: %s", menu.getSelectedPaths(), menu.getSelectedRecord()); String name = event.getLeaf().getName(); final PlaceController placeController = getEditorWorkFlow().getPlaceController(); Object placeObj = event.getLeaf().getAttributeAsObject(PLACE_ATTRIBUTE); if (placeObj instanceof Place) { placeController.goTo((Place) placeObj); return; } if ("Console".equals(name)) { SC.showConsole(); } else if ("About".equals(name)) { AboutWindow.getInstance(i18n).show(); } else { Layout placesContainer = getDisplay(); placesContainer.removeMembers(placesContainer.getMembers()); } } }); return menu; }
From source file:eu.cloud4soa.frontend.dashboard.client.Cloud4SOADashboard.java
License:Open Source License
private void manageActivitiesAndPlaces() { final PlaceController placeController = clientFactory.getPlaceController(); // Start ActivityManager for the main widget with our ActivityMapper ActivityMapper activityMapper = new Cloud4SOAUIActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(appWidget); // Start PlaceHistoryHandler with our PlaceHistoryMapper Cloud4SOAUIPlaceHistoryMapper historyMapper = GWT.create(Cloud4SOAUIPlaceHistoryMapper.class); final PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, defaultPlace); // hack the css path in order to make it relative to the module path // (ThemeManager should do this, but it doesn't) Theme c4sTheme = C4sTheme.C4S_THEME; String c4sThemeFile = c4sTheme.getFile(); c4sTheme.set("file", GWT.getModuleBaseURL() + "/" + c4sThemeFile); ThemeManager.register(c4sTheme);/* www . j av a 2 s . c om*/ GXT.setDefaultTheme(c4sTheme, true); //Style for main panel // appWidget.addStyleName("mainPanel"); RootPanel.get().add(appWidget); registerNavigationEventHandler(placeController); // check if the user session is alive in the server UserManagementAndSecurityServiceAsync uma = GWT.create(UserManagementAndSecurityService.class); uma.getC4sMode(new AsyncCallback<String>() { @Override public void onFailure(Throwable caught) { // nothing to do } @Override public void onSuccess(String result) { setC4sMode(result); } }); uma.currentUser(new AsyncCallback<UserModel>() { @Override public void onFailure(Throwable caught) { // error checking the user placeController.goTo(defaultPlace); } @Override public void onSuccess(UserModel result) { if (result == null) { // not logged in placeController.goTo(defaultPlace); } else { // logged in clientFactory.setCurrentUser(result); // Go to the place represented on URL else default place historyHandler.handleCurrentHistory(); } } }); }
From source file:eu.cloud4soa.frontend.dashboard.client.Cloud4SOADashboard.java
License:Open Source License
/** * Navigation event handler cannot be managed by the main activity, since this could lead to event loop while * the main activity is created and the same event handlers get registered over and over. *//*from ww w . j a va2s. com*/ private void registerNavigationEventHandler(final PlaceController placeController) { eventBus.addHandler(LoginEvent.getType(), new LoginHandler() { @Override public void setLoginHandlerRegistration(HandlerRegistration hr) { // nothing to do } @Override public void onLogin(LoginEvent e) { if (e.isLoginSuccessful()) { UserManagementAndSecurityServiceAsync userService = GWT .create(UserManagementAndSecurityService.class); userService.currentUser(new AsyncCallback<UserModel>() { @Override public void onFailure(Throwable caught) { // something wrong happened MessageBox.alert("Ops.. something went wrong", caught.toString(), new Listener<MessageBoxEvent>() { @Override public void handleEvent(MessageBoxEvent messageBoxEvent) { } }); } @Override public void onSuccess(UserModel userModel) { clientFactory.setCurrentUser(userModel); if (userModel.isDeveloper()) { // check if the developer has some application profile ModelManagerServiceAsync modelManagerService = GWT .create(ModelManagerService.class); modelManagerService.retrieveCurrentUserApplicationProfiles( new BasePagingLoadConfig(), new AsyncCallback<PagingLoadResult<ApplicationModel>>() { @Override public void onFailure(Throwable caught) { // something wrong happened placeController.goTo(new SearchPlace(Strings.EMPTY)); } @Override public void onSuccess(PagingLoadResult<ApplicationModel> result) { if (result.getTotalLength() == 0) { // no application profile found. Go creating one in the application editor place placeController.goTo(new ApplicationEditorPlace(Strings.EMPTY)); } else { // application profiles are already there. Go searching in the search place placeController.goTo(new SearchPlace(Strings.EMPTY)); } } }); } else { // logged in user is a PaaS provider. Go to the offer editor placeController.goTo(new OfferEditorPlace(Strings.EMPTY)); } } }); } } }); eventBus.addHandler(UserLoggedOutEvent.TYPE, new UserLoggedOutEvent.Handler() { @Override public void onUserLogout(UserLoggedOutEvent event) { placeController.goTo(new WelcomePlace()); } }); eventBus.addHandler(UserLogInCancelledEvent.TYPE, new UserLogInCancelledEvent.Handler() { @Override public void onLoginCancelled(UserLogInCancelledEvent event) { // when the user cancel the login, go back to the welcome page placeController.goTo(new WelcomePlace()); } }); eventBus.addHandler(CurrentUserProfileUpdatedEvent.TYPE, new CurrentUserProfileUpdatedEvent.Handler() { @Override public void onUserProfileUpdated(CurrentUserProfileUpdatedEvent event) { if (clientFactory.getCurrentUser().isDeveloper()) placeController.goTo(new SearchPlace(Strings.EMPTY)); else placeController.goTo(new OfferEditorPlace(Strings.EMPTY)); } }); eventBus.addHandler(RPCFailureOccurredEvent.TYPE, new RPCFailureOccurredEvent.Handler() { @Override public void onRPCFailure(RPCFailureOccurredEvent event) { if (event.getCaught() instanceof StatusCodeException && ((StatusCodeException) event.getCaught()).getStatusCode() == 0) DialogHelper.showErrorDialog( "You might have lost connectivity with the Cloud4SOA server. Please, try reloading the page."); else DialogHelper.showErrorDialog(event.getCaught().getMessage()); } }); }
From source file:nl.sense_os.commonsense.login.client.LoginEntryPoint.java
License:Open Source License
/** * Starts the application. Initializes the views and starts the default activity. *//*from ww w .j a v a2s .c o m*/ private void startApplication() { // Create ClientFactory using deferred binding LoginClientFactory clientFactory = GWT.create(LoginClientFactory.class); EventBus eventBus = clientFactory.getEventBus(); PlaceController placeController = clientFactory.getPlaceController(); // prepare UI LoginApplicationView main = clientFactory.getMainView(); SimplePanel appWidget = main.getActivityPanel(); // Start ActivityManager for the main widget with our ActivityMapper ActivityMapper activityMapper = new LoginActivityMapper(clientFactory); ActivityManager activityManager = new ActivityManager(activityMapper, eventBus); activityManager.setDisplay(appWidget); // Start PlaceHistoryHandler with our PlaceHistoryMapper LoginPlaceHistoryMapper historyMapper = GWT.create(LoginPlaceHistoryMapper.class); PlaceHistoryHandler historyHandler = new PlaceHistoryHandler(historyMapper); historyHandler.register(placeController, eventBus, new LoginPlace()); RootLayoutPanel.get().add(main); String errorMessage = getErrorParameter(); String newPasswordToken = getTokenParameter(); if (null != errorMessage) { if (errorMessage.contains("e-mail address:") && errorMessage.contains("is already registered")) { // parse email address int startIndex = errorMessage.indexOf("e-mail address: ") + "e-mail address: ".length(); int endIndex = errorMessage.indexOf(" is already registered"); String email = errorMessage.substring(startIndex, endIndex); // TODO start google connect activity placeController.goTo(new OpenIdConnectPlace(email)); } else { // handle error (probably from failed OpenID attempt) placeController.goTo(new LoginErrorPlace(errorMessage)); } } else if (null != newPasswordToken) { // clear any session ID SessionManager.removeSessionId(); // handle error (probably from failed OpenID attempt) placeController.goTo(new NewPasswordPlace(newPasswordToken)); } else { // Goes to place represented on URL or default place historyHandler.handleCurrentHistory(); } }