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

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

/*******************************************************************************
 * 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 java.util.Collection;
import java.util.Map;

import at.spardat.xma.mdl.Atom;
import at.spardat.xma.mdl.ISelectable;

/**
 * Interface of the widged model to represent a list of choises. It can be used with
 * the SWT-widgets Combo and List. The entries of the list have to be provided by the
 * programmer. All entries must by {@link Atom}s of the same type.
 * The supported types are T_STRING, T_BCD, T_DATE and T_TIMESTAMP.
 * There are convinience methods to use Java Strings directly.
 * These Strings are converted to Atoms of type T_STRING internally.
 * For domain values please use {@link ListDomWM}.
 *
 * @author s2877
 */
public interface IListWM extends ISelectable {

    /**
     * If the IListWM is used with the SWT-Control List, you can allow multi-selection
     * by specifying this style constant in the constructor.
     * Multi-selection is possible for List only.
     */
    public static final int S_MULTI_SELECT = 1;

    /**
     * If the IListWM is used with the SWT-Control Combo, you can allow entering
     * of values not contained in the list.
     * With S_NON_STRICT the user can enter additional values in the textfield of
     * the combo box.
     */
    public static final int S_NOT_STRICT = 2;


    /**
     * Adds an entry to the list. The entry is appended
     * at the end of the selection list.
     * @param entry to add
     */
    void add(Atom entry);

    /**
     * Adds an entry to the list and associates it with a key.
     * The entry is appended at the end of the selection list.
     * All selection and entry related methods then work with the key:
     * contains(), indexOf(), remove(), deselect(), select(), getSelected(), etc.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param key to add
     * @param entry to add
     */
    void add(String key, Atom entry);

    /**
     * Inserts an entry into the list at the specified position and associates it with a key.
     * All selection and entry related methods then work with the key:
     * contains(), indexOf(), remove(), deselect(), select(), getSelected(), etc.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param key to add
     * @param entry to add
     */
    void add(int index,String key, Atom entry);

    /**
     * Adds an entry to the list and associates it with a key.
     * The entry is appended at the end of the selection list.
     * All selection and entry related methods then work with the key:
     * contains(), indexOf(), remove(), deselect(), select(), getSelected(), etc.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param key to add
     * @param entry to add
     */
    void add(String key, String entry);


    /**
     * Inserts an entry into the list at the specified position and associates it with a key.
     * All selection and entry related methods then work with the key:
     * contains(), indexOf(), remove(), deselect(), select(), getSelected(), etc.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param key to add
     * @param entry to add
     */
    void add(int index, String key, String entry);

    /**
     * Inserts an entry into the list at the specified position.
     * @param index the desired zero base index of the new entry
     * @param entry to add
     */
    void add(int index, Atom entry);

    /**
     * Adds the entries to the list. The entries are appended
     * at the end of the list.
     * @param entries to add
     */
    void add(Atom[] entries);

    /**
     * Adds the entries to the list. The entries are appended
     * at the end of the list. The collection may contain Atoms or Strings.
     * If it contains Atoms, all entries must be Atoms with the same type.
     * If it contains Strings, all entries must be Strings.
     * @param entries to add
     */
    void add(Collection entries);

    /**
     * Adds all the key-value pairs from the map the list.
     * The entries are appended at the end of the list.
     * This method iterates over the Map and calls:
     * at.spardat.xma.mdl.list.IListWM#add(java.lang.String, java.lang.String).
     *
     * The keys in the Map have to be of the type String, the values have to be of the type String or Atom.
     * As the iteration order of a HashMap is undefined, it might be advisable to use a TreeMap or a LinkedHashMap.
     *
     * All selection and entry related methods then work with the keys:
     * contains(), indexOf(), remove(), deselect(), select(), getSelected(), etc.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param map -which is iterated
     * @see at.spardat.xma.mdl.list.IListWM#add(Map map)
     */
    public void add(Map map);

    /**
     * Get the entry at the specified position.
     * @param index the index of the desired entry.
     * @return the entry at the given index.
     */
    Atom getEntry(int index);

    /**
     * Get the entry for the given key.
     * @param key string representation of the desired entry.
     * @return the entry corresponding to the string representation.
     */
    Atom getEntry(String key);
    
    /**
     * Get the key for a given index.
     * @param index
     * @return
     */
    public String getKey(int index);    

    /**
     * Get the index of the given entry.
     * @param entry the entry of which the index is desired.
     * @return the index of the given entry.
     */
    int indexOf(Atom entry);

    /**
     * Removes an entry from the list.
     * @param entry to remove
     */
    void remove(Atom entry);

    /**
     * Removes the entry at the given position from the list.
     * @param index
     */
    void remove(int index);

    /**
     * Replaces an entry in the list. The old entry at the
     * given index position is replaced by the entry given
     * as parameter.
     * @param index the index of the entry to replace.
     * @param newEntry the new entry to insert.
     */
    void replace(int index, Atom newEntry);

    /**
     * Replaces an entry (key-value pair) in the list. The old entry at the
     * given index position is replaced by the entry given
     * as parameter.
     * This method can only be used if the model has the style strict, otherwise an exception is thrown!
     *
     * @param index the index of the entry to replace.
     * @param newKey the new key to insert.
     * @param newEntry the new entry to insert.
     */
    void replace(int index, String newKey, Atom newEntry);

    /**
     * Replaces an entry (key-value pair) in the list. The old entry at the
     * given index position is replaced by the entry given
     * as parameter.
     *
     * @param index the index of the entry to replace.
     * @param newKey the new key to insert.
     * @param newEntry the new entry to insert.
     */
    void replace(int index, String newKey, String newEntry);

    /**
     * Returns true if the list contains the given entry.
     * @param entry
     * @return true if the given entry is contained in the list.
     */
    boolean contains(Atom entry);


    /**
     * Adds an entry to the list. The entry is appended
     * at the end of the selection list.
     * @param entry to add
     */
    void add(String entry);



    /**
     * Inserts an entry into the list at the specified position.
     * @param index the desired zero base index of the new entry
     * @param entry to add
     */
    void add(int index, String entry);

    /**
     * Adds the entries to the list. The entries are appended
     * at the end of the list.
     * @param entries to add
     */
    void add(String[] entries);

    /**
     * Get the entry at the specified position.
     * @param index the index of the desired entry.
     * @return the entry at the given index.
     */
    String getStringEntry(int index);

    /**
     * Get the index of the given entry.
     * @param entry the entry of which the index is desired.
     * @return the index of the given entry.
     */
    int indexOf(String entry);

    /**
     * Removes an entry from the list.
     * @param entry to remove
     */
    void remove(String entry);

    /**
     * Replaces an entry in the list. The old entry at the
     * given index position is replaced by the entry given
     * as parameter.
     * @param index the index of the entry to replace.
     * @param newEntry the new entry to insert.
     */
    void replace(int index, String newEntry);

    /**
     * Returns true if the list contains the given entry.
     * @param entry
     * @return true if the given entry is contained in the list.
     */
    boolean contains(String entry);

    /**
     * Removes all entries from the list and deselects all selected entries.
     */
    public void clear();

    /**
     * Gets the size of the list.
     * @return the number of entries.
     */
    int size();

    /**
     * Sets the selection of this ListWM to the given value.
     * If value is empty (null or ""), the selection is cleared.
     * @param value to select
     */
    void set(String value);

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy