Ejemplo n.º 1
0
 @Override
 public void dispose() {
   disposeScheduleAction();
   if (headerImage != null) {
     headerImage.dispose();
   }
   if (editorBusyIndicator != null) {
     editorBusyIndicator.stop();
   }
   if (activateAction != null) {
     activateAction.dispose();
   }
   if (menuService != null) {
     if (leftToolBarManager != null) {
       menuService.releaseContributions(leftToolBarManager);
     }
     if (toolBarManager instanceof ContributionManager) {
       menuService.releaseContributions((ContributionManager) toolBarManager);
     }
   }
   if (textSupport != null) {
     textSupport.dispose();
   }
   if (messageHyperLinkListener instanceof IDisposable) {
     ((IDisposable) messageHyperLinkListener).dispose();
   }
   super.dispose();
 }
Ejemplo n.º 2
0
  @Override
  protected Composite createPageContainer(Composite parent) {
    this.editorParent = parent;
    Composite composite = super.createPageContainer(parent);

    EditorUtil.initializeScrollbars(getHeaderForm().getForm());

    // create left tool bar that replaces form heading label
    try {
      FormHeading heading = (FormHeading) getHeaderForm().getForm().getForm().getHead();

      Field field = FormHeading.class.getDeclaredField("titleRegion"); // $NON-NLS-1$
      field.setAccessible(true);

      TitleRegion titleRegion = (TitleRegion) field.get(heading);

      leftToolBarManager = new ToolBarManager(SWT.FLAT);
      leftToolBar = leftToolBarManager.createControl(titleRegion);
      leftToolBar.addControlListener(
          new ControlAdapter() {
            private boolean ignoreResizeEvents;

            @Override
            public void controlResized(ControlEvent e) {
              if (ignoreResizeEvents) {
                return;
              }
              ignoreResizeEvents = true;
              try {
                // the tool bar contents has changed, update state
                updateHeaderImage();
                updateHeaderLabel();
              } finally {
                ignoreResizeEvents = false;
              }
            }
          });

      // titleLabel = new Label(titleRegion, SWT.NONE);
      // need a viewer for copy support
      TextViewer titleViewer = new TextViewer(titleRegion, SWT.READ_ONLY);
      // Eclipse 3.3 needs a document, otherwise an NPE is thrown
      titleViewer.setDocument(new Document());

      titleLabel = titleViewer.getTextWidget();
      titleLabel.setForeground(heading.getForeground());
      titleLabel.setFont(heading.getFont());
      // XXX work-around problem that causes field to maintain selection when unfocused
      titleLabel.addFocusListener(
          new FocusAdapter() {
            @Override
            public void focusLost(FocusEvent e) {
              titleLabel.setSelection(0);
            }
          });

      titleRegion.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlResized(ControlEvent e) {
              // do not create busyLabel to avoid recursion
              updateSizeAndLocations();
            }
          });

      IHandlerService handlerService =
          (IHandlerService) getSite().getService(IHandlerService.class);
      if (handlerService != null) {
        textSupport = new CommonTextSupport(handlerService);
        textSupport.install(titleViewer, false);
      }
    } catch (Exception e) {
      if (!toolBarFailureLogged) {
        StatusHandler.log(
            new Status(
                IStatus.ERROR,
                TasksUiPlugin.ID_PLUGIN,
                "Failed to obtain busy label toolbar",
                e)); //$NON-NLS-1$
      }
      if (titleLabel != null) {
        titleLabel.dispose();
        titleLabel = null;
      }
      if (leftToolBar != null) {
        leftToolBar.dispose();
        leftToolBar = null;
      }
      if (leftToolBarManager != null) {
        leftToolBarManager.dispose();
        leftToolBarManager = null;
      }
    }

    updateHeader();

    return composite;
  }