org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants Java Examples

The following examples show how to use org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #2
Source File: ViewerColorUpdater.java    From goclipse with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #3
Source File: ImportArranger.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #4
Source File: AbstractBlockCommentAction.java    From Pydev with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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);
}
 
Example #5
Source File: PropertiesFileEditor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
@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);
}
 
Example #6
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #7
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
@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);
	}
}
 
Example #8
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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);
	}
}
 
Example #9
Source File: CommonSourceViewerConfiguration.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * @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$
}
 
Example #10
Source File: ThemeableEditorExtension.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
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();
	}
}
 
Example #11
Source File: ThemeManager.java    From APICloud-Studio with GNU General Public License v3.0 6 votes vote down vote up
/**
 * 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);
	}
}
 
Example #12
Source File: TexHardLineWrapAction.java    From texlipse with Eclipse Public License 1.0 5 votes vote down vote up
/** 
 * 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);
    }
}
 
Example #13
Source File: JavaSourceViewer.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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();
	}
}
 
Example #14
Source File: ActionUtil.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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;
}
 
Example #15
Source File: JavaPreview.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
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);
	}
 
Example #16
Source File: ModulaEditor.java    From xds-ide with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * {@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); 
}
 
Example #17
Source File: ColumnSupport.java    From e4macs with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 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;
}
 
Example #18
Source File: CtxInsensitiveImportComplProposal.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
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);
        }
    }
}
 
Example #19
Source File: InvasiveThemeHijacker.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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);
	}
}
 
Example #20
Source File: EditorUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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;
}
 
Example #21
Source File: EditorUtil.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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);
}
 
Example #22
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The default value used for tab width preference. (Used with getDefaultPluginPreferenceStore() )
 * 
 * @return
 */

protected int getDefaultTabWidth()
{
	return getChainedEditorPreferenceStore()
			.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
 
Example #23
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
/**
 * The default value for spaces for tabs preference. (Used with getDefaultPluginPreferenceStore() )
 * 
 * @return
 */

protected boolean getDefaultSpacesForTabs()
{
	return getChainedEditorPreferenceStore().getBoolean(
			AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
}
 
Example #24
Source File: DerivedSourceView.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
@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()));
}
 
Example #25
Source File: XtendFormatterPreview.java    From xtext-xtend with Eclipse Public License 2.0 5 votes vote down vote up
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;
}
 
Example #26
Source File: CommonEditorPreferencePage.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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();
}
 
Example #27
Source File: AbstractBlockCommentAction.java    From Pydev with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * @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);
}
 
Example #28
Source File: PreferenceStoreIndentationInformation.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
@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;
	}
}
 
Example #29
Source File: ThemeableEditorExtension.java    From APICloud-Studio with GNU General Public License v3.0 5 votes vote down vote up
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);
		}
	}
}
 
Example #30
Source File: AbstractSimpleLangSourceViewerConfiguration.java    From goclipse with Eclipse Public License 1.0 5 votes vote down vote up
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;
}