view flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java @ 4198:1cdbd8a0c994

Added two new tables ClickableQDTable and ClickableWTable and made Ws and Qs clickable in historical discharge calculation. The new tables define listener interfaces (clicked lower or upper icon) to listen to user clicks. In addition to this, there is an enum ClickMode with NONE, SINGLE and RANGE options, which allows to specifiy, which icons are displayed in the tables. NONE means no icon for user clicks, SINGLE has 1 icon, RANGE 2 icons for lower and upper.
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Mon, 22 Oct 2012 13:31:25 +0200
parents 11c589d68f13
children c0a275c581fb
line wrap: on
line source
package de.intevation.flys.client.client.ui;

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

import com.smartgwt.client.widgets.Canvas;

import java.util.HashMap;
import java.util.Map;


/**
 * "Workspace" canvas showing the CollectionViews (subwindows).
 * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
 */
public class FLYSWorkspace extends Canvas {

    /** The maximal number of windows that fit into the browser view when an
     * offset is used to move windows initially.*/
    public static int MAX_WINDOWS = 10;

    /** The number of pixels used to move windows.*/
    public static int WINDOW_OFFSET = 20;


    /** A map that contains the open CollectionViews. */
    protected Map<String, CollectionView> views;


    /**
     * The default constructor creates an empty FLYSWorkspace with no
     * CollectionViews opened.
     */
    public FLYSWorkspace() {
        views = new HashMap<String, CollectionView>();

        setWidth("100%");
        setHeight("100%");
    }


    /**
     * This method adds a new CollectionView to this workspace and stores a
     * reference in {@link views}.
     *
     * @param collectionView A new CollectionView.
     */
    public void addView(String uuid, CollectionView collectionView) {
        collectionView.moveTo(0, 0);
        collectionView.setMaximized(true);

        views.put(uuid, collectionView);
        addChild(collectionView);
    }


    public void removeProject(String uuid) {
        views.remove(uuid);
    }


    public void bringUp(String uuid) {
        CollectionView view = views.get(uuid);

        if (view != null) {
            view.show();
            view.restore();
        }
        else {
            GWT.log("FLYSWorkspace.bringUp() failed!");
        }
    }


    /**
     * Removes a project from workspace (view) and clears its reference from
     * hash map.
     *
     * @param uuid The project's uuid.
     */
    public void destroyProject(String uuid) {
        CollectionView project = views.get(uuid);

        if (project != null) {
            removeProject(uuid);
            project.destroy();
        }
    }


    public void updateTitle(String uuid, String title) {
        CollectionView view = views.get(uuid);
        view.setTitle(title);
    }


    public boolean hasView(String uuid) {
        if(views.get(uuid) != null) {
            return true;
        }
        return false;
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org