Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[gef-dev] RE: gef-dev digest, Vol 1 #183 - 4 msgs

> Someone recently contacted me with a similar idea.  The idea was to create 
> Content Providers like JFace has for trees/tables, but instead for a 
> specific graphical type of content such as a class diagram.

Content providers are a nice way to do things.  Although I think you could create
providers that are a little more general and then it would become trivial for people
to extend them to create things like ClassDiagram.  Consider the following possible
interfaces:

public interface IDiagramContentProvider
{
	// returns a list of model children.  Must be suitable for calling
	// from the diagram content edit part's getModelChildren()
	public List getChildren();
}

public interface IModifiableDiagramContentProvider extends IDiagramContentProvider
{
	// adds the specified child to the list returned by getChildren
	public void addChild(Object childModel);

	// removes the specified child from the list returned by getChildren
	// return true if childModel was in the last
	public boolean removeChild(Object childModel);

	// add listener to changes in the diagram
	public void addChangeListener(DiagramContentChangeListener  listener);

	// removes listener
	public void removeChangeListener(DiagramContentChangeListener listener);

	public interface DiagramContentChangeEventTypes
	{
		public final int   CHANGE_TYPE_CHILD_ADDED;
		public final int	 CHANGE_TYPE_CHILD_REMOVED;
		// ... there are many good, well-understood change event models you could copy
	}
}


A few other ideas:

1) To help with building coherent connection models, consider creating an interface that editparts
can give their model to and get back the source and target connections.  I am writing an application
that bases the connections present in the diagram on properties of the EditPart's models.  I have implemented a content provider that can be called to see how one Edit Part model is related to another.  This could be usefully generalized for other things like Class/ER/UML diagrams.

2) Build a default contents edit part that automagically supports creating and deleting graphical node edit parts that can be dragged and resized.  I was appalled by how long it took me to figure out how to do this.  It's taken me even longer to figure out how to do it right.

3) DOCUMENTATION!  The red book has a lot of content, but it seems presented in an order and detail that is not terribly useful to people writing simple applications to get their feet wet.


Regards,

Cameron


Back to the top