Source Code Cross Referenced for CustomEditPart.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) 


0001:        package com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.edit.parts;
0002:
0003:        import java.io.InputStream;
0004:        import java.util.ArrayList;
0005:        import java.util.HashMap;
0006:        import java.util.Iterator;
0007:        import java.util.List;
0008:
0009:        import org.eclipse.core.resources.IProject;
0010:        import org.eclipse.core.resources.ResourcesPlugin;
0011:        import org.eclipse.core.runtime.IPath;
0012:        import org.eclipse.draw2d.BorderLayout;
0013:        import org.eclipse.draw2d.ChopboxAnchor;
0014:        import org.eclipse.draw2d.ConnectionAnchor;
0015:        import org.eclipse.draw2d.Figure;
0016:        import org.eclipse.draw2d.IFigure;
0017:        import org.eclipse.draw2d.ImageFigure;
0018:        import org.eclipse.draw2d.PositionConstants;
0019:        import org.eclipse.draw2d.StackLayout;
0020:        import org.eclipse.draw2d.ToolbarLayout;
0021:        import org.eclipse.draw2d.geometry.Point;
0022:        import org.eclipse.draw2d.geometry.Rectangle;
0023:        import org.eclipse.emf.common.command.AbstractCommand;
0024:        import org.eclipse.emf.common.command.CompoundCommand;
0025:        import org.eclipse.emf.common.notify.Notification;
0026:        import org.eclipse.emf.common.notify.impl.AdapterImpl;
0027:        import org.eclipse.emf.ecore.EAnnotation;
0028:        import org.eclipse.emf.ecore.EClass;
0029:        import org.eclipse.emf.ecore.EObject;
0030:        import org.eclipse.emf.ecore.EStructuralFeature;
0031:        import org.eclipse.emf.edit.command.AddCommand;
0032:        import org.eclipse.emf.edit.command.RemoveCommand;
0033:        import org.eclipse.emf.edit.command.SetCommand;
0034:        import org.eclipse.emf.transaction.RecordingCommand;
0035:        import org.eclipse.emf.transaction.TransactionalEditingDomain;
0036:        import org.eclipse.emf.transaction.util.TransactionUtil;
0037:        import org.eclipse.gef.ConnectionEditPart;
0038:        import org.eclipse.gef.EditPart;
0039:        import org.eclipse.gef.EditPolicy;
0040:        import org.eclipse.gef.GraphicalEditPart;
0041:        import org.eclipse.gef.NodeEditPart;
0042:        import org.eclipse.gef.Request;
0043:        import org.eclipse.gef.RequestConstants;
0044:        import org.eclipse.gef.commands.Command;
0045:        import org.eclipse.gef.commands.UnexecutableCommand;
0046:        import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
0047:        import org.eclipse.gef.editpolicies.ComponentEditPolicy;
0048:        import org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy;
0049:        import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
0050:        import org.eclipse.gef.editpolicies.ResizableEditPolicy;
0051:        import org.eclipse.gef.requests.CreateConnectionRequest;
0052:        import org.eclipse.gef.requests.CreateRequest;
0053:        import org.eclipse.gef.requests.DirectEditRequest;
0054:        import org.eclipse.gef.requests.GroupRequest;
0055:        import org.eclipse.gef.requests.ReconnectRequest;
0056:        import org.eclipse.gmf.runtime.notation.Bounds;
0057:        import org.eclipse.gmf.runtime.notation.Edge;
0058:        import org.eclipse.gmf.runtime.notation.FillStyle;
0059:        import org.eclipse.gmf.runtime.notation.FontStyle;
0060:        import org.eclipse.gmf.runtime.notation.LineStyle;
0061:        import org.eclipse.gmf.runtime.notation.Node;
0062:        import org.eclipse.gmf.runtime.notation.NotationFactory;
0063:        import org.eclipse.gmf.runtime.notation.NotationPackage;
0064:        import org.eclipse.gmf.runtime.notation.View;
0065:        import org.eclipse.jface.wizard.WizardDialog;
0066:        import org.eclipse.swt.SWT;
0067:        import org.eclipse.swt.graphics.Color;
0068:        import org.eclipse.swt.graphics.Font;
0069:        import org.eclipse.swt.graphics.FontData;
0070:        import org.eclipse.swt.graphics.Image;
0071:        import org.eclipse.swt.widgets.Display;
0072:        import org.eclipse.ui.PlatformUI;
0073:        import org.eclipse.ui.part.FileEditorInput;
0074:
0075:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.*;
0076:        import com.bostechcorp.cbesb.common.util.custcomponent.ICustComponent;
0077:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ComponentFlowEditorDocument;
0078:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.ComponentFlowEditorElement;
0079:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.Custom;
0080:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.MessageExchange;
0081:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.componentflowFactory;
0082:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.componentflowPackage;
0083:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorDiagramEditorPlugin;
0084:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorPaletteFactory;
0085:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.part.ComponentFlowEditorVisualIDRegistry;
0086:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.view.factories.DomainElementInitializer;
0087:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.view.factories.MessageExchangeViewFactory;
0088:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.CustomPropertyWizard;
0089:        import com.bostechcorp.cbesb.ui.componentflow.componentFlowEditor.diagram.wizards.WizardUtil;
0090:        import com.bostechcorp.cbesb.ui.util.ucm.CustCompClassLoader;
0091:
0092:        /**
0093:         * @generated
0094:         */
0095:        public class CustomEditPart extends AbstractGraphicalEditPart implements 
0096:                NodeEditPart, IUpdatableEditPart {
0097:
0098:            /**
0099:             * @generated
0100:             */
0101:            public static final int VISUAL_ID = 2015;
0102:
0103:            /**
0104:             * @generated
0105:             */
0106:            protected IFigure contentPane;
0107:
0108:            /**
0109:             * @generated
0110:             */
0111:            protected IFigure primaryShape;
0112:
0113:            /**
0114:             * @generated NOT
0115:             */
0116:            protected CustCompClassLoader classLoader;
0117:
0118:            /**
0119:             * @generated NOT
0120:             */
0121:            protected IFigure decorationPane;
0122:
0123:            /**
0124:             * @generated NOT
0125:             */
0126:            protected IFigure invisibleRectangle;
0127:
0128:            /**
0129:             * @generated NOT
0130:             */
0131:            protected IFigure decorationShape;
0132:
0133:            /**
0134:             * @generated NOT
0135:             */
0136:            ImageFigure imageFigure;
0137:
0138:            /**
0139:             * @generated
0140:             */
0141:            public CustomEditPart(View model) {
0142:                assert model instanceof  Node;
0143:                setModel(model);
0144:            }
0145:
0146:            /**
0147:             * @generated
0148:             */
0149:            protected void createEditPolicies() {
0150:                installEditPolicy(EditPolicy.COMPONENT_ROLE,
0151:                        new ComponentEditPolicy() {
0152:                            protected Command createDeleteCommand(
0153:                                    GroupRequest deleteRequest) {
0154:                                TransactionalEditingDomain editingDomain = TransactionUtil
0155:                                        .getEditingDomain(getDiagramNode()
0156:                                                .getDiagram().getElement());
0157:                                CompoundCommand cc = new CompoundCommand();
0158:                                cc
0159:                                        .append(getDomainModelRemoveCommand(editingDomain));
0160:                                cc.append(RemoveCommand.create(editingDomain,
0161:                                        getDiagramNode()));
0162:                                return new WrappingCommand(editingDomain, cc);
0163:                            }
0164:
0165:                            private org.eclipse.emf.common.command.Command getDomainModelRemoveCommand(
0166:                                    TransactionalEditingDomain editingDomain) {
0167:                                return RemoveCommand
0168:                                        .create(
0169:                                                editingDomain,
0170:                                                getDiagramNode().getElement()
0171:                                                        .eContainer(),
0172:                                                componentflowPackage.eINSTANCE
0173:                                                        .getComponentFlowEditorDocument_ComponentFlowEditorElements(),
0174:                                                getDiagramNode().getElement());
0175:                            }
0176:                        });
0177:                installEditPolicy(EditPolicy.LAYOUT_ROLE,
0178:                        new ConstrainedLayoutEditPolicy() {
0179:                            protected Command getCreateCommand(
0180:                                    CreateRequest request) {
0181:                                return UnexecutableCommand.INSTANCE;
0182:                            }
0183:
0184:                            protected Object getConstraintFor(Rectangle rect) {
0185:                                return null;
0186:                            }
0187:
0188:                            protected Object getConstraintFor(Point point) {
0189:                                return null;
0190:                            }
0191:
0192:                            protected Command createChangeConstraintCommand(
0193:                                    EditPart child, Object constraint) {
0194:                                return UnexecutableCommand.INSTANCE;
0195:                            }
0196:
0197:                            protected EditPolicy createChildEditPolicy(
0198:                                    EditPart child) {
0199:                                return new ResizableEditPolicy() {
0200:                                    public EditPart getTargetEditPart(
0201:                                            Request request) {
0202:                                        if (RequestConstants.REQ_SELECTION
0203:                                                .equals(request.getType())) {
0204:                                            return CustomEditPart.this ;
0205:                                        }
0206:                                        return super .getTargetEditPart(request);
0207:                                    }
0208:                                };
0209:                            }
0210:                        });
0211:                installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE,
0212:                        new GraphicalNodeEditPolicy() {
0213:                            protected Command getReconnectTargetCommand(
0214:                                    ReconnectRequest request) {
0215:                                //XXX: reconnect command
0216:                                return UnexecutableCommand.INSTANCE;
0217:                            }
0218:
0219:                            protected Command getReconnectSourceCommand(
0220:                                    ReconnectRequest request) {
0221:                                //XXX: reconnect command
0222:                                return UnexecutableCommand.INSTANCE;
0223:                            }
0224:
0225:                            protected Command getConnectionCreateCommand(
0226:                                    CreateConnectionRequest request) {
0227:                                if (request instanceof  ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx) {
0228:                                    ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx requestEx = (ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx) request;
0229:                                    int[] visualIds = requestEx.getVisualIds();
0230:                                    CompoundCommand result = new CompoundCommand();
0231:                                    for (int i = 0; i < visualIds.length; i++) {
0232:                                        int nextVisualId = visualIds[i];
0233:                                        switch (nextVisualId) {
0234:                                        case MessageExchangeEditPart.VISUAL_ID:
0235:                                            result
0236:                                                    .append(new CreateMessageExchange4001StartCommand(
0237:                                                            requestEx));
0238:                                            break;
0239:                                        }
0240:                                    }
0241:                                    if (result.getCommandList().size() != 1
0242:                                            || !result.canExecute()) {
0243:                                        //Cannot create several connections at once.
0244:                                        //returning an unexecutable command does not change cursor to "No".
0245:                                        return null;
0246:                                    }
0247:                                    Command wrappedResult = new WrappingCommand(
0248:                                            TransactionUtil
0249:                                                    .getEditingDomain(getDiagramNode()
0250:                                                            .getDiagram()
0251:                                                            .getElement()),
0252:                                            result);
0253:                                    request.setStartCommand(wrappedResult);
0254:                                    return wrappedResult;
0255:                                }
0256:                                return null;
0257:                            }
0258:
0259:                            protected Command getConnectionCompleteCommand(
0260:                                    CreateConnectionRequest request) {
0261:                                if (request.getStartCommand() == null
0262:                                        || !request.getStartCommand()
0263:                                                .canExecute()) {
0264:                                    return UnexecutableCommand.INSTANCE;
0265:                                }
0266:                                if (request instanceof  ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx) {
0267:                                    ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx requestEx = (ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx) request;
0268:                                    int[] visualIds = requestEx.getVisualIds();
0269:                                    CompoundCommand result = new CompoundCommand();
0270:                                    for (int i = 0; i < visualIds.length; i++) {
0271:                                        int nextVisualId = visualIds[i];
0272:                                        switch (nextVisualId) {
0273:                                        case MessageExchangeEditPart.VISUAL_ID:
0274:                                            result
0275:                                                    .append(new CreateMessageExchange4001Command(
0276:                                                            requestEx));
0277:                                            break;
0278:                                        }
0279:                                    }
0280:                                    if (result.getCommandList().size() != 1) {
0281:                                        //Cannot create several connections at once.
0282:                                        return UnexecutableCommand.INSTANCE;
0283:                                    }
0284:                                    return new WrappingCommand(
0285:                                            TransactionUtil
0286:                                                    .getEditingDomain(getDiagramNode()
0287:                                                            .getDiagram()
0288:                                                            .getElement()),
0289:                                            result);
0290:                                }
0291:                                return UnexecutableCommand.INSTANCE;
0292:                            }
0293:                        });
0294:            }
0295:
0296:            /**
0297:             * @generated NOT
0298:             */
0299:            protected IFigure createFigure() {
0300:                invisibleRectangle = new Figure();
0301:                invisibleRectangle.setLayoutManager(new BorderLayout());
0302:                IFigure rec = new Figure();
0303:                invisibleRectangle.add(rec, BorderLayout.CENTER);
0304:                rec.setLayoutManager(new StackLayout());
0305:                IFigure shape = createNodeShape();
0306:                rec.add(shape);
0307:                contentPane = setupContentPane(shape);
0308:
0309:                View view = (View) getModel();
0310:                wizardOut(view, true);
0311:
0312:                decorationShape = createDecorationPane();
0313:                if (decorationShape != null) {
0314:                    rec.add(decorationShape);
0315:                }
0316:                // add----------------------------
0317:                org.eclipse.draw2d.Label fig = new org.eclipse.draw2d.Label();
0318:                fig.setText("");
0319:
0320:                ((BCFigure) shape).setFigureBCNameFigure(fig);
0321:
0322:                invisibleRectangle.add(fig, BorderLayout.BOTTOM);
0323:                // ---------------------------------------------------
0324:
0325:                return invisibleRectangle;
0326:            }
0327:
0328:            /**
0329:             * @generated
0330:             */
0331:            protected IFigure createNodeShape() {
0332:                BCFigure figure = new BCFigure();
0333:                primaryShape = figure;
0334:                return primaryShape;
0335:            }
0336:
0337:            /**
0338:             * @generated
0339:             */
0340:            public BCFigure getPrimaryShape() {
0341:                return (BCFigure) primaryShape;
0342:            }
0343:
0344:            /**
0345:             * @generated NOT
0346:             */
0347:            private IFigure createDecorationPane() {
0348:
0349:                View view = (View) getModel();
0350:
0351:                decorationPane = new Figure();
0352:                decorationPane.setLayoutManager(new BorderLayout());
0353:
0354:                Custom custom = (Custom) view.getElement();
0355:
0356:                ICustComponent curr = custom.getCustomComponent();
0357:                String file_name = ComponentFlowEditorDiagramEditor.project_name;
0358:                IPath rootLoc = ResourcesPlugin.getWorkspace().getRoot()
0359:                        .getLocation();
0360:
0361:                classLoader = CustCompClassLoader.getInstance(this .getClass()
0362:                        .getClassLoader(), file_name, rootLoc.toString() + "/"
0363:                        + file_name);
0364:                if (curr == null) {
0365:                    curr = classLoader.getComponentInstance(custom.getType());
0366:                    custom.setCustomComponent(curr);
0367:                }
0368:                if (curr != null) {
0369:                    try {
0370:                        InputStream stream = classLoader.getInputStream(curr
0371:                                .getBigIconResourceLocation());
0372:                        Display display = Display.getCurrent();
0373:                        Image image = new Image(display, stream);
0374:                        imageFigure = new ImageFigure(image,
0375:                                PositionConstants.CENTER);
0376:                        decorationPane.add(imageFigure, BorderLayout.TOP);
0377:
0378:                    } catch (Exception e) {
0379:                        imageFigure = new ImageFigure(
0380:                                ComponentFlowEditorDiagramEditorPlugin
0381:                                        .getInstance().getBundledImage(
0382:                                                "icons/customer32.ico"),
0383:                                PositionConstants.CENTER);
0384:                        decorationPane.add(imageFigure, BorderLayout.TOP);
0385:                    }
0386:
0387:                } else {
0388:
0389:                    imageFigure = new ImageFigure(
0390:                            ComponentFlowEditorDiagramEditorPlugin
0391:                                    .getInstance().getBundledImage(
0392:                                            "icons/customer32.ico"),
0393:                            PositionConstants.CENTER);
0394:                    decorationPane.add(imageFigure, BorderLayout.TOP);
0395:                }
0396:                return decorationPane;
0397:
0398:            }
0399:
0400:            /**
0401:             * Default implementation treats passed figure as content pane. Respects
0402:             * layout one may have set for generated figure.
0403:             * 
0404:             * @param nodeShape
0405:             *            instance of generated figure class
0406:             * @generated
0407:             */
0408:            protected IFigure setupContentPane(IFigure nodeShape) {
0409:                if (nodeShape.getLayoutManager() == null) {
0410:                    ToolbarLayout layout = new ToolbarLayout();
0411:                    layout.setSpacing(5);
0412:                    nodeShape.setLayoutManager(layout);
0413:                }
0414:                return nodeShape; // use nodeShape itself as contentPane
0415:            }
0416:
0417:            /**
0418:             * @generated
0419:             */
0420:            public IFigure getContentPane() {
0421:                if (contentPane == null) {
0422:                    return super .getContentPane();
0423:                }
0424:                return contentPane;
0425:            }
0426:
0427:            /**
0428:             * @generated
0429:             */
0430:            public Node getDiagramNode() {
0431:                return (Node) getModel();
0432:            }
0433:
0434:            /**
0435:             * @generated
0436:             */
0437:            protected boolean addFixedChild(EditPart childEditPart) {
0438:                if (childEditPart instanceof  CustomNameEditPart) {
0439:                    ((CustomNameEditPart) childEditPart)
0440:                            .setLabel(getPrimaryShape().getFigureBCNameFigure());
0441:                    return true;
0442:                }
0443:                return false;
0444:            }
0445:
0446:            /**
0447:             * @generated
0448:             */
0449:            protected boolean removeFixedChild(EditPart childEditPart) {
0450:                return false;
0451:            }
0452:
0453:            /**
0454:             * Returns the label which should be direct-edited by default.
0455:             * 
0456:             * @generated
0457:             */
0458:            private EditPart getPrimaryLabelEditPart() {
0459:                for (Iterator it = getDiagramNode().getChildren().iterator(); it
0460:                        .hasNext();) {
0461:                    View nextChild = (View) it.next();
0462:                    if (ComponentFlowEditorVisualIDRegistry
0463:                            .getVisualID(nextChild) == CustomNameEditPart.VISUAL_ID) {
0464:                        return (EditPart) getViewer().getEditPartRegistry()
0465:                                .get(nextChild);
0466:                    }
0467:                }
0468:                return null;
0469:            }
0470:
0471:            /**
0472:             * @generated
0473:             */
0474:            public void performRequest(Request req) {
0475:                if (RequestConstants.REQ_DIRECT_EDIT == req.getType()) {
0476:                    EditPart labelToEdit;
0477:                    if (req instanceof  DirectEditRequest) {
0478:                        labelToEdit = getLabelEditPart((DirectEditRequest) req);
0479:                    } else {
0480:                        labelToEdit = getPrimaryLabelEditPart();
0481:                    }
0482:                    if (labelToEdit != null) {
0483:                        labelToEdit.performRequest(req);
0484:                    }
0485:                }
0486:            }
0487:
0488:            /**
0489:             * @generated
0490:             */
0491:            private EditPart getLabelEditPart(DirectEditRequest req) {
0492:                EditPart result = getViewer().findObjectAt(req.getLocation());
0493:                if (result != null) {
0494:                    View view = (View) result.getModel();
0495:                    if (getDiagramNode().getChildren().contains(view)) {
0496:                        int visualId = ComponentFlowEditorVisualIDRegistry
0497:                                .getVisualID(view);
0498:                        switch (visualId) {
0499:                        case CustomNameEditPart.VISUAL_ID:
0500:                            return result;
0501:                        }
0502:                    }
0503:                }
0504:                return getPrimaryLabelEditPart();
0505:            }
0506:
0507:            /**
0508:             * @generated
0509:             */
0510:            protected void addChildVisual(EditPart childEditPart, int index) {
0511:                if (addFixedChild(childEditPart)) {
0512:                    return;
0513:                }
0514:                super .addChildVisual(childEditPart, -1);
0515:            }
0516:
0517:            /**
0518:             * @generated
0519:             */
0520:            protected void removeChildVisual(EditPart childEditPart) {
0521:                if (removeFixedChild(childEditPart)) {
0522:                    return;
0523:                }
0524:                super .removeChildVisual(childEditPart);
0525:            }
0526:
0527:            /**
0528:             * @generated
0529:             */
0530:            protected void refreshVisuals() {
0531:                super .refreshVisuals();
0532:                refreshBounds();
0533:                refreshBackgroundColor();
0534:                refreshForegroundColor();
0535:                refreshFont();
0536:                refreshVisibility();
0537:            }
0538:
0539:            /**
0540:             * @generated
0541:             */
0542:            protected void refreshVisibility() {
0543:                boolean isVisible = getDiagramNode().isVisible();
0544:                boolean wasVisible = getFigure().isVisible();
0545:                if (isVisible == wasVisible) {
0546:                    return;
0547:                }
0548:                if (!isVisible && (getSelected() != SELECTED_NONE)) {
0549:                    getViewer().deselect(this );
0550:                }
0551:
0552:                getFigure().setVisible(isVisible);
0553:                getFigure().revalidate();
0554:            }
0555:
0556:            /**
0557:             * @generated
0558:             */
0559:            protected void refreshBounds() {
0560:                Node node = getDiagramNode();
0561:                assert node.getLayoutConstraint() instanceof  Bounds;
0562:                Bounds bounds = (Bounds) node.getLayoutConstraint();
0563:                ((GraphicalEditPart) getParent()).setLayoutConstraint(this ,
0564:                        getFigure(), new Rectangle(bounds.getX(),
0565:                                bounds.getY(), bounds.getWidth(), bounds
0566:                                        .getHeight()));
0567:            }
0568:
0569:            /**
0570:             * @generated
0571:             */
0572:            protected List getModelChildren() {
0573:                return getDiagramNode().getVisibleChildren();
0574:            }
0575:
0576:            /**
0577:             * @generated
0578:             */
0579:            protected List getModelSourceConnections() {
0580:                return getDiagramNode().getSourceEdges();
0581:            }
0582:
0583:            /**
0584:             * @generated
0585:             */
0586:            protected List getModelTargetConnections() {
0587:                return getDiagramNode().getTargetEdges();
0588:            }
0589:
0590:            /**
0591:             * @generated NOT
0592:             */
0593:            public void adjustName() {
0594:                ComponentFlowEditorEditPartFactory.setModelName(this , "Custom");
0595:            }
0596:
0597:            /**
0598:             * @generated
0599:             */
0600:            public ConnectionAnchor getSourceConnectionAnchor(
0601:                    ConnectionEditPart connection) {
0602:                return new ChopboxAnchor(getFigure());
0603:            }
0604:
0605:            /**
0606:             * @generated
0607:             */
0608:            public ConnectionAnchor getSourceConnectionAnchor(Request request) {
0609:                return new ChopboxAnchor(getFigure());
0610:            }
0611:
0612:            /**
0613:             * @generated
0614:             */
0615:            public ConnectionAnchor getTargetConnectionAnchor(
0616:                    ConnectionEditPart connection) {
0617:                return new ChopboxAnchor(getFigure());
0618:            }
0619:
0620:            /**
0621:             * @generated
0622:             */
0623:            public ConnectionAnchor getTargetConnectionAnchor(Request request) {
0624:                return new ChopboxAnchor(getFigure());
0625:            }
0626:
0627:            /**
0628:             * @generated
0629:             */
0630:            public Object getAdapter(Class key) {
0631:                return super .getAdapter(key);
0632:            }
0633:
0634:            /**
0635:             * @generated NOT
0636:             */
0637:            public void wizardOut(View view, boolean newCom) {
0638:                ComponentFlowEditorElement element = (ComponentFlowEditorElement) view
0639:                        .getElement();
0640:
0641:                if (newCom && !WizardUtil.canWizardOut(view))
0642:                    return;
0643:
0644:                final Custom customComponent = (Custom) view.getElement();
0645:
0646:                transferInfo(customComponent, newCom);
0647:
0648:                try {
0649:                    ICustComponent curr = customComponent.getCustomComponent();
0650:                    if ((curr != null) && (classLoader != null)
0651:                            && (decorationPane != null)
0652:                            && (imageFigure != null)) {
0653:                        InputStream stream = classLoader.getInputStream(curr
0654:                                .getBigIconResourceLocation());
0655:                        Display display = Display.getCurrent();
0656:                        Image image = new Image(display, stream);
0657:                        decorationPane.remove(imageFigure);
0658:                        imageFigure = new ImageFigure(image,
0659:                                PositionConstants.CENTER);
0660:                        decorationPane.add(imageFigure, BorderLayout.TOP);
0661:
0662:                    }
0663:                } catch (Exception e) {
0664:                    e.printStackTrace();
0665:
0666:                }
0667:            }
0668:
0669:            /**
0670:             * @generated NOT
0671:             */
0672:            public void transferInfo(final Custom customComponent,
0673:                    final boolean newCom) {
0674:                TransactionalEditingDomain domain = TransactionUtil
0675:                        .getEditingDomain(customComponent);
0676:
0677:                FileEditorInput editorInput = (FileEditorInput) PlatformUI
0678:                        .getWorkbench().getActiveWorkbenchWindow()
0679:                        .getActivePage().getActiveEditor().getEditorInput();
0680:                IProject project = editorInput.getFile().getProject();
0681:
0682:                classLoader = CustCompClassLoader.getInstance(this .getClass()
0683:                        .getClassLoader(), project.getName(), project
0684:                        .getLocation().toOSString());
0685:                final List<ICustComponent> cus_list = classLoader
0686:                        .getComponentlist();
0687:                final View view = (View) getModel();
0688:
0689:                // I have got the custom components. I will create at least one of them.
0690:                /*
0691:                 * if ((cus_list != null) && (cus_list.size() > 0)) { for (int i = 0; i <
0692:                 * cus_list.size(); i++) { System.out.println("name is " +
0693:                 * cus_list.get(i).getClass().getName()); } }
0694:                 */
0695:
0696:                domain.getCommandStack().execute(new RecordingCommand(domain) {
0697:
0698:                    public void doExecute() {
0699:                        //It is very important to should add wizard out in here, included in a TransactionalEditingDomain
0700:
0701:                        final CustomPropertyWizard customWizard = new CustomPropertyWizard(
0702:                                cus_list, (Custom) customComponent, classLoader);
0703:                        if (newCom) {
0704:                            customWizard
0705:                                    .setAddedOperation((ComponentFlowEditorElement) view
0706:                                            .getElement());
0707:                            WizardDialog wizard = new WizardDialog(PlatformUI
0708:                                    .getWorkbench().getActiveWorkbenchWindow()
0709:                                    .getShell(), customWizard);
0710:                            wizard.open();
0711:                        } else {
0712:                            customWizard
0713:                                    .setUpdateOperation((ComponentFlowEditorElement) view
0714:                                            .getElement());
0715:                            WizardDialog wizard = new WizardDialog(PlatformUI
0716:                                    .getWorkbench().getActiveWorkbenchWindow()
0717:                                    .getShell(), customWizard);
0718:                            wizard.open();
0719:                        }
0720:
0721:                    }
0722:                });
0723:
0724:            }
0725:
0726:            /**
0727:             * @generated NOT
0728:             */
0729:            public List getAllCustom(String path) {
0730:                List list = new ArrayList();
0731:                return list;
0732:            }
0733:
0734:            /**
0735:             * @generated
0736:             */
0737:            public void activate() {
0738:                super .activate();
0739:                getDiagramNode().getElement().eAdapters().add(
0740:                        domainModelRefresher);
0741:            }
0742:
0743:            /**
0744:             * @generated
0745:             */
0746:            public void deactivate() {
0747:                getDiagramNode().getElement().eAdapters().remove(
0748:                        domainModelRefresher);
0749:                super .deactivate();
0750:            }
0751:
0752:            /**
0753:             * @generated
0754:             */
0755:            private DomainModelRefresher domainModelRefresher = new DomainModelRefresher();
0756:
0757:            /**
0758:             * @generated
0759:             */
0760:            private class DomainModelRefresher extends AdapterImpl {
0761:                /**
0762:                 * @generated NOT
0763:                 */
0764:                public void notifyChanged(Notification msg) {
0765:                    super .notifyChanged(msg);
0766:                    if (msg.isTouch()) {
0767:                        return;
0768:                    }
0769:                    Refresher refresher = getRefresher((EStructuralFeature) msg
0770:                            .getFeature(), msg);
0771:                    if (refresher != null) {
0772:                        refresher.refresh();
0773:                    }
0774:                    adjustName();
0775:                }
0776:            }
0777:
0778:            /**
0779:             * @generated
0780:             */
0781:            public void addRefresher(EStructuralFeature feature,
0782:                    Refresher refresher) {
0783:                CompositeRefresher compositeRefresher = getCompositeRefresher(feature);
0784:                compositeRefresher.addRefresher(refresher);
0785:            }
0786:
0787:            /**
0788:             * @generated
0789:             */
0790:            public void removeRefresher(EStructuralFeature feature,
0791:                    Refresher refresher) {
0792:                CompositeRefresher compositeRefresher = getCompositeRefresher(feature);
0793:                compositeRefresher.removeRefresher(refresher);
0794:            }
0795:
0796:            /**
0797:             * @generated
0798:             */
0799:            private CompositeRefresher getCompositeRefresher(
0800:                    EStructuralFeature feature) {
0801:                if (structuralFeatures2Refresher == null) {
0802:                    createRefreshers();
0803:                }
0804:                Refresher refresher = (Refresher) structuralFeatures2Refresher
0805:                        .get(feature);
0806:                if (refresher instanceof  CompositeRefresher) {
0807:                    return (CompositeRefresher) refresher;
0808:                }
0809:                CompositeRefresher result = new CompositeRefresher();
0810:                if (refresher != null) {
0811:                    result.addRefresher(refresher);
0812:                }
0813:                structuralFeatures2Refresher.put(feature, result);
0814:                return result;
0815:            }
0816:
0817:            /**
0818:             * @generated
0819:             */
0820:            protected void refreshFont() {
0821:                FontStyle style = (FontStyle) getDiagramNode().getStyle(
0822:                        NotationPackage.eINSTANCE.getFontStyle());
0823:                Font toDispose = createdFont;
0824:                if (style != null) {
0825:                    String fontName = style.getFontName();
0826:                    int fontHeight = style.getFontHeight();
0827:                    int fontStyle = SWT.NORMAL;
0828:                    if (style.isBold()) {
0829:                        fontStyle |= SWT.BOLD;
0830:                    }
0831:                    if (style.isItalic()) {
0832:                        fontStyle |= SWT.ITALIC;
0833:                    }
0834:                    Font currentFont = getFigure().getFont();
0835:                    if (currentFont != null) {
0836:                        FontData currentFontData = currentFont.getFontData()[0];
0837:                        if (currentFontData.getName().equals(fontName)
0838:                                && currentFontData.getHeight() == fontHeight
0839:                                && currentFontData.getStyle() == fontStyle) {
0840:                            return;
0841:                        }
0842:                    }
0843:                    createdFont = new Font(null, fontName, fontHeight,
0844:                            fontStyle);
0845:                    getFigure().setFont(createdFont);
0846:                } else {
0847:                    //revert to the default font
0848:                    getFigure().setFont(getViewer().getControl().getFont());
0849:                    createdFont = null;
0850:                }
0851:                if (toDispose != null) {
0852:                    toDispose.dispose();
0853:                }
0854:            }
0855:
0856:            /**
0857:             * The font (created by {@link #refreshFont()}) currently assigned to the
0858:             * label (unless the default font is assigned). Whenever another non-default
0859:             * font is assigned to it, it is safe to dispose the previous one.
0860:             * 
0861:             * @generated
0862:             */
0863:            private Font createdFont;
0864:
0865:            /**
0866:             * @generated
0867:             */
0868:            protected void refreshForegroundColor() {
0869:                LineStyle style = (LineStyle) getDiagramNode().getStyle(
0870:                        NotationPackage.eINSTANCE.getLineStyle());
0871:                Color toDispose = createdForegroundColor;
0872:                if (style != null) {
0873:                    int foregroundColor = style.getLineColor();
0874:                    int red = foregroundColor & 0x000000FF;
0875:                    int green = (foregroundColor & 0x0000FF00) >> 8;
0876:                    int blue = (foregroundColor & 0x00FF0000) >> 16;
0877:                    Color currentColor = getFigure().getForegroundColor();
0878:                    if (currentColor != null && currentColor.getRed() == red
0879:                            && currentColor.getGreen() == green
0880:                            && currentColor.getBlue() == blue) {
0881:                        return;
0882:                    }
0883:                    createdForegroundColor = new Color(null, red, green, blue);
0884:                    getFigure().setForegroundColor(createdForegroundColor);
0885:                } else {
0886:                    getFigure().setForegroundColor(
0887:                            getViewer().getControl().getForeground());
0888:                    createdForegroundColor = null;
0889:                }
0890:                if (toDispose != null) {
0891:                    toDispose.dispose();
0892:                }
0893:            }
0894:
0895:            /**
0896:             * The color (created by {@link #refreshForegroundColor()}) currently
0897:             * assigned to the figure. Whenever another color is assigned to it, it is
0898:             * safe to dispose the previous one.
0899:             * 
0900:             * @generated
0901:             */
0902:            private Color createdForegroundColor;
0903:
0904:            /**
0905:             * @generated
0906:             */
0907:            protected void refreshBackgroundColor() {
0908:                FillStyle style = (FillStyle) getDiagramNode().getStyle(
0909:                        NotationPackage.eINSTANCE.getFillStyle());
0910:                Color toDispose = createdBackgroundColor;
0911:                if (style != null) {
0912:                    int backgroundColor = style.getFillColor();
0913:                    int red = backgroundColor & 0x000000FF;
0914:                    int green = (backgroundColor & 0x0000FF00) >> 8;
0915:                    int blue = (backgroundColor & 0x00FF0000) >> 16;
0916:                    Color currentColor = getFigure().getBackgroundColor();
0917:                    if (currentColor != null && currentColor.getRed() == red
0918:                            && currentColor.getGreen() == green
0919:                            && currentColor.getBlue() == blue) {
0920:                        return;
0921:                    }
0922:                    createdBackgroundColor = new Color(null, red, green, blue);
0923:                    getFigure().setBackgroundColor(createdBackgroundColor);
0924:                } else {
0925:                    getFigure().setBackgroundColor(
0926:                            getViewer().getControl().getBackground());
0927:                }
0928:                if (toDispose != null) {
0929:                    toDispose.dispose();
0930:                }
0931:            }
0932:
0933:            /**
0934:             * The color (created by {@link #refreshBackgroundColor()}) currently
0935:             * assigned to the figure. Whenever another color is assigned to it, it is
0936:             * safe to dispose the previous one.
0937:             * 
0938:             * @generated
0939:             */
0940:            private Color createdBackgroundColor;
0941:
0942:            /**
0943:             * @generated
0944:             */
0945:            private HashMap structuralFeatures2Refresher;
0946:
0947:            /**
0948:             * @generated
0949:             */
0950:            public Refresher getRefresher(EStructuralFeature feature,
0951:                    Notification msg) {
0952:                if (structuralFeatures2Refresher == null) {
0953:                    createRefreshers();
0954:                }
0955:                return (Refresher) structuralFeatures2Refresher.get(feature);
0956:            }
0957:
0958:            /**
0959:             * @generated
0960:             */
0961:            private void createRefreshers() {
0962:                structuralFeatures2Refresher = new HashMap();
0963:                Refresher childrenRefresher = new Refresher() {
0964:                    public void refresh() {
0965:                        refreshChildren();
0966:                    }
0967:                };
0968:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0969:                        .getView_PersistedChildren(), childrenRefresher);
0970:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0971:                        .getView_TransientChildren(), childrenRefresher);
0972:                Refresher boundsRefresher = new Refresher() {
0973:                    public void refresh() {
0974:                        refreshBounds();
0975:                    }
0976:                };
0977:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0978:                        .getNode_LayoutConstraint(), boundsRefresher);
0979:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0980:                        .getSize_Width(), boundsRefresher);
0981:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0982:                        .getSize_Height(), boundsRefresher);
0983:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0984:                        .getLocation_X(), boundsRefresher);
0985:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0986:                        .getLocation_Y(), boundsRefresher);
0987:                Refresher visibilityRefresher = new Refresher() {
0988:                    public void refresh() {
0989:                        refreshVisibility();
0990:                    }
0991:                };
0992:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
0993:                        .getView_Visible(), visibilityRefresher);
0994:                Refresher sourceEdgesRefresher = new Refresher() {
0995:                    public void refresh() {
0996:                        refreshSourceConnections();
0997:                    }
0998:                };
0999:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1000:                        .getView_SourceEdges(), sourceEdgesRefresher);
1001:                Refresher targetEdgesRefresher = new Refresher() {
1002:                    public void refresh() {
1003:                        refreshTargetConnections();
1004:                    }
1005:                };
1006:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1007:                        .getView_TargetEdges(), targetEdgesRefresher);
1008:                Refresher fontRefresher = new Refresher() {
1009:                    public void refresh() {
1010:                        refreshFont();
1011:                    }
1012:                };
1013:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1014:                        .getFontStyle_FontHeight(), fontRefresher);
1015:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1016:                        .getFontStyle_FontName(), fontRefresher);
1017:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1018:                        .getFontStyle_Bold(), fontRefresher);
1019:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1020:                        .getFontStyle_Italic(), fontRefresher);
1021:
1022:                Refresher backgroundColorRefresher = new Refresher() {
1023:                    public void refresh() {
1024:                        refreshBackgroundColor();
1025:                    }
1026:                };
1027:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1028:                        .getFillStyle_FillColor(), backgroundColorRefresher);
1029:                Refresher foregroundColorRefresher = new Refresher() {
1030:                    public void refresh() {
1031:                        refreshForegroundColor();
1032:                    }
1033:                };
1034:                structuralFeatures2Refresher.put(NotationPackage.eINSTANCE
1035:                        .getLineStyle_LineColor(), foregroundColorRefresher);
1036:            }
1037:
1038:            /**
1039:             * @generated
1040:             */
1041:            private static class CreateMessageExchange4001StartCommand extends
1042:                    AbstractCommand {
1043:                /**
1044:                 * @generated
1045:                 */
1046:                private View source;
1047:
1048:                /**
1049:                 * @generated
1050:                 */
1051:                public CreateMessageExchange4001StartCommand(
1052:                        ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx requestEx) {
1053:                    //Until the mouse button is pressed, the source of the connection is in request.getTargetEditPart(), not in request.getSourceEditPart().
1054:                    source = (View) requestEx.getTargetEditPart().getModel();
1055:                }
1056:
1057:                /**
1058:                 * @generated
1059:                 */
1060:                public void execute() {
1061:                    //This command never gets executed
1062:                }
1063:
1064:                /**
1065:                 * @generated
1066:                 */
1067:                public void undo() {
1068:                    //This command never gets executed
1069:                }
1070:
1071:                /**
1072:                 * @generated
1073:                 */
1074:                public void redo() {
1075:                    //This command never gets executed
1076:                }
1077:
1078:                /**
1079:                 * @generated
1080:                 */
1081:                public boolean canUndo() {
1082:                    return true;
1083:                }
1084:
1085:                /**
1086:                 * @generated
1087:                 */
1088:                protected boolean prepare() {
1089:                    if (source == null) {
1090:                        return false;
1091:                    }
1092:                    ComponentFlowEditorDocument container = (ComponentFlowEditorDocument) getRelationshipContainer(
1093:                            source.getElement(), componentflowPackage.eINSTANCE
1094:                                    .getComponentFlowEditorDocument());
1095:                    if (container == null) {
1096:                        return false;
1097:                    }
1098:
1099:                    return true;
1100:                }
1101:
1102:                /**
1103:                 * Finds container element for the new relationship of the specified
1104:                 * type. Default implementation goes up by containment hierarchy
1105:                 * starting from the specified element and returns the first element
1106:                 * that is instance of the specified container class.
1107:                 * 
1108:                 * @generated
1109:                 */
1110:                protected EObject getRelationshipContainer(EObject element,
1111:                        EClass containerClass) {
1112:                    for (; element != null; element = element.eContainer()) {
1113:                        if (containerClass.isSuperTypeOf(element.eClass())) {
1114:                            return element;
1115:                        }
1116:                    }
1117:                    return null;
1118:                }
1119:
1120:            }
1121:
1122:            /**
1123:             * @generated
1124:             */
1125:            private static class CreateMessageExchange4001Command extends
1126:                    AbstractCommand {
1127:                /**
1128:                 * @generated
1129:                 */
1130:                private final View source;
1131:
1132:                /**
1133:                 * @generated
1134:                 */
1135:                private final View target;
1136:
1137:                /**
1138:                 * @generated
1139:                 */
1140:                private final Edge createdEdge;
1141:
1142:                /**
1143:                 * @generated
1144:                 */
1145:                private final org.eclipse.emf.common.command.Command domainModelAddCommand;
1146:
1147:                /**
1148:                 * @generated
1149:                 */
1150:                public CreateMessageExchange4001Command(
1151:                        ComponentFlowEditorPaletteFactory.CreateConnectionRequestEx requestEx) {
1152:                    if (requestEx.getSourceEditPart().getModel() instanceof  View) {
1153:                        source = (View) requestEx.getSourceEditPart()
1154:                                .getModel();
1155:                    } else {
1156:                        source = null;
1157:                    }
1158:                    if (requestEx.getTargetEditPart().getModel() instanceof  View) {
1159:                        target = (View) requestEx.getTargetEditPart()
1160:                                .getModel();
1161:                    } else {
1162:                        target = null;
1163:                    }
1164:                    if (source == null || target == null) {
1165:                        createdEdge = null;
1166:                        domainModelAddCommand = org.eclipse.emf.common.command.UnexecutableCommand.INSTANCE;
1167:                        return;
1168:                    }
1169:                    createdEdge = NotationFactory.eINSTANCE.createEdge();
1170:                    MessageExchange createdDomainElement = componentflowFactory.eINSTANCE
1171:                            .createMessageExchange();
1172:                    createdEdge.setElement(createdDomainElement);
1173:
1174:                    DomainElementInitializer.MessageExchange_4001
1175:                            .initializeElement(createdDomainElement);
1176:                    MessageExchangeViewFactory.decorateView(createdEdge);
1177:                    TransactionalEditingDomain domainModelEditDomain = TransactionUtil
1178:                            .getEditingDomain(source.getDiagram().getElement());
1179:                    org.eclipse.emf.common.command.CompoundCommand addLinkEndsCommand = new org.eclipse.emf.common.command.CompoundCommand();
1180:                    EObject container = getRelationshipContainer(source
1181:                            .getElement(), componentflowPackage.eINSTANCE
1182:                            .getComponentFlowEditorDocument());
1183:                    if (container == null) {
1184:                        domainModelAddCommand = null;
1185:                        return;
1186:                    }
1187:                    addLinkEndsCommand
1188:                            .append(AddCommand
1189:                                    .create(
1190:                                            domainModelEditDomain,
1191:                                            container,
1192:                                            componentflowPackage.eINSTANCE
1193:                                                    .getComponentFlowEditorDocument_MessageExchanges(),
1194:                                            createdDomainElement));
1195:
1196:                    if (createdDomainElement.getSourceElement() != null) {
1197:                        domainModelAddCommand = null;
1198:                        return;
1199:                    }
1200:                    addLinkEndsCommand.append(SetCommand.create(
1201:                            domainModelEditDomain, createdDomainElement,
1202:                            componentflowPackage.eINSTANCE
1203:                                    .getMessageExchange_SourceElement(), source
1204:                                    .getElement()));
1205:
1206:                    if (createdDomainElement.getTargetElement() != null) {
1207:                        domainModelAddCommand = null;
1208:                        return;
1209:                    }
1210:                    addLinkEndsCommand.append(SetCommand.create(
1211:                            domainModelEditDomain, createdDomainElement,
1212:                            componentflowPackage.eINSTANCE
1213:                                    .getMessageExchange_TargetElement(), target
1214:                                    .getElement()));
1215:                    domainModelAddCommand = addLinkEndsCommand;
1216:                }
1217:
1218:                /**
1219:                 * Finds container element for the new relationship of the specified
1220:                 * type. Default implementation goes up by containment hierarchy
1221:                 * starting from the specified element and returns the first element
1222:                 * that is instance of the specified container class.
1223:                 * 
1224:                 * @generated
1225:                 */
1226:                protected EObject getRelationshipContainer(EObject element,
1227:                        EClass containerClass) {
1228:                    for (; element != null; element = element.eContainer()) {
1229:                        if (containerClass.isSuperTypeOf(element.eClass())) {
1230:                            return element;
1231:                        }
1232:                    }
1233:                    return null;
1234:                }
1235:
1236:                /**
1237:                 * @generated
1238:                 */
1239:                public boolean canExecute() {
1240:                    if (source == null || target == null || createdEdge == null
1241:                            || domainModelAddCommand == null
1242:                            || !domainModelAddCommand.canExecute()) {
1243:                        return false;
1244:                    }
1245:
1246:                    return true;
1247:                }
1248:
1249:                /**
1250:                 * @generated
1251:                 */
1252:                public boolean canUndo() {
1253:                    return source != null && target != null
1254:                            && createdEdge != null
1255:                            && domainModelAddCommand != null
1256:                            && domainModelAddCommand.canUndo();
1257:                }
1258:
1259:                /**
1260:                 * @generated
1261:                 */
1262:                public void execute() {
1263:                    domainModelAddCommand.execute();
1264:                    source.getDiagram().insertEdge(createdEdge);
1265:                    createdEdge.setSource(source);
1266:                    createdEdge.setTarget(target);
1267:                }
1268:
1269:                /**
1270:                 * @generated
1271:                 */
1272:                public void undo() {
1273:                    domainModelAddCommand.undo();
1274:                    source.getDiagram().removeEdge(createdEdge);
1275:                    createdEdge.setSource(null);
1276:                    createdEdge.setTarget(null);
1277:                }
1278:
1279:                /**
1280:                 * @generated
1281:                 */
1282:                public void redo() {
1283:                    execute();
1284:                }
1285:            }
1286:
1287:            /**
1288:             * @generated
1289:             */
1290:            public class BCFigure extends org.eclipse.draw2d.RectangleFigure {
1291:
1292:                /**
1293:                 * @generated NOT
1294:                 */
1295:                public BCFigure() {
1296:
1297:                    this .setPreferredSize(getMapMode().DPtoLP(120),
1298:                            getMapMode().DPtoLP(120));
1299:                    createContents();
1300:                }
1301:
1302:                /**
1303:                 * @generated
1304:                 */
1305:                private void createContents() {
1306:                    org.eclipse.draw2d.Label fig_0 = new org.eclipse.draw2d.Label();
1307:                    fig_0.setText("<...>");
1308:                    fig_0.setSize(getMapMode().DPtoLP(120), getMapMode()
1309:                            .DPtoLP(60));
1310:
1311:                    setFigureBCNameFigure(fig_0);
1312:
1313:                    Object layData0 = null;
1314:
1315:                    this .add(fig_0, layData0);
1316:                }
1317:
1318:                /**
1319:                 * @generated
1320:                 */
1321:                private org.eclipse.draw2d.Label fBCNameFigure;
1322:
1323:                /**
1324:                 * @generated
1325:                 */
1326:                public org.eclipse.draw2d.Label getFigureBCNameFigure() {
1327:                    return fBCNameFigure;
1328:                }
1329:
1330:                /**
1331:                 * @generated
1332:                 */
1333:                private void setFigureBCNameFigure(org.eclipse.draw2d.Label fig) {
1334:                    fBCNameFigure = fig;
1335:                }
1336:
1337:                /**
1338:                 * @generated
1339:                 */
1340:                private boolean myUseLocalCoordinates = false;
1341:
1342:                /**
1343:                 * @generated
1344:                 */
1345:                protected boolean useLocalCoordinates() {
1346:                    return myUseLocalCoordinates;
1347:                }
1348:
1349:                /**
1350:                 * @generated
1351:                 */
1352:                protected void setUseLocalCoordinates(
1353:                        boolean useLocalCoordinates) {
1354:                    myUseLocalCoordinates = useLocalCoordinates;
1355:                }
1356:
1357:            }
1358:
1359:            /**
1360:             * @generated
1361:             */
1362:            private static class MapModeWorkaround {
1363:                /**
1364:                 * @generated
1365:                 */
1366:                public int DPtoLP(int dp) {
1367:                    return dp;
1368:                }
1369:
1370:                /**
1371:                 * @generated
1372:                 */
1373:                public static MapModeWorkaround INSTANCE = new MapModeWorkaround();
1374:            }
1375:
1376:            /**
1377:             * @generated
1378:             */
1379:            private MapModeWorkaround getMapMode() {
1380:                return MapModeWorkaround.INSTANCE;
1381:            }
1382:        }
w___ww.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.