コード例 #1
0
ファイル: DetailsSection.java プロジェクト: niwashun/fuseide
  @Override
  protected synchronized void onNodeChanged(AbstractNode node) {
    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.propertiesDetailsTitle);
    toolkit.decorateFormHeading(form);

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

    Composite sbody = form.getBody();

    if (node != null) {
      final IMessageManager mmng = form.getMessageManager();

      form.setText(node.getPatternName());

      IPropertyDescriptor idDescriptor = null;
      IPropertyDescriptor descriptionDescriptor = null;

      IPropertyDescriptor[] propertyDescriptors = node.getPropertyDescriptors();

      for (int i = 0; i < 2; i++) {
        for (IPropertyDescriptor descriptor : propertyDescriptors) {
          final Object id = descriptor.getId();
          if ("AbstractNode.Id".equals(id)) {
            idDescriptor = descriptor;
          } else if (NODE_DESCRIPTION.equals(id)) {
            descriptionDescriptor = descriptor;
          } else {
            String propertyName = getPropertyName(id);
            boolean mandatory =
                descriptor instanceof ExpressionPropertyDescriptor
                    || isMandatory(node, propertyName);
            if ((mandatory && i == 0) || (!mandatory && i == 1)) {
              createDecoratedTextField(descriptor, toolkit, sbody, mmng);
            }
          }
        }
      }

      if (idDescriptor != null || descriptionDescriptor != null) {
        if (idDescriptor != null) {
          createDecoratedTextField(idDescriptor, toolkit, sbody, mmng);
        }
        if (descriptionDescriptor != null) {
          createDecoratedTextField(descriptionDescriptor, toolkit, sbody, mmng);
        }
      }

      // ref ECLIPSE-1012: unsaved nodes may be disposed
      // mmng.update();
    } else {
      form.setText(EditorMessages.propertiesDetailsTitle);
    }

    layoutForm();
  }
コード例 #2
0
  /*
   * (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);
                }
              }
            });
  }