changeset 95:19e9d76a10fb

Fix: Recognize first letter to choose a project The first key must be checked if it's a key for a project. If yes switch directly to RunningProjectState else use SelectProjectState and wait for additional letters
author Björn Ricks <bjoern.ricks@intevation.de>
date Thu, 01 Sep 2011 08:19:26 +0200
parents 159a1ef0fd7c
children 8c7e0fd31e88
files getan/states.py
diffstat 1 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/getan/states.py	Wed Aug 31 15:43:12 2011 +0200
+++ b/getan/states.py	Thu Sep 01 08:19:26 2011 +0200
@@ -82,7 +82,8 @@
 
         else:
             if len(key) > 0:
-                return SelectProjectState(self.controller, self.view, key[0])
+                select_proj = SelectProjectState(self.controller, self.view, key[0])
+                return select_proj.check_key()
         return self
 
 
@@ -93,7 +94,6 @@
 
 class SelectProjectState(State):
 
-
     def __init__(self, controller, view, key):
         super(SelectProjectState, self).__init__(controller, view)
         self.proj_keys = key
@@ -105,6 +105,18 @@
     def set_footer_text(self):
         self.view.set_footer_text("Selecting project from key: %s" % self.proj_keys, "running")
 
+    def check_key(self):
+        proj = self.controller.project_by_key(self.proj_keys)
+        if proj:
+            self.reset()
+            self.view.select_project(proj)
+            self.controller.start_project(self.view.item_in_focus())
+            self.controller.update_entries(
+                    self.view.item_in_focus())
+            return RunningProjectsState(self.controller, self.view, proj)
+        return self
+
+
     def keypress(self, key):
         if 'esc' in key:
             self.reset()
@@ -114,14 +126,7 @@
             if len(key) > 0:
                 self.proj_keys += key[0]
                 self.set_footer_text()
-                proj = self.controller.project_by_key(self.proj_keys)
-                if proj:
-                    self.reset()
-                    self.view.select_project(proj)
-                    self.controller.start_project(self.view.item_in_focus())
-                    self.controller.update_entries(
-                        self.view.item_in_focus())
-                    return RunningProjectsState(self.controller, self.view, proj)
+                return self.check_key()
         return self
 
 class ExitState(ProjectState):
This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)