Source Code Cross Referenced for SpaceFieldListPage.java in  » Issue-Tracking » jTrac » info » jtrac » wicket » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Issue Tracking » jTrac » info.jtrac.wicket 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2005 the original author or authors.
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:         */
016:
017:        package info.jtrac.wicket;
018:
019:        import info.jtrac.domain.Field;
020:        import info.jtrac.domain.Space;
021:        import java.util.ArrayList;
022:        import java.util.Collections;
023:        import java.util.List;
024:        import java.util.Map;
025:        import org.apache.wicket.behavior.SimpleAttributeModifier;
026:        import org.apache.wicket.markup.html.WebPage;
027:        import org.apache.wicket.markup.html.basic.Label;
028:        import org.apache.wicket.markup.html.form.Button;
029:        import org.apache.wicket.markup.html.form.DropDownChoice;
030:        import org.apache.wicket.markup.html.form.Form;
031:        import org.apache.wicket.markup.html.form.IChoiceRenderer;
032:        import org.apache.wicket.markup.html.link.Link;
033:        import org.apache.wicket.markup.html.list.ListItem;
034:        import org.apache.wicket.markup.html.list.ListView;
035:        import org.apache.wicket.model.BoundCompoundPropertyModel;
036:        import org.apache.wicket.model.PropertyModel;
037:
038:        /**
039:         * space fields add / re-order page
040:         */
041:        public class SpaceFieldListPage extends BasePage {
042:
043:            private Space space;
044:            private WebPage previous;
045:
046:            public SpaceFieldListPage(Space space, String selectedFieldName,
047:                    WebPage previous) {
048:                this .previous = previous;
049:                this .space = space;
050:                add(new SpaceFieldsForm("form", space, selectedFieldName));
051:            }
052:
053:            /**
054:             * wicket form
055:             */
056:            private class SpaceFieldsForm extends Form {
057:
058:                private String type;
059:
060:                public String getType() {
061:                    return type;
062:                }
063:
064:                public void setType(String type) {
065:                    this .type = type;
066:                }
067:
068:                public SpaceFieldsForm(String id, final Space space,
069:                        final String selectedFieldName) {
070:                    super (id);
071:
072:                    final BoundCompoundPropertyModel model = new BoundCompoundPropertyModel(
073:                            this );
074:                    setModel(model);
075:
076:                    add(new Label("name", new PropertyModel(space, "name")));
077:                    add(new Label("prefixCode", new PropertyModel(space,
078:                            "prefixCode")));
079:
080:                    final SimpleAttributeModifier sam = new SimpleAttributeModifier(
081:                            "class", "alt");
082:
083:                    ListView listView = new ListView("fields", space
084:                            .getMetadata().getFieldList()) {
085:                        protected void populateItem(ListItem listItem) {
086:                            final Field field = (Field) listItem
087:                                    .getModelObject();
088:
089:                            if (field.getName().getText().equals(
090:                                    selectedFieldName)) {
091:                                listItem.add(new SimpleAttributeModifier(
092:                                        "class", "selected"));
093:                            } else if (listItem.getIndex() % 2 == 1) {
094:                                listItem.add(sam);
095:                            }
096:
097:                            listItem.add(new Button("up") {
098:                                @Override
099:                                public void onSubmit() {
100:                                    List<Field.Name> fieldOrder = space
101:                                            .getMetadata().getFieldOrder();
102:                                    int index = fieldOrder.indexOf(field
103:                                            .getName());
104:                                    int swapIndex = index - 1;
105:                                    if (swapIndex < 0) {
106:                                        if (fieldOrder.size() > 1) {
107:                                            swapIndex = fieldOrder.size() - 1;
108:                                        } else {
109:                                            swapIndex = 0;
110:                                        }
111:                                    }
112:                                    if (index != swapIndex) {
113:                                        Collections.swap(fieldOrder, index,
114:                                                swapIndex);
115:                                        setResponsePage(new SpaceFieldListPage(
116:                                                space, field.getName()
117:                                                        .getText(), previous));
118:                                    }
119:                                }
120:                            });
121:
122:                            listItem.add(new Button("down") {
123:                                @Override
124:                                public void onSubmit() {
125:                                    List<Field.Name> fieldOrder = space
126:                                            .getMetadata().getFieldOrder();
127:                                    int index = fieldOrder.indexOf(field
128:                                            .getName());
129:                                    int swapIndex = index + 1;
130:                                    if (swapIndex == fieldOrder.size()) {
131:                                        swapIndex = 0;
132:                                    }
133:                                    if (index != swapIndex) {
134:                                        Collections.swap(fieldOrder, index,
135:                                                swapIndex);
136:                                        setResponsePage(new SpaceFieldListPage(
137:                                                space, field.getName()
138:                                                        .getText(), previous));
139:                                    }
140:                                }
141:                            });
142:
143:                            listItem.add(new Label("name", new PropertyModel(
144:                                    field, "name.text")));
145:                            listItem.add(new Label("type", new PropertyModel(
146:                                    field, "name.description")));
147:                            listItem.add(new Label("label", new PropertyModel(
148:                                    field, "label")));
149:                            List<String> optionsList;
150:                            if (field.getOptions() != null) {
151:                                optionsList = new ArrayList(field.getOptions()
152:                                        .values());
153:                            } else {
154:                                optionsList = new ArrayList(0);
155:                            }
156:                            ListView options = new ListView("options",
157:                                    optionsList) {
158:                                protected void populateItem(ListItem item) {
159:                                    item.add(new Label("option", item
160:                                            .getModelObject()
161:                                            + ""));
162:                                }
163:                            };
164:                            listItem.add(options);
165:                            listItem.add(new Button("edit") {
166:                                @Override
167:                                public void onSubmit() {
168:                                    Field f = field.getClone();
169:                                    setResponsePage(new SpaceFieldFormPage(
170:                                            space, f, previous));
171:                                }
172:                            });
173:                        }
174:                    };
175:                    add(listView);
176:
177:                    final Map<String, String> types = space.getMetadata()
178:                            .getAvailableFieldTypes();
179:                    List<String> typesList = new ArrayList(types.keySet());
180:                    // pre-select the drop down for convenience
181:                    if (typesList.size() > 0) {
182:                        type = typesList.get(0);
183:                    }
184:
185:                    DropDownChoice choice = new DropDownChoice("type",
186:                            typesList, new IChoiceRenderer() {
187:                                public Object getDisplayValue(Object o) {
188:                                    return localize("space_fields.type_" + o)
189:                                            + " - "
190:                                            + localize(
191:                                                    "space_fields.typeRemaining",
192:                                                    types.get(o));
193:                                }
194:
195:                                public String getIdValue(Object o, int i) {
196:                                    return o.toString();
197:                                }
198:                            });
199:
200:                    add(choice);
201:
202:                    add(new Button("add") {
203:                        @Override
204:                        public void onSubmit() {
205:                            if (type == null) {
206:                                return;
207:                            }
208:                            Field field = space.getMetadata()
209:                                    .getNextAvailableField(
210:                                            Integer.parseInt(type));
211:                            field.initOptions();
212:                            setResponsePage(new SpaceFieldFormPage(space,
213:                                    field, previous));
214:                        }
215:                    });
216:
217:                    add(new Button("back") {
218:                        @Override
219:                        public void onSubmit() {
220:                            SpaceFormPage page = new SpaceFormPage(space);
221:                            page.setPrevious(previous);
222:                            setResponsePage(page);
223:                        }
224:                    });
225:
226:                    add(new Button("next") {
227:                        @Override
228:                        public void onSubmit() {
229:                            setResponsePage(new SpacePermissionsPage(space,
230:                                    previous));
231:                        }
232:                    });
233:
234:                    add(new Link("cancel") {
235:                        public void onClick() {
236:                            if (previous == null) {
237:                                setResponsePage(new OptionsPage());
238:                            } else {
239:                                if (previous instanceof  SpaceListPage) {
240:                                    ((SpaceListPage) previous)
241:                                            .setSelectedSpaceId(space.getId());
242:                                }
243:                                setResponsePage(previous);
244:                            }
245:                        }
246:                    });
247:
248:                }
249:
250:            }
251:
252:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.