public ViewerToolBar(IViewerBinding viewer, int style) {
    myViewer = viewer;
    myStyle = style;

    // TODO: Check style

    myViewer.registerService(this);

    final IManager manager = IManager.Factory.getManager();
    myToolkit = manager.getFormToolkit();

    final IServiceLocator serviceLocator = getViewer().getContext().getServiceLocator();
    myCommandService = (ICommandService) serviceLocator.getService(ICommandService.class);
    myHandlerService = (IHandlerService) serviceLocator.getService(IHandlerService.class);
    myCommandImageService =
        (ICommandImageService) serviceLocator.getService(ICommandImageService.class);

    /*
     * Find the control of the viewer (a Table or Tree).
     *
     * Find the parent Composite.
     *
     * Add a new Composite (with a GridLayout) and reparent the control
     *
     * Then add the toolbar itself on the correct side of the control
     */
    final Control control = myViewer.getControl();
    final Composite parent = control.getParent();

    myComposite = myToolkit.createComposite(parent);
    myComposite.setLayoutData(control.getLayoutData());
    final GridLayout compLayout = new GridLayout(1, false);
    myComposite.setLayout(compLayout);

    control.setParent(myComposite);
    control.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));

    myToolBar = new ToolBar(myComposite, SWT.FLAT | (style & (VERTICAL | HORIZONTAL)));
    if ((style & VERTICAL) != 0) {
      myToolBar.setLayoutData(new GridData(SWT.BEGINNING, SWT.FILL, false, false));
      compLayout.numColumns = 2;
    } else {
      myToolBar.setLayoutData(new GridData(SWT.FILL, SWT.BEGINNING, false, false));
    }
    /*
     * Inlined from FormToolkit.adapt(Composite composite). Do not set focus though.
     */
    myToolBar.setBackground(myComposite.getBackground());
    myToolBar.setMenu(myComposite.getMenu());

    myViewer.registerWidget(myToolBar);

    /*
     * Add standard items
     */
    if ((style & ADD) != 0) {
      // TODO addItem(ADD, "");
    }
    if ((style & DELETE) != 0) {
      addItem(
          DELETE,
          IManager.Factory.getManager()
              .getCommandIDs()
              .get(IWorkbenchCommandConstants.EDIT_DELETE));
    }
    if ((style & UP) != 0) {
      addItem(UP, "com.rcpcompany.uibindings.commands.moveItemUp");
    }
    if ((style & DOWN) != 0) {
      addItem(DOWN, "com.rcpcompany.uibindings.commands.moveItemDown");
    }

    myComposite.layout(true);
  }
  @Override
  protected void createFieldEditors() {
    final INavigatorManager manager = INavigatorManager.Factory.getManager();
    FieldEditor editor;

    final IManager uim = IManager.Factory.getManager();
    for (final CEObjectHolder<EObject> pmt : manager.getPreferenceModelTypes()) {
      final IEditorInformation mt = manager.getEditorInformation(pmt.getObjectClass());

      final String[][] translation = new String[mt.getEditors().size()][];
      for (int i = 0; i < translation.length; i++) {
        final IEditorPartDescriptor d = mt.getEditors().get(i);
        translation[i] = new String[] {d.getName(), d.getId()};
      }

      // IBindingObjectInformation.Factory.getLabel(mt.g) - upps - no class yet, just a name
      /*
       * TODO: change this to use a proper binding
       *
       * IBindingObjectInformation
       */
      String n = mt.getModelType();
      if (n.lastIndexOf('.') != -1) {
        n = n.substring(n.lastIndexOf('.') + 1);
      }
      if (n.matches("^I[A-Z]")) {
        n = n.substring(1);
      }
      String name = ToStringUtils.formatHumanReadable(n);
      final IModelClassInfo info = uim.getModelClassInfo(mt.getModelType(), null, false);
      if (info != null) {
        final Object l = info.getArguments().get(Constants.ARG_LABEL);
        if (l != null && l instanceof String) {
          name = (String) l;
        }
      }
      editor = new ComboFieldEditor(mt.getModelType(), name, translation, getFieldEditorParent());

      addField(editor);
    }

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_USE_GENERIC_EDITOR_PART_FALLBACK,
            "Fall back on generic editor part",
            getFieldEditorParent());
    addField(editor);

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_OPEN_MUST_OPEN_NEW,
            "Open command should open new editors",
            getFieldEditorParent());
    addField(editor);

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_SHOW_PIN_EDITOR_CONTRIBUTION,
            "Show 'pin editor' contribution in menus and toolbars",
            getFieldEditorParent());
    addField(editor);

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_PIN_EDITOR_BY_DEFAULT,
            "Pin new editors by default",
            getFieldEditorParent());
    addField(editor);

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_SHOW_CLONE_EDITOR_CONTRIBUTION,
            "Show 'clone editor' contribution in menus and toolbars",
            getFieldEditorParent());
    addField(editor);

    editor =
        new BooleanFieldEditor(
            NavigatorConstants.PREF_SHOW_CLONE_EDITOR_CONTRIBUTION,
            "Show other contribution in menus and toolbars",
            getFieldEditorParent());
    addField(editor);
  }