Package org.eclipse.wst.sse.ui

Examples of org.eclipse.wst.sse.ui.StructuredTextEditor


    realFile.deleteOnExit();

    IWorkbenchPage page = fWindow.getActivePage();
    try {
      IEditorPart editor = page.openEditor(input, UNTITLED_EDITOR_ID);
      StructuredTextEditor textEditor = null;
      if (editor instanceof StructuredTextEditor) {
        textEditor = (StructuredTextEditor) editor;
      }
      // Load the last template name used in New PHP File wizard.
      String templateName = PHPUiPlugin.getDefault().getPreferenceStore()
          .getString(PreferenceConstants.NEW_PHP_FILE_TEMPLATE);
      if (templateName == null || templateName.length() == 0) {
        return true;
      }
      TemplateStore templateStore = PHPUiPlugin.getDefault()
          .getCodeTemplateStore();
      Template template = templateStore.findTemplate(templateName);
      if (template == null) {
        return true;
      }
      // compile the template and insert the text into the new document
      CompiledTemplate compiledTemplate = PHPTemplateStore
          .compileTemplate(PHPUiPlugin.getDefault()
              .getCodeTemplateContextRegistry(), template);
      IDocumentProvider documentProvider = textEditor
          .getDocumentProvider();
      IDocument document = textEditor.getDocumentProvider().getDocument(
          textEditor.getEditorInput());
      document.set(compiledTemplate.string);
      documentProvider.saveDocument(null, textEditor.getEditorInput(),
          document, true);
      textEditor.selectAndReveal(compiledTemplate.offset, 0);

      // set document dirty
      document.replace(0, 0, ""); //$NON-NLS-1$
    } catch (PartInitException e) {
      Logger.logException(e);
View Full Code Here


    public void dispose() {
        toolkit.dispose();
    }

    protected String getTextFromMetadataEditor() {
        StructuredTextEditor metadataEditor = multiPageEditor.getMetadataEditor();
        return metadataEditor.getDocumentProvider().getDocument(getEditorInput()).get();
    }
View Full Code Here

          public Object[] getElements(Object object) {
            if (object instanceof ISourceModule) {
              IEditorPart activeEditor = PHPUiPlugin
                  .getActiveEditor();
              if (activeEditor instanceof StructuredTextEditor) {
                StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
                IDocument document = editor
                    .getDocumentProvider().getDocument(
                        editor.getEditorInput());
                IStructuredModel model = null;
                try {
                  model = StructuredModelManager
                      .getModelManager()
                      .getExistingModelForRead(document);
                  return super.getElements(model);
                } finally {
                  if (model != null) {
                    model.releaseFromRead();
                  }
                }
              }
            }
            return super.getElements(object);
          }

          @Override
          public void inputChanged(Viewer viewer, Object oldInput,
              Object newInput) {
            if (newInput instanceof ISourceModule) {
              IEditorPart activeEditor = PHPUiPlugin
                  .getActiveEditor();
              if (activeEditor instanceof StructuredTextEditor) {
                StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
                IDocument document = editor
                    .getDocumentProvider().getDocument(
                        editor.getEditorInput());
                IStructuredModel model = null;
                try {
                  model = StructuredModelManager
                      .getModelManager()
                      .getExistingModelForRead(document);
View Full Code Here

  }

  protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
    IEditorPart activeEditor = PHPUiPlugin.getActiveEditor();
    if (activeEditor instanceof StructuredTextEditor) {
      StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
      IDocument document = editor.getDocumentProvider().getDocument(
          editor.getEditorInput());
      IStructuredModel model = null;
      try {
        model = StructuredModelManager.getModelManager()
            .getExistingModelForRead(document);
        return new PHPNodeActionManager(model, treeViewer);
View Full Code Here

    ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
  }

  public void createPages() {
    try {
      sourceEditor = new StructuredTextEditor();
      addPage(0, sourceEditor, getEditorInput());
      setPageText(0, ClickPlugin.getString("editor.clickXML.source"));
    } catch(Exception ex){
      ClickPlugin.log(ex);
    }
View Full Code Here

                    {
                        if (object instanceof ISourceModule) {
                            IEditorPart activeEditor = PHPUiPlugin
                                    .getActiveEditor();
                            if (activeEditor instanceof StructuredTextEditor) {
                                StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
                                IDocument document = editor
                                        .getDocumentProvider().getDocument(
                                                editor.getEditorInput());
                                IStructuredModel model = null;
                                try {
                                    model = StructuredModelManager
                                            .getModelManager()
                                            .getExistingModelForRead(document);
                                    return super.getElements(model);
                                } finally {
                                    if (model != null) {
                                        model.releaseFromRead();
                                    }
                                }
                            }
                        }
                        return super.getElements(object);
                    }

                    @Override
                    public void inputChanged(Viewer viewer, Object oldInput,
                            Object newInput)
                    {
                        if (newInput instanceof ISourceModule) {
                            IEditorPart activeEditor = PHPUiPlugin
                                    .getActiveEditor();
                            if (activeEditor instanceof StructuredTextEditor) {
                                StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
                                IDocument document = editor
                                        .getDocumentProvider().getDocument(
                                                editor.getEditorInput());
                                IStructuredModel model = null;
                                try {
                                    model = StructuredModelManager
                                            .getModelManager()
                                            .getExistingModelForRead(document);
View Full Code Here

    protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer)
    {
        IEditorPart activeEditor = PHPUiPlugin.getActiveEditor();
        if (activeEditor instanceof StructuredTextEditor) {
            StructuredTextEditor editor = (StructuredTextEditor) activeEditor;
            IDocument document = editor.getDocumentProvider().getDocument(
                    editor.getEditorInput());
            IStructuredModel model = null;
            try {
                model = StructuredModelManager.getModelManager()
                        .getExistingModelForRead(document);
                return new TwigNodeActionManager(model, treeViewer);
View Full Code Here

          if (!resources.contains(file) || resources.size() == 0) {
            return;
          }
        }

        StructuredTextEditor textEditor = null;
        if (part instanceof IConfigEditor) {
          IConfigEditor editor = (IConfigEditor) part;
          textEditor = editor.getSourcePage();
        }
        else if (part instanceof XMLMultiPageEditorPart) {
          XMLMultiPageEditorPart xmlEditor = (XMLMultiPageEditorPart) part;
          IEditorPart[] editors = xmlEditor.findEditors(xmlEditor.getEditorInput());
          for (IEditorPart editor : editors) {
            if (editor instanceof StructuredTextEditor) {
              textEditor = ((StructuredTextEditor) editor);
            }
          }
        }

        if (textEditor != null) {
          SourceViewerConfiguration configuration = null;
          try {
            Method getSourceViewerConfigurationMethod = ReflectionUtils.findMethod(textEditor.getClass(),
                "getSourceViewerConfiguration");
            getSourceViewerConfigurationMethod.setAccessible(true);
            configuration = (SourceViewerConfiguration) getSourceViewerConfigurationMethod
                .invoke(textEditor);
          }
          catch (Exception e) {
            // TODO CD add logging here
          }
          if (configuration != null) {
            ISourceViewer textViewer = textEditor.getTextViewer();
            IReconciler reconciler = configuration.getReconciler(textViewer);
            if (reconciler instanceof DirtyRegionProcessor) {
              ((DirtyRegionProcessor) reconciler).setDocument(textViewer.getDocument());
            }
          }
View Full Code Here

   * Creates the first page of the multi-page editor, which contains a text
   * editor.
   */
  private void createSourcePage() {
    try {
      sourceEditor = new StructuredTextEditor() {
        @Override
        public void selectAndReveal(int start, int length) {
          setActiveEditor(sourceEditor);
          super.selectAndReveal(start, length);
        }
View Full Code Here

  }

  @Override
  public boolean performFinish() {
    if (editor != null && editor.getAdapter(StructuredTextEditor.class) != null) {
      StructuredTextEditor textEditor = (StructuredTextEditor) editor.getAdapter(StructuredTextEditor.class);
      textEditor.getTextViewer().setRedraw(false);
      performFinishHelper();
      textEditor.getTextViewer().setRedraw(true);
    }
    else {
      performFinishHelper();
    }
    return true;
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.ui.StructuredTextEditor

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.