Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Sapphire » Virtual Node Factory for classification of Nodes
icon3.gif  Virtual Node Factory for classification of Nodes [message #989403] Thu, 06 December 2012 06:08 Go to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
Hello everyone Smile I need a little help here

Let's say I have an XML like this:

<salaries>
    <employee department="dep1" name="name1" salary="1000" />
    <employee department="dep1" name="name2" salary="2000" />
    <employee department="dep2" name="name3" salary="4000" />
    <employee department="dep3" name="name4" salary="2500" />
    <employee department="dep2" name="name5" salary="1500" />
    <employee department="dep3" name="name6" salary="1100" />
    <employee department="dep1" name="name7" salary="2300" />
</salaries>


Employees are not classified by Department, but I don't want to view them in a single Node Factory, instead I aim to create a Node Factory for Departments (dep1, dep2, dep3), and inside each department, I want another Node Factory for the inner Employees. Is that even applicable?

Note: Departments are not known in advance, I mean they are not restricted to specific values.

Thanks in advance for your concern Smile

[Updated on: Thu, 06 December 2012 07:45]

Report message to a moderator

Re: Virtual Node Factory for classification of Nodes [message #989557 is a reply to message #989403] Thu, 06 December 2012 17:39 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
In order to put something like this together, you will need to shape the data at the model level into a hierarchy of departments and employees.

This will mean writing custom bindings for list properties holding departments and employees. See StandardXmlListBindingImpl for an in-depth example on how to implement a list property binding. I recommend using a meta-comment to persist a department that has been created, but has no employees. See XmlElement.setMetaCommentText(), etc.

So it would be a two step process... Create department, give it name. Then create employees underneath it. Your employees list binding would fill in the department for each newly created employee. If you'd like, you can still have a department property on the employee. If all the bindings are working correctly, changing department, will move the employee from one list to another.

- Konstantin
Re: Virtual Node Factory for classification of Nodes [message #989880 is a reply to message #989557] Sun, 09 December 2012 08:59 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
I'm sorry, but do you have any similar case? Cause I can't really find any sample using StandardXmlListBindingImpl or MetaComments
Re: Virtual Node Factory for classification of Nodes [message #990136 is a reply to message #989880] Tue, 11 December 2012 04:22 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
There aren't existing samples that put all of these concepts together. Let me see if I can whip something up.

- Konstantin
Re: Virtual Node Factory for classification of Nodes [message #990139 is a reply to message #990136] Tue, 11 December 2012 06:31 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
Well .. Thanks in advance Smile You're really saving me Very Happy
Re: Virtual Node Factory for classification of Nodes [message #990343 is a reply to message #990139] Wed, 12 December 2012 02:17 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
I created a new sample to demonstrate how to group flat data based on a particular property. The catalog editor maintains a flat list of items (name, description, category, manufacturer) in an XML file and presents them three different ways:

1. All together
2. Grouped by category
3. Grouped by manufacturer

I took a somewhat easier approach of not allowing direct creation/deletion of categories and manufacturers. You can only create/delete them by editing the respective properties of catalog items. This avoids the complication of dealing with meta-comments.

The new sample is available in the 0.7 code line (master branch), but it is compatible with 0.6.1 code line (R_0_6_x branch) as well. I did find and fix two bugs in the course of developing this sample and this sample will not function without these bugs fixes. The fixes are in 0.6.1 and 0.7 streams. The sample will not function with the 0.6 release.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=396335
https://bugs.eclipse.org/bugs/show_bug.cgi?id=396337

Take a look and post questions if something is not clear.

You can thank me by spreading the word about Sapphire. Tell your co-workers, blog, etc.

- Konstantin
Re: Virtual Node Factory for classification of Nodes [message #991040 is a reply to message #990343] Mon, 17 December 2012 07:35 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
Well .. I used to use sapphire 0.5, and now I'm trying to migrate to sapphire 0.6.1 in order to make use of the 2 new bug fixes you just mentioned.
I guess I have problems migrating to 0.6.1:

I changed the Editor class that extends SapphireEditorForXml as the following:
From:
        super( "org.mywork.msxmleditor" );
        setRootModelElementType( IDocument.TYPE );
        setEditorDefinitionPath( "org.mywork.msxmleditor/org/mywork/msxmleditor/ui/editor.sdef/editor.page" );

To
        super
        (
        	IDocument.TYPE,
        	DefinitionLoader
                        .context( MSXMLEditor.class.getClassLoader() )
                        .sdef( "org.mywork.msxmleditor.ui.editor" )
                        .page( "editor.page" )
        );


And also some services used the internal Model Elements, which couldn't be resolved, so I used the Model IElements instead.

I changed nothing else, and I have no errors before compiling. At runtime, I get an error telling me that it cannot launch the editor because it was unable to instantiate IDocument (the base class for the root tag)

I'm still debugging, but do you have any ideas? the IDocument class has nothing special !!

[Updated on: Mon, 17 December 2012 07:35]

Report message to a moderator

Re: Virtual Node Factory for classification of Nodes [message #991218 is a reply to message #991040] Mon, 17 December 2012 20:15 Go to previous messageGo to next message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
It is possible that something is going on that's preventing the annotation processor from producing implementation classes for your types. Did you ensure that you've upgraded Sapphire SDK in your dev Eclipse and Sapphire in your target platform. Both versions have to be the same.

Keep an eye on the .apt_generated folder in your project. It should contain generated implementation classes for types with @GenerateImpl. Run Project->Clean after making any changes to let Eclipse rebuild from scratch.

- Konstantin
Re: Virtual Node Factory for classification of Nodes [message #991278 is a reply to message #991218] Tue, 18 December 2012 10:25 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
Correct, and I could successfully migrate to 0.6.1 after doing the following:
1- Get a fresh new installation of eclipse.
2- Install sapphire using "Help > Install new software"
3- Adjust my app dependencies to the new sapphire version
4- Open the "sdef" of the editor, and find out if there's any errors to fix after migration (that one took me more than 3 hours of debugging Very Happy )

I'd recommend adding some guidelines like these to the migration guide. Don't you think so?
Re: Virtual Node Factory for classification of Nodes [message #991444 is a reply to message #991278] Wed, 19 December 2012 08:10 Go to previous messageGo to next message
Hazem ELRAFFIEE is currently offline Hazem ELRAFFIEEFriend
Messages: 61
Registered: September 2012
Member
Something else, which I don't know if it's applicable or not, but it could be very helpful if you try to make it while developing 0.7

When you have errors in the "sdef" file, you can only know it by opening the "sdef" and noticing the error red flag, but in the eclipse project explorer, you don't find an error red flag on the "sdef" file as a source file to the project.

In short words, when a java file has some errors, it has red flag in the project explorer, but when an "sdef" file has some errors, it doesn't have any red flags in the project explorer. (that's really confusing sometimes)
Re: Virtual Node Factory for classification of Nodes [message #991481 is a reply to message #991444] Wed, 19 December 2012 12:40 Go to previous message
Konstantin Komissarchik is currently offline Konstantin KomissarchikFriend
Messages: 1077
Registered: July 2009
Senior Member
Quote:
I'd recommend adding some guidelines like these to the migration guide.


Adding more guidance is always possible, but first I need to get a better understanding about what wasn't obvious. What steps did you initially follow to update your Sapphire environment?

Quote:
When you have errors in the "sdef" file, you can only know it by opening the "sdef" and noticing the error red flag, but in the eclipse project explorer, you don't find an error red flag on the "sdef" file as a source file to the project.


There is an enhancement request tracking this need, but as with all such items, there isn't enough time for everything. Some day.

https://bugs.eclipse.org/bugs/show_bug.cgi?id=329080

My general migration advice is to avoid the temptation of going solely by errors. Some of the migration tasks will advertise themselves with errors, but many will not. I recommend going through the migration guide section-by-section and seeing if the stated case applies to your code. This approach will minimize the risk of long debugging sessions stemming from missed migration steps.

- Konstantin

[Updated on: Wed, 19 December 2012 12:40]

Report message to a moderator

Previous Topic:Calling all Sapphire adopters
Next Topic:On-demand compilation of model elements
Goto Forum:
  


Current Time: Thu Mar 28 10:10:07 GMT 2024

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

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

Back to the top