import org.eclipse.ui.dialogs.PropertyPage;
public class PHPProjectPropertyPage extends PropertyPage implements IWorkbenchPropertyPage {
- protected PHPProjectLibraryPage projectsPage;
- protected PHPProject workingProject;
-
- public PHPProjectPropertyPage() {
- }
-
- protected Control createContents(Composite parent) {
- noDefaultAndApplyButton();
-
- workingProject = getPHPProject();
- if (workingProject == null || !workingProject.getProject().isOpen())
- return createClosedProjectPageContents(parent);
-
- return createProjectPageContents(parent);
- }
-
- protected PHPProject getPHPProject() {
- IAdaptable selectedElement = getElement();
- if (selectedElement == null)
- return null;
-
- if (selectedElement instanceof PHPProject)
- return (PHPProject) selectedElement;
-
- if (selectedElement instanceof IProject) {
- IProject simpleProject = (IProject) selectedElement;
- try {
- if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
- PHPProject phpProject = new PHPProject();
- phpProject.setProject(simpleProject);
- return phpProject;
- }
- } catch(CoreException e) {
- PHPeclipsePlugin.log(e);
- }
- }
-
- return null;
- }
-
- protected Control createClosedProjectPageContents(Composite parent) {
- Label label = new Label(parent, SWT.NONE);
- label.setText(PHPPreferencesMessages.getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$
-
- return label;
- }
-
- protected Control createProjectPageContents(Composite parent) {
- TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
- tabFolder.setLayout(new GridLayout());
- tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
- tabFolder.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- //tabChanged(e.item);
- }
- });
-
- projectsPage = new PHPProjectLibraryPage(workingProject);
- TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
- tabItem.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$
-// tabItem.setData(projectsPage);
- tabItem.setControl(projectsPage.getControl(tabFolder));
-
- return tabFolder;
- }
- public boolean performOk() {
- try {
- projectsPage.getWorkingProject().save();
- } catch (CoreException e) {
+ protected PHPProjectLibraryPage projectsPage;
+ protected PHPProject workingProject;
+
+ public PHPProjectPropertyPage() {
+ }
+
+ protected Control createContents(Composite parent) {
+ noDefaultAndApplyButton();
+
+ workingProject = getPHPProject();
+ if (workingProject == null || !workingProject.getProject().isOpen())
+ return createClosedProjectPageContents(parent);
+
+ return createProjectPageContents(parent);
+ }
+
+ protected PHPProject getPHPProject() {
+ IAdaptable selectedElement = getElement();
+ if (selectedElement == null)
+ return null;
+
+ if (selectedElement instanceof PHPProject)
+ return (PHPProject) selectedElement;
+
+ if (selectedElement instanceof IProject) {
+ IProject simpleProject = (IProject) selectedElement;
+ try {
+ if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) {
+ PHPProject phpProject = new PHPProject();
+ phpProject.setProject(simpleProject);
+ return phpProject;
+ }
+ } catch (CoreException e) {
+ PHPeclipsePlugin.log(e);
+ }
+ }
+
+ return null;
+ }
+
+ protected Control createClosedProjectPageContents(Composite parent) {
+ Label label = new Label(parent, SWT.NONE);
+ label.setText(PHPPreferencesMessages.getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$
+
+ return label;
+ }
+
+ protected Control createProjectPageContents(Composite parent) {
+ TabFolder tabFolder = new TabFolder(parent, SWT.NONE);
+ tabFolder.setLayout(new GridLayout());
+ tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH));
+ tabFolder.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ //tabChanged(e.item);
+ }
+ });
+
+ projectsPage = new PHPProjectLibraryPage(workingProject);
+ TabItem tabItem = new TabItem(tabFolder, SWT.NONE);
+ tabItem.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$
+ // tabItem.setData(projectsPage);
+ tabItem.setControl(projectsPage.getControl(tabFolder));
+
+ return tabFolder;
+ }
+ public boolean performOk() {
+ try {
+ projectsPage.getWorkingProject().save();
+ } catch (CoreException e) {
PHPeclipsePlugin.log(e);
- }
- return super.performOk();
- }
+ }
+ return super.performOk();
+ }
}