KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > editor > PDEDetailsSections


1 /*******************************************************************************
2  * Copyright (c) 2000, 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.pde.internal.ui.editor;
12
13 import org.eclipse.jface.viewers.ISelection;
14 import org.eclipse.pde.core.IModelChangedEvent;
15 import org.eclipse.swt.widgets.Composite;
16 import org.eclipse.ui.forms.IFormPart;
17
18 /**
19  * Wrapper for PDESections, implemens IDetailsPage for use in MasterDetailsBlock
20  */

21 public abstract class PDEDetailsSections extends PDEDetails {
22     private PDESection sections[];
23
24     protected abstract PDESection[] createSections(PDEFormPage page,
25             Composite parent);
26
27     /*
28      * (non-Javadoc)
29      *
30      * @see org.eclipse.ui.forms.IDetailsPage#createContents(org.eclipse.swt.widgets.Composite)
31      */

32     public void createContents(Composite parent) {
33         sections = createSections(getPage(), parent);
34         parent.setLayout(FormLayoutFactory.createDetailsGridLayout(false, 1));
35         for (int i = 0; i < sections.length; i++) {
36             getManagedForm().addPart(sections[i]);
37         }
38     }
39
40     public void dispose() {
41         for (int i = 0; i < sections.length; i++) {
42             sections[i].dispose();
43         }
44     }
45
46     public void fireSaveNeeded() {
47         markDirty();
48         getPage().getPDEEditor().fireSaveNeeded(getContextId(), false);
49     }
50
51     public abstract String JavaDoc getContextId();
52
53     public PDEFormPage getPage() {
54         return (PDEFormPage) getManagedForm().getContainer();
55     }
56
57     /*
58      * (non-Javadoc)
59      *
60      * @see org.eclipse.ui.forms.AbstractFormPart#isDirty()
61      */

62     public boolean isDirty() {
63         for (int i = 0; i < sections.length; i++) {
64             if (sections[i].isDirty()) {
65                 return true;
66             }
67         }
68         return super.isDirty();
69     }
70
71     public boolean isEditable() {
72         return getPage().getPDEEditor().getAggregateModel().isEditable();
73     }
74
75     /*
76      * (non-Javadoc)
77      *
78      * @see org.eclipse.ui.forms.AbstractFormPart#isStale()
79      */

80     public boolean isStale() {
81         for (int i = 0; i < sections.length; i++) {
82             if (sections[i].isStale()) {
83                 return true;
84             }
85         }
86         return super.isStale();
87     }
88
89     /*
90      * (non-Javadoc)
91      *
92      * @see org.eclipse.pde.core.IModelChangedListener#modelChanged(org.eclipse.pde.core.IModelChangedEvent)
93      */

94     public void modelChanged(IModelChangedEvent event) {
95     }
96
97     /*
98      * (non-Javadoc)
99      *
100      * @see org.eclipse.ui.forms.IDetailsPage#inputChanged(org.eclipse.jface.viewers.IStructuredSelection)
101      */

102     public void selectionChanged(IFormPart masterPart, ISelection selection) {
103     }
104
105     /*
106      * (non-Javadoc)
107      *
108      * @see org.eclipse.ui.forms.IDetailsPage#setFocus()
109      */

110     public void setFocus() {
111         if (sections.length > 0) {
112             sections[0].setFocus();
113         }
114     }
115 }
116
Popular Tags