All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.mdl.tree.TreeWMClient Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

// @(#) $Id: TreeWMClient.java 7142 2011-01-27 15:17:25Z hoenninger $
package at.spardat.xma.mdl.tree;

import at.spardat.xma.mdl.ModelChangeEvent;
import at.spardat.xma.mdl.NewModelEvent;
import at.spardat.xma.mdl.UIDelegateClient;
import at.spardat.xma.mdl.UIDelegateFactoryClient;
import at.spardat.xma.mdl.WModel;
import at.spardat.xma.page.Page;
import at.spardat.xma.page.PageClient;

/**
 * The representation of a TreeWM at the client side of XMA.
 *
 * @author YSD, 04.05.2003 12:37:53
 */
public class TreeWMClient extends TreeWM  implements ITreeWMClient {

    /**
     * The UI delete of this tree model
     */
    private TreeUIDelegateClient          ui_;


    /**
     * Constructor
     *
     * @param id id of the widget model within the page
     * @param pm the page that this widget model is part of
     * @param style bit or combination of style constants beginning with S_
     *         in this class or a superclass.
     */
    public TreeWMClient (short id, Page pm, int style) {
        super (id, pm, style);
        ui_ = (TreeUIDelegateClient) UIDelegateFactoryClient.getInstance((PageClient)pm).newUIDelegateFor(this);
    }

    /**
     * @see at.spardat.xma.mdl.WModel#handle(at.spardat.xma.mdl.ModelChangeEvent)
     */
    public boolean handle (ModelChangeEvent event) {
        boolean success = super.handle(event);
        if (success && !event.isFromUI()) {
            // notify the UIDelegate of the modification
            ui_.handleModelChangeEvent(event);
        }
        return success;
    }

    /**
     * @see at.spardat.xma.mdl.tree.ITreeWMClient#setExpanded(int, boolean)
     */
    public void setExpanded (int depth, boolean expanded) {
        if (!ui_.isUIAttached()) return;
        if (depth <= 0) return;
        TreeNode[] roots = getRoots();
        for (int i=0; i< roots.length; i++) {
            setExpandedSubTree (roots[i], depth, expanded);
        }
    }

    /**
     * Sets the expansion state of the top depth levels
     * in the subtree rooted at n.
     */
    private void setExpandedSubTree (TreeNode n, int depth, boolean expanded) {
        if (depth <= 0) return;
        // set the expansion status of this node
        ui_.setExpanded (n, expanded, false);
        // of the nodes in the subtree
        if (depth > 1) {
            TreeNode[] childs = n.getChilds();
            for (int i=0; iS_
         */
        public NewTreeWMClientEvent(int style) {
            super(style);
        }

        // see at.spardat.xma.mdl.NewModelEvent.createModel()
        public WModel createModel(short id,Page page) {
            return new TreeWMClient(id,page,style);
        }
    }

    // see at.sparda.xma.mdl.WModel.createNewModelEvent()
    public NewModelEvent createNewModelEvent() {
        int style = isMultiSelect()?S_MULTI_SELECT:S_NULL;
        return new NewTreeWMClientEvent(style);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy