Source Code Cross Referenced for NavigationHistoryEntry.java in  » IDE-Eclipse » ui-workbench » org » eclipse » ui » internal » 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 » IDE Eclipse » ui workbench » org.eclipse.ui.internal 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2006 IBM Corporation and others.
003:         * All rights reserved. This program and the accompanying materials
004:         * are made available under the terms of the Eclipse Public License v1.0
005:         * which accompanies this distribution, and is available at
006:         * http://www.eclipse.org/legal/epl-v10.html
007:         *
008:         * Contributors:
009:         *     IBM Corporation - initial API and implementation
010:         *******************************************************************************/package org.eclipse.ui.internal;
011:
012:        import java.util.ArrayList;
013:
014:        import org.eclipse.ui.IEditorPart;
015:        import org.eclipse.ui.IMemento;
016:        import org.eclipse.ui.INavigationLocation;
017:        import org.eclipse.ui.INavigationLocationProvider;
018:        import org.eclipse.ui.IWorkbenchPage;
019:        import org.eclipse.ui.PartInitException;
020:        import org.eclipse.ui.XMLMemento;
021:
022:        /*
023:         * Wraps the INavigationLocation and keeps editor info.
024:         */
025:        public class NavigationHistoryEntry {
026:
027:            private IWorkbenchPage page;
028:
029:            NavigationHistoryEditorInfo editorInfo;
030:
031:            String historyText;
032:
033:            /* Both may be set at the same time. */
034:            INavigationLocation location;
035:
036:            private IMemento locationMemento;
037:
038:            /**
039:             * Constructs a new HistoryEntry and intializes its editor input and editor id.
040:             */
041:            public NavigationHistoryEntry(
042:                    NavigationHistoryEditorInfo editorInfo,
043:                    IWorkbenchPage page, IEditorPart part,
044:                    INavigationLocation location) {
045:                this .editorInfo = editorInfo;
046:                this .page = page;
047:                this .location = location;
048:                if (location != null) {
049:                    historyText = location.getText();
050:                }
051:                // ensure that the historyText is initialized to something
052:                if (historyText == null || historyText.length() == 0) {
053:                    if (part != null) {
054:                        historyText = part.getTitle();
055:                    }
056:                }
057:            }
058:
059:            /**
060:             * Restores the state of the entry and the location if needed and then
061:             * restores the location.
062:             */
063:            void restoreLocation() {
064:                if (editorInfo.editorInput != null
065:                        && editorInfo.editorID != null) {
066:                    try {
067:                        IEditorPart editor = page.openEditor(
068:                                editorInfo.editorInput, editorInfo.editorID,
069:                                true);
070:                        if (location == null) {
071:                            if (editor instanceof  INavigationLocationProvider) {
072:                                location = ((INavigationLocationProvider) editor)
073:                                        .createEmptyNavigationLocation();
074:                            }
075:                        }
076:
077:                        if (location != null) {
078:                            if (locationMemento != null) {
079:                                location.setInput(editorInfo.editorInput);
080:                                location.restoreState(locationMemento);
081:                                locationMemento = null;
082:                            }
083:                            location.restoreLocation();
084:                        }
085:                    } catch (PartInitException e) {
086:                        // ignore for now
087:                    }
088:                }
089:            }
090:
091:            /**
092:             * Return the label to display in the history drop down list.  Use the
093:             * history entry text if the location has not been restored yet.
094:             */
095:            String getHistoryText() {
096:                if (location != null) {
097:                    // location exists or has been restored, use its text.
098:                    // Also update the historyText so that this value will
099:                    // be saved.  Doing so handles cases where getText() value 
100:                    // may be dynamic. 
101:                    String text = location.getText();
102:                    if ((text == null) || text.equals("")) { //$NON-NLS-1$
103:                        text = historyText;
104:                    } else {
105:                        historyText = text;
106:                    }
107:                    return text;
108:                } else {
109:                    return historyText;
110:                }
111:            }
112:
113:            /** 
114:             * Saves the state of this entry and its location.
115:             * Returns true if possible otherwise returns false.
116:             */
117:            boolean handlePartClosed() {
118:                if (!editorInfo.isPersistable()) {
119:                    return false;
120:                }
121:                if (location != null) {
122:                    locationMemento = XMLMemento
123:                            .createWriteRoot(IWorkbenchConstants.TAG_POSITION);
124:                    location.saveState(locationMemento);
125:                    location.releaseState();
126:                }
127:                return true;
128:            }
129:
130:            /**
131:             * Saves the state of this entry and its location.
132:             */
133:            void saveState(IMemento mem, ArrayList entries) {
134:                mem.putString(IWorkbenchConstants.TAG_HISTORY_LABEL,
135:                        getHistoryText());
136:                if (locationMemento != null) {
137:                    IMemento childMem = mem
138:                            .createChild(IWorkbenchConstants.TAG_POSITION);
139:                    childMem.putMemento(locationMemento);
140:                } else if (location != null) {
141:                    IMemento childMem = mem
142:                            .createChild(IWorkbenchConstants.TAG_POSITION);
143:                    location.saveState(childMem);
144:                }
145:            }
146:
147:            /**
148:             * Restore the state of this entry.
149:             */
150:            void restoreState(IMemento mem) {
151:                historyText = mem
152:                        .getString(IWorkbenchConstants.TAG_HISTORY_LABEL);
153:                locationMemento = mem
154:                        .getChild(IWorkbenchConstants.TAG_POSITION);
155:            }
156:
157:            /*
158:             * (non-Javadoc)
159:             * Method declared on Object.
160:             */
161:            public String toString() {
162:                return "Input<" + editorInfo.editorInput + "> Details<" + location + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
163:            }
164:
165:            /**
166:             * Disposes this entry and its location.
167:             */
168:            void dispose() {
169:                if (location != null) {
170:                    location.dispose();
171:                }
172:                editorInfo = null;
173:            }
174:
175:            /**
176:             * Merges this entry into the current entry. Returns true
177:             * if the merge was possible otherwise returns false.
178:             */
179:            boolean mergeInto(NavigationHistoryEntry currentEntry) {
180:                if (editorInfo.editorInput != null
181:                        && editorInfo.editorInput
182:                                .equals(currentEntry.editorInfo.editorInput)) {
183:                    if (location != null) {
184:                        if (currentEntry.location == null) {
185:                            currentEntry.location = location;
186:                            return true;
187:                        } else {
188:                            return location.mergeInto(currentEntry.location);
189:                        }
190:                    } else if (currentEntry.location == null) {
191:                        return true;
192:                    }
193:                }
194:                return false;
195:            }
196:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.