Wizards - RCP - ViewPart
 |
|
Subclasses of the Eclipse RCP ViewPart class can be
created using the RCP ViewPart wizard. The wizard can be
selected from the drop down Designer wizard menu or from the
Eclipse New wizard.
To use the wizard, select the project source folder and package
to contain the class. Then enter the class name and view name and hit the Finish
button. |

The wizard generates the following code.
- import
org.eclipse.jface.action.IMenuManager;
- import
org.eclipse.jface.action.IToolBarManager;
- import org.eclipse.swt.SWT;
- import
org.eclipse.swt.widgets.Composite;
- import
org.eclipse.ui.part.ViewPart;
public static final String ID = "sample.rcp.EclipseViewPartTest";
public class
EclipseViewPartTest extends ViewPart {
- public
void createPartControl(Composite parent) {
-
Composite container = new Composite(parent, SWT.NONE);
-
createActions();
-
initializeToolBar();
-
initializeMenu();
- }
- private
void createActions() {
- }
- private
void initializeToolBar() {
-
IToolBarManager tbm =
-
getViewSite().getActionBars().getToolBarManager();
- }
- private
void initializeMenu() {
-
IMenuManager manager =
-
getViewSite().getActionBars().getMenuManager();
- }
- public
void setFocus() {
- }
- }
If the ViewPart is created in an existing plugin project, the
plugin.xml file is also updated with the appropriate view declaration.

When editing ViewParts, Designer presents two tabs in
the design area, one for laying out the contents of the view (using any widgets
or layout managersr) and a
second for defining actions and assigning them to the view's toolbar and
menu.

On the Actions tab, the first column, Actions, is used to
define new actions (which are created as inner classes of the current
class). New actions may be created using the Add button (plus icon)
above the column, existing actions may be added using the Open
button (folder icon), and existing actions may be deleted using the Delete
button (minus) icon. Selecting an action allows you to edit its icons,
label and tool tip text within the property pane.
The second column, Toolbar, is used to define the contents of
the view's toolbar. Actions and separators may be dragged from the Actions
column and dropped in the Toolbar column. Toolbar actions may be
rearranged using the Move Up and Move Down buttons and
deleted using the Delete button above the column. The order of
individual items may also be rearranged via drag and drop.
The third column, Menu, is used to define the contents of the
view's menu. Actions, separators and menu managers may be dragged from
the Actions column and dropped in the Menu column. Menus may
be expanded and collapse using the Expand All and Collapse All
buttons and deleted using the Delete button above the column. The
order of individual items may also be rearranged via drag and drop.
When the ViewPart itself is selected in the property pane, its icon,
category and title may be edited. New categories may also be created.
 |