Source Code Cross Referenced for AsyncActivityName2EditPart.java in  » Workflow-Engines » osbl-1_0 » newprocess » 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 » Workflow Engines » osbl 1_0 » newprocess.diagram.edit.parts 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package newprocess.diagram.edit.parts;
002:
003:        import java.util.ArrayList;
004:        import java.util.Collections;
005:        import java.util.List;
006:
007:        import newprocess.diagram.edit.policies.New_processTextSelectionEditPolicy;
008:
009:        import org.eclipse.draw2d.IFigure;
010:        import org.eclipse.draw2d.Label;
011:        import org.eclipse.draw2d.geometry.Point;
012:        import org.eclipse.emf.common.notify.Notification;
013:        import org.eclipse.emf.ecore.EObject;
014:        import org.eclipse.emf.transaction.RunnableWithResult;
015:        import org.eclipse.gef.AccessibleEditPart;
016:        import org.eclipse.gef.EditPolicy;
017:        import org.eclipse.gef.GraphicalEditPart;
018:        import org.eclipse.gef.Request;
019:        import org.eclipse.gef.commands.Command;
020:        import org.eclipse.gef.editpolicies.NonResizableEditPolicy;
021:        import org.eclipse.gef.handles.NonResizableHandleKit;
022:        import org.eclipse.gef.requests.DirectEditRequest;
023:        import org.eclipse.gef.tools.DirectEditManager;
024:        import org.eclipse.gmf.runtime.common.ui.services.parser.IParser;
025:        import org.eclipse.gmf.runtime.common.ui.services.parser.IParserEditStatus;
026:        import org.eclipse.gmf.runtime.common.ui.services.parser.ParserEditStatus;
027:        import org.eclipse.gmf.runtime.common.ui.services.parser.ParserOptions;
028:        import org.eclipse.gmf.runtime.common.ui.services.parser.ParserService;
029:        import org.eclipse.gmf.runtime.diagram.ui.editparts.CompartmentEditPart;
030:        import org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart;
031:        import org.eclipse.gmf.runtime.diagram.ui.editparts.ITextAwareEditPart;
032:        import org.eclipse.gmf.runtime.diagram.ui.editpolicies.LabelDirectEditPolicy;
033:        import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
034:        import org.eclipse.gmf.runtime.diagram.ui.requests.RequestConstants;
035:        import org.eclipse.gmf.runtime.diagram.ui.tools.TextDirectEditManager;
036:        import org.eclipse.gmf.runtime.draw2d.ui.figures.WrapLabel;
037:        import org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter;
038:        import org.eclipse.gmf.runtime.emf.type.core.IElementType;
039:        import org.eclipse.gmf.runtime.emf.ui.services.parser.ISemanticParser;
040:        import org.eclipse.gmf.runtime.emf.ui.services.parser.ParserHintAdapter;
041:        import org.eclipse.gmf.runtime.notation.FontStyle;
042:        import org.eclipse.gmf.runtime.notation.NotationPackage;
043:        import org.eclipse.gmf.runtime.notation.View;
044:        import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
045:        import org.eclipse.jface.viewers.ICellEditorValidator;
046:        import org.eclipse.swt.accessibility.AccessibleEvent;
047:        import org.eclipse.swt.graphics.Color;
048:        import org.eclipse.swt.graphics.FontData;
049:        import org.eclipse.swt.graphics.Image;
050:
051:        /**
052:         * @generated
053:         */
054:        public class AsyncActivityName2EditPart extends CompartmentEditPart
055:                implements  ITextAwareEditPart {
056:
057:            /**
058:             * @generated
059:             */
060:            public static final int VISUAL_ID = 5004;
061:
062:            /**
063:             * @generated
064:             */
065:            private DirectEditManager manager;
066:
067:            /**
068:             * @generated
069:             */
070:            private IParser parser;
071:
072:            /**
073:             * @generated
074:             */
075:            private List parserElements;
076:
077:            /**
078:             * @generated
079:             */
080:            private String defaultText;
081:
082:            /**
083:             * @generated
084:             */
085:            public AsyncActivityName2EditPart(View view) {
086:                super (view);
087:            }
088:
089:            /**
090:             * @generated
091:             */
092:            protected void createDefaultEditPolicies() {
093:                super .createDefaultEditPolicies();
094:                installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE,
095:                        new LabelDirectEditPolicy());
096:                installEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE,
097:                        new NonResizableEditPolicy() {
098:
099:                            protected List createSelectionHandles() {
100:                                List handles = new ArrayList();
101:                                NonResizableHandleKit.addMoveHandle(
102:                                        (GraphicalEditPart) getHost(), handles);
103:                                return handles;
104:                            }
105:
106:                            public Command getCommand(Request request) {
107:                                return null;
108:                            }
109:
110:                            public boolean understandsRequest(Request request) {
111:                                return false;
112:                            }
113:                        });
114:            }
115:
116:            /**
117:             * @generated
118:             */
119:            protected String getLabelTextHelper(IFigure figure) {
120:                if (figure instanceof  WrapLabel) {
121:                    return ((WrapLabel) figure).getText();
122:                } else {
123:                    return ((Label) figure).getText();
124:                }
125:            }
126:
127:            /**
128:             * @generated
129:             */
130:            protected void setLabelTextHelper(IFigure figure, String text) {
131:                if (figure instanceof  WrapLabel) {
132:                    ((WrapLabel) figure).setText(text);
133:                } else {
134:                    ((Label) figure).setText(text);
135:                }
136:            }
137:
138:            /**
139:             * @generated
140:             */
141:            protected Image getLabelIconHelper(IFigure figure) {
142:                if (figure instanceof  WrapLabel) {
143:                    return ((WrapLabel) figure).getIcon();
144:                } else {
145:                    return ((Label) figure).getIcon();
146:                }
147:            }
148:
149:            /**
150:             * @generated
151:             */
152:            protected void setLabelIconHelper(IFigure figure, Image icon) {
153:                if (figure instanceof  WrapLabel) {
154:                    ((WrapLabel) figure).setIcon(icon);
155:                } else {
156:                    ((Label) figure).setIcon(icon);
157:                }
158:            }
159:
160:            /**
161:             * @generated
162:             */
163:            public void setLabel(WrapLabel figure) {
164:                unregisterVisuals();
165:                setFigure(figure);
166:                defaultText = getLabelTextHelper(figure);
167:                registerVisuals();
168:                refreshVisuals();
169:            }
170:
171:            /**
172:             * @generated
173:             */
174:            protected List getModelChildren() {
175:                return Collections.EMPTY_LIST;
176:            }
177:
178:            /**
179:             * @generated
180:             */
181:            public IGraphicalEditPart getChildBySemanticHint(String semanticHint) {
182:                return null;
183:            }
184:
185:            /**
186:             * @generated
187:             */
188:            protected EObject getParserElement() {
189:                EObject element = resolveSemanticElement();
190:                return element != null ? element : (View) getModel();
191:            }
192:
193:            /**
194:             * @generated
195:             */
196:            protected Image getLabelIcon() {
197:                return null;
198:            }
199:
200:            /**
201:             * @generated
202:             */
203:            protected String getLabelText() {
204:                String text = null;
205:                if (getParser() != null) {
206:                    text = getParser().getPrintString(
207:                            new EObjectAdapter(getParserElement()),
208:                            getParserOptions().intValue());
209:                }
210:                if (text == null || text.length() == 0) {
211:                    text = defaultText;
212:                }
213:                return text;
214:            }
215:
216:            /**
217:             * @generated
218:             */
219:            public void setLabelText(String text) {
220:                setLabelTextHelper(getFigure(), text);
221:                Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
222:                if (pdEditPolicy instanceof  New_processTextSelectionEditPolicy) {
223:                    ((New_processTextSelectionEditPolicy) pdEditPolicy)
224:                            .refreshFeedback();
225:                }
226:            }
227:
228:            /**
229:             * @generated
230:             */
231:            public String getEditText() {
232:                if (getParser() == null) {
233:                    return ""; //$NON-NLS-1$
234:                }
235:                return getParser().getEditString(
236:                        new EObjectAdapter(getParserElement()),
237:                        getParserOptions().intValue());
238:            }
239:
240:            /**
241:             * @generated
242:             */
243:            protected boolean isEditable() {
244:                return getParser() != null;
245:            }
246:
247:            /**
248:             * @generated
249:             */
250:            public ICellEditorValidator getEditTextValidator() {
251:                return new ICellEditorValidator() {
252:
253:                    public String isValid(final Object value) {
254:                        if (value instanceof  String) {
255:                            final EObject element = getParserElement();
256:                            final IParser parser = getParser();
257:                            try {
258:                                IParserEditStatus valid = (IParserEditStatus) getEditingDomain()
259:                                        .runExclusive(
260:                                                new RunnableWithResult.Impl() {
261:
262:                                                    public void run() {
263:                                                        setResult(parser
264:                                                                .isValidEditString(
265:                                                                        new EObjectAdapter(
266:                                                                                element),
267:                                                                        (String) value));
268:                                                    }
269:                                                });
270:                                return valid.getCode() == ParserEditStatus.EDITABLE ? null
271:                                        : valid.getMessage();
272:                            } catch (InterruptedException ie) {
273:                                ie.printStackTrace();
274:                            }
275:                        }
276:
277:                        // shouldn't get here
278:                        return null;
279:                    }
280:                };
281:            }
282:
283:            /**
284:             * @generated
285:             */
286:            public IContentAssistProcessor getCompletionProcessor() {
287:                if (getParser() == null) {
288:                    return null;
289:                }
290:                return getParser().getCompletionProcessor(
291:                        new EObjectAdapter(getParserElement()));
292:            }
293:
294:            /**
295:             * @generated
296:             */
297:            public ParserOptions getParserOptions() {
298:                return ParserOptions.NONE;
299:            }
300:
301:            /**
302:             * @generated
303:             */
304:            public IParser getParser() {
305:                if (parser == null) {
306:                    String parserHint = ((View) getModel()).getType();
307:                    ParserHintAdapter hintAdapter = new ParserHintAdapter(
308:                            getParserElement(), parserHint) {
309:
310:                        public Object getAdapter(Class adapter) {
311:                            if (IElementType.class.equals(adapter)) {
312:                                //return New_processElementTypes.AsyncActivity_2004;
313:                            }
314:                            return super .getAdapter(adapter);
315:                        }
316:                    };
317:                    parser = ParserService.getInstance().getParser(hintAdapter);
318:                }
319:                return parser;
320:            }
321:
322:            /**
323:             * @generated
324:             */
325:            protected DirectEditManager getManager() {
326:                if (manager == null) {
327:                    setManager(new TextDirectEditManager(this ,
328:                            TextDirectEditManager.getTextCellEditorClass(this ),
329:                            New_processEditPartFactory
330:                                    .getTextCellEditorLocator(this )));
331:                }
332:                return manager;
333:            }
334:
335:            /**
336:             * @generated
337:             */
338:            protected void setManager(DirectEditManager manager) {
339:                this .manager = manager;
340:            }
341:
342:            /**
343:             * @generated
344:             */
345:            protected void performDirectEdit() {
346:                getManager().show();
347:            }
348:
349:            /**
350:             * @generated
351:             */
352:            protected void performDirectEdit(Point eventLocation) {
353:                if (getManager().getClass() == TextDirectEditManager.class) {
354:                    ((TextDirectEditManager) getManager()).show(eventLocation
355:                            .getSWTPoint());
356:                }
357:            }
358:
359:            /**
360:             * @generated
361:             */
362:            private void performDirectEdit(char initialCharacter) {
363:                if (getManager() instanceof  TextDirectEditManager) {
364:                    ((TextDirectEditManager) getManager())
365:                            .show(initialCharacter);
366:                } else {
367:                    performDirectEdit();
368:                }
369:            }
370:
371:            /**
372:             * @generated
373:             */
374:            protected void performDirectEditRequest(Request request) {
375:                final Request theRequest = request;
376:                try {
377:                    getEditingDomain().runExclusive(new Runnable() {
378:
379:                        public void run() {
380:                            if (isActive() && isEditable()) {
381:                                if (theRequest
382:                                        .getExtendedData()
383:                                        .get(
384:                                                RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR) instanceof  Character) {
385:                                    Character initialChar = (Character) theRequest
386:                                            .getExtendedData()
387:                                            .get(
388:                                                    RequestConstants.REQ_DIRECTEDIT_EXTENDEDDATA_INITIAL_CHAR);
389:                                    performDirectEdit(initialChar.charValue());
390:                                } else if ((theRequest instanceof  DirectEditRequest)
391:                                        && (getEditText()
392:                                                .equals(getLabelText()))) {
393:                                    DirectEditRequest editRequest = (DirectEditRequest) theRequest;
394:                                    performDirectEdit(editRequest.getLocation());
395:                                } else {
396:                                    performDirectEdit();
397:                                }
398:                            }
399:                        }
400:                    });
401:                } catch (InterruptedException e) {
402:                    e.printStackTrace();
403:                }
404:            }
405:
406:            /**
407:             * @generated
408:             */
409:            protected void refreshVisuals() {
410:                super .refreshVisuals();
411:                refreshLabel();
412:                refreshFont();
413:                refreshFontColor();
414:                refreshUnderline();
415:                refreshStrikeThrough();
416:            }
417:
418:            /**
419:             * @generated
420:             */
421:            protected void refreshLabel() {
422:                setLabelTextHelper(getFigure(), getLabelText());
423:                setLabelIconHelper(getFigure(), getLabelIcon());
424:                Object pdEditPolicy = getEditPolicy(EditPolicy.PRIMARY_DRAG_ROLE);
425:                if (pdEditPolicy instanceof  New_processTextSelectionEditPolicy) {
426:                    ((New_processTextSelectionEditPolicy) pdEditPolicy)
427:                            .refreshFeedback();
428:                }
429:            }
430:
431:            /**
432:             * @generated
433:             */
434:            protected void refreshUnderline() {
435:                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
436:                        NotationPackage.eINSTANCE.getFontStyle());
437:                if (style != null && getFigure() instanceof  WrapLabel) {
438:                    ((WrapLabel) getFigure()).setTextUnderline(style
439:                            .isUnderline());
440:                }
441:            }
442:
443:            /**
444:             * @generated
445:             */
446:            protected void refreshStrikeThrough() {
447:                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
448:                        NotationPackage.eINSTANCE.getFontStyle());
449:                if (style != null && getFigure() instanceof  WrapLabel) {
450:                    ((WrapLabel) getFigure()).setTextStrikeThrough(style
451:                            .isStrikeThrough());
452:                }
453:            }
454:
455:            /**
456:             * @generated
457:             */
458:            protected void refreshFont() {
459:                FontStyle style = (FontStyle) getFontStyleOwnerView().getStyle(
460:                        NotationPackage.eINSTANCE.getFontStyle());
461:                if (style != null) {
462:                    FontData fontData = new FontData(
463:                            style.getFontName(),
464:                            style.getFontHeight(),
465:                            (style.isBold() ? org.eclipse.swt.SWT.BOLD
466:                                    : org.eclipse.swt.SWT.NORMAL)
467:                                    | (style.isItalic() ? org.eclipse.swt.SWT.ITALIC
468:                                            : org.eclipse.swt.SWT.NORMAL));
469:                    setFont(fontData);
470:                }
471:            }
472:
473:            /**
474:             * @generated
475:             */
476:            protected void setFontColor(Color color) {
477:                getFigure().setForegroundColor(color);
478:            }
479:
480:            /**
481:             * @generated
482:             */
483:            protected void addSemanticListeners() {
484:                if (getParser() instanceof  ISemanticParser) {
485:                    EObject element = resolveSemanticElement();
486:                    parserElements = ((ISemanticParser) getParser())
487:                            .getSemanticElementsBeingParsed(element);
488:                    for (int i = 0; i < parserElements.size(); i++) {
489:                        addListenerFilter(
490:                                "SemanticModel" + i, this , (EObject) parserElements.get(i)); //$NON-NLS-1$
491:                    }
492:                } else {
493:                    super .addSemanticListeners();
494:                }
495:            }
496:
497:            /**
498:             * @generated
499:             */
500:            protected void removeSemanticListeners() {
501:                if (parserElements != null) {
502:                    for (int i = 0; i < parserElements.size(); i++) {
503:                        removeListenerFilter("SemanticModel" + i); //$NON-NLS-1$
504:                    }
505:                } else {
506:                    super .removeSemanticListeners();
507:                }
508:            }
509:
510:            /**
511:             * @generated
512:             */
513:            protected AccessibleEditPart getAccessibleEditPart() {
514:                if (accessibleEP == null) {
515:                    accessibleEP = new AccessibleGraphicalEditPart() {
516:
517:                        public void getName(AccessibleEvent e) {
518:                            e.result = getLabelTextHelper(getFigure());
519:                        }
520:                    };
521:                }
522:                return accessibleEP;
523:            }
524:
525:            /**
526:             * @generated
527:             */
528:            private View getFontStyleOwnerView() {
529:                return getPrimaryView();
530:            }
531:
532:            /**
533:             * @generated
534:             */
535:            protected void addNotationalListeners() {
536:                super .addNotationalListeners();
537:                addListenerFilter("PrimaryView", this , getPrimaryView()); //$NON-NLS-1$
538:            }
539:
540:            /**
541:             * @generated
542:             */
543:            protected void removeNotationalListeners() {
544:                super .removeNotationalListeners();
545:                removeListenerFilter("PrimaryView"); //$NON-NLS-1$
546:            }
547:
548:            /**
549:             * @generated
550:             */
551:            protected void handleNotificationEvent(Notification event) {
552:                Object feature = event.getFeature();
553:                if (NotationPackage.eINSTANCE.getFontStyle_FontColor().equals(
554:                        feature)) {
555:                    Integer c = (Integer) event.getNewValue();
556:                    setFontColor(DiagramColorRegistry.getInstance().getColor(c));
557:                } else if (NotationPackage.eINSTANCE.getFontStyle_Underline()
558:                        .equals(feature)) {
559:                    refreshUnderline();
560:                } else if (NotationPackage.eINSTANCE
561:                        .getFontStyle_StrikeThrough().equals(feature)) {
562:                    refreshStrikeThrough();
563:                } else if (NotationPackage.eINSTANCE.getFontStyle_FontHeight()
564:                        .equals(feature)
565:                        || NotationPackage.eINSTANCE.getFontStyle_FontName()
566:                                .equals(feature)
567:                        || NotationPackage.eINSTANCE.getFontStyle_Bold()
568:                                .equals(feature)
569:                        || NotationPackage.eINSTANCE.getFontStyle_Italic()
570:                                .equals(feature)) {
571:                    refreshFont();
572:                } else {
573:                    if (getParser() != null
574:                            && getParser().isAffectingEvent(event,
575:                                    getParserOptions().intValue())) {
576:                        refreshLabel();
577:                    }
578:                    if (getParser() instanceof  ISemanticParser) {
579:                        ISemanticParser modelParser = (ISemanticParser) getParser();
580:                        if (modelParser
581:                                .areSemanticElementsAffected(null, event)) {
582:                            removeSemanticListeners();
583:                            if (resolveSemanticElement() != null) {
584:                                addSemanticListeners();
585:                            }
586:                            refreshLabel();
587:                        }
588:                    }
589:                }
590:                super .handleNotificationEvent(event);
591:            }
592:
593:            /**
594:             * @generated
595:             */
596:            protected IFigure createFigure() {
597:                // Parent should assign one using setLabel() method
598:                return null;
599:            }
600:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.