Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » GMF (Graphical Modeling Framework) » Show EObject in Diagram
Show EObject in Diagram [message #919930] Sat, 22 September 2012 14:18 Go to next message
Eclipse UserFriend
Hi,

i have a problem with showing EOject elements in diagram.

Deleting a View from the diagram i have already solved as followed:

The method call is done in the following code fragment:

ReferencableElement elementToHide = (ReferencableElement)(selectedItem.getData());
...
HelperClass.deleteViewObjectOf(elementToHide);


The following two methods give the Command for deletion:

public static CompoundCommand deleteViewObjectOf (Object element) {
	List<Object> singleElementList = new ArrayList<Object>();
	singleElementList.add(element);
	return deleteViewObjectOf(singleElementList);
}


public static CompoundCommand deleteViewObjectOf (Collection<?> elements) {
	if (getEditingDomain() != null) {
		Diagram d = ModelUtils.getDiagram(getEditingDomain());
		CompoundCommand cc = new CompoundCommand(Messages.Helpers_hide_all_elements);

		Hashtable<Object, Object> model hash = new Hashtable<Object, Object>();

		for (Object obj : elements) {
			modelhash.put(obj, obj);	
		}

		DiagramCommandStack dcs = modeller.getDefaultViewDiagramCommandStack();
		org.eclipse.gef.commands.CompoundCommand gefcc = new org.eclipse.gef.commands.CompoundCommand();

		for (Object obj : d.getChildren()) {
			if (obj instanceof View) {
				View v = (View)obj;
				v.getElement();

				if (model hash.containsKey(v.getElement())) {
					org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand dc = new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), v);
					gefcc.add(new ICommandProxy(dc));
				}
			}
		} 

		for (Object obj : d.getEdges()) {
			if (obj instanceof View) {
				View v = (View)obj;
				v.getElement();

				if (model hash.containsKey(v.getElement())) {
					org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand dc = new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), v);
					gefcc.add(new ICommandProxy(dc));
				}
			}
		} 


		try {
			dcs.execute(gefcc);
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}
		cc.append(new DeleteCommand(getEditingDomain(), elements))
		return cc;	
	}
	return null;
}


Deleting View elements works fine as already mentioned.

Now my question: How should i adjust the following method that an EObject or a ReferencableElement can be shown?


public static CompoundCommand deleteViewObjectOf (Collection<?> elements) {
	if (getEditingDomain() != null) {
		Diagram d = ModelUtils.getDiagram(getEditingDomain());
		CompoundCommand cc = new CompoundCommand(Messages.Helpers_hide_all_elements);

		Hashtable<Object, Object> model hash = new Hashtable<Object, Object>();

		for (Object obj : elements) {
			modelhash.put(obj, obj);	
		}

		DiagramCommandStack dcs = modeller.getDefaultViewDiagramCommandStack();
		org.eclipse.gef.commands.CompoundCommand gefcc = new org.eclipse.gef.commands.CompoundCommand();

		for (Object obj : d.getChildren()) {
			if (obj instanceof View) {
				View v = (View)obj;
				v.getElement();

				if (model hash.containsKey(v.getElement())) {
					//todo
				}
			}
		} 

		for (Object obj : d.getEdges()) {
			if (obj instanceof View) {
				View v = (View)obj;
				v.getElement();

				if (model hash.containsKey(v.getElement())) {
					//todo
				}
			}
		} 


		try {
			dcs.execute(gefcc);
		}
		catch(Exception ex) {
			ex.printStackTrace();
		}
		//todo
		return cc;	
	}
	return null;
}


Thanks and best regards,

Philipp

[Updated on: Sat, 22 September 2012 14:21] by Moderator

Report message to a moderator

Re: Show EObject in Diagram [message #921714 is a reply to message #919930] Mon, 24 September 2012 11:16 Go to previous messageGo to next message
Eclipse UserFriend
Hi Philipp,

what is your overall goal? Do you use GMF Tooling?

Ralph
Re: Show EObject in Diagram [message #921725 is a reply to message #921714] Mon, 24 September 2012 11:27 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ralph,

my overall goal is to hide or show certain EObect's in the diagram.
Hiding EObject's already works fine as described above.

Thanks.

Best regards,

Philipp
Re: Show EObject in Diagram [message #921915 is a reply to message #921725] Mon, 24 September 2012 14:50 Go to previous messageGo to next message
Eclipse UserFriend
Hi,

did you try to set the views visible property to true false instead of deleting the view?

Ralph
Re: Show EObject in Diagram [message #922112 is a reply to message #921915] Mon, 24 September 2012 18:56 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ralph,

yes i tried it, but it didn't work so.
Hiding elements isn't faulty.
The problem is the showing of the elements.

Thanks!

Best regards,

Philipp
Re: Show EObject in Diagram [message #934242 is a reply to message #922112] Fri, 05 October 2012 19:42 Go to previous message
Eclipse UserFriend
Hi,

you should take a look to Mylyn modeling bridge: http://wiki.eclipse.org/Mylyn/Modeling_Bridge
You can hide/show editparts depending on a context.

Regards,
Previous Topic:Get an image from a GMF/EMF diagram
Next Topic:Use GMF diagram only as a viewer rather than a editor
Goto Forum:
  


Current Time: Fri Feb 14 02:53:34 GMT 2025

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

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

Back to the top