001: /*
002: * MyGWT Widget Library
003: * Copyright(c) 2007, MyGWT.
004: * licensing@mygwt.net
005: *
006: * http://mygwt.net/license
007: */
008: package net.mygwt.ui.client.data;
009:
010: import net.mygwt.ui.client.event.Listener;
011: import net.mygwt.ui.client.viewer.RemoteContentProvider;
012:
013: /**
014: * Interface for objects that can retrieve remote data.
015: *
016: * @see DataLoader
017: * @see RemoteContentProvider
018: */
019: public interface Loader {
020:
021: /**
022: * Fires before a request is made for data (value is 300).
023: */
024: public static final int BeforeLoad = 300;
025:
026: /**
027: * Fires when new data has been loaded (value is 301).
028: */
029: public static final int Load = 301;
030:
031: /**
032: * Fires if an exception occurs while retrieving data (value is 302).
033: */
034: public static final int LoadException = 302;
035:
036: /**
037: * Adds a listener bound by the given event type.
038: *
039: * @param eventType the eventType
040: * @param listener the listener to be added
041: */
042: public void addListener(int eventType, Listener listener);
043:
044: /**
045: * Returns the last load config.
046: *
047: * @return the last load config
048: */
049: public LoadConfig getLastConfig();
050:
051: /**
052: * Returns <code>true</code> if remote sorting is enabled.
053: *
054: * @return the remote sort state
055: */
056: public boolean getRemoteSort();
057:
058: /**
059: * Returns the current sort direction.
060: *
061: * @return the sort direction
062: */
063: public int getSortDir();
064:
065: /**
066: * Returns the current sort field.
067: *
068: * @return the sort field
069: */
070: public String getSortField();
071:
072: /**
073: * Returns the total number of records which may not equal the local elements
074: * when using paging.
075: *
076: * @return the total length
077: */
078: public int getTotalLength();
079:
080: /**
081: * Loads the data using the specified configuation.
082: *
083: * @param config the configuration
084: */
085: public void load(LoadConfig config);
086:
087: /**
088: * Reloads using the last load config.
089: */
090: public void reload();
091:
092: /**
093: * Removes a listener.
094: *
095: * @param eventType the event type
096: * @param listener the listener to be removed
097: */
098: public void removeListener(int eventType, Listener listener);
099:
100: /**
101: * Sets the current sort dir.
102: *
103: * @param dir the sort dir
104: */
105: public void setSortDir(int dir);
106:
107: /**
108: * Sets the current sort field.
109: *
110: * @param field the sort field
111: */
112: public void setSortField(String field);
113:
114: /**
115: * Sorts the elements.
116: *
117: * @param sortField the sort field
118: * @param sortDir the sort direction
119: */
120: public void sort(String sortField, int sortDir);
121: }
|