view flys-client/src/main/java/de/intevation/flys/client/client/ui/FLYSWorkspace.java @ 279:e763d8efd42f

ISSUE-34 Limit the windows which are moved to the right lower corner to 10. flys-client/trunk@1906 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Thu, 12 May 2011 07:08:27 +0000
parents 905daf30221a
children 92c200887b20
line wrap: on
line source
package de.intevation.flys.client.client.ui;

import com.smartgwt.client.widgets.Canvas;

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


/**
 * @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 List<CollectionView> views;


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


    /**
     * This method adds a new CollectionView to this workspace and stores a
     * reference in {@link views}.
     *
     * @param collectionView A new CollectionView.
     */
    public void addView(CollectionView collectionView) {
        int num    = views != null ? views.size() : 0;
        int factor = num % MAX_WINDOWS;

        collectionView.moveTo(factor * WINDOW_OFFSET, factor * WINDOW_OFFSET);

        views.add(collectionView);
        addChild(collectionView);
    }
}
// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :

http://dive4elements.wald.intevation.org