public boolean openHyperLink() {
    String localiz = getLocalization();
    if (localiz == null) {
      return false;
    } else if (fBase.getUnderlyingResource() == null) {
      return false;
    } else if (fElement.length() == 0 || fElement.charAt(0) != '%') {
      return false;
    }

    IProject proj = fBase.getUnderlyingResource().getProject();
    IFile file = proj.getFile(localiz + ".properties"); // $NON-NLS-1$
    if (!file.exists()) return false;

    try {
      IEditorPart editor = IDE.openEditor(PDEPlugin.getActivePage(), file);
      if (!(editor instanceof TextEditor)) return false;
      TextEditor tEditor = (TextEditor) editor;
      IDocument doc = tEditor.getDocumentProvider().getDocument(tEditor.getEditorInput());
      if (doc == null) return false;

      try {
        String key = fElement.substring(1);
        int keyLen = key.length();
        int length = doc.getLength();
        int start = 0;
        IRegion region = null;
        FindReplaceDocumentAdapter docSearch = new FindReplaceDocumentAdapter(doc);
        while ((region = docSearch.find(start, key, true, false, false, false)) != null) {
          int offset = region.getOffset();
          if (offset > 0) {
            // check for newline before
            char c = doc.getChar(offset - 1);
            if (c != '\n' && c != '\r') {
              start += keyLen;
              continue;
            }
          }
          if (offset + keyLen < length) {
            // check for whitespace / assign symbol after
            char c = doc.getChar(offset + keyLen);
            if (!Character.isWhitespace(c) && c != '=' && c != ':') {
              start += keyLen;
              continue;
            }
          }
          tEditor.selectAndReveal(offset, keyLen);
          break;
        }
      } catch (BadLocationException e) {
        PDEPlugin.log(e);
      }

    } catch (PartInitException e) {
      return false;
    }
    return true;
  }
Пример #2
0
  /** Converts the text in editor to HTML text to be displayed in preview page. */
  void markdownToHtml() {
    String editorText = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();

    String htmlText = "<p>Error processing the input.</p>";
    try {
      htmlText = markdownProcessor.process(editorText);
    } catch (IOException e) {
    }

    browser.setText(htmlText);
  }
Пример #3
0
  protected void performSaveAs(IProgressMonitor progressMonitor) {
    FileEditorInput input = (FileEditorInput) getEditorInput();
    String path = input.getFile().getFullPath().toString();
    ResourceSet resourceSet = getResourceSet();
    URI platformURI = URI.createPlatformResourceURI(path, true);
    Resource oldFile = resourceSet.getResource(platformURI, true);

    super.performSaveAs(progressMonitor);

    // load and resave - input has been changed to new path by super
    FileEditorInput newInput = (FileEditorInput) getEditorInput();
    String newPath = newInput.getFile().getFullPath().toString();
    URI newPlatformURI = URI.createPlatformResourceURI(newPath, true);
    Resource newFile = resourceSet.createResource(newPlatformURI);
    // if the extension is the same, saving was already performed by super by saving
    // the plain text
    if (platformURI.fileExtension().equals(newPlatformURI.fileExtension())) {
      oldFile.unload();
      // save code folding state, is it possible with a new name
      codeFoldingManager.saveCodeFoldingStateFile(getResource().getURI().toString());
    } else {
      newFile.getContents().clear();
      newFile.getContents().addAll(oldFile.getContents());
      try {
        oldFile.unload();
        if (newFile.getErrors().isEmpty()) {
          newFile.save(null);
        }
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
Пример #4
0
 public void setFocus() {
   super.setFocus();
   this.invalidateTextRepresentation();
   // Parse the document again to remove errors that stem from unresolvable proxy
   // objects
   bgParsingStrategy.parse(getSourceViewer().getDocument(), resource, this, 10);
 }
Пример #5
0
  protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {

    super.performSave(overwrite, progressMonitor);

    // Save code folding state
    codeFoldingManager.saveCodeFoldingStateFile(getResource().getURI().toString());
  }
  /**
   * {@inheritDoc}
   *
   * @see
   *     org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#createPartControl(org.eclipse.swt.widgets.Composite)
   */
  @Override
  public void createPartControl(Composite parent) {
    super.createPartControl(parent);

    addProjectionSupport();
    addMatchingCharacterPainter();
  }
Пример #7
0
 public void initializeEditor() {
   super.initializeEditor();
   setEditorContextMenuId(
       "com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.EditorContext");
   setRulerContextMenuId(
       "com.github.funthomas424242.rezeptsammler.rezept.resource.rezept.EditorRuler");
 }
 @Override
 public void dispose() {
   getStore().removePropertyChangeListener(listener);
   colorManager.dispose();
   getJBehaveProject().removeListener(projectListener);
   super.dispose();
 }
Пример #9
0
  @Override
  protected void doSetInput(IEditorInput newInput) throws CoreException {
    // If this editor is for a project file, remove this editor as a property
    // change listener.
    if (fProject != null)
      AutotoolsPropertyManager.getDefault().removeProjectPropertyListener(fProject, this);
    this.fProject = null;
    super.doSetInput(newInput);
    this.input = newInput;

    if (input instanceof IFileEditorInput) {
      IFile f = ((IFileEditorInput) input).getFile();
      fProject = f.getProject();
      // This is a project file.  We want to be notified if the Autoconf editor
      // properties are changed such that the macro versions are changed.
      AutotoolsPropertyManager.getDefault().addProjectPropertyListener(fProject, this);
    }
    getOutlinePage().setInput(input);
    try {
      IDocument document = getInputDocument();

      setRootElement(reparseDocument(document));
    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Пример #10
0
 @Override
 protected void initializeEditor() {
   super.initializeEditor();
   setEditorContextMenuId(EDITOR_CONTEXT);
   setRulerContextMenuId(RULER_CONTEXT);
   setDocumentProvider(new JsDocumentProvider());
 }
Пример #11
0
  @Override
  protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    ISourceViewer sourceViewer = getSourceViewer();
    if (sourceViewer == null) return;

    String property = event.getProperty();

    AutoconfCodeScanner scanner = (AutoconfCodeScanner) getAutoconfCodeScanner();
    if (scanner != null) {
      if (scanner.affectsBehavior(event)) {
        scanner.adaptToPreferenceChange(event);
        sourceViewer.invalidateTextPresentation();
      }
    }

    if (AutotoolsEditorPreferenceConstants.AUTOCONF_VERSION.equals(property)
        || AutotoolsEditorPreferenceConstants.AUTOMAKE_VERSION.equals(property)) {
      handleVersionChange(sourceViewer);
    } else if (AutotoolsEditorPreferenceConstants.EDITOR_FOLDING_ENABLED.equals(property)) {
      if (sourceViewer instanceof ProjectionViewer) {
        ProjectionViewer projectionViewer = (ProjectionViewer) sourceViewer;
        if (fProjectionFileUpdater != null) fProjectionFileUpdater.uninstall();
        // either freshly enabled or provider changed
        fProjectionFileUpdater = new ProjectionFileUpdater();
        if (fProjectionFileUpdater != null) {
          fProjectionFileUpdater.install(this, projectionViewer);
        }
      }
      return;
    }

    super.handlePreferenceStoreChanged(event);
  }
  @Override
  protected void createActions() {
    super.createActions();
    ResourceBundle bundle = EditorMessages.getBundleForConstructedKeys();

    showOutline = new ShowOutlineAction(bundle, "ShowOutline.", this);
    showOutline.setActionDefinitionId(EditorActionDefinitionIds.SHOW_OUTLINE);
    setAction(EditorActionDefinitionIds.SHOW_OUTLINE, showOutline);
    markAsContentDependentAction(EditorActionDefinitionIds.SHOW_OUTLINE, true);

    quickSearch = new QuickSearchAction(bundle, "QuickSearch.", this);
    quickSearch.setActionDefinitionId(EditorActionDefinitionIds.QUICK_SEARCH);
    setAction(EditorActionDefinitionIds.QUICK_SEARCH, quickSearch);
    markAsContentDependentAction(EditorActionDefinitionIds.QUICK_SEARCH, true);

    jumpToDeclaration = new JumpToDeclarationAction(bundle, "JumpToDeclaration.", this);
    jumpToDeclaration.setActionDefinitionId(EditorActionDefinitionIds.JUMP_TO_DECLARATION);
    setAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, jumpToDeclaration);
    markAsContentDependentAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, true);

    toggleComment = new ToggleCommentAction(bundle, "ToggleComment.", this);
    toggleComment.setActionDefinitionId(EditorActionDefinitionIds.TOGGLE_COMMENT);
    setAction(EditorActionDefinitionIds.TOGGLE_COMMENT, toggleComment);
    markAsContentDependentAction(EditorActionDefinitionIds.JUMP_TO_DECLARATION, true);
  }
Пример #13
0
  @Override
  public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    super.init(site, input);

    // Show the 'presentation' action set with the 'Toggle Block SelectionMode' and
    // 'Show Whitespace Characters' actions.
    IWorkbenchPage page = site.getPage();
    page.showActionSet("org.eclipse.ui.edit.text.actionSet.presentation");
  }
 /**
  * Creates page 1 of the multi-page editor, which allows you to change the font used in page 2.
  */
 void createPage1() {
   try {
     m_editor = new TextEditor();
     int index = addPage(m_editor, getEditorInput());
     setPageText(index, m_editor.getTitle());
   } catch (PartInitException e) {
     e.printStackTrace();
   }
 }
 @Override
 protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
   super.configureSourceViewerDecorationSupport(support);
   if (AttemptToChangeCurrentLineColorAccordingToTheme) {
     adjustCurrentLineColor(getTheme());
     support.setCursorLinePainterPreferenceKeys(
         AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE,
         PreferenceConstants.CUSTOM_CURRENT_LINE_COLOR);
   }
 }
Пример #16
0
 // for bracket matching
 @Override
 protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
   super.configureSourceViewerDecorationSupport(support);
   char[] brackets = {'(', ')', '[', ']'};
   ICharacterPairMatcher matcher =
       new DefaultCharacterPairMatcher(brackets, IDocumentExtension3.DEFAULT_PARTITIONING);
   support.setCharacterPairMatcher(matcher);
   support.setMatchingCharacterPainterPreferenceKeys(
       Activator.PREFERENCE_BRACKET_MATCHING, Activator.PREFERENCE_COLOR_BRACKET_MATCHING);
 }
Пример #17
0
 /** Creates page 0 of the multi-page editor, which contains a text editor. */
 void createPage0() {
   try {
     editor = new TextEditor();
     int index = addPage(editor, getEditorInput());
     setPageText(index, editor.getTitle());
   } catch (PartInitException e) {
     ErrorDialog.openError(
         getSite().getShell(), "Error creating nested text editor", null, e.getStatus());
   }
 }
Пример #18
0
  /** Sorts the words in page 0, and shows them in page 2. */
  void sortWords() {

    String editorText = editor.getDocumentProvider().getDocument(editor.getEditorInput()).get();

    StringTokenizer tokenizer =
        new StringTokenizer(editorText, " \t\n\r\f!@#\u0024%^&*()-_=+`~[]{};:'\",.<>/?|\\");
    ArrayList editorWords = new ArrayList();
    while (tokenizer.hasMoreTokens()) {
      editorWords.add(tokenizer.nextToken());
    }

    Collections.sort(editorWords, Collator.getInstance());
    StringWriter displayText = new StringWriter();
    for (int i = 0; i < editorWords.size(); i++) {
      displayText.write(((String) editorWords.get(i)));
      displayText.write(System.getProperty("line.separator"));
    }
    text.setText(displayText.toString());
  }
  @Override
  protected void editorSaved() {
    super.editorSaved();

    ProjectAwareFastPartitioner partitioner =
        (ProjectAwareFastPartitioner) getInputDocument().getDocumentPartitioner();
    if (partitioner != null) {
      partitioner.invalidatePartitions();
    }
    validateAndMark();
  }
 @Override
 public void init(IEditorSite site, IEditorInput input) throws PartInitException {
   super.init(site, input);
   listener =
       new IPropertyChangeListener() {
         public void propertyChange(PropertyChangeEvent event) {
           updateStyles();
         }
       };
   getStore().addPropertyChangeListener(listener);
 }
Пример #21
0
 /**
  * {@inheritDoc}
  *
  * @see org.eclipse.ui.editors.text.TextEditor#dispose()
  */
 public void dispose() {
   if (outlinePage != null) {
     outlinePage.dispose();
   }
   IPreferenceStore preferenceStore = DFEditorActivator.getDefault().getPreferenceStore();
   preferenceStore.removePropertyChangeListener(this);
   outlinePage = null;
   dfPropModel = null;
   projectionSupport = null;
   super.dispose();
 }
Пример #22
0
  /**
   * {@inheritDoc}
   *
   * @see org.eclipse.ui.texteditor.AbstractTextEditor#init(org.eclipse.ui.IEditorSite,
   *     org.eclipse.ui.IEditorInput)
   */
  @Override
  public void init(IEditorSite site, IEditorInput input) throws PartInitException {
    ISharedTextColors colors = getSharedColors();
    IPreferenceStore preferenceStore = DFEditorActivator.getDefault().getPreferenceStore();
    DFPropFileConfiguration configuration = new DFPropFileConfiguration(colors, preferenceStore);
    setSourceViewerConfiguration(configuration);

    preferenceStore.addPropertyChangeListener(this);

    super.init(site, input);
  }
Пример #23
0
 @Override
 public void dispose() {
   if (fProjectionFileUpdater != null) {
     fProjectionFileUpdater.uninstall();
     fProjectionFileUpdater = null;
   }
   if (fProject != null) {
     AutotoolsPropertyManager.getDefault().removeProjectPropertyListener(fProject, this);
   }
   super.dispose();
 }
Пример #24
0
 /** InitialiSes this editor. */
 @Override
 protected void initializeEditor() {
   colorManager = new ColorManager();
   // Two elements are configured here:
   // 1.- SourceViewerConfiguration: adds new features to the editor, such
   // as formatting, syntax highlighting, text hovering, etc.
   // 2.- DocumentProvider: establishes a bridge between a file on a disk,
   // and
   // its representation as a document in memory.
   setSourceViewerConfiguration(new T24BasicSourceViewerConfiguration(this, colorManager));
   setDocumentProvider(new T24BasicDocumentProvider());
   super.initializeEditor();
 }
Пример #25
0
 @Override
 protected void initializeEditor() {
   super.initializeEditor();
   setDocumentProvider(getAutoconfDocumentProvider());
   IPreferenceStore[] stores = new IPreferenceStore[2];
   stores[0] = AutotoolsPlugin.getDefault().getPreferenceStore();
   stores[1] = EditorsUI.getPreferenceStore();
   ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(stores);
   setPreferenceStore(chainedStore);
   setSourceViewerConfiguration(new AutoconfSourceViewerConfiguration(chainedStore, this));
   AutotoolsEditorPreferenceConstants.initializeDefaultValues(stores[0]);
   AutoconfEditorPreferencePage.initDefaults(stores[0]);
 }
  /** Calculates the contents of page 2 when the it is activated. */
  protected void pageChange(int newPageIndex) {
    super.pageChange(newPageIndex);

    try {
      if (!getFileName().equals(AppYmlFile.configFileName)) {
        newPageIndex = 1;
      }

      if (newPageIndex == 0) {
        m_editor.doSave(null);

        String pathToFile = getFileLocation();

        m_ymlFile = null;
        m_ymlFile = new AppYmlFile(pathToFile);

        String sdk = m_ymlFile.getSdkPath();
        String appName = m_ymlFile.getAppName();
        String logName = m_ymlFile.getAppLog();

        m_appLogText.setText(logName);
        m_rhodesPathText.setText(sdk);
        m_appNameText.setText(appName);

        showCapabilitiesText(m_ymlFile.getCapabilities());

        return;
      }

      if (newPageIndex == 1) {
        m_editor.setInput(new FileEditorInput(getFile()));
        getFile().getProject().refreshLocal(IResource.DEPTH_INFINITE, null);
      }
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (CoreException e) {
      e.printStackTrace();
    }
  }
Пример #27
0
 @Override
 protected void initializeEditor() {
   super.initializeEditor();
   setPreferenceStore(
       new ChainedPreferenceStore(
           new IPreferenceStore[] {
             Activator.getCurrent().getPreferenceStore(), EditorsUI.getPreferenceStore()
           }));
   JavaColorManager colorManager = Activator.getCurrent().getColorManager();
   JavaSourceViewerConfiguration configuration =
       new JavaSourceViewerConfiguration(
           colorManager, getPreferenceStore(), this, IJavaPartitions.JAVA_PARTITIONING);
   setSourceViewerConfiguration(configuration);
 }
Пример #28
0
 @Override
 protected void editorContextMenuAboutToShow(IMenuManager menu) {
   super.editorContextMenuAboutToShow(menu);
   // remove editor actions that don't work in Photon
   menu.remove(ITextEditorActionConstants.CONTEXT_PREFERENCES);
   for (IContributionItem item : menu.getItems()) {
     if (item instanceof MenuManager) {
       MenuManager subMenu = (MenuManager) item;
       // Warning: this is a best effort since the menu doesn't have an
       // id
       if (subMenu.getMenuText().startsWith("Sho&w In")) { // $NON-NLS-1$
         menu.remove(subMenu);
       }
     }
   }
 }
Пример #29
0
 /**
  * Needed for content assistant in the Text viewer. This ensures actions such as key press would
  * trigger content assistant
  */
 @SuppressWarnings("deprecation")
 protected void createActions() {
   super.createActions();
   ResourceBundle bundle = T24BasicPlugin.getDefault().getResourceBundle();
   String id = ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS;
   Action action = new ContentAssistAction(bundle, "ContentAssistProposal", this);
   action.setActionDefinitionId(id);
   setAction("ContentAssistProposal", action);
   this.markAsContentDependentAction(id, true);
   ResourceAction printAction =
       new TextOperationAction(bundle, "Editor.Print.", this, ITextOperationTarget.PRINT, true);
   String printid = IWorkbenchActionDefinitionIds.PRINT;
   printAction.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
   printAction.setActionDefinitionId(printid);
   setAction(ITextEditorActionConstants.PRINT, new PrintActionDecorator(printAction));
   this.markAsContentDependentAction(printid, true);
 }
Пример #30
0
  public void editorContextMenuAboutToShow(IMenuManager menu) {
    super.editorContextMenuAboutToShow(menu);

    try {
      MenuManager subInsertTemplate = new MenuManager("Insert Template");
      TemplatesDocument templatesDocument = new TemplatesDocument();
      for (int i = 0; i < templatesDocument.numOfTemplates; i++) {
        addAction(subInsertTemplate, INSERT_TEMPLATES[i]);
      }
      menu.add(subInsertTemplate);
    } catch (Exception e) {
      e.printStackTrace();
    }
    // minchin
    MenuManager refactMenu = new MenuManager("Refactor");
    menu.add(refactMenu);

    addAction(refactMenu, SELECT_INTO_INF_ELEMENT);
    addAction(refactMenu, REPLACE_WITH_NEST);
    addAction(refactMenu, EXTRACT_INSERT_AFTER);
    addAction(refactMenu, EXTRACT_INSERT_BEFORE);
    addAction(refactMenu, INSERT_INTO_DICTIONARY);
    addAction(refactMenu, SEARCH_DICT_ENTRY);
    addAction(refactMenu, INSERT_INTO_DIRECTORY);
    addAction(refactMenu, SEARCH_DIR_REF);
    addAction(refactMenu, REPLACE_WITH_INFELMREF);

    // lebedkova
    addAction(refactMenu, RENAME);
    addAction(refactMenu, SELECT_INTO_INF_PRODUCT);
    addAction(refactMenu, SELECT_INTO_COND_BLOCK);
    addAction(refactMenu, SPLIT_INF_ELEM);
    addAction(refactMenu, MAKE_REF_OPTIONAL);
    addAction(refactMenu, MAKE_REF_REQUIRED);

    // smazhevsky
    addAction(refactMenu, HANDLE_DIFF_WITH_ANOTHER_INF_ELEM);
    // shutak
    addAction(refactMenu, FIND_CLONES_IN_INF_ELEM);
    // DRLMenuListener.instance.editor = this;

    // dluciv
    addAction(refactMenu, FIND_AND_BROWSE_VARIATIONS);

    menuListener.menuAboutToShow(menu);
  }