blob: 24b516983d86ebace14806a3e9db63e7038d2bd0 [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2001, 2004 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IBM Corporation - initial API and implementation
* Jens Lukowski/Innoopract - initial renaming/restructuring
*
*******************************************************************************/
package org.eclipse.wst.sse.ui;
import org.eclipse.core.runtime.IPluginDescriptor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistryImpl;
import org.eclipse.wst.sse.ui.registry.embedded.EmbeddedAdapterFactoryRegistryImpl;
import org.eclipse.wst.sse.ui.taginfo.TextHoverManager;
public class EditorPlugin extends AbstractUIPlugin {
public final static String ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
static EditorPlugin instance = null;
public static EditorPlugin getDefault() {
return instance;
}
public synchronized static EditorPlugin getInstance() {
return instance;
}
/**
* This method is here so that other editor plugins can set Editor
* defaults in their initialzeDefaultPreferences(...) methods.
*
* @param store
*/
public static void initializeDefaultEditorPreferences(IPreferenceStore store) {
// use the base annotation & quick diff preference page
EditorsUI.useAnnotationsPreferencePage(store);
EditorsUI.useQuickDiffPreferencePage(store);
// preferences relative to all sse editors are initialized
AbstractDecoratedTextEditorPreferenceConstants.initializeDefaultValues(store);
// let annotations show up in the vertical ruler if that's what the
// preference is
// // these annotation preferences have a different default value than
// the one the base provides
// store.setDefault("errorIndicationInVerticalRuler", false);
// //$NON-NLS-1$
// store.setDefault("warningIndicationInVerticalRuler", false);
// //$NON-NLS-1$
// these annotation preferences are not part of base text editor
// preference
store.setDefault(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, true);
store.setDefault(CommonEditorPreferenceNames.SHOW_QUICK_FIXABLES, true);
// matching brackets is not part of base text editor preference
store.setDefault(CommonEditorPreferenceNames.MATCHING_BRACKETS, true);
PreferenceConverter.setDefault(store, CommonEditorPreferenceNames.MATCHING_BRACKETS_COLOR, new RGB(192, 192, 192));
// open file hyperlink navigation is not part of base text editor
// preference
String mod1Name = Action.findModifierString(SWT.MOD1); // SWT.COMMAND
// on Mac;
// SWT.CONTROL
// elsewhere
store.setDefault(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS, true);
store.setDefault(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER, mod1Name);
PreferenceConverter.setDefault(store, CommonEditorPreferenceNames.LINK_COLOR, new RGB(0, 0, 255));
// hover help preferences are not part of base text editor preference
String mod2Name = Action.findModifierString(SWT.MOD2); // SWT.COMMAND
// on Mac;
// SWT.CONTROL
// elsewhere
store.setDefault(CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS, "combinationHover|true|0;problemHover|false|0;documentationHover|false|0;annotationHover|true|" + mod2Name); //$NON-NLS-1$
store.setDefault(CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
store.setDefault(CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER, false);
// tab width is also a model-side preference so need to load default
// from there
store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH);
// set default read-only foreground color scale value
store.setDefault(CommonEditorPreferenceNames.READ_ONLY_FOREGROUND_SCALE, 30);
}
private TextHoverManager fTextHoverManager;
public EditorPlugin(IPluginDescriptor descriptor) {
super(descriptor);
instance = this;
}
public AdapterFactoryRegistry getAdapterFactoryRegistry() {
return AdapterFactoryRegistryImpl.getInstance();
}
public AdapterFactoryRegistry getEmbeddedAdapterFactoryRegistry() {
return EmbeddedAdapterFactoryRegistryImpl.getInstance();
}
/**
* Return text hover manager
*
* @return TextHoverManager
*/
public TextHoverManager getTextHoverManager() {
if (fTextHoverManager == null) {
fTextHoverManager = new TextHoverManager();
}
return fTextHoverManager;
}
/**
* @see AbstractUIPlugin#initializeDefaultPreferences
*/
protected void initializeDefaultPreferences(IPreferenceStore store) {
initializeDefaultEditorPreferences(store);
}
}