KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > bull > eclipse > jonas > JonasProjectPropertyPage


1 package com.bull.eclipse.jonas;
2
3 /*
4  * (c) Copyright Emmanuel Rias, Bull SA 2003.
5  * All Rights Reserved.
6  */

7  
8 import org.eclipse.core.resources.IProject;
9 import org.eclipse.core.runtime.CoreException;
10 import org.eclipse.jdt.core.IJavaProject;
11 import org.eclipse.jdt.core.JavaCore;
12 import org.eclipse.jdt.internal.ui.util.TabFolderLayout;
13 import org.eclipse.jface.preference.IPreferencePage;
14 import org.eclipse.jface.preference.PreferencePage;
15 import org.eclipse.swt.SWT;
16 import org.eclipse.swt.layout.GridData;
17 import org.eclipse.swt.widgets.Composite;
18 import org.eclipse.swt.widgets.Control;
19 import org.eclipse.swt.widgets.TabFolder;
20 import org.eclipse.swt.widgets.TabItem;
21 import org.eclipse.ui.IWorkbench;
22 import org.eclipse.ui.IWorkbenchPreferencePage;
23 import org.eclipse.ui.dialogs.PropertyPage;
24
25 /**
26  * provides a tab control with property pages for the
27  * settings of a jonas project.
28  *
29  * @version 1.0
30  * @author Emmanuel Rias
31  */

32
33 public class JonasProjectPropertyPage extends PropertyPage
34     implements IWorkbenchPreferencePage, JonasPluginResources
35 {
36     private static final boolean DO_NOT_USE_WEBAPP_CLASSLOADER = false;
37     
38     private TabFolder folder;
39     private JonasProjectGeneralPropertyPage generalPropertyPage;
40     private JonasProjectExtraResourcesPropertyPage extraResourcesPropertyPage;
41
42     /**
43      * @see PreferencePage#createContents(Composite)
44      */

45     protected Control createContents(Composite parent) {
46         if (DO_NOT_USE_WEBAPP_CLASSLOADER==false) {
47             folder = new TabFolder(parent, SWT.NONE);
48         
49             folder.setLayout(new TabFolderLayout());
50             folder.setLayoutData(new GridData(GridData.FILL_BOTH));
51         
52             // general property page
53
generalPropertyPage = new JonasProjectGeneralPropertyPage(this);
54             // add to tab
55
TabItem generalTab = new TabItem(folder, SWT.NONE);
56             generalTab.setText(JonasPluginResources.PROPERTIES_PAGE_PROJECT_GENERAL_TAB_LABEL);
57             generalTab.setControl(generalPropertyPage.createContents(folder));
58             
59             // extra resources property page
60
extraResourcesPropertyPage = new JonasProjectExtraResourcesPropertyPage(this);
61             // add to tab
62
TabItem extraClassTab = new TabItem(folder, SWT.NONE);
63             extraClassTab.setText(JonasPluginResources.PROPERTIES_PAGE_PROJECT_EXTRA_TAB_LABEL);
64             extraClassTab.setControl(extraResourcesPropertyPage.getControl(folder));
65             
66             return folder;
67         } else {
68             generalPropertyPage = new JonasProjectGeneralPropertyPage(this);
69             return generalPropertyPage.createContents(parent);
70         }
71     }
72     
73     /**
74      * @see IPreferencePage#performOk()
75      */

76     public boolean performOk() {
77         // delegate to property pages
78
if (generalPropertyPage.performOk() == true)
79             // check if it's a jonas resources any more
80
if (generalPropertyPage.isJonasProjectChecked())
81                 if (extraResourcesPropertyPage != null)
82                     extraResourcesPropertyPage.performOk();
83
84         return true;
85     }
86     
87     /**
88      * @see org.eclipse.ui.IWorkbenchPreferencePage#init(IWorkbench)
89      */

90     public void init(IWorkbench workbench) {
91     }
92
93     /* helper methods */
94     protected IJavaProject getJavaProject() throws CoreException {
95         IProject project = (IProject)(this.getElement().getAdapter(IProject.class));
96         return (IJavaProject)(project.getNature(JavaCore.NATURE_ID));
97     }
98     protected JonasProject getJonasProject() throws CoreException {
99         return JonasProject.create(getJavaProject());
100     }
101     
102 }
103
104
Popular Tags