protected IFigure createFigure() { if (image == null) { ILabeledElement element = BPELUtil.adapt(getStartNode(), ILabeledElement.class); image = element.getSmallImage(getStartNode()); Rectangle rect = image.getBounds(); imageWidth = rect.width; imageHeight = rect.height; } this.hasFH = getFaultHandler() != null; this.hasEH = getEventHandler() != null; // Cause the handlerIcons don't belong to the // bounds of the StartNodeFigure (as a result of // moving them a bit to the right in vertical layout and a bit to to the bottom // in horizontal layout) hit testing // doesn't reach the Startnode. So add an invisible // border StartNodeFigure snf = new StartNodeFigure(); if (!ModelHelper.isHorizontalLayout(getModel())) snf.setBorder(new MarginBorder(0, 7 + BORDER_WIDTH, 0, 7 + BORDER_WIDTH)); else snf.setBorder(new MarginBorder(5, 0, 5, 0)); faultImageFigure = new ImageFigure(faultImage); faultImageFigure.setParent(snf); eventImageFigure = new ImageFigure(eventImage); eventImageFigure.setParent(snf); return snf; }
@Override protected IFigure createFigure() { // TODO: Shouldn't have to initialize labels in each subclass. initializeLabels(); if (collapsedImage == null) { // Create the actual figure for the collapsed edit part ILabeledElement element = BPELUtil.adapt(getActivity(), ILabeledElement.class); collapsedImage = element.getSmallImage(getActivity()); } this.collapsedImageLabel = new Label(collapsedImage); this.collapsedNameLabel = new Label(getLabel()); // TODO: Shouldn't have to set the decorator in each subclass. editPartMarkerDecorator = new BPELEditPartMarkerDecorator( (EObject) getModel(), new CollapsableDecorationLayout(/*collapsedImage.getBounds().width*/ 0)); editPartMarkerDecorator.addMarkerMotionListener(getMarkerMotionListener()); this.parentFigure = new Figure(); AlignedFlowLayout layout = new AlignedFlowLayout(); layout.setHorizontal(true); layout.setHorizontalSpacing(0); layout.setVerticalSpacing(0); parentFigure.setLayoutManager(layout); this.contentFigure = new CollapsableScopeContainerFigure(getModel(), getImage(), getLabel()); contentFigure.addMouseMotionListener(getMouseMotionListener()); contentFigure.setEditPart(this); contentFigure.setForegroundColor( BPELUIPlugin.INSTANCE.getColorRegistry().get(IBPELUIConstants.COLOR_BLACK)); parentFigure.add(contentFigure); // Configure the border and contents based on collapsed state if (isCollapsed()) { configureCollapsedFigure(contentFigure); } else { configureExpandedFigure(contentFigure); } boolean isHorizontal = ModelHelper.isHorizontalLayout(getModel()); this.auxilaryFigure = new AuxiliaryFigure(); layout = new AlignedFlowLayout(); layout.setHorizontal(!isHorizontal); auxilaryFigure.setLayoutManager(layout); contentFigure.addFigureListener(auxilaryFigure); parentFigure.add(auxilaryFigure); ScopeBorder border = getScopeBorder(); border.setShowFault(getFaultHandler() != null); border.setShowCompensation(getCompensationHandler() != null); border.setShowTermination(getTerminationHandler() != null); border.setShowEvent(getEventHandler() != null); return editPartMarkerDecorator.createFigure(parentFigure); }
/** Set the layout of the figure for expanded state. */ @Override protected void configureExpandedFigure(IFigure figure) { FlowLayout layout = new FlowLayout(); layout.setMajorAlignment(FlowLayout.ALIGN_CENTER); layout.setMinorAlignment(FlowLayout.ALIGN_CENTER); layout.setHorizontal(ModelHelper.isHorizontalLayout(getModel())); layout.setMajorSpacing(SPACING); layout.setMinorSpacing(SPACING); figure.setLayoutManager(layout); }
/** @see org.eclipse.bpel.ui.actions.editpart.IEditPartAction#onButtonPressed() */ public boolean onButtonPressed() { CompoundCommand command = new CompoundCommand(IBPELUIConstants.CMD_ADD_TERMINATIONHANDLER); final EObject child = UIObjectFactoryProvider.getInstance() .getFactoryFor(BPELPackage.eINSTANCE.getTerminationHandler()) .createInstance(); command.add(new InsertInContainerCommand((EObject) modelObject, child, null)); command.add(new SetNameAndDirectEditCommand(child, viewer)); ModelHelper.getBPELEditor(modelObject).getCommandStack().execute(command); BPELUtil.setShowTerminationHandler(editPart, true); return true; }
public boolean onButtonPressed() { CompoundCommand command = new CompoundCommand(); final ElseIf child = (ElseIf) UIObjectFactoryProvider.getInstance() .getFactoryFor(BPELPackage.eINSTANCE.getElseIf()) .createInstance(); command.add(new InsertInContainerCommand((EObject) modelObject, child, null)); command.add(new SetNameAndDirectEditCommand(child, viewer)); BPELEditor bpelEditor = ModelHelper.getBPELEditor(modelObject); bpelEditor.getCommandStack().execute(command); return true; }
@Override protected ArrayList<PolylineConnection> createHorizontalConnections(BPELEditPart parent) { ArrayList<PolylineConnection> connections = new ArrayList<PolylineConnection>(); List children = getConnectionChildren(parent); BPELEditPart sourcePart, targetPart; ConnectionAnchor sourceAnchor = null, targetAnchor = null; sourcePart = parent; sourceAnchor = sourcePart.getConnectionAnchor(CenteredConnectionAnchor.LEFT); if (children != null) { for (int i = 0; i < children.size(); i++) { if (i == 0) { // Link from the left border to the first child targetPart = (BPELEditPart) children.get(i); targetAnchor = targetPart.getConnectionAnchor(CenteredConnectionAnchor.LEFT); if (sourceAnchor != null && targetAnchor != null) connections.add(createConnection(sourceAnchor, targetAnchor, arrowColor)); } if (i < children.size() - 1) { sourcePart = (BPELEditPart) children.get(i); sourceAnchor = sourcePart.getConnectionAnchor(CenteredConnectionAnchor.RIGHT); targetPart = (BPELEditPart) children.get(i + 1); targetAnchor = targetPart.getConnectionAnchor(CenteredConnectionAnchor.LEFT); } else { // Link from the last child to the right border sourcePart = (BPELEditPart) children.get(i); sourceAnchor = sourcePart.getConnectionAnchor(CenteredConnectionAnchor.RIGHT); targetAnchor = parent.getConnectionAnchor(CenteredConnectionAnchor.RIGHT); } if (sourceAnchor != null && targetAnchor != null) { PolylineConnection connection = createConnection(sourceAnchor, targetAnchor, arrowColor); if (sourcePart instanceof StartNodeEditPart || sourcePart instanceof ScopeEditPart || sourcePart instanceof InvokeEditPart) { boolean horizontal = ModelHelper.getBPELEditor(getHost().getModel()).isHorizontalLayout(); connection.setConnectionRouter(new ImplicitLinkHandlerConnectionRouter(horizontal)); } connections.add(connection); } } } return connections; }
public boolean onButtonPressed() { CompoundCommand command = new CompoundCommand(IBPELUIConstants.CMD_ADD_EVENTHANDLER); final EventHandler eventHandler = BPELFactory.eINSTANCE.createEventHandler(); // Create an empty OnEvent inside it. final OnEvent onEvent = (OnEvent) UIObjectFactoryProvider.getInstance() .getFactoryFor(BPELPackage.eINSTANCE.getOnEvent()) .createInstance(); eventHandler.getEvents().add(onEvent); command.add(new InsertInContainerCommand((EObject) modelObject, eventHandler, null)); command.add(new SetNameAndDirectEditCommand(onEvent, viewer)); ModelHelper.getBPELEditor(modelObject).getCommandStack().execute(command); BPELUtil.setShowEventHandler(editPart, true); return true; }
/** @see org.eclipse.draw2d.Figure#paint(org.eclipse.draw2d.Graphics) */ public void paint(Graphics graphics) { super.paint(graphics); computeHandlerIconPositions(ModelHelper.isHorizontalLayout(getModel())); if (hasFH) { graphics.pushState(); graphics.setClip(faultImageFigure.getBounds().getCopy()); faultImageFigure.paint(graphics); graphics.popState(); } if (hasEH) { graphics.pushState(); graphics.setClip(eventImageFigure.getBounds().getCopy()); eventImageFigure.paint(graphics); graphics.popState(); } }
@Override protected void createEditPolicies() { super.createEditPolicies(); // Show the selection rectangle installEditPolicy( EditPolicy.SELECTION_FEEDBACK_ROLE, new ContainerHighlightEditPolicy(false, true) { @Override protected int getDrawerInset() { return DrawerBorder.DRAWER_WIDTH; } @Override protected int getNorthInset() { if (isCollapsed()) { return 0; } // This one is tricky, it depends on the font size. return 10; } @Override protected int getSouthInset() { return isCollapsed() ? 8 : 2; } @Override protected int getEastInset() { return DrawerBorder.DRAWER_WIDTH; } @Override protected int getWestInset() { return DrawerBorder.DRAWER_WIDTH; } }); BPELOrderedLayoutEditPolicy policy = null; if (ModelHelper.isHorizontalLayout(getModel())) policy = new SequenceHorizontalBPELOrderedLayoutPolicy(); else policy = new BPELOrderedLayoutEditPolicy(); installEditPolicy(EditPolicy.LAYOUT_ROLE, policy); }
@Override protected void createEditPolicies() { super.createEditPolicies(); // Show the selection rectangle installEditPolicy( EditPolicy.SELECTION_FEEDBACK_ROLE, new ContainerHighlightEditPolicy(false, true) { @Override protected int getDrawerInset() { return DrawerBorder.DRAWER_WIDTH; } @Override protected int getNorthInset() { return 0; } @Override protected int getSouthInset() { return 3; } @Override protected int getEastInset() { return DrawerBorder.DRAWER_WIDTH; } @Override protected int getWestInset() { return DrawerBorder.DRAWER_WIDTH; } }); if (ModelHelper.isHorizontalLayout(getModel())) installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedHorizontalLayoutEditPolicy()); else installEditPolicy(EditPolicy.LAYOUT_ROLE, new ScopeOrderedLayoutEditPolicy()); }
protected boolean handleAddImport(Object obj) { // Do not import schema for schemas if (obj instanceof XSDSimpleTypeDefinition) { String targetNamespace = ((XSDSimpleTypeDefinition) obj).getTargetNamespace(); if (targetNamespace != null) { if (((XSDSimpleTypeDefinition) obj) .getTargetNamespace() .equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) { return false; } } } AddImportCommand cmd = new AddImportCommand(BPELUtils.getProcess(modelObject), obj); if (cmd.canDoExecute() && cmd.wouldCreateDuplicateImport() == false) { ModelHelper.getBPELEditor(modelObject).getCommandStack().execute(cmd); // Now refresh the view to imported types. return true; } return false; }
private void refreshMargin() { if (ModelHelper.isHorizontalLayout(getModel())) setBorder(new MarginBorder(contentFigure.getPreferredSize().height + 10, 0, 0, 0)); else setBorder(null); }