|
From: Christopher W. <caw...@us...> - 2006-04-12 21:26:32
|
Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25379/src/org/rubypeople/rdt/internal/ui/text/ruby Modified Files: AbstractRubyScanner.java Log Message: a number of changes: - Re-arrange the preferences - add ability to edit ruby editor font - whole new syntax coloring page - new underline/strikethrough options for syntax coloring - fix bug delaying preference changes from applying on syntax coloring to open editors. - Add hyperlink between syntax coloring and general text editor prefs (which apply to coloring/fonts/appearance) - Remove some deprecated code Index: AbstractRubyScanner.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/AbstractRubyScanner.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** AbstractRubyScanner.java 2 Mar 2005 00:56:52 -0000 1.5 --- AbstractRubyScanner.java 12 Apr 2006 21:26:25 -0000 1.6 *************** *** 27,30 **** --- 27,32 ---- private String[] fPropertyNamesBold; private String[] fPropertyNamesItalic; + private String[] fPropertyNamesStrikethrough; + private String[] fPropertyNamesUnderline; private IColorManager fColorManager; private IPreferenceStore fPreferenceStore; *************** *** 92,112 **** fPropertyNamesBold = new String[length]; fPropertyNamesItalic = new String[length]; fNeedsLazyColorLoading = Display.getCurrent() == null; - for (int i = 0; i < length; i++) { - fPropertyNamesBold[i] = fPropertyNamesColor[i] + PreferenceConstants.EDITOR_BOLD_SUFFIX; - fPropertyNamesItalic[i] = fPropertyNamesColor[i] + PreferenceConstants.EDITOR_ITALIC_SUFFIX; if (fNeedsLazyColorLoading) ! addTokenWithProxyAttribute(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]); else ! addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]); } initializeRules(); } ! private void addTokenWithProxyAttribute(String colorKey, String boldKey, String italicKey) { ! fTokenMap.put(colorKey, new Token(createTextAttribute(null, boldKey, italicKey))); } --- 94,136 ---- fPropertyNamesBold = new String[length]; fPropertyNamesItalic = new String[length]; + fPropertyNamesStrikethrough = new String[length]; + fPropertyNamesUnderline = new String[length]; + for (int i= 0; i < length; i++) { + fPropertyNamesBold[i]= getBoldKey(fPropertyNamesColor[i]); + fPropertyNamesItalic[i]= getItalicKey(fPropertyNamesColor[i]); + fPropertyNamesStrikethrough[i]= getStrikethroughKey(fPropertyNamesColor[i]); + fPropertyNamesUnderline[i]= getUnderlineKey(fPropertyNamesColor[i]); + } + fNeedsLazyColorLoading = Display.getCurrent() == null; for (int i = 0; i < length; i++) { if (fNeedsLazyColorLoading) ! addTokenWithProxyAttribute(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); else ! addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); } initializeRules(); } + + protected String getBoldKey(String colorKey) { + return colorKey + PreferenceConstants.EDITOR_BOLD_SUFFIX; + } ! protected String getItalicKey(String colorKey) { ! return colorKey + PreferenceConstants.EDITOR_ITALIC_SUFFIX; ! } ! ! protected String getStrikethroughKey(String colorKey) { ! return colorKey + PreferenceConstants.EDITOR_STRIKETHROUGH_SUFFIX; ! } ! ! protected String getUnderlineKey(String colorKey) { ! return colorKey + PreferenceConstants.EDITOR_UNDERLINE_SUFFIX; ! } ! ! private void addTokenWithProxyAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { ! fTokenMap.put(colorKey, new Token(createTextAttribute(null, boldKey, italicKey, strikethroughKey, underlineKey))); } *************** *** 114,118 **** if (fNeedsLazyColorLoading && Display.getCurrent() != null) { for (int i = 0; i < fPropertyNamesColor.length; i++) { ! addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i]); } fNeedsLazyColorLoading = false; --- 138,142 ---- if (fNeedsLazyColorLoading && Display.getCurrent() != null) { for (int i = 0; i < fPropertyNamesColor.length; i++) { ! addToken(fPropertyNamesColor[i], fPropertyNamesBold[i], fPropertyNamesItalic[i], fPropertyNamesStrikethrough[i], fPropertyNamesUnderline[i]); } fNeedsLazyColorLoading = false; *************** *** 120,124 **** } ! private void addToken(String colorKey, String boldKey, String italicKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey); --- 144,148 ---- } ! private void addToken(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { if (fColorManager != null && colorKey != null && fColorManager.getColor(colorKey) == null) { RGB rgb = PreferenceConverter.getColor(fPreferenceStore, colorKey); *************** *** 131,138 **** if (!fNeedsLazyColorLoading) ! fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey))); else { Token token = ((Token) fTokenMap.get(colorKey)); ! if (token != null) token.setData(createTextAttribute(colorKey, boldKey, italicKey)); } } --- 155,162 ---- if (!fNeedsLazyColorLoading) ! fTokenMap.put(colorKey, new Token(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey))); else { Token token = ((Token) fTokenMap.get(colorKey)); ! if (token != null) token.setData(createTextAttribute(colorKey, boldKey, italicKey, strikethroughKey, underlineKey)); } } *************** *** 153,165 **** * @param italicKey * the italic preference key * @return the created text attribute ! * @since 3.0 */ ! private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey) { ! Color color = null; ! if (colorKey != null) color = fColorManager.getColor(colorKey); ! int style = fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; ! if (fPreferenceStore.getBoolean(italicKey)) style |= SWT.ITALIC; return new TextAttribute(color, null, style); --- 177,201 ---- * @param italicKey * the italic preference key + * @param strikethroughKey + * the strikethrough preference key + * @param underlineKey + * the underline preference key * @return the created text attribute ! * @since 0.9.0 */ ! private TextAttribute createTextAttribute(String colorKey, String boldKey, String italicKey, String strikethroughKey, String underlineKey) { ! Color color= null; ! if (colorKey != null) ! color= fColorManager.getColor(colorKey); ! int style= fPreferenceStore.getBoolean(boldKey) ? SWT.BOLD : SWT.NORMAL; ! if (fPreferenceStore.getBoolean(italicKey)) ! style |= SWT.ITALIC; ! ! if (fPreferenceStore.getBoolean(strikethroughKey)) ! style |= TextAttribute.STRIKETHROUGH; ! ! if (fPreferenceStore.getBoolean(underlineKey)) ! style |= TextAttribute.UNDERLINE; return new TextAttribute(color, null, style); *************** *** 179,183 **** else if (fPropertyNamesBold[index].equals(p)) adaptToStyleChange(token, event, SWT.BOLD); ! else if (fPropertyNamesItalic[index].equals(p)) adaptToStyleChange(token, event, SWT.ITALIC); } --- 215,224 ---- else if (fPropertyNamesBold[index].equals(p)) adaptToStyleChange(token, event, SWT.BOLD); ! else if (fPropertyNamesItalic[index].equals(p)) ! adaptToStyleChange(token, event, SWT.ITALIC); ! else if (fPropertyNamesStrikethrough[index].equals(p)) ! adaptToStyleChange(token, event, TextAttribute.STRIKETHROUGH); ! else if (fPropertyNamesUnderline[index].equals(p)) ! adaptToStyleChange(token, event, TextAttribute.UNDERLINE); } *************** *** 231,235 **** int length = fPropertyNamesColor.length; for (int i = 0; i < length; i++) { ! if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i])) return i; } } --- 272,276 ---- int length = fPropertyNamesColor.length; for (int i = 0; i < length; i++) { ! if (property.equals(fPropertyNamesColor[i]) || property.equals(fPropertyNamesBold[i]) || property.equals(fPropertyNamesItalic[i]) || property.equals(fPropertyNamesStrikethrough[i]) || property.equals(fPropertyNamesUnderline[i])) return i; } } |