KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > cheatsheet > comp > CompCSBlock


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
12 package org.eclipse.pde.internal.ui.editor.cheatsheet.comp;
13
14 import org.eclipse.jface.viewers.ISelection;
15 import org.eclipse.pde.core.IModelChangedEvent;
16 import org.eclipse.pde.core.IModelChangedListener;
17 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCS;
18 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTask;
19 import org.eclipse.pde.internal.core.icheatsheet.comp.ICompCSTaskGroup;
20 import org.eclipse.pde.internal.ui.editor.PDEFormPage;
21 import org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock;
22 import org.eclipse.pde.internal.ui.editor.PDESection;
23 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSDetails;
24 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSTaskDetails;
25 import org.eclipse.pde.internal.ui.editor.cheatsheet.comp.details.CompCSTaskGroupDetails;
26 import org.eclipse.swt.widgets.Composite;
27 import org.eclipse.ui.forms.DetailsPart;
28 import org.eclipse.ui.forms.IDetailsPage;
29 import org.eclipse.ui.forms.IDetailsPageProvider;
30 import org.eclipse.ui.forms.IManagedForm;
31
32 /**
33  * CompCSBlock
34  *
35  */

36 public class CompCSBlock extends PDEMasterDetailsBlock implements
37         IModelChangedListener, IDetailsPageProvider {
38
39     private CompCSMasterTreeSection fMasterSection;
40
41     private CompCSDetails fDetails;
42     
43     private CompCSTaskGroupDetails fTaskGroupDetails;
44     
45     private CompCSTaskDetails fTaskDetails;
46     
47     /**
48      * @param page
49      */

50     public CompCSBlock(PDEFormPage page) {
51         super(page);
52     }
53
54     /* (non-Javadoc)
55      * @see org.eclipse.pde.internal.ui.editor.PDEMasterDetailsBlock#createMasterSection(org.eclipse.ui.forms.IManagedForm, org.eclipse.swt.widgets.Composite)
56      */

57     protected PDESection createMasterSection(IManagedForm managedForm,
58             Composite parent) {
59         fMasterSection = new CompCSMasterTreeSection(getPage(), parent);
60         return fMasterSection;
61     }
62
63     /* (non-Javadoc)
64      * @see org.eclipse.ui.forms.MasterDetailsBlock#registerPages(org.eclipse.ui.forms.DetailsPart)
65      */

66     protected void registerPages(DetailsPart detailsPart) {
67         // Only static pages to be defined. Do not cache pages
68
detailsPart.setPageLimit(0);
69         // Register static page: compositeCheatsheet
70
fDetails = new CompCSDetails(fMasterSection);
71         detailsPart.registerPage(CompCSDetails.class, fDetails);
72         // Register static page: taskGroup
73
fTaskGroupDetails = new CompCSTaskGroupDetails(fMasterSection);
74         detailsPart.registerPage(CompCSTaskGroupDetails.class, fTaskGroupDetails);
75         // Register static page: task
76
fTaskDetails = new CompCSTaskDetails(fMasterSection);
77         detailsPart.registerPage(CompCSTaskDetails.class, fTaskDetails);
78         // Set this class as the page provider
79
detailsPart.setPageProvider(this);
80     }
81
82     /* (non-Javadoc)
83      * @see org.eclipse.ui.forms.IDetailsPageProvider#getPageKey(java.lang.Object)
84      */

85     public Object JavaDoc getPageKey(Object JavaDoc object) {
86         // Get static page key
87
if (object instanceof ICompCS) {
88             // Static page: compositeCheatsheet
89
return CompCSDetails.class;
90         } else if (object instanceof ICompCSTaskGroup) {
91             // Static page: taskGroup
92
return CompCSTaskGroupDetails.class;
93         } else if (object instanceof ICompCSTask) {
94             // Static page: task
95
return CompCSTaskDetails.class;
96         }
97         // Should never reach here
98
return object.getClass();
99     }
100     
101     /* (non-Javadoc)
102      * @see org.eclipse.ui.forms.IDetailsPageProvider#getPage(java.lang.Object)
103      */

104     public IDetailsPage getPage(Object JavaDoc key) {
105         // No dynamic pages. Static pages already registered
106
return null;
107     }
108     
109     /* (non-Javadoc)
110      * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
111      */

112     public void modelChanged(IModelChangedEvent event) {
113         // Inform the master section
114
if (fMasterSection != null) {
115             fMasterSection.modelChanged(event);
116         }
117         // Inform the details section
118
// Unnecessary
119
//if (fCurrentDetailsSection != null) {
120
// fCurrentDetailsSection.modelChanged(event);
121
//}
122
}
123
124     /**
125      * @return
126      */

127     public CompCSMasterTreeSection getMastersSection() {
128         return fMasterSection;
129     }
130     
131     /**
132      * @return
133      */

134     public ISelection getSelection() {
135         if (fMasterSection != null) {
136             return fMasterSection.getSelection();
137         }
138         return null;
139     }
140     
141 }
142
Popular Tags