Source Code Cross Referenced for BoxPart.java in  » GIS » udig-1.1 » net » refractions » udig » printing » ui » internal » editor » parts » 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 » GIS » udig 1.1 » net.refractions.udig.printing.ui.internal.editor.parts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *    uDig - User Friendly Desktop Internet GIS client
003:         *    http://udig.refractions.net
004:         *    (C) 2004, Refractions Research Inc.
005:         *
006:         *    This library is free software; you can redistribute it and/or
007:         *    modify it under the terms of the GNU Lesser General Public
008:         *    License as published by the Free Software Foundation;
009:         *    version 2.1 of the License.
010:         *
011:         *    This library is distributed in the hope that it will be useful,
012:         *    but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *    Lesser General Public License for more details.
015:         *
016:         */
017:        package net.refractions.udig.printing.ui.internal.editor.parts;
018:
019:        import java.util.List;
020:
021:        import net.refractions.udig.printing.model.Box;
022:        import net.refractions.udig.printing.model.BoxPrinter;
023:        import net.refractions.udig.printing.model.Connection;
024:        import net.refractions.udig.printing.model.PropertyListener;
025:        import net.refractions.udig.printing.ui.IBoxEditAction;
026:        import net.refractions.udig.printing.ui.internal.PrintingPlugin;
027:        import net.refractions.udig.printing.ui.internal.editor.BoxAction;
028:        import net.refractions.udig.printing.ui.internal.editor.commands.ConnectionCreateCommand;
029:        import net.refractions.udig.printing.ui.internal.editor.commands.ConnectionReconnectCommand;
030:        import net.refractions.udig.printing.ui.internal.editor.figures.BoxFigure;
031:        import net.refractions.udig.printing.ui.internal.editor.policies.PageElementEditPolicy;
032:
033:        import org.eclipse.core.runtime.IAdaptable;
034:        import org.eclipse.draw2d.ChopboxAnchor;
035:        import org.eclipse.draw2d.ConnectionAnchor;
036:        import org.eclipse.draw2d.IFigure;
037:        import org.eclipse.draw2d.geometry.Dimension;
038:        import org.eclipse.draw2d.geometry.Point;
039:        import org.eclipse.draw2d.geometry.Rectangle;
040:        import org.eclipse.gef.ConnectionEditPart;
041:        import org.eclipse.gef.EditPolicy;
042:        import org.eclipse.gef.GraphicalEditPart;
043:        import org.eclipse.gef.NodeEditPart;
044:        import org.eclipse.gef.Request;
045:        import org.eclipse.gef.commands.Command;
046:        import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
047:        import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
048:        import org.eclipse.gef.requests.CreateConnectionRequest;
049:        import org.eclipse.gef.requests.ReconnectRequest;
050:        import org.eclipse.jface.util.IPropertyChangeListener;
051:        import org.eclipse.jface.util.PropertyChangeEvent;
052:        import org.eclipse.swt.widgets.Display;
053:
054:        /**
055:         * A part for all boxes.
056:         * 
057:         * @author Richard Gould
058:         * @author Jesse
059:         * @since 0.3
060:         */
061:        public class BoxPart extends AbstractGraphicalEditPart implements 
062:                NodeEditPart, IAdaptable {
063:
064:            protected InternalPropertyListener listener = new InternalPropertyListener();
065:
066:            @SuppressWarnings("unchecked")
067:            public void activate() {
068:                if (isActive()) {
069:                    return;
070:                }
071:
072:                super .activate();
073:                Box box = ((Box) getModel());
074:                box.eAdapters().add(this .listener);
075:                box.addPropertyChangeListener(listener);
076:            }
077:
078:            public void deactivate() {
079:                if (!isActive()) {
080:                    return;
081:                }
082:                super .deactivate();
083:                Box box = ((Box) getModel());
084:                box.eAdapters().remove(this .listener);
085:                box.removePropertyChangeListener(listener);
086:            }
087:
088:            @Override
089:            public Object getAdapter(Class key) {
090:                Box box = ((Box) getModel());
091:                if (box instanceof  IAdaptable) {
092:                    Object obj = ((IAdaptable) box).getAdapter(key);
093:                    if (obj != null) {
094:                        return obj;
095:                    }
096:                }
097:                return super .getAdapter(key);
098:            }
099:
100:            protected void refreshVisuals() {
101:                Box labelBox = (Box) this .getModel();
102:                Point loc = labelBox.getLocation();
103:                Dimension size = labelBox.getSize();
104:                Rectangle rectangle = new Rectangle(loc, size);
105:
106:                ((BoxFigure) this .getFigure()).setBox((Box) this .getModel());
107:
108:                ((GraphicalEditPart) getParent()).setLayoutConstraint(this ,
109:                        getFigure(), rectangle);
110:            }
111:
112:            public BoxPrinter getBoxPrinter() {
113:                return ((Box) getModel()).getBoxPrinter();
114:            }
115:
116:            public void performRequest(Request request) {
117:                EditPolicy policy = getEditPolicy(request.getType());
118:                if (policy instanceof  PrintingEditPolicy) {
119:                    PrintingEditPolicy editPolicy = (PrintingEditPolicy) policy;
120:                    IBoxEditAction action = editPolicy.getAction()
121:                            .getBoxEditAction();
122:                    action.init(this );
123:                    action.perform();
124:                    Display display = getViewer().getControl().getDisplay();
125:                    while (!action.isDone()) {
126:                        if (!display.readAndDispatch()) {
127:                            try {
128:                                Thread.sleep(200);
129:                            } catch (InterruptedException e) {
130:                                break;
131:                            }
132:                        }
133:                    }
134:                    if (!action.isDone())
135:                        return;
136:
137:                    Command command = action.getCommand();
138:
139:                    if (command != null && command.canExecute()) {
140:                        getViewer().getEditDomain().getCommandStack().execute(
141:                                command);
142:                    }
143:                }
144:            }
145:
146:            protected List getModelSourceConnections() {
147:                return ((Box) getModel()).getSourceConnections();
148:            }
149:
150:            protected List getModelTargetConnections() {
151:                return ((Box) getModel()).getTargetConnections();
152:            }
153:
154:            protected void createEditPolicies() {
155:                installEditPolicy(EditPolicy.COMPONENT_ROLE,
156:                        new PageElementEditPolicy());
157:                installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
158:                        new GraphicalNodeEditPolicy() {
159:
160:                            protected Command getConnectionCompleteCommand(
161:                                    CreateConnectionRequest request) {
162:                                ConnectionCreateCommand cmd = (ConnectionCreateCommand) request
163:                                        .getStartCommand();
164:                                cmd.setTarget((Box) getHost().getModel());
165:                                return cmd;
166:                            }
167:
168:                            protected Command getConnectionCreateCommand(
169:                                    CreateConnectionRequest request) {
170:                                Box source = (Box) getHost().getModel();
171:                                ConnectionCreateCommand cmd = new ConnectionCreateCommand(
172:                                        source);
173:                                request.setStartCommand(cmd);
174:                                return cmd;
175:                            }
176:
177:                            protected Command getReconnectTargetCommand(
178:                                    ReconnectRequest request) {
179:                                Connection conn = (Connection) request
180:                                        .getConnectionEditPart().getModel();
181:                                Box newTarget = (Box) getHost().getModel();
182:                                ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(
183:                                        conn);
184:                                cmd.setNewTarget(newTarget);
185:                                return cmd;
186:                            }
187:
188:                            protected Command getReconnectSourceCommand(
189:                                    ReconnectRequest request) {
190:                                Connection conn = (Connection) request
191:                                        .getConnectionEditPart().getModel();
192:                                Box newSource = (Box) getHost().getModel();
193:                                ConnectionReconnectCommand cmd = new ConnectionReconnectCommand(
194:                                        conn);
195:                                cmd.setNewSource(newSource);
196:                                return cmd;
197:                            }
198:
199:                        });
200:
201:                List<BoxAction> list = PrintingPlugin
202:                        .getBoxExtensionActions(null);
203:                for (BoxAction element : list) {
204:                    try {
205:                        Class<? extends BoxPrinter> class1 = ((Box) getModel())
206:                                .getBoxPrinter().getClass();
207:                        Class<? extends BoxPrinter> c = element
208:                                .getAcceptablePrinterClass(class1);
209:                        if (c != null && c.isAssignableFrom(class1)) {
210:
211:                            EditPolicy policyObj = element.getEditPolicy();
212:                            installEditPolicy(element.getRequest().getType(),
213:                                    policyObj);
214:
215:                        }
216:                    } catch (Throwable e) {
217:                        continue;
218:                    }
219:                }
220:
221:            }
222:
223:            protected IFigure createFigure() {
224:                return new BoxFigure();
225:            }
226:
227:            public ConnectionAnchor getSourceConnectionAnchor(
228:                    ConnectionEditPart connection) {
229:                return new ChopboxAnchor(getFigure());
230:            }
231:
232:            public ConnectionAnchor getSourceConnectionAnchor(Request request) {
233:                return new ChopboxAnchor(getFigure());
234:            }
235:
236:            public ConnectionAnchor getTargetConnectionAnchor(
237:                    ConnectionEditPart connection) {
238:                return new ChopboxAnchor(getFigure());
239:            }
240:
241:            public ConnectionAnchor getTargetConnectionAnchor(Request request) {
242:                return new ChopboxAnchor(getFigure());
243:            }
244:
245:            protected class InternalPropertyListener extends PropertyListener
246:                    implements  IPropertyChangeListener {
247:
248:                protected void textChanged() {
249:                    refreshVisuals();
250:                }
251:
252:                protected void locationChanged() {
253:                    refreshVisuals();
254:                }
255:
256:                protected void sizeChanged() {
257:                    refreshVisuals();
258:                }
259:
260:                public void propertyChange(PropertyChangeEvent event) {
261:                    refreshVisuals();
262:                }
263:            }
264:        }
w__w__w.___java__2___s__._c__om | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.