KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > part > OldViewToNewWrapper


1 /*******************************************************************************
2  * Copyright (c) 2004, 2005 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.ui.internal.part;
12
13 import org.eclipse.ui.IEditorInput;
14 import org.eclipse.ui.IViewPart;
15 import org.eclipse.ui.IViewSite;
16 import org.eclipse.ui.IWorkbenchPart;
17 import org.eclipse.ui.IWorkbenchPart2;
18 import org.eclipse.ui.PartInitException;
19 import org.eclipse.ui.internal.components.framework.ComponentException;
20 import org.eclipse.ui.internal.part.components.services.IPartActionBars;
21 import org.eclipse.ui.internal.part.components.services.IPartDescriptor;
22 import org.eclipse.ui.internal.part.services.PartToViewActionBarsAdapter;
23
24 /**
25  * @since 3.1
26  */

27 public class OldViewToNewWrapper extends OldPartToNewWrapper {
28     
29     private IViewSite site;
30     private IPartDescriptor descriptor;
31     
32     private IViewPart part;
33     private IEditorInput editorInput;
34     private PartToViewActionBarsAdapter actionBars;
35     
36     public OldViewToNewWrapper(IViewPart part, IPartActionBars partActionBars,
37             StandardWorkbenchServices services) throws ComponentException {
38         super(services);
39         this.part = part;
40
41         actionBars = new PartToViewActionBarsAdapter(partActionBars,
42                 services.getStatusHandler(), services.getStatusFactory());
43         
44         descriptor = services.getDescriptor();
45         
46         editorInput = services.getEditorInput();
47         site = new CompatibilityPartSite(
48                 services, part, null, actionBars);
49
50         try {
51             part.init(site, services.getState());
52         } catch (PartInitException e) {
53             throw new ComponentException(part.getClass(), e);
54         }
55
56         part.createPartControl(services.getParentComposite());
57         
58         setPart(part);
59     }
60
61     /* (non-Javadoc)
62      * @see org.eclipse.ui.internal.part.IPartPropertyProvider#getContentDescription()
63      */

64     public String JavaDoc getContentDescription() {
65         IWorkbenchPart part = getPart();
66         if (part instanceof IWorkbenchPart2) {
67             IWorkbenchPart2 wbp2 = (IWorkbenchPart2)part;
68             
69             return wbp2.getContentDescription();
70         }
71         
72         String JavaDoc title = getTitle();
73         if (title.equals(getPartName())) {
74             return ""; //$NON-NLS-1$
75
}
76         return getTitle();
77     }
78     
79     public String JavaDoc getTitle() {
80         return getPart().getTitle();
81     }
82     
83     /* (non-Javadoc)
84      * @see org.eclipse.ui.internal.part.IPartPropertyProvider#getEditorInput()
85      */

86     public IEditorInput getEditorInput() {
87         return editorInput;
88     }
89     
90     /* (non-Javadoc)
91      * @see org.eclipse.ui.internal.part.IPartPropertyProvider#getPartName()
92      */

93     public String JavaDoc getPartName() {
94         IWorkbenchPart part = getPart();
95         if (part instanceof IWorkbenchPart2) {
96             IWorkbenchPart2 wbp2 = (IWorkbenchPart2)part;
97             
98             return wbp2.getPartName();
99         }
100         
101         return descriptor.getLabel();
102     }
103     
104     /* (non-Javadoc)
105      * @see org.eclipse.ui.internal.part.IPartPropertyProvider#isDirty()
106      */

107     public boolean isDirty() {
108         return false;
109     }
110 }
111
Popular Tags