org.eclipse.gef.EditPart Java Examples

The following examples show how to use org.eclipse.gef.EditPart. 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: ProcessMarkerNavigationProvider.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
protected void doGotoMarker(IMarker marker) {
	String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
	if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
		return;
	}
	DiagramEditor editor = (DiagramEditor) getEditor();
	Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
	EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
	if (targetView == null) {
		return;
	}
	EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
	if (targetEditPart != null) {
		ProcessDiagramEditorUtil.selectElementsInDiagram(editor, Arrays.asList(new EditPart[] { targetEditPart }));
	}
}
 
Example #2
Source File: EditorDragGuidePolicy.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * When drag the margin guide, the attache editparts move with the guide.
 * Now do nothing
 * 
 * @param request
 */
private void eraseAttachedPartsFeedback( Request request )
{
	if ( attachedEditParts != null )
	{
		ChangeBoundsRequest req = new ChangeBoundsRequest( request
				.getType( ) );
		req.setEditParts( attachedEditParts );

		Iterator i = attachedEditParts.iterator( );

		while ( i.hasNext( ) )
			( (EditPart) i.next( ) ).eraseSourceFeedback( req );
		attachedEditParts = null;
	}
}
 
Example #3
Source File: Activity2EditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected boolean addFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof ActivityName2EditPart) {
		((ActivityName2EditPart) childEditPart).setLabel(getPrimaryShape().getFigureActivityNameFigure());
		if (VISUAL_ID != 3007 && VISUAL_ID != 2007 && VISUAL_ID != 3015 && VISUAL_ID != 3058) {
			getPrimaryShape().getFigureActivityNameFigure()
					.addMouseMotionListener(new ActivityNameCursorMouseMotionListener(this));
		}
		return true;
	}

	if (childEditPart instanceof IntermediateErrorCatchEvent6EditPart) {
		BorderItemLocator locator = new ActivityBorderItemLocator(getMainFigure(), PositionConstants.SOUTH);
		getBorderedFigure().getBorderItemContainer()
				.add(((IntermediateErrorCatchEvent6EditPart) childEditPart).getFigure(), locator);
		return true;
	}
	return false;
}
 
Example #4
Source File: EditpartExtensionManager.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public static EditPart createEditPart( EditPart context, Object model )
{
	EvaluationContext econtext = new EvaluationContext( null, model );
	for ( Iterator<Expression> iterator = extensionMap.keySet( ).iterator( ); iterator.hasNext( ); )
	{
		try
		{
			Expression expression = iterator.next( );
			if ( expression.evaluate( econtext ) == EvaluationResult.TRUE )
			{
				EditPart editPart = (EditPart) extensionMap.get( expression )
						.createExecutableExtension( "type" ); //$NON-NLS-1$
				editPart.setModel( model );
				return editPart;
			}
		}
		catch ( CoreException e )
		{
			logger.log( Level.SEVERE, e.getMessage( ), e );
		}
	}
	return null;
}
 
Example #5
Source File: CrossflowMarkerNavigationProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
protected void doGotoMarker(IMarker marker) {
	String elementId = marker.getAttribute(org.eclipse.gmf.runtime.common.core.resources.IMarker.ELEMENT_ID, null);
	if (elementId == null || !(getEditor() instanceof DiagramEditor)) {
		return;
	}
	DiagramEditor editor = (DiagramEditor) getEditor();
	Map editPartRegistry = editor.getDiagramGraphicalViewer().getEditPartRegistry();
	EObject targetView = editor.getDiagram().eResource().getEObject(elementId);
	if (targetView == null) {
		return;
	}
	EditPart targetEditPart = (EditPart) editPartRegistry.get(targetView);
	if (targetEditPart != null) {
		CrossflowDiagramEditorUtil.selectElementsInDiagram(editor,
				Arrays.asList(new EditPart[] { targetEditPart }));
	}
}
 
Example #6
Source File: DiagramElementsModifierTest.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Test for moveGraphicalEditPart
 */
@Test
public void moveGraphicalEditPartTest() {

	List<Pair<String, Class<?>>> objects = Arrays
			.asList(new Pair<String, Class<?>>("ClassA",
					org.eclipse.uml2.uml.Class.class));
	init(objects, Arrays.asList());
	@SuppressWarnings("unchecked")
	List<EditPart> eps = getDiagramEditPart().getChildren();
	ClassEditPart classEp = (ClassEditPart) eps.get(0);

	int new_x = 250;
	int new_y = 150;
	DiagramElementsModifier.moveGraphicalEditPart(classEp, new Point(new_x,
			new_y));

	Assert.assertTrue(classEp.getModel() instanceof CSSShapeImpl);
	LayoutConstraint layoutConstraint = ((CSSShapeImpl) classEp.getModel())
			.getLayoutConstraint();
	Assert.assertTrue(layoutConstraint instanceof BoundsImpl);
	Assert.assertEquals(new_x, ((BoundsImpl) layoutConstraint).getX());
	Assert.assertEquals(new_y, ((BoundsImpl) layoutConstraint).getY());
}
 
Example #7
Source File: ProcessDiagramUpdateCommand.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
* @generated
*/
public Object execute(ExecutionEvent event) throws ExecutionException {
	ISelection selection = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService()
			.getSelection();
	if (selection instanceof IStructuredSelection) {
		IStructuredSelection structuredSelection = (IStructuredSelection) selection;
		if (structuredSelection.size() != 1) {
			return null;
		}
		if (structuredSelection.getFirstElement() instanceof EditPart
				&& ((EditPart) structuredSelection.getFirstElement()).getModel() instanceof View) {
			EObject modelElement = ((View) ((EditPart) structuredSelection.getFirstElement()).getModel())
					.getElement();
			List editPolicies = CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
			for (Iterator it = editPolicies.iterator(); it.hasNext();) {
				CanonicalEditPolicy nextEditPolicy = (CanonicalEditPolicy) it.next();
				nextEditPolicy.refresh();
			}

		}
	}
	return null;
}
 
Example #8
Source File: ERDiagramAlignmentAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private Command createAlignmentCommand() {
	AlignmentRequest request = new AlignmentRequest(
			RequestConstants.REQ_ALIGN);
	request.setAlignmentRectangle(calculateAlignmentRectangle(request));
	request.setAlignment(alignment);
	List editparts = getOperationSet(request);
	if (editparts.size() < 2)
		return null;

	CompoundCommand command = new CompoundCommand();
	command.setDebugLabel(getText());
	for (int i = 0; i < editparts.size(); i++) {
		EditPart editpart = (EditPart) editparts.get(i);
		command.add(editpart.getCommand(request));
	}
	return command;
}
 
Example #9
Source File: LaneEditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
protected boolean addFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof LaneNameEditPart) {
		((LaneNameEditPart) childEditPart).setLabel(getPrimaryShape().getFigureLaneNameFigure());
		if (VISUAL_ID != 3007 && VISUAL_ID != 2007 && VISUAL_ID != 3015 && VISUAL_ID != 3058) {
			getPrimaryShape().getFigureLaneNameFigure()
					.addMouseMotionListener(new ActivityNameCursorMouseMotionListener(this));
		}
		return true;
	}
	if (childEditPart instanceof LaneLaneCompartmentEditPart) {
		IFigure pane = getPrimaryShape().getFigureLaneContainerFigure();
		setupContentPane(pane); // FIXME each comparment should handle his content pane in his own way 
		pane.add(((LaneLaneCompartmentEditPart) childEditPart).getFigure());
		return true;
	}

	return false;
}
 
Example #10
Source File: AbstractReportEditPart.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
protected void reloadTheChildren( )
{
	List list = new ArrayList( getChildren( ) );
	int size = list.size( );

	for ( int i = 0; i < size; i++ )
	{
		EditPart part = (EditPart) list.get( i );

		removeChild( part );
	}

	list = getModelChildren( );
	size = list.size( );
	for ( int i = 0; i < size; i++ )
	{
		Object model = list.get( i );
		addChild( createChild( model ), i );
	}
	
	refreshVisuals( );
}
 
Example #11
Source File: ChangeBackgroundColorAction.java    From ermaster-b with Apache License 2.0 6 votes vote down vote up
private void setRGB(RGB rgb) {
	this.rgb = rgb;

	EditPart editPart = ((ERDiagramEditor) this.getWorkbenchPart())
			.getGraphicalViewer().getContents();

	if (editPart.getModel() instanceof ERModel) {
		// �r���[�̔w�i�F�ύX
		ERModel model = (ERModel) editPart.getModel();
		model.setDefaultColor(this.rgb.red, this.rgb.green, this.rgb.blue);
	} else {
		// �S�̃r���[�̔w�i�F�ύX
		ERDiagram diagram = ERModelUtil.getDiagram(editPart);
		diagram.setDefaultColor(this.rgb.red, this.rgb.green, this.rgb.blue);
	}

	this.setColorToImage();
}
 
Example #12
Source File: DiagramElementsModifierTest.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Test for resizeGraphicalEditPart
 */
@Test
public void resizeGraphicalEditPartTest() {

	List<Pair<String, Class<?>>> objects = Arrays
			.asList(new Pair<String, Class<?>>("ClassB",
					org.eclipse.uml2.uml.Class.class));
	init(objects, Arrays.asList());
	@SuppressWarnings("unchecked")
	List<EditPart> eps = getDiagramEditPart().getChildren();
	ClassEditPart classEp = (ClassEditPart) eps.get(0);

	int new_width = 200;
	int new_height = 600;
	DiagramElementsModifier.resizeGraphicalEditPart(classEp, new_width,
			new_height);

	Assert.assertTrue(classEp.getModel() instanceof CSSShapeImpl);
	LayoutConstraint layoutConstraint = ((CSSShapeImpl) classEp.getModel())
			.getLayoutConstraint();

	Assert.assertTrue(layoutConstraint instanceof BoundsImpl);

	Assert.assertEquals(new_width,
			((BoundsImpl) layoutConstraint).getWidth());
	Assert.assertEquals(new_height,
			((BoundsImpl) layoutConstraint).getHeight());
}
 
Example #13
Source File: RegionPriorityDecorationProvider.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createDecorators(IDecoratorTarget decoratorTarget) {
	EditPart editPart = (EditPart) decoratorTarget.getAdapter(EditPart.class);
	if (editPart instanceof GraphicalEditPart || editPart instanceof AbstractConnectionEditPart) {
		EditDomain ed = editPart.getViewer().getEditDomain();
		if (!(ed instanceof DiagramEditDomain)) {
			return;
		}
		if (shouldInstall(((DiagramEditDomain) ed).getEditorPart()) && editPart instanceof RegionEditPart) {
			IDecorator decorator = createStatusDecorator(decoratorTarget);
			decorators.add(decorator);
			decoratorTarget.installDecorator(getDecoratorKey(), decorator);
		}
	}
}
 
Example #14
Source File: RegionEditPart.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void addChildVisual(EditPart childEditPart, int index) {
	if (childEditPart instanceof RegionCompartmentEditPart) {
		IFigure pane = getPrimaryShape().getCompartmentPane();
		pane.setLayoutManager(new StackLayout());
		IFigure figure2 = ((RegionCompartmentEditPart) childEditPart).getFigure();
		pane.add(figure2);
	} else if (childEditPart instanceof RegionNameEditPart) {
		((RegionNameEditPart) childEditPart).setLabel(getPrimaryShape().getNameLabel());
	} else
		super.addChildVisual(childEditPart, index);
}
 
Example #15
Source File: ServiceTaskEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @Generated BonitaSoft
 */
@Override
public Object getAdapter(Class key) {

	if (key == SnapToHelper.class) {
		EditPart parent = getParent();
		while (!(parent instanceof DiagramEditPart)) {
			parent = parent.getParent();
		}
		return GMFTools.getSnapHelper((GraphicalEditPart) parent);
	}

	return super.getAdapter(key);
}
 
Example #16
Source File: DataColumnXTabDropAdapter.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private DesignElementHandle getExtendedItemHandle( Object target )
{
	if ( target instanceof CrosstabTableEditPart )
		return (DesignElementHandle) ( (CrosstabTableEditPart) target ).getModel( );
	if ( target instanceof EditPart )
	{
		EditPart part = (EditPart) target;
		DesignElementHandle handle = (DesignElementHandle) ( (IAdaptable) target ).getAdapter( DesignElementHandle.class );
		if ( handle == null && part.getParent( ) != null )
			return getExtendedItemHandle( part.getParent( ) );

	}
	return null;
}
 
Example #17
Source File: CsvSinkEditPart.java    From scava with Eclipse Public License 2.0 5 votes vote down vote up
/**
* @generated
*/
protected boolean removeFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof CsvSinkNameEditPart) {
		return true;
	}
	return false;
}
 
Example #18
Source File: IntermediateErrorCatchEvent3EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @Generated BonitaSoft
 */
@Override
public java.lang.Object getAdapter(Class key) {

	if (key == SnapToHelper.class) {
		EditPart parent = getParent();
		while (!(parent instanceof DiagramEditPart)) {
			parent = parent.getParent();
		}
		return GMFTools.getSnapHelper((GraphicalEditPart) parent);
	}

	return super.getAdapter(key);
}
 
Example #19
Source File: SendTaskEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
protected boolean removeFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof SendTaskLabelEditPart) {
		return true;
	}
	return false;
}
 
Example #20
Source File: BorderItemEditPart.java    From statecharts with Eclipse Public License 1.0 5 votes vote down vote up
@Override
protected void removeChildVisual(EditPart childEditPart) {
	if (childEditPart instanceof NamedElementLabelEditPart) {
		getFigure().remove(
				((NamedElementLabelEditPart) childEditPart).getFigure());
	} else
		super.removeChildVisual(childEditPart);
}
 
Example #21
Source File: BoundaryMessageEventEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @Generated BonitaSoft
 */
@Override
public java.lang.Object getAdapter(Class key) {

	if (key == SnapToHelper.class) {
		EditPart parent = getParent();
		while (!(parent instanceof DiagramEditPart)) {
			parent = parent.getParent();
		}
		return GMFTools.getSnapHelper((GraphicalEditPart) parent);
	}

	return super.getAdapter(key);
}
 
Example #22
Source File: ERModelUtil.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
public static ERDiagram getDiagram(EditPart editPart) {
	Object model = editPart.getModel();
	if (model instanceof ERModel) {
		return ((ERModel) model).getDiagram();

	}
	return (ERDiagram) model;
}
 
Example #23
Source File: ERDiagramAlignmentAction.java    From ermasterr with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the list of editparts which will participate in alignment.
 * 
 * @param request
 *            the alignment request
 * @return the list of parts which will be aligned
 */
@SuppressWarnings("unchecked")
protected List getOperationSet(final Request request) {
    if (operationSet != null)
        return operationSet;
    List editparts = new ArrayList(getSelectedObjects());
    for (final Iterator iter = editparts.iterator(); iter.hasNext();) {
        if (iter.next() instanceof NormalColumnEditPart) {
            iter.remove();
        }
    }

    if (editparts.isEmpty() || !(editparts.get(0) instanceof GraphicalEditPart))
        return Collections.EMPTY_LIST;
    final Object primary = editparts.get(editparts.size() - 1);
    editparts = ToolUtilities.getSelectionWithoutDependants(editparts);
    ToolUtilities.filterEditPartsUnderstanding(editparts, request);
    if (editparts.size() < 2 || !editparts.contains(primary))
        return Collections.EMPTY_LIST;
    final EditPart parent = ((EditPart) editparts.get(0)).getParent();
    for (int i = 1; i < editparts.size(); i++) {
        final EditPart part = (EditPart) editparts.get(i);
        if (part.getParent() != parent)
            return Collections.EMPTY_LIST;
    }
    return editparts;
}
 
Example #24
Source File: ERDiagramBendpointEditPolicy.java    From erflute with Apache License 2.0 5 votes vote down vote up
@Override
protected void showSelection() {
    final EditPart contents = getHost().getRoot().getContents();
    if (contents instanceof ERVirtualDiagramEditPart) {
        final ERVirtualDiagramEditPart part = (ERVirtualDiagramEditPart) contents;
        part.refreshVisuals();
    } else {
        final ERDiagramEditPart diagramEditPart = (ERDiagramEditPart) contents;
        diagramEditPart.refreshVisuals();
    }

    super.showSelection();
}
 
Example #25
Source File: ClassDiagramElementsController.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param interfaceEditPart
 * @param extensionEnd
 */
public static void addExtensionEndToInterface(InterfaceEditPart interfaceEditPart, ExtensionEnd extensionEnd){
	EditPart ep = getInterfaceAttributeEditPart(interfaceEditPart);
	if(ep != null) {
		ElementsManagerUtils.addElementToEditPart(ep, extensionEnd);
	}
}
 
Example #26
Source File: AbstractBonitaDecorator.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param fig
 * @return
 */
protected int getDelta(final Node view){
    if(getDecoratorTarget().getAdapter(EditPart.class) instanceof IGraphicalEditPart){
        final IGraphicalEditPart ep = (IGraphicalEditPart) getDecoratorTarget().getAdapter(EditPart.class) ;
        if(ep.resolveSemanticElement() instanceof SubProcessEvent){
            return -5 ;
        }
    }

    int delta = -5 ;
    if(view != null){
        final LayoutConstraint layoutConstraint = view.getLayoutConstraint();
        if (layoutConstraint instanceof Size) {
            final int width = ((Size)layoutConstraint).getWidth() ;
            if(width != 0){
                delta = - (width / 15) ;
                if(delta > -5){
                    delta = -5 ;
                }
            }else{
                delta = - 5 ;
            }
        }

    }

    return delta;
}
 
Example #27
Source File: CustomSubprocessEventCompartmentEditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public Object getAdapter(Class key) {

    if (key == SnapToHelper.class) {
        EditPart parent = getParent();
        while (!(parent instanceof DiagramEditPart)) {
            parent = parent.getParent();
        }
        return GMFTools.getSnapHelper((GraphicalEditPart) parent);
    }

    return super.getAdapter(key);
}
 
Example #28
Source File: ERDiagramBendpointEditPolicy.java    From ermaster-b with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
protected void showSelection() {
	EditPart contents = this.getHost().getRoot().getContents();
	if (contents instanceof ERModelEditPart) {
		ERModelEditPart part = (ERModelEditPart) contents;
		part.refreshVisuals();
	} else {
		ERDiagramEditPart diagramEditPart = (ERDiagramEditPart) contents;
		diagramEditPart.refreshVisuals();
	}

	super.showSelection();
}
 
Example #29
Source File: SubProcessEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
protected boolean addFixedChild(EditPart childEditPart) {
	if (childEditPart instanceof SubProcessEventLabel2EditPart) {
		((SubProcessEventLabel2EditPart) childEditPart)
				.setLabel(getPrimaryShape().getFigureEventSubProcessNameFigure());
		if (VISUAL_ID != 3007 && VISUAL_ID != 2007 && VISUAL_ID != 3015 && VISUAL_ID != 3058) {
			getPrimaryShape().getFigureEventSubProcessNameFigure()
					.addMouseMotionListener(new ActivityNameCursorMouseMotionListener(this));
		}
		return true;
	}

	return false;
}
 
Example #30
Source File: EndEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @Generated BonitaSoft
 */
@Override
public Object getAdapter(Class key) {

	if (key == SnapToHelper.class) {
		EditPart parent = getParent();
		while (!(parent instanceof DiagramEditPart)) {
			parent = parent.getParent();
		}
		return GMFTools.getSnapHelper((GraphicalEditPart) parent);
	}

	return super.getAdapter(key);
}