Freitag, 26. Juli 2013

Content Assist in Graphical Editors

For the latest release 2.1.1 of the Yakindu Statechart Tools we implemented a pretty cool new feature - Content Assist for Graphical Editors.

You already know content assist from the textual parts of SCT statecharts and of course from JDT, CDT etc. Content Assist in Graphical Editors follows the same idea and works in a comparable way. Select a state and press Ctl-Space and you get proposals for high level editing operations, as the following screenshot shows.
 
ContentAssist1

ContentAssist2




The infrastructure is quite generic and  it should be possible to add it to any editor that is based on the Graphical Editing Framework in no time. It provides a ContentProposalViewerKeyHandler that can be attachted to GEFs Graphical Viewer. It listens for the CTR-Space keystroke and opens a 
org.eclipse.jface.fieldassist.ContentProposalAdapter if the event occures. Since the ContentProposalAdapter and its corresponding IControlContentAdapter are mainly designed for text proposals / completions, there is a SemanticContentControlAdapter that adapts text replacements to semantic modifications. The text replacement string is internally used as a unique template id to identify the user selection and invoke the ISemanticModification.

In Yakindu Statechart Tools, clients can provide extensions to an extension point to contribute custom proposals. The extension point requires some text stuff like a label, description and an icon as well as an implementation of the ISemanticModification interface:

public interface ISemanticModification {

    public boolean IsModificationFor(View view);

    public void modify(View view);
}


Content Assist in Graphical Editors will save a lot of mouse click work and are an important step towards a graphical editor that can be entirely controled by keyword. However, content assist in graphical editors are way more complex to implement due to layouting issues.

This feature is still not final, we will have to improve key handling, auto layouting and documentation integration. But feel free to try this feature and we will appreciate any feedback on it!