Source Code Cross Referenced for DiffController.java in  » Project-Management » EmForce » ru » emdev » EmForge » wiki » web » bean » 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 » Project Management » EmForce » ru.emdev.EmForge.wiki.web.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package ru.emdev.EmForge.wiki.web.bean;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collection;
005:        import java.util.List;
006:
007:        import javax.faces.component.UIComponent;
008:        import javax.faces.context.FacesContext;
009:        import javax.faces.model.SelectItem;
010:
011:        import org.apache.commons.lang.StringUtils;
012:        import org.apache.commons.logging.Log;
013:        import org.apache.commons.logging.LogFactory;
014:
015:        import ru.emdev.EmForge.web.bean.MainMenuController.MainMenuItem;
016:
017:        import com.ecyrd.jspwiki.PageManager;
018:        import com.ecyrd.jspwiki.WikiContext;
019:        import com.ecyrd.jspwiki.WikiPage;
020:        import com.ecyrd.jspwiki.providers.ProviderException;
021:
022:        /** Controller for Wiki pages
023:         * 
024:         * @author spopov
025:         *
026:         */
027:        public class DiffController extends BaseWikiControllerImpl {
028:            protected final Log logger = LogFactory.getLog(getClass());
029:
030:            public static String WIKIVIEW_PAGE = "diff.faces";
031:
032:            protected Integer m_rev1;
033:            protected Integer m_rev2;
034:
035:            protected List<WikiPage> m_pageHistory;
036:            protected Collection<SelectItem> m_selectVersions;
037:
038:            @Override
039:            protected void init() {
040:
041:                String pageName = getPageParam();
042:                setPageName(pageName);
043:            }
044:
045:            @Override
046:            public Crumb getTrailCrumbInfo() {
047:                // TODO
048:                return new Crumb("Diff", m_urlConstructor.makeURL(
049:                        WikiContext.DIFF, getPageName(), false, "page="
050:                                + getPageName() + "&r1=" + getRev1() + "&r2="
051:                                + getRev2()));
052:            }
053:
054:            @Override
055:            public MainMenuItem getSelectionItemOnMainMenu() {
056:                return MainMenuItem.WIKI;
057:            }
058:
059:            @Override
060:            public String getTitleImpl() {
061:
062:                return "Compare revisions for page " + getPageName();
063:            }
064:
065:            public String getSubTitle() {
066:                return "Revision " + getRev1() + " and revision " + getRev2();
067:            }
068:
069:            public String getDiff() {
070:                return m_wikiEngine.getDiff(getWikiContext(), getRev2(),
071:                        getRev1());
072:            }
073:
074:            @SuppressWarnings("unchecked")
075:            @Override
076:            public void setPageName(String pageName) {
077:                if (!StringUtils.isEmpty(pageName)) {
078:                    // making initialization 
079:                    PageManager pageManager = m_wikiEngine.getPageManager();
080:
081:                    try {
082:                        m_pageHistory = pageManager.getVersionHistory(pageName);
083:                    } catch (ProviderException ex) {
084:                        logger.error("Cannot get page history");
085:                    }
086:
087:                    //clear select Versions
088:                    m_selectVersions = null;
089:                }
090:
091:                super .setPageName(pageName);
092:            }
093:
094:            public void setRev1(Integer i_rev) {
095:                m_rev1 = i_rev;
096:            }
097:
098:            public Integer getRev1() {
099:                if (m_rev1 == null) {
100:                    try {
101:                        m_rev1 = Integer.valueOf(getParam("r1"));
102:                    } catch (Exception ex) {
103:                        // ignore all exceptoins
104:                    }
105:
106:                    if (m_rev1 == null && m_pageHistory != null) {
107:                        // get latest version
108:                        if (m_pageHistory.size() > 0) {
109:                            m_rev1 = m_pageHistory
110:                                    .get(m_pageHistory.size() - 1).getVersion();
111:                        } else {
112:                            m_rev1 = -1;
113:                        }
114:                    }
115:                }
116:
117:                return m_rev1;
118:            }
119:
120:            public void setRev2(Integer i_rev) {
121:
122:                m_rev2 = i_rev;
123:            }
124:
125:            public Integer getRev2() {
126:                if (m_rev2 == null) {
127:                    try {
128:                        m_rev2 = Integer.valueOf(getParam("r2"));
129:                    } catch (Exception ex) {
130:                        // ignore all exceptoins
131:                    }
132:
133:                    if (m_rev2 == null && m_pageHistory != null) {
134:                        // get latest version
135:                        if (m_pageHistory.size() > 1) {
136:                            m_rev2 = m_pageHistory
137:                                    .get(m_pageHistory.size() - 2).getVersion();
138:                        } else {
139:                            m_rev2 = -1;
140:                        }
141:                    }
142:                }
143:
144:                return m_rev2;
145:            }
146:
147:            public Collection<SelectItem> getSelectVersions() {
148:                if (m_selectVersions == null && m_pageHistory != null) {
149:                    // build select versions
150:                    m_selectVersions = new ArrayList<SelectItem>();
151:                    for (WikiPage page : m_pageHistory) {
152:                        m_selectVersions.add(new SelectItem(page.getVersion()));
153:                    }
154:                }
155:
156:                // to avoid lot of error messages in logs (we will need to clarify why they happens)
157:                // it is better to return empty array instead of null
158:                return m_selectVersions == null ? new ArrayList<SelectItem>()
159:                        : m_selectVersions;
160:            }
161:
162:            /** It is a trick.
163:             * JSF Required selectVersions during validation step - but in this phase it is not yet passed page name
164:             * Stored in t:saveState - so, we do not have pageName - and as result - we do not have pageVersions...
165:             * 
166:             * Very stupid hack - during validation stage first called custom validators - so, in this validator we just
167:             * add values into selectVersions array to return them on validation stage later
168:             * @param i_context
169:             * @param ui_component
170:             * @param value
171:             */
172:            public void validateVersion(FacesContext i_context,
173:                    UIComponent ui_component, Object value) {
174:                if (m_selectVersions == null) {
175:                    m_selectVersions = new ArrayList<SelectItem>();
176:                }
177:
178:                m_selectVersions.add(new SelectItem(value));
179:            }
180:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.