Java 类org.eclipse.jface.text.source.SourceViewer 实例源码

项目:gw4e.project    文件:EdgeActionSection.java   
protected  SourceViewer createViewer (Composite composite) {
    SourceViewer viewer = ViewerHelper.createEditor(composite); 
    viewer.getControl().setData(WIDGET_ID, WIDGET_ACTION_SCRIPT);
    FocusListener listener = new FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
        }

        @Override
        public void focusLost(FocusEvent event) {
            if (!notification) return;
            if (viewer.getDocument() == null) return;
            String content  = viewer.getDocument().get();
            getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_ACTION, content);

        }
    };
    viewer.getControl().addFocusListener(listener);
    return viewer;
}
项目:gw4e.project    文件:EdgeGuardSection.java   
protected  SourceViewer createViewer (Composite composite) {
    SourceViewer viewer = ViewerHelper.createEditor(composite); 
    viewer.getControl().setData(WIDGET_ID, WIDGET_GUARD_SCRIPT);
    FocusListener listener = new FocusListener() {
        @Override
        public void focusGained(FocusEvent e) {
        }

        @Override
        public void focusLost(FocusEvent event) {
            if (!notification) return;
            if (viewer.getDocument() == null) return;
            String content  = viewer.getDocument().get();
            getProperties().setPropertyValue(ModelProperties.PROPERTY_EDGE_GUARD, content);
        }
    };
    viewer.getControl().addFocusListener(listener);
    return viewer;      
}
项目:tm4e    文件:TMPresentationReconciler.java   
/**
 * Returns the {@link TMPresentationReconciler} of the given text viewer and
 * null otherwise.
 * 
 * @param textViewer
 * @return the {@link TMPresentationReconciler} of the given text viewer and
 *         null otherwise.
 */
public static TMPresentationReconciler getTMPresentationReconciler(ITextViewer textViewer) {
    try {
        Field field = SourceViewer.class.getDeclaredField("fPresentationReconciler");
        if (field != null) {
            field.setAccessible(true);
            IPresentationReconciler presentationReconciler = (IPresentationReconciler) field.get(textViewer);
            return presentationReconciler instanceof TMPresentationReconciler
                    ? (TMPresentationReconciler) presentationReconciler
                    : null;
        }
    } catch (Exception e) {

    }
    return null;
}
项目:http4e    文件:ParameterizeTextView.java   
private StyledText buildEditorText( Composite parent){
   final SourceViewer sourceViewer = new SourceViewer(parent, null, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL);
   final HConfiguration sourceConf = new HConfiguration(HContentAssistProcessor.PARAM_PROCESSOR);
   sourceViewer.configure(sourceConf);
   sourceViewer.setDocument(DocumentUtils.createDocument1());

   sourceViewer.getControl().addKeyListener(new KeyAdapter() {

      public void keyPressed( KeyEvent e){
         // if ((e.character == ' ') && ((e.stateMask & SWT.CTRL) != 0)) {
         if (Utils.isAutoAssistInvoked(e)) {
            IContentAssistant ca = sourceConf.getContentAssistant(sourceViewer);
            ca.showPossibleCompletions();
         }
      }
   });

   return sourceViewer.getTextWidget();
}
项目:tlaplus    文件:ObligationsView.java   
/**
 * Removes the item from the view, performing necessary
 * cleanup.
 * 
 * @param item
 */
private void removeItem(ExpandItem item)
{
    // remove the source viewer's control from the
    // font listener since it no longer needs to be
    // notified of font changes.
    fontListener.removeControl(((SourceViewer) viewers.get(item)).getControl());

    // retrieve the id for the item
    // the id is stored in the item's data, which should be a marker,
    // as set in the updateItem method
    final Object data = item.getData(KEY);
    items.remove(Integer.parseInt(data.toString()));

    item.getControl().dispose();
    item.dispose();
}
项目:typescript.java    文件:TypeScriptTemplatePreferencePage.java   
protected SourceViewer createViewer(Composite parent) {
    IDocument document= new Document();
    JavaScriptTextTools tools= JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(document, IJavaScriptPartitions.JAVA_PARTITIONING);
    IPreferenceStore store= JSDTTypeScriptUIPlugin.getDefault().getCombinedPreferenceStore();
    SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
    SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaScriptPartitions.JAVA_PARTITIONING, false);
    viewer.configure(configuration);
    viewer.setEditable(false);
    viewer.setDocument(document);

    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    viewer.getTextWidget().setFont(font);
    new TypeScriptSourcePreviewerUpdater(viewer, configuration, store);

    Control control= viewer.getControl();
    GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    control.setLayoutData(data);

    return viewer;
}
项目:typescript.java    文件:TypeScriptMergeViewer.java   
@Override
protected void configureTextViewer(TextViewer viewer) {
    if (viewer instanceof SourceViewer) {
        SourceViewer sourceViewer = (SourceViewer) viewer;
        if (fSourceViewer == null)
            fSourceViewer = new ArrayList<>();
        if (!fSourceViewer.contains(sourceViewer))
            fSourceViewer.add(sourceViewer);
        TypeScriptTextTools tools = JSDTTypeScriptUIPlugin.getDefault().getJavaTextTools();
        if (tools != null) {
            IEditorInput editorInput = getEditorInput(sourceViewer);
            sourceViewer.unconfigure();
            if (editorInput == null) {
                sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
                return;
            }
            getSourceViewerConfiguration(sourceViewer, editorInput);
        }
    }
}
项目:typescript.java    文件:TypeScriptMergeViewer.java   
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
    if (fEditor != null) {
        Object editor = fEditor.get(sourceViewer);
        if (editor instanceof TypeScriptEditorAdapter) {
            TypeScriptEditorAdapter cuea = (TypeScriptEditorAdapter) editor;
            cuea.setActionsActivated(state);

            IAction saveAction = cuea.getAction(ITextEditorActionConstants.SAVE);
            if (saveAction instanceof IPageListener) {
                PartEventAction partEventAction = (PartEventAction) saveAction;
                IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart();
                if (state)
                    partEventAction.partActivated(compareEditorPart);
                else
                    partEventAction.partDeactivated(compareEditorPart);
            }
        }
    }
}
项目:bts    文件:E4TemplatePreferencePage.java   
/**
 * Creates the viewer to be used to display the pattern. Subclasses may override.
 *
 * @param parent the parent composite of the viewer
 * @return a configured <code>SourceViewer</code>
 */
protected SourceViewer createViewer(Composite parent) {
    SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    SourceViewerConfiguration configuration= new SourceViewerConfiguration() {
        @Override
        public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {

            ContentAssistant assistant= new ContentAssistant();
            assistant.enableAutoActivation(true);
            assistant.enableAutoInsert(true);
            assistant.setContentAssistProcessor(fTemplateProcessor, IDocument.DEFAULT_CONTENT_TYPE);
            return assistant;
        }
    };
    viewer.configure(configuration);
    return viewer;
}
项目:bts    文件:E4TemplatePreferencePage.java   
private SourceViewer doCreateViewer(Composite parent) {
        Label label= new Label(parent, SWT.NONE);
        label.setText(TemplatesMessages.TemplatePreferencePage_preview);
        GridData data= new GridData();
        data.horizontalSpan= 2;
        label.setLayoutData(data);

        SourceViewer viewer= createViewer(parent);

        viewer.setEditable(false);
        Cursor arrowCursor= viewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
        viewer.getTextWidget().setCursor(arrowCursor);

        // Don't set caret to 'null' as this causes https://bugs.eclipse.org/293263
//      viewer.getTextWidget().setCaret(null);

        Control control= viewer.getControl();
        data= new GridData(GridData.FILL_BOTH);
        data.horizontalSpan= 2;
        data.heightHint= convertHeightInCharsToPixels(5);
        control.setLayoutData(data);

        return viewer;
    }
项目:bts    文件:DefaultMergeViewer.java   
protected void configureSourceViewer(SourceViewer sourceViewer) {
    IEditorInput editorInput = getEditorInput(sourceViewer);
    SourceViewerConfiguration sourceViewerConfiguration = createSourceViewerConfiguration(sourceViewer, editorInput);
    sourceViewer.unconfigure();
    sourceViewer.configure(sourceViewerConfiguration);
    if (sourceViewer.getDocument() instanceof IXtextDocument) {
        IXtextDocument xtextDocument = (IXtextDocument) sourceViewer.getDocument();
        if (!xtextDocument.readOnly(TEST_EXISTING_XTEXT_RESOURCE)) {
            String[] configuredContentTypes = sourceViewerConfiguration.getConfiguredContentTypes(sourceViewer);
            for (String contentType : configuredContentTypes) {
                sourceViewer.removeTextHovers(contentType);
            }
            sourceViewer.setHyperlinkDetectors(null, sourceViewerConfiguration.getHyperlinkStateMask(sourceViewer));
        }
    }
}
项目:bts    文件:DefaultMergeViewer.java   
protected SourceViewerConfiguration createSourceViewerConfiguration(SourceViewer sourceViewer,
        IEditorInput editorInput) {
    SourceViewerConfiguration sourceViewerConfiguration = null;
    if (editorInput != null && getEditor(sourceViewer) != null) {
        DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
        sourceViewerConfiguration = mergeEditor.getXtextSourceViewerConfiguration();
        try {
            mergeEditor.init((IEditorSite) mergeEditor.getSite(), editorInput);
            mergeEditor.createActions();
        } catch (PartInitException partInitException) {
            throw new WrappedException(partInitException);
        }
    } else {
        sourceViewerConfiguration = sourceViewerConfigurationProvider.get();
    }
    return sourceViewerConfiguration;
}
项目:bts    文件:DefaultMergeViewer.java   
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
    DefaultMergeEditor mergeEditor = getEditor(sourceViewer);
    if (mergeEditor != null) {
        mergeEditor.setActionsActivated(state);
        IAction saveAction = mergeEditor.getAction(ITextEditorActionConstants.SAVE);
        if (saveAction instanceof IPageListener) {
            PartEventAction partEventAction = (PartEventAction) saveAction;
            IWorkbenchPart compareEditorPart = getCompareConfiguration().getContainer().getWorkbenchPart();
            if (state) {
                partEventAction.partActivated(compareEditorPart);
            } else {
                partEventAction.partDeactivated(compareEditorPart);
            }
        }
    }
}
项目:bts    文件:DefaultMergeViewer.java   
@Override
protected SourceViewer createSourceViewer(Composite parent, int textOrientation) {
    if (getSite() != null) {
        if (sourceViewerEditorMap == null) {
            sourceViewerEditorMap = Maps.newHashMapWithExpectedSize(3);
        }
        DefaultMergeEditor mergeEditor = createMergeEditor();
        mergeEditor.setXtextEditorCallback(new CompoundXtextEditorCallback(null));
        mergeEditor.setTextOrientation(textOrientation);
        mergeEditor.setInternalSite(getSite());
        mergeEditor.createPartControl(parent);
        SourceViewer internalSourceViewer = (SourceViewer) mergeEditor.getInternalSourceViewer();
        sourceViewerEditorMap.put(internalSourceViewer, mergeEditor);
        return internalSourceViewer;
    }

    return super.createSourceViewer(parent, textOrientation);
}
项目:bts    文件:EmbeddedEditorFactory.java   
protected OperationHistoryListener installUndoRedoSupport(SourceViewer viewer, IDocument document, final EmbeddedEditorActions actions) {
            IDocumentUndoManager undoManager = DocumentUndoManagerRegistry.getDocumentUndoManager(document);
            final IUndoContext context = undoManager.getUndoContext();

            // XXX cp uncommented

//          IOperationHistory operationHistory = PlatformUI.getWorkbench().getOperationSupport().getOperationHistory();
            OperationHistoryListener operationHistoryListener = new OperationHistoryListener(context, new IUpdate() {
                public void update() {
                    actions.updateAction(ITextEditorActionConstants.REDO);
                    actions.updateAction(ITextEditorActionConstants.UNDO);
                }
            });
            viewer.addTextListener(new ITextListener() {

                public void textChanged(TextEvent event) {
                    actions.updateAction(ITextEditorActionConstants.REDO);
                    actions.updateAction(ITextEditorActionConstants.UNDO);

                }
            });
//          
//          operationHistory.addOperationHistoryListener(operationHistoryListener);
            return operationHistoryListener;
        }
项目:LogViewer    文件:LogFileViewer.java   
public LogFileViewer(Composite parent, int style) {
    store = LogViewerPlugin.getDefault().getPreferenceStore();
    if (store.getBoolean(ILogViewerConstants.PREF_WORD_WRAP))
        style |= SWT.WRAP;
    showWhenUpdated = store.getBoolean(ILogViewerConstants.PREF_SHOW_WHEN_UPDATED);
    showTopOfFile = store.getBoolean(ILogViewerConstants.PREF_SHOW_TOP_OF_FILE);
    txtViewer = new SourceViewer(parent,null,style);
    FontData[] fontData = PreferenceConverter.getFontDataArray(store,ILogViewerConstants.PREF_EDITOR_FONT_STYLE);
    if(fontData == null) {
        fontData = JFaceResources.getDefaultFont().getFontData();
    }
    txtViewer.getTextWidget().setFont(new Font(Display.getCurrent(),fontData));
    propertyChangeListener = new PropertyChangeListener();
    store.addPropertyChangeListener(propertyChangeListener);
    createCursorLinePainter();
    createAndInstallPresentationReconciler();
}
项目:APICloud-Studio    文件:AbstractFormatterSelectionBlock.java   
public AbstractFormatterSelectionBlock(IStatusChangeListener context, IProject project,
        IWorkbenchPreferenceContainer container)
{
    super(context, project, ProfileManager.collectPreferenceKeys(TEMP_LIST, true), container);
    Collections.sort(TEMP_LIST, new Comparator<IScriptFormatterFactory>()
    {
        public int compare(IScriptFormatterFactory s1, IScriptFormatterFactory s2)
        {
            return s1.getName().compareToIgnoreCase(s2.getName());
        }
    });
    factories = TEMP_LIST.toArray(new IScriptFormatterFactory[TEMP_LIST.size()]);
    TEMP_LIST = new ArrayList<IScriptFormatterFactory>();
    sourcePreviewViewers = new ArrayList<SourceViewer>();

    // Override the super preferences lookup order.
    // All the changes to the formatter settings should go to the instance scope (no project scope here). Only the
    // selected profile will be picked from the project scope and then the instance scope when requested.
    fLookupOrder = new IScopeContext[] { EclipseUtil.instanceScope(), EclipseUtil.defaultScope() };
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaTemplatesPage.java   
@Override
protected SourceViewer createPatternViewer(Composite parent) {
    IDocument document= new Document();
    JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
    IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
    JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
    SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
    viewer.configure(configuration);
    viewer.setEditable(false);
    viewer.setDocument(document);

    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    viewer.getTextWidget().setFont(font);
    new JavaSourcePreviewerUpdater(viewer, configuration, store);

    Control control= viewer.getControl();
    GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    control.setLayoutData(data);

    viewer.setEditable(false);
    return viewer;
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaTemplatePreferencePage.java   
@Override
protected SourceViewer createViewer(Composite parent) {
    IDocument document= new Document();
    JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
    IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
    SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
    SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
    viewer.configure(configuration);
    viewer.setEditable(false);
    viewer.setDocument(document);

    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    viewer.getTextWidget().setFont(font);
    new JavaSourcePreviewerUpdater(viewer, configuration, store);

    Control control= viewer.getControl();
    GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    control.setLayoutData(data);

    return viewer;
}
项目:Eclipse-Postfix-Code-Completion    文件:PropertiesFileMergeViewer.java   
@Override
protected void configureTextViewer(TextViewer textViewer) {
    if (!(textViewer instanceof SourceViewer))
        return;

    if (fPreferenceStore == null) {
        fSourceViewerConfigurations= new ArrayList<SourceViewerConfiguration>(3);
        fPreferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore();
        fPreferenceChangeListener= new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                Iterator<SourceViewerConfiguration> iter= fSourceViewerConfigurations.iterator();
                while (iter.hasNext())
                    ((PropertiesFileSourceViewerConfiguration)iter.next()).handlePropertyChangeEvent(event);
                invalidateTextPresentation();
            }
        };
        fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
    }

    SourceViewerConfiguration sourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), fPreferenceStore, null,
            getDocumentPartitioning());

    fSourceViewerConfigurations.add(sourceViewerConfiguration);
    ((SourceViewer)textViewer).configure(sourceViewerConfiguration);
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaTextViewer.java   
JavaTextViewer(Composite parent) {
    fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
    JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
    if (tools != null) {
        IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
        fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING));
    }

    fSourceViewer.setEditable(false);

    String symbolicFontName= JavaMergeViewer.class.getName();
    Font font= JFaceResources.getFont(symbolicFontName);
    if (font != null)
        fSourceViewer.getTextWidget().setFont(font);

}
项目:Eclipse-Postfix-Code-Completion    文件:JavaMergeViewer.java   
@Override
protected void configureTextViewer(TextViewer viewer) {
    if (viewer instanceof SourceViewer) {
        SourceViewer sourceViewer= (SourceViewer)viewer;
        if (fSourceViewer == null)
            fSourceViewer= new ArrayList<SourceViewer>();
        if (!fSourceViewer.contains(sourceViewer))
            fSourceViewer.add(sourceViewer);
        JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
        if (tools != null) {
            IEditorInput editorInput= getEditorInput(sourceViewer);
            sourceViewer.unconfigure();
            if (editorInput == null) {
                sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
                return;
            }
            getSourceViewerConfiguration(sourceViewer, editorInput);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion    文件:JavaMergeViewer.java   
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
    if (fEditor != null) {
        Object editor= fEditor.get(sourceViewer);
        if (editor instanceof CompilationUnitEditorAdapter) {
            CompilationUnitEditorAdapter cuea = (CompilationUnitEditorAdapter)editor;
            cuea.setActionsActivated(state);

            IAction saveAction= cuea.getAction(ITextEditorActionConstants.SAVE);
            if (saveAction instanceof IPageListener) {
                PartEventAction partEventAction = (PartEventAction) saveAction;
                IWorkbenchPart compareEditorPart= getCompareConfiguration().getContainer().getWorkbenchPart();
                if (state)
                    partEventAction.partActivated(compareEditorPart);
                else
                    partEventAction.partDeactivated(compareEditorPart);
            }
        }
    }
}
项目:editorconfig-eclipse    文件:SyntaxColoringPreferencePage.java   
private Control createPreviewer(Composite parent) {

        IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { fOverlayStore,
                EditorConfigUIPlugin.getDefault().getCombinedPreferenceStore() });
        fPreviewViewer = new SourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
        fColorManager = new EditorConfigColorManager(false);
        EditorConfigSourceViewerConfiguration configuration = new EditorConfigSourceViewerConfiguration(fColorManager,
                store, null, IEditorConfigPartitions.EDITOR_CONFIG_PARTITIONING);
        fPreviewViewer.configure(configuration);
        Font font = JFaceResources.getFont(PreferenceConstants.EDITOR_CONFIG_EDITOR_TEXT_FONT);
        fPreviewViewer.getTextWidget().setFont(font);
        new SourcePreviewerUpdater(fPreviewViewer, configuration, store);
        fPreviewViewer.setEditable(false);

        String content = loadPreviewContentFromFile("EditorConfigEditorColorSettingPreviewCode.txt"); //$NON-NLS-1$
        IDocument document = new Document(content);
        EditorConfigDocumentSetupParticipant.setupDocument(document);
        fPreviewViewer.setDocument(document);

        return fPreviewViewer.getControl();
    }
项目:idecore    文件:ApexCodeTemplateSelectionPage.java   
/**
 * Creates, configures and returns a source viewer to present the template
 * pattern on the preference page. Clients may override to provide a
 * custom source viewer featuring e.g. syntax coloring.
 * 
 * @param parent
 *            the parent control
 * @return a configured source viewer
 */
@Override
protected final SourceViewer createViewer(Composite parent) {
    final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null);
    configuration.init(this.componentModel.getProject());

    final IDocument document = new Document();
    new ApexDocumentSetupParticipant().setup(document);

    SourceViewer viewer= new SourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
    viewer.configure(configuration);
    viewer.setDocument(document);

    viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    viewer.setEditable(false);

    return viewer;
}
项目:idecore    文件:AbstractTemplateSelectionPage.java   
private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(NewWizardMessages.WizardPage_4);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);

    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.heightHint = convertHeightInCharsToPixels(5);
    // [261274] - source viewer was growing to fit the max line width of the template
    data.widthHint = convertWidthInCharsToPixels(2);
    control.setLayoutData(data);

    return viewer;
}
项目:idecore    文件:ApexTemplatePreferencePage.java   
@Override
protected SourceViewer createViewer(Composite parent) {
    final SourceViewer viewer = super.createViewer(parent);

    new ApexDocumentSetupParticipant().setup(viewer.getDocument());

    final ApexSourceViewerConfiguration configuration = new ApexSourceViewerConfiguration(preferenceStore(), null);
    configuration.init(null);
    viewer.unconfigure();
    viewer.configure(configuration);

    viewer.getTextWidget().setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
    viewer.setEditable(false);

    return viewer;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaTemplatesPage.java   
@Override
protected SourceViewer createPatternViewer(Composite parent) {
    IDocument document= new Document();
    JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
    IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
    JavaSourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL, store);
    SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
    viewer.configure(configuration);
    viewer.setEditable(false);
    viewer.setDocument(document);

    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    viewer.getTextWidget().setFont(font);
    new JavaSourcePreviewerUpdater(viewer, configuration, store);

    Control control= viewer.getControl();
    GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    control.setLayoutData(data);

    viewer.setEditable(false);
    return viewer;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaTemplatePreferencePage.java   
@Override
protected SourceViewer createViewer(Composite parent) {
    IDocument document= new Document();
    JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
    tools.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
    IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
    SourceViewer viewer= new JavaSourceViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL, store);
    SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING, false);
    viewer.configure(configuration);
    viewer.setEditable(false);
    viewer.setDocument(document);

    Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
    viewer.getTextWidget().setFont(font);
    new JavaSourcePreviewerUpdater(viewer, configuration, store);

    Control control= viewer.getControl();
    GridData data= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
    control.setLayoutData(data);

    return viewer;
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:PropertiesFileMergeViewer.java   
@Override
protected void configureTextViewer(TextViewer textViewer) {
    if (!(textViewer instanceof SourceViewer))
        return;

    if (fPreferenceStore == null) {
        fSourceViewerConfigurations= new ArrayList<SourceViewerConfiguration>(3);
        fPreferenceStore= JavaPlugin.getDefault().getCombinedPreferenceStore();
        fPreferenceChangeListener= new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                Iterator<SourceViewerConfiguration> iter= fSourceViewerConfigurations.iterator();
                while (iter.hasNext())
                    ((PropertiesFileSourceViewerConfiguration)iter.next()).handlePropertyChangeEvent(event);
                invalidateTextPresentation();
            }
        };
        fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
    }

    SourceViewerConfiguration sourceViewerConfiguration= new PropertiesFileSourceViewerConfiguration(JavaPlugin.getDefault().getJavaTextTools().getColorManager(), fPreferenceStore, null,
            getDocumentPartitioning());

    fSourceViewerConfigurations.add(sourceViewerConfiguration);
    ((SourceViewer)textViewer).configure(sourceViewerConfiguration);
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaTextViewer.java   
JavaTextViewer(Composite parent) {
    fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
    JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
    if (tools != null) {
        IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
        fSourceViewer.configure(new JavaSourceViewerConfiguration(tools.getColorManager(), store, null, IJavaPartitions.JAVA_PARTITIONING));
    }

    fSourceViewer.setEditable(false);

    String symbolicFontName= JavaMergeViewer.class.getName();
    Font font= JFaceResources.getFont(symbolicFontName);
    if (font != null)
        fSourceViewer.getTextWidget().setFont(font);

}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaMergeViewer.java   
@Override
protected void configureTextViewer(TextViewer viewer) {
    if (viewer instanceof SourceViewer) {
        SourceViewer sourceViewer= (SourceViewer)viewer;
        if (fSourceViewer == null)
            fSourceViewer= new ArrayList<SourceViewer>();
        if (!fSourceViewer.contains(sourceViewer))
            fSourceViewer.add(sourceViewer);
        JavaTextTools tools= JavaCompareUtilities.getJavaTextTools();
        if (tools != null) {
            IEditorInput editorInput= getEditorInput(sourceViewer);
            sourceViewer.unconfigure();
            if (editorInput == null) {
                sourceViewer.configure(getSourceViewerConfiguration(sourceViewer, null));
                return;
            }
            getSourceViewerConfiguration(sourceViewer, editorInput);
        }
    }
}
项目:Eclipse-Postfix-Code-Completion-Juno38    文件:JavaMergeViewer.java   
@Override
protected void setActionsActivated(SourceViewer sourceViewer, boolean state) {
    if (fEditor != null) {
        Object editor= fEditor.get(sourceViewer);
        if (editor instanceof CompilationUnitEditorAdapter) {
            CompilationUnitEditorAdapter cuea = (CompilationUnitEditorAdapter)editor;
            cuea.setActionsActivated(state);

            IAction saveAction= cuea.getAction(ITextEditorActionConstants.SAVE);
            if (saveAction instanceof IPageListener) {
                PartEventAction partEventAction = (PartEventAction) saveAction;
                IWorkbenchPart compareEditorPart= getCompareConfiguration().getContainer().getWorkbenchPart();
                if (state)
                    partEventAction.partActivated(compareEditorPart);
                else
                    partEventAction.partDeactivated(compareEditorPart);
            }
        }
    }
}
项目:birt    文件:JSEditor.java   
/**
 * Saves input code to model
 */
private void saveModel( )
{
    if ( isCodeModified( ) && editObject instanceof DesignElementHandle )
    {
        saveEditorContentsDE( (DesignElementHandle) editObject,
                isSaveScript );
    }

    setIsModified( false );

    ( (IFormPage) getParentEditor( ) ).getEditor( )
            .editorDirtyStateChanged( );

    firePropertyChange( PROP_DIRTY );

    SourceViewer viewer = getViewer( );
    IUndoManager undoManager = viewer == null ? null
            : viewer.getUndoManager( );

    if ( undoManager != null )
    {
        undoManager.endCompoundChange( );
    }
    cleanPoint = getUndoLevel( );
}
项目:glassmaker    文件:NewCardTemplatesWizardPage.java   
private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText("Preview");
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);

    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 1;
    data.verticalSpan=2;
    data.heightHint = convertHeightInCharsToPixels(5);
    // [261274] - source viewer was growing to fit the max line width of the template
    data.widthHint = convertWidthInCharsToPixels(2);
    control.setLayoutData(data);

    fImage=new Label(parent, SWT.NONE);
    fImage.setLayoutData(data);

    return viewer;
}
项目:Pydev    文件:PyContentViewer.java   
PyContentViewer(Composite parent, CompareConfiguration mp) {
    fSourceViewer = new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
    IPreferenceStore store = PydevPrefs.getChainedPrefStore();

    final ColorAndStyleCache c = new ColorAndStyleCache(store);

    // Ideally we wouldn't pass null for the grammarVersionProvider... although
    // I haven't been able to get to this code at all (is this something still needed?)
    // It seems that Eclipse (in 4.5m5 at least) never gets to use the org.eclipse.compare.contentViewers
    // as it seems to use what's provided by org.eclipse.compare.contentMergeViewers or the
    // editor directly... if that's not the case, first we need to discover how that's still needed.
    fSourceViewer.configure(new PyEditConfigurationWithoutEditor(c, store, null));

    fSourceViewer.setEditable(false);
    parent.addDisposeListener(new DisposeListener() {

        @Override
        public void widgetDisposed(DisposeEvent e) {
            c.dispose();
        }
    });
}
项目:Pydev    文件:PyPresentationReconciler.java   
/**
 * Important: update only asynchronously...
 */
public void invalidateTextPresentation() {
    if (viewer != null) {
        RunInUiThread.async(new Runnable() {

            @Override
            public void run() {
                ITextViewer v = viewer;
                if (v != null && v instanceof SourceViewer) {
                    SourceViewer sourceViewer = (SourceViewer) v;
                    StyledText textWidget = sourceViewer.getTextWidget();
                    if (textWidget != null && !textWidget.isDisposed()) {
                        sourceViewer.invalidateTextPresentation();
                    }
                }
            }
        });
    }
}
项目:eclipse-silverstripedt    文件:NewSilverStripeTemplatesWizardPage.java   
private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(HTMLUIMessages.NewHTMLTemplatesWizardPage_5);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);

    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.heightHint = convertHeightInCharsToPixels(5);
    // [261274] - source viewer was growing to fit the max line width of the template
    data.widthHint = convertWidthInCharsToPixels(2);
    control.setLayoutData(data);

    return viewer;
}
项目:eclipse-silverstripedt    文件:NewSilverStripeClassWizardTemplatePage.java   
private SourceViewer doCreateViewer(Composite parent) {
    Label label = new Label(parent, SWT.NONE);
    label.setText(Messages.NewGenericFileTemplatesWizardPage_2);
    GridData data = new GridData();
    data.horizontalSpan = 2;
    label.setLayoutData(data);

    SourceViewer viewer = createViewer(parent);
    viewer.setEditable(false);

    Control control = viewer.getControl();
    data = new GridData(GridData.FILL_BOTH);
    data.horizontalSpan = 2;
    data.heightHint = convertHeightInCharsToPixels(5);
    control.setLayoutData(data);

    return viewer;
}
项目:goclipse    文件:LangTemplatePreferencePage.java   
@Override
protected SourceViewer createViewer(Composite parent) {
    LangSourceViewer viewer = new LangSourceViewer(parent, null, null, false,
        SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);

    final IContentAssistProcessor templateProcessor = getTemplateProcessor();

    IDocument document = new Document();
    LangDocumentPartitionerSetup.getInstance().setup(document);

    IPreferenceStore store = LangUIPlugin.getDefault().getCombinedPreferenceStore();
    SourceViewerConfiguration configuration = EditorSettings_Actual
            .createTemplateEditorSourceViewerConfiguration(store, templateProcessor);
    viewer.configure(configuration);
    viewer.setEditable(true);
    viewer.setDocument(document);

    return viewer;
}