org.eclipse.ui.editors.text.EditorsUI#getPreferenceStore ( )源码实例Demo

下面列出了org.eclipse.ui.editors.text.EditorsUI#getPreferenceStore ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: birt   文件: DecoratedScriptEditor.java
/**
 * Constructs a decorated script editor with the specified parent and the
 * specified script.
 * 
 * @param parent
 *            the parent editor.
 * @param script
 *            the script to edit
 */
public DecoratedScriptEditor( IEditorPart parent, String script )
{
	super( );
	this.parent = parent;
	this.sourceViewerConfiguration = new ScriptSourceViewerConfiguration( context );
	setSourceViewerConfiguration( this.sourceViewerConfiguration );
	setDocumentProvider( new ScriptDocumentProvider( parent ) );
	setScript( script );

	IPreferences preferences = PreferenceFactory.getInstance( )
			.getPreferences( ReportPlugin.getDefault( ) );
	if ( preferences instanceof PreferenceWrapper )
	{
		IPreferenceStore store = ( (PreferenceWrapper) preferences ).getPrefsStore( );
		if ( store != null )
		{
			IPreferenceStore baseEditorPrefs = EditorsUI.getPreferenceStore();
			setPreferenceStore( new ChainedPreferenceStore(new IPreferenceStore[]{store, baseEditorPrefs}) );
		}
	}
}
 
源代码2 项目: birt   文件: AbstractSyntaxColoringPage.java
public void dispose() {
	if (fForegroundColor != null) {
		fForegroundColor.dispose();
		fForegroundColor = null;
	}
	if (fBackgroundColor != null) {
		fBackgroundColor.dispose();
		fBackgroundColor = null;
	}
	if (fSelectionForegroundColor != null) {
		fSelectionForegroundColor.dispose();
		fSelectionForegroundColor = null;
	}
	if (fSelectionBackgroundColor != null) {
		fSelectionBackgroundColor.dispose();
		fSelectionBackgroundColor = null;
	}
	if (fListener != null) {
		final IPreferenceStore store = EditorsUI.getPreferenceStore();
		if (store != null) {
			store.removePropertyChangeListener(fListener);
		}
	}
	super.dispose();
}
 
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;
}
 
源代码4 项目: xtext-eclipse   文件: PreferenceStoreAccessImpl.java
@Override
public IPreferenceStore getContextPreferenceStore(Object context) {
	lazyInitialize();
	// may be null on shutdown
	Activator activator = Activator.getDefault();
	if (activator != null)
		return new ChainedPreferenceStore(new IPreferenceStore[] { 
				getWritablePreferenceStore(context),
				activator.getPreferenceStore(),
				EditorsUI.getPreferenceStore()});
	return new ChainedPreferenceStore(new IPreferenceStore[] { 
			getWritablePreferenceStore(context),
			EditorsUI.getPreferenceStore()});
}
 
源代码5 项目: texlipse   文件: TexSourceViewerConfiguration.java
/**
 * Creates a new source viewer configuration.
 * 
 * @param te The editor that this configuration is associated to
 */
public TexSourceViewerConfiguration(TexEditor editor) {        
    super(EditorsUI.getPreferenceStore());
    this.editor = editor;
    this.colorManager = new ColorManager();
    this.annotationHover = new TexAnnotationHover();

    // Adds a listener for changing content assistant properties if
    // these are changed in the preferences
    TexlipsePlugin.getDefault().getPreferenceStore().addPropertyChangeListener(new  
            IPropertyChangeListener() {
        
        public void propertyChange(PropertyChangeEvent event) {
            
            if (assistant == null)
                return;
            
            String property = event.getProperty();
            if (TexlipseProperties.TEX_COMPLETION.equals(property)) {
                assistant.enableAutoActivation(
                        TexlipsePlugin.getDefault().getPreferenceStore().getBoolean(
                                TexlipseProperties.TEX_COMPLETION));
            } else if (TexlipseProperties.TEX_COMPLETION_DELAY.equals(property)) {
                assistant.setAutoActivationDelay(
                        TexlipsePlugin.getDefault().getPreferenceStore().getInt(
                                TexlipseProperties.TEX_COMPLETION_DELAY));
            }
        };
    });
    
}
 
源代码6 项目: tlaplus   文件: ColorPredicatePreferencePage.java
public ColorPredicatePreferencePage()
{
    super(GRID);
    // Using somebody's else PreferenceStore is not a good idea!
    // @see Bug #261 in general/bugzilla/index.html
    final IPreferenceStore[] preferenceStores = new IPreferenceStore[2];
    preferenceStores[0] = EditorsUI.getPreferenceStore();
    preferenceStores[1] = ProverUIActivator.getDefault().getPreferenceStore();
    
    setPreferenceStore(new TLCChainedPreferenceStore(preferenceStores));
    getPreferenceStore().addPropertyChangeListener(this);
    setDescription("Color Predicates");
}
 
/**
 * @param composite
 */
public SourceViewer createSourcePreview(Composite composite, IScriptFormatterFactory factory)
{
	IPreferenceStore generalTextStore = EditorsUI.getPreferenceStore();
	// TODO - Note that we pass the factory's preferences store and not calling to this.getPrefereceStore.
	// In case we decide to unify the preferences into the this plugin, we might need to change this.
	IPreferenceStore store = new ChainedPreferenceStore(new IPreferenceStore[] { factory.getPreferenceStore(),
			generalTextStore });
	SourceViewer fPreviewViewer = createPreviewViewer(composite, null, null, false, SWT.V_SCROLL | SWT.H_SCROLL
			| SWT.BORDER, store);
	if (fPreviewViewer == null)
	{
		return null;
	}
	SourceViewerConfiguration configuration = (SourceViewerConfiguration) factory
			.createSimpleSourceViewerConfiguration(fColorManager, store, null, false);
	fPreviewViewer.configure(configuration);
	if (fPreviewViewer.getTextWidget().getTabs() == 0)
	{
		fPreviewViewer.getTextWidget().setTabs(4);
	}
	new ScriptSourcePreviewerUpdater(fPreviewViewer, configuration, store);
	fPreviewViewer.setEditable(false);
	IDocument document = new Document();
	fPreviewViewer.setDocument(document);
	IPartitioningConfiguration partitioningConfiguration = (IPartitioningConfiguration) factory
			.getPartitioningConfiguration();
	CompositePartitionScanner partitionScanner = new CompositePartitionScanner(
			partitioningConfiguration.createSubPartitionScanner(), new NullSubPartitionScanner(),
			new NullPartitionerSwitchStrategy());
	IDocumentPartitioner partitioner = new ExtendedFastPartitioner(partitionScanner,
			partitioningConfiguration.getContentTypes());
	partitionScanner.setPartitioner((IExtendedPartitioner) partitioner);
	partitioner.connect(document);
	document.setDocumentPartitioner(partitioner);
	return fPreviewViewer;
}
 
/**
 * Creates and returns a preference store which combines the preference
 * stores from the text tools and which is read-only.
 *
 * @param javaTextTools the Java text tools
 * @return the combined read-only preference store
 * @since 3.0
 */
private static final IPreferenceStore createPreferenceStore(JavaTextTools javaTextTools) {
	Assert.isNotNull(javaTextTools);
	IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
	if (javaTextTools.getCorePreferenceStore() == null)
		return new ChainedPreferenceStore(new IPreferenceStore[] { javaTextTools.getPreferenceStore(), generalTextStore});

	return new ChainedPreferenceStore(new IPreferenceStore[] { javaTextTools.getPreferenceStore(), new PreferencesAdapter(javaTextTools.getCorePreferenceStore()), generalTextStore });
}
 
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;
}
 
private Control createPreviewer(Composite parent) {

		IPreferenceStore generalTextStore= EditorsUI.getPreferenceStore();
		IPreferenceStore store= new ChainedPreferenceStore(new IPreferenceStore[] { getPreferenceStore(), new PreferencesAdapter(createTemporaryCorePreferenceStore()), generalTextStore });
		fPreviewViewer= new JavaSourceViewer(parent, null, null, false, SWT.H_SCROLL | SWT.BORDER, store);
		SimpleJavaSourceViewerConfiguration configuration= new SimpleJavaSourceViewerConfiguration(fColorManager, store, null, IJavaPartitions.JAVA_PARTITIONING, false);
		fPreviewViewer.configure(configuration);
		// fake 1.5 source to get 1.5 features right.
		configuration.handlePropertyChangeEvent(new PropertyChangeEvent(this, JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_4, JavaCore.VERSION_1_5));
		Font font= JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT);
		fPreviewViewer.getTextWidget().setFont(font);
		new JavaSourcePreviewerUpdater(fPreviewViewer, configuration, store);

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

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

		String content= loadPreviewContentFromFile("ColorSettingPreviewCode.txt"); //$NON-NLS-1$
		IDocument document= new Document(content);
		JavaPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
		fPreviewViewer.setDocument(document);

		installSemanticHighlighting();


		return fPreviewViewer.getControl();
	}
 
源代码11 项目: e4macs   文件: ToggleLineHighlight.java
/**
 * @see com.mulgasoft.emacsplus.commands.EmacsPlusNoEditHandler#transform(ITextEditor, IDocument, ITextSelection, ExecutionEvent)
 */
@Override
protected int transform(ITextEditor editor, IDocument document, ITextSelection currentSelection,
		ExecutionEvent event) throws BadLocationException {
	IPreferenceStore store= EditorsUI.getPreferenceStore();
	if (store != null) {
		store.setValue(EDITOR_CURRENT_LINE, !store.getBoolean(EDITOR_CURRENT_LINE));
	}
	return NO_OFFSET;
}
 
源代码12 项目: saros   文件: SarosAnnotation.java
/**
 * Loads the default colors from the plugin.xml and overwrites possible errors in the EditorsUI
 * preference store.
 */
public static void resetColors() {

  log.debug("resetting annotation colors");

  final IPreferenceStore preferenceStore = EditorsUI.getPreferenceStore();

  final AnnotationPreferenceLookup lookup = EditorsUI.getAnnotationPreferenceLookup();

  final String[] annotationTypesToReset = {
    SelectionAnnotation.TYPE, ViewportAnnotation.TYPE, ContributionAnnotation.TYPE
  };

  for (int i = 0; i <= SIZE; ++i) {

    for (String annotationType : annotationTypesToReset) {

      final String annotationTypeToLookup = getNumberedType(annotationType, i);

      final AnnotationPreference preference =
          lookup.getAnnotationPreference(annotationTypeToLookup);

      if (preference == null) {
        log.warn("could not reset color for annotation type: " + annotationTypeToLookup);
        continue;
      }

      preferenceStore.setToDefault(preference.getColorPreferenceKey());

      if (log.isTraceEnabled()) {
        log.trace(
            "reset "
                + annotationTypeToLookup
                + " to: "
                + preferenceStore.getString(preference.getColorPreferenceKey()));
      }
    }
  }
}
 
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;
}
 
源代码14 项目: n4js   文件: StyledTextDescriptor.java
/**
 * Creates and returns with a new {@link StyledText styled text} instance hooked up to the given parent composite.
 *
 * @param parent
 *            the parent of the styled text control.
 * @param style
 *            style bits for the new text control.
 * @return a new styled text control initialized from the descriptor.
 */
default StyledText toStyledText(final Composite parent, final int style) {

	final StyledText text = new StyledText(parent, READ_ONLY | style);
	text.setText(getText());
	text.setStyleRanges(getRanges());
	text.setFont(getFont());
	text.setEditable(false);
	text.setEnabled(false);

	final AtomicReference<Color> colorRef = new AtomicReference<>();
	final IPreferenceStore prefStore = EditorsUI.getPreferenceStore();
	if (null == prefStore
			|| prefStore.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {

		colorRef.set(getDefault().getSystemColor(COLOR_LIST_BACKGROUND));

	} else {

		RGB rgb = null;
		if (prefStore.contains(PREFERENCE_COLOR_BACKGROUND)) {
			if (prefStore.isDefault(PREFERENCE_COLOR_BACKGROUND)) {
				rgb = getDefaultColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
			} else {
				rgb = getColor(prefStore, PREFERENCE_COLOR_BACKGROUND);
			}
			if (rgb != null) {
				colorRef.set(new Color(text.getDisplay(), rgb));
			}
		}

	}

	if (null != colorRef.get()) {
		text.setBackground(colorRef.get());
		text.addDisposeListener(e -> {
			if (!colorRef.get().isDisposed()) {
				colorRef.get().dispose();
			}
		});
	}

	text.pack();
	return text;
}
 
源代码15 项目: xtext-eclipse   文件: PreferenceStoreAccessor.java
public void populateTextStyle(String id, TextStyle style, TextStyle defaults) {
	IPreferenceStore editorsStore = EditorsUI.getPreferenceStore();
	RGB fontColorDefaultDefault = editorsStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) 
			? getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND).getRGB()
			: PreferenceConverter.getColor(editorsStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND);
	RGB backgrounColorDefaultDefault = editorsStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) 
			? getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND).getRGB() 
			: PreferenceConverter.getColor(editorsStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
	FontData[] fontDataDefaultDefault = JFaceResources.getTextFont().getFontData();

	IPreferenceStore preferenceStore = getPreferenceStore();
	String cssID = CSS_PREFIX + id;
	IPreferenceStore cssPrefStore = getPluginCssPreferenceStore();
	
	String colorKey = PREFERENCE_TAG + getTokenColorPreferenceKey(id);
	String cssFontColor = cssPrefStore.getString(getTokenColorPreferenceKey(cssID));
	if(!Strings.isEmpty(cssFontColor)) {
		preferenceStore.setDefault(colorKey, cssFontColor);
	} else if (defaults.getColor() != null) {
		PreferenceConverter.setDefault(preferenceStore, colorKey, defaults.getColor());
	} else {
		PreferenceConverter.setDefault(preferenceStore, colorKey, fontColorDefaultDefault);
	}
	
	String backgroundKey = PREFERENCE_TAG + getTokenBackgroundColorPreferenceKey(id);
	String cssBgColor = cssPrefStore.getString(getTokenBackgroundColorPreferenceKey(cssID));
	if(!Strings.isEmpty(cssBgColor)) {
		preferenceStore.setDefault(backgroundKey, cssBgColor);
	} else if (defaults.getBackgroundColor() != null) {
		PreferenceConverter.setDefault(preferenceStore, backgroundKey, defaults.getBackgroundColor());
	} else {
		PreferenceConverter.setDefault(preferenceStore, backgroundKey, backgrounColorDefaultDefault);
	}
	
	String fontKey = PREFERENCE_TAG + getTokenFontPreferenceKey(id);
	String cssFont = cssPrefStore.getString(getTokenFontPreferenceKey(cssID));
	if(!Strings.isEmpty(cssFont)) {
		preferenceStore.setDefault(fontKey, cssFont);
	} else if (defaults.getFontData() != null)
		PreferenceConverter.setDefault(preferenceStore, fontKey, defaults.getFontData());
	else {
		PreferenceConverter.setDefault(preferenceStore, fontKey, fontDataDefaultDefault);
	}
	
	String styleKey = PREFERENCE_TAG + getTokenStylePreferenceKey(id);
	int cssStyle = cssPrefStore.getInt(getTokenStylePreferenceKey(cssID));
	if(cssStyle != 0) {
		preferenceStore.setDefault(styleKey, cssStyle);
	} else {
		preferenceStore.setDefault(styleKey, defaults.getStyle());
	}
	
	// populate
	RGB color = PreferenceConverter.getColor(preferenceStore, colorKey);
	if (!color.equals(fontColorDefaultDefault))
		style.setColor(color);
	RGB background = PreferenceConverter.getColor(preferenceStore, backgroundKey);
	if (!background.equals(backgrounColorDefaultDefault))
		style.setBackgroundColor(background);
	FontData[] fontDataArray = PreferenceConverter.getFontDataArray(preferenceStore, fontKey);
	if (!Arrays.equals(fontDataArray, fontDataDefaultDefault)) {
		style.setFontData(fontDataArray);
	}
	style.setStyle(preferenceStore.getInt(styleKey));
}
 
源代码16 项目: xds-ide   文件: DisableSpellCheckingProposal.java
public final void apply(final IDocument document) {
	IPreferenceStore store= EditorsUI.getPreferenceStore();
	store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, false);
}
 
public final void apply(final IDocument document) {
	IPreferenceStore store= EditorsUI.getPreferenceStore();
	store.setValue(SpellingService.PREFERENCE_SPELLING_ENABLED, false);
}
 
源代码18 项目: textuml   文件: TextUMLSourceViewerConfiguration.java
public TextUMLSourceViewerConfiguration(SourceEditor editor) {
    // failing to pass the preference store in causes annotation hovering
    // not to work
    super(EditorsUI.getPreferenceStore());
    this.editor = editor;
}
 
源代码19 项目: birt   文件: AbstractSyntaxColoringPage.java
public AbstractSyntaxColoringPage() {
	final IPreferenceStore store = EditorsUI.getPreferenceStore();
	if (store != null) {
		store.addPropertyChangeListener(fListener);
	}
}
 
源代码20 项目: birt   文件: AbstractSyntaxColoringPage.java
/**
 * Initializes the colors of the source preview window based on the values in the Editors' UI preference store
 * 
 * @param viewer the {@link ISourceViewer} used as the source preview
 */
protected void initializeSourcePreviewColors(ISourceViewer viewer) {
	final IPreferenceStore store = EditorsUI.getPreferenceStore();
	if (store != null && viewer != null) {

		final StyledText styledText = viewer.getTextWidget();

		// ----------- foreground color --------------------
		Color color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
		styledText.setForeground(color);

		if (fForegroundColor != null)
			fForegroundColor.dispose();

		fForegroundColor = color;

		// ---------- background color ----------------------
		color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
		styledText.setBackground(color);

		if (fBackgroundColor != null)
			fBackgroundColor.dispose();

		fBackgroundColor = color;

		// ----------- selection foreground color --------------------
		color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
		styledText.setSelectionForeground(color);

		if (fSelectionForegroundColor != null)
			fSelectionForegroundColor.dispose();

		fSelectionForegroundColor = color;

		// ---------- selection background color ----------------------
		color = store.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT) ? null : createColor(store, AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
		styledText.setSelectionBackground(color);

		if (fSelectionBackgroundColor != null)
			fSelectionBackgroundColor.dispose();

		fSelectionBackgroundColor = color;
	}
}