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

at.spardat.xma.mdl.list.ListWMClient 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
 *******************************************************************************/

/*
 * Created on 04.11.2003
 *
 *
 *
 */
package at.spardat.xma.mdl.list;


import at.spardat.enterprise.fmt.AStringFmt;
import at.spardat.enterprise.fmt.IFmt;
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;

/**
 * Client side implementation of {@link ListWM}.
 *
 * @author s2877
 */
public class ListWMClient extends ListWM implements IListWMClient {

    private ListUIDelegateClient               ui_;

    private PageClient                         page_;

    /**
     * An optionally attached Formatter.
     */
    private IFmt                            fmt_;

    /**
     * Constructs a ListWMClient.
     * The behaviour can be ajusted with the following styles
     * 
    *
  • {@link IListWM#S_MULTI_SELECT} *
  • {@link IListWM#S_NOT_STRICT} *
      * @param id a numeric id which identifies the WidgetModel within its Page. * @param pm reference to the enclosing Page * @param style one of the style-constants listed above or S_NULL. */ public ListWMClient(short id, Page pm, int style) { super(id, pm,style); ui_ = (ListUIDelegateClient) UIDelegateFactoryClient.getInstance((PageClient)pm).newUIDelegateFor(this); page_ = (PageClient)pm; } /* * @see at.spardat.xma.mdl.list.IListWMClient#getFmt() */ public IFmt getFmt() { return fmt_; } /* * @see at.spardat.xma.mdl.list.IListWMClient#setFmt(at.spardat.enterprise.fmt.IFmt) */ public void setFmt (IFmt formatter) { fmt_ = formatter; handle (new FormatterChangedEvent()); } /* * @see at.spardat.xma.mdl.list.IListWMClient#getFormattedString() */ public String getFormattedString () { String key = getSelected(); if(key == null || fmt_ == null) return key; else return fmt_.format(key); } /* * @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; } /* (non-Javadoc) * @see at.spardat.xma.mdl.IWModelClient#getUIDelegate() */ public UIDelegateClient getUIDelegate() { return ui_; } /** * Returns the PageClient this WidgetModelC belongs to. * * @return PageClient, never null. */ public PageClient getPageModelC () { return page_; } /* (non-Javadoc) * @see at.spardat.xma.mdl.IWModelClient#isEditable() */ public boolean isEditable() { return ui_.isEditable(); } /* (non-Javadoc) * @see at.spardat.xma.mdl.IWModelClient#setEditable(boolean) */ public void setEditable(boolean what) { ui_.setEditable(what); } /* (non-Javadoc) * @see at.spardat.xma.mdl.IWModelClient#isEnabled() */ public boolean isEnabled() { return ui_.isEnabled(); } /* (non-Javadoc) * @see at.spardat.xma.mdl.IWModelClient#setEnabled(boolean) */ public void setEnabled(boolean what) { ui_.setEnabled(what); } /** * @see at.spardat.xma.mdl.simple.ISimpleWMClient#isMandatory() */ public boolean isMandatory () { if (fmt_ == null) return false; return fmt_.isMandatory(); } /** * @see at.spardat.xma.mdl.simple.ISimpleWMClient#setMandatory(boolean) */ public void setMandatory (boolean what) { if (fmt_ == null) { if(what==false) return; fmt_ = AStringFmt.getInstance(-1); // create an unrestricted validator } boolean oldMand = fmt_.isMandatory(); if(oldMand!=what) { page_.getPageEffects().mandatoryChanged(ui_.getUIControl(),what); fmt_.setMandatory(what); ui_.updateErrorState(); } } /** * Indicates that the formatter has been changed programmatically */ class FormatterChangedEvent extends Notification { public FormatterChangedEvent () { super (ListWMClient.this, false); } } /** * @return if prefix search will be done case sensitive * @since 1.7.3 */ public boolean isPrefixSearchCaseSensitive() { return ui_.isPrefixSearchCaseSensitive(); } /** * determine if prefix seach has to be done case sensitive or not * @param prefixSearchCaseSensitive * @since 1.7.3 */ public void setPrefixSearchCaseSensitive(boolean prefixSearchCaseSensitive) { ui_.setPrefixSearchCaseSensitive(prefixSearchCaseSensitive); } /** * @return if prefix search will be done on this list model * @since 1.8.1 */ public boolean isDoPrefixSearch() { return ui_.isDoPrefixSearch(); } /** * determine if prefix search has to be done on this model * @since 1.8.1 */ public void setDoPrefixSearch(boolean doPrefixSearch) { ui_.setDoPrefixSearch(doPrefixSearch); } /** * Event class used to notify the dynamic registration of a new ListWMClient. * @author gub * @since 2.1.0 * @see Page#addWModel(WModel) */ public static class NewListWMClientEvent extends NewListWMEvent { /** empty contructor for deserialization */ public NewListWMClientEvent() {} /** * constructor which initializes dataSource and style * @param style one of the style-constants listed in {@link IListWM}. */ public NewListWMClientEvent(int style) { super(style); } // see at.spardat.xma.mdl.NewModelEvent.createModel() public WModel createModel(short id, Page page) { return new ListWMClient(id,page,style); } } // see at.sparda.xma.mdl.WModel.createNewModelEvent() public NewModelEvent createNewModelEvent() { int style = S_NULL; if(isMultiSelect()) style|=S_MULTI_SELECT; if(!isUserStrict()) style|=S_NOT_STRICT; return new NewListWMClientEvent(style); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy