I would like some feedback on the design of this 'Word'-like application:
The application
---------------------
I'm implementing a 'Word' kind of application with Paragraph and Character styles. Character styles inherit information from the paragraph styles they belong to, and paragraph styles may or may not inherit from other paragraph styles.
Each document in my application consist of several 'frames' which contain JTextPanes with styles.
There is a Paragraph Style editor and a Character Style editor. The different styles may be used and shared amongst the different frames and pages in each document.
The user specifies which paragraph styles that should be available in each frame (the character styles just follow the paragraph styles since they all belong to one and only one paragraph style).
How I'm thinking of doing it
----------------------------------------
Each JTextPane (frame) contain a StyleContext which I add styles to. I do not distinguish between char/pstyles - both are created with StyleContext.addStyle()
Character styles will be Style's with the Paragraph Style as their resolving parent.
But how will I distinguish between character styles belonging to a paragraph style, and paragraph styles that have another paragraph style as their resolving parent?
I need a central Style repository - but I can't use StyleContext for this, as I need to be able to restrict the styles that are available for each 'frame'.
So I'm considering a singelton which holds all available StyleContext's - and one StyleContext for each JTextPane.
Possible problems; when styles are updated I need to go through all frames to make sure the same styles are updated.
The styles need to hold extra information - eg. database ids and such. I will just add them as attributes, e.g. style.addAttribute(DATABASE_ID_CONSTANT, new Integer(102)) - Are there any problems with this approach? Will all these custom attributes be copied with style.copyAttributes() etc?
I'm adding listeners to each style, so that the frames are updated and repainted with the new style info when the styles are changed though the style editors.
The frame formatting info will need to be saved to a database - so I need a way of getting a document, retrieving the paragraph styles used (and positions - from, to) and the character styles used (positions) and their databse IDs.
Any feedback on the approach appreciated
The application
---------------------
I'm implementing a 'Word' kind of application with Paragraph and Character styles. Character styles inherit information from the paragraph styles they belong to, and paragraph styles may or may not inherit from other paragraph styles.
Each document in my application consist of several 'frames' which contain JTextPanes with styles.
There is a Paragraph Style editor and a Character Style editor. The different styles may be used and shared amongst the different frames and pages in each document.
The user specifies which paragraph styles that should be available in each frame (the character styles just follow the paragraph styles since they all belong to one and only one paragraph style).
How I'm thinking of doing it
----------------------------------------
Each JTextPane (frame) contain a StyleContext which I add styles to. I do not distinguish between char/pstyles - both are created with StyleContext.addStyle()
Character styles will be Style's with the Paragraph Style as their resolving parent.
But how will I distinguish between character styles belonging to a paragraph style, and paragraph styles that have another paragraph style as their resolving parent?
I need a central Style repository - but I can't use StyleContext for this, as I need to be able to restrict the styles that are available for each 'frame'.
So I'm considering a singelton which holds all available StyleContext's - and one StyleContext for each JTextPane.
Possible problems; when styles are updated I need to go through all frames to make sure the same styles are updated.
The styles need to hold extra information - eg. database ids and such. I will just add them as attributes, e.g. style.addAttribute(DATABASE_ID_CONSTANT, new Integer(102)) - Are there any problems with this approach? Will all these custom attributes be copied with style.copyAttributes() etc?
I'm adding listeners to each style, so that the frames are updated and repainted with the new style info when the styles are changed though the style editors.
The frame formatting info will need to be saved to a database - so I need a way of getting a document, retrieving the paragraph styles used (and positions - from, to) and the character styles used (positions) and their databse IDs.
Any feedback on the approach appreciated