示例#1
0
  private BusyIndicator getBusyLabel() {
    if (busyLabel != null) {
      return busyLabel;
    }
    try {
      FormHeading heading = (FormHeading) getHeaderForm().getForm().getForm().getHead();
      // ensure that busy label exists
      heading.setBusy(true);
      heading.setBusy(false);

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

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

      for (Control child : titleRegion.getChildren()) {
        if (child instanceof BusyIndicator) {
          busyLabel = (BusyIndicator) child;
        }
      }
      if (busyLabel == null) {
        return null;
      }
      busyLabel.addControlListener(
          new ControlAdapter() {
            @Override
            public void controlMoved(ControlEvent e) {
              updateSizeAndLocations();
            }
          });
      // the busy label may get disposed if it has no image
      busyLabel.addDisposeListener(
          new DisposeListener() {
            public void widgetDisposed(DisposeEvent e) {
              busyLabel.setMenu(null);
              busyLabel = null;
            }
          });

      if (leftToolBar != null) {
        leftToolBar.moveAbove(busyLabel);
      }
      if (titleLabel != null) {
        titleLabel.moveAbove(busyLabel);
      }

      updateSizeAndLocations();

      return busyLabel;
    } catch (Exception e) {
      if (!toolBarFailureLogged) {
        StatusHandler.log(
            new Status(
                IStatus.ERROR,
                TasksUiPlugin.ID_PLUGIN,
                "Failed to obtain busy label toolbar",
                e)); //$NON-NLS-1$
      }
      busyLabel = null;
    }
    return busyLabel;
  }