Search in sources :

Example 1 with NewProjectNameAndLocationWizardPage

use of org.python.pydev.ui.wizards.project.NewProjectNameAndLocationWizardPage in project Pydev by fabioz.

the class AppEngineConfigWizardPageTestWorkbench method testCreateLaunchAndDebugGoogleAppProject.

public void testCreateLaunchAndDebugGoogleAppProject() throws Exception {
    final Display display = Display.getDefault();
    final Boolean[] executed = new Boolean[] { false };
    display.syncExec(new Runnable() {

        @Override
        public void run() {
            final Shell shell = new Shell(display);
            shell.setLayout(new FillLayout());
            Composite pageContainer = new Composite(shell, 0);
            AppEngineWizard appEngineWizard = new AppEngineWizard();
            appEngineWizard.setContainer(new IWizardContainer() {

                @Override
                public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
                    runnable.run(new NullProgressMonitor());
                }

                @Override
                public void updateWindowTitle() {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public void updateTitleBar() {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public void updateMessage() {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public void updateButtons() {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public void showPage(IWizardPage page) {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public Shell getShell() {
                    throw new RuntimeException("Not implemented");
                }

                @Override
                public IWizardPage getCurrentPage() {
                    return null;
                }
            });
            appEngineWizard.init(PlatformUI.getWorkbench(), new StructuredSelection());
            appEngineWizard.addPages();
            appEngineWizard.createPageControls(pageContainer);
            IWizardPage[] pages = appEngineWizard.getPages();
            NewProjectNameAndLocationWizardPage nameAndLocation = (NewProjectNameAndLocationWizardPage) pages[0];
            AppEngineConfigWizardPage appEnginePage = (AppEngineConfigWizardPage) pages[1];
            assertFalse(nameAndLocation.isPageComplete());
            nameAndLocation.setProjectName("AppEngineTest");
            assertTrue(nameAndLocation.isPageComplete());
            assertFalse(appEnginePage.isPageComplete());
            appEnginePage.setAppEngineLocationFieldValue(TestDependent.GOOGLE_APP_ENGINE_LOCATION + "invalid_path_xxx");
            assertFalse(appEnginePage.isPageComplete());
            appEnginePage.setAppEngineLocationFieldValue(TestDependent.GOOGLE_APP_ENGINE_LOCATION);
            assertTrue(appEnginePage.isPageComplete());
            assertTrue(appEngineWizard.performFinish());
            IProject createdProject = appEngineWizard.getCreatedProject();
            PythonNature nature = PythonNature.getPythonNature(createdProject);
            Map<String, String> expected = new HashMap<String, String>();
            expected.put(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE, new File(TestDependent.GOOGLE_APP_ENGINE_LOCATION).getAbsolutePath());
            IPythonPathNature pythonPathNature = nature.getPythonPathNature();
            try {
                assertEquals(expected, pythonPathNature.getVariableSubstitution());
                String projectExternalSourcePath = pythonPathNature.getProjectExternalSourcePath(false);
                assertTrue(projectExternalSourcePath.indexOf(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE) != -1);
                projectExternalSourcePath = pythonPathNature.getProjectExternalSourcePath(true);
                assertTrue(projectExternalSourcePath.indexOf(AppEngineConstants.GOOGLE_APP_ENGINE_VARIABLE) == -1);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
            // goToManual();
            executed[0] = true;
        }
    });
    assertTrue(executed[0]);
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) IPythonPathNature(org.python.pydev.core.IPythonPathNature) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IWizardContainer(org.eclipse.jface.wizard.IWizardContainer) Shell(org.eclipse.swt.widgets.Shell) NewProjectNameAndLocationWizardPage(org.python.pydev.ui.wizards.project.NewProjectNameAndLocationWizardPage) Composite(org.eclipse.swt.widgets.Composite) PythonNature(org.python.pydev.plugin.nature.PythonNature) FillLayout(org.eclipse.swt.layout.FillLayout) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException) IWizardPage(org.eclipse.jface.wizard.IWizardPage) HashMap(java.util.HashMap) Map(java.util.Map) File(java.io.File) Display(org.eclipse.swt.widgets.Display)

Aggregations

File (java.io.File)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IProject (org.eclipse.core.resources.IProject)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)1 IWizardContainer (org.eclipse.jface.wizard.IWizardContainer)1 IWizardPage (org.eclipse.jface.wizard.IWizardPage)1 FillLayout (org.eclipse.swt.layout.FillLayout)1 Composite (org.eclipse.swt.widgets.Composite)1 Display (org.eclipse.swt.widgets.Display)1 Shell (org.eclipse.swt.widgets.Shell)1 IPythonPathNature (org.python.pydev.core.IPythonPathNature)1 PythonNature (org.python.pydev.plugin.nature.PythonNature)1 NewProjectNameAndLocationWizardPage (org.python.pydev.ui.wizards.project.NewProjectNameAndLocationWizardPage)1