Source Code Cross Referenced for ItemViewPanel.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 static info.jtrac.domain.ItemItem.*;
020:
021:        import info.jtrac.domain.Field;
022:        import info.jtrac.domain.History;
023:        import info.jtrac.domain.Item;
024:        import info.jtrac.domain.ItemItem;
025:        import info.jtrac.domain.ItemSearch;
026:        import info.jtrac.util.DateUtils;
027:        import info.jtrac.util.ItemUtils;
028:        import java.util.ArrayList;
029:        import java.util.List;
030:        import java.util.Map;
031:        import org.apache.wicket.PageParameters;
032:        import org.apache.wicket.behavior.SimpleAttributeModifier;
033:        import org.apache.wicket.markup.html.WebMarkupContainer;
034:        import org.apache.wicket.markup.html.basic.Label;
035:        import org.apache.wicket.markup.html.link.Link;
036:        import org.apache.wicket.markup.html.list.ListItem;
037:        import org.apache.wicket.markup.html.list.ListView;
038:        import org.apache.wicket.model.PropertyModel;
039:
040:        /**
041:         * panel for showing the item read-only view
042:         */
043:        public class ItemViewPanel extends BasePanel {
044:
045:            private boolean hideLinks;
046:
047:            public ItemViewPanel(String id, long itemId) {
048:                super (id);
049:                addComponents(getJtrac().loadItem(itemId));
050:            }
051:
052:            public ItemViewPanel(String id, final Item item, boolean hideLinks) {
053:                super (id);
054:                this .hideLinks = hideLinks;
055:                addComponents(item);
056:            }
057:
058:            private void addComponents(final Item item) {
059:
060:                add(new Label("refId", new PropertyModel(item, "refId")));
061:
062:                add(new Link("relate") {
063:                    public void onClick() {
064:                        // TODO choose specific space for search
065:                        ItemSearch itemSearch = new ItemSearch(getPrincipal(),
066:                                ItemViewPanel.this );
067:                        itemSearch.setRelatingItemRefId(item.getRefId());
068:                        setResponsePage(new ItemSearchFormPage(itemSearch));
069:                    }
070:                }.setVisible(!hideLinks));
071:
072:                if (item.getRelatedItems() != null) {
073:                    add(new ListView("relatedItems", new ArrayList(item
074:                            .getRelatedItems())) {
075:                        protected void populateItem(ListItem listItem) {
076:                            final ItemItem itemItem = (ItemItem) listItem
077:                                    .getModelObject();
078:                            String message = null;
079:                            if (itemItem.getType() == DUPLICATE_OF) {
080:                                message = localize("item_view.duplicateOf");
081:                            } else if (itemItem.getType() == DEPENDS_ON) {
082:                                message = localize("item_view.dependsOn");
083:                            } else if (itemItem.getType() == RELATED) {
084:                                message = localize("item_view.relatedTo");
085:                            }
086:                            final String refId = itemItem.getRelatedItem()
087:                                    .getRefId();
088:                            if (hideLinks) {
089:                                message = message + " " + refId;
090:                            }
091:                            listItem.add(new Label("message", message));
092:                            Link link = new Link("link") {
093:                                public void onClick() {
094:                                    setResponsePage(ItemViewPage.class,
095:                                            new PageParameters("0=" + refId));
096:                                }
097:                            };
098:                            link.add(new Label("refId", refId));
099:                            link.setVisible(!hideLinks);
100:                            listItem.add(link);
101:                            listItem.add(new Link("remove") {
102:                                public void onClick() {
103:                                    setResponsePage(new ItemRelateRemovePage(
104:                                            item.getId(), itemItem));
105:                                }
106:                            }.setVisible(!hideLinks));
107:                        }
108:                    });
109:                } else {
110:                    add(new WebMarkupContainer("relatedItems")
111:                            .setVisible(false));
112:                }
113:
114:                if (item.getRelatingItems() != null) {
115:                    add(new ListView("relatingItems", new ArrayList(item
116:                            .getRelatingItems())) {
117:                        protected void populateItem(ListItem listItem) {
118:                            final ItemItem itemItem = (ItemItem) listItem
119:                                    .getModelObject();
120:                            // this looks very similar to related items block above
121:                            // but the display strings could be different and in future handling of the 
122:                            // inverse of the bidirectional link could be different as well                    
123:                            String message = null;
124:                            if (itemItem.getType() == DUPLICATE_OF) {
125:                                message = localize("item_view.duplicateOfThis");
126:                            } else if (itemItem.getType() == DEPENDS_ON) {
127:                                message = localize("item_view.dependsOnThis");
128:                            } else if (itemItem.getType() == RELATED) {
129:                                message = localize("item_view.relatedToThis");
130:                            }
131:                            final String refId = itemItem.getItem().getRefId();
132:                            if (hideLinks) {
133:                                message = refId + " " + message;
134:                            }
135:                            listItem.add(new Label("message", message));
136:                            Link link = new Link("link") {
137:                                public void onClick() {
138:                                    setResponsePage(ItemViewPage.class,
139:                                            new PageParameters("0=" + refId));
140:                                }
141:                            };
142:                            link.add(new Label("refId", refId));
143:                            link.setVisible(!hideLinks);
144:                            listItem.add(link);
145:                            listItem.add(new Link("remove") {
146:                                public void onClick() {
147:                                    setResponsePage(new ItemRelateRemovePage(
148:                                            item.getId(), itemItem));
149:                                }
150:                            }.setVisible(!hideLinks));
151:                        }
152:                    });
153:                } else {
154:                    add(new WebMarkupContainer("relatingItems")
155:                            .setVisible(false));
156:                }
157:
158:                add(new Label("status", new PropertyModel(item, "statusValue")));
159:                add(new Label("loggedBy", new PropertyModel(item,
160:                        "loggedBy.name")));
161:                add(new Label("assignedTo", new PropertyModel(item,
162:                        "assignedTo.name")));
163:                add(new Label("summary", new PropertyModel(item, "summary")));
164:                add(new Label("detail", ItemUtils.fixWhiteSpace(item
165:                        .getDetail())).setEscapeModelStrings(false));
166:
167:                final SimpleAttributeModifier sam = new SimpleAttributeModifier(
168:                        "class", "alt");
169:                final Map<Field.Name, Field> fields = item.getSpace()
170:                        .getMetadata().getFields();
171:                add(new ListView("fields", item.getSpace().getMetadata()
172:                        .getFieldOrder()) {
173:                    protected void populateItem(ListItem listItem) {
174:                        if (listItem.getIndex() % 2 == 0) {
175:                            listItem.add(sam);
176:                        }
177:                        Field.Name fieldName = (Field.Name) listItem
178:                                .getModelObject();
179:                        Field field = fields.get(fieldName);
180:                        listItem.add(new Label("label", field.getLabel()));
181:                        listItem.add(new Label("value", item
182:                                .getCustomValue(fieldName)));
183:                    }
184:                });
185:
186:                final List<Field> editable = item.getSpace().getMetadata()
187:                        .getEditableFields();
188:                add(new ListView("labels", editable) {
189:                    protected void populateItem(ListItem listItem) {
190:                        Field field = (Field) listItem.getModelObject();
191:                        listItem.add(new Label("label", field.getLabel()));
192:                    }
193:                });
194:
195:                if (item.getHistory() != null) {
196:                    List<History> history = new ArrayList(item.getHistory());
197:                    add(new ListView("history", history) {
198:                        protected void populateItem(ListItem listItem) {
199:                            if (listItem.getIndex() % 2 != 0) {
200:                                listItem.add(sam);
201:                            }
202:                            final History h = (History) listItem
203:                                    .getModelObject();
204:                            listItem.add(new Label("loggedBy",
205:                                    new PropertyModel(h, "loggedBy.name")));
206:                            listItem.add(new Label("status", new PropertyModel(
207:                                    h, "statusValue")));
208:                            listItem.add(new Label("assignedTo",
209:                                    new PropertyModel(h, "assignedTo.name")));
210:
211:                            WebMarkupContainer comment = new WebMarkupContainer(
212:                                    "comment");
213:                            comment.add(new AttachmentLinkPanel("attachment", h
214:                                    .getAttachment()));
215:                            comment.add(new Label("comment", ItemUtils
216:                                    .fixWhiteSpace(h.getComment()))
217:                                    .setEscapeModelStrings(false));
218:                            listItem.add(comment);
219:
220:                            listItem.add(new Label("timeStamp", DateUtils
221:                                    .formatTimeStamp(h.getTimeStamp())));
222:                            listItem.add(new ListView("fields", editable) {
223:                                protected void populateItem(ListItem listItem) {
224:                                    Field field = (Field) listItem
225:                                            .getModelObject();
226:                                    listItem.add(new Label("field", h
227:                                            .getCustomValue(field.getName())));
228:                                }
229:                            });
230:                        }
231:                    });
232:                }
233:
234:            }
235:
236:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.