/**
  * Creates a new content provider for Java elements.
  *
  * @param provideMembers if set, members of compilation units and class files are shown
  */
 public ScriptExplorerContentProvider(final boolean provideMembers) {
   super(provideMembers);
   fShowLibrariesNode = false;
   fIsFlatLayout = false;
   fFoldPackages = arePackagesFoldedInHierarchicalLayout();
   fPendingUpdates = null;
   DLTKUIPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
 }
 public TestScriptCommentScanner(
     String[] tags, String commentKey, String todoKey, boolean caseSensitive) {
   super(
       new DLTKColorManager(true),
       DLTKUIPlugin.getDefault().getPreferenceStore(),
       commentKey,
       todoKey,
       new TestTodoTaskPreferences(tags, caseSensitive));
 }
  private void restoreFromPreferences() {

    String compiledTextHoverModifiers =
        fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS);

    StringTokenizer tokenizer =
        new StringTokenizer(compiledTextHoverModifiers, EditorTextHoverDescriptor.VALUE_SEPARATOR);
    HashMap idToModifier = new HashMap(tokenizer.countTokens() / 2);

    while (tokenizer.hasMoreTokens()) {
      String id = tokenizer.nextToken();
      if (tokenizer.hasMoreTokens()) idToModifier.put(id, tokenizer.nextToken());
    }

    String compiledTextHoverModifierMasks =
        DLTKUIPlugin.getDefault()
            .getPreferenceStore()
            .getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS);

    tokenizer =
        new StringTokenizer(
            compiledTextHoverModifierMasks, EditorTextHoverDescriptor.VALUE_SEPARATOR);
    HashMap idToModifierMask = new HashMap(tokenizer.countTokens() / 2);

    while (tokenizer.hasMoreTokens()) {
      String id = tokenizer.nextToken();
      if (tokenizer.hasMoreTokens()) idToModifierMask.put(id, tokenizer.nextToken());
    }

    for (int i = 0; i < fHoverConfigs.length; i++) {
      String modifierString = (String) idToModifier.get(getContributedHovers()[i].getId());
      boolean enabled = true;
      if (modifierString == null) modifierString = EditorTextHoverDescriptor.DISABLED_TAG;

      if (modifierString.startsWith(EditorTextHoverDescriptor.DISABLED_TAG)) {
        enabled = false;
        modifierString = modifierString.substring(1);
      }

      if (modifierString.equals(EditorTextHoverDescriptor.NO_MODIFIER))
        modifierString = ""; // $NON-NLS-1$

      fHoverConfigs[i].fModifierString = modifierString;
      fHoverConfigs[i].fIsEnabled = enabled;
      fHoverConfigs[i].fStateMask = EditorTextHoverDescriptor.computeStateMask(modifierString);

      if (fHoverConfigs[i].fStateMask == -1) {
        try {
          fHoverConfigs[i].fStateMask =
              Integer.parseInt((String) idToModifierMask.get(getContributedHovers()[i].getId()));
        } catch (NumberFormatException ex) {
          fHoverConfigs[i].fStateMask = -1;
        }
      }
    }
  }
 public void setLinkingEnabled(boolean enabled) {
   fLinkingEnabled = enabled;
   DLTKUIPlugin.getDefault().getPreferenceStore().setValue(getLinkToEditorKey(), enabled);
   if (enabled) {
     IEditorPart editor = getSite().getPage().getActiveEditor();
     if (editor != null) {
       setSelectionFromEditor(editor);
     }
   }
 }
Пример #5
0
  public void install(IValidationContext helper) {

    IEditorInput fEditorInput = findEditor(helper);

    fDocumentProvider = DLTKUIPlugin.getDefault().getSourceModuleDocumentProvider();

    fEditor = getEditor(fEditorInput);

    fIsScriptReconcilingListener = fEditor instanceof IPhpScriptReconcilingListener;
    if (fIsScriptReconcilingListener) {
      fJavaReconcilingListener = (IPhpScriptReconcilingListener) fEditor;
    }
  }
Пример #6
0
 private void restoreLayoutState(IMemento memento) {
   if (memento == null) {
     // read state from the preference store
     IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
     fCurrViewState = store.getInt(this.getViewSite().getId() + TAG_VIEW_STATE);
   } else {
     // restore from memento
     Integer integer = memento.getInteger(this.getViewSite().getId() + TAG_VIEW_STATE);
     if ((integer == null) || !isValidState(integer.intValue())) {
       fCurrViewState = LIST_VIEW_STATE;
     } else fCurrViewState = integer.intValue();
   }
 }
Пример #7
0
    public void changeControlPressed(DialogField field) {
      IEnvironment environment = getEnvironment();
      IEnvironmentUI environmentUI = (IEnvironmentUI) environment.getAdapter(IEnvironmentUI.class);
      if (environmentUI != null) {
        String selectedDirectory = environmentUI.selectFolder(getShell());

        if (selectedDirectory != null) {
          // fLocation.setText(selectedDirectory);
          DLTKUIPlugin.getDefault()
              .getDialogSettings()
              .put(DIALOGSTORE_LAST_EXTERNAL_LOC, selectedDirectory);
        }
      }
    }
Пример #8
0
  public DeleteAction(IWorkbenchSite site) {
    super(site);
    setText(ReorgMessages.DeleteAction_3);
    setDescription(ReorgMessages.DeleteAction_4);
    ISharedImages workbenchImages = DLTKUIPlugin.getDefault().getWorkbench().getSharedImages();
    setDisabledImageDescriptor(
        workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED));
    setImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));
    setHoverImageDescriptor(workbenchImages.getImageDescriptor(ISharedImages.IMG_TOOL_DELETE));

    if (DLTKCore.DEBUG) {
      System.err.println("Add help support here..."); // $NON-NLS-1$
    }
  }
  /**
   * @param input the editor input
   * @param offset the offset in the file
   * @return the element at the given offset
   */
  protected IModelElement getElementAt(IEditorInput input, int offset) {

    IWorkingCopyManager manager = DLTKUIPlugin.getDefault().getWorkingCopyManager();
    ISourceModule unit = manager.getWorkingCopy(input);
    if (unit != null)
      try {
        if (unit.isConsistent()) return unit.getElementAt(offset);
        else {
          /*
           * XXX: We should set the selection later when the CU is
           * reconciled. see
           * https://bugs.eclipse.org/bugs/show_bug.cgi?id=51290
           */
        }
      } catch (ModelException ex) {
        // fall through
      }
    return null;
  }
Пример #10
0
  /**
   * Returns the model element wrapped by the given editor input.
   *
   * @param editorInput the editor input
   * @return the model element wrapped by <code>editorInput</code> or <code>null</code> if none
   */
  public static ISourceModule getEditorInputModelElement(IEditorInput editorInput) {
    // Performance: check working copy manager first: this is faster
    ISourceModule je =
        DLTKUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(editorInput, false);
    if (je != null) {
      return je;
    }

    if (editorInput instanceof FileStoreEditorInput) {
      ISourceModule module = resolveSourceModule((FileStoreEditorInput) editorInput);
      if (module != null) {
        return module;
      }
    }
    IModelElement me = (IModelElement) editorInput.getAdapter(IModelElement.class);
    if (me instanceof ISourceModule) {
      return (ISourceModule) me;
    }
    return null;
  }
  public void performOk() {
    StringBuffer buf = new StringBuffer();
    StringBuffer maskBuf = new StringBuffer();
    for (int i = 0; i < fHoverConfigs.length; i++) {
      buf.append(getContributedHovers()[i].getId());
      buf.append(EditorTextHoverDescriptor.VALUE_SEPARATOR);
      if (!fHoverConfigs[i].fIsEnabled) buf.append(EditorTextHoverDescriptor.DISABLED_TAG);
      String modifier = fHoverConfigs[i].fModifierString;
      if (modifier == null || modifier.length() == 0)
        modifier = EditorTextHoverDescriptor.NO_MODIFIER;
      buf.append(modifier);
      buf.append(EditorTextHoverDescriptor.VALUE_SEPARATOR);

      maskBuf.append(getContributedHovers()[i].getId());
      maskBuf.append(EditorTextHoverDescriptor.VALUE_SEPARATOR);
      maskBuf.append(fHoverConfigs[i].fStateMask);
      maskBuf.append(EditorTextHoverDescriptor.VALUE_SEPARATOR);
    }
    fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS, buf.toString());
    fStore.setValue(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS, maskBuf.toString());

    DLTKUIPlugin.getDefault().resetEditorTextHoverDescriptors(fNature);
  }
Пример #12
0
  private void switchViewer(int state) {
    // Indicate which viewer is to be used
    if (fCurrViewState == state) return;
    else {
      fCurrViewState = state;
      IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
      store.setValue(getViewSite().getId() + TAG_VIEW_STATE, state);
    }

    // get the information from the existing viewer
    StructuredViewer viewer = fWrappedViewer.getViewer();
    Object object = viewer.getInput();
    ISelection selection = viewer.getSelection();

    // create and set up the new viewer
    Control control = createViewer(fWrappedViewer.getControl().getParent()).getControl();

    setUpViewer(fWrappedViewer);

    createSelectAllAction();

    // add the selection information from old viewer
    fWrappedViewer.setViewerInput(object);
    fWrappedViewer.getControl().setFocus();
    fWrappedViewer.setSelection(selection, true);

    // dispose old viewer
    viewer.getContentProvider().dispose();
    viewer.getControl().dispose();

    // layout the new viewer
    if (control != null && !control.isDisposed()) {
      control.setVisible(true);
      control.getParent().layout(true);
    }
  }
Пример #13
0
 public static IWorkbenchPage getActivePage() {
   return DLTKUIPlugin.getDefault().internalGetActivePage();
 }
 private EditorTextHoverDescriptor[] getContributedHovers() {
   return DLTKUIPlugin.getDefault().getEditorTextHoverDescriptors(fStore, fNature);
 }
 /*
  * (non-Javadoc) Method declared on IContentProvider.
  */
 public void dispose() {
   super.dispose();
   DLTKCore.removeElementChangedListener(this);
   DLTKUIPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
 }
Пример #16
0
 public static ISourceModuleDocumentProvider getDocumentProvider() {
   return DLTKUIPlugin.getDefault().getSourceModuleDocumentProvider();
 }
 public NewSourceFolderCreationWizard() {
   super();
   setDefaultPageImageDescriptor(DLTKPluginImages.DESC_WIZBAN_NEWSRCFOLDR);
   setDialogSettings(DLTKUIPlugin.getDefault().getDialogSettings());
   setWindowTitle(NewWizardMessages.NewSourceFolderCreationWizard_title);
 }
Пример #18
0
 public static void log(IStatus status) {
   DLTKUIPlugin.getDefault().getLog().log(status);
 }
Пример #19
0
 public static ImageDescriptorRegistry getImageDescriptorRegistry() {
   return DLTKUIPlugin.getDefault().internalGetImageDescriptorRegistry();
 }
 private void initLinkingEnabled() {
   fLinkingEnabled =
       DLTKUIPlugin.getDefault().getPreferenceStore().getBoolean(getLinkToEditorKey());
 }
Пример #21
0
 public static IWorkbenchWindow getActiveWorkbenchWindow() {
   return DLTKUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
 }
 public JavaScriptFileCreationWizard() {
   setDefaultPageImageDescriptor(JavaScriptImages.DESC_WIZBAN_PROJECT_CREATION);
   setDialogSettings(DLTKUIPlugin.getDefault().getDialogSettings());
   setWindowTitle(JavascriptWizardMessages.FileCreationWizard_title);
 }
 @Override
 protected void setPreferenceStore() {
   setPreferenceStore(DLTKUIPlugin.getDefault().getPreferenceStore());
 }
 private IType[] getTypes() throws ModelException {
   IEditorInput input = fEditor.getEditorInput();
   return DLTKUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input).getTypes();
 }
 private ISourceReference getSourceReference() {
   IEditorInput input = fEditor.getEditorInput();
   return DLTKUIPlugin.getDefault().getWorkingCopyManager().getWorkingCopy(input);
 }
 protected ScriptUILabelProvider createLabelProvider() {
   return new AppearanceAwareLabelProvider(
       AppearanceAwareLabelProvider.DEFAULT_TEXTFLAGS,
       AppearanceAwareLabelProvider.DEFAULT_IMAGEFLAGS | ScriptElementImageProvider.SMALL_ICONS,
       DLTKUIPlugin.getDefault().getPreferenceStore());
 }
 protected IPreferenceStore getPreferenceStore() {
   return DLTKUIPlugin.getDefault().getPreferenceStore();
 }