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