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