-3

I'm working on an application where I need to map fields in one CSV file to fields in a data structure defined by the application. I'd thought of different ways of doing this, but the method that I like the best is the one where I would have a graphical user interface where the user could just drag columns from an entity representing the CSV file to an entity representing the internal data structure. This way, it would be all drag and drop.

Does anyone know of a Java library I can use to achieve something like this?

UPDATE

I'd like to point out that I am looking for components which can help me with the visualisation. I do know that I can't find any ready made components which will take care of the entire mapping and data transformations for me. It's a matter of trying to track down swing components which can help me visualise relationships between entities and their fields (CSV file being an entity and internal data structure being another entity).

sbrattla
  • 5,274
  • 3
  • 39
  • 63
  • There are no libraries that give you a graphical swing interface, bind CSV to data structure and transform that file. You would need to code it all by yourself. Create a list with CSV fields, create a list with class fields, implement drag-n-drop to bind fields to eachother. Create a parser that uses those relations to parse CSV file. – bezmax Jan 23 '12 at 12:28
  • What part of my post makes you think that I'm after a library which does it all for me (withouth me having to lift a single finger and at the same time brews me a cup of steaming hot coffee?). I'm simply asking if anyone knows of a library (graph library, relationship visualisation library or the like) which can *help me achieve it* (as opposed to actually carry out the task)? – sbrattla Jan 23 '12 at 12:32
  • I'm still not sure how is swing not enough to achieve your task. You can create your component, make it render some kind of circle with text in it. Then make your panel, which draws lines between linked circles in it. Then implement drag-and-drop on those circles to link them together. Now create list of circles on the left side representing your CSS file fields, and list of circles on the right side representing class fields. – bezmax Jan 23 '12 at 12:39
  • question to vague ask more specific questions – Peter Jan 23 '12 at 12:40
  • @Max: Sure, swing has everything I need to achieve the task, but I can't think of any good arguments for spending hours and hours doing things myself if someone else have already a killer library that does the same thing. Is it not better to use available components whenever possible instead of reinventing the wheel? I've managed to find the JGraph library which can help me visualise the mapping between CSV and the custom data structure. However, any other suggestions are very welcome. – sbrattla Jan 23 '12 at 13:10
  • @sbrattla Well, in reality, the algorithm I describerd (with circle components) is very easy to implement if you have any Swing experience. It is basically as easy as it sounds from my description. Therefore, I'd say it is a huge overhead to use some kind of visualization library for this simple task. – bezmax Jan 24 '12 at 10:38
  • @Max That's fair enough. However, I find it surprising that the question received as much negative feedback as it did. It is after all not very different from asking for a Java FTP library, Java ORM library or Java XMLRPC library for that matter. It was simply a question which asked for other's experience on libraries which can visualise relationships. Anyway, I've begun experimenting with JGraph which appears to be an excellent library for this task! – sbrattla Jan 25 '12 at 07:33
  • @sbrattla Basically this site is not Google. If you try writing "Java Graph Library" in google I'm sure you will find plenty results. As about `which is better` kind of questions - they are prohibited by website rules. This site is for constructive questions and answers, while `which is better` questions bring discussions and no results. – bezmax Jan 25 '12 at 07:51

1 Answers1

3

Consider using JList or JTable containing a checkbox column, either of which would leverage the existing DnD support for those components. A common interface uses two parallel lists flanking a column of controls. For example,

Word Style Organizer
(source: java2s.com)

Glorfindel
  • 21,988
  • 13
  • 81
  • 109
trashgod
  • 203,806
  • 29
  • 246
  • 1,045
  • Sorry, I don't know of a Java implementation. – trashgod Jan 23 '12 at 17:37
  • Thanks a lot for your answer! I appreciate that someone does try to approach the question in a sensible way! – sbrattla Jan 23 '12 at 20:08
  • You're welcome, although I must acknowledge @Max & your clarifying comments. I vaguely recall something similar among NetBeans' entity management dialogs. I've not seen a more general abstraction, and I'm at a loss for search terms: set picker? list organizer? choose _n_ from column A? – trashgod Jan 23 '12 at 20:53