Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #38599
| From | Martin Gregorie <martin@mydomain.invalid> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Displaying a ragged array |
| Date | 2018-09-17 23:43 +0000 |
| Organization | albasani.net |
| Message-ID | <pnpe6d$ivs$1@news.albasani.net> (permalink) |
| References | <pnmkqh$7dp$1@news.albasani.net> <pnoc21$ga9$1@dont-email.me> <pnovgf$rio$1@news.albasani.net> <pnp6d1$vj6$1@dont-email.me> |
On Mon, 17 Sep 2018 23:29:39 +0200, Daniele Futtorovic wrote: > On 2018-09-17 21:32, Martin Gregorie wrote: >> On Mon, 17 Sep 2018 16:00:03 +0200, Daniele Futtorovic wrote: >> >>> I think you should compose, rather than inherit that (i.e. a >>> DatastoreTableModel layer). >>> >> Why? > > The old "favour composition over inheritance" thing. Your Datastore is > not a TableModel, it's a Datastore. E.g. it might get populated by other > sub-components. Why should those have to interact with a TableModel > that's none of their business? > Fair comment, though its unlikely to gain subcomponents as I designed it to do nothing except store data fields and support the insert*/delete*/ get* methods needed to manage its contents plus, of course, the three TableModel interface methods (getColumnCount, getRowCount, getValueAt). >> Yes, missing elements will always be at the end. They are distinct from >> empty elements, which are represented by empty Strings. Missing >> elements are off the end of the ArrayList, i.e. get(n) would throw an >> IndexOutOfBoundsException if asked to fetch them. Datastore returns >> null and sets an error (testable with hasError()) if you try it. > > (A quick size() check might be preferable to throwing an Exception) > I did that already: Datastore checks row and column indexes and, if out of range or pointing at a numexistent field, sets an error condition (visible with hasError() and returns null. >>> A _display_ problem I would address at the _rendering_ level, rather >>> than the model level. That is, using the TableCellRenderer and >>> TableCellEditor. >>> Sure. Datastore is part of the Model class . The display mechanics will be in View (not yet written). >> The app is an editor for manipulating CSV files with embedded comment >> lines. Yes, I know that yoy can use a spreadsheet, but they can and do >> mess with fields that they think need special treatment, e.g. dates. >> >> One problem I see with using a JTable is that, while a comment line can >> be handled as a line containing one field, it would be would be best >> treated as a complete line, because its width should not affect the >> first column width, i.e. the displayed width of the first fields on >> other lines. > > I can see two options. > One would be to display comments separately, in a dedicated UI > component, when a specific data row is selected. This assumes that > comment lines "belong" to a specific data row. > I'm still thinking about that. You're right that they belong in a specific row, so should be displayed at the correct position(s) in the row list. > The other would be to use a JTreeTable. I'd love to get you a link for > that, but that Oracle's Java site is so goddamn fucking useless I > haven't been able to find the relevant article. I think it was somewhere > in the Swing tutorials. > Is that like a JTree, but with the content of branches displayed horizontally rather than hanging down as in a JTree? It doesn't appear to be part of the Java 8 standard class library. FWIW I've dropped Oracle Java in favour of Open Java, which is currently at v1.8, because Open Java is a standard Fedora package and updates are automatically part of my normal weekly Linux update. -- Martin | martin at Gregorie | gregorie dot org
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-16 22:17 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-17 16:00 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 19:32 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-17 23:29 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 23:43 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-19 18:12 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-19 17:49 +0000
Re: Displaying a ragged array Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-09-19 14:25 -0400
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-19 19:29 +0000
Re: Displaying a ragged array Daniele Futtorovic <da.futt.news@laposte-dot-net.invalid> - 2018-09-20 15:30 +0200
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-20 15:06 +0000
Re: Displaying a ragged array Eric Douglas <e.d.programmer@gmail.com> - 2018-09-24 08:11 -0700
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-24 17:52 +0000
Re: Displaying a ragged array Eric Douglas <e.d.programmer@gmail.com> - 2018-09-24 12:01 -0700
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-10-23 21:00 +0000
Re: Displaying a ragged array Eric Sosman <esosman@comcast-dot-net.invalid> - 2018-09-17 10:17 -0400
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 19:46 +0000
Re: Displaying a ragged array Martin Gregorie <martin@mydomain.invalid> - 2018-09-17 23:53 +0000
csiph-web