Java Code Examples for org.eclipse.gef.EditPart#getChildren()

The following examples show how to use org.eclipse.gef.EditPart#getChildren() . 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: 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 2
Source File: StateMachineDiagramElementsManager.java    From txtUML with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Adds the children of a state to the state.
 * (Calls the {@link #addSubElements(EditPart)} for every region) 
 * @param state - The state
 */
private void fillState(EditPart state, List<Element> elements){
	EditPart ep = StateMachineDiagramElementsController.getStateCompartmentEditPart(state);
	if(ep == null) {
		ep = StateMachineDiagramElementsController.getCustomStateMachineCompartmentEditPart(state);
	}
	if(ep == null) {
		return;
	}
	@SuppressWarnings("unchecked")
	List<RegionEditPart> regions = ep.getChildren();
	
	for(RegionEditPart region : regions){
		this.addSubElements(region, elements);
	}
}
 
Example 3
Source File: ReportEditorWithPalette.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private EditPart getInterestEditPart( EditPart part, Object obj )
{
	List chList = part.getChildren( );
	for ( int i = 0; i < chList.size( ); i++ )
	{
		ReportElementEditPart reportEditPart = (ReportElementEditPart) chList.get( i );
		if ( reportEditPart.isinterestSelection( obj ) )
		{
			return reportEditPart;
		}
		else
		{
			EditPart retValue = getInterestEditPart( reportEditPart, obj );
			if ( retValue != null )
			{
				return retValue;
			}
		}
	}
	return null;
}
 
Example 4
Source File: DefaultBreadcrumbNodeProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
private EditPart getInterestEditPart( EditPart part, Object obj )
{
	List chList = part.getChildren( );
	for ( int i = 0; i < chList.size( ); i++ )
	{
		ReportElementEditPart reportEditPart = (ReportElementEditPart) chList.get( i );
		if ( reportEditPart.isinterestSelection( obj ) )
		{
			return reportEditPart;
		}
		else
		{
			EditPart retValue = getInterestEditPart( reportEditPart, obj );
			if ( retValue != null )
			{
				return retValue;
			}
		}
	}
	return null;
}
 
Example 5
Source File: WalkerGroupEditPart.java    From erflute with Apache License 2.0 6 votes vote down vote up
@Override
protected Rectangle getRectangle() {
    final Rectangle rectangle = super.getRectangle();
    final WalkerGroup group = (WalkerGroup) getModel();
    final EditPart contents = getRoot().getContents();
    for (final Object child : contents.getChildren()) {
        if (child instanceof DiagramWalkerEditPart) {
            final DiagramWalkerEditPart editPart = (DiagramWalkerEditPart) child;
            if (group.contains((DiagramWalker) editPart.getModel())) {
                final Rectangle bounds = editPart.getFigure().getBounds();
                if (bounds.x + bounds.width > rectangle.x + rectangle.width) {
                    rectangle.width = bounds.x + bounds.width - rectangle.x;
                }
                if (bounds.y + bounds.height > rectangle.y + rectangle.height) {
                    rectangle.height = bounds.y + bounds.height - rectangle.y;
                }
                if (rectangle.width != group.getWidth() || rectangle.height != group.getHeight()) {
                    group.setLocation(new Location(group.getX(), group.getY(), rectangle.width, rectangle.height));
                }
            }
        }
    }
    return rectangle;
}
 
Example 6
Source File: CustomCatchLinkEvent2EditPart.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void handleNotificationEvent(Notification notification) {
	super.handleNotificationEvent(notification);
	Object feature = notification.getFeature();
	//if name changed
	if(notification.getEventType() == Notification.SET
			&& feature.equals(ProcessPackage.Literals.ELEMENT__NAME)){
		final IGraphicalEditPart topGraphicEditPart = (IGraphicalEditPart) getRoot().getChildren().get(0);
		for(ThrowLinkEvent tle : ((CatchLinkEvent)resolveSemanticElement()).getFrom()){
			/*Get the corresponding ThrowLinkEditpart*/
			final EditPart findEditPart = topGraphicEditPart.findEditPart(topGraphicEditPart, tle);
			if(findEditPart != null){
				/*refresh the label edit part*/
				for(EditPart childPart : (List<EditPart>)findEditPart.getChildren()){
					childPart.refresh();
				}
			}
		}
	}
}
 
Example 7
Source File: AbstractReportEditPart.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void updateChildrenLayoutPreference(EditPart part)
{
	if (part instanceof ReportElementEditPart)
	{
		((ReportElementEditPart)part).updateLayoutPreference( );
	}
	List children = part.getChildren( );
	int size = children.size( );
	for ( int i = 0; i < size; i++ )
	{
		Object chPart = children.get( i );
		updateChildrenLayoutPreference( (EditPart)chPart);	
	}
}
 
Example 8
Source File: ImporterUtil.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private static String getTextFromEditPart(EditPart o) {
    for(Object obj : o.getChildren()){
        if(obj instanceof ITextAwareEditPart){
            return ((ITextAwareEditPart)obj).getEditText();
        }
    }
    return null;
}
 
Example 9
Source File: CustomDragDropEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private boolean isCollapsed(EditPart ep) {
    if(ep instanceof ShapeCompartmentEditPart){
        return !((ShapeCompartmentEditPart) ep).getCompartmentFigure().isExpanded() ;
    }else{
        if(ep instanceof ITextAwareEditPart){
            ep=ep.getParent() ;
        }
        for(final Object child : ep.getChildren()){
            if(child instanceof ShapeCompartmentEditPart){
                return !((ShapeCompartmentEditPart) child).getCompartmentFigure().isExpanded() ;
            }
        }
    }
    return false;
}
 
Example 10
Source File: SequenceFlowCreationEditPolicy.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private EditPart getCompartmentEditPart(EditPart target) {
	if(target instanceof ShapeCompartmentEditPart){
		return target;
	}else{
		for(Object c : target.getChildren()){
			if(c instanceof ShapeCompartmentEditPart){
				return (EditPart) c;
			}
		}
	}
	return null;
}
 
Example 11
Source File: MultiPageReportEditor.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
private void refreshResourceEditPart( EditPart parent )
{
	if ( parent instanceof IResourceEditPart )
	{
		( (IResourceEditPart) parent ).refreshResource( );
	}
	List list = parent.getChildren( );
	for ( int i = 0; i < list.size( ); i++ )
	{
		EditPart part = (EditPart) list.get( i );
		refreshResourceEditPart( part );
	}
}
 
Example 12
Source File: RootDragTracker.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns a list including all of the children of the edit part passed in.
 */
private List getAllChildren( EditPart editPart, List allChildren )
{
	List children = editPart.getChildren( );
	for ( int i = 0; i < children.size( ); i++ )
	{
		GraphicalEditPart child = (GraphicalEditPart) children.get( i );
		allChildren.add( child );
		getAllChildren( child, allChildren );
	}
	return allChildren;
}
 
Example 13
Source File: ActivityDiagramElementsGmfArranger.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void arrange(IProgressMonitor monitor) {
	monitor.beginTask("Arrange", 1);
	monitor.subTask("Arranging elements...");
	EditPart activityEditpart = (EditPart) diagep.getChildren().get(0);
	EditPart activityContentEditpart = (EditPart) activityEditpart.getChildren().get(5);
	super.arrangeChildren(activityContentEditpart);
	@SuppressWarnings("unchecked")
	List<GraphicalEditPart> listEp =  activityContentEditpart.getChildren();
	DiagramElementsModifier.hideConnectionLabelsForEditParts(listEp, Arrays.asList(ObjectFlowGuardEditPart.class, ControlFlowGuardEditPart.class));
	monitor.worked(1);
}
 
Example 14
Source File: AbstractDiagramElementsGmfArranger.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Arranges the children of an EditPart with the GMF arranging algorithm 
 * @param parent - The children of this EditPart will be arranged
 */
protected void arrangeChildren(EditPart parent) {
	@SuppressWarnings("unchecked")
	List<EditPart> elements = parent.getChildren();

	if(!elements.isEmpty()){
		ArrangeRequest arrangeRequest = new ArrangeRequest(ActionIds.ACTION_ARRANGE_ALL);
		List<EditPart> l = new ArrayList<EditPart>();
		l.addAll(elements);
		arrangeRequest.setPartsToArrange(l);
		Command cmd = parent.getCommand(arrangeRequest);
		cmd.execute();
	}
}
 
Example 15
Source File: StateMachineDiagramElementsController.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param ep
 * @return
 */
public static CustomStateMachineCompartmentEditPart getCustomStateMachineCompartmentEditPart(EditPart ep) {
	@SuppressWarnings("unchecked")
	List<Object> compartments = ep.getChildren();
	for(Object compartment : compartments) {
		if(compartment instanceof CustomStateMachineCompartmentEditPart) {
			return (CustomStateMachineCompartmentEditPart) compartment;
		}
	}
	return null;
}
 
Example 16
Source File: StateMachineDiagramElementsController.java    From txtUML with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @param ep
 * @return
 */
public static StateCompartmentEditPart getStateCompartmentEditPart(EditPart ep) {
	@SuppressWarnings("unchecked")
	List<Object> compartments = ep.getChildren();
	for(Object compartment : compartments) {
		if(compartment instanceof StateCompartmentEditPart) {
			return (StateCompartmentEditPart) compartment;
		}
	}
	return null;
}
 
Example 17
Source File: CustomFeedbackXYLayoutPolicy.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Override to compute position of Subprocess event children when changing parent
 */
@Override
protected Command createAddCommand(final EditPart child, final Object constraint) {
    if (child instanceof CustomSubProcessEvent2EditPart && constraint instanceof Rectangle) {
        final Rectangle rect = (Rectangle) constraint;

        final CompoundCommand cmds = new CompoundCommand("Move Subprocesss Event");

        ICommand boundsCommand = new SetBoundsCommand(((ShapeEditPart) child).getEditingDomain(),
                DiagramUIMessages.SetLocationCommand_Label_Resize,
                new EObjectAdapter((View) child.getModel()),
                rect.getTopLeft());

        cmds.add(new ICommandProxy(boundsCommand));

        ShapeCompartmentEditPart compartment = null;
        for (final Object c : child.getChildren()) {
            if (c instanceof ShapeCompartmentEditPart) {
                compartment = (ShapeCompartmentEditPart) c;
            }
        }

        final Location origin = (Location) ((Node) child.getModel()).getLayoutConstraint();
        for (final Object ep : compartment.getChildren()) {
            if (ep instanceof IGraphicalEditPart) {
                final Node view = (Node) ((IGraphicalEditPart) ep).getModel();
                final Location loc = (Location) view.getLayoutConstraint();
                final Point delta = new Point(loc.getX() - origin.getX(), loc.getY() - origin.getY());

                final Point newLoc = new Point(rect.getTopLeft().x + delta.x, rect.getTopLeft().y + delta.y);

                boundsCommand = new SetBoundsCommand(((IGraphicalEditPart) ep).getEditingDomain(),
                        DiagramUIMessages.SetLocationCommand_Label_Resize,
                        new EObjectAdapter((View) ((IGraphicalEditPart) ep).getModel()),
                        newLoc);

                cmds.add(new ICommandProxy(boundsCommand));
            }
        }

        return cmds.unwrap();
    } else {
        return super.createAddCommand(child, constraint);
    }

}