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

at.spardat.xma.mdl.list.ListDomWMClient Maven / Gradle / Ivy

The 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: ListDomWMClient.java 7142 2011-01-27 15:17:25Z hoenninger $
package at.spardat.xma.mdl.list;

import at.spardat.xma.mdl.ModelChangeEvent;
import at.spardat.xma.mdl.NewModelEvent;
import at.spardat.xma.mdl.Notification;
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;

/**
 * Implementation of IListDomWMClient.
 *
 * @author YSD, 20.04.2003 19:15:19
 */
public class ListDomWMClient extends ListDomWM implements IListDomWMClient {

    /**
     * The Page this WidgetModel belongs to. Never null.
     */
    private PageClient                          pageModel_;

    /**
     * The associated UI delegate. Never null.
     */
    private ListDomUIDelegateClient             ui_;

    /**
     * One of the SHOW_-constants.
     */
    private int                                 showStyle_ = SHOW_LONG;

    /**
     * One of the ORDER_-constants.
     */
    private int                                 orderStyle_ = ORDER_LONG;

    /**
     * Indicates that a value must be provided on a UI
     */
    private boolean                             mandatory_;

    /**
     * Indicates that long values of the selected entry should be shown as tooltip.
     */
    private boolean                             isShowLongValueAsTooltips_ = false;




    /**
     * Constructs with a provided data source.
     *
     * @param id a numeric id which identifies the WidgetModel within its Page.
     * @param pm reference to the enclosing Page
     * @param dataSource specifies a tabular data source
     * @param style one of the SHOW_-constants or MANDATORY defined in {@link IListDomWMClient}.
     * @exception IllegalArgumentException if dataSource is null or empty.
     */
    public ListDomWMClient (short id, Page pm, String dataSource, int style) {
        super (id, pm, dataSource);
        pageModel_ = (PageClient) pm;
        ui_ = (ListDomUIDelegateClient) UIDelegateFactoryClient.getInstance((PageClient)pm).newUIDelegateFor(this);
        setShowStyle (style);
        if ((style & MANDATORY) != 0) mandatory_ = true;
    }

    /**
     * Sets the style that drives what is shown in the combo box. This method also
     * determines the sort order. SHOW_LONG implies ORDER_LONG and
     * SHOW_SHORT_LONG implies ORDER_SHORT. 

* * This set method may only be called after construction. Calling it later won't * effect the visual appearance of the combo. * * @param showStyle must be either SHOW_LONG or SHOW_SHORT_LONG. If non of these * style is set, this method does nothing. */ public void setShowStyle (int showStyle) { if ((showStyle & SHOW_LONG) != 0) { showStyle_ = SHOW_LONG; setOrderStyle (ORDER_LONG);} else if ((showStyle & SHOW_SHORT_LONG) != 0) { showStyle_ = SHOW_SHORT_LONG; setOrderStyle(ORDER_SHORT); } else if ((showStyle & SHOW_SHORT) != 0) { showStyle_ = SHOW_SHORT; setOrderStyle(ORDER_SHORT); } } /** * Sets the style that determines the sort order.

* * This method may only be called after construction. Calling it later won't * affect the visual appearance of the combo. * * @param orderStyle may be ORDER_LONG, ORDER_SHORT or * ORDER_NATURAL. */ public void setOrderStyle (int orderStyle) { if ((orderStyle & ORDER_LONG) != 0) orderStyle_ = ORDER_LONG; else if ((orderStyle & ORDER_NATURAL) != 0) orderStyle_ = ORDER_NATURAL; else if ((orderStyle & ORDER_SHORT) !=0 ) orderStyle_ = ORDER_SHORT; else throw new IllegalArgumentException(); } /** * @see at.spardat.xma.mdl.list.IListDomWMClient#getOrderStyle() */ public int getOrderStyle() { return orderStyle_; } /** * @see at.spardat.xma.mdl.list.IListDomWMClient#getShowStyle() */ public int getShowStyle() { return showStyle_; } /** * @see at.spardat.xma.mdl.list.IListDomWMClient#isMandatory() */ public boolean isMandatory() { return mandatory_; } /** * @see at.spardat.xma.mdl.list.IListDomWMClient#setMandatory(boolean) */ public void setMandatory (boolean what) { boolean oldVal = mandatory_; mandatory_ = what; if (oldVal != what) handle (new MandatoryChangedEvent()); } /** * @see at.spardat.xma.mdl.IWModelClient#getUIDelegate() */ public UIDelegateClient getUIDelegate() { return ui_; } /** * @see at.spardat.xma.mdl.WModel#handle(at.spardat.xma.mdl.ModelChangeEvent) */ public boolean handle (ModelChangeEvent event) { boolean success = super.handle(event); // notify the UI-delegate if (!event.isFromUI()) { ui_.handleModelChangeEvent(event); } return success; } /** * Returns the PageClient this WidgetModelC belongs to. * * @return PageClient, never null. */ public PageClient getPageModelC () { return pageModel_; } /** * @see at.spardat.xma.mdl.IWModelClient#isEditable() */ public boolean isEditable() { return ui_.isEditable(); } /** * @see at.spardat.xma.mdl.IWModelClient#isEnabled() */ public boolean isEnabled() { return ui_.isEnabled(); } /** * @see at.spardat.xma.mdl.IWModelClient#setEditable(boolean) */ public void setEditable(boolean what) { ui_.setEditable(what); } /** * @see at.spardat.xma.mdl.IWModelClient#setEnabled(boolean) */ public void setEnabled(boolean what) { ui_.setEnabled(what); } /** * Indicates that the formatter has been changed programmatically */ class MandatoryChangedEvent extends Notification { public MandatoryChangedEvent () { super (ListDomWMClient.this, false); } } /** * Returns if the selected long value should be shown as tooltip. */ public boolean isShowLongValueAsTooltips_() { return isShowLongValueAsTooltips_; } /** * @see at.spardat.xma.mdl.list.IListDomWMClient#setShowLongValueToolTips() */ public void setShowLongValueToolTips () { isShowLongValueAsTooltips_ = true; } /** * Event class used to notify the dynamic registration of a new ListDomWMClient. * @author gub * @since 2.1.0 * @see Page#addWModel(WModel) */ public static class NewListDomWMClientEvent extends NewListDomWMEvent { /** empty contructor for deserialization */ public NewListDomWMClientEvent() {} /** * constructor which initializes dataSource and style * @param dataSource specifies a tabular data source * @param style one of the SHOW_-constants or MANDATORY defined in {@link IListDomWMClient}. */ public NewListDomWMClientEvent(String dataSource, int style) { super(dataSource,style); } // see at.spardat.xma.mdl.NewModelEvent.createModel() public WModel createModel(short id, Page page) { return new ListDomWMClient(id,page,dataSource,style); } } // see at.sparda.xma.mdl.WModel.createNewModelEvent() public NewModelEvent createNewModelEvent() { return new NewListDomWMClientEvent(getDataSource(),showStyle_); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy