Anonymous avatar Anonymous committed 82deb04

new element added: TextInput, plugings changed

Comments (0)

Files changed (7)

elements/elements.py

     def visible(self, value):
         self._visible = value
 
+class TextInput(Element):
+    # self.value is the text to be shown
+    def __init__(self, name, title, text, visible=True):
+        self.text = text
+        Element.__init__(self, name, title=title, editable=True,
+                         visible=visible)
+
 class TextBox(Element):
     # self.value is the text to be shown
     def __init__(self, name, title, text, editable=False, visible=True):

plugins/plantrisk_change.py

 from limma import PACKAGE_DIR
 from limma.items.item import AbstractItem, Resource
 from limma.items.global_item_type_dict import ITEM_TYPE_TO_CLASS
-from limma.elements.elements import TextBox, PathBox, SubprocessBox
+from limma.elements.elements import TextInput, PathBox, SubprocessBox
 from limma.persister.persister import PersistentObject
 
 class PlantriskChange(AbstractItem):
 
         # first element: case name
         self._case_name = PersistentObject()
-        self._case_box = TextBox('case', "Case",
-                                 self._case_name, 
-                                 editable=True)
+        self._case_box = TextInput('case', "Case", self._case_name)
 
         # second element: workbook with the changes
         self._input_path = PersistentObject()
         
         # forth element: file name to be created
         self._output_fname = PersistentObject()
-        self._output_fname_box = PathBox('output_fname',
-                                         "File name of the PlantRisk workbook "
-                                         "to be created",
-                                         self._output_fname,
-                                         editable=True)
+        self._output_fname_box = TextInput('output_fname',
+                                           "File name of the PlantRisk workbook "
+                                           "to be created",
+                                           self._output_fname)
 
         # fifth element: subprocess
         self._output = PersistentObject()

plugins/plantrisk_master.py

 
 from limma.items.item import AbstractItem, Resource
 from limma.items.global_item_type_dict import ITEM_TYPE_TO_CLASS
-from limma.elements.elements import TextBox, PathBox
+from limma.elements.elements import TextInput, PathBox
 from limma.persister.persister import PersistentObject
 
 class PlantriskMaster(AbstractItem):
 
         # first element is the case
         self._case_name = PersistentObject()
-        self._case_box = TextBox('case', "Case",
-                                 self._case_name, 
-                                 editable=True)
+        self._case_box = TextInput('case', "Case", self._case_name)
 
         # second element is the file name (path)
         self._path = PersistentObject()

plugins/shell_no_cancel.py

 
 from limma.items.item import AbstractItem
 from limma.items.global_item_type_dict import ITEM_TYPE_TO_CLASS
-from limma.elements.elements import TextBox
+from limma.elements.elements import TextInput, TextBox
 from limma.persister.persister import PersistentObject
 
 class ShellNoCancelItem(AbstractItem):
 
         # first element is the command
         self._cmd_str = PersistentObject()
-        self._cmd_box = TextBox('command', "Command", self._cmd_str, 
-                                editable=True)
+        self._cmd_box = TextInput('command', "Command", self._cmd_str)
 
         # second element is the output
         self._output = PersistentObject()

plugins/shell_with_cancel.py

 from limma.items.item import AbstractItem
 from limma.items.global_item_type_dict import ITEM_TYPE_TO_CLASS
-from limma.elements.elements import TextBox, SubprocessBox
+from limma.elements.elements import TextInput, SubprocessBox
 from limma.persister.persister import PersistentObject
 
 class ShellWithCancelItem(AbstractItem):
 
         # first element is the command box
         self._cmd_str = PersistentObject()
-        self._cmd_box = TextBox('command', "Command", self._cmd_str, 
-                                editable=True)
+        self._cmd_box = TextInput('command', "Command", self._cmd_str)
 
         # second element is the running window (it needs to know
         # the command

ui/console/console_ui.py

 from limma.ui.ui import AbstractUI
 from limma.ui.console.console_widgets import (
-    text_box_display, text_box_edit, subprocess_execute)
+    text_box_display, text_input_display, text_box_edit, subprocess_execute)
 from limma.ui.console.menu import Option, Menu
 from limma.structure.structure import Structure
-from limma.elements.elements import TextBox, SubprocessBox, PathBox
+from limma.elements.elements import TextBox, TextInput, SubprocessBox, PathBox
 
 EXIT_OPTION = Option('x', "Exit", None)
 CURSOR_STR = ">>> Execution cursor"
             return
 
         # XXX: is the a more OOP way of doing this?
-        if isinstance(element, TextBox):
+        if isinstance(element, TextInput):
+            text_input_display(element.title, element.text)
+        elif isinstance(element, TextBox):
             text_box_display(element.title, element.text)
         elif isinstance(element, SubprocessBox):
             text_box_display(element.title, element.output)
         elif isinstance(element, PathBox):
-            text_box_display(element.title, element.path)
+            text_input_display(element.title, element.path)
         else:
             raise NotImplementedError("display_element of type %s not "
                                       "implemented" % type(element))
 
         element = self.sheet.items[i_item].elements[i_element]
 
-        if isinstance(element, TextBox):
+        if isinstance(element, TextInput):
+            old_value = element.text
+            new_value = text_box_edit(element.title)
+        elif isinstance(element, TextBox):
             old_value = element.text
             new_value = text_box_edit(element.title)
         elif isinstance(element, PathBox):

ui/console/console_widgets.py

 
 from limma.util.execution import Execution
 
+def text_input_display(title, text):
+    print ' %s: %s' % (title, text)
+
 def text_box_display(header, text, n_head=None, n_tail=None):
 
     if text: # text may be None
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.