KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > directory > ldapstudio > apacheds > configuration > editor > ServerConfigurationEditorInput


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.apacheds.configuration.editor;
21
22
23 import org.apache.directory.ldapstudio.apacheds.configuration.model.ServerConfiguration;
24 import org.eclipse.jface.resource.ImageDescriptor;
25 import org.eclipse.ui.IEditorInput;
26 import org.eclipse.ui.IPersistableElement;
27
28
29 /**
30  * This class represents the Server Configuration Editor Input.
31  *
32  * @author <a HREF="mailto:dev@directory.apache.org">Apache Directory Project</a>
33  * @version $Rev$, $Date$
34  */

35 public class ServerConfigurationEditorInput implements IEditorInput
36 {
37     /** The Server Configuration */
38     private ServerConfiguration serverConfiguration;
39
40
41     /**
42      * Creates a new instance of ServerConfigurationEditorInput.
43      *
44      * @param serverConfiguration
45      * the Server Configuration
46      */

47     public ServerConfigurationEditorInput( ServerConfiguration serverConfiguration )
48     {
49         this.serverConfiguration = serverConfiguration;
50     }
51
52
53     /**
54      * Gets the Server Configuration
55      *
56      * @return
57      * the Server Configuration
58      */

59     public ServerConfiguration getServerConfiguration()
60     {
61         return serverConfiguration;
62     }
63
64
65     /* (non-Javadoc)
66      * @see org.eclipse.ui.IEditorInput#getToolTipText()
67      */

68     public String JavaDoc getToolTipText()
69     {
70         String JavaDoc path = serverConfiguration.getPath();
71         if ( path == null )
72         {
73             return "New Configuration File";
74         }
75         else
76         {
77             return path;
78         }
79
80     }
81
82
83     /* (non-Javadoc)
84      * @see org.eclipse.ui.IEditorInput#getName()
85      */

86     public String JavaDoc getName()
87     {
88         return "Apache DS Configuration";
89     }
90
91
92     /* (non-Javadoc)
93      * @see org.eclipse.ui.IEditorInput#exists()
94      */

95     public boolean exists()
96     {
97         return ( serverConfiguration != null );
98     }
99
100
101     /* (non-Javadoc)
102      * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
103      */

104     public ImageDescriptor getImageDescriptor()
105     {
106         return null;
107     }
108
109
110     /* (non-Javadoc)
111      * @see org.eclipse.ui.IEditorInput#getPersistable()
112      */

113     public IPersistableElement getPersistable()
114     {
115         return null;
116     }
117
118
119     /* (non-Javadoc)
120      * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
121      */

122     public Object JavaDoc getAdapter( Class JavaDoc adapter )
123     {
124         return null;
125     }
126
127
128     /* (non-Javadoc)
129      * @see java.lang.Object#equals(java.lang.Object)
130      */

131     public boolean equals( Object JavaDoc obj )
132     {
133         if ( obj instanceof ServerConfigurationEditorInput )
134         {
135             ServerConfigurationEditorInput input = ( ServerConfigurationEditorInput ) obj;
136
137             if ( input.exists() && exists() )
138             {
139                 String JavaDoc inputPath = input.getServerConfiguration().getPath();
140                 String JavaDoc myPath = getServerConfiguration().getPath();
141
142                 if ( inputPath != null && myPath != null )
143                 {
144                     return inputPath.equals( myPath );
145                 }
146             }
147         }
148         return false;
149     }
150 }
151
Popular Tags