Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added option to disable aptana themes in pydev.

  • Loading branch information...
commit da348b05dc7ed721d9b81686a4705fb6dc47343c 1 parent 72e217a
@fabioz fabioz authored
View
5 plugins/org.python.pydev.red_core/plugin.xml
@@ -34,5 +34,10 @@
</viewerContentBinding>
</extension>
+<extension point="org.eclipse.core.runtime.preferences">
+ <initializer class="org.python.pydev.red_core.preferences.PydevRedCorePreferencesInitializer"/>
+</extension>
+
+
</plugin>
View
58 plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/AddRedCorePreferences.java
@@ -9,17 +9,21 @@
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
import org.python.pydev.editor.preferences.PydevEditorPrefs;
import org.python.pydev.plugin.preferences.IPydevPreferencesProvider;
import org.python.pydev.plugin.preferences.IPydevPreferencesProvider2;
+import org.python.pydev.red_core.preferences.PydevRedCorePreferencesInitializer;
import org.python.pydev.utils.LabelFieldEditor;
import org.python.pydev.utils.LinkFieldEditor;
@@ -34,8 +38,9 @@
public class AddRedCorePreferences implements IPydevPreferencesProvider, IPydevPreferencesProvider2{
- public IPreferenceStore[] getPreferenceStore() {
- if(!AddRedCoreThemeAvailable.isRedCoreAvailable()){
+
+ public IPreferenceStore[] getPreferenceStore() {
+ if(!AddRedCoreThemeAvailable.isRedCoreAvailableForTheming()){
return null;
}
return new IPreferenceStore[]{
@@ -45,7 +50,7 @@
}
public boolean isColorOrStyleProperty(String property) {
- if(!AddRedCoreThemeAvailable.isRedCoreAvailable()){
+ if(!AddRedCoreThemeAvailable.isRedCoreAvailableForTheming()){
return false;
}
if(property.equals(IThemeManager.THEME_CHANGED)){
@@ -55,7 +60,7 @@ public boolean isColorOrStyleProperty(String property) {
}
private TextAttribute getFromTheme(String name) {
- if(!AddRedCoreThemeAvailable.isRedCoreAvailable()){
+ if(!AddRedCoreThemeAvailable.isRedCoreAvailableForTheming()){
return null;
}
Theme currentTheme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
@@ -139,17 +144,60 @@ public TextAttribute getHyperlinkTextAttribute() {
}
public RGB getConsoleBackgroundRGB() {
- if(!AddRedCoreThemeAvailable.isRedCoreAvailable()){
+ if(!AddRedCoreThemeAvailable.isRedCoreAvailableForTheming()){
return null;
}
Theme currentTheme = ThemePlugin.getDefault().getThemeManager().getCurrentTheme();
return currentTheme.getBackground();
}
+
+ protected Button addUseAptanaThemesCheckbox(final Composite parent, String label) {
+ final Button checkBox= new Button(parent, SWT.CHECK);
+ checkBox.setText(label);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan= 2;
+ checkBox.setLayoutData(gd);
+ checkBox.setSelection(PydevRedCorePreferencesInitializer.getUseAptanaThemes());
+
+ final Label labelReUseAptanaThemes = addLabel(parent, "");
+ checkBox.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ PydevRedCorePreferencesInitializer.setUseAptanaThemes(checkBox.getSelection());
+ labelReUseAptanaThemes.setText("Restart required!\nMeanwhile, new and existing editors (or other widgets) may not function properly.\n\n");
+ labelReUseAptanaThemes.setForeground(labelReUseAptanaThemes.getDisplay().getSystemColor(SWT.COLOR_RED));
+ parent.layout();
+ }
+
+ });
+
+ return checkBox;
+ }
+
+ protected Label addLabel(Composite parent, String label) {
+ Label labelWidget= new Label(parent, SWT.None);
+ labelWidget.setText(label);
+
+ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
+ gd.horizontalSpan= 2;
+ labelWidget.setLayoutData(gd);
+
+ return labelWidget;
+ }
+
public boolean createColorOptions(Composite appearanceComposite, final PydevEditorPrefs prefs) {
if(!AddRedCoreThemeAvailable.isRedCoreAvailable()){
return false;
}
+
+ addUseAptanaThemesCheckbox(appearanceComposite, "Use aptana themes? (restart required)");
+
+
+ if(!PydevRedCorePreferencesInitializer.getUseAptanaThemes()){
+ return false;
+ }
+
LinkFieldEditor colorsAndFontsLinkFieldEditor = new LinkFieldEditor(
"UNUSED", "Colors handled through <a>Aptana Themes</a>\n"
, appearanceComposite, new SelectionListener() {
View
6 plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/AddRedCoreThemeAvailable.java
@@ -6,6 +6,8 @@
*/
package org.python.pydev.red_core;
+import org.python.pydev.red_core.preferences.PydevRedCorePreferencesInitializer;
+
import com.aptana.editor.common.CommonEditorPlugin;
import com.aptana.theme.ThemePlugin;
@@ -16,6 +18,10 @@
private static volatile Boolean redCoreAvailable = null;
+ public static boolean isRedCoreAvailableForTheming(){
+ return(isRedCoreAvailable() && PydevRedCorePreferencesInitializer.getUseAptanaThemes());
+ }
+
public static boolean isRedCoreAvailable(){
if(redCoreAvailable == null){
try {
View
38 plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/AddRedCoreThemeImpl.java
@@ -12,25 +12,33 @@
import org.eclipse.swt.widgets.Composite;
import org.python.pydev.core.callbacks.ICallbackListener;
import org.python.pydev.editor.PyEdit;
+import org.python.pydev.red_core.preferences.PydevRedCorePreferencesInitializer;
-import com.aptana.editor.common.extensions.ThemeableEditorExtension;
import com.aptana.editor.common.extensions.FindBarEditorExtension;
+import com.aptana.editor.common.extensions.ThemeableEditorExtension;
public class AddRedCoreThemeImpl {
private FindBarEditorExtension themeableEditorFindBarExtension;
private ThemeableEditorExtension themeableEditorColorsExtension;
- public void installRedCoreTheme(final PyEdit edit) {
+ @SuppressWarnings({ "unchecked", "rawtypes" })
+ public void installRedCoreTheme(final PyEdit edit) {
final PyEditThemeAdaptable adaptable = new PyEditThemeAdaptable(edit);
themeableEditorFindBarExtension = new FindBarEditorExtension(adaptable);
- themeableEditorColorsExtension = new ThemeableEditorExtension(adaptable);
+
+ if(PydevRedCorePreferencesInitializer.getUseAptanaThemes()){
+ //may be null!
+ themeableEditorColorsExtension = new ThemeableEditorExtension(adaptable);
+ }
edit.onCreatePartControl.registerListener(new ICallbackListener() {
public Object call(Object obj) {
Composite parent = (Composite) obj;
- themeableEditorColorsExtension.setParent(parent);
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.setParent(parent);
+ }
Composite newParent = themeableEditorFindBarExtension.createFindBarComposite(parent);
return newParent;
}
@@ -40,7 +48,9 @@ public Object call(Object obj) {
public Object call(Object obj) {
themeableEditorFindBarExtension.createFindBar(adaptable.getISourceViewer());
- themeableEditorColorsExtension.overrideThemeColors();
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.overrideThemeColors();
+ }
return null;
}
});
@@ -48,7 +58,9 @@ public Object call(Object obj) {
edit.onInitializeLineNumberRulerColumn.registerListener(new ICallbackListener() {
public Object call(Object obj) {
- themeableEditorColorsExtension.initializeLineNumberRulerColumn((LineNumberRulerColumn) obj);
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.initializeLineNumberRulerColumn((LineNumberRulerColumn) obj);
+ }
return null;
}
});
@@ -57,7 +69,9 @@ public Object call(Object obj) {
public Object call(Object obj) {
themeableEditorFindBarExtension.dispose();
- themeableEditorColorsExtension.dispose();
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.dispose();
+ }
return null;
}
});
@@ -65,7 +79,9 @@ public Object call(Object obj) {
edit.onHandlePreferenceStoreChanged.registerListener(new ICallbackListener() {
public Object call(Object event) {
- themeableEditorColorsExtension.handlePreferenceStoreChanged((PropertyChangeEvent) event);
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.handlePreferenceStoreChanged((PropertyChangeEvent) event);
+ }
return null;
}
});
@@ -73,7 +89,9 @@ public Object call(Object event) {
edit.onCreateSourceViewer.registerListener(new ICallbackListener() {
public Object call(Object viewer) {
- themeableEditorColorsExtension.createBackgroundPainter((ISourceViewer) viewer);
+ if(themeableEditorColorsExtension != null){
+ themeableEditorColorsExtension.createBackgroundPainter((ISourceViewer) viewer);
+ }
return null;
}
});
@@ -81,7 +99,7 @@ public Object call(Object viewer) {
edit.onCreateActions.registerListener(new ICallbackListener() {
public Object call(Object obj) {
- themeableEditorFindBarExtension.createFindBarActions();
+ themeableEditorFindBarExtension.createFindBarActions();
return null;
}
});
View
5 plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/AddRedCoreThemeToView.java
@@ -15,8 +15,9 @@
public class AddRedCoreThemeToView implements IViewCreatedObserver{
- public void notifyViewCreated(Object view) {
- if(AddRedCoreThemeAvailable.isRedCoreAvailable()){
+ @SuppressWarnings("unchecked")
+ public void notifyViewCreated(Object view) {
+ if(AddRedCoreThemeAvailable.isRedCoreAvailableForTheming()){
if(view instanceof PydevPackageExplorer){
AddRedCoreThemeToViewCallbacks onViewCreatedListener = new AddRedCoreThemeToViewCallbacks();
PydevPackageExplorer castView = (PydevPackageExplorer) view;
View
5 plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/AddRedCoreThemeToViewCallbacks.java
@@ -18,9 +18,10 @@
/**
* Used to create the callbacks that will add the theming to the pydev views.
*/
+@SuppressWarnings("rawtypes")
public class AddRedCoreThemeToViewCallbacks {
- public final ICallbackListener onDispose;
+ public final ICallbackListener onDispose;
public final ICallbackListener onTreeViewCreated;
private class Container{
@@ -37,7 +38,7 @@ public Container(TreeViewer viewer) {
private Container container;
- public AddRedCoreThemeToViewCallbacks() {
+ public AddRedCoreThemeToViewCallbacks() {
onDispose = new ICallbackListener() {
public Object call(Object obj) {
View
1  plugins/org.python.pydev.red_core/src/org/python/pydev/red_core/PyEditThemeAdaptable.java
@@ -30,6 +30,7 @@ public PyEditThemeAdaptable(PyEdit edit) {
}
+ @SuppressWarnings("rawtypes")
public Object getAdapter(Class adapter) {
if(ITextEditor.class == adapter){
return edit.get();
View
26 ....python.pydev.red_core/src/org/python/pydev/red_core/preferences/PydevRedCorePreferencesInitializer.java
@@ -0,0 +1,26 @@
+package org.python.pydev.red_core.preferences;
+
+import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
+import org.eclipse.core.runtime.preferences.DefaultScope;
+import org.osgi.service.prefs.Preferences;
+import org.python.pydev.red_core.PydevRedCoreActivator;
+
+public class PydevRedCorePreferencesInitializer extends AbstractPreferenceInitializer {
+
+ public static final String USE_APTANA_THEMES = "PYDEV_USE_APTANA_THEMES";
+
+ @Override
+ public void initializeDefaultPreferences() {
+ Preferences node = new DefaultScope().getNode(PydevRedCoreActivator.PLUGIN_ID);
+ node.putBoolean(USE_APTANA_THEMES, true);
+ }
+
+ public static boolean getUseAptanaThemes() {
+ return PydevRedCoreActivator.getDefault().getPreferenceStore().getBoolean(USE_APTANA_THEMES);
+ }
+
+ public static void setUseAptanaThemes(boolean b) {
+ PydevRedCoreActivator.getDefault().getPreferenceStore().setValue(USE_APTANA_THEMES, b);
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.