KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > schemas > view > editors > attributeType > ATESubstringComboContentProvider


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.editors.attributeType;
21
22
23 import java.util.Collections JavaDoc;
24 import java.util.List JavaDoc;
25
26 import org.apache.directory.ldapstudio.schemas.model.MatchingRule;
27 import org.apache.directory.ldapstudio.schemas.model.MatchingRules;
28 import org.eclipse.jface.viewers.IStructuredContentProvider;
29 import org.eclipse.jface.viewers.Viewer;
30
31
32 /**
33  * This class implements the Content Provider for the Substring Combo of the Attribute Type Editor.
34  *
35  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
36  * @version $Rev$, $Date$
37  */

38 public class ATESubstringComboContentProvider implements IStructuredContentProvider
39 {
40     /* (non-Javadoc)
41      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
42      */

43     public Object JavaDoc[] getElements( Object JavaDoc inputElement )
44     {
45         if ( inputElement instanceof ATEMatchingRulesComboInput )
46         {
47             ATEMatchingRulesComboInput input = ( ATEMatchingRulesComboInput ) inputElement;
48
49             if ( input.getChildren().isEmpty() )
50             {
51                 // Creating the '(None)' item
52
input.addChild( new NonExistingMatchingRule( NonExistingMatchingRule.NONE ) );
53
54                 // Creating Children
55
List JavaDoc<MatchingRule> substringMatchingRules = MatchingRules.getSubstringMatchingRules();
56                 for ( MatchingRule substringMatchingRule : substringMatchingRules )
57                 {
58                     input.addChild( substringMatchingRule );
59                 }
60             }
61
62             // Getting Children
63
List JavaDoc<Object JavaDoc> children = input.getChildren();
64
65             // Sorting Children
66
Collections.sort( children, new ATEMatchingRulesComboComparator() );
67
68             return children.toArray();
69         }
70
71         // Default
72
return new Object JavaDoc[0];
73     }
74
75
76     /* (non-Javadoc)
77      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
78      */

79     public void dispose()
80     {
81     }
82
83
84     /* (non-Javadoc)
85      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
86      */

87     public void inputChanged( Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput )
88     {
89     }
90 }
91
Popular Tags