Skip to content

Commit 702f004

Browse files
committed
merciless adding comments and renaming variables (not yet classes) to
make things clear
1 parent d9d0065 commit 702f004

File tree

9 files changed

+116
-61
lines changed

9 files changed

+116
-61
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,19 @@ For example [add Blue Light theme](https://github.com/Nodeclipse/EditBox/commit/
2727

2828
Latest released version is 0.60.0.
2929

30-
mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=0.60.0-SNAPSHOT
30+
mvn -Dtycho.mode=maven org.eclipse.tycho:tycho-versions-plugin:set-version -DnewVersion=0.65.0-SNAPSHOT
3131

3232
While it is nice to play with colors, there are Nodeclipse core projects to do.
3333
If there are updates here, they will be released together with [Nodeclipse train](http://www.nodeclipse.org/history).
3434

35+
### History
36+
37+
0.50
38+
0.55
39+
0.60
40+
0.65 (2014-08) change icon; combo to apply one of bundled themes to all categories
41+
(this is done for case when switching to black themes and back)
42+
3543
## Themes
3644

3745
Text Category included `*.*` file mask. Remove it for better customization.
@@ -90,6 +98,17 @@ see `pm.eclipse.editbox\docs` for an example.
9098

9199
### Terms
92100

101+
Looking at code and .prefs file
102+
103+
```
104+
pm.eclipse.editbox.provider.java_Default=\#COMMENT\r\n\#Mon Jun 30 17\:24\:47 CST 2014\r\nHighlightOne\=false\r\nFillGradient\=false\r\nFillSelected\=true\r\nRoundBox\=true\r\nBorderColorType\=1\r\nName\=Default\r\nExpandBox\=false\r\nBorderDrawLine\=false\r\nFillOnMove\=true\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=acb3b7\r\nBorderColor\=c0c0c0\r\nFillKeyModifier\=Alt\r\nHighlightColorType\=3\r\nFillGradientColor\=dadcc2\r\nBuilder\=Java\r\nHighlightDrawLine\=false\r\nFillSelectedColor\=ffffff\r\nBorderLineStyle\=2\r\nColors\=ffffff-c5d0ac-d9e3b7-e8ecd9\r\nHighlightLineStyle\=0\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
105+
pm.eclipse.editbox.provider.java_RainbowDrops=\#COMMENT\r\n\#Wed Jul 09 17\:06\:50 CST 2014\r\nHighlightOne\=true\r\nFillGradient\=false\r\nFillSelected\=false\r\nRoundBox\=false\r\nBorderColorType\=0\r\nName\=RainbowDrops\r\nExpandBox\=false\r\nBorderDrawLine\=true\r\nFillOnMove\=false\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=00ff00\r\nBorderColor\=00bbbb\r\nFillKeyModifier\=Alt\r\nHighlightColorType\=0\r\nFillGradientColor\=null\r\nBuilder\=Java\r\nHighlightDrawLine\=true\r\nFillSelectedColor\=202020\r\nBorderLineStyle\=1\r\nColors\=202020-null\r\nHighlightLineStyle\=0\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
106+
pm.eclipse.editbox.provider.java_catalog=Default,Whitebox,OnClick,GreyGradient,Java_v_20,RainbowDropsLine,RainbowDropsLineFill,BlueToDeepBlue,OrangeToRed,BlueGradient22WithDarkBoldLeftBorder,BlueLight,Java_PaleBlue,RainbowDrops
107+
pm.eclipse.editbox.provider.java_default=RainbowDrops
108+
pm.eclipse.editbox.provider.java_enabled=true
109+
pm.eclipse.editbox.provider.java_fileNames=*.java,*.class,*.gradle,*.groovy,*.scala
110+
```
111+
93112
Catalog is list of Themes.
94113
Provider `BoxProviderImpl` is Category . Provider is holding theme (Settings object).
95114
Theme `BoxSettingsImpl` is set of colors .

pm.eclipse.editbox/src/pm/eclipse/editbox/EditBox.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ public BoxProviderRegistry getProviderRegistry(){
4444
}
4545

4646
public boolean isEnabled() {
47-
if (getPreferenceStore().contains(ENABLED))
47+
//if (getPreferenceStore().contains(ENABLED))
4848
return getPreferenceStore().getBoolean(ENABLED);
49-
return false;
49+
//return false;
5050
}
5151

5252
public void setEnabled(boolean flag){

pm.eclipse.editbox/src/pm/eclipse/editbox/IBoxSettingsStore.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
import java.util.Set;
44

55

6+
/**
7+
* How this provider is saved into several lines of Eclipse preferences
8+
* see BoxSettingsStoreImpl
9+
*/
610
public interface IBoxSettingsStore {
711

812
void setProviderId(String id);

pm.eclipse.editbox/src/pm/eclipse/editbox/impl/BoxProviderImpl.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public BoxSettingsStoreImpl getSettingsStore() {
3737

3838
public IBoxSettings getEditorsBoxSettings() {
3939
if (editorsSettings == null) {
40-
editorsSettings = createSettings0();
40+
editorsSettings = createEmptySettings();
4141
getSettingsStore().loadDefaults(editorsSettings);
4242
editorsSettings.addPropertyChangeListener(new IPropertyChangeListener() {
4343
public void propertyChange(PropertyChangeEvent event) {
@@ -132,12 +132,12 @@ public void setDefaultSettingsCatalog(Collection<String> cat){
132132
}
133133

134134
public IBoxSettings createSettings() {
135-
BoxSettingsImpl result = createSettings0();
135+
BoxSettingsImpl result = createEmptySettings();
136136
result.copyFrom(getEditorsBoxSettings());
137137
return result;
138138
}
139139

140-
protected BoxSettingsImpl createSettings0() {
140+
protected BoxSettingsImpl createEmptySettings() {
141141
return new BoxSettingsImpl();
142142
}
143143

pm.eclipse.editbox/src/pm/eclipse/editbox/impl/BoxProviderRegistry.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
*/
2525
public class BoxProviderRegistry {
2626

27-
//used to get Preferences, if changed, user preferences are gone after update
27+
//used to get Preferences, if this misspelled value is changed, user preferences are gone after update
2828
private static final String PROVIDERS = "proivders";
2929
// always added. Is it useless?
3030
private static final String PROVIDER_ID_ = "pm.eclipse.editbox.provider.";
@@ -46,11 +46,7 @@ public Collection<IBoxProvider> getBoxProviders() {
4646
if (providers == null){
4747
providers = defaultProviders();
4848
}else{
49-
// comparing providers from Preferences with defaultProviders
50-
// can be here
51-
// proivders=java,python,markup,text,js
52-
// createProvider(String name)
53-
//
49+
// comparing providers from Preferences with defaultProviders can be here
5450
}
5551
return providers;
5652
}

pm.eclipse.editbox/src/pm/eclipse/editbox/impl/BoxSettingsImpl.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
import pm.eclipse.editbox.EditBox;
1919
import pm.eclipse.editbox.IBoxSettings;
2020

21+
/**
22+
* Utils to handle theme, including serialization
23+
*
24+
*/
2125
public class BoxSettingsImpl implements IBoxSettings {
2226

2327
private static final BoxSettingsImpl DEFAULT = new BoxSettingsImpl(){{
@@ -35,9 +39,10 @@ public class BoxSettingsImpl implements IBoxSettings {
3539
fillKeyModifier = "Alt";
3640
}};
3741

42+
// this is actually domain model class Theme { //TODO extract into class ?
3843
protected boolean enabled;
3944
protected String name;
40-
protected String text;
45+
protected String text; //?
4146

4247
protected Color borderColor;
4348
protected Color highlightColor;
@@ -49,7 +54,6 @@ public class BoxSettingsImpl implements IBoxSettings {
4954
protected boolean roundBox;
5055
protected String builder;
5156
protected Color[] boxColors;
52-
protected ArrayList<IPropertyChangeListener> listeners;
5357
protected boolean highlightDrawLine;
5458
protected Color fillGradientColor;
5559
protected boolean fillGradient;
@@ -65,6 +69,8 @@ public class BoxSettingsImpl implements IBoxSettings {
6569
protected boolean noBackground;
6670
protected boolean expandBox;
6771
protected int alpha;
72+
//}
73+
protected ArrayList<IPropertyChangeListener> listeners;
6874

6975
private transient Color[] borderColors;
7076
private transient Color[] highlightColors;

pm.eclipse.editbox/src/pm/eclipse/editbox/impl/BoxSettingsStoreImpl.java

Lines changed: 51 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,31 @@
1414
import pm.eclipse.editbox.IBoxSettingsStore;
1515

1616

17+
/**
18+
* Saving to pm.eclipse.editbox.prefs
19+
<pre>
20+
pm.eclipse.editbox.provider.java_Default=\#COMMENT\r\n\#Mon Jun 30 17\:24\:47 CST 2014\r\nHighlightOne\=false\r\nFillGradient\=false\r\nFillSelected\=true\r\nRoundBox\=true\r\nBorderColorType\=1\r\nName\=Default\r\nExpandBox\=false\r\nBorderDrawLine\=false\r\nFillOnMove\=true\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=acb3b7\r\nBorderColor\=c0c0c0\r\nFillKeyModifier\=Alt\r\nHighlightColorType\=3\r\nFillGradientColor\=dadcc2\r\nBuilder\=Java\r\nHighlightDrawLine\=false\r\nFillSelectedColor\=ffffff\r\nBorderLineStyle\=2\r\nColors\=ffffff-c5d0ac-d9e3b7-e8ecd9\r\nHighlightLineStyle\=0\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
21+
pm.eclipse.editbox.provider.java_RainbowDrops=\#COMMENT\r\n\#Wed Jul 09 17\:06\:50 CST 2014\r\nHighlightOne\=true\r\nFillGradient\=false\r\nFillSelected\=false\r\nRoundBox\=false\r\nBorderColorType\=0\r\nName\=RainbowDrops\r\nExpandBox\=false\r\nBorderDrawLine\=true\r\nFillOnMove\=false\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=00ff00\r\nBorderColor\=00bbbb\r\nFillKeyModifier\=Alt\r\nHighlightColorType\=0\r\nFillGradientColor\=null\r\nBuilder\=Java\r\nHighlightDrawLine\=true\r\nFillSelectedColor\=202020\r\nBorderLineStyle\=1\r\nColors\=202020-null\r\nHighlightLineStyle\=0\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
22+
pm.eclipse.editbox.provider.java_catalog=Default,Whitebox,OnClick,GreyGradient,Java_v_20,RainbowDropsLine,RainbowDropsLineFill,BlueToDeepBlue,OrangeToRed,BlueGradient22WithDarkBoldLeftBorder,BlueLight,Java_PaleBlue,RainbowDrops
23+
pm.eclipse.editbox.provider.java_default=RainbowDrops
24+
pm.eclipse.editbox.provider.java_enabled=true
25+
pm.eclipse.editbox.provider.java_fileNames=*.java,*.class,*.gradle,*.groovy,*.scala
26+
pm.eclipse.editbox.provider.js_Default=\#COMMENT\r\n\#Fri Jul 04 11\:28\:13 CST 2014\r\nHighlightOne\=true\r\nFillGradient\=false\r\nFillSelected\=true\r\nRoundBox\=true\r\nBorderColorType\=0\r\nName\=Default\r\nExpandBox\=false\r\nBorderDrawLine\=false\r\nFillOnMove\=false\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=000000\r\nBorderColor\=00bbbb\r\nFillKeyModifier\=Alt\r\nHighlightColorType\=0\r\nFillGradientColor\=null\r\nBuilder\=Text\r\nHighlightDrawLine\=false\r\nFillSelectedColor\=ffffc4\r\nBorderLineStyle\=0\r\nColors\=null-d0dd9b-cdd8b9-e9f58b\r\nHighlightLineStyle\=0\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
27+
pm.eclipse.editbox.provider.js_RainbowDropsLineFill=\#COMMENT\r\n\#Wed Jul 09 17\:06\:50 CST 2014\r\nHighlightOne\=true\r\nFillGradient\=false\r\nFillSelected\=true\r\nRoundBox\=false\r\nBorderColorType\=0\r\nName\=RainbowDropsLineFill\r\nExpandBox\=false\r\nBorderDrawLine\=true\r\nFillOnMove\=true\r\nAlpha\=0\r\nHighlightWidth\=1\r\nBorderWidth\=1\r\nHighlightColor\=00ff00\r\nBorderColor\=00bbbb\r\nFillKeyModifier\=\r\nHighlightColorType\=0\r\nFillGradientColor\=null\r\nBuilder\=Java\r\nHighlightDrawLine\=true\r\nFillSelectedColor\=000080\r\nBorderLineStyle\=1\r\nColors\=202020-null\r\nHighlightLineStyle\=1\r\nNoBackground\=false\r\nCirculateLevelColors\=false\r\n
28+
pm.eclipse.editbox.provider.js_default=RainbowDropsLineFill
29+
pm.eclipse.editbox.provider.js_enabled=true
30+
pm.eclipse.editbox.provider.js_fileNames=*.js,*.jjs,*.jshintrc,*.mjs,*.njs,*.pjs,*.vjs,*.ts,*.coffee,*.dart
31+
</pre>
32+
* where java or js is providerId
33+
* keys starting with Capital are actually themes names
34+
*/
1735
public class BoxSettingsStoreImpl implements IBoxSettingsStore {
1836

1937
private static final String FILE_NAMES = "fileNames";
2038
private static final String TXT_POSTFIX = "$txt";
21-
private static final String DEFAULT = "default";
39+
private static final String DEFAULT = "default"; //what theme to use as default
2240
private static final String ENABLED = "enabled";
41+
private static final String CATALOG = "catalog";
2342
protected String providerId;
2443
protected IPreferenceStore store;
2544
private Set<String> catalog;
@@ -31,54 +50,60 @@ protected IPreferenceStore getStore(){
3150
return store;
3251
}
3352

34-
protected String key(String postfix){
53+
protected String providerKey(String postfix){
3554
return providerId+"_"+postfix;
3655
}
3756

57+
@Override
3858
public void setProviderId(String id) {
3959
this.providerId = id;
4060
}
4161

62+
@Override
4263
public void loadDefaults(IBoxSettings editorsSettings) {
43-
String defaultName = getStore().getString(key(DEFAULT));
44-
if (isEmpty(defaultName)) defaultName = providerId;
45-
load(defaultName,editorsSettings);
46-
}
47-
48-
public void load(String name, IBoxSettings editorsSettings) {
49-
String value = getStore().getString(key(name));
50-
if (!isEmpty(value))
51-
editorsSettings.load(value);
64+
String defaultThemeName = getStore().getString(providerKey(DEFAULT));
65+
if (isEmpty(defaultThemeName)){
66+
defaultThemeName = providerId;
67+
}
68+
load(defaultThemeName, editorsSettings);
69+
}
70+
71+
@Override
72+
public void load(String themeName, IBoxSettings editorsSettings) {
73+
String themeInsideString = getStore().getString(providerKey(themeName));
74+
if (!isEmpty(themeInsideString))
75+
editorsSettings.load(themeInsideString);
5276
else
5377
try {
54-
editorsSettings.load(getClass().getResourceAsStream("/"+name + ".eb"));
78+
editorsSettings.load(getClass().getResourceAsStream("/"+themeName + ".eb"));
5579
} catch (Exception e) {
56-
EditBox.logError(this, "Error loading settings: "+name, e);
80+
EditBox.logError(this, "Error loading settings: "+themeName, e);
5781
}
5882
editorsSettings.setEnabled(getIsEnabled());
5983
editorsSettings.setFileNames(getFileNames());
6084
}
6185

62-
protected boolean isEmpty(String s) {
86+
protected static boolean isEmpty(String s) {
6387
return s == null || s.length() == 0;
6488
}
6589

6690
protected boolean getIsEnabled() {
67-
String key = key(ENABLED);
91+
String key = providerKey(ENABLED);
6892
if (getStore().contains(key))
6993
return getStore().getBoolean(key);
7094
return true;
7195
}
7296

97+
@Override
7398
public void saveDefaults(IBoxSettings settings) {
74-
getStore().setValue(key(ENABLED), settings.getEnabled()?"true":"false");
75-
getStore().setValue(key(DEFAULT),settings.getName());
99+
getStore().setValue(providerKey(ENABLED), settings.getEnabled()?"true":"false");
100+
getStore().setValue(providerKey(DEFAULT), settings.getName());
76101
store(settings);
77102
}
78103

79104
public void store(IBoxSettings settings) {
80105
String name = settings.getName();
81-
getStore().setValue(key(name),settings.export());
106+
getStore().setValue(providerKey(name),settings.export());
82107
setFileNames(settings.getFileNames());
83108
addToCatalog(name);
84109
EditBox.getDefault().savePluginPreferences();
@@ -98,13 +123,14 @@ private void storeCatalog(Set<String> cat) {
98123
if (sb.length()>0) sb.append(",");
99124
sb.append(c);
100125
}
101-
getStore().setValue(key("catalog"), sb.toString());
126+
getStore().setValue(providerKey(CATALOG), sb.toString());
102127
}
103128

129+
@Override
104130
public Set<String> getCatalog() {
105131
if (catalog == null){
106132
catalog = new LinkedHashSet<String>();
107-
String cstr = getStore().getString(key("catalog"));
133+
String cstr = getStore().getString(providerKey(CATALOG));
108134
if (!isEmpty(cstr))
109135
for (String s : cstr.split(","))
110136
catalog.add(s);
@@ -119,11 +145,12 @@ public void setDefaultSettingsCatalog(Collection<String> cat){
119145
defaultCatalog = cat;
120146
}
121147

148+
@Override
122149
public void remove(String name) {
123150
if (getCatalog().remove(name))
124151
storeCatalog(getCatalog());
125-
getStore().setValue(key(name), "");
126-
getStore().setValue(key(name+TXT_POSTFIX), "");
152+
getStore().setValue(providerKey(name), "");
153+
getStore().setValue(providerKey(name+TXT_POSTFIX), "");
127154
EditBox.getDefault().savePluginPreferences();
128155
}
129156

@@ -138,14 +165,14 @@ protected void setFileNames(Collection<String> fileNames) {
138165
first = false;
139166
}
140167
}
141-
getStore().setValue(key(FILE_NAMES), sb.toString());
168+
getStore().setValue(providerKey(FILE_NAMES), sb.toString());
142169
}
143170

144171
/*
145172
* @return null if settings never stored before
146173
*/
147174
protected Collection<String> getFileNames() {
148-
String key = key(FILE_NAMES);
175+
String key = providerKey(FILE_NAMES);
149176

150177
if (!getStore().contains(key))
151178
return null;

0 commit comments

Comments
 (0)