KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > team > internal > ccvs > ui > model > CVSRepositoryLocationPropertySource


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.team.internal.ccvs.ui.model;
12
13
14 import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
15 import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
16 import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
17 import org.eclipse.ui.views.properties.IPropertyDescriptor;
18 import org.eclipse.ui.views.properties.IPropertySource;
19 import org.eclipse.ui.views.properties.PropertyDescriptor;
20
21 public class CVSRepositoryLocationPropertySource implements IPropertySource {
22     ICVSRepositoryLocation location;
23     
24     // Property Descriptors
25
static protected IPropertyDescriptor[] propertyDescriptors = new IPropertyDescriptor[5];
26     {
27         PropertyDescriptor descriptor;
28         String JavaDoc category = CVSUIMessages.cvs;
29         
30         // host
31
descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_HOST, CVSUIMessages.CVSRepositoryLocationPropertySource_host);
32         descriptor.setAlwaysIncompatible(true);
33         descriptor.setCategory(category);
34         propertyDescriptors[0] = descriptor;
35         // user
36
descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_USER, CVSUIMessages.CVSRepositoryLocationPropertySource_user);
37         descriptor.setAlwaysIncompatible(true);
38         descriptor.setCategory(category);
39         propertyDescriptors[1] = descriptor;
40         // port
41
descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_PORT, CVSUIMessages.CVSRepositoryLocationPropertySource_port);
42         descriptor.setAlwaysIncompatible(true);
43         descriptor.setCategory(category);
44         propertyDescriptors[2] = descriptor;
45         // root
46
descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_ROOT, CVSUIMessages.CVSRepositoryLocationPropertySource_root);
47         descriptor.setAlwaysIncompatible(true);
48         descriptor.setCategory(category);
49         propertyDescriptors[3] = descriptor;
50         // method
51
descriptor = new PropertyDescriptor(ICVSUIConstants.PROP_METHOD, CVSUIMessages.CVSRepositoryLocationPropertySource_method);
52         descriptor.setAlwaysIncompatible(true);
53         descriptor.setCategory(category);
54         propertyDescriptors[4] = descriptor;
55     }
56
57     /**
58      * Create a PropertySource and store its file
59      */

60     public CVSRepositoryLocationPropertySource(ICVSRepositoryLocation location) {
61         this.location = location;
62     }
63     
64     /**
65      * Do nothing because properties are read only.
66      */

67     public Object JavaDoc getEditableValue() {
68         return this;
69     }
70
71     /**
72      * Return the Property Descriptors for the receiver.
73      */

74     public IPropertyDescriptor[] getPropertyDescriptors() {
75         return propertyDescriptors;
76     }
77
78     /*
79      * @see IPropertySource#getPropertyValue(Object)
80      */

81     public Object JavaDoc getPropertyValue(Object JavaDoc id) {
82         if (id.equals(ICVSUIConstants.PROP_HOST)) {
83             return location.getHost();
84         }
85         if (id.equals(ICVSUIConstants.PROP_USER)) {
86             return location.getUsername();
87         }
88         if (id.equals(ICVSUIConstants.PROP_METHOD)) {
89             return location.getMethod().getName();
90         }
91         if (id.equals(ICVSUIConstants.PROP_ROOT)) {
92             return location.getRootDirectory();
93         }
94         if (id.equals(ICVSUIConstants.PROP_PORT)) {
95             int port = location.getPort();
96             if (port == ICVSRepositoryLocation.USE_DEFAULT_PORT) {
97                 return CVSUIMessages.CVSRepositoryLocationPropertySource_default;
98             }
99             return "" + port; //$NON-NLS-1$
100
}
101         return ""; //$NON-NLS-1$
102
}
103
104     /**
105      * Answer true if the value of the specified property
106      * for this object has been changed from the default.
107      */

108     public boolean isPropertySet(Object JavaDoc property) {
109         return false;
110     }
111     /**
112      * Reset the specified property's value to its default value.
113      * Do nothing because properties are read only.
114      *
115      * @param property The property to reset.
116      */

117     public void resetPropertyValue(Object JavaDoc property) {
118     }
119     /**
120      * Do nothing because properties are read only.
121      */

122     public void setPropertyValue(Object JavaDoc name, Object JavaDoc value) {
123     }
124 }
125
Popular Tags