Source Code Cross Referenced for NodeEditor.java in  » ERP-CRM-Financial » jmoney » net » sf » jmoney » views » 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 » ERP CRM Financial » jmoney » net.sf.jmoney.views 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *
003:         *  JMoney - A Personal Finance Manager
004:         *  Copyright (c) 2004 Johann Gyger <jgyger@users.sf.net>
005:         *
006:         *
007:         *  This program is free software; you can redistribute it and/or modify
008:         *  it under the terms of the GNU General Public License as published by
009:         *  the Free Software Foundation; either version 2 of the License, or
010:         *  (at your option) any later version.
011:         *
012:         *  This program is distributed in the hope that it will be useful,
013:         *  but WITHOUT ANY WARRANTY; without even the implied warranty of
014:         *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
015:         *  GNU General Public License for more details.
016:         *
017:         *  You should have received a copy of the GNU General Public License
018:         *  along with this program; if not, write to the Free Software
019:         *  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
020:         *
021:         */
022:
023:        package net.sf.jmoney.views;
024:
025:        import java.util.Vector;
026:
027:        import net.sf.jmoney.IBookkeepingPage;
028:        import net.sf.jmoney.IBookkeepingPageFactory;
029:        import net.sf.jmoney.JMoneyPlugin;
030:        import net.sf.jmoney.model2.Account;
031:        import net.sf.jmoney.model2.AccountInfo;
032:        import net.sf.jmoney.model2.ExtendableObject;
033:        import net.sf.jmoney.model2.ExtendablePropertySet;
034:        import net.sf.jmoney.model2.PageEntry;
035:        import net.sf.jmoney.model2.PropertySet;
036:        import net.sf.jmoney.model2.ScalarPropertyAccessor;
037:        import net.sf.jmoney.model2.SessionChangeAdapter;
038:        import net.sf.jmoney.model2.SessionChangeListener;
039:
040:        import org.eclipse.core.runtime.IProgressMonitor;
041:        import org.eclipse.ui.IEditorInput;
042:        import org.eclipse.ui.IEditorSite;
043:        import org.eclipse.ui.IMemento;
044:        import org.eclipse.ui.IWorkbenchWindow;
045:        import org.eclipse.ui.PartInitException;
046:        import org.eclipse.ui.actions.ActionGroup;
047:        import org.eclipse.ui.forms.editor.FormEditor;
048:        import org.eclipse.ui.operations.UndoRedoActionGroup;
049:
050:        /**
051:         * TODO
052:         * 
053:         * @author Johann Gyger
054:         */
055:        public class NodeEditor extends FormEditor {
056:
057:            protected Object navigationTreeNode;
058:            protected Vector<PageEntry> pageListeners;
059:
060:            protected SessionChangeListener accountNameChangeListener = null;
061:
062:            /* (non-Javadoc)
063:             * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
064:             */
065:            @Override
066:            protected void addPages() {
067:                NodeEditorInput cInput = (NodeEditorInput) this 
068:                        .getEditorInput();
069:                IMemento memento = cInput.getMemento();
070:
071:                IBookkeepingPage pages[] = new IBookkeepingPage[pageListeners
072:                        .size()];
073:
074:                for (int i = 0; i < pageListeners.size(); i++) {
075:                    PageEntry entry = pageListeners.get(i);
076:                    String pageId = entry.getPageId();
077:                    IBookkeepingPageFactory pageListener = entry
078:                            .getPageFactory();
079:                    pages[i] = pageListener.createFormPage(this ,
080:                            memento == null ? null : memento.getChild(pageId));
081:                }
082:
083:                cInput.pages = pages;
084:            }
085:
086:            @Override
087:            public void dispose() {
088:                // When the editor is disposed, let the editor input
089:                // know that there is no editor open.  This is necessary
090:                // because the input is kept around by Eclipse even when the
091:                // editor is closed and kept in a Most Recently Used list.
092:                // This list is persisted in the workbench memento, but the
093:                // editor input must not try to persist the values of the controls
094:                // because the controls no longer exist.
095:                // We indicate this situation by clearing out the list
096:                // of pages.
097:                NodeEditorInput cInput = (NodeEditorInput) this 
098:                        .getEditorInput();
099:                cInput.pages = null;
100:
101:                if (accountNameChangeListener != null) {
102:                    ((Account) cInput.getNode()).getDataManager()
103:                            .removeChangeListener(accountNameChangeListener);
104:                }
105:
106:                super .dispose();
107:            }
108:
109:            /* (non-Javadoc)
110:             * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
111:             */
112:            @Override
113:            public void init(IEditorSite site, IEditorInput input)
114:                    throws PartInitException {
115:                super .init(site, input);
116:
117:                final NodeEditorInput cInput = (NodeEditorInput) input;
118:
119:                navigationTreeNode = cInput.getNode();
120:                pageListeners = cInput.getPageListeners();
121:
122:                setPartName(cInput.getName());
123:                setTitleImage(cInput.getImage());
124:
125:                /*
126:                 * If the node object is an account then the title is the name of the account.
127:                 * We must listen for changes in the name and update the title accordingly.
128:                 * This ensures the title changes when the account name is edited.
129:                 */
130:                if (cInput.getNode() instanceof  Account) {
131:                    final Account account = (Account) cInput.getNode();
132:                    accountNameChangeListener = new SessionChangeAdapter() {
133:                        @Override
134:                        public void objectChanged(
135:                                ExtendableObject changedObject,
136:                                ScalarPropertyAccessor propertyAccessor,
137:                                Object oldValue, Object newValue) {
138:                            if (changedObject == account
139:                                    && propertyAccessor == AccountInfo
140:                                            .getNameAccessor()) {
141:                                setPartName(account.getName());
142:                            }
143:                        }
144:                    };
145:                    account.getDataManager().addChangeListener(
146:                            accountNameChangeListener);
147:                }
148:
149:                ActionGroup ag = new UndoRedoActionGroup(
150:                //				getSite(), 
151:                        site, getSite().getWorkbenchWindow().getWorkbench()
152:                                .getOperationSupport().getUndoContext(), true);
153:                ag.fillActionBars(site.getActionBars());
154:            }
155:
156:            /* (non-Javadoc)
157:             * @see org.eclipse.ui.ISaveablePart#doSave(org.eclipse.core.runtime.IProgressMonitor)
158:             */
159:            @Override
160:            public void doSave(IProgressMonitor monitor) {
161:                // TODO Auto-generated method stub
162:            }
163:
164:            /* (non-Javadoc)
165:             * @see org.eclipse.ui.ISaveablePart#doSaveAs()
166:             */
167:            @Override
168:            public void doSaveAs() {
169:                throw new RuntimeException("Illegal invocation");
170:            }
171:
172:            /* (non-Javadoc)
173:             * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
174:             */
175:            @Override
176:            public boolean isSaveAsAllowed() {
177:                return false;
178:            }
179:
180:            /**
181:             * @return
182:             */
183:            public Object getSelectedObject() {
184:                return navigationTreeNode;
185:            }
186:
187:            /**
188:             * @param extendableObject
189:             */
190:            public static void openEditor(IWorkbenchWindow window,
191:                    ExtendableObject extendableObject) {
192:                ExtendablePropertySet<?> propertySet = PropertySet
193:                        .getPropertySet(extendableObject.getClass());
194:                Vector<PageEntry> pages = propertySet.getPageFactories();
195:
196:                // Create an editor for this node (or active if an editor
197:                // is already open).  However, if no pages are registered for this
198:                // node then do nothing.
199:                if (!pages.isEmpty()) {
200:                    try {
201:                        IEditorInput editorInput = new NodeEditorInput(
202:                                extendableObject, extendableObject.toString(),
203:                                propertySet.getIcon(), pages, null);
204:                        window.getActivePage().openEditor(editorInput,
205:                                "net.sf.jmoney.genericEditor");
206:                    } catch (PartInitException e) {
207:                        JMoneyPlugin.log(e);
208:                    }
209:                }
210:            }
211:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.