Package tool.editors

Source Code of tool.editors.ToolEditor

package tool.editors;

import org.eclipse.jface.text.source.projection.ProjectionSupport;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;

import tool.editors.text.ToolDocumentProvider;



public class ToolEditor extends TextEditor {

  public static final String EDITOR_ID = "tool.editors.ToolEditor";
  public static final String EDITOR_CONTEXT = EDITOR_ID + ".context";
  public static final String RULER_CONTEXT = EDITOR_CONTEXT + ".ruler";
  private ColorManager colorManager;
  /** The outline page */
  private ToolMethodContentOutlinePage fOutlinePage;
  /** The projection support */
  private ProjectionSupport fProjectionSupport;

  public ToolEditor() {
    super();
    colorManager = new ColorManager();
    setSourceViewerConfiguration(new ToolSourceViewerConfiguration(colorManager));
    setDocumentProvider(new ToolDocumentProvider());
  }
  public void dispose() {
    colorManager.dispose();
    super.dispose();
  }
  /** The <code>JavaEditor</code> implementation of this
   * <code>AbstractTextEditor</code> method performs gets
   * the java content outline page if request is for a an
   * outline page.
   *
   * @param required the required type
   * @return an adapter for the required type or <code>null</code>
   */
  @SuppressWarnings("rawtypes")
  public Object getAdapter(Class required) {
    if (IContentOutlinePage.class.equals(required)) {
      if (fOutlinePage == null) {
        fOutlinePage = new ToolMethodContentOutlinePage(
            getDocumentProvider(), this );
        if (getEditorInput() != null)
          fOutlinePage.setInput(getEditorInput());
      }
      return fOutlinePage;
    }

    if (fProjectionSupport != null) {
      Object adapter = fProjectionSupport.getAdapter(
          getSourceViewer(), required);
      if (adapter != null)
        return adapter;
    }

    return super.getAdapter(required);
  }
  protected void initializeEditor() {
    super.initializeEditor();
    setEditorContextMenuId(EDITOR_CONTEXT);
    setRulerContextMenuId(RULER_CONTEXT);
  }
}
TOP

Related Classes of tool.editors.ToolEditor

TOP
Copyright © 2018 www.massapi.com. 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.