下面列出了怎么用org.eclipse.ui.internal.editors.text.EditorsPlugin的API类实例代码及写法,或者点击链接到github查看源代码。
public FormatterPreview(Composite parent, String resFileName, XdsSourceType xdsSourceType) {
super(parent, SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.READ_ONLY);
this.xdsSourceType = xdsSourceType;
this.styledText = this.getTextWidget();
String resPath = RESOURCE_FOLDER_LOCATION + resFileName;
try(InputStream resourceStream = ResourceUtils.getPluginResourceAsStream(ResourceUtils.getXdsResourcesPluginBundle(), resPath)) {
this.initialText = IOUtils.toString(resourceStream);
}
catch (Exception e) {
this.initialText = "** Internal error: can't read " + resPath + "\n** Preview not available"; //$NON-NLS-1$ //$NON-NLS-2$
}
Font font= JFaceResources.getTextFont();
styledText.setFont(font);
defBackgroundColor = getEditorBackgroundColor(EditorsPlugin.getDefault().getPreferenceStore());
styledText.setBackground(defBackgroundColor);
styledText.setText(initialText);
colorIt();
}
@Override
public void earlyStartup() {
GamaPreferences.Modeling.EDITOR_BASE_FONT.init(() -> getDefaultFontData()).onChange(font -> {
try {
final FontData newValue = new FontData(font.getName(), font.getSize(), font.getStyle());
setValue(EditorsPlugin.getDefault().getPreferenceStore(), TEXT_FONT, newValue);
} catch (final Exception e) {}
});
GamaPreferences.Modeling.EDITOR_BACKGROUND_COLOR.init(() -> getDefaultBackground()).onChange(c -> {
final RGB rgb = new RGB(c.getRed(), c.getGreen(), c.getBlue());
PreferenceConverter.setValue(EditorsPlugin.getDefault().getPreferenceStore(),
AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, rgb);
GamaPreferences.Modeling.OPERATORS_MENU_SORT
.onChange(newValue -> OperatorsReferenceMenu.byName = newValue.equals("Name"));
});
GamlRuntimeModule.staticInitialize();
GamlEditorBindings.install();
GamlReferenceSearch.install();
}
public void initialize(ColumnViewer viewer, ViewerColumn column) {
PlatformUI.getPreferenceStore().addPropertyChangeListener(this);
EditorsPlugin.getDefault().getPreferenceStore().addPropertyChangeListener(this);
JFaceResources.getColorRegistry().addListener(this);
setOwnerDrawEnabled(showColoredLabels());
super.initialize(viewer, column);
}
private Color getColorFromStore(IPreferenceStore store, String isDefaultKey, int systemDefault, String key) {
String isDefault = store.getString(isDefaultKey);
if(Strings.isEmpty(isDefault) || Strings.equal("true", isDefault)) {
return getDisplay().getSystemColor(systemDefault);
} else {
RGB rgb = PreferenceConverter.getColor(store, key);
return EditorsPlugin.getDefault().getSharedTextColors().getColor(rgb);
}
}
public SwaggerEditor() {
super(new SwaggerDocumentProvider(), //
// ZEN-4361 Missing marker location indicators (Overview Ruler) next to editor
// scrollbar in KZOE
new ChainedPreferenceStore(new IPreferenceStore[] { //
Activator.getDefault().getPreferenceStore(), //
// Preferences store for EditorsPlugin has settings to show/hide the rules and
// markers
EditorsPlugin.getDefault().getPreferenceStore() }));
getPreferenceStore().addPropertyChangeListener(validationChangeListener);
}
public OpenApi3Editor() {
super(new OpenApi3DocumentProvider(), //
// ZEN-4361 Missing marker location indicators (Overview Ruler) next to editor
// scrollbar in KZOE
new ChainedPreferenceStore(new IPreferenceStore[] { //
Activator.getDefault().getPreferenceStore(), //
// Preferences store for EditorsPlugin has settings to show/hide the rules and
// markers
EditorsPlugin.getDefault().getPreferenceStore() }));
getPreferenceStore().addPropertyChangeListener(validationChangeListener);
}
private static GamaColor getDefaultBackground() {
EditorsPlugin.getDefault().getPreferenceStore()
.setValue(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false);
final RGB rgb = PreferenceConverter.getColor(EditorsPlugin.getDefault().getPreferenceStore(),
AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
return new GamaColor(rgb.red, rgb.green, rgb.blue);
}
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 SyntaxColoringPreferencePage(String title) {
super(title);
setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
syntaxColorings = SyntaxColoringPreferencesRegistry.get().contributions();
}
public SyntaxColoringPreferencePage(String title, ImageDescriptor image) {
super(title, image);
setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
syntaxColorings = SyntaxColoringPreferencesRegistry.get().contributions();
}
private SourceViewerConfiguration getSourceViewerConfiguration() {
return new ModulaSourceViewerConfiguration(tokenManager, null, EditorsPlugin.getDefault().getPreferenceStore(), ModulaEditor.eolCommentPrefix);
}
private SourceViewerConfiguration getSourceViewerConfiguration() {
return new DbgScriptSourceViewerConfiguration(tokenManager, EditorsPlugin.getDefault().getPreferenceStore(), DbgScriptEditor.eolCommentPrefix);
}
public void dispose() {
super.dispose();
PlatformUI.getPreferenceStore().removePropertyChangeListener(this);
EditorsPlugin.getDefault().getPreferenceStore().removePropertyChangeListener(this);
JFaceResources.getColorRegistry().removeListener(this);
}
protected ISharedTextColors getSharedColors() {
return EditorsPlugin.getDefault().getSharedTextColors();
}
private GWTSpellingService() {
super(EditorsPlugin.getDefault().getPreferenceStore());
}
public static GamaFont getDefaultFontData() {
final FontData fd = PreferenceConverter.getFontData(EditorsPlugin.getDefault().getPreferenceStore(), TEXT_FONT);
return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}
public static GamaFont getDefaultFont() {
final FontData fd = PreferenceConverter.getFontData(EditorsPlugin.getDefault().getPreferenceStore(),
JFaceResources.TEXT_FONT);
return new GamaFont(fd.getName(), fd.getStyle(), fd.getHeight());
}
public static IPreferenceStore getChainedPreferenceStore()
{
return new ChainedPreferenceStore(new IPreferenceStore[] { XMLPlugin.getDefault().getPreferenceStore(),
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() });
}
public static IPreferenceStore getChainedPreferenceStore()
{
return new ChainedPreferenceStore(new IPreferenceStore[] { JSPlugin.getDefault().getPreferenceStore(),
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() });
}
public static IPreferenceStore getChainedPreferenceStore()
{
return new ChainedPreferenceStore(new IPreferenceStore[] { DTDPlugin.getDefault().getPreferenceStore(),
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() });
}
public static IPreferenceStore getChainedPreferenceStore()
{
return new ChainedPreferenceStore(new IPreferenceStore[] { CSSPlugin.getDefault().getPreferenceStore(),
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() });
}
public static IPreferenceStore getChainedPreferenceStore()
{
return new ChainedPreferenceStore(new IPreferenceStore[] { HTMLPlugin.getDefault().getPreferenceStore(),
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() });
}
@Override
protected void initializeEditor()
{
setPreferenceStore(new ChainedPreferenceStore(new IPreferenceStore[] {
CommonEditorPlugin.getDefault().getPreferenceStore(), EditorsPlugin.getDefault().getPreferenceStore() }));
}
/**
* Returns the editor's tab width as set in the given editor's-specific preferences. In case a value is not found,
* or the preferences are null, the workspace settings for the editor's tab-width will be returned.
*
* @param preferenceStore
* The editor's preferences store; Null, in case a workspace setting is needed.
* @return The editor's tab-width
* @deprecated Use EditorUtil.getSpaceIndentSize(preferencesQualifier)
*/
public static int getEditorTabWidth(IPreferenceStore preferenceStore)
{
IPreferenceStore prefs = getChainedPreferences(preferenceStore, EditorsPlugin.getDefault().getPreferenceStore());
return prefs.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
}
/**
* Returns the editor's setting for 'Insert Spaces for Tabs'. This setting exists in the general 'Text Editors'
* preference page.
*
* @param preferenceStore
* The editor's preferences store; Null, in case a workspace setting is needed.
* @return The value for the generic editor's 'Insert Spaces for Tabs'
*/
public static boolean isInsertSpacesForTabs(IPreferenceStore preferenceStore)
{
IPreferenceStore prefs = getChainedPreferences(preferenceStore, EditorsPlugin.getDefault().getPreferenceStore());
return prefs.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SPACES_FOR_TABS);
}