Displaying a ragged array

I'm in the process of creating a desktop application to display and edit data that's best treated as a ragged array of Strings: it is quite unlikely that all rows in the array will be the same length.

I've built and debugged a Datastore class to hold it as an ArrayList of ArrayList - the ArrayList being in a wrapper class representing a row of fields. The DataStore allows rows, columns and individual fields to be inserted, deleted, and the fields to be modified.

Datastore extends AbstractTableModel because I was initially intending to use a JTable to display and manipulate its contents, but now its successfully manipulating the ragged array I'm having twinges of doubt about how whether a JTable can is the best way of displaying it and allowing it to be viewed and modified, i.e. can a JTable deal successfully with the missing elements at the end of rows in a ragged array?

Would I be better off with a custom built structure containing, say, an array of JButtons to display fields in the ragged array and that can be clicked to add a field, edit or delete it?

I'll be very interested to hear how you've handled, or would handle, this display problem.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie
Loading thread data ...

You do not specify the language in which you're writing. Is it unique to the RPi?

Reply to
Roger Bell_West

With all the "J"s in the original post, I'd guess either JavaScript or Java.

--
+----------------------------------------------------------------------+ 
| Gerald W. Lester, President, KNG Consulting LLC                      | 
 Click to see the full signature
Reply to
Gerald Lester

Surprisingly he's not using GEORGEIII macros or 6809 assembler! ;-)

Reply to
mm0fmf

Apologies for that: it was meant for comp.lang.java.programmer

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

I could possibly help if it were PAL-III.

--
Ivan Reid, School of Engineering & Design, _____________  CMS Collaboration, 
Brunel University.    Ivan.Reid@[brunel.ac.uk|cern.ch]    Room 40-1-B12, CERN 
 Click to see the full signature
Reply to
Ivan D. Reid

XML/XLST to a web browser.

--
Adrian C
Reply to
Adrian Caspersz

...and modifying it? Saving the result?

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

web app, client side javascript (jquery, handlebars etc...)

formatting link

or good old CGI html forms processing (POST/GET etc...)

or a NodeJS server....

--
Adrian C
Reply to
Adrian Caspersz

Why would I ever build a web app or use that typeless mess called javascript when what I need is a standalone application, preferably written in Java (or C with curses or GTK2 at a pinch) that reads, alters and saves local files?

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Since I can get all the interface separation I need by using an MVC structured program written in Java, thats what I'm about to do.

Yep, somebody who 'codes' by copying snippets from slashdot and calling somebody else's JS fragments from github etc. may well do that. I'll give it a miss, thanks.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Fashion ? Foolishness ?

Ah because you want to practice separation of function and interface, so you'll write the backend in C, middleware in Java and a web front end in PHP and JavaScript and feel thoroughly miser^Wmodern.

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:\>WIN                                     | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

when you want multiple people to be able to access & manipulate data on a central server & you don't want then tied to particular hardware or software

a well conceived web app would be accessible from any device including an old WAP mobile phone with minimal disruption to the user experience.

this is not the correct model for every app

--
Wasn't there something about a PASCAL programmer knowing the value of 
everything and the Wirth of nothing?
Reply to
Alister

Indeed, but that is NOT what I want or need. I said at the outset that its a *desktop application* - doesn't anybody read? To be precise, its specialised desktop CSV editor, intended to read, update and write files on the locally accessible filesystem. Yes, I could do the job with a text editor or use a spreadsheet, but both have disadvantages:

- a text editor isn't great for editing files with TAB field separators and/or where the first few fields on a line vary hugely in length and the later ones are short and/or can be empty. Both cases are difficult to read in a standard text editor

- a spreadsheet at least aligns fields in columns, but also monkeys about with some data, e.g.fields containing dates or numbers may have their formats modified in ways the the target consuming program doesn't like. Some spreadsheets are worse than others at doing this.

So, I am writing a CSV editor that gives the field alignment benefits of a spreadsheet but that is guaranteed not to mess with the format of any data. It will be a Java program because Java has extensive GUI support thanks to its AWT and Swing class libraries and because it can be run on any hardware and OS where there's version 1.8 JVM - which is almost every current system including the RPi. And as a bonus, thanks to X.11 forwarding, it can also be used to edit files on any machine that is accessible via an SSH session.

Quite. And its not correct for this one.

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Ah. The new Barclay's 'Smart Investor' website described exactly!

Only idiots would use it apart from people who were already part of it before it was 'improved' with pastel shades of happy sheeple investing in rap investments...

--
The theory of Communism may be summed up in one sentence: Abolish all  
private property. 
 Click to see the full signature
Reply to
The Natural Philosopher

It is also a common 'enterprise' style, sometimes it even makes sense (usually when scalability is a dominant issue, inefficiency is trumped by being able to throw more hardware at the job without thinking).

Thoroughly unsuited for most purpose of course.

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:\>WIN                                     | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

Reply to
Andy Burns

.... and would have got anybody using it helped through the door with a hobnailed boot in all places but one [1] where I've worked.

[1] The Naval Dockyard Project, Bath, 1975 - the project was three years

creative use of the TMMITFM staffing method [2].

By the time I was involved, the MOD management had been shoved to one side and replaced by ICL Datakill guys, who were actually pretty good, and the programming duffers had also been removed and replaced by around

80 contractors, of whom I was one. Most were quite good, but there were 2-3 shockers:

- one was well known to a bunch of the others who said they'd never seen him to finish a program: he worked a lot of overtime, pocketed the cash and left just before his mess was due to be system tested.

- another didn't know that in COBOL one paragraph falls through to the next unless a GOTO says otherwise. Consequently, all his code looked like this: PARA-1. STATEMENT..... ........ GO TO PARA-2. PARA-2. STATEMENT..... ........ GO TO PARA-3. PARA-3. ...

- a third never did understand that a 'divide by zero' error would be caught by an ON SIZE ERROR exception. He thought it should cause the mainframe to screech to a halt and require a reboot.

Anyway, we got the system redesigned, up and running in 18 months, and even had fun doing it. Bath is a nice,lively town and it was a happy, well lubricated project that worked surprisingly well considering the speed with which the team had been assembled. It turned out to be a good social mix of remaining MOD HEOs, contractors and the Datakill crew management.

[2] TMMITFM stands for the 'Those Magnificent Men In Their Flying Machines' film and its "There is nothing a German Officer Cannot Do" scenes as the German military flew across the Channel while reading their how-to-fly manual. In this project it became implemented as "There is nothing a Civil Servant Cannot Do". The MOD bosses staffed the project by sending a bunch of HEOs on a systems course. When they got back they were told to design the system, a complex one that was supposed to manage all aspects of purchasing, stock control and tracking as naval equipment and stores were bought, moved round between the four naval dockyards, and eventually used up or scrapped. Two or three months later they sent another bunch of HEOs on a COBOL course. When they got back the analysts were told "Here are your programmers: give them some programs to write" and the whole catastrophe started to crumble.
--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie

Thanks, I guess. I wasted a pleasant half hour going to that site and following the links. The BOFH lives on!

--
/~\  cgibbs@kltpzyxm.invalid (Charlie Gibbs) 
\ /  I'm really at ac.dekanfrus if you read it the right way. 
 Click to see the full signature
Reply to
Charlie Gibbs

When it makes sense it is usually the only way to get the job done, because you've sailed off the deep end in requirements either way past where you can fit the job on a single machine or because you need to push availability past the point where a country getting disconnected causes you problems so you have to have wide area distribution, local storage with global failover (see things like Amazon's Dynamo for the extreme end of this trend - one of the few that is publicly documented, the architecture of the Yahoo! customer database is interesting but that's all I'm willing to say about it).

--
Steve O'Hara-Smith                          |   Directable Mirror Arrays 
C:\>WIN                                     | A better way to focus the sun 
 Click to see the full signature
Reply to
Ahem A Rivet's Shot

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.