Anonymous avatar Anonymous committed 6d77609

Opening newly created module

Comments (0)

Files changed (6)

+- Make a new module dialog : April 25, 2006
+
+
 > Public release 0.1pre : April 22, 2006
 
 
 * Showing current line in status bar @ 1
 
 
+* Switch editor dialog; C-x b and C-F6 @ 1
+
+
 * Make a new package @ 1
   Should ask the source folder.
 
 
-* Switch editor dialog; C-x b and C-F6 @ 1
-
-
-* Make a new module @ 1
-  Should ask the source folder and package.
-
-
 --- Remaining Stories ---
 ? Rename rope; maybe pyrope
 ? Using underlined_words function style

docs/workingon.txt

-*** Make a new module @ 1 ***
+* Make a new package @ 1
+  Should ask the source folder.
+
 
 - Where does this belong to Project or another class: Project
 - Add Folder.create_file, Folder.create_folder, Folder.get_child
+- Should ask the source folder and the package
+- Add to UICore
+- Open module after creating
 
 ? Use Dialogs instead
-? Testing GUI? again!
-* Should ask the source folder and the package
-* Add to UICore
-* Open module after creating
-
-
+? GUI Testing Problems? again!
 ? Separation of UI Wizards
 ? Better multi-sequence key event handling
 ? Iterator for accessing editor text or LineOrientedOutput
     def _create_menu(self):
         fileMenu = Menu(self.menubar, tearoff=0)
         self.menubar.add_cascade(label='File', menu=fileMenu, underline=1)
-        fileMenu.add_command(label='Open Project ...', command=self._open_project, underline=6)
+        fileMenu.add_command(label='Open Project ...', command=self._open_project_dialog, underline=6)
         fileMenu.add_command(label='Close Project', command=self.close_project, underline=3)
         fileMenu.add_separator()
-        fileMenu.add_command(label='New File ...', command=self._create_new_file, underline=0)
-        fileMenu.add_command(label='New Folder ...', command=self._create_new_folder, underline=0)
-        fileMenu.add_command(label='New Module ...', command=self._create_module, underline=4)
+        fileMenu.add_command(label='New File ...', command=self._create_new_file_dialog, underline=0)
+        fileMenu.add_command(label='New Folder ...', command=self._create_new_folder_dialog, underline=0)
+        fileMenu.add_command(label='New Module ...', command=self._create_module_dialog, underline=4)
         fileMenu.add_separator()
-        fileMenu.add_command(label='Open File ...', command=self._open_file, underline=0)
-        fileMenu.add_command(label='Find File ...', command=self._find_file, underline=0)
+        fileMenu.add_command(label='Open File ...', command=self._open_file_dialog, underline=0)
+        fileMenu.add_command(label='Find File ...', command=self._find_file_dialog, underline=0)
         fileMenu.add_separator()
         fileMenu.add_command(label='Exit', command=self.exit, underline=1)
 
     def _set_key_binding(self, widget):
-        widget.bind('<Control-x><Control-f>', self._open_file)
-        widget.bind('<Control-x><Control-n>', self._create_new_file)
+        widget.bind('<Control-x><Control-f>', self._open_file_dialog)
+        widget.bind('<Control-x><Control-n>', self._create_new_file_dialog)
         def _save_active_editor(event):
             self.save_file()
             return 'break'
         widget.bind('<Control-x><Control-s>', _save_active_editor)
-        widget.bind('<Control-x><Control-p>', self._open_project)
+        widget.bind('<Control-x><Control-p>', self._open_project_dialog)
         def _exit(event):
             self.exit()
             return 'break'
         widget.bind('<Control-x><Control-c>', _exit)
-        widget.bind('<Control-x><Control-d>', self._create_new_folder)
-        widget.bind('<Control-R>', self._find_file)
+        widget.bind('<Control-x><Control-d>', self._create_new_folder_dialog)
+        widget.bind('<Control-R>', self._find_file_dialog)
         widget.bind('<Control-F11>', self._run_active_editor)
         def _close_active_editor(event):
             self.close_active_editor()
         widget.bind('<Control-x><k>', _close_active_editor)
 
 
-    def _find_file(self, event=None):
+    def _find_file_dialog(self, event=None):
         if not self.project:
             tkMessageBox.showerror(parent=self.root, title='No Open Project',
                                    message='No project is open')
         if event:
             return 'break'
 
-    def _create_module(self, event=None):
+    def _create_module_dialog(self, event=None):
         if not self.project:
             tkMessageBox.showerror(parent=self.root, title='No Open Project',
                                    message='No project is open')
         module_label = Label(create_dialog, text='Module')
         module_entry = Entry(create_dialog)
         
-        def create_module():
+        def do_create_module():
             source_folder = self.project.get_resource(source_entry.get())
             new_module = self.project.create_module(source_folder,
                                                     module_entry.get())
+            self._open_file_resource(new_module)
             toplevel.destroy()
         def cancel():
             toplevel.destroy()
-        source_entry.bind('<Return>', lambda event: create_module())
+        source_entry.bind('<Return>', lambda event: do_create_module())
         source_entry.bind('<Escape>', lambda event: cancel())
-        module_entry.bind('<Return>', lambda event: create_module())
+        module_entry.bind('<Return>', lambda event: do_create_module())
         module_entry.bind('<Escape>', lambda event: cancel())
 
-#        ok_button = Button(create_dialog, text='Create', command=create_module)
+#        ok_button = Button(create_dialog, text='Create', command=do_create_module)
 #        cancel_button = Button(create_dialog, text='Cancel', command=cancel)
         source_label.grid(row=0, column=0)
         source_entry.grid(row=0, column=1)
         self.run_active_editor()
         return 'break'
 
-    def _open_file(self, event=None):
+    def _open_file_dialog(self, event=None):
         if not self.project:
             tkMessageBox.showerror(parent=self.root, title='No Open Project',
                                    message='No project is open')
         self._show_open_dialog(doOpen, 'Open File Dialog')
         return 'break'
 
-    def _create_new_file(self, event=None):
+    def _create_new_file_dialog(self, event=None):
         if not self.project:
             tkMessageBox.showerror(parent=self.root, title='No Open Project',
                                    message='No project is open')
         self._show_open_dialog(doOpen, 'New File Dialog')
         return 'break'
 
-    def _create_new_folder(self, event=None):
+    def _create_new_folder_dialog(self, event=None):
         if not self.project:
             tkMessageBox.showerror(parent=self.root, title='No Open Project',
                                    message='No project is open')
         self._show_open_dialog(doOpen, 'New Folder Dialog')
         return 'break'
 
-    def _open_project(self, event=None):
+    def _open_project_dialog(self, event=None):
         def doOpen(projectRoot):
             self.open_project(projectRoot)
         directory = tkFileDialog.askdirectory(parent=self.root, title='Open Project')
         if self.project is None:
             raise RopeException('No project is open')
         file = self.project.get_resource(fileName)
+        return self._open_file_resource(file)
+
+    def _open_file_resource(self, file):
         for editor in self.editors:
             if editor.get_file() == file:
                 editor._rope_title.invoke()
 
     def create_module(self, src_folder, module):
         packages = module.split('.')
-        parent = self.get_root_folder()
+        parent = src_folder
         for package in packages[:-1]:
             parent = parent.get_child(package)
         return parent.create_file(packages[-1] + '.py')

ropetest/projecttest.py

         new_module = self.project.create_module(self.project.get_root_folder(), 'package.module')
         self.assertEquals(self.project.get_resource('package/module.py'), new_module)
 
+    def test_packaged_module_creation_with_nested_src(self):
+        src = self.project.get_root_folder().create_folder('src')
+        package = src.create_folder('pkg')
+        new_module = self.project.create_module(src, 'pkg.mod')
+        self.assertEquals(self.project.get_resource('src/pkg/mod.py'), new_module)
+
 
 class FileFinderTest(unittest.TestCase):
     def setUp(self):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.