Expand Up @@ -14,122 +14,6 @@

define("orion/editor/textMateStyler", ['orion/editor/regex' ], function(mRegex) {

var preferences;

function _update( storage, stylerOptions, sUtil ){

var USER_THEME = "";

var parent = stylerOptions.textView._parent;
var document = parent.ownerDocument;
var stylesheet = stylerOptions._stylesheet = stylerOptions.util.createElement(document, "style");
stylesheet.appendChild(document.createTextNode(stylerOptions._styleSheet( storage, USER_THEME, stylerOptions.util)));
var head = document.getElementsByTagName("head")[0] || document.documentElement;

head.appendChild(stylesheet);

stylerOptions.textView.update(true);
}

function _updateStylesheet(preferences, util){

var storage;
var CATEGORY = "JavaScript Editor";

var self = this;

preferences.getPreferences('/settings', 2).then( function(prefs){

var data = prefs.get(CATEGORY);

if( data !== undefined ){

storage = JSON.parse( prefs.get(CATEGORY) );
if (!storage) { return; }
if (self._stylesheet) {
self._stylesheet.parentNode.removeChild(self._stylesheet);
self._stylesheet = null;
}

self._update( storage, self, util );
}
});
}


function _styleSheet( settings, theme ){

var elements = [];

for( var count = 0; count < settings.length; count++ ){
elements[settings[count].element] = settings[count].value;
}

var result = [];
result.push("");

//view container
var family = elements['fontFamily'];
if(family === "sans serif"){
family = '"Menlo", "Consolas", "Vera Mono", "monospace"';
}else{
family = 'monospace';
}

result.push( theme + " .textviewContainer {" );
result.push( "\background-color:" + elements['background'] + ";" );
result.push( "\tfont-family: " + family + ";" );
result.push( "\tfont-size: " + elements['fontSize'] + ";" );
result.push( "\tmin-width: 50px;" );
result.push( "\tmin-height: 50px;" );
result.push("\tcolor: " + elements['text'] + ";");
result.push("}");

result.push( theme + " {");
result.push("\tfont-family: " + family + ";");
result.push("\tfont-size: " + elements['fontSize'] + ";");

result.push("\tcolor: " + elements['text'] + ";");
result.push("}");

result.push( theme + " .textview {");
result.push("\tbackground-color: " + elements['background'] + ";");
result.push("}");

result.push( theme + ".ruler.annotations{");
result.push("\tbackground-color: " + 'white' + ";");
result.push("}");

result.push( theme + " .ruler {");
result.push("\tbackground-color: " + elements['annotationRuler'] + ";");
result.push("}");

result.push( theme + " .rulerLines {");
result.push("\tcolor: " + elements['lineNumber'] + ";");
result.push("\tbackground-color: " + elements['annotationRuler'] + ";");
result.push("}");

result.push( theme + " .rulerLines.even {");
result.push("\tcolor: " + elements['lineNumber'] + ";");
result.push("\tbackground-color: " + elements['annotationRuler'] + ";");
result.push("}");

result.push( theme + " .rulerLines.odd {");
result.push("\tcolor: " + elements['lineNumber'] + ";");
result.push("\tbackground-color: " + elements['annotationRuler'] + ";");
result.push("}");

result.push( theme + " .annotationLine.currentLine {");
result.push("\tbackground-color: " + elements['currentLine'] + ";");
result.push("}");

result.push( theme + " .entity-name-tag {");
result.push("\color: " + elements['keyword'] + ";");
result.push("}");

return result.join("\n");
}

var RegexUtil = {
// Rules to detect some unsupported Oniguruma features
unsupported: [
Expand Down Expand Up @@ -545,8 +429,8 @@ var RegexUtil = {
* produce this object by running a PList-to-JavaScript conversion tool on a TextMate <code>.tmLanguage</code> file.
* @param {Object[]} [externalGrammars] Additional grammar objects that will be used to resolve named rule references.
*/
function TextMateStyler(textView, grammar, externalGrammars, mBootStrap, util) {
this.initialize(textView, mBootStrap);
function TextMateStyler(textView, grammar, externalGrammars) {
this.initialize(textView);
// Copy grammar object(s) since we will mutate them
this.grammar = clone(grammar);
this.externalGrammars = externalGrammars ? clone(externalGrammars) : [];
Expand All @@ -555,26 +439,13 @@ var RegexUtil = {
this._tree = null;
this._allGrammars = {}; /* key: {String} scopeName of grammar, value: {Object} grammar */
this.preprocess(this.grammar);
this._updateStylesheet = _updateStylesheet;
this._update = _update;
this._styleSheet = _styleSheet;
this.util = util;
}
TextMateStyler.prototype = /** @lends orion.editor.TextMateStyler.prototype */ {
initialize: function(textView, mBootStrap, util) {
initialize: function(textView) {
this.textView = textView;
this.textView.stylerOptions = this;
var self = this;

if (this.textView && mBootStrap) {
mBootStrap.startup().then(function(core) {
preferences = core.preferences;
self.preferences = preferences;
self._updateStylesheet(preferences, util);
self.storageKey = preferences.listenForChangedSettings( self._listener.onStorage );
});
}

this._listener = {
onModelChanged: function(e) {
self.onModelChanged(e);
Expand All @@ -597,11 +468,6 @@ var RegexUtil = {
onDestroy: function(/**eclipse.DestroyEvent*/ e) {
this.destroy();
},
onStorage: function (e) {
if( e.key === this.storageKey ){
this._updateStylesheet( this.preferences );
}
},
destroy: function() {
if (this.textView) {
this.textView.removeEventListener("ModelChanged", this._listener.onModelChanged);
Expand Down
190 changes: 190 additions & 0 deletions bundles/org.eclipse.orion.client.editor/web/orion/editor/textTheme.js
@@ -0,0 +1,190 @@
/*******************************************************************************
* @license
* Copyright (c) 2013 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
* (http://www.eclipse.org/legal/epl-v10.html), and the Eclipse Distribution
* License v1.0 (http://www.eclipse.org/org/documents/edl-v10.html).
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/

/*globals define document*/

define("orion/editor/textTheme", ['orion/editor/eventTarget', 'orion/editor/util'], function(mEventTarget, util) {
var THEME_PREFIX = "orion-theme-";

var DefaultTheme;

/**
* Constructs a new text theme.
*
* @class A TextTheme is a class used to specify an editor theme.
* @name orion.editor.TextTheme
* @borrows orion.editor.EventTarget#addEventListener as #addEventListener
* @borrows orion.editor.EventTarget#removeEventListener as #removeEventListener
* @borrows orion.editor.EventTarget#dispatchEvent as #dispatchEvent
*/
function TextTheme() {

}

TextTheme.getTheme = function() {
if (!DefaultTheme) {
//TODO: Load a default sheet somehow
DefaultTheme = new TextTheme();
}
return DefaultTheme;
};

TextTheme.prototype = /** @lends orion.editor.TextTheme.prototype */ {
load: function (className, styleSheet) {
//check to see if ID exists already
var node = document.getElementById(THEME_PREFIX + className);
if (node) {
//TODO: Check if contents are the same, if so return
node.removeChild(node.firstChild);
node.appendChild(document.createTextNode(styleSheet));
} else {
node = util.createElement(document, "style");
node.appendChild(document.createTextNode(styleSheet));
var head = document.getElementsByTagName("head")[0] || document.documentElement;
head.appendChild(node);
}
},
setThemeClass: function(className, styleSheet) {
//TODO: Also need to check the styleSheet contents before determining if it is the same
//if (className === this._themeClass) { return; }
this._themeClass = className;
this.load(className, styleSheet);
this.onThemeChanged({type: "ThemeChanged"});
},
getThemeClass: function() {
return this._themeClass;
},
/**
* @class This is the event sent when the current theme has changed.
* <p>
* <b>See:</b><br/>
* {@link orion.editor.TextTheme}<br/>
* {@link orion.editor.TextTheme#event:onThemeChanged}
* </p>
* @name orion.editor.ThemeChangedEvent
*/
/**
* This event is sent when the current theme has changed.
*
* @event
* @param {orion.editor.ThemeChangedEvent} themeChangedEvent the event
*/
onThemeChanged: function(themeChangedEvent) {
return this.dispatchEvent(themeChangedEvent);
},
buildStyleSheet: function(settings, theme ){

var result = [];
result.push("");

//view container
var family = settings.fontFamily;
if(family === "sans serif"){
family = '"Menlo", "Consolas", "Vera Mono", "monospace"';
}else{
family = 'monospace';
}

result.push("." + theme + " {");
result.push("\tfont-family: " + family + ";");
result.push("\tfont-size: " + settings.fontSize + ";");

result.push("\tcolor: " + settings.text + ";");
result.push("}");

//From textview.css
result.push("." + theme + " .textview {");
result.push("\tbackground-color: " + settings.background + ";");
result.push("}");

//From rulers.css
result.push("." + theme + " .ruler.annotations {");
result.push("\tbackground-color: " + settings.annotationRuler + ";");
result.push("}");

result.push("." + theme + " .ruler.lines {");
result.push("\tbackground-color: " + settings.annotationRuler + ";");
result.push("}");

result.push("." + theme + " .ruler.folding {");
result.push("\tbackground-color: " + settings.annotationRuler + ";");
result.push("}");

result.push("." + theme + " .ruler.overview {");
result.push("\tbackground-color: " + settings.overviewRuler + ";");
result.push("}");

result.push("." + theme + " .rulerLines {");
result.push("\tcolor: " + settings.lineNumber + ";");
result.push("}");

result.push("." + theme + " .rulerLines.even {");
result.push("\tcolor: " + settings.lineNumberEven + ";");
result.push("}");

result.push("." + theme + " .rulerLines.odd {");
result.push("\tcolor: " + settings.lineNumberOdd + ";");
result.push("}");

//From annotations.css
result.push("." + theme + " .annotationLine.currentLine {");
result.push("\tbackground-color: " + settings.currentLine + ";");
result.push("}");

//From default-theme.css
result.push("." + theme + " .entity-name-tag {");
result.push("\tcolor: " + settings.keyword + ";");
result.push("}");

result.push("." + theme + " .entity-other-attribute-name {");
result.push("\tcolor: " + settings.attribute + ";");
result.push("}");

result.push("." + theme + " .string-quoted {");
result.push("\tcolor: " + settings.string + ";");
result.push("}");

//From textstyler.css
result.push("." + theme + " .token_keyword {");
result.push("\tcolor: " + settings.keyword + ";");
result.push("}");

result.push("." + theme + " .token_string {");
result.push("\tcolor: " + settings.string + ";");
result.push("}");

result.push("." + theme + " .token_singleline_comment {");
result.push("\tcolor: " + settings.comment + ";");
result.push("}");

result.push("." + theme + " .token_multiline_comment {");
result.push("\tcolor: " + settings.comment + ";");
result.push("}");

result.push("." + theme + " .token_doc_comment {");
result.push("\tcolor: " + settings.comment + ";");
result.push("}");

result.push("." + theme + " .token_doc_html_markup {");
result.push("\tcolor: " + settings.comment + ";");
result.push("}");

return result.join("\n");
}
};
mEventTarget.EventTarget.addMixin(TextTheme.prototype);

return {
TextTheme: TextTheme
};

});
Expand Up @@ -14,7 +14,7 @@

/*global define*/

define("orion/editor/textView", ['orion/editor/textModel', 'orion/editor/keyBinding', 'orion/editor/eventTarget', 'orion/editor/util'], function(mTextModel, mKeyBinding, mEventTarget, util) { //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$
define("orion/editor/textView", ['orion/editor/textModel', 'orion/editor/keyBinding', 'orion/editor/eventTarget', 'orion/editor/textTheme', 'orion/editor/util'], function(mTextModel, mKeyBinding, mEventTarget, mTextTheme, util) { //$NON-NLS-4$ //$NON-NLS-3$ //$NON-NLS-2$ //$NON-NLS-1$ //$NON-NLS-0$

/** @private */
function getWindow(document) {
Expand Down Expand Up @@ -4961,6 +4961,14 @@ define("orion/editor/textView", ['orion/editor/textModel', 'orion/editor/keyBind
this._model.addEventListener("preChanging", this._modelListener.onChanging); //$NON-NLS-0$
this._model.addEventListener("postChanged", this._modelListener.onChanged); //$NON-NLS-0$

var theme = mTextTheme.TextTheme.getTheme();
this._themeListener = {
onChanged: function(themeChangedEvent) {
self._setThemeClass(theme.getThemeClass());
}
};
theme.addEventListener("ThemeChanged", this._themeListener.onChanged); //$NON-NLS-0$

var handlers = this._handlers = [];
var clientDiv = this._clientDiv, viewDiv = this._viewDiv, rootDiv = this._rootDiv;
var topNode = this._overlayDiv || clientDiv;
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.orion.client.ui/web/edit/setup.js
Expand Up @@ -141,7 +141,7 @@ exports.setUpEditor = function(serviceRegistry, preferences, isReadOnly){
name = self.getTitle();
}

var chooser = new mThemeChooser.MiniThemeChooser( preferences, editor.getTextView() );
var chooser = new mThemeChooser.MiniThemeChooser( preferences );
mGlobalCommands.addSettings( chooser );

mGlobalCommands.setPageTarget({task: "Coding", name: name, target: metadata, //$NON-NLS-0$
Expand Down
11 changes: 3 additions & 8 deletions bundles/org.eclipse.orion.client.ui/web/orion/highlight.js
Expand Up @@ -10,9 +10,8 @@
******************************************************************************/

/*global define*/
define(['examples/editor/textStyler', 'orion/editor/textMateStyler', 'orion/editor/AsyncStyler',
'examples/editor/textStylerOptions', 'orion/bootstrap', 'orion/editor/util', 'orion/Deferred'],
function(mTextStyler, mTextMateStyler, AsyncStyler, mTextStylerOptions, mBootstrap, util, Deferred) {
define(['examples/editor/textStyler', 'orion/editor/textMateStyler', 'orion/editor/AsyncStyler', 'orion/Deferred'],
function(mTextStyler, mTextMateStyler, AsyncStyler, Deferred) {
/**
* Returns a promise that will provide a styler for the given content type.
* @static
Expand Down Expand Up @@ -59,10 +58,6 @@ define(['examples/editor/textStyler', 'orion/editor/textMateStyler', 'orion/edit
styler = new mTextStyler.TextStyler(textView, "css", annotationModel); //$NON-NLS-0$
break;
}
if (styler) {
// Temporary. Add support for the preference page.
new mTextStylerOptions.TextStylerOptions(styler);
}
return styler;
}
// Check default styler
Expand Down Expand Up @@ -105,7 +100,7 @@ define(['examples/editor/textStyler', 'orion/editor/textMateStyler', 'orion/edit
styler.setContentType(contentType);
} else if (type === "grammar" || typeof type === "undefined") { //$NON-NLS-1$ //$NON-NLS-0$
var grammar = provider.getProperty("grammar"); //$NON-NLS-0$
styler = new mTextMateStyler.TextMateStyler(textView, grammar, grammars, mBootstrap, util);
styler = new mTextMateStyler.TextMateStyler(textView, grammar, grammars);
}
}
return styler;
Expand Down
Expand Up @@ -18,7 +18,6 @@ define({
"Title": "Title",
"Plugins": "Plugins",
"User Profile": "User Profile",
"JavaScript Editor": "JavaScript Editor",
"General": "General",
"Navigation": "Navigation",
"Open in same tab": "Open in same tab",
Expand Down

This file was deleted.

Expand Up @@ -22,10 +22,9 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
'orion/widgets/themes/container/ThemeData',
'orion/widgets/settings/SplitSelectionLayout',
'orion/widgets/plugin/PluginList',
'orion/widgets/settings/UserSettings',
'orion/widgets/settings/InputBuilder'
'orion/widgets/settings/UserSettings'
], function(messages, require, mGlobalCommands, PageUtil, lib, objects, URITemplate,
ThemeBuilder, SettingsList, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings, InputBuilder) {
ThemeBuilder, SettingsList, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings) {

/**
* @param {Object} options
Expand Down Expand Up @@ -81,7 +80,6 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
// to build the UI until there are settings to be found there.
window.setTimeout(function() {
this.drawUserInterface();
this.inputBuilder = new InputBuilder( this.preferences );
}.bind(this), 100);
window.addEventListener("hashchange", this.processHash.bind(this)); //$NON-NLS-0$

Expand Down Expand Up @@ -163,10 +161,6 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',

showUserSettings: function(id){

// var td = this.preferences.getPreferences('/settings', 2).then( function(prefs){ //$NON-NLS-0$
// var navigate = prefs.get(messages["JavaScript Editor"]);
// } );

this.selectCategory(id);

lib.empty(this.table);
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -177,8 +177,8 @@ define(['orion/widgets/themes/container/ThemeSheetWriter'],
ThemeData.prototype.getStyles = getStyles;


function getThemeStorageInfo(){
var themeInfo = { storage:'/themes', styleset:'styles', defaultTheme:'orion' };
function getThemeStorageInfo(){
var themeInfo = { storage:'/themes', styleset:'styles', defaultTheme:'orion', selectedKey: 'selected' };
return themeInfo;
}

Expand Down
Expand Up @@ -11,14 +11,20 @@
/*global orion window console define localStorage*/
/*jslint browser:true*/

define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/editor/ThemeData','orion/widgets/input/Select'],
function(messages, require, ThemeData, Select ) {
define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/editor/ThemeData', 'orion/editor/textTheme', 'orion/widgets/input/Select'],
function(messages, require, ThemeData, mTextTheme, Select ) {

function MiniThemeChooser(preferences, textview){
function MiniThemeChooser(preferences){
this.preferences = preferences;
this.textview = textview;
this.themeData = new ThemeData.ThemeData();
this.initializeStorage();
var miniChooser = this;
//TODO: Need an abstract class that both setup.js and MiniThemeChooser.js can use to change the settings
var storageKey = preferences.listenForChangedSettings(function(e) {
if (e.key === storageKey) {
miniChooser.selectTheme();
}
});
}

MiniThemeChooser.prototype.template = '<div id="themeContainer">' +
Expand Down Expand Up @@ -82,13 +88,11 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit

var themeInfo = this.themeData.getThemeStorageInfo();
var themeData = this.themeData;
var selectedTheme;
var settings;

var miniChooser = this;

this.preferences.getPreferences(themeInfo.storage, 2).then(function(prefs){ //$NON-NLS-0$

var currentTheme = prefs.get( 'selected' );

if( !currentTheme && !name ){
Expand All @@ -97,11 +101,22 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
prefs.put( themeInfo.styleset, JSON.stringify(styleset) );
}

if( currentTheme ){
currentTheme = JSON.parse ( currentTheme );
} else {
currentTheme = {};
currentTheme[themeInfo.selectedKey] = name;
}

if( currentTheme && !name ) {
name = currentTheme[themeInfo.selectedKey];
}

if( name ){

selectedTheme = { 'selected': name };
currentTheme[themeInfo.selectedKey] = name;

var styles = prefs.get( 'editorstyles' );
var styles = prefs.get( themeInfo.styleset );

if( styles ){
styles = JSON.parse( styles );
Expand All @@ -115,8 +130,7 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
}
}
}

prefs.put( 'selected', JSON.stringify(selectedTheme) );
prefs.put( 'selected', JSON.stringify(currentTheme) );

miniChooser.setThemeData( settings );
}
Expand All @@ -126,51 +140,13 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
MiniThemeChooser.prototype.selectTheme = selectTheme;

function setThemeData( settings ){

var subcategories;
var tv = this.textview;

this.preferences.getPreferences('/settings', 2).then(function(prefs){

if( settings ){
var font = {};
font.label = 'Font';
font.data = [ { label:'Family', value: 'Sans Serif', ui:'Font' },
{ label:'Size', value: settings.fontSize.value, ui:'Font' },
{ label:'Color', value: settings.text.value },
{ label:'Background', value: settings.background.value } ];

subcategories = [ { element: 'fontFamily', value: 'sans serif' },
{ element: 'fontSize', value: settings.fontSize },
{ element: 'fontWeight', value: 'normal' },
{ element: 'text', value: settings.text },
{ element: 'background', value: settings.background },
{ element: 'string', value: settings.string },
{ element: 'annotationRuler', value: settings.annotationRuler },
{ element: 'comment', value: settings.comment },
{ element: 'keyword', value: settings.keyword },
{ element: 'overviewRuler', value: settings.overviewRuler },
{ element: 'annotationRuler', value: settings.annotationRuler },
{ element: 'lineNumber', value: settings.lineNumber },
{ element: 'currentLine', value: settings.currentLine },
{ element: 'attribute', value: settings.attribute }
];

prefs.put( 'JavaScript Editor', JSON.stringify(subcategories) );

if( tv.stylerOptions ){
tv.stylerOptions._update( subcategories, tv.stylerOptions );
}
}
} );
var theme = mTextTheme.TextTheme.getTheme();
theme.setThemeClass("userTheme", theme.buildStyleSheet(settings, "userTheme"));
}

MiniThemeChooser.prototype.setThemeData = setThemeData;

function initializeStorage(){
var builder = this;
var themeInfo = this.themeData.getThemeStorageInfo();
var themeData = this.themeData;
this.selectTheme();
}

Expand All @@ -180,64 +156,53 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit

var themeInfo = this.themeData.getThemeStorageInfo();

var tv = this.textview;
var miniChooser = this;

this.preferences.getPreferences('/settings', 2).then(function(prefs){

var styles = prefs.get( 'JavaScript Editor' );
this.preferences.getPreferences(themeInfo.storage, 2).then(function(prefs){
var styles = prefs.get( themeInfo.styleset );
var selection = prefs.get( 'selected' );
if(selection){ selection = JSON.parse( selection ); }
var settings;

if(styles){
styles = JSON.parse( styles );
if( styles ){
styles = JSON.parse( styles );

for( var s in styles ){
if( styles[s].element === 'fontSize' ){
styles[s].value = size;
break;
for( var s = 0; s < styles.length; s++ ){
styles[s].fontSize = size;
if( styles[s].name === selection[themeInfo.selectedKey] ){
settings = styles[s];
}

}
}

prefs.put( 'JavaScript Editor', JSON.stringify(styles) );

var nodes = document.querySelectorAll( '.userTheme' );
for( var item in nodes ){
if( nodes[item].style ){
nodes[item].style.fontSize = size;
}
}

nodes = document.querySelectorAll( '.textviewContainer' );

prefs.put( themeInfo.styleset , JSON.stringify(styles) );

for( var item in nodes ){
if( nodes[item].style ){
nodes[item].style.fontSize = size;
}
if( settings ){
miniChooser.setThemeData( settings );
}

tv.update( true );
});
}

MiniThemeChooser.prototype.selectFontSize = selectFontSize;

function addFontSizePicker(){

var chooser = this;
var miniChooser = this;

var currentSize = '10pt';

var themeInfo = this.themeData.getThemeStorageInfo();

this.preferences.getPreferences('/settings', 2).then(function(prefs){

var styles = prefs.get( 'JavaScript Editor' );

if(styles){
styles = JSON.parse( styles );

for( var s in styles ){
if( styles[s].element === 'fontSize' ){
currentSize = styles[s].value;
this.preferences.getPreferences(themeInfo.storage, 2).then(function(prefs){
var styles = prefs.get( themeInfo.styleset );
var selection = prefs.get( 'selected' );
if(selection){ selection = JSON.parse( selection ); }
if( styles ){
styles = JSON.parse( styles );
for( var s = 0; s < styles.length; s++ ){
if( styles[s].name === selection[themeInfo.selectedKey] ){
currentSize = styles[s].fontSize;
break;
}
}
Expand All @@ -262,7 +227,7 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
}

this.sizeSelect = new Select( { options: options }, picker );
this.sizeSelect.setStorageItem = chooser.selectFontSize.bind(chooser);
this.sizeSelect.setStorageItem = miniChooser.selectFontSize.bind(miniChooser);
this.sizeSelect.show();
});
}
Expand All @@ -277,7 +242,7 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
var options = [];

var chooser = this;

var selection = prefs.get( 'selected' );

if(selection){ selection = JSON.parse( selection ); }
Expand All @@ -295,20 +260,21 @@ define(['i18n!orion/settings/nls/messages', 'require','orion/widgets/themes/edit
}

if(!selection) {
selection = { 'selected':'Prospecto' };
selection = {};
selection[themeInfo.selectedKey] = themeInfo.defaultTheme;
}

if( styles ){

for( var theme in styles ){
for( var theme= 0; theme < styles.length; theme++ ){

var set = {
value: styles[theme].name,
label: styles[theme].name
};

if( selection ){
if( styles[theme].name === selection.selected ){
if( styles[theme].name === selection[themeInfo.selectedKey] ){
set.selected = true;
}
}
Expand Down
Expand Up @@ -233,7 +233,7 @@ define([],
ThemeData.prototype.fontSettable = fontSettable;

function getThemeStorageInfo(){
var themeInfo = { storage:'/themes', styleset:'editorstyles', defaultTheme:'Prospecto' };
var themeInfo = { storage:'/themes', styleset:'editorstyles', defaultTheme:'Prospecto', selectedKey: 'editorSelected' };
return themeInfo;
}

Expand Down Expand Up @@ -682,7 +682,7 @@ define([],

var newStyle = new StyleSet();

newStyle.name = xml.getElementsByTagName("colorTheme")[0].attributes[1].value;;
newStyle.name = xml.getElementsByTagName("colorTheme")[0].attributes[1].value;
newStyle.annotationRuler = xml.getElementsByTagName("background")[0].attributes[0].value;
newStyle.background = xml.getElementsByTagName("background")[0].attributes[0].value;
newStyle.comment = xml.getElementsByTagName("singleLineComment")[0].attributes[0].value;
Expand All @@ -703,39 +703,7 @@ define([],
ThemeData.prototype.importTheme = importTheme;

function processSettings( settings, preferences ){

if( !settings['fontSize'] ){
settings['fontSize'] = { value:'10pt' };
}

preferences.getPreferences('/settings', 2).then(function(prefs){ //$NON-NLS-0$

var font = {};
font.label = 'Font';
font.data = [ { label:'Family', value: 'Sans Serif', ui:'Font' },
{ label:'Size', value: settings['fontSize'].value, ui:'Font' },
{ label:'Color', value: settings['text'].value },
{ label:'Background', value: settings['background'].value } ];

var subcategories = [ { element: 'fontFamily', value: 'sans serif' },
{ element: 'fontSize', value: settings['fontSize'].value },
{ element: 'fontWeight', value: 'normal' },
{ element: 'text', value: settings['text'].value },
{ element: 'background', value: settings['background'].value },
{ element: 'string', value: settings['string'].value },
{ element: 'annotationRuler', value: settings['annotationRuler'].value },
{ element: 'comment', value: settings['comment'].value },
{ element: 'keyword', value: settings['keyword'].value },
{ element: 'overviewRuler', value: settings['overviewRuler'].value },
{ element: 'annotationRuler', value: settings['annotationRuler'].value },
{ element: 'lineNumber', value: settings['lineNumber'].value },
{ element: 'currentLine', value: settings['currentLine'].value },
{ element: 'attribute', value: settings['attribute'].value }
];

prefs.put( 'JavaScript Editor', JSON.stringify(subcategories) );

});

}

ThemeData.prototype.processSettings = processSettings;
Expand Down
4 changes: 0 additions & 4 deletions bundles/org.eclipse.orion.client.ui/web/settings/settings.js
Expand Up @@ -52,10 +52,6 @@ define(['i18n!orion/settings/nls/messages', 'orion/bootstrap', 'orion/status', '
prefs.put("selected", null); //$NON-NLS-0$
preferencesStatusService.setMessage("Theme settings have been cleared.");
});
preferences.getPreferences('/settings', 2).then(function(prefs) { //$NON-NLS-0$
prefs.put("JavaScript Editor", null); //$NON-NLS-0$ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=386765
preferencesStatusService.setMessage("Theme settings have been cleared.");
});
}});
commandService.addCommand(clearPrefsCommand);
// add as a binding only command
Expand Down
Expand Up @@ -22,10 +22,9 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
'orion/widgets/themes/container/ThemeData',
'orion/widgets/settings/SplitSelectionLayout',
'orion/widgets/plugin/PluginList',
'orion/widgets/settings/UserSettings',
'orion/widgets/settings/InputBuilder'
'orion/widgets/settings/UserSettings'
], function(messages, require, mGlobalCommands, PageUtil, lib, objects, URITemplate,
ThemeBuilder, SettingsList, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings, InputBuilder) {
ThemeBuilder, SettingsList, editorThemeData, containerThemeData, SplitSelectionLayout, PluginList, UserSettings) {

/**
* @param {Object} options
Expand Down Expand Up @@ -81,7 +80,6 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
// to build the UI until there are settings to be found there.
window.setTimeout(function() {
this.drawUserInterface();
this.inputBuilder = new InputBuilder( this.preferences );
}.bind(this), 100);
window.addEventListener("hashchange", this.processHash.bind(this)); //$NON-NLS-0$

Expand Down Expand Up @@ -162,10 +160,6 @@ define(['i18n!orion/settings/nls/messages', 'require', 'orion/globalCommands',
},

showUserSettings: function(id){

// var td = this.preferences.getPreferences('/settings', 2).then( function(prefs){ //$NON-NLS-0$
// var navigate = prefs.get(messages["JavaScript Editor"]);
// } );

this.selectCategory(id);

Expand Down
4 changes: 0 additions & 4 deletions modules/orionode/lib/orionode.client/settings/settings.js
Expand Up @@ -51,10 +51,6 @@ define(['i18n!orion/settings/nls/messages', 'orion/bootstrap', 'orion/status', '
prefs.put("selected", null); //$NON-NLS-0$
preferencesStatusService.setMessage("Theme settings have been cleared.");
});
preferences.getPreferences('/settings', 2).then(function(prefs) { //$NON-NLS-0$
prefs.put("JavaScript Editor", null); //$NON-NLS-0$ // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=386765
preferencesStatusService.setMessage("Theme settings have been cleared.");
});
}});
commandService.addCommand(clearPrefsCommand);
// add as a binding only command
Expand Down