Java 类org.eclipse.jface.text.formatter.FormattingContextProperties 实例源码

项目:APICloud-Studio    文件:ScriptFormattingStrategy.java   
@Override
public void formatterStarts(final IFormattingContext context)
{
    super.formatterStarts(context);
    final IDocument document = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
    final TypedPosition partition = (TypedPosition) context
            .getProperty(FormattingContextProperties.CONTEXT_PARTITION);
    final IProject project = (IProject) context.getProperty(ScriptFormattingContextProperties.CONTEXT_PROJECT);
    final String formatterId = (String) context.getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_ID);
    final Boolean isSlave = (Boolean) context
            .getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_IS_SLAVE);
    final Boolean canConsumeIndentation = isSlave != null
            && isSlave
            && (Boolean) context
                    .getProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_CAN_CONSUME_INDENTATION);
    final Boolean isSelection = !(Boolean) context.getProperty(FormattingContextProperties.CONTEXT_DOCUMENT);
    IRegion selectionRegion = null;
    if (isSelection != null && isSelection)
    {
        selectionRegion = (IRegion) context.getProperty(FormattingContextProperties.CONTEXT_REGION);
    }
    fJobs.addLast(new FormatJob(context, document, partition, project, formatterId, isSlave, canConsumeIndentation,
            isSelection, selectionRegion));
}
项目:APICloud-Studio    文件:CommonMultiPassContentFormatter.java   
/**
 * Update the fomatting context to reflect to the script formatter that should be used with the given content-type.
 * 
 * @param context
 * @param region
 * @param lastContentType
 */
private void updateContex(IFormattingContext context, String contentType, int offset, int length)
{
    IScriptFormatterFactory factory = ScriptFormatterManager.getSelected(contentType);
    if (factory != null)
    {
        factory.setMainContentType(contentType);
        if (context != null)
        {
            context.setProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_ID, factory.getId());
            context.setProperty(FormattingContextProperties.CONTEXT_PARTITION, new TypedPosition(offset, length,
                    contentType));
            context.setProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_CAN_CONSUME_INDENTATION,
                    factory.canConsumePreviousIndent());
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitEditor.java   
@Override
public IFormattingContext createFormattingContext() {
    IFormattingContext context= new JavaFormattingContext();

    Map<String, String> preferences;
    IJavaElement inputJavaElement= getInputJavaElement();
    IJavaProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaProject() : null;
    if (javaProject == null)
        preferences= new HashMap<String, String>(JavaCore.getOptions());
    else
        preferences= new HashMap<String, String>(javaProject.getOptions(true));

    context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);

    return context;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompilationUnitEditor.java   
@Override
public IFormattingContext createFormattingContext() {
    IFormattingContext context= new JavaFormattingContext();

    Map<String, String> preferences;
    IJavaElement inputJavaElement= getInputJavaElement();
    IJavaProject javaProject= inputJavaElement != null ? inputJavaElement.getJavaProject() : null;
    if (javaProject == null)
        preferences= new HashMap<String, String>(JavaCore.getOptions());
    else
        preferences= new HashMap<String, String>(javaProject.getOptions(true));

    context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);

    return context;
}
项目:ncl30-eclipse    文件:NCLDocumentFormattingStrategy.java   
/**
 * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
 */
public void formatterStarts(final IFormattingContext context) {
    super.formatterStarts(context);

    documents.addLast(context
            .getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
}
项目:gwt-eclipse-plugin    文件:AbstractFormattingStrategy.java   
@Override
public void formatterStarts(IFormattingContext context) {
  super.formatterStarts(context);

  IDocument document = (IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM);
  TypedPosition position = (TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION);

  partitions.addLast(position);
  documents.addLast(document);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaSourceViewer.java   
@Override
public IFormattingContext createFormattingContext() {

    // it's ok to use instance preferences here as subclasses replace
    // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer)
    IFormattingContext context= new JavaFormattingContext();
    Map<String, String> map= new HashMap<String, String>(JavaCore.getOptions());
    context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map);

    return context;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaFormattingStrategy.java   
@Override
public void formatterStarts(final IFormattingContext context) {
    super.formatterStarts(context);

    fPartitions.addLast((TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
    fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
}
项目:Eclipse-Postfix-Code-Completion    文件:CompilationUnitPreview.java   
@Override
protected void doFormatPreview() {
       if (fPreviewText == null) {
           fPreviewDocument.set(""); //$NON-NLS-1$
           return;
       }
       fPreviewDocument.set(fPreviewText);

    fSourceViewer.setRedraw(false);
    final IFormattingContext context = new JavaFormattingContext();
    try {
        final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
        if (formatter instanceof IContentFormatterExtension) {
            final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
            context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues);
            context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
            extension.format(fPreviewDocument, context);
        } else
            formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
    } catch (Exception e) {
        final IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
            FormatterMessages.JavaPreview_formatter_exception, e);
        JavaPlugin.log(status);
    } finally {
        context.dispose();
        fSourceViewer.setRedraw(true);
    }
   }
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaSourceViewer.java   
@Override
public IFormattingContext createFormattingContext() {

    // it's ok to use instance preferences here as subclasses replace
    // with project dependent versions (see CompilationUnitEditor.AdaptedSourceViewer)
    IFormattingContext context= new JavaFormattingContext();
    Map<String, String> map= new HashMap<String, String>(JavaCore.getOptions());
    context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, map);

    return context;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaFormattingStrategy.java   
@Override
public void formatterStarts(final IFormattingContext context) {
    super.formatterStarts(context);

    fPartitions.addLast((TypedPosition) context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
    fDocuments.addLast((IDocument) context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:CompilationUnitPreview.java   
@Override
protected void doFormatPreview() {
       if (fPreviewText == null) {
           fPreviewDocument.set(""); //$NON-NLS-1$
           return;
       }
       fPreviewDocument.set(fPreviewText);

    fSourceViewer.setRedraw(false);
    final IFormattingContext context = new JavaFormattingContext();
    try {
        final IContentFormatter formatter = fViewerConfiguration.getContentFormatter(fSourceViewer);
        if (formatter instanceof IContentFormatterExtension) {
            final IContentFormatterExtension extension = (IContentFormatterExtension) formatter;
            context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, fWorkingValues);
            context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.valueOf(true));
            extension.format(fPreviewDocument, context);
        } else
            formatter.format(fPreviewDocument, new Region(0, fPreviewDocument.getLength()));
    } catch (Exception e) {
        final IStatus status= new Status(IStatus.ERROR, JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR,
            FormatterMessages.JavaPreview_formatter_exception, e);
        JavaPlugin.log(status);
    } finally {
        context.dispose();
        fSourceViewer.setRedraw(true);
    }
   }
项目:gwt-eclipse-plugin    文件:IndependentMultiPassContentFormatter.java   
private void setToTempDocument(IFormattingContext context) {
  context.setProperty(FormattingContextProperties.CONTEXT_MEDIUM,
      tempDocument);
}
项目:APICloud-Studio    文件:CommonProjectionViewer.java   
@SuppressWarnings("rawtypes")
@Override
public IFormattingContext createFormattingContext()
{
    final IFormattingContext context = super.createFormattingContext();
    try
    {
        QualifiedContentType contentType = CommonEditorPlugin.getDefault().getDocumentScopeManager()
                .getContentType(getDocument(), 0);
        if (contentType != null && contentType.getPartCount() > 0)
        {
            for (String ct : contentType.getParts())
            {
                String mainContentType = ct;
                // We need to make sure that in case the given content type is actually a nested language in
                // HTML, we look for the HTML formatter factory because it should be the 'Master' formatter.
                if (mainContentType.startsWith(CommonSourceViewerConfiguration.CONTENTTYPE_HTML_PREFIX))
                {
                    mainContentType = CommonSourceViewerConfiguration.CONTENTTYPE_HTML_PREFIX;
                }
                final IScriptFormatterFactory factory = ScriptFormatterManager.getSelected(mainContentType);
                if (factory != null)
                {
                    // The code above might change the content type that is used to
                    // get the formatter, but we still need to save the original content-type so that the
                    // IScriptFormatter instance will handle the any required parsing by calling the right
                    // IParser.
                    factory.setMainContentType(contentType.getParts()[0]);

                    ITextEditor textEditor = (ITextEditor) getAdapter(ITextEditor.class);
                    if (textEditor != null)
                    {
                        IResource file = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
                        context.setProperty(ScriptFormattingContextProperties.CONTEXT_FORMATTER_ID, factory.getId());
                        IProject project = (file != null) ? file.getProject() : null;
                        Map preferences = factory.retrievePreferences(new PreferencesLookupDelegate(project));
                        context.setProperty(FormattingContextProperties.CONTEXT_PREFERENCES, preferences);
                    }
                    break;
                }
            }
        }
    }
    catch (BadLocationException e)
    {
    }
    return context;
}