Source Code Cross Referenced for XSLTNameEditPart.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.XSLT;
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 XSLTNameEditPart extends AbstractGraphicalEditPart {
070:
071:            /**
072:             * @generated
073:             */
074:            public static final int VISUAL_ID = 5004;
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 XSLTNameEditPart(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:            				XSLT 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:            protected void performDirectEdit() {
185:                //getManager().show();
186:            }
187:
188:            /**
189:             * @generated
190:             */
191:            protected void refreshVisuals() {
192:                super .refreshVisuals();
193:                refreshLabel();
194:                refreshFont();
195:                refreshFontColor();
196:            }
197:
198:            /**
199:             * @generated
200:             */
201:            protected void refreshLabel() {
202:                getLabel().setText(getLabelText());
203:                getLabel().setIcon(getLabelIcon());
204:            }
205:
206:            /**
207:             * @generated
208:             */
209:            private static final String VIEW_PATTERN = "{0}";
210:
211:            /**
212:             * @generated
213:             */
214:            private static final String EDIT_PATTERN = "{0}";
215:
216:            /**
217:             * @generated
218:             */
219:            protected String getLabelText() {
220:                XSLT element = resolveSemanticElement();
221:                if (element == null) {
222:                    return defaultText;
223:                }
224:                return buildTextByPattern(element, VIEW_PATTERN);
225:            }
226:
227:            /**
228:             * @generated
229:             */
230:            protected String getLabelEditText() {
231:                XSLT element = resolveSemanticElement();
232:                if (element == null) {
233:                    return defaultText;
234:                }
235:                return buildTextByPattern(element, EDIT_PATTERN);
236:            }
237:
238:            /**
239:             * @generated
240:             */
241:            protected String buildTextByPattern(XSLT element, String pattern) {
242:                if (element.getName() == null) {
243:                    return defaultText;
244:                }
245:                return MessageFormat.format(pattern, new Object[] { element
246:                        .getName() });
247:            }
248:
249:            /**
250:             * @generated
251:             */
252:            protected void refreshFont() {
253:                FontStyle style = (FontStyle) getUpdatableParent()
254:                        .getDiagramNode().getStyle(
255:                                NotationPackage.eINSTANCE.getFontStyle());
256:                Font toDispose = createdFont;
257:                if (style != null) {
258:                    String fontName = style.getFontName();
259:                    int fontHeight = style.getFontHeight();
260:                    int fontStyle = SWT.NORMAL;
261:                    if (style.isBold()) {
262:                        fontStyle |= SWT.BOLD;
263:                    }
264:                    if (style.isItalic()) {
265:                        fontStyle |= SWT.ITALIC;
266:                    }
267:                    Font currentFont = getFigure().getFont();
268:                    if (currentFont != null) {
269:                        FontData currentFontData = currentFont.getFontData()[0];
270:                        if (currentFontData.getName().equals(fontName)
271:                                && currentFontData.getHeight() == fontHeight
272:                                && currentFontData.getStyle() == fontStyle) {
273:                            return;
274:                        }
275:                    }
276:                    createdFont = new Font(null, fontName, fontHeight,
277:                            fontStyle);
278:                    getFigure().setFont(createdFont);
279:                } else {
280:                    //revert to the default font
281:                    getFigure().setFont(getViewer().getControl().getFont());
282:                    createdFont = null;
283:                }
284:                if (toDispose != null) {
285:                    toDispose.dispose();
286:                }
287:            }
288:
289:            /**
290:             * The font (created by {@link #refreshFont()}) currently assigned to the label (unless the default font is assigned).
291:             * Whenever another non-default font is assigned to it, it is safe to dispose the previous one.
292:             * @generated
293:             */
294:            private Font createdFont;
295:
296:            /**
297:             * @generated
298:             */
299:            protected void refreshFontColor() {
300:                FontStyle style = (FontStyle) getUpdatableParent()
301:                        .getDiagramNode().getStyle(
302:                                NotationPackage.eINSTANCE.getFontStyle());
303:                Color toDispose = createdFontColor;
304:                if (style != null) {
305:                    int fontColor = style.getFontColor();
306:                    int red = fontColor & 0x000000FF;
307:                    int green = (fontColor & 0x0000FF00) >> 8;
308:                    int blue = (fontColor & 0x00FF0000) >> 16;
309:                    Color currentColor = getLabel().getForegroundColor();
310:                    if (currentColor != null && currentColor.getRed() == red
311:                            && currentColor.getGreen() == green
312:                            && currentColor.getBlue() == blue) {
313:                        return;
314:                    }
315:                    createdFontColor = new Color(null, red, green, blue);
316:                    getFigure().setForegroundColor(createdFontColor);
317:                } else {
318:                    getFigure().setForegroundColor(
319:                            getViewer().getControl().getForeground());
320:                    createdFontColor = null;
321:                }
322:                if (toDispose != null) {
323:                    toDispose.dispose();
324:                }
325:            }
326:
327:            /**
328:             * The color (created by {@link #refreshFontColor()}) currently assigned to the label.
329:             * Whenever another color is assigned to it, it is safe to dispose the previous one.
330:             * @generated
331:             */
332:            private Color createdFontColor;
333:
334:            /**
335:             * @generated NOT
336:             */
337:            protected Image getLabelIcon() {
338:                /*XSLT element = resolveSemanticElement();
339:                 ImageDescriptor imageDescriptor = ComponentFlowEditorDiagramEditorPlugin
340:                 .getInstance().getItemImageDescriptor(element);
341:                 if (imageDescriptor != null) {
342:                 return imageDescriptor.createImage();
343:                 }
344:                 return ImageDescriptor.getMissingImageDescriptor().createImage();*/
345:                return null;
346:            }
347:
348:            /**
349:             * @generated
350:             */
351:            private XSLT resolveSemanticElement() {
352:                for (EditPart editPart = this ; editPart != null; editPart = editPart
353:                        .getParent()) {
354:                    View view = (View) editPart.getModel();
355:                    if (view != null && view.getElement() != null) {
356:                        return (XSLT) view.getElement();
357:                    }
358:                }
359:                return null;
360:            }
361:
362:            /**
363:             * @generated
364:             */
365:            private XSLTEditPart getUpdatableParent() {
366:                for (EditPart editPart = getParent(); editPart != null; editPart = editPart
367:                        .getParent()) {
368:                    if (editPart instanceof  XSLTEditPart) {
369:                        return (XSLTEditPart) editPart;
370:                    }
371:                }
372:                return null;
373:            }
374:
375:            /**
376:             * @generated
377:             */
378:            public void activate() {
379:                super .activate();
380:                XSLTEditPart updatableParent = getUpdatableParent();
381:                if (updatableParent != null) {
382:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
383:                            .getFontStyle_FontColor(), fontColorRefresher);
384:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
385:                            .getFontStyle_FontHeight(), fontRefresher);
386:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
387:                            .getFontStyle_FontName(), fontRefresher);
388:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
389:                            .getFontStyle_Bold(), fontRefresher);
390:                    updatableParent.addRefresher(NotationPackage.eINSTANCE
391:                            .getFontStyle_Italic(), fontRefresher);
392:                    updatableParent.addRefresher(componentflowPackage.eINSTANCE
393:                            .getBaseElement_Name(), labelRefresher);
394:                }
395:            }
396:
397:            /**
398:             * @generated
399:             */
400:            public void deactivate() {
401:                super .deactivate();
402:                XSLTEditPart updatableParent = getUpdatableParent();
403:                if (updatableParent != null) {
404:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
405:                            .getFontStyle_FontColor(), fontColorRefresher);
406:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
407:                            .getFontStyle_FontHeight(), fontRefresher);
408:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
409:                            .getFontStyle_FontName(), fontRefresher);
410:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
411:                            .getFontStyle_Bold(), fontRefresher);
412:                    updatableParent.removeRefresher(NotationPackage.eINSTANCE
413:                            .getFontStyle_Italic(), fontRefresher);
414:                    updatableParent.removeRefresher(
415:                            componentflowPackage.eINSTANCE
416:                                    .getBaseElement_Name(), labelRefresher);
417:                }
418:            }
419:
420:            /**
421:             * @generated
422:             */
423:            private IUpdatableEditPart.Refresher labelRefresher = new IUpdatableEditPart.Refresher() {
424:                public void refresh() {
425:                    refreshLabel();
426:                }
427:            };
428:
429:            /**
430:             * @generated
431:             */
432:            private IUpdatableEditPart.Refresher fontColorRefresher = new IUpdatableEditPart.Refresher() {
433:                public void refresh() {
434:                    refreshFontColor();
435:                }
436:            };
437:
438:            /**
439:             * @generated
440:             */
441:            private IUpdatableEditPart.Refresher fontRefresher = new IUpdatableEditPart.Refresher() {
442:                public void refresh() {
443:                    refreshFont();
444:                }
445:            };
446:
447:            /**
448:             * @generated
449:             */
450:            protected IFigure createFigure() {
451:                // Parent should assign one using setLabel method
452:                return null;
453:            }
454:
455:            /**
456:             * @generated
457:             */
458:            public Label getLabel() {
459:                return (Label) getFigure();
460:            }
461:
462:            /**
463:             * @generated
464:             */
465:            public void setLabel(Label figure) {
466:                unregisterVisuals();
467:                setFigure(figure);
468:                defaultText = figure.getText();
469:                registerVisuals();
470:                refreshVisuals();
471:            }
472:
473:        }
w__w___w.__j__a_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.