Commits

Aleš Erjavec  committed acc364e

Added context dependent settings to 'Select' widget.

  • Participants
  • Parent commits 8a0b98c

Comments (0)

Files changed (1)

File _textable/widgets/OWTextableSelect.py

 class OWTextableSelect(OWWidget):
 
     """Orange widget for segment in-/exclusion based on intrisic properties"""
-    
+
+    contextHandlers = {
+        "": SegmentationContextHandler(
+            "", ["regexAnnotationKey", "thresholdAnnotationKey"])
+    }
     settingsList = [
             'regex',
             'method',
             'label',
             'autoNumber',
             'autoNumberKey',
-            'savedRegexAnnotationKey',
-            'savedThresholdAnnotationKey',
             'displayAdvancedSettings',
             'uuid',
     ]
 
     def inputData(self, segmentation):
         """Process incoming segmentation"""
+        self.closeContext("")
         self.segmentation = segmentation
         self.infoBox.inputChanged()
+        self.updateGUI()
+        if segmentation is not None:
+            self.openContext("", segmentation)
         self.sendButton.sendIf()
 
 
             self.advancedSettings.setVisible(False)
 
 
-
-    def handleNewSignals(self):
-        """Overridden: called after multiple signals have been added"""
-        self.restoreSettings()
-
-    def getSettings(self, alsoContexts = True, globalContexts=False):
-        """Overridden: called when a file is saved (among other situations)"""
-        self.storeSettings()
-        return super(type(self), self).getSettings(
-                alsoContexts = True, globalContexts=False
-        )
-
-    def restoreSettings(self):
-        """When a scheme file is opened, restore those settings that depend
-        on the particular segmentations that enter this widget.
-        """
-        if not self.settingsRestored:
-            self.settingsRestored = True
-            if self.segmentation is not None:
-                segmentation   = self.segmentation
-                annotationKeys = [u'(none)']
-                annotationKeys.extend(
-                        segmentation.get_annotation_keys()
-                )
-                for key in annotationKeys:
-                    if key == self.savedRegexAnnotationKey:
-                        self.regexAnnotationKey = key
-                    if key == self.savedThresholdAnnotationKey:
-                        self.thresholdAnnotationKey = key
-            self.sendButton.sendIf()
-
-    def storeSettings(self):
-        """When a scheme file is saved, store those settings that depend
-        on the particular segmentations that enter this widget.
-        """
-        if self.settingsRestored:
-            if self.segmentation is not None:
-                self.savedRegexAnnotationKey     = self.regexAnnotationKey
-                self.savedThresholdAnnotationKey = self.thresholdAnnotationKey
-            else:
-                self.savedRegexAnnotationKey     = None
-                self.savedThresholdAnnotationKey = None
-
-
-
 if __name__ == '__main__':
     appl = QApplication(sys.argv)
     ow   = OWTextableSelect()