KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > model > RefactoringDescriptorSynchronizationProxy


1 /*******************************************************************************
2  * Copyright (c) 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.ltk.internal.ui.refactoring.model;
12
13 import org.eclipse.team.core.diff.IThreeWayDiff;
14
15 import org.eclipse.core.runtime.Assert;
16 import org.eclipse.core.runtime.IProgressMonitor;
17
18 import org.eclipse.ltk.core.refactoring.RefactoringDescriptor;
19 import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
20
21 /**
22  * Wrapper which wraps a refactoring descriptor proxy and adds synchronization
23  * information to it.
24  *
25  * @since 3.2
26  */

27 public final class RefactoringDescriptorSynchronizationProxy extends RefactoringDescriptorProxy {
28
29     /** The direction of the difference */
30     private final int fDirection;
31
32     /** The non-empty name of the associated project */
33     private final String JavaDoc fProject;
34
35     /** The encapsulated descriptor proxy */
36     private final RefactoringDescriptorProxy fProxy;
37
38     /**
39      * Creates a new refactoring descriptor synchronization proxy.
40      * <p>
41      * The value of the direction argument is used to compose an icon which
42      * reflects the direction of the difference between the two or three
43      * versions of the refactoring descriptor.
44      * </p>
45      *
46      * @param proxy
47      * the descriptor proxy to encapsulate
48      * @param project
49      * the non-empty name of the project the refactoring is
50      * associated with
51      * @param direction
52      * the direction of the difference
53      *
54      * @see IThreeWayDiff#getDirection()
55      */

56     public RefactoringDescriptorSynchronizationProxy(final RefactoringDescriptorProxy proxy, final String JavaDoc project, final int direction) {
57         Assert.isNotNull(proxy);
58         Assert.isNotNull(project);
59         Assert.isTrue(!"".equals(project)); //$NON-NLS-1$
60
fProxy= proxy;
61         fProject= project;
62         fDirection= direction;
63     }
64
65     /**
66      * {@inheritDoc}
67      */

68     public int compareTo(final Object JavaDoc object) {
69         return fProxy.compareTo(object);
70     }
71
72     /**
73      * {@inheritDoc}
74      */

75     public String JavaDoc getDescription() {
76         return fProxy.getDescription();
77     }
78
79     /**
80      * Returns the direction of the difference of this refactoring descriptor.
81      * <p>
82      * The result of this method is used to compose an icon which reflects the
83      * direction of the difference between the two or three versions of the
84      * refactoring descriptor.
85      * </p>
86      *
87      * @return the direction of the difference
88      *
89      * @see IThreeWayDiff#getDirection()
90      */

91     public int getDirection() {
92         return fDirection;
93     }
94
95     /**
96      * {@inheritDoc}
97      */

98     public String JavaDoc getProject() {
99         return fProject;
100     }
101
102     /**
103      * {@inheritDoc}
104      */

105     public long getTimeStamp() {
106         return fProxy.getTimeStamp();
107     }
108
109     /**
110      * {@inheritDoc}
111      */

112     public RefactoringDescriptor requestDescriptor(final IProgressMonitor monitor) {
113         return fProxy.requestDescriptor(monitor);
114     }
115
116     /**
117      * {@inheritDoc}
118      */

119     public String JavaDoc toString() {
120         return fProxy.toString();
121     }
122 }
Popular Tags