Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**
* Copyright 2011 ArcBees 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.gwtplatform.mvp.client;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.google.gwt.event.shared.EventHandler;
import com.google.gwt.event.shared.GwtEvent;
import com.google.gwt.event.shared.GwtEvent.Type;
import com.google.gwt.event.shared.HasHandlers;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.gwt.user.client.ui.Widget;
import com.google.web.bindery.event.shared.EventBus;
import com.google.web.bindery.event.shared.HandlerRegistration;
import com.gwtplatform.mvp.client.proxy.ResetPresentersEvent;
/**
* A presenter that does not have to be a singleton. Pages from your
* application will usually be singletons and extend the {@link Presenter} class.
*
* Choosing between a {@link Presenter} and {@link PresenterWidget} is a design decision that
* requires some thought. For example, a {@link PresenterWidget} is useful when
* you need a custom widget with extensive logic. For example, a chat box that can be instantiated
* multiple times and needs to communicate with the server would be a good candidate for
* a {@link PresenterWidget}. The drawback of a {@link PresenterWidget} is that it is managed by its
* parent presenter, which increases coupling. Therefore, you should use a {@link Presenter} when
* the parent is not expected to know its child. Moreover, only {@link Presenter} can be attached
* to name tokens in order to support browser history.
*
* {@link PresenterWidget}s and {@link Presenter}s are organized in a hierarchy.
* Internally, parent presenters have links to their currently attached children presenters. A
* parent {@link Presenter} can contain either {@link Presenter}s or {@link PresenterWidget}s,
* but a {@link PresenterWidget} can only contain {@link PresenterWidget}s.
*
* To reveal a {@link PresenterWidget} you should insert it within a {@link HasSlots slot} of its
* containing presenter using one of the following methods:
*
* Revealing a {@link Presenter} is done differently, refer to the class documentation for more details.
*
* To hide a {@link PresenterWidget} or a {@link Presenter} you can use {@link #setInSlot} to place
* another presenter in the same slot, or you can call one of the following methods:
*
{@link PopupView#hide()} if the presenter is a popup or a dialog box.
*
* Hide a {@link Presenter} using these methods, but
*
* A presenter has a number of lifecycle methods that you can hook on to:
*
*
{@link #onBind()}
*
{@link #onReveal()}
*
{@link #onReset()}
*
{@link #onHide()}
*
{@link #onUnbind()}
*
* Revealing or hiding a {@link PresenterWidget} triggers an internal chain of events that result in
* these lifecycle methods being called. For an example, here is what happens following
* a call to {@link #setInSlot(Object, PresenterWidget)}:
*
*
If a presenter already occupies this slot it is removed.
*
If the presenter owning the slot is currently visible then
* {@link #onHide()} is called on the removed presenter and, recursively,
* on its children (bottom-up: first the children, then the parent)
*
If the parent is not visible and is a {@link Presenter}, it asks to be
* set in one of its parent slot by firing a
* {@link com.gwtplatform.mvp.client.proxy.RevealContentEvent RevealContentEvent}.
* For more details, see the documentation for {@link Presenter}.
*
*
If, at this point, the presenter owning the slot is not visible, then the
* chain stops. Otherwise, {@link #onReveal()} is called on the {@link PresenterWidget} that
* was just added.
*
{@link #onReveal()} is called recursively on that presenter's children
* (top-down: first the parent, then the children).
*
If {@link #setInSlot(Object, PresenterWidget, boolean)} was called with {@code false}
* as the third parameter then the process stops. Otherwise, {@link #onReset()} is
* called on all the currently visible presenters (top-down: first the parent, then
* the children).
*
*
* @param The {@link View} type.
*/
public abstract class PresenterWidget extends
HandlerContainerImpl implements HasHandlers, HasSlots, HasPopupSlot, IsWidget {
private static class HandlerInformation {
private Type type;
private H eventHandler;
private HandlerInformation(Type type, H eventHandler) {
this.type = type;
this.eventHandler = eventHandler;
}
}
private final EventBus eventBus;
private final V view;
boolean visible;
/**
* This map makes it possible to keep a list of all the active children in
* every slot managed by this {@link PresenterWidget}. A slot is identified by an
* opaque object. A single slot can have many children.
*/
private final Map