Ejemplo n.º 1
0
 public void layout() {
   _form.layout(true);
   _form.getBody().layout(true, true);
 }
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.ui.views.properties.tabbed.AbstractPropertySection#createControls
   * (org.eclipse.swt.widgets.Composite,
   * org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage)
   */
  @Override
  public void createControls(
      final Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) {

    this.parent = parent;
    this.toolkit = new FormToolkit(parent.getDisplay());
    super.createControls(parent, aTabbedPropertySheetPage);

    if (form != null && !form.isDisposed()) {
      try {
        form.dispose();
      } catch (Exception e) {
        // ignore any expose exceptions
      }
    }
    form = null;

    if (parent.isDisposed()) return;

    parent.setLayout(new GridLayout());
    // parent.setLayout(new GridLayout(1, false));
    parent.setLayoutData(new GridData(GridData.FILL_BOTH));

    form = toolkit.createForm(parent);
    form.setLayoutData(new GridData(GridData.FILL_BOTH));
    form.setText(EditorMessages.propertiesDocumentationTitle);
    toolkit.decorateFormHeading(form);

    form.getBody().setLayout(new GridLayout(1, false));

    Composite sbody = form.getBody();

    ToolBar navBar = new ToolBar(sbody, SWT.NONE);
    toolkit.adapt(navBar);
    navBar.setLayoutData(
        new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
    final ToolItem back = new ToolItem(navBar, SWT.PUSH);
    back.setText("<");
    back.setEnabled(false);
    final ToolItem forward = new ToolItem(navBar, SWT.PUSH);
    forward.setText(">");
    forward.setEnabled(false);

    back.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.back();
          }
        });
    forward.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            browser.forward();
          }
        });

    final LocationListener locationListener =
        new LocationListener() {
          public void changed(LocationEvent event) {
            Browser browser = (Browser) event.widget;
            back.setEnabled(browser.isBackEnabled());
            forward.setEnabled(browser.isForwardEnabled());
          }

          public void changing(LocationEvent event) {}
        };

    browser = new Browser(sbody, SWT.NONE);
    GridData data = new GridData(GridData.FILL_BOTH);
    browser.setLayoutData(data);
    IWorkbenchHelpSystem helpSystem = PlatformUI.getWorkbench().getHelpSystem();
    URL url = helpSystem.resolve("org.fusesource.ide.help/index.html", true);
    browser.setUrl(url.toExternalForm());
    browser.addLocationListener(locationListener);

    // section.pack();
    // form.pack();
    form.layout(true, true);
    parent.layout(true, true);

    // in case of timing issues, lets do another layout just in case...
    Display.getCurrent()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                if (form != null && !form.isDisposed()) {
                  form.layout(true, true);
                }
                if (parent != null && !parent.isDisposed()) {
                  parent.layout(true, true);
                }
              }
            });
  }