KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ltk > internal > ui > refactoring > history > BrowseRefactoringHistoryLabelProvider


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 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.history;
12
13 import org.eclipse.core.runtime.Assert;
14
15 import org.eclipse.core.resources.ResourcesPlugin;
16
17 import org.eclipse.swt.graphics.Image;
18
19 import org.eclipse.jface.viewers.ILabelProvider;
20
21 import org.eclipse.ui.model.WorkbenchLabelProvider;
22
23 import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryControlConfiguration;
24 import org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryLabelProvider;
25
26 /**
27  * Label provider for the browse refactoring history control
28  *
29  * @since 3.2
30  */

31 public final class BrowseRefactoringHistoryLabelProvider extends RefactoringHistoryLabelProvider {
32
33     /** The delegate label provider */
34     private final ILabelProvider fDelegateLabelProvider;
35
36     /** The workbench label provider */
37     private final ILabelProvider fWorkbenchLabelProvider= new WorkbenchLabelProvider();
38
39     /**
40      * Creates a new browse refactoring history label provider.
41      *
42      * @param configuration
43      * the refactoring history control configuration
44      */

45     public BrowseRefactoringHistoryLabelProvider(final RefactoringHistoryControlConfiguration configuration) {
46         super(configuration);
47         Assert.isNotNull(configuration);
48         fDelegateLabelProvider= configuration.getLabelProvider();
49     }
50
51     /**
52      * {@inheritDoc}
53      */

54     public Image getImage(final Object JavaDoc element) {
55         if (element instanceof RefactoringHistoryProject) {
56             final RefactoringHistoryProject project= (RefactoringHistoryProject) element;
57             return fWorkbenchLabelProvider.getImage(ResourcesPlugin.getWorkspace().getRoot().getProject(project.getProject()));
58         }
59         return fDelegateLabelProvider.getImage(element);
60     }
61
62     /**
63      * {@inheritDoc}
64      */

65     public String JavaDoc getText(final Object JavaDoc element) {
66         if (element instanceof RefactoringHistoryProject) {
67             final RefactoringHistoryProject project= (RefactoringHistoryProject) element;
68             return fWorkbenchLabelProvider.getText(ResourcesPlugin.getWorkspace().getRoot().getProject(project.getProject()));
69         }
70         return fDelegateLabelProvider.getText(element);
71     }
72     
73     /* (non-Javadoc)
74      * @see org.eclipse.ltk.ui.refactoring.history.RefactoringHistoryLabelProvider#dispose()
75      */

76     public void dispose() {
77         if (fDelegateLabelProvider != null) {
78             fDelegateLabelProvider.dispose();
79         }
80         if (fWorkbenchLabelProvider != null) {
81             fWorkbenchLabelProvider.dispose();
82         }
83         super.dispose();
84     }
85 }
86
Popular Tags