1 package net.sourceforge.phpeclipse.preferences;
3 import net.sourceforge.phpdt.internal.core.JavaProject;
4 import net.sourceforge.phpeclipse.PHPeclipsePlugin;
6 import org.eclipse.core.resources.IProject;
7 import org.eclipse.core.runtime.CoreException;
8 import org.eclipse.core.runtime.IAdaptable;
9 import org.eclipse.swt.SWT;
10 import org.eclipse.swt.events.SelectionAdapter;
11 import org.eclipse.swt.events.SelectionEvent;
12 import org.eclipse.swt.layout.GridData;
13 import org.eclipse.swt.layout.GridLayout;
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.swt.widgets.Control;
16 import org.eclipse.swt.widgets.Label;
17 import org.eclipse.swt.widgets.TabFolder;
18 import org.eclipse.swt.widgets.TabItem;
19 import org.eclipse.ui.IWorkbenchPropertyPage;
20 import org.eclipse.ui.dialogs.PropertyPage;
22 public class PHPProjectPropertyPage extends PropertyPage implements
23 IWorkbenchPropertyPage {
24 protected PHPProjectLibraryPage projectsPage;
26 protected JavaProject workingProject;
28 public PHPProjectPropertyPage() {
31 protected Control createContents(Composite parent) {
32 noDefaultAndApplyButton();
34 workingProject = getPHPProject();
35 if (workingProject == null || !workingProject.getProject().isOpen())
36 return createClosedProjectPageContents(parent);
38 return createProjectPageContents(parent);
41 protected JavaProject getPHPProject() {
42 IAdaptable selectedElement = getElement();
43 if (selectedElement == null)
46 if (selectedElement instanceof JavaProject)
47 return (JavaProject) selectedElement;
49 if (selectedElement instanceof IProject) {
50 IProject simpleProject = (IProject) selectedElement;
52 if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
53 JavaProject phpProject = new JavaProject();
54 phpProject.setProject(simpleProject);
57 } catch (CoreException e) {
58 PHPeclipsePlugin.log(e);
65 protected Control createClosedProjectPageContents(Composite parent) {
66 Label label = new Label(parent, SWT.NONE);
67 label.setText(PHPPreferencesMessages
68 .getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$
73 protected Control createProjectPageContents(Composite parent) {
74 TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
75 tabFolder.setLayout(new GridLayout());
76 tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
77 tabFolder.addSelectionListener(new SelectionAdapter() {
78 public void widgetSelected(SelectionEvent e) {
79 // tabChanged(e.item);
83 projectsPage = new PHPProjectLibraryPage(workingProject);
84 TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
85 tabItem.setText(PHPPreferencesMessages
86 .getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$
87 // tabItem.setData(projectsPage);
88 tabItem.setControl(projectsPage.getControl(tabFolder));
93 public boolean performOk() {
95 projectsPage.getWorkingProject().save();
96 } catch (CoreException e) {
97 PHPeclipsePlugin.log(e);
99 return super.performOk();