1 20 package org.apache.directory.ldapstudio.aciitemeditor.sourceeditor; 21 22 23 import java.util.HashMap ; 24 import java.util.Map ; 25 26 import org.eclipse.jface.text.TextAttribute; 27 import org.eclipse.swt.SWT; 28 import org.eclipse.swt.graphics.Color; 29 import org.eclipse.swt.graphics.RGB; 30 import org.eclipse.swt.widgets.Display; 31 32 33 39 public class ACITextAttributeProvider 40 { 41 public static final String DEFAULT_ATTRIBUTE = "__pos_aci_default_attribute"; public static final String KEYWORD_ATTRIBUTE = "__pos_aci_keyword_attribute"; public static final String STRING_ATTRIBUTE = "__pos_aci_string_attribute"; public static final String GRANT_DENY_ATTRIBUTE = "__pos_aci_grant_deny_attribute"; public static final String IDENTIFICATION_ATTRIBUTE = "__pos_aci_identification_attribute"; public static final String PRECEDENCE_ATTRIBUTE = "__pos_aci_precedence_attribute"; public static final String AUTHENTICATIONLEVEL_ATTRIBUTE = "__pos_aci_authenticationlevel_attribute"; public static final String ITEMORUSERFIRST_ATTRIBUTE = "__pos_aci_itemoruserfirst_attribute"; public static final String USER_ATTRIBUTE = "__pos_aci_user_attribute"; 51 public static final String GRANT_VALUE = "__pos_aci_grant_value"; public static final String DENY_VALUE = "__pos_aci_deny_value"; 54 private Map <String , TextAttribute> attributes = new HashMap <String , TextAttribute>(); 55 56 57 60 public ACITextAttributeProvider() 61 { 62 attributes.put( DEFAULT_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 0 ) ) ) ); 63 64 attributes.put( KEYWORD_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 127, 0, 85 ) ), 65 null, SWT.BOLD ) ); 66 67 attributes.put( STRING_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 255 ) ) ) ); 68 69 attributes.put( GRANT_DENY_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 125, 125, 70 125 ) ) ) ); 71 72 attributes.put( GRANT_VALUE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 150, 0 ) ) ) ); 73 attributes.put( DENY_VALUE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 150, 0, 0 ) ) ) ); 74 75 attributes.put( IDENTIFICATION_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 125, 0, 76 0 ) ), null, SWT.BOLD ) ); 77 78 attributes.put( PRECEDENCE_ATTRIBUTE, new TextAttribute( 79 new Color( Display.getCurrent(), new RGB( 0, 0, 125 ) ), null, SWT.BOLD ) ); 80 81 attributes.put( AUTHENTICATIONLEVEL_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 82 125, 0 ) ), null, SWT.BOLD ) ); 83 84 attributes.put( ITEMORUSERFIRST_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 125, 0, 85 125 ) ), null, SWT.BOLD ) ); 86 87 attributes.put( USER_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 122, 255 ) ), 88 null, SWT.BOLD ) ); 89 90 } 91 92 93 101 public TextAttribute getAttribute( String type ) 102 { 103 TextAttribute attr = ( TextAttribute ) attributes.get( type ); 104 if ( attr == null ) 105 { 106 attr = ( TextAttribute ) attributes.get( DEFAULT_ATTRIBUTE ); 107 } 108 return attr; 109 } 110 } 111 | Popular Tags |