org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart Java Examples

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ActivitySwitchEditPolicy.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
private List<IFigure> addSignalEventFigures() {
    final List<IFigure> result = new ArrayList<IFigure>();
    final IGraphicalEditPart host = getHost();
    if (!(isEndEvent(host.resolveSemanticElement()) || hasIncomingConnection())){
    	result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.StartSignalEvent_2022));
    } else {
    	result.add(EMPTY_FIGURE);
    }
    result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.IntermediateCatchSignalEvent_2021));
    result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.IntermediateThrowSignalEvent_2020));
    if (!(isStartEvent(host.resolveSemanticElement()) || hasOutgoingConnection())) {
    	result.add(createClickableFigure(new Point(0, 0),getHost(), ProcessElementTypes.EndSignalEvent_2023));
    } else {
    	result.add(EMPTY_FIGURE);
    }
    return result;
}
 
Example #2
Source File: HasDataFilter.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public boolean select(Object object) {
    if (object instanceof IGraphicalEditPart) {
        IGraphicalEditPart editPart = (IGraphicalEditPart) object;
        EObject eObject = editPart.resolveSemanticElement();
        if (eObject == null
                || eObject instanceof CatchMessageEvent
                || eObject instanceof TimerEvent
                || eObject instanceof MainProcess
                || eObject instanceof SendTask
                || eObject instanceof StartSignalEvent
                || eObject instanceof StartTimerEvent) {
            return false;
        }

        return (eObject.eClass().getEAllStructuralFeatures().contains(ProcessPackage.Literals.DATA_AWARE__DATA)
                || eObject instanceof Lane);

    }
    return false;
}
 
Example #3
Source File: MultipleShapesVerticalMoveTool.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * creates the command to move the shapes left or right.
 */
protected Command getCommand() {
	if (_container == null) {
		return null;
	}
	CompoundCommand command = new CompoundCommand("Multiple Shape Move");
	TransactionalEditingDomain editingDomain = _container.getEditingDomain();

	Point moveDelta  = ((ChangeBoundsRequest) getSourceRequest()).getMoveDelta().getCopy();
	Dimension spSizeDelta = new Dimension(moveDelta.x, moveDelta.y);
	ZoomManager zoomManager = ((DiagramRootEditPart) 
			getCurrentViewer().getRootEditPart()).getZoomManager();
	spSizeDelta.scale(1/zoomManager.getZoom());
	command.add(_container.getCommand(getSourceRequest()));


	for (IGraphicalEditPart sp : _subProcesses) {
		Dimension spDim = sp.getFigure().getBounds().getSize().getCopy();
		spDim.expand(spSizeDelta);
		SetBoundsCommand setBounds = 
			new SetBoundsCommand(editingDomain,"MultipleShape Move", sp, spDim);
		command.add(new ICommandProxy(setBounds));
	}
	return command;
}
 
Example #4
Source File: AbstractSubProcessEventStartTypeDecorator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void deactivateDiagramEventBroker(IGraphicalEditPart part) {
	if(part instanceof SubProcessEvent2EditPart){
		SubProcessEvent2EditPart ep = (SubProcessEvent2EditPart) part ;
		BasicCompartment v = null ;
		for(Object c : ep.getChildren()){
			if(c instanceof ShapeCompartmentEditPart){
				v = (BasicCompartment) ((ShapeCompartmentEditPart) c).getNotationView() ;
			}
		}
		if(v != null ){
			DiagramEventBroker.getInstance(part.getEditingDomain()).removeNotificationListener(v,NotationPackage.eINSTANCE.getDrawerStyle_Collapsed(),notificationListener);  
		}
	}
	DiagramEventBroker.getInstance(part.getEditingDomain()).removeNotificationListener(part.resolveSemanticElement(),ProcessPackage.eINSTANCE.getContainer_Elements(), notificationListener);
}
 
Example #5
Source File: ImportBarFileCommandTest.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * This test ensures that a import a bpmn file create a new process from this file
 * 
 * @throws InterruptedException
 * @throws IOException
 */
@Test
public void testImportBPMN2() throws InterruptedException, IOException {
    new BotApplicationWorkbenchWindow(bot).importOther().selectBPMN2Importer()
            .setArchive(ImportBarFileCommandTest.class.getResource("standardProcess.bpmn"))
            .finish();

    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);
    assertNotNull("no pool found (import failed?)", pool);
    assertEquals("standardProcess (1.0)", botEditor.getTitle());
}
 
Example #6
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Test
public void testCreateData() throws Exception {
    SWTBotTestUtil.createNewDiagram(bot);
    final SWTBotEditor botEditor = bot.activeEditor();
    final SWTBotGefEditor gmfEditor = bot.gefEditor(botEditor.getTitle());

    final IGraphicalEditPart part = (IGraphicalEditPart) gmfEditor.mainEditPart().part();
    final MainProcess model = (MainProcess) part.resolveSemanticElement();
    final Pool pool = (Pool) model.getElements().get(0);

    gmfEditor.getEditPart(pool.getName()).parent().select();
    bot.viewById(SWTBotTestUtil.VIEWS_PROPERTIES_PROCESS_GENERAL).show();
    addDataOnSelectedElementWithName("newData", SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);

    assertTrue("no data added", pool.getData().size() == 1);
    assertTrue("wrong data added", pool.getData().get(0).getName().equals("newData"));
}
 
Example #7
Source File: SheetLabelProvider.java    From statecharts with Eclipse Public License 1.0 6 votes vote down vote up
public String getText(Object element) {
	element = unwrap(element);
	if (element instanceof IGraphicalEditPart) {
		EObject semanticElement = ((IGraphicalEditPart) element)
				.resolveSemanticElement();

		if (semanticElement == null) {
			View view = ((IGraphicalEditPart) element).getNotationView();
			return view.getType();
		} else {

			IElementType elementType = ElementTypeRegistry.getInstance()
					.getElementType(semanticElement);
			StringBuilder builder = new StringBuilder();
			builder.append(elementType.getDisplayName());
			if (semanticElement instanceof NamedElement
					&& ((NamedElement) semanticElement).getName() != null) {
				builder.append(' ');
				builder.append(((NamedElement) semanticElement).getName());
			}
			return builder.toString();
		}
	}
	return null;
}
 
Example #8
Source File: ImporterUtil.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
public static void resizeActivities(EditPart root){
    for(Object o : root.getChildren()){
        if(o instanceof ActivityEditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }else if(o instanceof Activity2EditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }else if(o instanceof TaskEditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }else if(o instanceof Task2EditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }else if(o instanceof CallActivity2EditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }else if(o instanceof CallActivityEditPart){
            FiguresHelper.resizeActivitiesFigure((IGraphicalEditPart) o, getTextFromEditPart((EditPart) o));
        }
    }
}
 
Example #9
Source File: ForkedColorsAndFontsPropertySection.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
    * Update font property
    */
protected void updateFontBold() {

	// Update model in response to user

	List commands = new ArrayList();
	Iterator it = getInputIterator();

	while (it.hasNext()) {
		final IGraphicalEditPart ep = (IGraphicalEditPart) it.next();
		commands.add(createCommand(FONT_COMMAND_NAME,
			((View) ep.getModel()).eResource(), new Runnable() {

				public void run() {
					ep.setStructuralFeatureValue(NotationPackage.eINSTANCE.getFontStyle_Bold(),
						Boolean.valueOf(fontBoldButton.getSelection()));
				}
			}));
	}

	executeAsCompositeCommand(FONT_COMMAND_NAME, commands);

}
 
Example #10
Source File: CrossflowModelingAssistantProviderOfTypeEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnTarget(IAdaptable target) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnTarget((TypeEditPart) targetEditPart);
}
 
Example #11
Source File: ProcessModelingAssistantProviderOfANDGateway2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSource(IAdaptable source) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSource((ANDGateway2EditPart) sourceEditPart);
}
 
Example #12
Source File: ProcessModelingAssistantProviderOfBoundaryMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSource(IAdaptable source) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSource((BoundaryMessageEventEditPart) sourceEditPart);
}
 
Example #13
Source File: CrossflowModelingAssistantProviderOfCsvSinkEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSourceAndTarget((CsvSinkEditPart) sourceEditPart, targetEditPart);
}
 
Example #14
Source File: ProcessModelingAssistantProviderOfServiceTask2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSourceAndTarget((ServiceTask2EditPart) sourceEditPart, targetEditPart);
}
 
Example #15
Source File: ActivityEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected IFigure getContentPaneFor(IGraphicalEditPart editPart) {
	if (editPart instanceof IBorderItemEditPart) {
		return getBorderedFigure().getBorderItemContainer();
	}
	return getContentPane();
}
 
Example #16
Source File: ProcessModelingAssistantProviderOfNonInterruptingBoundaryTimerEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSourceAndTarget((NonInterruptingBoundaryTimerEvent2EditPart) sourceEditPart,
			targetEditPart);
}
 
Example #17
Source File: CustomSubprocessEventCompartmentEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected List<IGraphicalEditPart> getChildrenToMoveHorizontaly(int xPosition, int yPosition,double zoom){
    IGraphicalEditPart _container = (IGraphicalEditPart) getParent().getParent() ;
    // the children that will be moved around
    List<IGraphicalEditPart> rightChildren = new ArrayList<IGraphicalEditPart>();

    if (_container != null && _container.resolveSemanticElement() instanceof Container) {
        List children  = null;
        if (_container.resolveSemanticElement() instanceof Container) {
            children = _container.getChildren();
        } else if (_container instanceof ShapeCompartmentEditPart) {
            children = ((ShapeCompartmentEditPart) _container).getChildren();
        }
        if (children == null) {
            throw new IllegalArgumentException("The part " + _container + " did not contain elements"); //$NON-NLS-1$ //$NON-NLS-2$
        }
        // now iterate over the compartment children
        // and take those that are on the right.
        for (Object child : children) {
            if (child instanceof ShapeNodeEditPart) {
                MultipleShapesHorizontalMoveTool.setBoundsForOverlapComputation((IGraphicalEditPart) child,SINGLETON) ;
                SINGLETON = SINGLETON.scale(zoom) ;
                ((DiagramEditPart) getViewer().getContents()).getFigure().translateToRelative(SINGLETON);
                if (SINGLETON.x > xPosition && SINGLETON.y < yPosition && SINGLETON.y + SINGLETON.height + 60  > yPosition) {
                    rightChildren.add((IGraphicalEditPart) child);
                }
            }
        }
    }
    return rightChildren;
}
 
Example #18
Source File: ProcessModelingAssistantProviderOfIntermediateCatchMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSourceAndTarget((IntermediateCatchMessageEventEditPart) sourceEditPart, targetEditPart);
}
 
Example #19
Source File: CrossflowModelingAssistantProviderOfTaskEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
public List<IElementType> doGetRelTypesOnSourceAndTarget(TaskEditPart source, IGraphicalEditPart targetEditPart) {
	List<IElementType> types = new LinkedList<IElementType>();
	if (targetEditPart instanceof TopicEditPart) {
		types.add(CrossflowElementTypes.TaskOutput_4003);
	}
	if (targetEditPart instanceof QueueEditPart) {
		types.add(CrossflowElementTypes.TaskOutput_4003);
	}
	return types;
}
 
Example #20
Source File: CrossflowModelingAssistantProviderOfTaskEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSource(IAdaptable source) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSource((TaskEditPart) sourceEditPart);
}
 
Example #21
Source File: ProcessModelingAssistantProviderOfEndTerminatedEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnTarget(IAdaptable target) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnTarget((EndTerminatedEventEditPart) targetEditPart);
}
 
Example #22
Source File: ProcessModelingAssistantProviderOfIntermediateThrowMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSourceAndTarget(IAdaptable source, IAdaptable target) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSourceAndTarget((IntermediateThrowMessageEventEditPart) sourceEditPart, targetEditPart);
}
 
Example #23
Source File: ProcessModelingAssistantProviderOfCatchLinkEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnSource(IAdaptable source) {
	IGraphicalEditPart sourceEditPart = (IGraphicalEditPart) source.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnSource((CatchLinkEventEditPart) sourceEditPart);
}
 
Example #24
Source File: CrossflowModelingAssistantProviderOfTaskEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getTypesForSource(IAdaptable target, IElementType relationshipType) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetTypesForSource((TaskEditPart) targetEditPart, relationshipType);
}
 
Example #25
Source File: ProcessModelingAssistantProviderOfStartMessageEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getTypesForSource(IAdaptable target, IElementType relationshipType) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetTypesForSource((StartMessageEvent2EditPart) targetEditPart, relationshipType);
}
 
Example #26
Source File: ProcessModelingAssistantProviderOfInclusiveGatewayEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getTypesForSource(IAdaptable target, IElementType relationshipType) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetTypesForSource((InclusiveGatewayEditPart) targetEditPart, relationshipType);
}
 
Example #27
Source File: ExtractAsCallActivityTransactionalCommand.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param allParts
 * @return
 */
private List<SourceElement> findTarget(List<IGraphicalEditPart> parts) {
    Map<SourceElement, Integer> nbOutgoings = new HashMap<SourceElement, Integer>();
    for (IGraphicalEditPart part : parts) {
        EObject node = part.resolveSemanticElement();
        if (node instanceof SourceElement) {
            SourceElement source = (SourceElement) node;
            nbOutgoings.put(source, source.getOutgoing().size());
        }
    }
    Set<SourceElement> nodes = nbOutgoings.keySet();
    if (nodes.size() == 0) {
        return Collections.emptyList();
    } else {
        AbstractProcess process = ModelHelper.getParentProcess(nodes.iterator().next());
        for (SequenceFlow transition : getAllRelatedTransitions(nodes, process)) {
            nbOutgoings.put(transition.getSource(), nbOutgoings.get(transition.getSource()) - 1);
        }

        List<SourceElement> outPoints = new ArrayList<SourceElement>();
        for (Entry<SourceElement, Integer> entry : nbOutgoings.entrySet()) {
            if (entry.getValue() != 0) {
                outPoints.add(entry.getKey());
            }
        }
        return outPoints;
    }
}
 
Example #28
Source File: ProcessModelingAssistantProviderOfIntermediateCatchTimerEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnTarget(IAdaptable target) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnTarget((IntermediateCatchTimerEventEditPart) targetEditPart);
}
 
Example #29
Source File: InitializeTreeNodeAnnotationsCommand.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
private CompositeTransactionalCommand annotateElements(
		List<IGraphicalEditPart> elements) {
	final CompositeTransactionalCommand cmd = new CompositeTransactionalCommand(
			getEditingDomain(), "AnnotateChildren");
	cmd.add(new SetTreeNodesPositionAnnotationCommand(getEditingDomain(),
			TreeLayoutUtil.getViews(elements)));
	for (final IGraphicalEditPart editPart : elements) {
		final List<IGraphicalEditPart> children = TreeLayoutUtil
				.getOrderedTreeChildren(editPart);
		if (!children.isEmpty()) {
			cmd.add(annotateElements(children));
		}
	}
	return cmd;
}
 
Example #30
Source File: ProcessModelingAssistantProviderOfScriptTask2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
@Override

public List<IElementType> getRelTypesOnTarget(IAdaptable target) {
	IGraphicalEditPart targetEditPart = (IGraphicalEditPart) target.getAdapter(IGraphicalEditPart.class);
	return doGetRelTypesOnTarget((ScriptTask2EditPart) targetEditPart);
}