KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > view > views > SchemaTextAttributeProvider


1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  *
19  */

20 package org.apache.directory.ldapstudio.schemas.view.views;
21
22
23 import java.util.HashMap JavaDoc;
24 import java.util.Map JavaDoc;
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 /**
34  * This class provides the TextAttributes elements for each kind of attribute.
35  *
36  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
37  * @version $Rev$, $Date$
38  */

39 public class SchemaTextAttributeProvider
40 {
41     public static final String JavaDoc DEFAULT_ATTRIBUTE = "__pos_schema_default_attribute"; //$NON-NLS-1$
42
public static final String JavaDoc STRING_ATTRIBUTE = "__pos_schema_string_attribute"; //$NON-NLS-1$
43
public static final String JavaDoc KEYWORD_ATTRIBUTE = "__pos_schema_keyword_attribute"; //$NON-NLS-1$
44
public static final String JavaDoc ATTRIBUTETYPE_ATTRIBUTE = "__pos_schema_attributetype_attribute"; //$NON-NLS-1$
45
public static final String JavaDoc OBJECTCLASS_ATTRIBUTE = "__pos_schema_objectclass_attribute"; //$NON-NLS-1$
46
public static final String JavaDoc OID_ATTRIBUTE = "__pos_schema_oid_attribute"; //$NON-NLS-1$
47

48     private Map JavaDoc<String JavaDoc, TextAttribute> attributes = new HashMap JavaDoc<String JavaDoc, TextAttribute>();
49
50
51     /**
52      * Creates a new instance of SchemaTextAttributeProvider.
53      *
54      */

55     public SchemaTextAttributeProvider()
56     {
57         attributes.put( DEFAULT_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 0 ) ) ) );
58
59         attributes.put( KEYWORD_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 127, 0, 85 ) ),
60             null, SWT.BOLD ) );
61
62         attributes.put( STRING_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 0, 0, 255 ) ) ) );
63
64         attributes.put( ATTRIBUTETYPE_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 89, 71,
65             158 ) ), null, SWT.BOLD ) );
66
67         attributes.put( OBJECTCLASS_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(),
68             new RGB( 45, 124, 68 ) ), null, SWT.BOLD ) );
69
70         attributes.put( OID_ATTRIBUTE, new TextAttribute( new Color( Display.getCurrent(), new RGB( 255, 0, 0 ) ) ) );
71     }
72
73
74     /**
75      * Gets the correct TextAttribute for the given type
76      *
77      * @param type
78      * the type of element
79      * @return
80      * the correct TextAttribute for the given type
81      */

82     public TextAttribute getAttribute( String JavaDoc type )
83     {
84         TextAttribute attr = ( TextAttribute ) attributes.get( type );
85         if ( attr == null )
86         {
87             attr = ( TextAttribute ) attributes.get( DEFAULT_ATTRIBUTE );
88         }
89         return attr;
90     }
91 }
92
Popular Tags