Source Code Cross Referenced for HTTPNameEditPart.java in  » ESB » cbesb-1.2 » com » bostechcorp » cbesb » ui » componentflow » componentFlowEditor » diagram » edit » 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 » ESB » cbesb 1.2 » com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.parts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * ChainBuilder ESB
003:         *          Visual Enterprise Integration
004:         * 
005:         * Copyright (C) 2006 Bostech Corporation
006:         * 
007:         * This program is free software; you can redistribute it and/or modify it 
008:         * under the terms of the GNU General Public License as published by the 
009:         * Free Software Foundation; either version 2 of the License, or (at your option) 
010:         * 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 MERCHANTABILITY 
014:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 
015:         * for more details.
016:         * 
017:         * You should have received a copy of the GNU General Public License along with 
018:         * this program; if not, write to the Free Software Foundation, Inc., 
019:         * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
020:         *
021:         *
022:         * $Id$
023:         */
024:        package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.parts;
025:
026:        import java.text.MessageFormat;
027:        import java.text.ParseException;
028:
029:        import org.eclipse.draw2d.IFigure;
030:        import org.eclipse.draw2d.Label;
031:        import org.eclipse.draw2d.geometry.Rectangle;
032:        import org.eclipse.emf.ecore.EAttribute;
033:        import org.eclipse.emf.edit.command.SetCommand;
034:        import org.eclipse.emf.transaction.TransactionalEditingDomain;
035:        import org.eclipse.emf.transaction.util.TransactionUtil;
036:        import org.eclipse.gef.EditPart;
037:        import org.eclipse.gef.EditPolicy;
038:        import org.eclipse.gef.Request;
039:        import org.eclipse.gef.RequestConstants;
040:        import org.eclipse.gef.commands.Command;
041:        import org.eclipse.gef.commands.UnexecutableCommand;
042:        import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
043:        import org.eclipse.gef.editpolicies.DirectEditPolicy;
044:        import org.eclipse.gef.requests.DirectEditRequest;
045:        import org.eclipse.gef.tools.CellEditorLocator;
046:        import org.eclipse.gef.tools.DirectEditManager;
047:        import org.eclipse.gmf.runtime.notation.FontStyle;
048:        import org.eclipse.gmf.runtime.notation.NotationPackage;
049:        import org.eclipse.gmf.runtime.notation.View;
050:        import org.eclipse.jface.resource.ImageDescriptor;
051:
052:        import org.eclipse.jface.viewers.CellEditor;
053:        import org.eclipse.jface.viewers.TextCellEditor;
054:        import org.eclipse.swt.SWT;
055:        import org.eclipse.swt.graphics.Color;
056:        import org.eclipse.swt.graphics.Font;
057:        import org.eclipse.swt.graphics.FontData;
058:        import org.eclipse.swt.graphics.Image;
059:
060:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.HTTP;
061:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.componentflowPackage;
062:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
063:
064:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.providers.ComponentFlowEditorAbstractParser;
065:
066:        /**
067:         * @generated
068:         */
069:        public class HTTPNameEditPart extends AbstractGraphicalEditPart {
070:
071:            /**
072:             * @generated
073:             */
074:            public static final int VISUAL_ID = 5003;
075:
076:            /**
077:             * @generated
078:             */
079:            private DirectEditManager manager;
080:
081:            /**
082:             * @generated
083:             */
084:            private String defaultText;
085:
086:            /**
087:             * @generated
088:             */
089:            public HTTPNameEditPart(View view) {
090:                setModel(view);
091:            }
092:
093:            /**
094:             * @generated NOT
095:             */
096:            protected void createEditPolicies() {/*
097:            		installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new DirectEditPolicy() {
098:            			protected void showCurrentEditValue(DirectEditRequest request) {
099:            				String value = (String) request.getCellEditor().getValue();
100:            				getLabel().setText(value);
101:            			}
102:
103:            			protected Command getDirectEditCommand(DirectEditRequest request) {
104:            				String value = (String) request.getCellEditor().getValue();
105:            				if (value == null) {
106:            					//Invalid value is transformed into a null by the validator.
107:            					//XXX: implement validator
108:            					return UnexecutableCommand.INSTANCE;
109:            				}
110:            				final Object[] parseResult;
111:            				try {
112:            					parseResult = new MessageFormat(EDIT_PATTERN).parse(value);
113:            				} catch (IllegalArgumentException e) {
114:            					return UnexecutableCommand.INSTANCE;
115:            				} catch (ParseException e) {
116:            					return UnexecutableCommand.INSTANCE;
117:            				}
118:            				TransactionalEditingDomain editingDomain = TransactionUtil
119:            						.getEditingDomain(getUpdatableParent().getDiagramNode()
120:            								.getDiagram().getElement());
121:            				if (parseResult.length != 1) {
122:            					return UnexecutableCommand.INSTANCE;
123:            				}
124:            				org.eclipse.emf.common.command.Command domainModelCommand = createDomainModelCommand(
125:            						editingDomain, parseResult[0]);
126:            				return new WrappingCommand(editingDomain, domainModelCommand);
127:            			}
128:
129:            			org.eclipse.emf.common.command.Command createDomainModelCommand(
130:            					TransactionalEditingDomain editingDomain, Object value) {
131:            				HTTP element = resolveSemanticElement();
132:            				EAttribute feature = (EAttribute) componentflowPackage.eINSTANCE
133:            						.getBaseElement_Name();
134:            				Object valueToSet;
135:            				try {
136:            					valueToSet = ComponentFlowEditorAbstractParser.parseValue(
137:            							feature, value);
138:            				} catch (IllegalArgumentException e) {
139:            					return org.eclipse.emf.common.command.UnexecutableCommand.INSTANCE;
140:            				}
141:            				return SetCommand.create(editingDomain, element, feature,
142:            						valueToSet);
143:            			}
144:            		});
145:             */
146:            }
147:
148:            /**
149:             * @generated
150:             */
151:            public void performRequest(Request req) {
152:                if (RequestConstants.REQ_DIRECT_EDIT == req.getType()) {
153:                    performDirectEdit();
154:                } else {
155:                    super .performRequest(req);
156:                }
157:            }
158:
159:            /**
160:             * @generated
161:             */
162:            protected DirectEditManager getManager() {
163:                if (manager == null) {
164:                    manager = new DirectEditManager(this , TextCellEditor.class,
165:                            new CellEditorLocator() {
166:                                public void relocate(CellEditor celleditor) {
167:                                    Rectangle rect = getLabel().getTextBounds();
168:                                    getLabel().translateToAbsolute(rect);
169:                                    celleditor.getControl().setBounds(rect.x,
170:                                            rect.y, rect.width, rect.height);
171:                                }
172:                            }) {
173:                        protected void initCellEditor() {
174:                            getCellEditor().setValue(getLabelEditText());
175:                        }
176:                    };
177:                }
178:                return manager;
179:            }
180:
181:            /**
182:             * @generated NOT
183:             * 
184:             */
185:            protected void performDirectEdit() {
186:                //getManager().show();
187:            }
188:
189:            /**
190:             * @generated
191:             */
192:            protected void refreshVisuals() {
193:                super .refreshVisuals();
194:                refreshLabel();
195:                refreshFont();
196:                refreshFontColor();
197:            }
198:
199:            /**
200:             * @generated
201:             */
202:            protected void refreshLabel() {
203:                getLabel().setText(getLabelText());
204:                getLabel().setIcon(getLabelIcon());
205:            }
206:
207:            /**
208:             * @generated
209:             */
210:            private static final String VIEW_PATTERN = "{0}";
211:
212:            /**
213:             * @generated
214:             */
215:            private static final String EDIT_PATTERN = "{0}";
216:
217:            /**
218:             * @generated
219:             */
220:            protected String getLabelText() {
221:                HTTP element = resolveSemanticElement();
222:                if (element == null) {
223:                    return defaultText;
224:                }
225:                return buildTextByPattern(element, VIEW_PATTERN);
226:            }
227:
228:            /**
229:             * @generated
230:             */
231:            protected String getLabelEditText() {
232:                HTTP element = resolveSemanticElement();
233:                if (element == null) {
234:                    return defaultText;
235:                }
236:                return buildTextByPattern(element, EDIT_PATTERN);
237:            }
238:
239:            /**
240:             * @generated
241:             */
242:            protected String buildTextByPattern(HTTP element, String pattern) {
243:                if (element.getName() == null) {
244:                    return defaultText;
245:                }
246:                return MessageFormat.format(pattern, new Object[] { element
247:                        .getName() });
248:            }
249:
250:            /**
251:             * @generated
252:             */
253:            protected void refreshFont() {
254:                FontStyle style = (FontStyle) getUpdatableParent()
255:                        .getDiagramNode().getStyle(
256:                                NotationPackage.eINSTANCE.getFontStyle());
257:                Font toDispose = createdFont;
258:                if (style != null) {
259:                    String fontName = style.getFontName();
260:                    int fontHeight = style.getFontHeight();
261:                    int fontStyle = SWT.NORMAL;
262:                    if (style.isBold()) {
263:                        fontStyle |= SWT.BOLD;
264:                    }
265:                    if (style.isItalic()) {
266:                        fontStyle |= SWT.ITALIC;
267:                    }
268:                    Font currentFont = getFigure().getFont();
269:                    if (currentFont != null) {
270:                        FontData currentFontData = currentFont.getFontData()[0];
271:                        if (currentFontData.getName().equals(fontName)
272:                                && currentFontData.getHeight() == fontHeight
273:                                && currentFontData.getStyle() == fontStyle) {
274:                            return;
275:                        }
276:                    }
277:                    createdFont = new Font(null, fontName, fontHeight,
278:                            fontStyle);
279:                    getFigure().setFont(createdFont);
280:                } else {
281:                    //revert to the default font
282:                    getFigure().setFont(getViewer().getControl().getFont());
283:                    createdFont = null;
284:                }
285:                if (toDispose != null) {
286:                    toDispose.dispose();
287:                }
288:            }
289:
290:            /**
291:             * The font (created by {@link #refreshFont()}) currently assigned to the label (unless the default font is assigned).
292:             * Whenever another non-default font is assigned to it, it is safe to dispose the previous one.
293:             * @generated
294:             */
295:            private Font createdFont;
296:
297:            /**
298:             * @generated
299:             */
300:            protected void refreshFontColor() {
301:                FontStyle style = (FontStyle) getUpdatableParent()
302:                        .getDiagramNode().getStyle(
303:                                NotationPackage.eINSTANCE.getFontStyle());
304:                Color toDispose = createdFontColor;
305:                if (style != null) {
306:                    int fontColor = style.getFontColor();
307:                    int red = fontColor & 0x000000FF;
308:                    int green = (fontColor & 0x0000FF00) >> 8;
309:                    int blue = (fontColor & 0x00FF0000) >> 16;
310:                    Color currentColor = getLabel().getForegroundColor();
311:                    if (currentColor != null && currentColor.getRed() == red
312:                            && currentColor.getGreen() == green
313:                            && currentColor.getBlue() == blue) {
314:                        return;
315:                    }
316:                    createdFontColor = new Color(null, red, green, blue);
317:                    getFigure().setForegroundColor(createdFontColor);
318:                } else {
319:                    getFigure().setForegroundColor(
320:                            getViewer().getControl().getForeground());
321:                    createdFontColor = null;
322:                }
323:                if (toDispose != null) {
324:                    toDispose.dispose();
325:                }
326:            }
327:
328:            /**
329:             * The color (created by {@link #refreshFontColor()}) currently assigned to the label.
330:             * Whenever another color is assigned to it, it is safe to dispose the previous one.
331:             * @generated
332:             */
333:            private Color createdFontColor;
334:
335:            /**
336:             * @generated NOT
337:             */
338:            protected Image getLabelIcon() {
339:                /*HTTP element = resolveSemanticElement();
340:                 ImageDescriptor imageDescriptor = ComponentFlowEditorDiagramEditorPlugin
341:                 .getInstance().getItemImageDescriptor(element);
342:                 if (imageDescriptor != null) {
343:                 return imageDescriptor.createImage();
344:                 }
345:                 return ImageDescriptor.getMissingImageDescriptor().createImage();*/
346:                return null;
347:            }
348:
349:            /**
350:             * @generated
351:             */
352:            private HTTP resolveSemanticElement() {
353:                for (EditPart editPart = this ; editPart != null; editPart = editPart
354:                        .getParent()) {
355:                    View view = (View) editPart.getModel();
356:                    if (view != null && view.getElement() != null) {
357:                        return (HTTP) view.getElement();
358:                    }
359:                }
360:                return null;
361:            }
362:
363:            /**
364:             * @generated
365:             */
366:            private HTTPEditPart getUpdatableParent() {
367:                for (EditPart editPart = getParent(); editPart != null; editPart = editPart
368:                        .getParent()) {
369:                    if (editPart instanceof  HTTPEditPart) {
370:                        return (HTTPEditPart) editPart;
371:                    }
372:                }
373:                return null;
374:            }
375:
376:            /**
377:             * @generated
378:             */
379:            public void activate() {
380:                super .activate();
381:                HTTPEditPart updatableParent = getUpdatableParent();
382:                if (updatableParent != null) {
383:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
384:                            .getFontStyle_FontColor(), fontColorRefresher);
385:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
386:                            .getFontStyle_FontHeight(), fontRefresher);
387:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
388:                            .getFontStyle_FontName(), fontRefresher);
389:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
390:                            .getFontStyle_Bold(), fontRefresher);
391:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
392:                            .getFontStyle_Italic(), fontRefresher);
393:                    updatableParent.addRefresher(componentflowPackage.eINSTANCE
394:                            .getBaseElement_Name(), labelRefresher);
395:                }
396:            }
397:
398:            /**
399:             * @generated
400:             */
401:            public void deactivate() {
402:                super .deactivate();
403:                HTTPEditPart updatableParent = getUpdatableParent();
404:                if (updatableParent != null) {
405:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
406:                            .getFontStyle_FontColor(), fontColorRefresher);
407:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
408:                            .getFontStyle_FontHeight(), fontRefresher);
409:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
410:                            .getFontStyle_FontName(), fontRefresher);
411:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
412:                            .getFontStyle_Bold(), fontRefresher);
413:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
414:                            .getFontStyle_Italic(), fontRefresher);
415:                    updatableParent.removeRefresher(
416:                            componentflowPackage.eINSTANCE
417:                                    .getBaseElement_Name(), labelRefresher);
418:                }
419:            }
420:
421:            /**
422:             * @generated
423:             */
424:            private IUpdatableEditPart.Refresher labelRefresher = new IUpdatableEditPart.Refresher() {
425:                public void refresh() {
426:                    refreshLabel();
427:                }
428:            };
429:
430:            /**
431:             * @generated
432:             */
433:            private IUpdatableEditPart.Refresher fontColorRefresher = new IUpdatableEditPart.Refresher() {
434:                public void refresh() {
435:                    refreshFontColor();
436:                }
437:            };
438:
439:            /**
440:             * @generated
441:             */
442:            private IUpdatableEditPart.Refresher fontRefresher = new IUpdatableEditPart.Refresher() {
443:                public void refresh() {
444:                    refreshFont();
445:                }
446:            };
447:
448:            /**
449:             * @generated
450:             */
451:            protected IFigure createFigure() {
452:                // Parent should assign one using setLabel method
453:                return null;
454:            }
455:
456:            /**
457:             * @generated
458:             */
459:            public Label getLabel() {
460:                return (Label) getFigure();
461:            }
462:
463:            /**
464:             * @generated
465:             */
466:            public void setLabel(Label figure) {
467:                unregisterVisuals();
468:                setFigure(figure);
469:                defaultText = figure.getText();
470:                registerVisuals();
471:                refreshVisuals();
472:            }
473:
474:        }
w__w_w___.__ja_v___a___2___s__._c_o__m___ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.