Java Code Examples for org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart#resolveSemanticElement()

The following examples show how to use org.eclipse.gmf.runtime.diagram.ui.editparts.IGraphicalEditPart#resolveSemanticElement() . 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: CustomResizableEditPolicyEx.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected boolean isResizeValid(final ChangeBoundsRequest request) {
    if (request.getEditParts() != null && !request.getEditParts().isEmpty()) {
        final IGraphicalEditPart ep = (IGraphicalEditPart) request.getEditParts().get(0);
        if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0 && ep.resolveSemanticElement() instanceof SubProcessEvent) {
            return checkSubprocessEventCanReduce(request);
        } else if (ep.resolveSemanticElement() instanceof Lane) {
            if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0) {
                return checkSwimLanesCanReduce(request);
            } else {
                return true;
            }
        } else if (ep.resolveSemanticElement() instanceof Pool) {
            if (request.getSizeDelta().height <= 0 && request.getSizeDelta().width <= 0) {
                return checkSwimLanesCanReduce(request);
            } else {
                return true;
            }
        }
        return !checkOverlapOtherFigures(request);
    }

    return true;
}
 
Example 2
Source File: TestFullScenario.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * @param diagramEditPart
 * @return
 */
private Task getTheTask(final IGraphicalEditPart diagramEditPart) {
    final MainProcess process = (MainProcess) diagramEditPart.resolveSemanticElement();
    final Pool pool = (Pool) process.getElements().get(0);
    Task task = null;
    for (final Element item : pool.getElements()) {
        if (item instanceof Task) {
            task = (Task) item;
        } else if (item instanceof Lane) {
            for (final Element laneItem : ((Lane) item).getElements()) {
                if (laneItem instanceof Task) {
                    task = (Task) laneItem;
                }
            }
        }
    }
    return task;
}
 
Example 3
Source File: DiagramFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object toTest) {
	if (toTest instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) toTest;
		Object model = editPart.resolveSemanticElement();
		return model instanceof MainProcess ;
	}
	return false;
}
 
Example 4
Source File: ConnectableElementFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();	
		if(model instanceof MainProcess)
			return false ;
		return model instanceof ConnectableElement;
	}
	return false;
}
 
Example 5
Source File: PageFlowAndLaneFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();	
		if(model instanceof MainProcess)
			return false ;
		return model instanceof PageFlow && !(model instanceof AbstractProcess);
	}
	return false;
}
 
Example 6
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 7
Source File: PoolFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object toTest) {
	if ( toTest instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart)  toTest;
		Object model = editPart.resolveSemanticElement();	
		return model instanceof Pool  || model instanceof Lane;
	}
	return false;
}
 
Example 8
Source File: AbstractProcessFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public boolean select(Object object) {
    if (object instanceof IGraphicalEditPart) {
        IGraphicalEditPart editPart = (IGraphicalEditPart) object;
        Object model = editPart.resolveSemanticElement();
        if((model instanceof AbstractProcess || model instanceof Lane) && !(model instanceof MainProcess) ){
            return true ;
        }
    }
    return false;
}
 
Example 9
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private Pool createProcessWithData() {
    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();
    final String dataName = "newData";
    addDataOnSelectedElementWithName(dataName, SWTBotConstants.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);
    return pool;
}
 
Example 10
Source File: VisibilitySectionFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();
		if(model instanceof MainProcess)
			return false ;
		return model instanceof Gateway || model instanceof BoundaryEvent || model instanceof Event || model instanceof SequenceFlow;
	}
	return false;
}
 
Example 11
Source File: OperationContainerFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
    if (object instanceof IGraphicalEditPart) {
        IGraphicalEditPart editPart = (IGraphicalEditPart) object;
        Object model = editPart.resolveSemanticElement();
        if (model instanceof MainProcess) {
            return false;
        }
        return model instanceof OperationContainer /* && !(model instanceof CallActivity) */ ;
    }
    return false;
}
 
Example 12
Source File: ExclusiveGatewayFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object toTest) {
	if (toTest instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) toTest;
		Object model = editPart.resolveSemanticElement();
		return model instanceof XORGateway;
	}
	return false;
}
 
Example 13
Source File: FontSectionFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();
		return model instanceof BoundaryEvent || model instanceof Gateway || model instanceof Event || model instanceof Activity || model instanceof Lane ||model instanceof Pool  || model instanceof Connection || model instanceof MessageFlow;
	}
	return false;
}
 
Example 14
Source File: RulerGridFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object toTest) {
	if (toTest instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) toTest;
		Object model = editPart.resolveSemanticElement();
		return model instanceof MainProcess ||  model instanceof Element || model instanceof TextAnnotationAttachment;
	}
	return false;
}
 
Example 15
Source File: LinkEventFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();
		return model instanceof LinkEvent;
	}
	return false;
}
 
Example 16
Source File: BotGefProcessDiagramEditor.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private String getPoolName(SWTBotGefEditPart gep) {
    while (gep != null) {
        gep = gep.parent();
        final IGraphicalEditPart graphicalEditPart = (IGraphicalEditPart) gep.part();
        if (graphicalEditPart.resolveSemanticElement() instanceof PoolImpl) {
            //TODO: Access to the name via SWTBotGefEditPart instead of IGraphicalEditPart
            return ((CustomPoolNameEditPart) graphicalEditPart.getChildren().get(0)).getEditText();
        }
        gep = gep.parent();
    }
    return null;
}
 
Example 17
Source File: CatchMessageEventFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object toTest) {
	if (toTest instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) toTest;
		Object model = editPart.resolveSemanticElement();
		return model instanceof AbstractCatchMessageEvent;
	}
	return false;
}
 
Example 18
Source File: ActivityFilter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
public boolean select(Object object) {
	if (object instanceof IGraphicalEditPart) {
		IGraphicalEditPart editPart = (IGraphicalEditPart) object;
		Object model = editPart.resolveSemanticElement();
		return model instanceof Activity;
	}
	return false;
}
 
Example 19
Source File: MultipleShapesHorizontalMoveTool.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Moved to public so that it may be called programmatically
 * by an other tool.
 */
public boolean handleButtonDown(int button) {
	Object underMouse = getCurrentViewer().findObjectAt(getCurrentInput().getMouseLocation());
	if (!(underMouse instanceof IGraphicalEditPart)) {
		return true;
	}
	stateTransition(STATE_INITIAL, STATE_DRAG_IN_PROGRESS);
	_initialPosition = getCurrentPosition();
	_initPosNoZoom = getCurrentPositionZoomed();

	// calculate the initial selection
	// of shapes that should move
	_container = (IGraphicalEditPart) findPool(underMouse);

	// the children that will be moved around
	List<IGraphicalEditPart> rightChildren = new ArrayList<IGraphicalEditPart>();
	List<IGraphicalEditPart> subProcesses = 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) {
				setBoundsForOverlapComputation((IGraphicalEditPart) child,SINGLETON) ;
				((DiagramEditPart) getCurrentViewer().getContents())
				.getFigure().translateToRelative(SINGLETON);
				if (SINGLETON.x > _initPosNoZoom) {
					rightChildren.add((IGraphicalEditPart) child);
				} 
			}
		}
	}
	_movingShapes = rightChildren;
	_subProcesses = subProcesses;

	updateSourceRequest();
	showSourceFeedback();

	return true;
}
 
Example 20
Source File: DataWizardIT.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
@Test
public void testDataDefaultValueReturnType() 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_DATA).show();

    SWTBotTestUtil.selectTabbedPropertyView(bot, SWTBotTestUtil.VIEWS_PROPERTIES_POOL_DATA_VARIABLES);

    bot.buttonWithId(SWTBotConstants.SWTBOT_ID_ADD_PROCESS_DATA).click();
    // Shell "New variable"
    bot.waitUntil(Conditions.shellIsActive(Messages.newVariable));

    final String dataName = "myDataName";
    bot.textWithLabel(Messages.name + " *").setText(dataName);

    String defaultValue = "test return type";
    bot.textWithLabel(Messages.defaultValueLabel).setText(defaultValue);
    bot.sleep(500);

    SWTBotShell activeShell = bot.activeShell();
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON).click();
    assertEquals("Expression return type should be " + String.class.getName(), String.class.getName(),
            bot.comboBoxWithLabel(Messages.returnType).getText());
    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.comboBoxWithLabel(Messages.datatypeLabel).setSelection(DataTypeLabels.integerDataType);

    defaultValue = "50";
    bot.textWithLabel(Messages.defaultValueLabel).setText(defaultValue);
    bot.sleep(500);
    bot.toolbarButtonWithId(ExpressionViewer.SWTBOT_ID_EDITBUTTON).click();
    assertEquals("Expression return type should be " + Integer.class.getName(), Integer.class.getName(),
            bot.comboBoxWithLabel(Messages.returnType)
                    .getText());

    bot.button(IDialogConstants.OK_LABEL).click();
    activeShell.setFocus();
    bot.waitUntil(Conditions.widgetIsEnabled(bot.button(IDialogConstants.FINISH_LABEL)));
    bot.button(IDialogConstants.FINISH_LABEL).click();
}