Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » "List" layout on canvas
"List" layout on canvas [message #485984] Tue, 15 September 2009 19:41 Go to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi,

I want to have a "list" layout on the canvas of my gmf editor.

- no overlap
- one element by line
- a policy with horizontal line to indicate to user between each elements th e new or moved element will be placed after drop

By now I try :
- gmfgen-> gen editor generator -> gen diagram -> figure view map -> layout type : FLOW_LAYOUT
- set a layout editpolicy

result :
at the creation my element are correctly set in place (more or less, they are always added at the end of the list) but they are one per line
when I close and reopen or refresh they reduce them as little square and I've got a lot in the same line even if I set a minimun dimension
For the line guiding the user, it appears on each EditPart but not between them, i.e. not on the canvas

So how can I do that? will my approach good?

Thanks by advance for any hints

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #486203 is a reply to message #485984] Wed, 16 September 2009 17:47 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Hi again,

I progressed... a little.

I try with :
mfgen-> gen editor generator -> gen diagram -> figure view map -> layout type
: TOOLBAR_LAYOUT

and it keeps one per line even after reopen the editor.

But the new element are always added at the end of the canvas.

and another issue is that I can't add an EditPolicy which affect the
canvas between each EditPart which constitutes line. I can only apply it
on each EditPart and so inside each of them.


Aurelien Pupier wrote:

> Hi,

> I want to have a "list" layout on the canvas of my gmf editor.

> - no overlap
> - one element by line
> - a policy with horizontal line to indicate to user between each elements
th e new or moved element will be placed after drop

> By now I try :
> - gmfgen-> gen editor generator -> gen diagram -> figure view map -> layout
type : FLOW_LAYOUT
> - set a layout editpolicy

> result :
> at the creation my element are correctly set in place (more or less, they
are always added at the end of the list) but they are one per line
> when I close and reopen or refresh they reduce them as little square and
I've got a lot in the same line even if I set a minimun dimension
> For the line guiding the user, it appears on each EditPart but not between
them, i.e. not on the canvas

> So how can I do that? will my approach good?

> Thanks by advance for any hints

> Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #486234 is a reply to message #486203] Wed, 16 September 2009 20:04 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: news.sascha.gessler.googlemail.com

Hi,

> I progressed... a little.

> I try with :
> mfgen-> gen editor generator -> gen diagram -> figure view map -> layout
type
> : TOOLBAR_LAYOUT

You need to overwrite the following figure of your diagram edit part:

protected IFigure createFigure() {
FreeformLayer l = new FreeformLayer();
l.setBorder(new MarginBorder(50));
ToolbarLayout lm = new ToolbarLayout();
lm.setSpacing(10);
l.setLayoutManager(lm);
return l;
}

(and don't forget to set the @generatednot tag, otherwise you loose your
configuration after regenerating the diagram editor)

> and another issue is that I can't add an EditPolicy which affect the
> canvas between each EditPart which constitutes line. I can only apply it
> on each EditPart and so inside each of them.
By setting the spacing (lm.setSpacing(10)) you can affect those.


> But the new element are always added at the end of the canvas.

See GMF Recipes "HowTo add children in a GMF compartment at a specific
position" at:
http://wiki.eclipse.org/GMF/Recipes


Another hint: If you want to do the same for compartments set the
listLayout attribute (GMFGen) and again overwrite the createFigure method.


Cheers,

sas
Re: "List" layout on canvas [message #486491 is a reply to message #485984] Thu, 17 September 2009 20:24 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

First thank you very much sas, your advice really help me a lot.

It begins to work :
- can create an element at the right place, ie at the place where the line feedback was
- can move element, so reorder the list

but still have some issues :
- when reopening a diagram, all elements are smaller (little square) and are on the same line
- drop an element at the bottom, create it at the penultimate place and not the last
- there is no line feedback on the move of an element
- when I try to move an element which has a part hidden because it is out of the scope of the editor, the feedback of the figure have a doubled heigth
- when I resize the diagram editor, the next create elment doesn't have the same size as the previous created

NB : I replace with :
protected IFigure createFigure() {
FreeformLayer freeFormLayer = (FreeformLayer) super.createFigure();
FlowLayout layout = new FlowLayout();
layout.setMajorSpacing(getMapMode().DPtoLP(5));
layout.setMinorSpacing(getMapMode().DPtoLP(5));
layout.setObserveVisibility(true);
layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
layout.setHorizontal(true);
freeFormLayer.setLayoutManager(layout);

return freeFormLayer;
}

Thanks by advance

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team

[Updated on: Thu, 17 September 2009 20:48]

Report message to a moderator

Re: "List" layout on canvas [message #486895 is a reply to message #486491] Sun, 20 September 2009 19:37 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Aurelien Pupier wrote on Thu, 17 September 2009 16:24

but still have some issues :
- when reopening a diagram, all elements are smaller (little square) and are on the same line


This is my real big issue.
I really don't understand this behavior...
Where is the placement calculate when teh diagram open? How can I force it to be the same as if I create each element one after one?


Aurelien Pupier wrote on Thu, 17 September 2009 16:24

- drop an element at the bottom, create it at the penultimate place and not the last


the question is : why we can calculate and place the line feedack at the end but can't put the element at the end...


Aurelien Pupier wrote on Thu, 17 September 2009 16:24

- there is no line feedback on the move of an element


this is a known bug but I didn't find any workaround
I can have it but the line feedback is not deleted after dropping.
bug : http://bugs.eclipse.org/bugs/show_bug.cgi?id=276033
newsgroup related question : http://www.eclipse.org/newsportal/article.php?id=16524&g roup=eclipse.modeling.gmf


Aurelien Pupier wrote on Thu, 17 September 2009 16:24

- when I try to move an element which has a part hidden because it is out of the scope of the editor, the feedback of the figure have a doubled heigth


I don't look at it much deeper

Aurelien Pupier wrote on Thu, 17 September 2009 16:24

- when I resize the diagram editor, the next create elment doesn't have the same size as the previous created


Maybe an issue related to the first one (reordonment after reopen)


Aurelien Pupier wrote on Thu, 17 September 2009 16:24

NB : I replace with :
protected IFigure createFigure() {
FreeformLayer freeFormLayer = (FreeformLayer) super.createFigure();
FlowLayout layout = new FlowLayout();
layout.setMajorSpacing(getMapMode().DPtoLP(5));
layout.setMinorSpacing(getMapMode().DPtoLP(5));
layout.setObserveVisibility(true);
layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
layout.setHorizontal(true);
freeFormLayer.setLayoutManager(layout);

return freeFormLayer;
}


If someone can confirm me if it's like this that I have to do.

Thanks by advance for any help

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #487089 is a reply to message #486895] Mon, 21 September 2009 19:56 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Aurelien Pupier wrote on Sun, 20 September 2009 15:37
Aurelien Pupier wrote on Thu, 17 September 2009 16:24

but still have some issues :
- when reopening a diagram, all elements are smaller (little square) and are on the same line


This is my real big issue.
I really don't understand this behavior...
Where is the placement calculate when teh diagram open? How can I force it to be the same as if I create each element one after one?



Hi again,

I found perhaps a way to achieve this.
I set a child accesor on my element and when I modify it in th eproperty view the elemen ton the diagram is automatically updated and resized correctly!! So perhaps I can use the refresh which is called when I open my diagram. Now I can't find it because it is all generated and I don't know where I can find that. So if someone indicate me where I can take a look I will be thankful.

Thanks

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #487293 is a reply to message #487089] Tue, 22 September 2009 16:56 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Quote:

Where is the placement calculate when teh diagram open?



In my understanding there are two models in use that are stored by an GMF diagram editor. The first one is used to store the domain model you work on, for example myTest.petrinet in case of an GMF petrinet editor. The second model (which usually for our example would be stored in myTest.petrinet_diagram) is the diagram notation that actually stores all diagram related properties. Therefore the data you ask for should be stored in this model.

Quote:

How can I force it to be the same as if I create each element one after one?



A good way for me has been to configure this stuff in the .gmfgraph file. Usually I forbid users to resize nodes by setting a node's resize constraint feature to NONE and rather set add a default size facet to the node (right-click on node > add child > ...). This way the node automatically resizes according to the contained elements. For example if you put an Label inside the figure descriptor that represents your node, the node's size is determined by the size of the label, i.e. the more text the bigger the node.

Please note that the automatic layout mechanism is left out as soon as the user changes the size of the node for the first time. (This is actually why i set the resize constraint feature to NONE.)

Quote:

NB : I replace with :
protected IFigure createFigure() {
FreeformLayer freeFormLayer = (FreeformLayer) super.createFigure();
FlowLayout layout = new FlowLayout();
layout.setMajorSpacing(getMapMode().DPtoLP(5));
layout.setMinorSpacing(getMapMode().DPtoLP(5));
layout.setObserveVisibility(true);
layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
layout.setHorizontal(true);
freeFormLayer.setLayoutManager(layout);

return freeFormLayer;
}



I do something like this with my compartments:

        @Override
	public IFigure createFigure() {
		ResizableCompartmentFigure rcf = (ResizableCompartmentFigure) super.createFigure();
		  rcf.getContentPane().setLayoutManager(newConstrainedToolbarL ayout(
				HORIZONTAL, 
				STRETCH_NOT, 
				STRETCH_NOT, 
				DEFAULT_SPACING, 
				ALIGN_TOPLEFT));
		rcf.setBorder(null); // remove unwanted horizontal rule above compartment 
		return rcf;
	}

	protected ConstrainedToolbarLayout newConstrainedToolbarLayout(boolean vertical, 
			boolean stretchMajorAxis, boolean stretchMinorAxis, 
			int spacing,
			int minorAlignment) {
		ConstrainedToolbarLayout layout = new ConstrainedToolbarLayout(vertical);
		layout.setStretchMajorAxis(stretchMajorAxis);
		layout.setStretchMinorAxis(stretchMinorAxis);
		layout.setSpacing(spacing);
		layout.setMinorAlignment(minorAlignment);
		layout.setIgnoreInvisibleChildren(true);
		
		return layout;
	}


Best regards,

sas

[Updated on: Tue, 22 September 2009 17:38]

Report message to a moderator

Re: "List" layout on canvas [message #489036 is a reply to message #485984] Thu, 01 October 2009 09:53 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Thx again sas.

I tried your createFigure. The resize works pretty fine but you use a constrainedToolbarLayout which is not an orderedLayout. So when I move, or create an element at a precise place, the order in the model is not updated and that's a needed behavior for me.

I will retry with flowLayout and hope to be able to resize elements as I want.


Regards,

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #489069 is a reply to message #489036] Thu, 01 October 2009 12:34 Go to previous messageGo to next message
No real name is currently offline No real nameFriend
Messages: 31
Registered: September 2009
Member
Hi,

Quote:

The resize works pretty fine but you use a constrainedToolbarLayout which is not an orderedLayout. So when I move, or create an element at a precise place, the order in the model is not updated and that's a needed behavior for me.



Actually I can provide you with an implementation of this behavior for compartments with a ConstrainedToolbarLayout, which btw is based on the following GMF Recipes (http://wiki.eclipse.org/GMF/Recipes):
- "HowTo reorder children in a GMF compartment with Drag & Drop"
- "HowTo add children in a GMF compartment at a specific position"

In addition to the createFigure method given above you furthermore need to provide a customized createDefaultEditPolicies method that installs two more edit policies.

Best regards,

sas

Attachment: Implementation
/**
 * Layout edit policy that allows moving elements by drag and drop.
 *
 * @author sas
 */
public class CompartmentEditPolicy extends ConstrainedToolbarLayoutEditPolicy {
	
	/**
	 * the containing feature this edit policy works on
	 */
	private final EStructuralFeature mContainingFeature;

	/**
	 * Constructs a {@link CompartmentEditPolicy} that works on the given containing feature.
	 * 
	 * @param isHorizontal denotes whether the given compartment uses a horizontal layout 
	 * @param containingFeature the containing feature we work on
	 */
	public CompartmentEditPolicy(EStructuralFeature containingFeature) {
		super();
		
		Assert.isNotNull(containingFeature, "containing feature must be set");
		
		this.mContainingFeature = containingFeature;
	}
	
	protected EditPolicy createChildEditPolicy(EditPart child) {
		ResizableEditPolicyEx policy = new ResizableEditPolicyEx();
		policy.setResizeDirections(0);
		return policy;
	}

	@Override
	protected Command getMoveChildrenCommand(Request request) {
		
		CompoundCommand command = new CompoundCommand();
		List<?> editParts = ((ChangeBoundsRequest)request).getEditParts();
		
		EditPart insertionReference = getInsertionReference(request);
		for (int i = 0; i < editParts.size(); i++) {
			EditPart child = (EditPart)editParts.get(i);
			command.add(createMoveChildCommand(child, insertionReference));
		}
		return command.unwrap();
	}
	
	protected Command createMoveChildCommand(EditPart child, EditPart after) {	
		int newIndex;
		int displacement;

		int childIndex = getHost().getChildren().indexOf(child);
		int afterIndex = getHost().getChildren().indexOf(after);	

		if(afterIndex == -1) {
			newIndex = getHost().getChildren().size()-1;			
			displacement = newIndex - childIndex;
		} else {		
			newIndex = afterIndex;
			displacement = afterIndex - childIndex;
			if (childIndex <= afterIndex) {
				newIndex--;
				displacement--;			
			}
		}


		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost()).getEditingDomain();
		CompartmentChildRepositionCommand command = new CompartmentChildRepositionCommand(editingDomain, 
				child.getParent(), ((View) child.getParent().getModel()).getElement(), 
				mContainingFeature, childIndex, newIndex);

		eraseLayoutTargetFeedback(null);
		return new ICommandProxy(command);
	}
	
	protected EditPart getInsertionReference(Request request) {
		List<?> children = getHost().getChildren();

		if (request.getType().equals(RequestConstants.REQ_CREATE)) {
			int i = getFeedbackIndexFor(request);
			if (i == -1)
				return null;
			return (EditPart)children.get(i);
		}

		int index = getFeedbackIndexFor(request);
		if (index != -1) {
			List<?> selection = getHost().getViewer().getSelectedEditParts();
			do {
				EditPart editpart = (EditPart) children.get(index);
				if (!selection.contains(editpart))
					return editpart;
			} while (++index  < children.size());
		}
		return null; //Not found, add at the end.
	}

	/**
	 * @param request the Request
	 * @return the index for the insertion reference
	 */
	protected int getFeedbackIndexFor(Request request) {
		List<?> children = getHost().getChildren();
		if (children.isEmpty())
			return -1;
			
		Transposer transposer = new Transposer();
		transposer.setEnabled (!isHorizontal());
		
		Point p = transposer.t(getLocationFromRequest(request));

		// Current row bottom, initialize to above the top.
		int rowBottom = Integer.MIN_VALUE;
		int candidate = -1;
		for (int i = 0; i < children.size(); i++) {
			EditPart child = (EditPart) children.get(i);
			Rectangle rect = transposer.t(getAbsoluteBounds(((GraphicalEditPart)child)));
			if (rect.y > rowBottom) {
				/*
				 * We are in a new row, so if we don't have a candidate but yet are within the
				 * previous row, then the current entry becomes the candidate. This is because
				 * we know we must be to the right of center of the last Figure in the
				 * previous row, so this Figure (which is at the start of a new row) is the
				 * candidate.
				 */
				if (p.y <= rowBottom) {
					if (candidate == -1)
						candidate = i;
					break;
				} else
					candidate = -1; // Mouse's Y is outside the row, so reset the candidate
			}
			rowBottom = Math.max(rowBottom, rect.bottom());
			if (candidate == -1) {
				/*
				 * See if we have a possible candidate. It is a candidate if the cursor is
				 * left of the center of this candidate.
				 */
				if (p.x <= rect.x + (rect.width / 2))
					candidate = i;
			}
			if (candidate != -1) {
				// We have a candidate, see if the rowBottom has grown to include the mouse Y.
				if (p.y <= rowBottom) {
					/*
					 * Now we have determined that the cursor.Y is above the bottom of the
					 * current row of figures. Stop now, to prevent the next row from being
					 * searched
					 */
					break;
				}
			}
		}
		return candidate;
	}
	
	private Point getLocationFromRequest(Request request) {
		return ((DropRequest)request).getLocation();
	}

	private Rectangle getAbsoluteBounds(GraphicalEditPart ep) {
		Rectangle bounds = ep.getFigure().getBounds().getCopy();
		ep.getFigure().translateToAbsolute(bounds);
		return bounds;
	}



}


/**
 * This command repositions an element inside an compartment. 
 * 
 * @author sas
 */
public class CompartmentChildRepositionCommand extends AbstractTransactionalCommand {

	/**
	 * the visual representation of the model container we work on
	 */
	private final EditPart mContainerPart;
	
	/**
	 * the container we work on
	 */
	private final EObject mContainer;
	
	/**
	 * the containing feature
	 */
	private final EStructuralFeature mContainingFeature;
	
	/**
	 * the old index
	 */
	private final int mOldIndex;
	
	/**
	 * the new index
	 */
	private final int mNewIndex;


	
	/**
 	 * Constructs a runtime instance of <code>CompartmentRepositionElementCommand</code>.
	 */
	public CompartmentChildRepositionCommand(TransactionalEditingDomain editingDomain,
			EditPart containerPart, EObject container, EStructuralFeature containingFeature,
			int oldIndex, int newIndex) {
		super(editingDomain, "", getWorkspaceFiles(container));
		
		Assert.isNotNull(containerPart);
		this.mContainerPart = containerPart;
		Assert.isNotNull(container);
		this.mContainer = container;
		Assert.isNotNull(containingFeature);
		this.mContainingFeature = containingFeature;
		Assert.isTrue(oldIndex >= 0);
		this.mOldIndex = oldIndex;
		Assert.isTrue(newIndex >= -1);
		this.mNewIndex = newIndex;
	}
	
	/**
	 * Convenience method to access <code>mContainer.eGet(mContainingFeature)</code>.
	 * 
	 * @return the containing {@link EList} or <code>null</code> if the containing feature doesn't 
	 * reference an {@link EList}
	 */
	protected EList<?> getContainingList() {
		Object featureValue = mContainer.eGet(mContainingFeature);
		return featureValue instanceof EList<?> ? (EList<?>) featureValue : null;
	}
	

	@Override
	public boolean canExecute() {
		// containing feature needs to be set
		if (!mContainer.eIsSet(mContainingFeature)) {
			return false;
		}
		
		// containing feature needs to reference an EList
		if (getContainingList() == null) {
			return false;
		}
		
		// ensure valid value of mOldIndex
		if (mOldIndex < 0 || mOldIndex >= getContainingList().size()) {
			return false;
		}
		
		return true;
	}

	@Override
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor,
			IAdaptable info) throws ExecutionException {
		CommandResult commandResult = null;
		try {
			// reposition model element
    		getContainingList().move(mNewIndex, mOldIndex);
			
    		// reposition visual representation of model element
    		View containerView = (View) mContainerPart.getModel();
    		View childView = (View) containerView.getChildren().get(mOldIndex);
			ViewUtil.repositionChildAt(containerView, childView, mNewIndex);

			// refresh container part
			mContainerPart.refresh();		
        } catch (RuntimeException exp){
            commandResult = CommandResult.newErrorCommandResult(exp);
        }
		return (commandResult == null) ? CommandResult.newOKCommandResult()
			: commandResult;

	}

}


public class CompartmentChildCreationEditPolicy extends CreationEditPolicy {

	@Override
	protected Command getCreateCommand(CreateViewRequest request) {
		TransactionalEditingDomain editingDomain = ((IGraphicalEditPart) getHost())
		.getEditingDomain();
		CompositeTransactionalCommand cc = new CompositeTransactionalCommand(
				editingDomain, DiagramUIMessages.AddCommand_Label);

		Iterator<?> descriptors = request.getViewDescriptors().iterator();

		while (descriptors.hasNext()) {
			CreateViewRequest.ViewDescriptor descriptor =
				(CreateViewRequest.ViewDescriptor)descriptors.next();

			CreateCommand createCommand =
				new CompartmentChildCreateCommand(editingDomain,
						descriptor, 
						(View)(getHost().getModel()), getFeedbackIndexFor(request));

			cc.compose(createCommand);
		}
		return new ICommandProxy(cc.reduce());
	}


	protected int getFeedbackIndexFor(Request request) {
		List<?> children = getHost().getChildren();
		if (children.isEmpty())
			return -1;

		Transposer transposer = new Transposer();
		transposer.setEnabled (!isHorizontal());

		Point p = transposer.t(getLocationFromRequest(request));

		// Current row bottom, initialize to above the top.
		int rowBottom = Integer.MIN_VALUE;
		int candidate = -1;
		for (int i = 0; i < children.size(); i++) {
			EditPart child = (EditPart) children.get(i);
			Rectangle rect = transposer.t(getAbsoluteBounds(((GraphicalEditPart)child)));
			if (rect.y > rowBottom) {
				/*
				 * We are in a new row, so if we don't have a candidate but yet are within the
				 * previous row, then the current entry becomes the candidate. This is because
				 * we know we must be to the right of center of the last Figure in the
				 * previous row, so this Figure (which is at the start of a new row) is the
				 * candidate.
				 */
				if (p.y <= rowBottom) {
					if (candidate == -1)
						candidate = i;
					break;
				} else
					candidate = -1; // Mouse's Y is outside the row, so reset the candidate
			}
			rowBottom = Math.max(rowBottom, rect.bottom());
			if (candidate == -1) {
				/*
				 * See if we have a possible candidate. It is a candidate if the cursor is
				 * left of the center of this candidate.
				 */
				if (p.x <= rect.x + (rect.width / 2))
					candidate = i;
			}
			if (candidate != -1) {
				// We have a candidate, see if the rowBottom has grown to include the mouse Y.
				if (p.y <= rowBottom) {
					/*
					 * Now we have determined that the cursor.Y is above the bottom of the
					 * current row of figures. Stop now, to prevent the next row from being
					 * searched
					 */
					break;
				}
			}
		}
		return candidate;
	}

	protected boolean isHorizontal() {
		IFigure figure = ((GraphicalEditPart)getHost()).getContentPane();
		return ((ConstrainedToolbarLayout)figure.getLayoutManager()).isHorizontal();
	}

	private Point getLocationFromRequest(Request request) {
		return ((DropRequest)request).getLocation();
	}

	private Rectangle getAbsoluteBounds(GraphicalEditPart ep) {
		Rectangle bounds = ep.getFigure().getBounds().getCopy();
		ep.getFigure().translateToAbsolute(bounds);
		return bounds;
	}
}


public class CompartmentChildCreateCommand extends CreateCommand {

	int index;

	public CompartmentChildCreateCommand (TransactionalEditingDomain editingDomain, ViewDescriptor viewDescriptor,
			View containerView, int index) {
		super(editingDomain, viewDescriptor, containerView);
		this.index = index;
	}

	@Override
	protected CommandResult doExecuteWithResult(IProgressMonitor monitor, IAdaptable info)
	throws ExecutionException {
		View view =
			ViewService.getInstance().createView(
					viewDescriptor.getViewKind(),
					viewDescriptor.getElementAdapter(),
					containerView,
					viewDescriptor.getSemanticHint(),
					index,
					viewDescriptor.isPersisted(),
					viewDescriptor.getPreferencesHint());
		if (view == null) {
			return super.doExecuteWithResult(monitor, info);
		}
		
		Assert.isNotNull(view, "failed to create a view");
		viewDescriptor.setView(view);
		

		return CommandResult.newOKCommandResult(viewDescriptor);
	}

}






Re: "List" layout on canvas [message #489164 is a reply to message #485984] Thu, 01 October 2009 16:37 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Thanks (again) a lot sas!

Now all my elements fits the width Smile

But :
* I lost the sourcefeedback line Confused
* The size of my compartment is not always resized, so sometimes the compartment has a scrollbar. I want that the compartment have a min size and then grow when I add children and that there is not enough space to display all of them.

I tried to set up also this list behavior on my canvas (display the top node references as a list too) and :
When I modify the createFigure and set a ConstrainedLayoutToolbar of the FreeFormLayer :
* For the first element placed, It seems that the maximum size is not respected, nor even the "default size facet" as suggested before so the element fill the place

I also tried to replace the FreeFormLayer by a ResizableCompartmentFigure in order to match the most with what I've done with COmpartment but on my diagram there is no correct display :
* some elements have no width (we only see a vertical line when selected)
* some other (with compartment!!) displays only an empty square when selected

thanks by advance for any advice

Aurelien Pupier


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #489321 is a reply to message #485984] Fri, 02 October 2009 12:29 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Discover other issues for my DiagramPart :

* when I reopened the diagram : the EditParts have not the same width
* when I move EditPart to left or right the width is expanding. FreeFormLayer growth.

and still :
* the EditParts fill also the heigth although I just want them to fill the width
* no more sourcefeedback line

So I really don't know how I can set a "list" layout on the canvas...

Can I disallow to growth to the side and allow only to the bottom?
How can I force each EditPart to take the same place when I reopened the diagram?

Thanks by advance


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Re: "List" layout on canvas [message #489672 is a reply to message #489069] Mon, 05 October 2009 14:15 Go to previous messageGo to next message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Ok, I can adapt your solution also with DiagramEditPart.and it works pretty well.

The last issues are :
* no sourcefeedback line
* sometimes when we move an editpart to a side, the width increase and therefore an horizontal scrollbar appear


Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
[SOLVED]Re: "List" layout on canvas [message #489976 is a reply to message #489672] Tue, 06 October 2009 17:22 Go to previous message
Aurélien Pupier is currently offline Aurélien PupierFriend
Messages: 637
Registered: July 2009
Location: Grenoble, FRANCE
Senior Member

Aurelien Pupier wrote on Mon, 05 October 2009 10:15
Ok, I can adapt your solution also with DiagramEditPart.and it works pretty well.

The last issues are :
* no sourcefeedback line


see http://www.eclipse.org/forums/index.php?t=msg&th=155453& amp;start=0&S=b3b0490843dbe98e9ecf36286689f550

Aurelien Pupier wrote on Mon, 05 October 2009 10:15

* sometimes when we move an editpart to a side, the width increase and therefore an horizontal scrollbar appear


I modify the dragtracker on each editpart in order to not take care of horizontal move.

Thanks sas for your help

Aurelien Pupier




Aurélien Pupier - Red Hat
Senior Software Engineer in Fuse Tooling team
Previous Topic:Editor opening an empty file
Next Topic:Double clicking event?
Goto Forum:
  


Current Time: Fri Apr 26 21:21:47 GMT 2024

Powered by FUDForum. Page generated in 0.04138 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top