[jboss-cvs] jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor ...

Max Rydahl Andersen mandersen at jboss.com
Fri Aug 25 06:12:45 EDT 2006


  User: mandersen
  Date: 06/08/25 06:12:45

  Modified:    hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor   
                        HQLSourceViewerConfiguration.java HQLColors.java
                        HQLCodeScanner.java
  Log:
  JBIDE-320 & HBX-735 customize HQL editor coloring
  
  Revision  Changes    Path
  1.4       +3 -2      jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLSourceViewerConfiguration.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HQLSourceViewerConfiguration.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLSourceViewerConfiguration.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- HQLSourceViewerConfiguration.java	7 Jul 2006 13:51:08 -0000	1.3
  +++ HQLSourceViewerConfiguration.java	25 Aug 2006 10:12:45 -0000	1.4
  @@ -36,6 +36,7 @@
   import org.eclipse.jface.text.rules.Token;
   import org.eclipse.jface.text.source.ISourceViewer;
   import org.eclipse.jface.text.source.SourceViewerConfiguration;
  +import org.hibernate.eclipse.hqleditor.preferences.HQLPreferenceConstants;
   
   public class HQLSourceViewerConfiguration extends SourceViewerConfiguration {
   
  @@ -100,11 +101,11 @@
           reconciler.setDamager( dr, IDocument.DEFAULT_CONTENT_TYPE );
           reconciler.setRepairer( dr, IDocument.DEFAULT_CONTENT_TYPE );
           
  -        dr = new DefaultDamagerRepairer( new SingleTokenScanner( new TextAttribute( colorProvider.getColor( HQLColors.HQL_COMMENT_COLOR ))));
  +        dr = new DefaultDamagerRepairer( new SingleTokenScanner( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_COMMENT_COLOR ))));
           reconciler.setDamager( dr, HQLPartitionScanner.HQL_COMMENT );
           reconciler.setRepairer( dr, HQLPartitionScanner.HQL_COMMENT );
   
  -        dr = new DefaultDamagerRepairer( new SingleTokenScanner( new TextAttribute( colorProvider.getColor( HQLColors.HQL_QUOTED_LITERAL_COLOR ))));
  +        dr = new DefaultDamagerRepairer( new SingleTokenScanner( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_QUOTED_LITERAL_COLOR ))));
           reconciler.setDamager( dr, HQLPartitionScanner.HQL_QUOTED_LITERAL );
           reconciler.setRepairer( dr, HQLPartitionScanner.HQL_QUOTED_LITERAL );
   
  
  
  
  1.4       +28 -23    jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLColors.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HQLColors.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLColors.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -b -r1.3 -r1.4
  --- HQLColors.java	7 Jul 2006 13:51:08 -0000	1.3
  +++ HQLColors.java	25 Aug 2006 10:12:45 -0000	1.4
  @@ -25,34 +25,39 @@
   import java.util.Iterator;
   import java.util.Map;
   
  +import org.eclipse.jface.preference.PreferenceConverter;
   import org.eclipse.swt.graphics.Color;
   import org.eclipse.swt.graphics.RGB;
   import org.eclipse.swt.widgets.Display;
  +import org.hibernate.eclipse.console.HibernateConsolePlugin;
   
   public class HQLColors {
   
  -    public static final RGB HQL_COMMENT_COLOR              = new RGB( 0, 0, 128 );  
  -    public static final RGB HQL_MULTILINE_COMMENT_COLOR    = new RGB( 128, 0, 0 );  
  -    public static final RGB HQL_QUOTED_LITERAL_COLOR       = new RGB( 0, 0, 255 );  
  -    public static final RGB HQL_KEYWORD_COLOR              = new RGB( 128, 0, 0 );  
  -    public static final RGB HQL_IDENTIFIER_COLOR           = new RGB( 0, 128, 128 );   
  -    public static final RGB HQL_DEFAULT_COLOR              = new RGB( 0, 0, 0 );    
  -        
  -    protected Map colorTable = new HashMap(10);
  +	protected Map fColorTable = new HashMap(10);
   
       public void dispose() {
  -        Iterator e = colorTable.values().iterator();
  +		Iterator e = fColorTable.values().iterator();
           while (e.hasNext())
               ((Color) e.next()).dispose();
  +		fColorTable.clear();
  +	}
  +
  +	public Color getColor (String colorName) {
  +		RGB rgb = PreferenceConverter.getColor(
  +				HibernateConsolePlugin.getDefault().getPreferenceStore(),
  +				colorName);
  +		return getColor(rgb);
       }
       
  -    public Color getColor( RGB rgb ) {
  -        Color color = (Color) colorTable.get( rgb );
  +	protected Color getColor(RGB rgb) {
  +		if(rgb==null) rgb = new RGB(0,0,0);
  +		Color color = (Color) fColorTable.get(rgb);
           if (color == null) {
  -            color = new Color( Display.getCurrent(), rgb );
  -            colorTable.put( rgb, color );
  +			color = new Color(Display.getCurrent(), rgb);
  +			fColorTable.put(rgb, color);
           }
           return color;
       }
       
  +   
   }
  \ No newline at end of file
  
  
  
  1.7       +11 -6     jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCodeScanner.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: HQLCodeScanner.java
  ===================================================================
  RCS file: /cvsroot/jboss/jbosside/hibernatetools/plugins/org.hibernate.eclipse.console/src/org/hibernate/eclipse/hqleditor/HQLCodeScanner.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -b -r1.6 -r1.7
  --- HQLCodeScanner.java	7 Jul 2006 13:51:08 -0000	1.6
  +++ HQLCodeScanner.java	25 Aug 2006 10:12:45 -0000	1.7
  @@ -36,6 +36,7 @@
   import org.eclipse.jface.text.rules.WhitespaceRule;
   import org.eclipse.jface.text.rules.WordRule;
   import org.eclipse.swt.SWT;
  +import org.hibernate.eclipse.hqleditor.preferences.HQLPreferenceConstants;
   
   public class HQLCodeScanner extends RuleBasedScanner {
   
  @@ -221,12 +222,16 @@
       } 
       
       public HQLCodeScanner( HQLColors colorProvider ) {
  -        final IToken commentToken    = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_COMMENT_COLOR )));
  -        final IToken stringToken     = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_QUOTED_LITERAL_COLOR )));
  -        final IToken keywordToken    = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_KEYWORD_COLOR ), null, SWT.BOLD));
  -        final IToken functionToken   = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_KEYWORD_COLOR )));
  -        final IToken otherToken      = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_DEFAULT_COLOR )));
  -        final IToken hqlToken        = new Token( new TextAttribute( colorProvider.getColor( HQLColors.HQL_IDENTIFIER_COLOR )));
  +        final IToken commentToken    = new Token( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_COMMENT_COLOR )));
  +        final IToken stringToken     = new Token( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_QUOTED_LITERAL_COLOR )));
  +        final IToken keywordToken    = new Token( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_KEYWORD_COLOR ), null, SWT.BOLD)) {
  +        	public Object getData() {
  +        		// TODO Auto-generated method stub
  +        		return super.getData();
  +        	}
  +        };
  +        final IToken functionToken   = new Token( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_KEYWORD_COLOR )));
  +        final IToken otherToken      = new Token( new TextAttribute( colorProvider.getColor( HQLPreferenceConstants.HQL_DEFAULT_COLOR )));        
           
           setDefaultReturnToken( otherToken );
   
  
  
  



More information about the jboss-cvs-commits mailing list