Source Code Cross Referenced for AbstractEditor.java in  » Net » hyperpool-0.4.0 » vicazh » hyperpool » 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 » Net » hyperpool 0.4.0 » vicazh.hyperpool 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package vicazh.hyperpool;
002:
003:        import java.util.*;
004:        import javax.management.*;
005:        import javax.swing.tree.*;
006:
007:        /**
008:         * The abstract editor
009:         * 
010:         * @author Victor Zhigunov
011:         * @version 0.4.0
012:         */
013:        abstract public class AbstractEditor extends
014:                NotificationBroadcasterSupport {
015:
016:            protected Map<Integer, DefaultMutableTreeNode> map = new HashMap<Integer, DefaultMutableTreeNode>();
017:
018:            protected DefaultMutableTreeNode node;
019:
020:            protected void remove() {
021:                Object object = node.getUserObject();
022:                parent = (DefaultMutableTreeNode) node.getParent();
023:                i = parent.getIndex(node);
024:                if (!(object instanceof  GroupMBean)
025:                        && object instanceof  LineMBean) {
026:                    ((GroupMBean) parent.getUserObject()).getObjects()
027:                            .remove(i);
028:                    DefaultMutableTreeNode snode = parent.getNextSibling();
029:                    if (snode != null)
030:                        ((SelectorMBean) snode.getUserObject()).removed(i);
031:                } else {
032:                    DefaultMutableTreeNode nodenext = node.getPreviousSibling();
033:                    Object next = null;
034:                    if (nodenext != null)
035:                        next = nodenext.getUserObject();
036:                    if (next == null
037:                            && !(parent.getUserObject() instanceof  ProjectMBean)
038:                            && !(parent.getUserObject() instanceof  GroupMBean)
039:                            && parent.getUserObject() instanceof  LineMBean)
040:                        // object is last
041:                        next = ((GroupMBean) ((DefaultMutableTreeNode) parent
042:                                .getParent()).getUserObject()).getObject();
043:                    if (parent.getChildCount() == i + 1)
044:                        // element is first
045:                        prev(parent, next);
046:                    else
047:                        // element is not first
048:                        prev((DefaultMutableTreeNode) parent.getChildAt(i + 1),
049:                                next);
050:                }
051:            }
052:
053:            private void prev(DefaultMutableTreeNode prev, Object object) {
054:                Object o = prev.getUserObject();
055:                if (o instanceof  LineMBean) {
056:                    ((LineMBean) o).setObject(object);
057:                    if (o instanceof  GroupMBean)
058:                        // ends of lines
059:                        for (int i = 0; i < prev.getChildCount(); i++) {
060:                            DefaultMutableTreeNode n = (DefaultMutableTreeNode) prev
061:                                    .getChildAt(i);
062:                            if (n.getChildCount() == 0)
063:                                // line is empty
064:                                prev(n, object);
065:                            else
066:                                // last element
067:                                prev((DefaultMutableTreeNode) n.getChildAt(0),
068:                                        object);
069:                        }
070:                } else if (o instanceof  ServiceMBean)
071:                    ((ServiceMBean) o).setElement((ElementMBean) object);
072:                else
073:                    ((SelectorMBean) o).setGroup((GroupMBean) object);
074:            }
075:
076:            protected DefaultMutableTreeNode parent;
077:
078:            protected int i;
079:
080:            protected Object next;
081:
082:            protected void put(Object object) {
083:                parent = node;
084:                i = 0;
085:                next = node.getUserObject();
086:                if (next instanceof  ProjectMBean)
087:                    next = null;
088:                else if ((object instanceof  GroupMBean || !(object instanceof  LineMBean))
089:                        && !(next instanceof  GroupMBean)
090:                        && next instanceof  LineMBean)
091:                    // element into line
092:                    // line is current
093:                    next = ((GroupMBean) ((DefaultMutableTreeNode) node
094:                            .getParent()).getUserObject()).getObject();
095:                else if (object instanceof  LineMBean
096:                        && next instanceof  GroupMBean)
097:                    // line into group
098:                    // group is current
099:                    next = ((GroupMBean) next).getObject();
100:                else if (object instanceof  LineMBean
101:                        && next instanceof  LineMBean) {
102:                    // line into group
103:                    // line is current
104:                    parent = (DefaultMutableTreeNode) node.getParent();
105:                    i = parent.getIndex(node) + 1;
106:                    next = ((GroupMBean) ((DefaultMutableTreeNode) node
107:                            .getParent()).getUserObject()).getObject();
108:                    node = node.getLastLeaf();
109:                } else {
110:                    parent = (DefaultMutableTreeNode) node.getParent();
111:                    i = parent.getIndex(node) + 1;
112:                    node = node.getLastLeaf();
113:                }
114:                if (!(object instanceof  GroupMBean)
115:                        && object instanceof  LineMBean) {
116:                    ((LineMBean) object).setObject(next);
117:                    ((GroupMBean) parent.getUserObject()).getObjects().add(i,
118:                            (LineMBean) object);
119:                    DefaultMutableTreeNode snode = parent.getNextSibling();
120:                    if (snode != null)
121:                        ((SelectorMBean) snode.getUserObject()).added(i);
122:                } else {
123:                    if (object instanceof  SelectorMBean)
124:                        ((SelectorMBean) object).setGroup((GroupMBean) next);
125:                    else if (object instanceof  ServiceMBean)
126:                        ((ServiceMBean) object).setElement((ElementMBean) next);
127:                    else
128:                        ((LineMBean) object).setObject(next);
129:                    if (parent.getChildCount() == i)
130:                        // element is first
131:                        prev(parent, object);
132:                    else
133:                        // element is not first
134:                        prev((DefaultMutableTreeNode) parent.getChildAt(i),
135:                                object);
136:                }
137:            }
138:
139:            protected void stop() throws Exception {
140:                node = null;
141:            }
142:
143:            public void upLine() {
144:                if (node.getUserObject() instanceof  GroupMBean
145:                        || !(node.getUserObject() instanceof  LineMBean))
146:                    node = (DefaultMutableTreeNode) node.getParent();
147:            }
148:
149:            public void upGroup() {
150:                if (node.getUserObject() instanceof  LineMBean)
151:                    node = (DefaultMutableTreeNode) node.getParent();
152:            }
153:
154:            abstract protected void move(DefaultMutableTreeNode node1,
155:                    DefaultMutableTreeNode node2);
156:
157:            void up(int currentID) {
158:                DefaultMutableTreeNode c = map.get(currentID);
159:                DefaultMutableTreeNode n = c.getPreviousSibling();
160:                if (n.getUserObject() instanceof  SelectorMBean)
161:                    n = n.getPreviousSibling().getPreviousNode();
162:                else {
163:                    DefaultMutableTreeNode p = n.getPreviousSibling();
164:                    n = p == null ? n.getPreviousNode() : p;
165:                }
166:                move(c, n);
167:            }
168:
169:            void down(int currentID) {
170:                DefaultMutableTreeNode c = map.get(currentID);
171:                DefaultMutableTreeNode n = c.getNextSibling();
172:                if (n.getUserObject() instanceof  GroupMBean)
173:                    n = n.getNextSibling();
174:                move(c, n);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.