Exemplo n.º 1
0
 /** Creates the actions and action groups for this view. */
 protected void createActions() {
   fGotoInputAction = new GotoInputAction(this);
   fGotoInputAction.setEnabled(false);
   fCopyToClipboardAction = new CopyToClipboardAction(getViewSite());
   ISelectionProvider provider = getSelectionProvider();
   if (provider != null) provider.addSelectionChangedListener(fCopyToClipboardAction);
 }
  /**
   * Creates a new <code>ImplementorsSearchGroup</code>. The group requires that the selection
   * provided by the given selection provider is of type {@link IStructuredSelection}.
   *
   * @param site the site that will own the action group.
   * @param specialSelectionProvider the selection provider used instead of the sites selection
   *     provider.
   * @since 3.4
   */
  public ImplementorsSearchGroup(IWorkbenchSite site, ISelectionProvider specialSelectionProvider) {
    fSite = site;
    fGroupId = IContextMenuConstants.GROUP_SEARCH;

    fFindImplementorsAction = new FindImplementorsAction(site);
    fFindImplementorsAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENTORS_IN_WORKSPACE);

    fFindImplementorsInProjectAction = new FindImplementorsInProjectAction(site);
    fFindImplementorsInProjectAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENTORS_IN_PROJECT);

    fFindImplementorsInWorkingSetAction = new FindImplementorsInWorkingSetAction(site);
    fFindImplementorsInWorkingSetAction.setActionDefinitionId(
        IJavaEditorActionDefinitionIds.SEARCH_IMPLEMENTORS_IN_WORKING_SET);

    // register the actions as selection listeners
    ISelectionProvider provider =
        specialSelectionProvider == null ? fSite.getSelectionProvider() : specialSelectionProvider;
    ISelection selection = provider.getSelection();
    registerAction(fFindImplementorsAction, provider, selection, specialSelectionProvider);
    registerAction(fFindImplementorsInProjectAction, provider, selection, specialSelectionProvider);
    registerAction(
        fFindImplementorsInWorkingSetAction, provider, selection, specialSelectionProvider);
  }
Exemplo n.º 3
0
 @Override
 public final void run() {
   if (saveRequired) {
     EclipseObjects.getActivePage().saveAllEditors(true);
     if (EclipseObjects.getActivePage().getDirtyEditors().length != 0) {
       return;
     }
   }
   if (fEditor != null) {
     ISelectionProvider provider = fEditor.getSelectionProvider();
     if (provider != null) {
       ISelection s = provider.getSelection();
       if (s instanceof ITextSelection) {
         IWorkingCopy wc =
             CUIPlugin.getDefault()
                 .getWorkingCopyManager()
                 .getWorkingCopy(fEditor.getEditorInput());
         if (wc != null) run(fEditor.getSite(), wc, (ITextSelection) s);
       }
     }
   } else if (fSite != null) {
     if (fElement != null) {
       run(fSite, fElement);
     }
   }
 }
Exemplo n.º 4
0
 private void initialize(ISelectionProvider provider) {
   ISelection selection = provider.getSelection();
   fOpen.update(selection);
   if (!fIsEditorOwner) {
     provider.addSelectionChangedListener(fOpen);
   }
 }
Exemplo n.º 5
0
 public static @Nullable ISelection getActiveSelection(@Nullable IWorkbenchSite site) {
   try {
     if (site == null) {
       return null;
     }
     IWorkbenchWindow workbenchWindow = site.getWorkbenchWindow();
     if (workbenchWindow == null) {
       return null;
     }
     IWorkbenchPage activePage = workbenchWindow.getActivePage();
     if (activePage == null) {
       return null;
     }
     IEditorPart activeEditor = activePage.getActiveEditor();
     if (activeEditor == null) {
       return null;
     }
     IEditorSite editorSite = activeEditor.getEditorSite();
     if (editorSite == null) {
       return null;
     }
     ISelectionProvider selectionProvider = editorSite.getSelectionProvider();
     if (selectionProvider == null) {
       return null;
     }
     return selectionProvider.getSelection();
   } catch (Exception e) {
     return null;
   }
 }
  /**
   * Asserts that when a selection is set on the viewer:
   *
   * <ul>
   *   <li>the selection is available in the observable
   *   <li>Value change events are fired with appropriate diff values
   * </ul>
   */
  public void testGetSetValue() {
    SelectionProviderSingleSelectionObservableValue observable =
        new SelectionProviderSingleSelectionObservableValue(
            SWTObservables.getRealm(Display.getDefault()), selectionProvider);
    ValueChangeEventTracker listener = new ValueChangeEventTracker();
    observable.addValueChangeListener(listener);
    assertNull(observable.getValue());

    selectionProvider.setSelection(new StructuredSelection(model[0]));
    assertEquals(1, listener.count);
    assertNull(listener.event.diff.getOldValue());
    assertEquals(model[0], listener.event.diff.getNewValue());
    assertEquals(observable, listener.event.getObservableValue());
    assertEquals(model[0], observable.getValue());

    selectionProvider.setSelection(new StructuredSelection(model[1]));
    assertEquals(2, listener.count);
    assertEquals(model[0], listener.event.diff.getOldValue());
    assertEquals(model[1], listener.event.diff.getNewValue());
    assertEquals(observable, listener.event.getObservableValue());
    assertEquals(model[1], observable.getValue());

    selectionProvider.setSelection(StructuredSelection.EMPTY);
    assertEquals(3, listener.count);
    assertEquals(model[1], listener.event.diff.getOldValue());
    assertNull(listener.event.diff.getNewValue());
    assertEquals(observable, listener.event.getObservableValue());
    assertEquals(null, observable.getValue());
  }
Exemplo n.º 7
0
  protected void installOccurrencesFinder(final boolean forceUpdate) {
    fMarkOccurrenceAnnotations = true;

    fPostSelectionListener =
        new ISelectionChangedListener() {

          @Override
          public void selectionChanged(final SelectionChangedEvent event) {
            final ISelection selection = event.getSelection();
            erlangEditor.markOccurencesHandler.updateOccurrenceAnnotations(
                (ITextSelection) selection, erlangEditor.getModule());
          }
        };
    final ISelectionProvider selectionProvider = erlangEditor.getSelectionProvider();
    if (selectionProvider != null) {
      ((IPostSelectionProvider) selectionProvider)
          .addPostSelectionChangedListener(fPostSelectionListener);

      if (forceUpdate) {
        fForcedMarkOccurrencesSelection = selectionProvider.getSelection();
        final IErlModule module = erlangEditor.getModule();
        if (module != null) {
          erlangEditor.markOccurencesHandler.updateOccurrenceAnnotations(
              (ITextSelection) fForcedMarkOccurrencesSelection, module);
        }
      }
    }
    if (fOccurrencesFinderJobCanceler == null) {
      fOccurrencesFinderJobCanceler = new OccurrencesFinderJobCanceler();
      fOccurrencesFinderJobCanceler.install();
    }
  }
  @Override
  public boolean isEnabled() {

    // Check if we are closing down
    IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
      return false;
    }

    // Get the selection
    IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
    IWorkbenchPart part = page.getActivePart();
    if (part == null) {
      return false;
    }
    ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
    if (selectionProvider == null) {
      return false;
    }
    ISelection selection = selectionProvider.getSelection();

    // Make sure there is only one selection and that it is an experiment
    fExperiment = null;
    if (selection instanceof TreeSelection) {
      TreeSelection sel = (TreeSelection) selection;
      // There should be only one item selected as per the plugin.xml
      Object element = sel.getFirstElement();
      if (element instanceof TmfExperimentElement) {
        fExperiment = (TmfExperimentElement) element;
      }
    }

    return (fExperiment != null);
  }
Exemplo n.º 9
0
  /** Selects and reveals the given offset and length in the given editor part. */
  public static void revealInEditor(IEditorPart editor, final int offset, final int length) {
    if (editor instanceof ITextEditor) {
      ((ITextEditor) editor).selectAndReveal(offset, length);
      return;
    }

    // Support for non-text editor - try IGotoMarker interface
    if (editor instanceof IGotoMarker) {
      final IEditorInput input = editor.getEditorInput();
      if (input instanceof IFileEditorInput) {
        final IGotoMarker gotoMarkerTarget = (IGotoMarker) editor;
        WorkspaceModifyOperation op =
            new WorkspaceModifyOperation() {
              @Override
              protected void execute(IProgressMonitor monitor) throws CoreException {
                IMarker marker = null;
                try {
                  marker = ((IFileEditorInput) input).getFile().createMarker(IMarker.TEXT);
                  marker.setAttribute(IMarker.CHAR_START, offset);
                  marker.setAttribute(IMarker.CHAR_END, offset + length);

                  gotoMarkerTarget.gotoMarker(marker);

                } finally {
                  if (marker != null) {
                    marker.delete();
                  }
                }
              }
            };

        try {
          op.run(null);
        } catch (InvocationTargetException ex) {
          // reveal failed
        } catch (InterruptedException e) {
          Assert.isTrue(false, "this operation can not be canceled"); // $NON-NLS-1$
        }
      }
      return;
    }

    /*
     * Workaround: send out a text selection XXX: Needs to be improved, see
     * https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
     */
    if (editor != null && editor.getEditorSite().getSelectionProvider() != null) {
      IEditorSite site = editor.getEditorSite();
      if (site == null) {
        return;
      }

      ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
      if (provider == null) {
        return;
      }

      provider.setSelection(new TextSelection(offset, length));
    }
  }
  private static ITextSelection getTextSelection(JavaEditor editor) {
    ISelectionProvider selectionProvider = editor.getSelectionProvider();
    if (selectionProvider == null) return null;

    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof ITextSelection)) return null;

    return (ITextSelection) selection;
  }
Exemplo n.º 11
0
 /*
  * @see ActionGroup#dispose()
  */
 @Override
 public void dispose() {
   fSelectionProvider.removeSelectionChangedListener(fOpenImplementation);
   fSelectionProvider.removeSelectionChangedListener(fOpenSuperImplementation);
   fSelectionProvider.removeSelectionChangedListener(fOpenAttachedJavadoc);
   fSelectionProvider.removeSelectionChangedListener(fOpenTypeHierarchy);
   fSelectionProvider.removeSelectionChangedListener(fOpenCallHierarchy);
   super.dispose();
 }
 @Override
 public void dispose() {
   fFilterActionGroup.dispose();
   fShowActionGroup.dispose();
   fChangeListener = null;
   ISelectionProvider selectionProvider = fSite.getSelectionProvider();
   selectionProvider.removeSelectionChangedListener(fWorkingSetAssignementAction);
   super.dispose();
 }
  void setSelectionFromEditor(IWorkbenchPart part) {
    if (!fProcessSelectionEvents
        || !linkBrowsingViewSelectionToEditor()
        || !(part instanceof IEditorPart)) return;

    IWorkbenchPartSite site = part.getSite();
    if (site == null) return;
    ISelectionProvider provider = site.getSelectionProvider();
    if (provider != null) setSelectionFromEditor(part, provider.getSelection());
  }
Exemplo n.º 14
0
 /**
  * The <code>CompositeEditorSite</code> implementation of this <code>IWorkbenchPartSite</code>
  * method remembers the selection provider, and also hooks a listener on it, which calls <code>
  * handleSelectionChanged</code> when a selection changed event occurs.
  *
  * @see #handleSelectionChanged
  */
 public void setSelectionProvider(ISelectionProvider provider) {
   ISelectionProvider oldSelectionProvider = selectionProvider;
   selectionProvider = provider;
   if (oldSelectionProvider != null) {
     oldSelectionProvider.removeSelectionChangedListener(getSelectionChangedListener());
   }
   if (selectionProvider != null) {
     selectionProvider.addSelectionChangedListener(getSelectionChangedListener());
   }
 }
Exemplo n.º 15
0
 /** {@inheritDoc} */
 public void dispose() {
   if (fActions != null) {
     final ISelectionProvider provider = fSite.getSelectionProvider();
     for (Iterator iter = fActions.iterator(); iter.hasNext(); ) {
       Action action = (Action) iter.next();
       if (action instanceof ISelectionChangedListener)
         provider.removeSelectionChangedListener((ISelectionChangedListener) action);
     }
   }
   fActions = null;
   super.dispose();
 }
  /*
   * (non-Javadoc)
   *
   * @see org.eclipse.ui.ISelectionService#getSelection()
   */
  public ISelection getSelection() {
    if (activePart != null) {
      // get the selection from the active part
      ISelectionProvider selectionProvider = activePart.getSite().getSelectionProvider();
      return selectionProvider == null ? null : selectionProvider.getSelection();
    }

    Object selection = selectionService.getSelection();
    if (selection == null || selection instanceof ISelection) {
      return (ISelection) selection;
    }
    return new StructuredSelection(selection);
  }
 /**
  * Returns the text selection of the current editor. <code>null</code> is returned when the
  * current editor does not have focus or does not return a text selection.
  *
  * @return Returns the text selection of the current editor or <code>null</code>.
  * @since 3.0
  */
 protected ITextSelection getCurrentTextSelection() {
   IWorkbenchPart part = JavaPlugin.getActivePage().getActivePart();
   if (part instanceof IEditorPart) {
     ISelectionProvider selectionProvider = part.getSite().getSelectionProvider();
     if (selectionProvider != null) {
       ISelection selection = selectionProvider.getSelection();
       if (selection instanceof ITextSelection) {
         return (ITextSelection) selection;
       }
     }
   }
   return null;
 }
  private GenerateBuildPathActionGroup(IWorkbenchSite site) {
    fSite = site;
    fActions = new ArrayList();

    final CreateLinkedSourceFolderAction addLinkedSourceFolderAction =
        new CreateLinkedSourceFolderAction();
    fActions.add(addLinkedSourceFolderAction);

    final CreateLocalSourceFolderAction addSourceFolderAction = new CreateLocalSourceFolderAction();
    fActions.add(addSourceFolderAction);

    final AddFolderToBuildpathAction addFolder = new AddFolderToBuildpathAction(site);
    fActions.add(addFolder);

    final AddSelectedLibraryToBuildpathAction addSelectedLibrary =
        new AddSelectedLibraryToBuildpathAction(site);
    fActions.add(addSelectedLibrary);

    final RemoveFromBuildpathAction remove = new RemoveFromBuildpathAction(site);
    fActions.add(remove);

    final AddArchiveToBuildpathAction addArchive = new AddArchiveToBuildpathAction(site);
    fActions.add(addArchive);

    final AddLibraryToBuildpathAction addLibrary = new AddLibraryToBuildpathAction(site);
    fActions.add(addLibrary);

    if (DLTKCore.DEBUG) {
      System.err.println("Add Update Zip Action here..."); // $NON-NLS-1$
    }

    final ExcludeFromBuildpathAction exclude = new ExcludeFromBuildpathAction(site);
    fActions.add(exclude);

    final IncludeToBuildpathAction include = new IncludeToBuildpathAction(site);
    fActions.add(include);

    final EditFilterAction editFilterAction = new EditFilterAction();
    fActions.add(editFilterAction);

    final ConfigureBuildPathAction configure = new ConfigureBuildPathAction(site);
    fActions.add(configure);

    final ISelectionProvider provider = fSite.getSelectionProvider();
    for (Iterator iter = fActions.iterator(); iter.hasNext(); ) {
      Action action = (Action) iter.next();
      if (action instanceof ISelectionChangedListener) {
        provider.addSelectionChangedListener((ISelectionChangedListener) action);
      }
    }
  }
  /** Refreshes the local resources that are selected in the view. */
  private void refreshLocal() {
    final ISelectionProvider selectionProvider = fView.getSite().getSelectionProvider();
    if (selectionProvider == null) return;

    ISelection selection = selectionProvider.getSelection();
    if (!(selection instanceof IStructuredSelection)) return;

    RefreshAction refreshAction = new RefreshAction(fView.getSite());
    if (selection.isEmpty()) refreshAction.refreshAll();
    else {
      refreshAction.selectionChanged((IStructuredSelection) selection);
      refreshAction.run();
    }
  }
Exemplo n.º 20
0
 /**
  * Returns the <code>ShowInContext</code> to show in the selected target, or <code>null</code> if
  * there is no valid context to show.
  *
  * <p>This implementation obtains the context from the <code>IShowInSource</code> of the source
  * part (if provided), or, if the source part is an editor, it creates the context from the
  * editor's input and selection.
  *
  * <p>Subclasses may extend or reimplement.
  *
  * @return the <code>ShowInContext</code> to show or <code>null</code>
  */
 private ShowInContext getContext(IWorkbenchPart sourcePart) {
   IShowInSource source = getShowInSource(sourcePart);
   if (source != null) {
     ShowInContext context = source.getShowInContext();
     if (context != null) {
       return context;
     }
   } else if (sourcePart instanceof IEditorPart) {
     Object input = ((IEditorPart) sourcePart).getEditorInput();
     ISelectionProvider sp = sourcePart.getSite().getSelectionProvider();
     ISelection sel = sp == null ? null : sp.getSelection();
     return new ShowInContext(input, sel);
   }
   return null;
 }
Exemplo n.º 21
0
  /** {@inheritDoc} */
  @Override
  public void createPartControl(Composite parent, FormToolkit toolkit) {
    sashForm = new SashForm(parent, sashFormStyle);
    sashForm.setLayout(new GridLayout(1, false));

    List<ISubView> subViews = getSubViews();

    for (final ISubView subView : subViews) {
      subView.createPartControl(sashForm, toolkit);
      subView.getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
      subView
          .getControl()
          .addFocusListener(
              new FocusAdapter() {
                /** {@inheritDoc} */
                @Override
                public void focusGained(FocusEvent e) {
                  getRootEditor().setActiveSubView(subView);
                }
              });

      if (null != subView.getSelectionProvider()) {
        ISelectionProvider prov = subView.getSelectionProvider();
        prov.addSelectionChangedListener(
            new ISelectionChangedListener() {
              @Override
              public void selectionChanged(SelectionChangedEvent event) {
                getRootEditor().setSelection(event.getSelection());
              }
            });
        prov.addSelectionChangedListener(getRootEditor().getSelectionChangedListener());
        if (prov instanceof IPostSelectionProvider) {
          ((IPostSelectionProvider) prov)
              .addPostSelectionChangedListener(getRootEditor().getPostSelectionChangedListener());
        }
      }
    }

    if (!weightMapping.isEmpty()) {
      int[] weights = new int[subViews.size()];
      for (int i = 0; i < subViews.size(); i++) {
        if (weightMapping.containsKey(subViews.get(i))) {
          weights[i] = weightMapping.get(subViews.get(i));
        }
      }
      sashForm.setWeights(weights);
    }
  }
Exemplo n.º 22
0
 public CopyHandler(ViewSettings settings, Display display, ISelectionProvider selectionSource) {
   this.settings = settings;
   this.converter = new CellTextConverter(settings);
   this.display = display;
   this.selectionSource = selectionSource;
   selectionSource.addSelectionChangedListener(this);
 }
 /**
  * Create a new ViewerContribution.
  *
  * @param selProvider the selection provider
  */
 public ViewerContribution(ISelectionProvider selProvider) {
   super();
   this.selProvider = selProvider;
   if (selProvider != null) {
     selProvider.addSelectionChangedListener(this);
   }
 }
  /*
   * @see org.eclipse.swt.dnd.DragSourceListener#dragStart
   */
  @Override
  public void dragStart(DragSourceEvent event) {
    fEditorInputDatas = new ArrayList<EditorInputData>();

    ISelection selection = fProvider.getSelection();
    if (selection instanceof IStructuredSelection) {
      IStructuredSelection structuredSelection = (IStructuredSelection) selection;
      for (Iterator<?> iter = structuredSelection.iterator(); iter.hasNext(); ) {
        Object element = iter.next();
        IEditorInput editorInput = EditorUtility.getEditorInput(element);
        if (editorInput != null && editorInput.getPersistable() != null) {
          try {
            String editorId = EditorUtility.getEditorID(editorInput);
            // see org.eclipse.ui.internal.ide.EditorAreaDropAdapter.openNonExternalEditor(..):
            IEditorRegistry editorReg = PlatformUI.getWorkbench().getEditorRegistry();
            IEditorDescriptor editorDesc = editorReg.findEditor(editorId);
            if (editorDesc != null && !editorDesc.isOpenExternal()) {
              fEditorInputDatas.add(
                  EditorInputTransfer.createEditorInputData(editorId, editorInput));
            }
          } catch (PartInitException e) {
            JavaPlugin.log(e);
          }
        }
      }
    }

    event.doit = fEditorInputDatas.size() > 0;
  }
  public void dragSetData(DragSourceEvent event) {
    IStructuredSelection selection = (IStructuredSelection) provider.getSelection();
    Iterator<?> iterator = selection.iterator();

    if (PluginTransfer.getInstance().isSupportedType(event.dataType)) {
      try {
        List<Reachable> objectURIs = new ArrayList<Reachable>();
        while (iterator.hasNext()) {
          Object next = iterator.next();
          ReachableObject fromObject;
          try {
            fromObject = manager.getHandlerFromObject(next).getFromObject(next);
            if (fromObject.getReachable() != null) {
              objectURIs.add(fromObject.getReachable());
            }
          } catch (IReachableHandlerException e) {
            e.printStackTrace();
          }
        }
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        ObjectOutputStream buffered;
        buffered = new ObjectOutputStream(bos);
        buffered.writeObject(objectURIs.toArray());
        byte[] data = bos.toByteArray();
        bos.close();
        buffered.close();

        event.data = new PluginTransferData(PLUGIN_TRANSFER_ACTION_ID, data);
      } catch (IOException e) {
        e.printStackTrace();
      }
    }
  }
Exemplo n.º 26
0
 public void setSelectionProvider(ISelectionProvider selectionProvider) {
   if (this.selectionProvider != null) {
     this.selectionProvider.removeSelectionChangedListener(this);
   }
   this.selectionProvider = selectionProvider;
   selectionProvider.addSelectionChangedListener(this);
 }
Exemplo n.º 27
0
 /*
  * (non-Javadoc) Method declared in ActionGroup
  */
 @Override
 public void dispose() {
   if (fRegisteredSelectionListeners != null) {
     ISelectionProvider provider = fSite.getSelectionProvider();
     for (Iterator<ISelectionChangedListener> iter = fRegisteredSelectionListeners.iterator();
         iter.hasNext(); ) {
       ISelectionChangedListener listener = iter.next();
       provider.removeSelectionChangedListener(listener);
     }
   }
   if (fQuickAccessHandlerActivation != null && fHandlerService != null) {
     fHandlerService.deactivateHandler(fQuickAccessHandlerActivation);
   }
   fEditor = null;
   //    fCleanUp.dispose();
   super.dispose();
 }
Exemplo n.º 28
0
 private void registerSelectionListener(
     ISelectionProvider provider, ISelectionChangedListener listener) {
   if (fRegisteredSelectionListeners == null) {
     fRegisteredSelectionListeners = new ArrayList<ISelectionChangedListener>(20);
   }
   provider.addSelectionChangedListener(listener);
   fRegisteredSelectionListeners.add(listener);
 }
 @Override
 public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
   if (!(receiver instanceof SQLEditorBase)) {
     return false;
   }
   SQLEditor editor = (SQLEditor) receiver;
   final Control editorControl = editor.getEditorControl();
   if (editorControl == null) {
     return false;
   }
   boolean isFocused = editorControl.isFocusControl();
   boolean isConnected =
       editor.getDataSourceContainer() != null && editor.getDataSourceContainer().isConnected();
   switch (property) {
     case PROP_CAN_EXECUTE:
       return isConnected
           && isFocused
           && (!"statement".equals(expectedValue) || editor.hasActiveQuery());
     case PROP_CAN_EXPLAIN:
       return isConnected
           && isFocused
           && editor.hasActiveQuery()
           && DBUtils.getAdapter(DBCQueryPlanner.class, editor.getDataSource()) != null;
     case PROP_CAN_NAVIGATE:
       {
         // Check whether some word is under cursor
         ISelectionProvider selectionProvider = editor.getSelectionProvider();
         if (selectionProvider == null) {
           return false;
         }
         ITextSelection selection = (ITextSelection) selectionProvider.getSelection();
         Document document = editor.getDocument();
         return selection != null
             && document != null
             && !new SQLIdentifierDetector(
                     editor.getSyntaxManager().getStructSeparator(),
                     editor.getSyntaxManager().getQuoteSymbol())
                 .detectIdentifier(
                     document, new Region(selection.getOffset(), selection.getLength()))
                 .isEmpty();
       }
     case PROP_CAN_EXPORT:
       return isConnected && editor.hasActiveQuery();
   }
   return false;
 }
 @Override
 public void dispose() {
   if (provider != null) {
     provider.removeSelectionChangedListener(openExternalDartdocAction);
   }
   openExternalDartdocAction = null;
   super.dispose();
 }