KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jaspersoft > jasperserver > irplugin > gui > inputcontrols > ListInputControl


1 /*
2  * BooleanInputControl.java
3  *
4  * All rights reserved.
5  * Copyright (C) 2005 JasperSoft Corporation
6  *
7  * JasperSoft Corporation
8  * 303 Second Street, Suite 450 North
9  * San Francisco, CA 94107
10  * http://www.jaspersoft.com
11  *
12  *
13  * Created on June 7, 2006, 3:19 PM
14  *
15  */

16
17 package com.jaspersoft.jasperserver.irplugin.gui.inputcontrols;
18
19 import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ListItem;
20 import com.jaspersoft.jasperserver.api.metadata.xml.domain.impl.ResourceDescriptor;
21 import com.jaspersoft.jasperserver.irplugin.gui.inputcontrols.ui.BasicInputControlUI;
22 import com.jaspersoft.jasperserver.irplugin.gui.inputcontrols.ui.ListInputControlUI;
23 import java.util.List JavaDoc;
24
25 /**
26  *
27  * @author gtoffoli
28  */

29 public class ListInputControl extends BasicInputControl{
30     
31     java.util.List JavaDoc wrappedItems = null;
32     
33     /** Creates a new instance of BooleanInputControl */
34     public ListInputControl() {
35         super();
36         setInputControlUI( new ListInputControlUI());
37     }
38     
39      public void setInputControl(ResourceDescriptor inputControl, List JavaDoc items) {
40         
41          this.inputControl = inputControl;
42          
43         String JavaDoc label = inputControl.getLabel() + ((inputControl.isMandatory()) ? "*" : "");
44         getInputControlUI().setLabel(label);
45         getInputControlUI().setReadOnly( inputControl.isReadOnly() );
46         
47         wrappedItems = new java.util.ArrayList JavaDoc();
48         
49         if (!inputControl.isMandatory())
50         {
51             wrappedItems.add(new ListItemWrapper(new ListItem("",null)));
52         }
53         
54         for (int i=0; items != null && items.size()>i; ++i)
55         {
56             ListItem item = (ListItem)items.get(i);
57             wrappedItems.add( new ListItemWrapper(item));
58         }
59         
60         getInputControlUI().setHistory( wrappedItems );
61     
62         List JavaDoc history = getHistory(inputControl.getUriString());
63      
64         if (history != null && history.size() > 0)
65         {
66             getInputControlUI().setValue( history.get(0) );
67         }
68      }
69      
70      public Object JavaDoc validate() throws InputValidationException
71      {
72         return getInputControlUI().getValue();
73      }
74      
75 }
76
Popular Tags