KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2005, 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
17 import org.eclipse.ltk.core.refactoring.RefactoringDescriptorProxy;
18
19 import org.eclipse.ltk.internal.ui.refactoring.RefactoringUIMessages;
20
21 import org.eclipse.swt.widgets.Composite;
22
23 import org.eclipse.compare.CompareConfiguration;
24 import org.eclipse.compare.CompareUI;
25
26 /**
27  * Compare viewer which displays a summary of a pending refactoring.
28  *
29  * @since 3.2
30  */

31 public final class RefactoringDescriptorCompareViewer extends RefactoringDescriptorViewer {
32
33     /** The compare configuration */
34     private final CompareConfiguration fConfiguration;
35
36     /**
37      * Creates a new refactoring descriptor compare viewer.
38      *
39      * @param parent
40      * the parent control
41      * @param configuration
42      * the compare configuration
43      * @param style
44      * the viewer style
45      */

46     public RefactoringDescriptorCompareViewer(final Composite parent, final CompareConfiguration configuration, final int style) {
47         super(parent, style);
48         Assert.isNotNull(configuration);
49         fConfiguration= configuration;
50         fBrowser.setData(CompareUI.COMPARE_VIEWER_TITLE, RefactoringUIMessages.RefactoringWizard_refactoring);
51     }
52
53     /**
54      * Returns the compare configuration.
55      *
56      * @return the compare configuration
57      */

58     public CompareConfiguration getCompareConfiguration() {
59         return fConfiguration;
60     }
61
62     /**
63      * {@inheritDoc}
64      */

65     public void setInput(final Object JavaDoc element) {
66         if (element instanceof RefactoringDescriptorCompareInput) {
67             final RefactoringDescriptorCompareInput input= (RefactoringDescriptorCompareInput) element;
68             final RefactoringDescriptorProxy descriptor= input.getDescriptor();
69             if (descriptor instanceof RefactoringDescriptorSynchronizationProxy) {
70                 final RefactoringDescriptorSynchronizationProxy proxy= (RefactoringDescriptorSynchronizationProxy) descriptor;
71                 if (proxy.getDirection() == IThreeWayDiff.INCOMING)
72                     fBrowser.setData(CompareUI.COMPARE_VIEWER_TITLE, ModelMessages.RefactoringDescriptorCompareInput_pending_refactoring);
73                 else
74                     fBrowser.setData(CompareUI.COMPARE_VIEWER_TITLE, ModelMessages.RefactoringDescriptorCompareInput_performed_refactoring);
75             }
76             super.setInput(descriptor);
77         }
78         super.setInput(element);
79     }
80 }
81
Popular Tags