@Override
  public void dispose() {
    getSite().getPage().removePartListener(fPartListener);

    Enumeration<IMemoryViewPane> enumeration = fViewPanes.elements();
    while (enumeration.hasMoreElements()) {
      Object element = enumeration.nextElement();
      if (element instanceof IMemoryViewPane) {
        ((IMemoryViewPane) element).dispose();
      }
    }

    fViewPaneControls.clear();

    IViewSite viewSite = getViewSite();
    String secondaryId = viewSite.getSecondaryId();
    if (secondaryId != null) MemoryViewIdRegistry.deregisterView(secondaryId);

    fSyncService.shutdown();

    if (fAddHandler != null) fAddHandler.dispose();

    if (fToggleMonitorsHandler != null) fToggleMonitorsHandler.dispose();

    if (fNextMemoryBlockHandler != null) fNextMemoryBlockHandler.dispose();

    super.dispose();
  }
  /*
   * (non-Javadoc)
   * @see org.eclipse.core.commands.AbstractHandler
   * #setEnabled(java.lang.Object)
   */
  @Override
  public void setEnabled(Object evaluationContext) {

    this.resourcesToDelete.clear();

    // Check the target view
    IWorkbenchPart part = null;
    try {
      part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart();
    } catch (Exception e) {
      // nothing
    }

    if (part == null
        || !PetalsConstants.PETALS_PROJECT_EXPLORER_VIEW_ID.equals(part.getSite().getId())) {
      super.setBaseEnabled(false);
      return;
    }

    // Check the selection
    ISelection s = null;
    try {
      s = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getSelection();
    } catch (Exception e1) {
      // nothing
    }

    if (s == null || s.isEmpty() || !(s instanceof IStructuredSelection)) {
      super.setBaseEnabled(false);
      return;
    }

    // The selection must either contain only project, or non-projects
    boolean haveProject = false;
    boolean haveOthers = false;
    for (Iterator<?> it = ((IStructuredSelection) s).iterator(); it.hasNext(); ) {
      Object o = it.next();
      IResource res = (IResource) PlatformUtils.getAdapter(o, IResource.class);

      if (res != null) {
        this.resourcesToDelete.add(res);
        if (res instanceof IProject) haveProject = true;
        else haveOthers = true;
      }
    }

    super.setBaseEnabled(haveOthers != haveProject);
  }
  @Override
  public void setEnabled(final Object evaluationContext) {

    super.setEnabled(evaluationContext);

    if (_isAppPhotoFilterInitialized == false) {

      _isAppPhotoFilterInitialized = true;

      /*
       * initialize app photo filter, this is a hack because the whole app startup should be
       * sometimes be streamlined, it's more and more confusing
       */
      final Command command =
          ((ICommandService)
                  PlatformUI //
                      .getWorkbench()
                      .getService(ICommandService.class)) //
              .getCommand(ActionHandlerPhotoFilter.COMMAND_ID);

      final State state = command.getState(RegistryToggleState.STATE_ID);
      final Boolean isPhotoFilterActive = (Boolean) state.getValue();

      TourbookPlugin.setActivePhotoFilter(isPhotoFilterActive);
    }
  }
예제 #4
0
  @Override
  public final void addHandlerListener(final IHandlerListener handlerListener) {
    if (!hasListeners()) {
      attachListener();
    }

    super.addHandlerListener(handlerListener);
  }
예제 #5
0
  @Override
  public final void removeHandlerListener(final IHandlerListener handlerListener) {
    super.removeHandlerListener(handlerListener);

    if (!hasListeners()) {
      detachListener();
    }
  }
  /** We have to dispose the windows shown on our Editor */
  @Override
  public void dispose() {
    super.dispose();
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            if (window != null) {
              window.dispose();
            }
          }
        });

    Display.getDefault()
        .asyncExec(
            new Runnable() {
              @Override
              public void run() {
                if (wndFind != null) {
                  wndFind.close();
                }
              }
            });

    IWorkbenchWindow wind = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (wind == null) {
      return;
    }
    IEditorReference[] editors =
        wind.getActivePage().findEditors(null, GraphEditor.ID, IWorkbenchPage.MATCH_ID);
    if (editors != null && editors.length == 0 && satView != null) {
      satView.setEditor(null);
      satView.clear();
    }

    for (AbstractHandler hnd : handlers) {
      hnd.dispose();
    }
  }
예제 #7
0
 @Override
 public void dispose() {
   super.dispose();
   if (clipboard != null) clipboard.dispose();
 }