KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*******************************************************************************
2  * Copyright (c) 2003, 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.core.resources.IProject;
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.pde.core.IModelChangedEvent;
16 import org.eclipse.pde.core.IModelChangedListener;
17 import org.eclipse.swt.dnd.Clipboard;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.forms.SectionPart;
20 import org.eclipse.ui.forms.widgets.ExpandableComposite;
21 import org.eclipse.ui.forms.widgets.FormToolkit;
22 import org.eclipse.ui.forms.widgets.Section;
23
24 public abstract class PDESection extends SectionPart implements IModelChangedListener,
25         IContextPart, IAdaptable {
26
27     private PDEFormPage fPage;
28
29     public PDESection(PDEFormPage page, Composite parent, int style) {
30         this(page, parent, style, true);
31     }
32
33     public PDESection(PDEFormPage page, Composite parent, int style, boolean titleBar) {
34         super(parent, page.getManagedForm().getToolkit(),
35                 titleBar ? (ExpandableComposite.TITLE_BAR | style) : style);
36         fPage = page;
37         initialize(page.getManagedForm());
38         getSection().clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
39         getSection().setData("part", this); //$NON-NLS-1$
40
}
41
42     protected abstract void createClient(Section section, FormToolkit toolkit);
43
44     public PDEFormPage getPage() {
45         return fPage;
46     }
47
48     protected IProject getProject() {
49         return fPage.getPDEEditor().getCommonProject();
50     }
51
52     public boolean doGlobalAction(String JavaDoc actionId) {
53         return false;
54     }
55
56     public void modelChanged(IModelChangedEvent e) {
57         if (e.getChangeType() == IModelChangedEvent.WORLD_CHANGED)
58             markStale();
59     }
60
61     public String JavaDoc getContextId() {
62         return null;
63     }
64
65     public void fireSaveNeeded() {
66         markDirty();
67         if (getContextId() != null)
68             getPage().getPDEEditor().fireSaveNeeded(getContextId(), false);
69     }
70
71     public boolean isEditable() {
72         return getPage().getPDEEditor().getAggregateModel().isEditable();
73     }
74
75     public boolean canPaste(Clipboard clipboard) {
76         return false;
77     }
78
79     public void cancelEdit() {
80         super.refresh();
81     }
82
83     public Object JavaDoc getAdapter(Class JavaDoc adapter) {
84         return null;
85     }
86 }
87
Popular Tags