[isabelle-dev] NEWS: Dockable window "Find"

Holger Gast gast at informatik.uni-tuebingen.de
Fri Sep 20 09:18:02 CEST 2013


>> [...]
>> font management, etc. ;( Obviously, the choice of UI frameworks does
>> matter in everyday work on UIs.
> 
> All UI frameworks I've seen so far are crap.  A UI framework alone does not give
> you a real editor, you would have to implement that yourself.
It is, of course, just not true that you have to do everything yourself.
To illustrate my claim that the choice of the UI framework does matter,
consider the notorious sub/super-scripting problem for Isabelle theories.
Swing doesn't have it, the really powerful Netbeans editor doesn't
(or didn't, when I last looked), but JFace/SWT *does*:
I just skimmed the API documentation (the JavaDoc, yes, the JavaDoc),
found the "StyledText" (which is used by the JFace TextEditor, which is used by
the Eclipse text editors), found the setStyleRange(StyleRange) method,
and found the "rise" parameter in the StyleRange.
>From there, with the assistence of WindowBuilder for layouting etc.,
I got the attached subscript/superscript demo working immediately.

At the core, one just creates StyleRanges and set them to the widget:

styledText.setStyleRanges(new StyleRange[] {
   keyword(0, 7), subScript(s1, 1), subScript(s2, 1), superScript(s3, 5) });

private StyleRange subScript(int start, int length) {
   StyleRange r = new StyleRange();
   r.start = start;
   r.length = length;
   r.rise = -4;
   r.font = scriptFont;
   return r;
}

> we knew that already from the start.  (You were actually the one to see good OO
> design in Swing and its pluggable LAFs.)
I still maintain that Swing has a large amount of good OO design, and
in particular a very neat model/view separation. Also, it is a good
place to see how far one gets by the consistent application of proven
design patterns. My expressed current preference for JFace/SWT stems from
- its speed
- its modern widgets, e.g. tables that have attached trees for folding rows
- its use of the platform's native widget set, which does wonders for usability

> Maybe you want to help them getting SWT into a form that they can catch up with
> the display qualities of Isabelle/jEdit (sub/superscripts, hyperlinks and formal
> markup in tooltips etc.). I had to bend Java 2D and Swing quite a bit to make
> this work, but it has to be repeated for SWT
These features are all availabe in Eclipse editor and hence supported
by the overall editing framework. To make this very clear: nobody uses
SWT by itself. The Eclipse platform consists of three layers,
with according resonsibilities:
1) SWT: wrapper for the native widget set, quite a few editor-specific
   custom widgets. This is intentionally kept with minimal functionality,
   because it needs to be ported to different platforms.
2) JFace: the viewers implement model/view separation (the model-view-controller
   pattern), and add editor-specifics, such as syntax-coloring, annotation bars,
   auto-completion, and much much more. In general, there is one Viewer type
   for one SWT widget type, and it makes the minimal widget useful
   to applications.
3) Eclipse: adds functionality concerning the editing environment:
   resources on the disk, opening/closing/re-arranging/... of editors and
   views, matching files types to their editors, etc. (This is sometimes
   called the view-handler pattern [1]). The usage is actually
   very simple, once one has grasped isolated the essential points from
   the generality of the overall platform. At least, my students were able
   to create views and editors after one lecture on the plugin and
   window handling concepts.

The layers 2+3 offer extensive means of customization.
To come back to the above example, one does, of course, not set
StyleRanges on the SWT widget oneself. One registers with the
JFace TextViewer's syntax highlighting mechanism and produces
them on demand -- for instance from the semantic markup offered
by Isabelle/Scala.

> -- and all the portability issues
> will probably come back once again in a different form.
Actually, probably not: the Eclipse IDE is widely used on the platforms
that Isabelle supports and the IBM engineers are doing a constantly great
job at keeping the differences under the hood of SWT and the whole system
running. Since the Eclipse/JFace/SWT stack is actually used in industry
for end-user applications, there is a lot of pressure to succeed.
The available "delta-pack" makes it straightforward to package
an application for different platforms.

I hope to have clarified my earlier claims in this way.
I'm also always happy to answer more specific questions
if they arise.

Cheers,

Holger

[1] Buschmann et al.: Pattern-oriented software architecture. Wiley.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SubSuperScriptDemo.java
Type: text/x-java
Size: 2808 bytes
Desc: not available
URL: <https://mailman46.in.tum.de/pipermail/isabelle-dev/attachments/20130920/77e318df/attachment-0002.java>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: subsuperdemo.png
Type: image/png
Size: 9094 bytes
Desc: not available
URL: <https://mailman46.in.tum.de/pipermail/isabelle-dev/attachments/20130920/77e318df/attachment-0002.png>


More information about the isabelle-dev mailing list