[Libreoffice-commits] core.git: 2 commits - wizards/com

Xisco Fauli anistenis at gmail.com
Sat Nov 23 08:27:53 PST 2013


 wizards/com/sun/star/wizards/ui/event/DataAware.py    |    5 --
 wizards/com/sun/star/wizards/ui/event/UnoDataAware.py |   28 --------------
 wizards/com/sun/star/wizards/web/WWD_Events.py        |   20 +---------
 wizards/com/sun/star/wizards/web/WWD_General.py       |   36 +++++++++++-------
 wizards/com/sun/star/wizards/web/WWD_Startup.py       |    9 ++--
 wizards/com/sun/star/wizards/web/WebWizardConst.py    |    3 +
 wizards/com/sun/star/wizards/web/WebWizardDialog.py   |    3 +
 7 files changed, 33 insertions(+), 71 deletions(-)

New commits:
commit f86769904747a89bcd7e81ad0d859f38175822c3
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sat Nov 23 17:23:19 2013 +0100

    pyweb: Cleanup publisher options
    
    Change-Id: I4308a831a505b0a5d0ac04b943cd9d6efa89298d

diff --git a/wizards/com/sun/star/wizards/ui/event/DataAware.py b/wizards/com/sun/star/wizards/ui/event/DataAware.py
index 0fae91a..70e52df 100644
--- a/wizards/com/sun/star/wizards/ui/event/DataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/DataAware.py
@@ -53,9 +53,6 @@ class DataAware(object):
         self._dataObject = dataObject_
         self._field = field_
 
-    def enableControls(self, value):
-        pass
-
     '''
     sets the given value to the UI control
     @param newValue the value to set to the ui control.
@@ -89,7 +86,6 @@ class DataAware(object):
                 self.setToUI(data)
             except Exception:
                 traceback.print_exc()
-        self.enableControls(data)
 
     '''
     sets a new data object. Optionally
@@ -135,7 +131,6 @@ class DataAware(object):
                         #Listbox Element
                         ui = ui[0]
                     setattr(self._dataObject, self._field, ui)
-            self.enableControls(ui)
         except Exception:
             traceback.print_exc()
 
diff --git a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
index 1ed80a1..1254e98 100644
--- a/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
+++ b/wizards/com/sun/star/wizards/ui/event/UnoDataAware.py
@@ -34,8 +34,6 @@ For those controls, static convenience methods are offered, to simplify use.
 
 class UnoDataAware(DataAware):
 
-    disableObjects = []
-
     def __init__(self, dataObject, field, unoObject_, unoPropName_, isShort=False):
         super(UnoDataAware,self).__init__(dataObject, field)
         self.unoControl = unoObject_
@@ -43,10 +41,6 @@ class UnoDataAware(DataAware):
         self.unoPropName = unoPropName_
         self.isShort = isShort
 
-    def enableControls(self, value):
-        for i in self.disableObjects:
-            i.Model.Enabled = self.getBoolean(value)
-
     def setToUI(self, value):
         if (isinstance(value, list)):
             value = tuple(value)
@@ -65,28 +59,6 @@ class UnoDataAware(DataAware):
             else:
                 uno.invoke(self.unoModel, "set" + self.unoPropName, (value,))
 
-    # Try to get from an arbitrary object a boolean value.
-    # Null returns Boolean.FALSE;
-    # A Boolean object returns itself.
-    # An Array returns true if it not empty.
-    # An Empty String returns Boolean.FALSE.
-    # everything else returns a Boolean.TRUE.
-    # @param value
-    # @return
-    def getBoolean(self, value):
-        if (value is None):
-            return False
-        elif (isinstance(value, bool)):
-            return bool(value)
-        elif (isinstance(value, list)):
-            return True if (len(value) is not 0) else False
-        elif (value is ""):
-            return False
-        elif (isinstance(value, int)):
-            return True if (value == 0) else False
-        else:
-            return True
-
     def getFromUI(self):
         return getattr(self.unoModel, self.unoPropName)
 
diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.py b/wizards/com/sun/star/wizards/web/WWD_Events.py
index af88c00..50d5bc7 100644
--- a/wizards/com/sun/star/wizards/web/WWD_Events.py
+++ b/wizards/com/sun/star/wizards/web/WWD_Events.py
@@ -425,8 +425,8 @@ class WWD_Events(WWD_Startup):
     '''
 
     def updatePublishUI(self, number):
-        (self.pubAware[number]).updateUI()
-        (self.pubAware[number + 1]).updateUI()
+        self.pubAware[number].updateUI()
+        self.pubAware[number + 1].updateUI()
         self.checkPublish()
 
     '''
diff --git a/wizards/com/sun/star/wizards/web/WWD_General.py b/wizards/com/sun/star/wizards/web/WWD_General.py
index 4a06ce6..cecd51e 100644
--- a/wizards/com/sun/star/wizards/web/WWD_General.py
+++ b/wizards/com/sun/star/wizards/web/WWD_General.py
@@ -30,10 +30,7 @@ from ..common.HelpIds import HelpIds
 from ..common.PropertyNames import PropertyNames
 from ..ui.event.ListModelBinder import ListModelBinder
 
-from com.sun.star.lang import IllegalArgumentException
-
 '''
- at author rpiterman
 This class implements general methods, used by different sub-classes
 (either WWD_Sturtup, or WWD_Events) or both.
 '''
@@ -172,6 +169,8 @@ class WWD_General(WebWizardDialog):
         If it is empty, then step3 and on are disabled.
         '''
         if self.checkDocList():
+            self.changeLocalDirState(self.chkLocalDir.Model.State)
+            self.changeZipState(self.chkZip.Model.State)
             self.checkPublish()
 
     '''
@@ -232,7 +231,7 @@ class WWD_General(WebWizardDialog):
         if p.cp_Publish:
             url = getattr(text.Model, _property)
             if url is None or url == "":
-                raise IllegalArgumentException ()
+                return False
             else:
                 return True
         else:
@@ -248,15 +247,12 @@ class WWD_General(WebWizardDialog):
     '''
 
     def checkPublish_(self):
-        try:
-            return \
-                self.checkPublish2(LOCAL_PUBLISHER, self.txtLocalDir, "Text") \
-                or (not self.proxies and self.checkPublish2(
-                    FTP_PUBLISHER, self.lblFTP, PropertyNames.PROPERTY_LABEL) \
-                or self.checkPublish2(ZIP_PUBLISHER, self.txtZip, "Text")) \
-                and self.checkSaveSession()
-        except IllegalArgumentException as ex:
-            return False
+        return \
+        self.checkPublish2(LOCAL_PUBLISHER, self.txtLocalDir, "Text") \
+        or (not self.proxies and self.checkPublish2(
+            FTP_PUBLISHER, self.lblFTP, PropertyNames.PROPERTY_LABEL) \
+        or self.checkPublish2(ZIP_PUBLISHER, self.txtZip, "Text")) \
+        and self.checkSaveSession()
 
     '''
     This method checks if the publishing
@@ -269,6 +265,20 @@ class WWD_General(WebWizardDialog):
     def checkPublish(self):
         self.enableFinishButton(self.checkPublish_())
 
+    def chkLocalDirItemChanged(self):
+        self.changeLocalDirState(self.chkLocalDir.Model.State)
+        self.checkPublish()
+
+    def chkZipItemChanged(self):
+        self.changeZipState(self.chkZip.Model.State)
+        self.checkPublish()
+
+    def changeLocalDirState(self, enable):
+        self.btnLocalDir.Model.Enabled = enable
+
+    def changeZipState(self, enable):
+        self.btnZip.Model.Enabled = enable
+        
     '''
     shows a message box "Unexpected Error... " :-)
     @param ex
diff --git a/wizards/com/sun/star/wizards/web/WWD_Startup.py b/wizards/com/sun/star/wizards/web/WWD_Startup.py
index f76ffc4..b2dfecd 100644
--- a/wizards/com/sun/star/wizards/web/WWD_Startup.py
+++ b/wizards/com/sun/star/wizards/web/WWD_Startup.py
@@ -127,6 +127,8 @@ class WWD_Startup(WWD_General):
         self.buildStep5()
         self.buildStep6()
         self.buildStep7(self.proxies, exclamationURL)
+        self.txtLocalDir.Model.Enabled = False
+        self.txtZip.Model.Enabled = False
         self.buildStepX()
         self.xMSF = xmsf
         xDesktop = Desktop.getDesktop(xmsf)
@@ -223,7 +225,6 @@ class WWD_Startup(WWD_General):
         DataAware.updateUIs(self.genAware)
         DataAware.updateUIs(self.pubAware)
         self.sessionNameDA.updateUI()
-        self.checkPublish()
 
     '''
     create the peer, add roadmap,
@@ -448,9 +449,9 @@ class WWD_Startup(WWD_General):
         self.pubAware_(
             LOCAL_PUBLISHER, self.chkLocalDir, self.txtLocalDir, False)
         self.pubAware_(
-            FTP_PUBLISHER, self.chkFTP, self.lblFTP, True)
-        self.pubAware_(
             ZIP_PUBLISHER, self.chkZip, self.txtZip, False)
+        self.pubAware_(
+            FTP_PUBLISHER, self.chkFTP, self.lblFTP, True)
         self.sessionNameDA = UnoDataAware.attachEditControl(
             self.settings.cp_DefaultSession, "cp_Name",
             self.cbSaveSettings, True)
@@ -466,8 +467,6 @@ class WWD_Startup(WWD_General):
     def pubAware_(self, publish, checkbox, textbox, isLabel):
         p = self.settings.cp_DefaultSession.cp_Publishing.getElement(publish)
         uda = UnoDataAware.attachCheckBox(p, "cp_Publish", checkbox, True)
-        uda.Inverse = True
-        uda.disableObjects = [textbox]
         self.pubAware.append(uda)
         if isLabel:
             aux = UnoDataAware.attachLabel(p, "cp_URL", textbox, False)
diff --git a/wizards/com/sun/star/wizards/web/WebWizardConst.py b/wizards/com/sun/star/wizards/web/WebWizardConst.py
index 7af2518..f6a2282 100644
--- a/wizards/com/sun/star/wizards/web/WebWizardConst.py
+++ b/wizards/com/sun/star/wizards/web/WebWizardConst.py
@@ -29,7 +29,8 @@ BTNICONSETS_ACTION_PERFORMED = "chooseIconset" # "btnIconSetsActionPerformed"
 BTNFAVICON_ACTION_PERFORMED = "chooseFavIcon" # "btnFavIconActionPerformed"
 BTNPREVIEW_ACTION_PERFORMED = "documentPreview" # "btnPreviewActionPerformed"
 BTNFTP_ACTION_PERFORMED = "setFTPPublish" # "btnFTPActionPerformed"
-CHKLOCALDIR_ITEM_CHANGED = "checkPublish" # "chkLocalDirItemChanged"
+CHKLOCALDIR_ITEM_CHANGED = "chkLocalDirItemChanged" # "chkLocalDirItemChanged"
+CHKZIP_ITEM_CHANGED = "chkZipItemChanged"
 CHKSAVESETTINGS_ITEM_CHANGED = "checkPublish" # "chkSaveSettingsItemChanged"
 TXTSAVESETTINGS_TEXT_CHANGED = "checkPublish" # "txtSaveSettingsTextChanged"
 BTNLOCALDIR_ACTION_PERFORMED = "setPublishLocalDir" # "btnLocalDirActionPerformed"
diff --git a/wizards/com/sun/star/wizards/web/WebWizardDialog.py b/wizards/com/sun/star/wizards/web/WebWizardDialog.py
index 47a7880..80b221c 100644
--- a/wizards/com/sun/star/wizards/web/WebWizardDialog.py
+++ b/wizards/com/sun/star/wizards/web/WebWizardDialog.py
@@ -599,7 +599,8 @@ class WebWizardDialog(WizardDialog):
                 self.resources.resbtnLocalDir_value, "btnLocalDir",
                 308, 77, 7, tabIndex + 1, 16), self)
         self.chkZip = self.insertCheckBox(
-            "chkZip", None, WebWizardDialog.PROPNAMES_CHKBOX,
+            "chkZip", CHKZIP_ITEM_CHANGED, 
+            WebWizardDialog.PROPNAMES_CHKBOX,
             (9, HelpIds.getHelpIdString(HID7_CHK_PUBLISH_ZIP),
                 self.resources.reschkZip_value, "chkZip", 103, 96, 0, 7,
                 tabIndex + 1, 215), self)
commit 2d5695bab3d62f0284669373e472c82e5e45ec2b
Author: Xisco Fauli <anistenis at gmail.com>
Date:   Sat Nov 23 14:22:51 2013 +0100

    pyweb: remove unused code
    
    Change-Id: Ia0d1ab92d3b23e834e3b953a8caadfdcae75d0ab

diff --git a/wizards/com/sun/star/wizards/web/WWD_Events.py b/wizards/com/sun/star/wizards/web/WWD_Events.py
index 0547983..af88c00 100644
--- a/wizards/com/sun/star/wizards/web/WWD_Events.py
+++ b/wizards/com/sun/star/wizards/web/WWD_Events.py
@@ -17,7 +17,6 @@
 #
 import traceback
 import uno
-import time
 
 from .WWD_Startup import WWD_Startup
 from .WWD_General import WWD_General
@@ -25,7 +24,6 @@ from .WebWizardConst import *
 from ..common.FileAccess import FileAccess
 from ..common.Configuration import Configuration
 from ..ui.event.ListModelBinder import ListModelBinder
-from ..ui.event.CommonListener import KeyListenerProcAdapter
 from ..ui.event.Task import Task
 from .data.CGDocument import CGDocument
 from .data.CGSession import CGSession
@@ -61,13 +59,8 @@ class WWD_Events(WWD_Startup):
 
     def __init__(self, xmsf):
         super(WWD_Events, self).__init__(xmsf)
-        c = KeyListenerProcAdapter(self.keyPressed)
-        self.chkFTP.addKeyListener(c)
-        self.chkLocalDir.addKeyListener(c)
-        self.chkZip.addKeyListener(c)
         self.currentSession = ""
         self.exitOnCreate = True
-        self.time = 0
         self.count = 0
         self.bgDialog = None
         self.iconsDialog = None
@@ -101,15 +94,6 @@ class WWD_Events(WWD_Startup):
             if sessionToLoad is not self.currentSession:
                 self.loadSession(sessionToLoad)
 
-    def keyPressed(self, ke):
-        if (ke.KeyChar == '&'):
-            self.time = time.time()
-        elif (ke.KeyChar == '%' and ((time.time() - self.time) < 300)):
-            b = self.xDialogModel.btnWizardFinish.Enabled
-            if (b):
-                self.finishWizard1(False)
-
-
     '''
     **************
         STEP 1


More information about the Libreoffice-commits mailing list