Source Code Cross Referenced for SiteUndoManager.java in  » IDE-Eclipse » Eclipse-plug-in-development » org » eclipse » pde » internal » ui » editor » site » 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 » Eclipse plug in development » org.eclipse.pde.internal.ui.editor.site 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*******************************************************************************
002:         * Copyright (c) 2000, 2005 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.pde.internal.ui.editor.site;
011:
012:        import org.eclipse.core.runtime.CoreException;
013:        import org.eclipse.pde.core.IModelChangeProvider;
014:        import org.eclipse.pde.core.IModelChangedEvent;
015:        import org.eclipse.pde.internal.core.isite.ISite;
016:        import org.eclipse.pde.internal.core.isite.ISiteArchive;
017:        import org.eclipse.pde.internal.core.isite.ISiteCategory;
018:        import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
019:        import org.eclipse.pde.internal.core.isite.ISiteDescription;
020:        import org.eclipse.pde.internal.core.isite.ISiteFeature;
021:        import org.eclipse.pde.internal.core.isite.ISiteModel;
022:        import org.eclipse.pde.internal.core.isite.ISiteObject;
023:        import org.eclipse.pde.internal.core.site.SiteObject;
024:        import org.eclipse.pde.internal.ui.PDEPlugin;
025:        import org.eclipse.pde.internal.ui.editor.ModelUndoManager;
026:
027:        public class SiteUndoManager extends ModelUndoManager {
028:            public SiteUndoManager(SiteEditor editor) {
029:                super (editor);
030:                setUndoLevelLimit(30);
031:            }
032:
033:            protected String getPageId(Object obj) {
034:                if (obj instanceof  ISiteDescription) {
035:                    return ArchivePage.PAGE_ID;
036:                }
037:                if (obj instanceof  ISiteFeature || obj instanceof  ISiteCategory
038:                        || obj instanceof  ISiteCategoryDefinition) {
039:                    return FeaturesPage.PAGE_ID;
040:                }
041:                // site elements and attributes are on different pages, stay on the
042:                // current page
043:                return null;
044:            }
045:
046:            /*
047:             * @see IModelUndoManager#execute(ModelUndoOperation)
048:             */
049:            protected void execute(IModelChangedEvent event, boolean undo) {
050:                IModelChangeProvider model = event.getChangeProvider();
051:                Object[] elements = event.getChangedObjects();
052:                int type = event.getChangeType();
053:                String propertyName = event.getChangedProperty();
054:
055:                switch (type) {
056:                case IModelChangedEvent.INSERT:
057:                    if (undo)
058:                        executeRemove(model, elements);
059:                    else
060:                        executeAdd(model, elements);
061:                    break;
062:                case IModelChangedEvent.REMOVE:
063:                    if (undo)
064:                        executeAdd(model, elements);
065:                    else
066:                        executeRemove(model, elements);
067:                    break;
068:                case IModelChangedEvent.CHANGE:
069:                    if (undo)
070:                        executeChange(elements[0], propertyName, event
071:                                .getNewValue(), event.getOldValue());
072:                    else
073:                        executeChange(elements[0], propertyName, event
074:                                .getOldValue(), event.getNewValue());
075:                }
076:            }
077:
078:            private void executeAdd(IModelChangeProvider model,
079:                    Object[] elements) {
080:                ISiteModel siteModel = (model instanceof  ISiteModel) ? (ISiteModel) model
081:                        : null;
082:                ISite site = siteModel != null ? siteModel.getSite() : null;
083:
084:                try {
085:                    for (int i = 0; i < elements.length; i++) {
086:                        Object element = elements[i];
087:
088:                        if (element instanceof  ISiteFeature) {
089:                            site
090:                                    .addFeatures(new ISiteFeature[] { (ISiteFeature) element });
091:                        } else if (element instanceof  ISiteArchive) {
092:                            site
093:                                    .addArchives(new ISiteArchive[] { (ISiteArchive) element });
094:                        } else if (element instanceof  ISiteCategoryDefinition) {
095:                            site
096:                                    .addCategoryDefinitions(new ISiteCategoryDefinition[] { (ISiteCategoryDefinition) element });
097:                        } else if (element instanceof  ISiteCategory) {
098:                            ISiteCategory category = (ISiteCategory) element;
099:                            ISiteFeature feature = (ISiteFeature) category
100:                                    .getParent();
101:                            feature
102:                                    .addCategories(new ISiteCategory[] { category });
103:                        }
104:                    }
105:                } catch (CoreException e) {
106:                    PDEPlugin.logException(e);
107:                }
108:            }
109:
110:            private void executeRemove(IModelChangeProvider model,
111:                    Object[] elements) {
112:                ISiteModel siteModel = (model instanceof  ISiteModel) ? (ISiteModel) model
113:                        : null;
114:                ISite site = siteModel != null ? siteModel.getSite() : null;
115:
116:                try {
117:                    for (int i = 0; i < elements.length; i++) {
118:                        Object element = elements[i];
119:
120:                        if (element instanceof  ISiteFeature) {
121:                            site
122:                                    .removeFeatures(new ISiteFeature[] { (ISiteFeature) element });
123:                        } else if (element instanceof  ISiteArchive) {
124:                            site
125:                                    .removeArchives(new ISiteArchive[] { (ISiteArchive) element });
126:                        } else if (element instanceof  ISiteCategoryDefinition) {
127:                            site
128:                                    .removeCategoryDefinitions(new ISiteCategoryDefinition[] { (ISiteCategoryDefinition) element });
129:                        } else if (element instanceof  ISiteCategory) {
130:                            ISiteCategory category = (ISiteCategory) element;
131:                            ISiteFeature feature = (ISiteFeature) category
132:                                    .getParent();
133:                            feature
134:                                    .removeCategories(new ISiteCategory[] { category });
135:                        }
136:                    }
137:                } catch (CoreException e) {
138:                    PDEPlugin.logException(e);
139:                }
140:            }
141:
142:            private void executeChange(Object element, String propertyName,
143:                    Object oldValue, Object newValue) {
144:
145:                if (element instanceof  SiteObject) {
146:                    SiteObject sobj = (SiteObject) element;
147:                    try {
148:                        sobj.restoreProperty(propertyName, oldValue, newValue);
149:                    } catch (CoreException e) {
150:                        PDEPlugin.logException(e);
151:                    }
152:                }
153:            }
154:
155:            public void modelChanged(IModelChangedEvent event) {
156:                if (event.getChangeType() == IModelChangedEvent.CHANGE) {
157:                    Object object = event.getChangedObjects()[0];
158:                    if (object instanceof  ISiteObject) {
159:                        ISiteObject obj = (ISiteObject) object;
160:                        //Ignore events from objects that are not yet in the model.
161:                        if (!(obj instanceof  ISite) && !obj.isInTheModel())
162:                            return;
163:                    }
164:                }
165:                super.modelChanged(event);
166:            }
167:        }
w___w_w_.__j___a___va__2s_.c__om___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.