mirror of
https://github.com/eclipse-sailing-analytics/sailing-analytics.git
synced 2026-10-28 14:57:12 +00:00
Header selection is now based on the active Place
This commit is contained in:
1 parent
6297fd2e40
commit
6167498a38
7 files changed
+135
-5
No files matched your search
@@ -11,6 +11,7 @@ import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sap.sse.gwt.client.AbstractEntryPoint;
|
||||
import com.sap.sse.gwt.client.StringMessages;
|
||||
import com.sap.sse.gwt.client.mvp.impl.ActivityMapperRegistry;
|
||||
import com.sap.sse.gwt.client.mvp.impl.CustomActivityManager;
|
||||
|
||||
/**
|
||||
* Subclasses implement their {@link EntryPoint#onModuleLoad()} by delegating to
|
||||
@@ -46,7 +47,7 @@ public abstract class AbstractMvpEntryPoint<S extends StringMessages> extends Ab
|
||||
activityMapperRegistry.addActivityMapper(activityMapper);
|
||||
}
|
||||
EventBus eventBus = clientFactory.getEventBus();
|
||||
ActivityManager activityManager = new ActivityManager(activityMapperRegistry, eventBus);
|
||||
ActivityManager activityManager = new CustomActivityManager(activityMapperRegistry, eventBus);
|
||||
activityManager.setDisplay(clientFactory.getContent());
|
||||
|
||||
// Start PlaceHistoryHandler with our PlaceHistoryMapper
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* Copyright 2010 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package com.sap.sse.gwt.client.mvp;
|
||||
|
||||
import com.google.gwt.event.shared.EventHandler;
|
||||
import com.google.gwt.event.shared.GwtEvent;
|
||||
import com.google.gwt.place.shared.Place;
|
||||
|
||||
/**
|
||||
* Event thrown after the place changed.
|
||||
*/
|
||||
public class PlaceChangedEvent extends GwtEvent<PlaceChangedEvent.Handler> {
|
||||
|
||||
/**
|
||||
* Implemented by handlers of PlaceChangedEvent.
|
||||
*/
|
||||
public interface Handler extends EventHandler {
|
||||
/**
|
||||
* Called when a {@link PlaceChangedEvent} is fired.
|
||||
*
|
||||
* @param event the {@link PlaceChangedEvent}
|
||||
*/
|
||||
void onPlaceChanged(PlaceChangedEvent event);
|
||||
}
|
||||
|
||||
/**
|
||||
* A singleton instance of Type<Handler>.
|
||||
*/
|
||||
public static final Type<Handler> TYPE = new Type<Handler>();
|
||||
|
||||
private final Place newPlace;
|
||||
|
||||
/**
|
||||
* Constructs a PlaceChangedEvent for the given {@link Place}.
|
||||
*
|
||||
* @param newPlace a {@link Place} instance
|
||||
*/
|
||||
public PlaceChangedEvent(Place newPlace) {
|
||||
this.newPlace = newPlace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Type<Handler> getAssociatedType() {
|
||||
return TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the new {@link Place}.
|
||||
*
|
||||
* @return a {@link Place} instance
|
||||
*/
|
||||
public Place getNewPlace() {
|
||||
return newPlace;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void dispatch(Handler handler) {
|
||||
handler.onPlaceChanged(this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.sap.sse.gwt.client.mvp.impl;
|
||||
|
||||
import com.google.gwt.activity.shared.ActivityManager;
|
||||
import com.google.gwt.activity.shared.ActivityMapper;
|
||||
import com.google.gwt.place.shared.PlaceChangeEvent;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sap.sse.gwt.client.mvp.PlaceChangedEvent;
|
||||
|
||||
public class CustomActivityManager extends ActivityManager {
|
||||
|
||||
private EventBus eventBus;
|
||||
|
||||
public CustomActivityManager(ActivityMapper mapper, EventBus eventBus) {
|
||||
super(mapper, eventBus);
|
||||
this.eventBus = eventBus;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlaceChange(PlaceChangeEvent event) {
|
||||
super.onPlaceChange(event);
|
||||
eventBus.fireEvent(new PlaceChangedEvent(event.getNewPlace()));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user