Source Code Cross Referenced for TCPIPNameEditPart.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.TCPIP;
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 TCPIPNameEditPart extends AbstractGraphicalEditPart {
063:
064:            /**
065:             * @generated
066:             */
067:            public static final int VISUAL_ID = 5014;
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 TCPIPNameEditPart(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:            				TCPIP 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:                TCPIP 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:                TCPIP 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(TCPIP 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:                //		TCPIP 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:                return null;
339:            }
340:
341:            /**
342:             * @generated
343:             */
344:            private TCPIP resolveSemanticElement() {
345:                for (EditPart editPart = this ; editPart != null; editPart = editPart
346:                        .getParent()) {
347:                    View view = (View) editPart.getModel();
348:                    if (view != null && view.getElement() != null) {
349:                        return (TCPIP) view.getElement();
350:                    }
351:                }
352:                return null;
353:            }
354:
355:            /**
356:             * @generated
357:             */
358:            private TCPIPEditPart getUpdatableParent() {
359:                for (EditPart editPart = getParent(); editPart != null; editPart = editPart
360:                        .getParent()) {
361:                    if (editPart instanceof  TCPIPEditPart) {
362:                        return (TCPIPEditPart) editPart;
363:                    }
364:                }
365:                return null;
366:            }
367:
368:            /**
369:             * @generated
370:             */
371:            public void activate() {
372:                super .activate();
373:                TCPIPEditPart updatableParent = getUpdatableParent();
374:                if (updatableParent != null) {
375:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
376:                            .getFontStyle_FontColor(), fontColorRefresher);
377:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
378:                            .getFontStyle_FontHeight(), fontRefresher);
379:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
380:                            .getFontStyle_FontName(), fontRefresher);
381:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
382:                            .getFontStyle_Bold(), fontRefresher);
383:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
384:                            .getFontStyle_Italic(), fontRefresher);
385:                    updatableParent.addRefresher(componentflowPackage.eINSTANCE
386:                            .getBaseElement_Name(), labelRefresher);
387:                }
388:            }
389:
390:            /**
391:             * @generated
392:             */
393:            public void deactivate() {
394:                super .deactivate();
395:                TCPIPEditPart updatableParent = getUpdatableParent();
396:                if (updatableParent != null) {
397:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
398:                            .getFontStyle_FontColor(), fontColorRefresher);
399:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
400:                            .getFontStyle_FontHeight(), fontRefresher);
401:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
402:                            .getFontStyle_FontName(), fontRefresher);
403:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
404:                            .getFontStyle_Bold(), fontRefresher);
405:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
406:                            .getFontStyle_Italic(), fontRefresher);
407:                    updatableParent.removeRefresher(
408:                            componentflowPackage.eINSTANCE
409:                                    .getBaseElement_Name(), labelRefresher);
410:                }
411:            }
412:
413:            /**
414:             * @generated
415:             */
416:            private IUpdatableEditPart.Refresher labelRefresher = new IUpdatableEditPart.Refresher() {
417:                public void refresh() {
418:                    refreshLabel();
419:                }
420:            };
421:
422:            /**
423:             * @generated
424:             */
425:            private IUpdatableEditPart.Refresher fontColorRefresher = new IUpdatableEditPart.Refresher() {
426:                public void refresh() {
427:                    refreshFontColor();
428:                }
429:            };
430:
431:            /**
432:             * @generated
433:             */
434:            private IUpdatableEditPart.Refresher fontRefresher = new IUpdatableEditPart.Refresher() {
435:                public void refresh() {
436:                    refreshFont();
437:                }
438:            };
439:
440:            /**
441:             * @generated NOT
442:             */
443:            protected IFigure createFigure() {
444:                // Parent should assign one using setLabel method
445:                return null;
446:            }
447:
448:            /**
449:             * @generated
450:             */
451:            public Label getLabel() {
452:                return (Label) getFigure();
453:            }
454:
455:            /**
456:             * @generated
457:             */
458:            public void setLabel(Label figure) {
459:                unregisterVisuals();
460:                setFigure(figure);
461:                defaultText = figure.getText();
462:                registerVisuals();
463:                refreshVisuals();
464:            }
465:
466:        }
w__w__w__.___j___av___a2_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.