view flys-client/src/main/java/de/intevation/flys/client/client/ui/ThemeNavigationPanel.java @ 4215:c179cd02177d

Logout the current user Add code to the logout button to remove the current user from the session and to redirect the browser window to the login page. Part of flys/issue916 (Logout: "Abmelden" Knopf mit Funktion belegen)
author Björn Ricks <bjoern.ricks@intevation.de>
date Tue, 23 Oct 2012 09:59:16 +0200
parents f43d06d6a4a2
children f3325079dacc
line wrap: on
line source
package de.intevation.flys.client.client.ui;

import java.util.ArrayList;
import java.util.List;

import com.google.gwt.core.client.GWT;

import com.smartgwt.client.widgets.Canvas;
import com.smartgwt.client.widgets.ImgButton;
import com.smartgwt.client.widgets.events.ClickEvent;
import com.smartgwt.client.widgets.events.ClickHandler;
import com.smartgwt.client.widgets.layout.HLayout;

import de.intevation.flys.client.client.FLYSConstants;
import de.intevation.flys.client.client.event.OnMoveEvent;
import de.intevation.flys.client.client.event.OnMoveHandler;


/**
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class ThemeNavigationPanel extends Canvas {

    public static final int PANEL_MARGIN  = 5;
    public static final int BUTTON_HEIGHT = 25;
    public static final int BUTTON_MARGIN = 5;


    protected FLYSConstants MSG = GWT.create(FLYSConstants.class);


    protected List<OnMoveHandler> handlers;


    public ThemeNavigationPanel() {
        this.handlers = new ArrayList<OnMoveHandler>();

        setWidth100();
        setHeight(BUTTON_HEIGHT);
        setMargin(PANEL_MARGIN);

        HLayout layout = new HLayout();
        layout.setWidth100();
        layout.setHeight(BUTTON_HEIGHT);
        layout.setMembersMargin(BUTTON_MARGIN);

        Canvas cu = createButton(MSG.theme_top(), OnMoveEvent.TOP);
        Canvas u  = createButton(MSG.theme_up(), OnMoveEvent.UP);
        Canvas d  = createButton(MSG.theme_down(), OnMoveEvent.DOWN);
        Canvas cd = createButton(MSG.theme_bottom(), OnMoveEvent.BOTTOM);

        layout.addMember(cu);
        layout.addMember(u);
        layout.addMember(d);
        layout.addMember(cd);

        addChild(layout);
    }


    protected Canvas createButton(final String title, final int moveType) {
        String url = GWT.getHostPageBaseURL() + title;

        ImgButton b = new ImgButton();
        b.setSrc(url);
        b.setHeight(BUTTON_HEIGHT);
        b.setWidth(40);
        b.setIconHeight(BUTTON_HEIGHT-10);
        b.setShowDown(false);
        b.setShowRollOver(false);
        b.setShowDisabled(false);
        b.setShowDisabledIcon(true);
        b.setShowDownIcon(false);
        b.setShowFocusedIcon(false);
        b.setBackgroundColor("f2f2f2");
        b.setBorder("1px solid #A6ABB4");

        b.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                fireOnMoveEvent(moveType);
            }
        });

        return b;
    }


    protected void addOnMoveHandler(OnMoveHandler handler) {
        if (handler != null) {
            handlers.add(handler);
        }
    }


    protected void fireOnMoveEvent(int type) {
        OnMoveEvent event = new OnMoveEvent(type);

        for (OnMoveHandler handler: handlers) {
            handler.onMove(event);
        }
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org