applying code changes to fix ticket issue #637. You can now work with files and get...
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpeclipse / wizards / PHPFileWizardPage.java
index bbcc353..f4ac33a 100644 (file)
@@ -51,7 +51,7 @@ public class PHPFileWizardPage extends WizardPage {
 
        /**
         * Constructor for SampleNewWizardPage.
-        *
+        * 
         * @param pageName
         */
        public PHPFileWizardPage(ISelection selection) {
@@ -83,7 +83,8 @@ public class PHPFileWizardPage extends WizardPage {
                });
 
                Button button = new Button(container, SWT.PUSH);
-               button.setText(PHPWizardMessages.getString("WizardPage.browseButtonText"));
+               button.setText(PHPWizardMessages
+                               .getString("WizardPage.browseButtonText"));
                button.addSelectionListener(new SelectionAdapter() {
                        public void widgetSelected(SelectionEvent e) {
                                handleBrowse();
@@ -110,7 +111,8 @@ public class PHPFileWizardPage extends WizardPage {
         */
 
        private void initialize() {
-               if (selection != null && selection.isEmpty() == false && selection instanceof IStructuredSelection) {
+               if (selection != null && selection.isEmpty() == false
+                               && selection instanceof IStructuredSelection) {
                        IStructuredSelection ssel = (IStructuredSelection) selection;
                        if (ssel.size() > 1)
                                return;
@@ -134,8 +136,10 @@ public class PHPFileWizardPage extends WizardPage {
         */
 
        private void handleBrowse() {
-               ContainerSelectionDialog dialog = new ContainerSelectionDialog(getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
-                               PHPWizardMessages.getString("WizardPage.selectNewFileContainer"));
+               ContainerSelectionDialog dialog = new ContainerSelectionDialog(
+                               getShell(), ResourcesPlugin.getWorkspace().getRoot(), false,
+                               PHPWizardMessages
+                                               .getString("WizardPage.selectNewFileContainer"));
                if (dialog.open() == ContainerSelectionDialog.OK) {
                        Object[] results = dialog.getResult();
                        if (results.length == 1) {
@@ -156,7 +160,8 @@ public class PHPFileWizardPage extends WizardPage {
                String fileName = getFileName();
 
                if (container.length() == 0) {
-                       updateStatus(PHPWizardMessages.getString("WizardPage.containerMustBeSpecified"));
+                       updateStatus(PHPWizardMessages
+                                       .getString("WizardPage.containerMustBeSpecified"));
                        return;
                }
                if (fileName.length() == 0) {
@@ -193,9 +198,11 @@ public class PHPFileWizardPage extends WizardPage {
        protected boolean checkFolderForExistingFile() {
                IContainer container = getFileContainer();
                if (container != null) {
-                       IResource file = container.getFile(new Path(fileText.getText().trim()));
+                       IResource file = container.getFile(new Path(fileText.getText()
+                                       .trim()));
                        if (file != null && file.exists()) {
-                               this.setErrorMessage(PHPWizardMessages.getString("WizardPage.fileAlreadyExists"));
+                               this.setErrorMessage(PHPWizardMessages
+                                               .getString("WizardPage.fileAlreadyExists"));
                                return true;
                        }
                }
@@ -204,14 +211,16 @@ public class PHPFileWizardPage extends WizardPage {
 
        private IContainer getFileContainer() {
                if (containerText.getText() != null) {
-                       IPath containerPath = new Path(containerText.getText().trim());
+                       IPath containerPath = new Path(containerText.getText().trim());
                        IContainer container = null;
                        if (containerPath.segmentCount() > 1) {
-                               container = ResourcesPlugin.getWorkspace().getRoot().getFolder(containerPath);
+                               container = ResourcesPlugin.getWorkspace().getRoot().getFolder(
+                                               containerPath);
                        } else {
                                if (containerPath.segmentCount() == 1) {
                                        // this is a project
-                                       container = ResourcesPlugin.getWorkspace().getRoot().getProject(containerText.getText().trim());
+                                       container = ResourcesPlugin.getWorkspace().getRoot()
+                                                       .getProject(containerText.getText().trim());
                                }
                        }
                        if (container != null && container.exists()) {
@@ -225,10 +234,13 @@ public class PHPFileWizardPage extends WizardPage {
                super.setVisible(visible);
                if (visible) {
                        String fileName = fileText.getText().trim();
-                       if (getFileContainer() != null && fileName.equalsIgnoreCase(INITIAL_FILENAME)) {
+                       if (getFileContainer() != null
+                                       && fileName.equalsIgnoreCase(INITIAL_FILENAME)) {
                                fileText.setFocus();
                                fileText.setText(fileName);
-                               fileText.setSelection(0, fileName.length() - (new Path(INITIAL_FILENAME)).getFileExtension().length() - 1);
+                               fileText.setSelection(0, fileName.length()
+                                               - (new Path(INITIAL_FILENAME)).getFileExtension()
+                                                               .length() - 1);
                        }
                }
        }