Posts

Showing posts from October, 2007

eclipse Table object and TableViewer and TableLayout

Eclipse has a Table widget. The widget is fairly simple like most widgets, and jface viewers and other managers are needed to make it easier to use. This is a much different strategy than .Net's Form framework where everything is built into the object(convenient but the design is not always great).

The one thing I learned is that for column layout management, you can use a TableColumnLayout object. The TableColumnLayout object helps manage columns but allowing them to have a weight, minimum size, etc. While not hugely robust, it does allow you to not have to set resize listeners on the table object and then manually layout the columns. The only caveat is that the TableColumnLayout layout object must be used on a Composite that has a single child-the table.


Here's a link to an example.

eclipse TextActionHandle and the command framework

Eclipse has a TextActionHandler class (that uses the action framework) to handle global edit actions such as cut, copy and paste. This class has a hook for adding Text controls to it and when the text control is activated (because you have selected it or are editing it) it automatically translates the global edit actions to actions on the Text control. For application areas where you want the logical concept of the "delete" command to translate into something you want to do, for example, delete the currently selected domain object in a master list table viewer, you need to connect to the global command. The standard way has been to obtain the part site (editor or view) then use setGlobalActionHandler() to a locally defined action that then executes your logical "delete" command. Now, with the command framework, you can define a local IHandler object and using the IHandlerService obtained from the getEditorSite().getService(IHandlerService.class) method, you link…

eclipse: Defining your own toolbar menu in plugin.xml but using it in your view or editor's controls

The next challenge I have is how to define a toolbar menu in the plugin.xml folder, for example, to define toolbars for Sections or other widgets capable of having a toolbar (not just the main workbench page) but still pull that definition and instantiate it for my specific view or editor part such as the section. The issue where I don't see how it works is if I define it in the plugin.xml how to do I ensure that when the toolbar needs to be created from that XML specification, that it has the right parent is used such as my Section object in an editor.

The standard menu examples (eclipse 3.3) all seem to assume that it is the main workbench window page that has the toolbars and menus, except perhaps those view specific popup menus and such. Like the popup menus, I need to ensure that the right parent is used to create the toolbar.

The key to the story is the IMenuService which is accessible off the workbench (not the window). The menu service off the workbench


IMenuService service …