类org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants源码实例Demo

下面列出了怎么用org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: APICloud-Studio   文件: ThemeManager.java
/**
 * Set the FG, BG, selection and current line colors on our editors.
 * 
 * @param theme
 */
private void setAptanaEditorColorsToMatchTheme(Theme theme)
{
	IEclipsePreferences prefs = EclipseUtil.instanceScope().getNode("com.aptana.editor.common"); //$NON-NLS-1$
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, toString(theme.getForeground()));

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, toString(theme.getBackground()));

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, false);
	prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, toString(theme.getForeground()));

	prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
			toString(theme.getLineHighlightAgainstBG()));
	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
public void handlePreferenceStoreChanged(PropertyChangeEvent event)
{
	if (event.getProperty().equals(IThemeManager.THEME_CHANGED))
	{
		IThemeableEditor editor = this.fEditor.get();
		overrideThemeColors();
		if (editor != null)
		{
			editor.getISourceViewer().invalidateTextPresentation();
		}
	}
	else if (event.getProperty().equals(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE))
	{
		Object newValue = event.getNewValue();
		if (newValue instanceof Boolean)
		{
			boolean on = (Boolean) newValue;
			fFullLineBackgroundPainter.setHighlightLineEnabled(on);
		}
	}
	else if (event.getProperty().equals(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT))
	{
		overrideRulerColors();
	}
}
 
/**
 * @return the default indentation string (either tab or spaces which represents a tab)
 */
public String getIndent()
{
	boolean useSpaces = fPreferenceStore
			.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);

	if (useSpaces)
	{
		int tabWidth = fPreferenceStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
		StringBuilder buf = new StringBuilder();

		for (int i = 0; i < tabWidth; ++i)
		{
			buf.append(' ');
		}

		return buf.toString();
	}

	return "\t"; //$NON-NLS-1$
}
 
private void setTabSpaceCombo()
{
	IEclipsePreferences store = getPluginPreferenceStore();

	if (store.getBoolean(IPreferenceConstants.USE_GLOBAL_DEFAULTS, false))
	{
		tabSpaceCombo.setText(Messages.CommonEditorPreferencePage_UseDefaultOption);
	}
	else
	{
		boolean useSpaces = store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS,
				true);
		tabSpaceCombo.setText(useSpaces ? Messages.CommonEditorPreferencePage_UseSpacesOption
				: Messages.CommonEditorPreferencePage_UseTabOption);
	}
}
 
@Override
protected void performDefaults()
{
	IEclipsePreferences store = getPluginPreferenceStore();

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);

	setPluginDefaults();
	setTabSpaceCombo();
	super.performDefaults();
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
/**
 * This method re-applies the plugin defaults for the spaces for tabs and tab width preferences from the default
 * scope of the plugin preference store. The default values are taken from getDefaultTabWidth() and
 * getDefaultSpacesForTabs(). The default scope getDefaultPluginPreferenceStore() is used.
 */
protected void setPluginDefaults()
{
	IEclipsePreferences store = getDefaultPluginPreferenceStore();
	if (store == null)
	{
		return;
	}

	store.putBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS,
			getDefaultSpacesForTabs());
	store.putInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, getDefaultTabWidth());
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
/**
 * This method removes the spaces for tabs and tab width preferences from the default scope of the plugin preference
 * store.
 */
protected void removePluginDefaults()
{
	IEclipsePreferences store = getDefaultPluginPreferenceStore();
	if (store == null)
	{
		return;
	}

	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
}
 
@Override
protected void initializeEditor() {
	setDocumentProvider(JavaPlugin.getDefault().getPropertiesFileDocumentProvider());
	IPreferenceStore store= JavaPlugin.getDefault().getCombinedPreferenceStore();
	setPreferenceStore(store);
	JavaTextTools textTools= JavaPlugin.getDefault().getJavaTextTools();
	setSourceViewerConfiguration(new PropertiesFileSourceViewerConfiguration(textTools.getColorManager(), store, this, IPropertiesFilePartitions.PROPERTIES_FILE_PARTITIONING));
	setEditorContextMenuId("#TextEditorContext"); //$NON-NLS-1$
	setRulerContextMenuId("#TextRulerContext"); //$NON-NLS-1$
	setHelpContextId(ITextEditorHelpContextIds.TEXT_EDITOR);
	configureInsertMode(SMART_INSERT, false);
	setInsertMode(INSERT);

	// Need to listen on Editors UI preference store because JDT disables this functionality in its preferences.
	fPropertyChangeListener= new IPropertyChangeListener() {
		public void propertyChange(PropertyChangeEvent event) {
			if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(event.getProperty()))
				handlePreferenceStoreChanged(event);
		}
	};
	EditorsUI.getPreferenceStore().addPropertyChangeListener(fPropertyChangeListener);
}
 
源代码9 项目: Pydev   文件: AbstractBlockCommentAction.java
/**
 * @return the number of columns to be used (and the char too)
 */
public Tuple<Integer, Character> getColsAndChar() {
    int cols = this.defaultCols;
    char c = '-';

    if (SharedCorePlugin.inTestMode()) {
        // use defaults
    } else {
        IPreferenceStore chainedPrefStore = PyDevUiPrefs.getChainedPrefStore();
        cols = chainedPrefStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);

        IPreferenceStore prefs = PyDevUiPrefs.getPreferenceStore();
        c = prefs.getString(getPreferencesNameForChar()).charAt(0);
    }
    return new Tuple<Integer, Character>(cols, c);
}
 
源代码10 项目: Pydev   文件: ImportArranger.java
/**
 * @return the maximum number of columns that may be available in a line.
 */
private static int getMaxCols(boolean multilineImports) {
    final int maxCols;
    if (multilineImports) {
        if (SharedCorePlugin.inTestMode()) {
            maxCols = 80;
        } else {
            IPreferenceStore chainedPrefStore = PyDevUiPrefs.getChainedPrefStore();
            maxCols = chainedPrefStore
                    .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
        }
    } else {
        maxCols = Integer.MAX_VALUE;
    }
    return maxCols;
}
 
源代码11 项目: goclipse   文件: ViewerColorUpdater.java
@Override
protected void doConfigureViewer() {
	// ----------- foreground color --------------------
	fForegroundColor = updateColorFromSetting(fForegroundColor,
		AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT,
		AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
	styledText.setForeground(fForegroundColor);
	
	// ---------- background color ----------------------
	fBackgroundColor = updateColorFromSetting(fBackgroundColor,
		AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT,
		AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
	styledText.setBackground(fBackgroundColor);
	
	// ----------- selection foreground color --------------------
	fSelectionForegroundColor = updateColorFromSetting(fSelectionForegroundColor,
		AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR,
		AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR);
	styledText.setSelectionForeground(fSelectionForegroundColor);
	
	// ---------- selection background color ----------------------
	fSelectionBackgroundColor = updateColorFromSetting(fSelectionBackgroundColor,
		AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR,
		AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR);
	styledText.setSelectionBackground(fSelectionBackgroundColor);
}
 
@Override
public synchronized void propertyChange(PropertyChangeEvent event) {
	String property = event.getProperty();
	if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)
			|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS.equals(property)) {
		indentString = null;
	}
}
 
源代码13 项目: texlipse   文件: TexHardLineWrapAction.java
/** 
 * When the user presses <code>Esc, q</code> or selects from menu bar
 * <code>Wrap Lines</code> this method is invoked.
 * @param action	an action that invokes  
 * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
 */
public void run(IAction action) {
    this.lineLength = TexlipsePlugin.getDefault().getPreferenceStore().getInt(TexlipseProperties.WORDWRAP_LENGTH);
    this.tabWidth = TexlipsePlugin.getDefault().getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
    TexSelections selection = new TexSelections(getTexEditor());
    try {
        doWrapB(selection);
    } catch(BadLocationException e) {
        TexlipsePlugin.log("TexCorrectIndentationAction.run", e);
    }
}
 
源代码14 项目: xds-ide   文件: ModulaEditor.java
/**
 * {@inheritDoc}
 */
@Override
protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
    String property= event.getProperty();
    if (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
        // Ignore common editor tabs size, use our tabs from formatter settings
        return;
    }
    super.handlePreferenceStoreChanged(event); 
}
 
源代码15 项目: xtext-xtend   文件: DerivedSourceView.java
@Override
protected void inititalizeColors() {
	IPreferenceStore store = preferenceStoreAccess.getPreferenceStore();
	getColorRegistry().addListener(this);
	StyledText textWidget = getSourceViewer().getTextWidget();
	textWidget.setForeground(
			getColorFromStore(store, 
					AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, 
					SWT.COLOR_WIDGET_FOREGROUND, 
					AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND));
	textWidget.setBackground(
			getColorFromStore(store, 
					AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, 
					SWT.COLOR_INFO_BACKGROUND, 
					AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND));

	lineNumberRulerColumn.setForeground(
			getColorFromStore(store, 
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR,
					SWT.COLOR_WIDGET_FOREGROUND,
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
	lineNumberRulerColumn.setBackground(
			getColorFromStore(store, 
					AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, 
					SWT.COLOR_WIDGET_BACKGROUND, 
					AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND));
	lineNumberRulerColumn.setFont(getFont(getViewerFontName()));
}
 
源代码16 项目: xtext-xtend   文件: XtendFormatterPreview.java
public XtendFormatterPreview forEmbeddedEditor(EmbeddedEditor editorHandle) {
	if (this.editorHandle != null) {
		throw new IllegalStateException("This formatter preview is already binded to an embedet editor");
	}
	this.editorHandle = editorHandle;
	this.modelAccess = editorHandle.createPartialEditor();
	this.marginPainter = new MarginPainter(editorHandle.getViewer());
	final RGB rgb = PreferenceConverter.getColor(preferenceStoreAccess.getPreferenceStore(),
			AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
	marginPainter.setMarginRulerColor(EditorUtils.colorFromRGB(rgb));
	editorHandle.getViewer().addPainter(marginPainter);
	return this;
}
 
源代码17 项目: APICloud-Studio   文件: InvasiveThemeHijacker.java
protected void setGeneralEditorValues(Theme theme, IEclipsePreferences prefs, boolean revertToDefaults)
{
	if (prefs == null)
		return;
	if (revertToDefaults)
	{
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
		prefs.remove(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
		prefs.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR);
	}
	else
	{
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND,
				StringConverter.asString(theme.getSelectionAgainstBG()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND,
				StringConverter.asString(theme.getForeground()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, StringConverter.asString(theme.getBackground()));
		prefs.put(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, StringConverter.asString(theme.getForeground()));
		prefs.put(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR,
				StringConverter.asString(theme.getLineHighlightAgainstBG()));
	}

	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT, revertToDefaults);
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, revertToDefaults);
	prefs.putBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, revertToDefaults);

	try
	{
		prefs.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(ThemePlugin.getDefault(), e);
	}
}
 
源代码18 项目: APICloud-Studio   文件: ThemeableEditorExtension.java
public void createBackgroundPainter(ISourceViewer viewer)
{
	if (fFullLineBackgroundPainter == null)
	{
		if (viewer instanceof ITextViewerExtension2)
		{
			boolean lineHighlight = Platform.getPreferencesService().getBoolean(EditorsUI.PLUGIN_ID,
					AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true, null);
			fFullLineBackgroundPainter = new LineBackgroundPainter(viewer);
			fFullLineBackgroundPainter.setHighlightLineEnabled(lineHighlight);
			ITextViewerExtension2 extension = (ITextViewerExtension2) viewer;
			extension.addPainter(fFullLineBackgroundPainter);
		}
	}
}
 
public boolean performOk()
{
	IEclipsePreferences store = getPluginPreferenceStore();

	if (tabSpaceCombo.getText().equals(Messages.CommonEditorPreferencePage_UseSpacesOption))
	{
		store.putBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, true);
		store.putBoolean(IPreferenceConstants.USE_GLOBAL_DEFAULTS, false);
	}
	else if (tabSpaceCombo.getText().equals(Messages.CommonEditorPreferencePage_UseTabOption))
	{
		store.putBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS, false);
		store.putBoolean(IPreferenceConstants.USE_GLOBAL_DEFAULTS, false);
	}
	else
	{
		removePluginDefaults();
		store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
		store.remove(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
		store.putBoolean(IPreferenceConstants.USE_GLOBAL_DEFAULTS, true);
	}

	try
	{
		store.flush();
	}
	catch (BackingStoreException e)
	{
		IdeLog.logError(CommonEditorPlugin.getDefault(), e);
	}
	return super.performOk();
}
 
/**
 * The default value for spaces for tabs preference. (Used with getDefaultPluginPreferenceStore() )
 * 
 * @return
 */

protected boolean getDefaultSpacesForTabs()
{
	return getChainedEditorPreferenceStore().getBoolean(
			AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
}
 
/**
 * The default value used for tab width preference. (Used with getDefaultPluginPreferenceStore() )
 * 
 * @return
 */

protected int getDefaultTabWidth()
{
	return getChainedEditorPreferenceStore()
			.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
 
源代码22 项目: APICloud-Studio   文件: EditorUtil.java
/**
 * Retrieves the indentation settings from the given preferences qualifier, or falls back on default settings if the
 * given qualifier is null, or the value of the indent-size is smaller than 1.
 */
public static int getSpaceIndentSize(String preferencesQualifier)
{
	int spaceIndentSize = 0;
	if (preferencesQualifier != null)
	{
		spaceIndentSize = Platform.getPreferencesService().getInt(preferencesQualifier,
				AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 0, null);
	}
	// Fall back on CommonEditorPlugin or EditorsPlugin values if none are set for current editor
	return (spaceIndentSize > 0) ? spaceIndentSize : getDefaultSpaceIndentSize(preferencesQualifier);
}
 
源代码23 项目: APICloud-Studio   文件: EditorUtil.java
public static int getDefaultSpaceIndentSize(String preferencesQualifier)
{
	int spaceIndentSize = 0;
	if (CommonEditorPlugin.getDefault() != null && EditorsPlugin.getDefault() != null)
	{
		spaceIndentSize = new ChainedPreferenceStore(new IPreferenceStore[] {
				CommonEditorPlugin.getDefault().getPreferenceStore(),
				EditorsPlugin.getDefault().getPreferenceStore() })
				.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
	}
	return (spaceIndentSize > 0) ? spaceIndentSize : DEFAULT_SPACE_INDENT_SIZE;
}
 
public void propertyChange(PropertyChangeEvent event) {
	String property = event.getProperty();
	if (AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND.equals(property)
			|| AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property)
			|| AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND.equals(property)
			|| AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
			|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR.equals(property)
			|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR.equals(property)
			|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR.equals(property)
			|| AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR.equals(property))
	{
		initializeViewerColors();
	}
}
 
public static boolean isEditable(Shell shell, IJavaElement element) {
	if (! isProcessable(shell, element))
		return false;

	IJavaElement cu= element.getAncestor(IJavaElement.COMPILATION_UNIT);
	if (cu != null) {
		IResource resource= cu.getResource();
		if (resource != null && resource.isDerived(IResource.CHECK_ANCESTORS)) {

			// see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#validateEditorInputState()
			final String warnKey= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WARN_IF_INPUT_DERIVED;
			IPreferenceStore store= EditorsUI.getPreferenceStore();
			if (!store.getBoolean(warnKey))
				return true;

			MessageDialogWithToggle toggleDialog= MessageDialogWithToggle.openYesNoQuestion(
					shell,
					ActionMessages.ActionUtil_warning_derived_title,
					Messages.format(ActionMessages.ActionUtil_warning_derived_message, BasicElementLabels.getPathLabel(resource.getFullPath(), false)),
					ActionMessages.ActionUtil_warning_derived_dontShowAgain,
					false,
					null,
					null);

			EditorsUI.getPreferenceStore().setValue(warnKey, !toggleDialog.getToggleState());

			return toggleDialog.getReturnCode() == IDialogConstants.YES_ID;
		}
	}
	return true;
}
 
public JavaPreview(Map<String, String> workingValues, Composite parent) {
		JavaTextTools tools= JavaPlugin.getDefault().getJavaTextTools();
		fPreviewDocument= new Document();
		fWorkingValues= workingValues;
		tools.setupJavaDocumentPartitioner( fPreviewDocument, IJavaPartitions.JAVA_PARTITIONING);

		PreferenceStore prioritizedSettings= new PreferenceStore();
		HashMap<String, String> complianceOptions= new HashMap<String, String>();
		JavaModelUtil.setComplianceOptions(complianceOptions, JavaModelUtil.VERSION_LATEST);
		for (Entry<String, String> complianceOption : complianceOptions.entrySet()) {
			prioritizedSettings.setValue(complianceOption.getKey(), complianceOption.getValue());
		}

		IPreferenceStore[] chain= { prioritizedSettings, JavaPlugin.getDefault().getCombinedPreferenceStore() };
		fPreferenceStore= new ChainedPreferenceStore(chain);
		fSourceViewer= new JavaSourceViewer(parent, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore);
		fSourceViewer.setEditable(false);
		Cursor arrowCursor= fSourceViewer.getTextWidget().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
		fSourceViewer.getTextWidget().setCursor(arrowCursor);

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

		fViewerConfiguration= new SimpleJavaSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, IJavaPartitions.JAVA_PARTITIONING, true);
		fSourceViewer.configure(fViewerConfiguration);
		fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT));

		fMarginPainter= new MarginPainter(fSourceViewer);
		final RGB rgb= PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR);
		fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb));
		fSourceViewer.addPainter(fMarginPainter);

		new JavaSourcePreviewerUpdater();
		fSourceViewer.setDocument(fPreviewDocument);
	}
 
源代码27 项目: e4macs   文件: ColumnSupport.java
/**
 * Get the Eclipse global preference value that controls spacing/tabs
 * 
 * @return true if spaces set
 */
public static final boolean isSpacesForTabs() {
	boolean result = false;
	// This is the global editor preference
	result = EditorsUI.getPreferenceStore().getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
	return result;
}
 
源代码28 项目: Pydev   文件: CtxInsensitiveImportComplProposal.java
protected void apply(IDocument document, char trigger, int stateMask, int offset, IAdaptable projectAdaptable) {
    if (this.indentString == null) {
        throw new RuntimeException("Indent string not set (not called with a PyEdit as viewer?)");
    }

    if (!triggerCharAppliesCurrentCompletion(trigger, document, offset)) {
        newForcedOffset = offset + 1; //+1 because that's the len of the trigger
        return;
    }

    final int maxCols;
    if (SharedCorePlugin.inTestMode()) {
        maxCols = 80;
    } else {
        IPreferenceStore chainedPrefStore = PyDevUiPrefs.getChainedPrefStore();
        maxCols = chainedPrefStore
                .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN);
    }

    AddTokenAndImportStatement.ComputedInfo computedInfo = new AddTokenAndImportStatement.ComputedInfo(
            realImportRep, fReplacementOffset, fLen, indentString,
            fReplacementString, appliedWithTrigger, importLen, document);
    new AddTokenAndImportStatement(document, trigger, offset, addLocalImport, getAddLocalImportsOnTopOfMethod(),
            ImportsPreferencesPage.getGroupImports(projectAdaptable), maxCols).createTextEdit(computedInfo);
    this.fReplacementString = computedInfo.fReplacementString;
    this.appliedWithTrigger = computedInfo.appliedWithTrigger;
    this.importLen = computedInfo.importLen;
    for (ReplaceEdit edit : computedInfo.replaceEdit) {
        try {
            edit.apply(document);
        } catch (Exception e) {
            Log.log(e);
        }
    }
}
 
源代码29 项目: Pydev   文件: AbstractBlockCommentAction.java
/**
 * @return the editor tab width.
 */
public int getEditorTabWidth() {
    if (SharedCorePlugin.inTestMode()) {
        return 4; //if not available, default is 4
    }

    IPreferenceStore chainedPrefStore = PyDevUiPrefs.getChainedPrefStore();
    return chainedPrefStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
 
public static final String getAdditionalInfoAffordanceString() {
	IPreferenceStore store = EditorsUI.getPreferenceStore();
	if(!store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)) {
		return null;
	}
	
	return LangUIMessages.SourceHover_additionalInfo_affordance;
}
 
 类所在包
 类方法
 同包方法