001: /**
002: * Copyright 2006 Webmedia Group Ltd.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: **/package org.araneaframework.uilib.list.structure;
016:
017: import java.io.Serializable;
018:
019: /**
020: * Base implementation of the {@link ListField}.
021: */
022: public class ListField implements Serializable {
023:
024: private static final long serialVersionUID = 1L;
025:
026: /**
027: * ListColumn Id.
028: */
029: protected String id;
030:
031: /**
032: * ListColumn label.
033: */
034: protected String label;
035:
036: /**
037: * Constructs a new <code>ListColumn</code> with <code>Id</code> and
038: * <code>Label</code>.
039: *
040: * @param id
041: * ListColumn id.
042: * @param label
043: * ListColumn label.
044: */
045: public ListField(String id, String label) {
046: this .id = id;
047: this .label = label;
048: }
049:
050: /**
051: * Constructs a new <code>ListColumn</code> without <code>Label</code>.
052: *
053: * @param id
054: * ListColumn id.
055: */
056: public ListField(String id) {
057: this (id, null);
058: }
059:
060: /**
061: * Returns the Id of this <code>ListColumn</code>.
062: *
063: * @return the Id of this <code>ListColumn</code>.
064: */
065: public String getId() {
066: return this .id;
067: }
068:
069: /**
070: * Returns the label of this <code>ListColumn</code>.
071: *
072: * @return the label of this <code>ListColumn</code>.
073: */
074: public String getLabel() {
075: return this .label;
076: }
077:
078: /**
079: * Saves the new label of this <code>ListColumn</code>.
080: *
081: * @param label
082: * the new label of this <code>ListColumn</code>.
083: */
084: public void setLabel(String label) {
085: this .label = label;
086: }
087:
088: /**
089: * Returns view model.
090: *
091: * @return view model.
092: */
093: public ViewModel getViewModel() {
094: return new ViewModel();
095: }
096:
097: /**
098: * View Model.
099: */
100: public class ViewModel implements Serializable {
101:
102: private static final long serialVersionUID = 1L;
103:
104: private String id;
105: private String label;
106:
107: /**
108: * Takes a snapshot of outer class state.
109: */
110: protected ViewModel() {
111: this .id = ListField.this .id;
112: this .label = ListField.this .label;
113: }
114:
115: /**
116: * @return Returns the id.
117: */
118: public String getId() {
119: return id;
120: }
121:
122: /**
123: * @return Returns the label.
124: */
125: public String getLabel() {
126: return label;
127: }
128: }
129: }
|