@Override
  public void build() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    workbenchWindow.addPerspectiveListener(perspectiveAdapter);

    IPerspectiveDescriptor[] descriptors = load();
    for (int i = 0; i < descriptors.length; i++) {
      createPerspectiveButton(descriptors[i]);
    }

    // Button for the perspective dialog
    Composite otherBg = new Composite(background, SWT.NONE);
    otherBg.setLayout(new FormLayout());
    otherButton = new Button(otherBg, SWT.PUSH | SWT.FLAT);
    FormData fdOther = new FormData();
    otherButton.setLayoutData(fdOther);
    fdOther.left = new FormAttachment(0, left.getBounds().width);
    FormData buttonPos = getLayoutSet().getPosition(ILayoutSetConstants.PERSP_BUTTON_POS);
    fdOther.top = buttonPos.top;
    otherButton.setData(RWT.CUSTOM_VARIANT, "perspective"); // $NON-NLS-1$
    otherButton.setText(Messages.get().PerspectiveSwitcherBuilder_Other);
    IWorkbenchWindow activeWindow = workbench.getActiveWorkbenchWindow();
    final IWorkbenchAction perspectiveAction =
        ActionFactory.OPEN_PERSPECTIVE_DIALOG.create(activeWindow);
    otherButton.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            perspectiveAction.run();
          }
        });
  }
  public void build() {
    IWorkbench workbench = PlatformUI.getWorkbench();
    IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
    workbenchWindow.addPerspectiveListener(perspectiveAdapter);

    IPerspectiveDescriptor[] descriptors = load();
    for (int i = 0; i < descriptors.length; i++) {
      createPerspectiveButton(descriptors[i]);
    }
  }
  /**
   * Adds the new wizards to the current perspective displayed in <code>activeWorkbenchWindow</code>
   * , if they've not been added already. Adds listeners on the window so that the same is done
   * whenever the user switches perspectives in the window.
   *
   * <p>Note: This method can only be called once the workbench has been started.
   */
  private void maybeAddNewWizardActionsToWindow(IWorkbenchWindow activeWorkbenchWindow) {
    if (activeWorkbenchWindow == null) {
      return;
    }

    activeWorkbenchWindow.addPerspectiveListener(perspectiveListener);

    WorkbenchPage activePage = (WorkbenchPage) activeWorkbenchWindow.getActivePage();
    if (activePage == null) {
      return;
    }

    IPerspectiveDescriptor perspectiveDesc = activePage.getPerspective();
    maybeAddNewWizardActionsToPerspective(activePage, perspectiveDesc);
  }
 public SafiDBPerspective() {
   super();
   IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
   window.addPerspectiveListener(this);
   // AsteriskDiagramEditorPlugin.getInstance().setDBPerspective(this);
 }