| Home » Eclipse Projects » GEF » separate view model from business model
 Goto Forum:| 
| separate view model from business model [message #113891] | Tue, 27 January 2004 15:10  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: david_michonneau.hotmail.com 
 I would like to separate the view model from the business model in my GEF
 editor. Is there any example on how to accomplish this?
 
 For example one model class is Element and has a name property (business
 model). Its associated UI has x,y coordinates. What's the best way to create
 the association? I was thinking of making the business model IAdaptable to
 retrieve its UI counterpart, if any. Then how to hook up the notification
 framework? When the position change I need to  notify the EditPart, but when
 the name change too... So should the EditPart listens to two model instances
 UIElement and BusinessElement for example? Or is there any better way to do
 it?
 
 Thanks,
 
 David
 |  |  |  |  | 
| Re: separate view model from business model [message #113905 is a reply to message #113891] | Tue, 27 January 2004 16:15   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: phil.williams.toadmail.com 
 David,
 
 This is exactly what I am doing.
 
 Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of which
 subclass AbstractModel).
 
 In my business model I have many distinct subclasses of these: Foo1, Foo2, Bar1,
 Bar2, etc.  But I don't want to "pollute" this model with graphical information
 like size and location of a widget on the screen that represents them.
 
 My GUI model I have a FooElement, BarElement, BazElement (which subclass a
 common AbstractElement class).  The AbstractElement has AbstractModel member.
 This gets set in the Factory that builds the model when needed by GEF.  And
 since I am using the logic example as my learning tool, my factory looks
 sometihng like:
 
 public class ElementFactory implements CreationFactory {
 
 private String template;
 
 public ElementFactory(String str) {
 template = str;
 }
 
 public Object getNewObject() {
 if (ElementConstants.FOO1.equals(template))
 return new FooElement( new Foo1() );
 else if ( ElementConstants.FOO2.equals( template ) )
 return new FooElement( new Foo2() );
 
 ...
 
 return null;
 }
 
 public Object getObjectType() {
 return template;
 }
 }
 
 In this way my GUI model ends up much smaller than my business model.  Of course
 the GUI model has getters so that the base business model can be accessed when
 needed.
 
 Hope this helps.
 
 Phil
 
 David Michonneau wrote:
 
 > I would like to separate the view model from the business model in my GEF
 > editor. Is there any example on how to accomplish this?
 >
 > For example one model class is Element and has a name property (business
 > model). Its associated UI has x,y coordinates. What's the best way to create
 > the association? I was thinking of making the business model IAdaptable to
 > retrieve its UI counterpart, if any. Then how to hook up the notification
 > framework? When the position change I need to  notify the EditPart, but when
 > the name change too... So should the EditPart listens to two model instances
 > UIElement and BusinessElement for example? Or is there any better way to do
 > it?
 >
 > Thanks,
 >
 > David
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #113940 is a reply to message #113905] | Tue, 27 January 2004 17:30   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: david_michonneau.hotmail.com 
 That looks interesting, I have one question about that: when you create your
 editpart from an AbstractElement, do you register it as listener of both
 AbstractElement and its AbstractModel member?
 
 Thanks,
 
 David
 
 "Phil Williams" <phil.williams@toadmail.com> wrote in message
 news:bv6k9j$7i6$1@eclipse.org...
 > David,
 >
 > This is exactly what I am doing.
 >
 > Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 which
 > subclass AbstractModel).
 >
 > In my business model I have many distinct subclasses of these: Foo1, Foo2,
 Bar1,
 > Bar2, etc.  But I don't want to "pollute" this model with graphical
 information
 > like size and location of a widget on the screen that represents them.
 >
 > My GUI model I have a FooElement, BarElement, BazElement (which subclass a
 > common AbstractElement class).  The AbstractElement has AbstractModel
 member.
 > This gets set in the Factory that builds the model when needed by GEF.
 And
 > since I am using the logic example as my learning tool, my factory looks
 > sometihng like:
 >
 > public class ElementFactory implements CreationFactory {
 >
 > private String template;
 >
 > public ElementFactory(String str) {
 > template = str;
 > }
 >
 > public Object getNewObject() {
 > if (ElementConstants.FOO1.equals(template))
 > return new FooElement( new Foo1() );
 > else if ( ElementConstants.FOO2.equals( template ) )
 > return new FooElement( new Foo2() );
 >
 > ...
 >
 > return null;
 > }
 >
 > public Object getObjectType() {
 > return template;
 > }
 > }
 >
 > In this way my GUI model ends up much smaller than my business model.  Of
 course
 > the GUI model has getters so that the base business model can be accessed
 when
 > needed.
 >
 > Hope this helps.
 >
 > Phil
 >
 > David Michonneau wrote:
 >
 > > I would like to separate the view model from the business model in my
 GEF
 > > editor. Is there any example on how to accomplish this?
 > >
 > > For example one model class is Element and has a name property (business
 > > model). Its associated UI has x,y coordinates. What's the best way to
 create
 > > the association? I was thinking of making the business model IAdaptable
 to
 > > retrieve its UI counterpart, if any. Then how to hook up the
 notification
 > > framework? When the position change I need to  notify the EditPart, but
 when
 > > the name change too... So should the EditPart listens to two model
 instances
 > > UIElement and BusinessElement for example? Or is there any better way to
 do
 > > it?
 > >
 > > Thanks,
 > >
 > > David
 > >
 > >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #113953 is a reply to message #113940] | Tue, 27 January 2004 17:51   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: phil.williams.toadmail.com 
 Exactly, but there are some business model elements that do not require the edit
 part to be notified of changes since some are represented as plane widgets on
 the screen and the user modifications will not change the visual representation.
 
 If the model affects the visual representation of the widget in the editor then
 the edit part will listen from Business Model Events.  I do this in the activate
 method of the editpart.  There is a base edit part that all my edit parts
 inherit from and its activate method adds itself as a listener for GUI model
 changes.  If the individual edit parts needs to hear business model events, then
 it will add itself as a listener for business model events.
 
 Phil
 
 David Michonneau wrote:
 
 > That looks interesting, I have one question about that: when you create your
 > editpart from an AbstractElement, do you register it as listener of both
 > AbstractElement and its AbstractModel member?
 >
 > Thanks,
 >
 > David
 >
 > "Phil Williams" <phil.williams@toadmail.com> wrote in message
 > news:bv6k9j$7i6$1@eclipse.org...
 >
 >>David,
 >>
 >>This is exactly what I am doing.
 >>
 >>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 >
 > which
 >
 >>subclass AbstractModel).
 >>
 >>In my business model I have many distinct subclasses of these: Foo1, Foo2,
 >
 > Bar1,
 >
 >>Bar2, etc.  But I don't want to "pollute" this model with graphical
 >
 > information
 >
 >>like size and location of a widget on the screen that represents them.
 >>
 >>My GUI model I have a FooElement, BarElement, BazElement (which subclass a
 >>common AbstractElement class).  The AbstractElement has AbstractModel
 >
 > member.
 >
 >>This gets set in the Factory that builds the model when needed by GEF.
 >
 > And
 >
 >>since I am using the logic example as my learning tool, my factory looks
 >>sometihng like:
 >>
 >>public class ElementFactory implements CreationFactory {
 >>
 >>private String template;
 >>
 >>public ElementFactory(String str) {
 >>template = str;
 >>}
 >>
 >>public Object getNewObject() {
 >>if (ElementConstants.FOO1.equals(template))
 >>return new FooElement( new Foo1() );
 >>else if ( ElementConstants.FOO2.equals( template ) )
 >>return new FooElement( new Foo2() );
 >>
 >>...
 >>
 >>return null;
 >>}
 >>
 >>public Object getObjectType() {
 >>return template;
 >>}
 >>}
 >>
 >>In this way my GUI model ends up much smaller than my business model.  Of
 >
 > course
 >
 >>the GUI model has getters so that the base business model can be accessed
 >
 > when
 >
 >>needed.
 >>
 >>Hope this helps.
 >>
 >>Phil
 >>
 >>David Michonneau wrote:
 >>
 >>
 >>>I would like to separate the view model from the business model in my
 >
 > GEF
 >
 >>>editor. Is there any example on how to accomplish this?
 >>>
 >>>For example one model class is Element and has a name property (business
 >>>model). Its associated UI has x,y coordinates. What's the best way to
 >
 > create
 >
 >>>the association? I was thinking of making the business model IAdaptable
 >
 > to
 >
 >>>retrieve its UI counterpart, if any. Then how to hook up the
 >
 > notification
 >
 >>>framework? When the position change I need to  notify the EditPart, but
 >
 > when
 >
 >>>the name change too... So should the EditPart listens to two model
 >
 > instances
 >
 >>>UIElement and BusinessElement for example? Or is there any better way to
 >
 > do
 >
 >>>it?
 >>>
 >>>Thanks,
 >>>
 >>>David
 >>>
 >>>
 >>
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #113979 is a reply to message #113953] | Tue, 27 January 2004 18:40   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: david_michonneau.hotmail.com 
 Cool, another question about the container:
 
 I believe you have a container for all your objects in both the UI model and
 the Business model (and the UI container has the Business container as
 member). Then what happens when you add one child to your business model:
 you need to create its ui counterpart, then add the business child to the
 business model, and the ui child instance as a child of the ui container,
 isn't it complicated? Also what about those elements that do not have any UI
 representation?
 
 Thanks for answering all my questions ;)
 
 David
 
 "Phil Williams" <phil.williams@toadmail.com> wrote in message
 news:bv6ptk$ecj$1@eclipse.org...
 > Exactly, but there are some business model elements that do not require
 the edit
 > part to be notified of changes since some are represented as plane widgets
 on
 > the screen and the user modifications will not change the visual
 representation.
 >
 > If the model affects the visual representation of the widget in the editor
 then
 > the edit part will listen from Business Model Events.  I do this in the
 activate
 > method of the editpart.  There is a base edit part that all my edit parts
 > inherit from and its activate method adds itself as a listener for GUI
 model
 > changes.  If the individual edit parts needs to hear business model
 events, then
 > it will add itself as a listener for business model events.
 >
 > Phil
 >
 > David Michonneau wrote:
 >
 > > That looks interesting, I have one question about that: when you create
 your
 > > editpart from an AbstractElement, do you register it as listener of both
 > > AbstractElement and its AbstractModel member?
 > >
 > > Thanks,
 > >
 > > David
 > >
 > > "Phil Williams" <phil.williams@toadmail.com> wrote in message
 > > news:bv6k9j$7i6$1@eclipse.org...
 > >
 > >>David,
 > >>
 > >>This is exactly what I am doing.
 > >>
 > >>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 > >
 > > which
 > >
 > >>subclass AbstractModel).
 > >>
 > >>In my business model I have many distinct subclasses of these: Foo1,
 Foo2,
 > >
 > > Bar1,
 > >
 > >>Bar2, etc.  But I don't want to "pollute" this model with graphical
 > >
 > > information
 > >
 > >>like size and location of a widget on the screen that represents them.
 > >>
 > >>My GUI model I have a FooElement, BarElement, BazElement (which subclass
 a
 > >>common AbstractElement class).  The AbstractElement has AbstractModel
 > >
 > > member.
 > >
 > >>This gets set in the Factory that builds the model when needed by GEF.
 > >
 > > And
 > >
 > >>since I am using the logic example as my learning tool, my factory looks
 > >>sometihng like:
 > >>
 > >>public class ElementFactory implements CreationFactory {
 > >>
 > >>private String template;
 > >>
 > >>public ElementFactory(String str) {
 > >>template = str;
 > >>}
 > >>
 > >>public Object getNewObject() {
 > >>if (ElementConstants.FOO1.equals(template))
 > >>return new FooElement( new Foo1() );
 > >>else if ( ElementConstants.FOO2.equals( template ) )
 > >>return new FooElement( new Foo2() );
 > >>
 > >>...
 > >>
 > >>return null;
 > >>}
 > >>
 > >>public Object getObjectType() {
 > >>return template;
 > >>}
 > >>}
 > >>
 > >>In this way my GUI model ends up much smaller than my business model.
 Of
 > >
 > > course
 > >
 > >>the GUI model has getters so that the base business model can be
 accessed
 > >
 > > when
 > >
 > >>needed.
 > >>
 > >>Hope this helps.
 > >>
 > >>Phil
 > >>
 > >>David Michonneau wrote:
 > >>
 > >>
 > >>>I would like to separate the view model from the business model in my
 > >
 > > GEF
 > >
 > >>>editor. Is there any example on how to accomplish this?
 > >>>
 > >>>For example one model class is Element and has a name property
 (business
 > >>>model). Its associated UI has x,y coordinates. What's the best way to
 > >
 > > create
 > >
 > >>>the association? I was thinking of making the business model IAdaptable
 > >
 > > to
 > >
 > >>>retrieve its UI counterpart, if any. Then how to hook up the
 > >
 > > notification
 > >
 > >>>framework? When the position change I need to  notify the EditPart, but
 > >
 > > when
 > >
 > >>>the name change too... So should the EditPart listens to two model
 > >
 > > instances
 > >
 > >>>UIElement and BusinessElement for example? Or is there any better way
 to
 > >
 > > do
 > >
 > >>>it?
 > >>>
 > >>>Thanks,
 > >>>
 > >>>David
 > >>>
 > >>>
 > >>
 > >
 > >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114015 is a reply to message #113905] | Tue, 27 January 2004 21:26   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: none.us.ibm.com 
 David and Phil,
 
 I use the following naming convention
 
 Business Model: Class, Relationship, Package, Namespace
 View Model: ClassView, RelationshipView, PackageView, Diagram
 
 Of course "class" may be something else for you.
 
 In the model, the views have a reference to their business object.  Their is
 nothing wrong with doing this, as long as the relationship is only navigable
 from view->business object.  Their may even be multiple views of the same
 business object.
 
 The editpart implementation listens to the view object and the business
 object both.  It's "primary" model is the view, because without a view there
 is no editpart.  Also, the view is unique in the diagram, while the business
 object may not be.
 
 "Phil Williams" <phil.williams@toadmail.com> wrote in message
 news:bv6k9j$7i6$1@eclipse.org...
 > David,
 >
 > This is exactly what I am doing.
 >
 > Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 which
 > subclass AbstractModel).
 >
 > In my business model I have many distinct subclasses of these: Foo1, Foo2,
 Bar1,
 > Bar2, etc.  But I don't want to "pollute" this model with graphical
 information
 > like size and location of a widget on the screen that represents them.
 >
 > My GUI model I have a FooElement, BarElement, BazElement (which subclass a
 > common AbstractElement class).  The AbstractElement has AbstractModel
 member.
 > This gets set in the Factory that builds the model when needed by GEF.
 And
 > since I am using the logic example as my learning tool, my factory looks
 > sometihng like:
 >
 > public class ElementFactory implements CreationFactory {
 >
 > private String template;
 >
 > public ElementFactory(String str) {
 > template = str;
 > }
 >
 > public Object getNewObject() {
 > if (ElementConstants.FOO1.equals(template))
 > return new FooElement( new Foo1() );
 > else if ( ElementConstants.FOO2.equals( template ) )
 > return new FooElement( new Foo2() );
 >
 > ...
 >
 > return null;
 > }
 >
 > public Object getObjectType() {
 > return template;
 > }
 > }
 >
 > In this way my GUI model ends up much smaller than my business model.  Of
 course
 > the GUI model has getters so that the base business model can be accessed
 when
 > needed.
 >
 > Hope this helps.
 >
 > Phil
 >
 > David Michonneau wrote:
 >
 > > I would like to separate the view model from the business model in my
 GEF
 > > editor. Is there any example on how to accomplish this?
 > >
 > > For example one model class is Element and has a name property (business
 > > model). Its associated UI has x,y coordinates. What's the best way to
 create
 > > the association? I was thinking of making the business model IAdaptable
 to
 > > retrieve its UI counterpart, if any. Then how to hook up the
 notification
 > > framework? When the position change I need to  notify the EditPart, but
 when
 > > the name change too... So should the EditPart listens to two model
 instances
 > > UIElement and BusinessElement for example? Or is there any better way to
 do
 > > it?
 > >
 > > Thanks,
 > >
 > > David
 > >
 > >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114058 is a reply to message #114015] | Tue, 27 January 2004 21:53   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: david_michonneau.hotmail.com 
 Do you have a sample implementation of such separation applied to a GEF
 editor? That would be great.
 
 Thanks,
 
 David
 
 "Randy Hudson" <none@us.ibm.com> wrote in message
 news:bv76hh$rmj$1@eclipse.org...
 > David and Phil,
 >
 > I use the following naming convention
 >
 > Business Model: Class, Relationship, Package, Namespace
 > View Model: ClassView, RelationshipView, PackageView, Diagram
 >
 > Of course "class" may be something else for you.
 >
 > In the model, the views have a reference to their business object.  Their
 is
 > nothing wrong with doing this, as long as the relationship is only
 navigable
 > from view->business object.  Their may even be multiple views of the same
 > business object.
 >
 > The editpart implementation listens to the view object and the business
 > object both.  It's "primary" model is the view, because without a view
 there
 > is no editpart.  Also, the view is unique in the diagram, while the
 business
 > object may not be.
 >
 > "Phil Williams" <phil.williams@toadmail.com> wrote in message
 > news:bv6k9j$7i6$1@eclipse.org...
 > > David,
 > >
 > > This is exactly what I am doing.
 > >
 > > Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 > which
 > > subclass AbstractModel).
 > >
 > > In my business model I have many distinct subclasses of these: Foo1,
 Foo2,
 > Bar1,
 > > Bar2, etc.  But I don't want to "pollute" this model with graphical
 > information
 > > like size and location of a widget on the screen that represents them.
 > >
 > > My GUI model I have a FooElement, BarElement, BazElement (which subclass
 a
 > > common AbstractElement class).  The AbstractElement has AbstractModel
 > member.
 > > This gets set in the Factory that builds the model when needed by GEF.
 > And
 > > since I am using the logic example as my learning tool, my factory looks
 > > sometihng like:
 > >
 > > public class ElementFactory implements CreationFactory {
 > >
 > > private String template;
 > >
 > > public ElementFactory(String str) {
 > > template = str;
 > > }
 > >
 > > public Object getNewObject() {
 > > if (ElementConstants.FOO1.equals(template))
 > > return new FooElement( new Foo1() );
 > > else if ( ElementConstants.FOO2.equals( template ) )
 > > return new FooElement( new Foo2() );
 > >
 > > ...
 > >
 > > return null;
 > > }
 > >
 > > public Object getObjectType() {
 > > return template;
 > > }
 > > }
 > >
 > > In this way my GUI model ends up much smaller than my business model.
 Of
 > course
 > > the GUI model has getters so that the base business model can be
 accessed
 > when
 > > needed.
 > >
 > > Hope this helps.
 > >
 > > Phil
 > >
 > > David Michonneau wrote:
 > >
 > > > I would like to separate the view model from the business model in my
 > GEF
 > > > editor. Is there any example on how to accomplish this?
 > > >
 > > > For example one model class is Element and has a name property
 (business
 > > > model). Its associated UI has x,y coordinates. What's the best way to
 > create
 > > > the association? I was thinking of making the business model
 IAdaptable
 > to
 > > > retrieve its UI counterpart, if any. Then how to hook up the
 > notification
 > > > framework? When the position change I need to  notify the EditPart,
 but
 > when
 > > > the name change too... So should the EditPart listens to two model
 > instances
 > > > UIElement and BusinessElement for example? Or is there any better way
 to
 > do
 > > > it?
 > > >
 > > > Thanks,
 > > >
 > > > David
 > > >
 > > >
 > >
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114312 is a reply to message #114058] | Wed, 28 January 2004 10:05   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: phil.williams.toadmail.com 
 I am doing exactly what Randy said, although I think he stated it more
 succinctly :).
 
 I am in the process of building an plug in that does this but I am still
 working out some details.  I found that the 2 keys are:
 
 1)  When the ClassView (I use the naming convention of ClassElement so
 as not to confuse myself with the View component of MVC (I am so easily
 confused)) is created through the factory that it has a handle to the
 business model.
 2)  When the edit part is activated, it adds itself as a listener for
 business model changes if needed.  As you said earlier, there are some
 aspects of the business model that may not have a graphical
 representation other than showing up as a widget on the screen.
 
 If some business model class needs to create something that is not
 represented graphically then it does so and there is no figure or edit
 part that goes with it.  Although, the question that I would have is
 when is that the case?  I would think that there would be some aspect (a
 member variable perhaps) that the user would want to change.  While this
 may not be represented graphically in your editor, it may need to be
 displayed on a property sheet somewhere.  If that is the case, it would
 be the XXXXView's (or XXXElement's) responsibility to expose it to the
 PropertySheet view or to a custom View (as I am doing).
 
 Hope this helps,
 
 Phil
 
 P.S. Can we overload the word View just a little bit more! :)
 
 David Michonneau wrote:
 > Do you have a sample implementation of such separation applied to a GEF
 > editor? That would be great.
 >
 > Thanks,
 >
 > David
 >
 > "Randy Hudson" <none@us.ibm.com> wrote in message
 > news:bv76hh$rmj$1@eclipse.org...
 >
 >>David and Phil,
 >>
 >>I use the following naming convention
 >>
 >>Business Model: Class, Relationship, Package, Namespace
 >>View Model: ClassView, RelationshipView, PackageView, Diagram
 >>
 >>Of course "class" may be something else for you.
 >>
 >>In the model, the views have a reference to their business object.  Their
 >
 > is
 >
 >>nothing wrong with doing this, as long as the relationship is only
 >
 > navigable
 >
 >>from view->business object.  Their may even be multiple views of the same
 >>business object.
 >>
 >>The editpart implementation listens to the view object and the business
 >>object both.  It's "primary" model is the view, because without a view
 >
 > there
 >
 >>is no editpart.  Also, the view is unique in the diagram, while the
 >
 > business
 >
 >>object may not be.
 >>
 >>"Phil Williams" <phil.williams@toadmail.com> wrote in message
 >>news:bv6k9j$7i6$1@eclipse.org...
 >>
 >>>David,
 >>>
 >>>This is exactly what I am doing.
 >>>
 >>>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each of
 >>
 >>which
 >>
 >>>subclass AbstractModel).
 >>>
 >>>In my business model I have many distinct subclasses of these: Foo1,
 >
 > Foo2,
 >
 >>Bar1,
 >>
 >>>Bar2, etc.  But I don't want to "pollute" this model with graphical
 >>
 >>information
 >>
 >>>like size and location of a widget on the screen that represents them.
 >>>
 >>>My GUI model I have a FooElement, BarElement, BazElement (which subclass
 >
 > a
 >
 >>>common AbstractElement class).  The AbstractElement has AbstractModel
 >>
 >>member.
 >>
 >>>This gets set in the Factory that builds the model when needed by GEF.
 >>
 >>And
 >>
 >>>since I am using the logic example as my learning tool, my factory looks
 >>>sometihng like:
 >>>
 >>>public class ElementFactory implements CreationFactory {
 >>>
 >>>private String template;
 >>>
 >>>public ElementFactory(String str) {
 >>>template = str;
 >>>}
 >>>
 >>>public Object getNewObject() {
 >>>if (ElementConstants.FOO1.equals(template))
 >>>return new FooElement( new Foo1() );
 >>>else if ( ElementConstants.FOO2.equals( template ) )
 >>>return new FooElement( new Foo2() );
 >>>
 >>>...
 >>>
 >>>return null;
 >>>}
 >>>
 >>>public Object getObjectType() {
 >>>return template;
 >>>}
 >>>}
 >>>
 >>>In this way my GUI model ends up much smaller than my business model.
 >
 > Of
 >
 >>course
 >>
 >>>the GUI model has getters so that the base business model can be
 >
 > accessed
 >
 >>when
 >>
 >>>needed.
 >>>
 >>>Hope this helps.
 >>>
 >>>Phil
 >>>
 >>>David Michonneau wrote:
 >>>
 >>>
 >>>>I would like to separate the view model from the business model in my
 >>
 >>GEF
 >>
 >>>>editor. Is there any example on how to accomplish this?
 >>>>
 >>>>For example one model class is Element and has a name property
 >
 > (business
 >
 >>>>model). Its associated UI has x,y coordinates. What's the best way to
 >>
 >>create
 >>
 >>>>the association? I was thinking of making the business model
 >
 > IAdaptable
 >
 >>to
 >>
 >>>>retrieve its UI counterpart, if any. Then how to hook up the
 >>
 >>notification
 >>
 >>>>framework? When the position change I need to  notify the EditPart,
 >
 > but
 >
 >>when
 >>
 >>>>the name change too... So should the EditPart listens to two model
 >>
 >>instances
 >>
 >>>>UIElement and BusinessElement for example? Or is there any better way
 >
 > to
 >
 >>do
 >>
 >>>>it?
 >>>>
 >>>>Thanks,
 >>>>
 >>>>David
 >>>>
 >>>>
 >>>
 >>
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114350 is a reply to message #114058] | Wed, 28 January 2004 10:59   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: none.us.ibm.com 
 There is an "example" in WSAD :-), of course it's just the binary product.
 That would make a great example, but people already complain about the logic
 example's complexity.  If we were to introduce EMF and a partitioned model
 ...... :-0
 
 "David Michonneau" <david_michonneau@hotmail.com> wrote in message
 news:bv7833$t5c$1@eclipse.org...
 > Do you have a sample implementation of such separation applied to a GEF
 > editor? That would be great.
 >
 > Thanks,
 >
 > David
 >
 > "Randy Hudson" <none@us.ibm.com> wrote in message
 > news:bv76hh$rmj$1@eclipse.org...
 > > David and Phil,
 > >
 > > I use the following naming convention
 > >
 > > Business Model: Class, Relationship, Package, Namespace
 > > View Model: ClassView, RelationshipView, PackageView, Diagram
 > >
 > > Of course "class" may be something else for you.
 > >
 > > In the model, the views have a reference to their business object.
 Their
 > is
 > > nothing wrong with doing this, as long as the relationship is only
 > navigable
 > > from view->business object.  Their may even be multiple views of the
 same
 > > business object.
 > >
 > > The editpart implementation listens to the view object and the business
 > > object both.  It's "primary" model is the view, because without a view
 > there
 > > is no editpart.  Also, the view is unique in the diagram, while the
 > business
 > > object may not be.
 > >
 > > "Phil Williams" <phil.williams@toadmail.com> wrote in message
 > > news:bv6k9j$7i6$1@eclipse.org...
 > > > David,
 > > >
 > > > This is exactly what I am doing.
 > > >
 > > > Say I have 3 different "types" of model elements: Foo, Bar, Baz (each
 of
 > > which
 > > > subclass AbstractModel).
 > > >
 > > > In my business model I have many distinct subclasses of these: Foo1,
 > Foo2,
 > > Bar1,
 > > > Bar2, etc.  But I don't want to "pollute" this model with graphical
 > > information
 > > > like size and location of a widget on the screen that represents them.
 > > >
 > > > My GUI model I have a FooElement, BarElement, BazElement (which
 subclass
 > a
 > > > common AbstractElement class).  The AbstractElement has AbstractModel
 > > member.
 > > > This gets set in the Factory that builds the model when needed by GEF.
 > > And
 > > > since I am using the logic example as my learning tool, my factory
 looks
 > > > sometihng like:
 > > >
 > > > public class ElementFactory implements CreationFactory {
 > > >
 > > > private String template;
 > > >
 > > > public ElementFactory(String str) {
 > > > template = str;
 > > > }
 > > >
 > > > public Object getNewObject() {
 > > > if (ElementConstants.FOO1.equals(template))
 > > > return new FooElement( new Foo1() );
 > > > else if ( ElementConstants.FOO2.equals( template ) )
 > > > return new FooElement( new Foo2() );
 > > >
 > > > ...
 > > >
 > > > return null;
 > > > }
 > > >
 > > > public Object getObjectType() {
 > > > return template;
 > > > }
 > > > }
 > > >
 > > > In this way my GUI model ends up much smaller than my business model.
 > Of
 > > course
 > > > the GUI model has getters so that the base business model can be
 > accessed
 > > when
 > > > needed.
 > > >
 > > > Hope this helps.
 > > >
 > > > Phil
 > > >
 > > > David Michonneau wrote:
 > > >
 > > > > I would like to separate the view model from the business model in
 my
 > > GEF
 > > > > editor. Is there any example on how to accomplish this?
 > > > >
 > > > > For example one model class is Element and has a name property
 > (business
 > > > > model). Its associated UI has x,y coordinates. What's the best way
 to
 > > create
 > > > > the association? I was thinking of making the business model
 > IAdaptable
 > > to
 > > > > retrieve its UI counterpart, if any. Then how to hook up the
 > > notification
 > > > > framework? When the position change I need to  notify the EditPart,
 > but
 > > when
 > > > > the name change too... So should the EditPart listens to two model
 > > instances
 > > > > UIElement and BusinessElement for example? Or is there any better
 way
 > to
 > > do
 > > > > it?
 > > > >
 > > > > Thanks,
 > > > >
 > > > > David
 > > > >
 > > > >
 > > >
 > >
 > >
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114388 is a reply to message #114350] | Wed, 28 January 2004 11:09   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: phil.williams.toadmail.com 
 You raise an interesting point.  I had thought about using EMF and
 thought that it would work (actually sure that it would work).  But was
 a little worried about tackling all the learning curves at once (GEF,
 SWT, Eclipse API, etc).  I have been thinking that what I am doing is an
 EMF-lite.  Maybe the next version will use EMF as its under pinnings.
 
 Phil
 
 Randy Hudson wrote:
 
 > There is an "example" in WSAD :-), of course it's just the binary product.
 > That would make a great example, but people already complain about the logic
 > example's complexity.  If we were to introduce EMF and a partitioned model
 > ..... :-0
 >
 > "David Michonneau" <david_michonneau@hotmail.com> wrote in message
 > news:bv7833$t5c$1@eclipse.org...
 >
 >>Do you have a sample implementation of such separation applied to a GEF
 >>editor? That would be great.
 >>
 >>Thanks,
 >>
 >>David
 >>
 >>"Randy Hudson" <none@us.ibm.com> wrote in message
 >>news:bv76hh$rmj$1@eclipse.org...
 >>
 >>>David and Phil,
 >>>
 >>>I use the following naming convention
 >>>
 >>>Business Model: Class, Relationship, Package, Namespace
 >>>View Model: ClassView, RelationshipView, PackageView, Diagram
 >>>
 >>>Of course "class" may be something else for you.
 >>>
 >>>In the model, the views have a reference to their business object.
 >
 > Their
 >
 >>is
 >>
 >>>nothing wrong with doing this, as long as the relationship is only
 >>
 >>navigable
 >>
 >>>from view->business object.  Their may even be multiple views of the
 >
 > same
 >
 >>>business object.
 >>>
 >>>The editpart implementation listens to the view object and the business
 >>>object both.  It's "primary" model is the view, because without a view
 >>
 >>there
 >>
 >>>is no editpart.  Also, the view is unique in the diagram, while the
 >>
 >>business
 >>
 >>>object may not be.
 >>>
 >>>"Phil Williams" <phil.williams@toadmail.com> wrote in message
 >>>news:bv6k9j$7i6$1@eclipse.org...
 >>>
 >>>>David,
 >>>>
 >>>>This is exactly what I am doing.
 >>>>
 >>>>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each
 >
 > of
 >
 >>>which
 >>>
 >>>>subclass AbstractModel).
 >>>>
 >>>>In my business model I have many distinct subclasses of these: Foo1,
 >>
 >>Foo2,
 >>
 >>>Bar1,
 >>>
 >>>>Bar2, etc.  But I don't want to "pollute" this model with graphical
 >>>
 >>>information
 >>>
 >>>>like size and location of a widget on the screen that represents them.
 >>>>
 >>>>My GUI model I have a FooElement, BarElement, BazElement (which
 >
 > subclass
 >
 >>a
 >>
 >>>>common AbstractElement class).  The AbstractElement has AbstractModel
 >>>
 >>>member.
 >>>
 >>>>This gets set in the Factory that builds the model when needed by GEF.
 >>>
 >>>And
 >>>
 >>>>since I am using the logic example as my learning tool, my factory
 >
 > looks
 >
 >>>>sometihng like:
 >>>>
 >>>>public class ElementFactory implements CreationFactory {
 >>>>
 >>>>private String template;
 >>>>
 >>>>public ElementFactory(String str) {
 >>>>template = str;
 >>>>}
 >>>>
 >>>>public Object getNewObject() {
 >>>>if (ElementConstants.FOO1.equals(template))
 >>>>return new FooElement( new Foo1() );
 >>>>else if ( ElementConstants.FOO2.equals( template ) )
 >>>>return new FooElement( new Foo2() );
 >>>>
 >>>>...
 >>>>
 >>>>return null;
 >>>>}
 >>>>
 >>>>public Object getObjectType() {
 >>>>return template;
 >>>>}
 >>>>}
 >>>>
 >>>>In this way my GUI model ends up much smaller than my business model.
 >>
 >>Of
 >>
 >>>course
 >>>
 >>>>the GUI model has getters so that the base business model can be
 >>
 >>accessed
 >>
 >>>when
 >>>
 >>>>needed.
 >>>>
 >>>>Hope this helps.
 >>>>
 >>>>Phil
 >>>>
 >>>>David Michonneau wrote:
 >>>>
 >>>>
 >>>>>I would like to separate the view model from the business model in
 >
 > my
 >
 >>>GEF
 >>>
 >>>>>editor. Is there any example on how to accomplish this?
 >>>>>
 >>>>>For example one model class is Element and has a name property
 >>
 >>(business
 >>
 >>>>>model). Its associated UI has x,y coordinates. What's the best way
 >
 > to
 >
 >>>create
 >>>
 >>>>>the association? I was thinking of making the business model
 >>
 >>IAdaptable
 >>
 >>>to
 >>>
 >>>>>retrieve its UI counterpart, if any. Then how to hook up the
 >>>
 >>>notification
 >>>
 >>>>>framework? When the position change I need to  notify the EditPart,
 >>
 >>but
 >>
 >>>when
 >>>
 >>>>>the name change too... So should the EditPart listens to two model
 >>>
 >>>instances
 >>>
 >>>>>UIElement and BusinessElement for example? Or is there any better
 >
 > way
 >
 >>to
 >>
 >>>do
 >>>
 >>>>>it?
 >>>>>
 >>>>>Thanks,
 >>>>>
 >>>>>David
 >>>>>
 >>>>>
 >>>>
 >>>
 >>
 >
 >
 |  |  |  |  | 
| Re: separate view model from business model [message #114481 is a reply to message #114388] | Wed, 28 January 2004 13:09   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: none.us.ibm.com 
 The strongest motivation for using EMF would be if you were splitting up the
 models across multiple files.
 
 "Phil Williams" <phil.williams@toadmail.com> wrote in message
 news:bv8mn8$jbc$1@eclipse.org...
 > You raise an interesting point.  I had thought about using EMF and
 > thought that it would work (actually sure that it would work).  But was
 > a little worried about tackling all the learning curves at once (GEF,
 > SWT, Eclipse API, etc).  I have been thinking that what I am doing is an
 > EMF-lite.  Maybe the next version will use EMF as its under pinnings.
 >
 > Phil
 >
 > Randy Hudson wrote:
 >
 > > There is an "example" in WSAD :-), of course it's just the binary
 product.
 > > That would make a great example, but people already complain about the
 logic
 > > example's complexity.  If we were to introduce EMF and a partitioned
 model
 > > ..... :-0
 > >
 > > "David Michonneau" <david_michonneau@hotmail.com> wrote in message
 > > news:bv7833$t5c$1@eclipse.org...
 > >
 > >>Do you have a sample implementation of such separation applied to a GEF
 > >>editor? That would be great.
 > >>
 > >>Thanks,
 > >>
 > >>David
 > >>
 > >>"Randy Hudson" <none@us.ibm.com> wrote in message
 > >>news:bv76hh$rmj$1@eclipse.org...
 > >>
 > >>>David and Phil,
 > >>>
 > >>>I use the following naming convention
 > >>>
 > >>>Business Model: Class, Relationship, Package, Namespace
 > >>>View Model: ClassView, RelationshipView, PackageView, Diagram
 > >>>
 > >>>Of course "class" may be something else for you.
 > >>>
 > >>>In the model, the views have a reference to their business object.
 > >
 > > Their
 > >
 > >>is
 > >>
 > >>>nothing wrong with doing this, as long as the relationship is only
 > >>
 > >>navigable
 > >>
 > >>>from view->business object.  Their may even be multiple views of the
 > >
 > > same
 > >
 > >>>business object.
 > >>>
 > >>>The editpart implementation listens to the view object and the business
 > >>>object both.  It's "primary" model is the view, because without a view
 > >>
 > >>there
 > >>
 > >>>is no editpart.  Also, the view is unique in the diagram, while the
 > >>
 > >>business
 > >>
 > >>>object may not be.
 > >>>
 > >>>"Phil Williams" <phil.williams@toadmail.com> wrote in message
 > >>>news:bv6k9j$7i6$1@eclipse.org...
 > >>>
 > >>>>David,
 > >>>>
 > >>>>This is exactly what I am doing.
 > >>>>
 > >>>>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each
 > >
 > > of
 > >
 > >>>which
 > >>>
 > >>>>subclass AbstractModel).
 > >>>>
 > >>>>In my business model I have many distinct subclasses of these: Foo1,
 > >>
 > >>Foo2,
 > >>
 > >>>Bar1,
 > >>>
 > >>>>Bar2, etc.  But I don't want to "pollute" this model with graphical
 > >>>
 > >>>information
 > >>>
 > >>>>like size and location of a widget on the screen that represents them.
 > >>>>
 > >>>>My GUI model I have a FooElement, BarElement, BazElement (which
 > >
 > > subclass
 > >
 > >>a
 > >>
 > >>>>common AbstractElement class).  The AbstractElement has AbstractModel
 > >>>
 > >>>member.
 > >>>
 > >>>>This gets set in the Factory that builds the model when needed by GEF.
 > >>>
 > >>>And
 > >>>
 > >>>>since I am using the logic example as my learning tool, my factory
 > >
 > > looks
 > >
 > >>>>sometihng like:
 > >>>>
 > >>>>public class ElementFactory implements CreationFactory {
 > >>>>
 > >>>>private String template;
 > >>>>
 > >>>>public ElementFactory(String str) {
 > >>>>template = str;
 > >>>>}
 > >>>>
 > >>>>public Object getNewObject() {
 > >>>>if (ElementConstants.FOO1.equals(template))
 > >>>>return new FooElement( new Foo1() );
 > >>>>else if ( ElementConstants.FOO2.equals( template ) )
 > >>>>return new FooElement( new Foo2() );
 > >>>>
 > >>>>...
 > >>>>
 > >>>>return null;
 > >>>>}
 > >>>>
 > >>>>public Object getObjectType() {
 > >>>>return template;
 > >>>>}
 > >>>>}
 > >>>>
 > >>>>In this way my GUI model ends up much smaller than my business model.
 > >>
 > >>Of
 > >>
 > >>>course
 > >>>
 > >>>>the GUI model has getters so that the base business model can be
 > >>
 > >>accessed
 > >>
 > >>>when
 > >>>
 > >>>>needed.
 > >>>>
 > >>>>Hope this helps.
 > >>>>
 > >>>>Phil
 > >>>>
 > >>>>David Michonneau wrote:
 > >>>>
 > >>>>
 > >>>>>I would like to separate the view model from the business model in
 > >
 > > my
 > >
 > >>>GEF
 > >>>
 > >>>>>editor. Is there any example on how to accomplish this?
 > >>>>>
 > >>>>>For example one model class is Element and has a name property
 > >>
 > >>(business
 > >>
 > >>>>>model). Its associated UI has x,y coordinates. What's the best way
 > >
 > > to
 > >
 > >>>create
 > >>>
 > >>>>>the association? I was thinking of making the business model
 > >>
 > >>IAdaptable
 > >>
 > >>>to
 > >>>
 > >>>>>retrieve its UI counterpart, if any. Then how to hook up the
 > >>>
 > >>>notification
 > >>>
 > >>>>>framework? When the position change I need to  notify the EditPart,
 > >>
 > >>but
 > >>
 > >>>when
 > >>>
 > >>>>>the name change too... So should the EditPart listens to two model
 > >>>
 > >>>instances
 > >>>
 > >>>>>UIElement and BusinessElement for example? Or is there any better
 > >
 > > way
 > >
 > >>to
 > >>
 > >>>do
 > >>>
 > >>>>>it?
 > >>>>>
 > >>>>>Thanks,
 > >>>>>
 > >>>>>David
 > >>>>>
 > >>>>>
 > >>>>
 > >>>
 > >>
 > >
 > >
 |  |  |  |  | 
| Re: separate view model from business model [message #114526 is a reply to message #113891] | Wed, 28 January 2004 13:38   |  | 
| Eclipse User  |  |  |  |  | Originally posted by: Lamont_Gilbert.rigidsoftware.com 
 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 David Michonneau wrote:
 | I would like to separate the view model from the business model in my GEF
 | editor. Is there any example on how to accomplish this?
 |
 | For example one model class is Element and has a name property (business
 | model). Its associated UI has x,y coordinates. What's the best way to
 create
 | the association? I was thinking of making the business model IAdaptable to
 | retrieve its UI counterpart, if any. Then how to hook up the notification
 | framework? When the position change I need to  notify the EditPart,
 but when
 | the name change too... So should the EditPart listens to two model
 instances
 | UIElement and BusinessElement for example? Or is there any better way
 to do
 | it?
 |
 | Thanks,
 |
 | David
 |
 |
 
 i have to say my architecture has become quite huge.  Just start off
 simple, and divide it as you go along.  Initially I had single classes,
 then I split out portions until I ended up where I am now.  This is how
 mine is.
 
 I have my eclipse EditParts which contain my Models.  My models do not
 contain ANY eclipse classes.  the EditPartPolicies interpret my models
 data so the EditParts can handle em.
 
 
 I try to keep isolation between packages as much as possible.  I often
 get cought planning in a 20 minute daydream what the arch will be.  But
 then I tell myself, just make it work.  Once it works, then I may do
 another set of splitting.
 
 My splitting technique usually involves creating a set of interfaces,
 and having my business models implement those interfaces.  and having
 the other classes interact with the interafaces.
 
 Sometimes that works, sometimes I end up having to creat another class
 that encapulates the interface, and the other classes interact with that
 wrapper class.  This is the case for me now because I maintain a
 database AND drawing files.  So I have a class that encapsulates both
 the db and the drawing file. hard to explain.  just start our slow, and
 when the time comes, Divide.  Kind of like a cell :)
 
 
 
 - --
 Respectfully,
 
 
 CL Gilbert
 
 "Verily, verily, I say unto you, He that entereth not by the door() into
 the sheepfold{}, but climbeth up some other *way, the same is a thief
 and a robber."  John 10:1
 
 GnuPG Key Fingerprint:
 82A6 8893 C2A1 F64E A9AD  19AE 55B2 4CD7 80D2 0A2D
 
 For a free Java interface to Freechess.org see
 http://www.rigidsoftware.com/Chess/chess.html
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.2.4 (GNU/Linux)
 Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
 
 iD8DBQFAGAG0VbJM14DSCi0RAu5QAJ9Q1nfF7FQmeSr3W/6e9SOu7pQTCwCg ukpO
 HqBEEHiqjs6jR3jYdcHsTMs=
 =xs6D
 -----END PGP SIGNATURE-----
 |  |  |  |  | 
| Re: separate view model from business model [message #114552 is a reply to message #114481] | Wed, 28 January 2004 14:31  |  | 
| Eclipse User  |  |  |  |  | Originally posted by: phil.williams.toadmail.com 
 I realize that we are now terribly off topic....but what does splitting
 a model across multiple files have to do with EMF?  I can see that EMF
 may support that, but y would that be the strongest motivation?
 
 Wouldn't a stronger motivation be if you want to build a flexible
 framework for modeling something?  For example, I could see using it in
 the future on the project that I am working on since it may allow users
 to build new business model elements w/o having to write any code.  How
 I save it is secondary, at least to me.
 
 Phil
 
 Randy Hudson wrote:
 > The strongest motivation for using EMF would be if you were splitting up the
 > models across multiple files.
 >
 > "Phil Williams" <phil.williams@toadmail.com> wrote in message
 > news:bv8mn8$jbc$1@eclipse.org...
 >
 >>You raise an interesting point.  I had thought about using EMF and
 >>thought that it would work (actually sure that it would work).  But was
 >>a little worried about tackling all the learning curves at once (GEF,
 >>SWT, Eclipse API, etc).  I have been thinking that what I am doing is an
 >>EMF-lite.  Maybe the next version will use EMF as its under pinnings.
 >>
 >>Phil
 >>
 >>Randy Hudson wrote:
 >>
 >>
 >>>There is an "example" in WSAD :-), of course it's just the binary
 >
 > product.
 >
 >>>That would make a great example, but people already complain about the
 >
 > logic
 >
 >>>example's complexity.  If we were to introduce EMF and a partitioned
 >
 > model
 >
 >>>..... :-0
 >>>
 >>>"David Michonneau" <david_michonneau@hotmail.com> wrote in message
 >>>news:bv7833$t5c$1@eclipse.org...
 >>>
 >>>
 >>>>Do you have a sample implementation of such separation applied to a GEF
 >>>>editor? That would be great.
 >>>>
 >>>>Thanks,
 >>>>
 >>>>David
 >>>>
 >>>>"Randy Hudson" <none@us.ibm.com> wrote in message
 >>>>news:bv76hh$rmj$1@eclipse.org...
 >>>>
 >>>>
 >>>>>David and Phil,
 >>>>>
 >>>>>I use the following naming convention
 >>>>>
 >>>>>Business Model: Class, Relationship, Package, Namespace
 >>>>>View Model: ClassView, RelationshipView, PackageView, Diagram
 >>>>>
 >>>>>Of course "class" may be something else for you.
 >>>>>
 >>>>>In the model, the views have a reference to their business object.
 >>>
 >>>Their
 >>>
 >>>
 >>>>is
 >>>>
 >>>>
 >>>>>nothing wrong with doing this, as long as the relationship is only
 >>>>
 >>>>navigable
 >>>>
 >>>>>from view->business object.  Their may even be multiple views of the
 >>>
 >>>same
 >>>
 >>>
 >>>>>business object.
 >>>>>
 >>>>>The editpart implementation listens to the view object and the business
 >>>>>object both.  It's "primary" model is the view, because without a view
 >>>>
 >>>>there
 >>>>
 >>>>
 >>>>>is no editpart.  Also, the view is unique in the diagram, while the
 >>>>
 >>>>business
 >>>>
 >>>>
 >>>>>object may not be.
 >>>>>
 >>>>>"Phil Williams" <phil.williams@toadmail.com> wrote in message
 >>>>>news:bv6k9j$7i6$1@eclipse.org...
 >>>>>
 >>>>>
 >>>>>>David,
 >>>>>>
 >>>>>>This is exactly what I am doing.
 >>>>>>
 >>>>>>Say I have 3 different "types" of model elements: Foo, Bar, Baz (each
 >>>
 >>>of
 >>>
 >>>
 >>>>>which
 >>>>>
 >>>>>
 >>>>>>subclass AbstractModel).
 >>>>>>
 >>>>>>In my business model I have many distinct subclasses of these: Foo1,
 >>>>
 >>>>Foo2,
 >>>>
 >>>>
 >>>>>Bar1,
 >>>>>
 >>>>>
 >>>>>>Bar2, etc.  But I don't want to "pollute" this model with graphical
 >>>>>
 >>>>>information
 >>>>>
 >>>>>
 >>>>>>like size and location of a widget on the screen that represents them.
 >>>>>>
 >>>>>>My GUI model I have a FooElement, BarElement, BazElement (which
 >>>
 >>>subclass
 >>>
 >>>
 >>>>a
 >>>>
 >>>>
 >>>>>>common AbstractElement class).  The AbstractElement has AbstractModel
 >>>>>
 >>>>>member.
 >>>>>
 >>>>>
 >>>>>>This gets set in the Factory that builds the model when needed by GEF.
 >>>>>
 >>>>>And
 >>>>>
 >>>>>
 >>>>>>since I am using the logic example as my learning tool, my factory
 >>>
 >>>looks
 >>>
 >>>
 >>>>>>sometihng like:
 >>>>>>
 >>>>>>public class ElementFactory implements CreationFactory {
 >>>>>>
 >>>>>>private String template;
 >>>>>>
 >>>>>>public ElementFactory(String str) {
 >>>>>>template = str;
 >>>>>>}
 >>>>>>
 >>>>>>public Object getNewObject() {
 >>>>>>if (ElementConstants.FOO1.equals(template))
 >>>>>>return new FooElement( new Foo1() );
 >>>>>>else if ( ElementConstants.FOO2.equals( template ) )
 >>>>>>return new FooElement( new Foo2() );
 >>>>>>
 >>>>>>...
 >>>>>>
 >>>>>>return null;
 >>>>>>}
 >>>>>>
 >>>>>>public Object getObjectType() {
 >>>>>>return template;
 >>>>>>}
 >>>>>>}
 >>>>>>
 >>>>>>In this way my GUI model ends up much smaller than my business model.
 >>>>
 >>>>Of
 >>>>
 >>>>
 >>>>>course
 >>>>>
 >>>>>
 >>>>>>the GUI model has getters so that the base business model can be
 >>>>
 >>>>accessed
 >>>>
 >>>>
 >>>>>when
 >>>>>
 >>>>>
 >>>>>>needed.
 >>>>>>
 >>>>>>Hope this helps.
 >>>>>>
 >>>>>>Phil
 >>>>>>
 >>>>>>David Michonneau wrote:
 >>>>>>
 >>>>>>
 >>>>>>
 >>>>>>>I would like to separate the view model from the business model in
 >>>
 >>>my
 >>>
 >>>
 >>>>>GEF
 >>>>>
 >>>>>
 >>>>>>>editor. Is there any example on how to accomplish this?
 >>>>>>>
 >>>>>>>For example one model class is Element and has a name property
 >>>>
 >>>>(business
 >>>>
 >>>>
 >>>>>>>model). Its associated UI has x,y coordinates. What's the best way
 >>>
 >>>to
 >>>
 >>>
 >>>>>create
 >>>>>
 >>>>>
 >>>>>>>the association? I was thinking of making the business model
 >>>>
 >>>>IAdaptable
 >>>>
 >>>>
 >>>>>to
 >>>>>
 >>>>>
 >>>>>>>retrieve its UI counterpart, if any. Then how to hook up the
 >>>>>
 >>>>>notification
 >>>>>
 >>>>>
 >>>>>>>framework? When the position change I need to  notify the EditPart,
 >>>>
 >>>>but
 >>>>
 >>>>
 >>>>>when
 >>>>>
 >>>>>
 >>>>>>>the name change too... So should the EditPart listens to two model
 >>>>>
 >>>>>instances
 >>>>>
 >>>>>
 >>>>>>>UIElement and BusinessElement for example? Or is there any better
 >>>
 >>>way
 >>>
 >>>
 >>>>to
 >>>>
 >>>>
 >>>>>do
 >>>>>
 >>>>>
 >>>>>>>it?
 >>>>>>>
 >>>>>>>Thanks,
 >>>>>>>
 >>>>>>>David
 >>>>>>>
 >>>>>>>
 >>>>>>
 >>>
 >
 >
 |  |  |  | 
 
 
 Current Time: Thu Oct 30 22:24:53 EDT 2025 
 Powered by FUDForum . Page generated in 0.11008 seconds |