示例#1
0
    def showMessageBox(self, xMSF, windowServiceName, windowAttribute,
            MessageText, peer=None):

        if MessageText is None:
            return 0

        iMessage = 0
        try:
            # If the peer is null we try to get one from the desktop...
            if peer is None:
                xFrame = Desktop.getActiveFrame(xMSF)
                peer = xFrame.getComponentWindow()

            xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
            oDescriptor = WindowDescriptor()
            oDescriptor.WindowServiceName = windowServiceName
            oDescriptor.Parent = peer
            oDescriptor.Type = MODALTOP
            oDescriptor.WindowAttributes = windowAttribute
            xMsgPeer = xToolkit.createWindow(oDescriptor)
            xMsgPeer.MessageText = MessageText
            iMessage = xMsgPeer.execute()
            xMsgPeer.dispose()
        except Exception:
            traceback.print_exc()

        return iMessage
示例#2
0
    def execute(self, args):
        """
    Arguments:
    - `args`:
    """
        try:
            from org.creativecommons.license.store import RdfLoaderThread

            for item in args:
                if item.Name == "Environment":
                    lEnvironment = item.Value
                    break

            #Display license information when opening CC licensed documents
            for item in lEnvironment:
                if item.Name == "EnvType":
                    sEnvType = item.Value
                if item.Name == "EventName":
                    sEventName = item.Value
                if item.Name == "Frame":
                    m_xFrame = item.Value

            #Only parse the rdf graph at the start-up of LibreOffice
            if sEventName == "OnStartApp":
                RdfLoaderThread().start()

            #Check for license info only if loading a new document
            if sEventName == "OnLoad":
                self.updateCurrentComponent()
                docProperties = self.xCurrentComponent.getDocumentInfo()

                #if this document has license information
                if docProperties.getPropertySetInfo().\
                  hasPropertyByName("license"):
                    message = ("This work is licensed under a "
                               "" + docProperties.\
                               getPropertyValue("License Name") +
                    "" + " License available at \n"
                    "" + docProperties.getPropertyValue("license"))

                    parentwin = self.xCurrentComponent.\
                      CurrentController.Frame.ContainerWindow
                    tk = parentwin.getToolkit()

                    #describe window properties.
                    aDescriptor = WindowDescriptor()
                    from com.sun.star.awt.VclWindowPeerAttribute import OK
                    aDescriptor.WindowAttributes = OK
                    aDescriptor.WindowServiceName = "messbox"
                    aDescriptor.ParentIndex = -1
                    aDescriptor.Parent = parentwin
                    msgbox = tk.createWindow(aDescriptor)

                    msgbox.setMessageText(message)
                    msgbox.execute()

        except:
            traceback.print_exc()
def MessageBox(Document, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK):
    ParentWin = Document.CurrentController.Frame.ContainerWindow

    MsgType = MsgType.lower()

    #available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")

    if not (MsgType in MsgTypes):
        MsgType = "messbox"

    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = MsgButtons

    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)

    msgbox.MessageText = MsgText
    if MsgTitle:
        msgbox.CaptionText = MsgTitle

    return msgbox.execute()
示例#4
0
def createWindow(toolkit, parent, service, attr, nX, nY, nWidth, nHeight):
    aRect = Rectangle(X=nX, Y=nY, Width=nWidth, Height=nHeight)
    d = WindowDescriptor(Type=SIMPLE,
                         WindowServiceName=service,
                         ParentIndex=-1,
                         Bounds=aRect,
                         Parent=parent,
                         WindowAttributes=attr)
    return toolkit.createWindow(d)
示例#5
0
def createWindow(toolkit, props, attrs):
    d = WindowDescriptor(Type=SIMPLE,
                         WindowServiceName=props.pop("WindowServiceName"),
                         ParentIndex=-1,
                         Bounds=props.pop("Bounds"),
                         Parent=props.pop("Parent"),
                         WindowAttributes=props.pop("WindowAttributes"))
    newwindow = toolkit.createWindow(d)
    for key, val in props.items():
        newwindow.setProperty(key, val)
    for key, val in attrs.items():
        getattr(newwindow, key)(val)
示例#6
0
def MessageBox(Document, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK):
    ParentWin = Document.CurrentController.Frame.ContainerWindow

    MsgType = MsgType.lower()

    # available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")

    if not (MsgType in MsgTypes):
        MsgType = "messbox"

    # describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    # aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = MsgButtons

    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)

    msgbox.MessageText = MsgText
    if MsgTitle:
        msgbox.CaptionText = MsgTitle

    return msgbox.execute()
示例#7
0
    def showMessageBox(self,
                       xMSF,
                       windowServiceName,
                       windowAttribute,
                       MessageText,
                       peer=None):

        if MessageText is None:
            return 0

        iMessage = 0
        try:
            # If the peer is null we try to get one from the desktop...
            if peer is None:
                xFrame = Desktop.getActiveFrame(xMSF)
                peer = xFrame.getComponentWindow()

            xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
            oDescriptor = WindowDescriptor()
            oDescriptor.WindowServiceName = windowServiceName
            oDescriptor.Parent = peer
            oDescriptor.Type = MODALTOP
            oDescriptor.WindowAttributes = windowAttribute
            xMsgPeer = xToolkit.createWindow(oDescriptor)
            xMsgPeer.MessageText = MessageText
            iMessage = xMsgPeer.execute()
            xMsgPeer.dispose()
        except Exception:
            traceback.print_exc()

        return iMessage
    def createNewPreviewFrame(self, xMSF, listener):
        xToolkit = None
        try:
            xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
        except Exception:
            # TODO Auto-generated catch block
            traceback.print_exc()

        #describe the window and its properties
        aDescriptor = WindowDescriptor()
        aDescriptor.Type = TOP
        aDescriptor.WindowServiceName = "window"
        aDescriptor.ParentIndex = -1
        aDescriptor.Parent = None
        aDescriptor.Bounds = Rectangle(10, 10, 640, 480)

        #Set Window Attributes
        gnDefaultWindowAttributes = \
            com_sun_star_awt_WindowAttribute_BORDER + \
            com_sun_star_awt_WindowAttribute_MOVEABLE + \
            com_sun_star_awt_WindowAttribute_SIZEABLE + \
            com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN

        aDescriptor.WindowAttributes = gnDefaultWindowAttributes
        #create a new blank container window
        xPeer = None
        try:
            xPeer = xToolkit.createWindow(aDescriptor)
        except IllegalArgumentException:
            traceback.print_exc()

        #define some further properties of the frame window
        #if it's needed .-)
        #xPeer->setBackground(...);
        #create new empty frame and set window on it
        xFrame = None
        try:
            xFrame = xMSF.createInstance("com.sun.star.frame.Frame")
        except Exception:
            traceback.print_exc()

        xFrame.initialize(xPeer)
        #from now this frame is useable ...
        #and not part of the desktop tree.
        #You are alone with him .-)
        if listener is not None:
            Desktop.getDesktop(xMSF).addTerminateListener(
                TerminateListenerProcAdapter(listener))

        return xFrame
示例#9
0
    def execute(self, args):
        """
    Arguments:
    - `args`:
    """
        try:
            from org.creativecommons.license.store import RdfLoaderThread

            for item in args:
                if item.Name == "Environment":
                    lEnvironment = item.Value
                    break

            #Display license information when opening CC licensed documents
            for item in lEnvironment:
                if item.Name == "EnvType":
                    sEnvType = item.Value
                if item.Name == "EventName":
                    sEventName = item.Value
                if item.Name == "Frame":
                    m_xFrame = item.Value

            #Only parse the rdf graph at the start-up of LibreOffice
            if sEventName == "OnStartApp":
                RdfLoaderThread().start()

            #Check for license info only if loading a new document
            if sEventName == "OnLoad":
                self.updateCurrentComponent()
                docProperties = self.xCurrentComponent.getDocumentInfo()

                #if this document has license information
                if docProperties.getPropertySetInfo().\
                  hasPropertyByName("license"):
                    message = ("This work is licensed under a "
                               "" + docProperties.\
                               getPropertyValue("License Name") +
                    "" + " License available at \n"
                    "" + docProperties.getPropertyValue("license"))

                    parentwin = self.xCurrentComponent.\
                      CurrentController.Frame.ContainerWindow
                    tk = parentwin.getToolkit()

                    #describe window properties.
                    aDescriptor = WindowDescriptor()
                    from com.sun.star.awt.VclWindowPeerAttribute import OK
                    aDescriptor.WindowAttributes = OK
                    aDescriptor.WindowServiceName = "messbox"
                    aDescriptor.ParentIndex = -1
                    aDescriptor.Parent = parentwin
                    msgbox = tk.createWindow(aDescriptor)

                    msgbox.setMessageText(message)
                    msgbox.execute()

        except:
            traceback.print_exc()
示例#10
0
 def createPreviewFrame(self, xmsf, xControl):
     controlPeer = xControl.Peer
     r = xControl.PosSize
     toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit")
     aDescriptor = WindowDescriptor()
     aDescriptor.Type = SIMPLE
     aDescriptor.WindowServiceName = "window"
     aDescriptor.ParentIndex = -1
     aDescriptor.Parent = controlPeer
     #xWindowPeer; #argument !
     aDescriptor.Bounds = Rectangle(0, 0, r.Width, r.Height)
     aDescriptor.WindowAttributes = CLIPCHILDREN | SHOW
     self.xWindow = toolkit.createWindow(aDescriptor)
     self.xFrame = xmsf.createInstance("com.sun.star.frame.Frame")
     self.xFrame.initialize(self.xWindow)
     self.xWindow.setVisible(True)
示例#11
0
    def createNewPreviewFrame(self, xMSF, listener):
        xToolkit = None
        try:
            xToolkit = xMSF.createInstance("com.sun.star.awt.Toolkit")
        except Exception:
            # TODO Auto-generated catch block
            traceback.print_exc()

        #describe the window and its properties
        aDescriptor = WindowDescriptor()
        aDescriptor.Type = TOP
        aDescriptor.WindowServiceName = "window"
        aDescriptor.ParentIndex = -1
        aDescriptor.Parent = None
        aDescriptor.Bounds = Rectangle(10, 10, 640, 480)

        #Set Window Attributes
        gnDefaultWindowAttributes = \
            com_sun_star_awt_WindowAttribute_BORDER + \
            com_sun_star_awt_WindowAttribute_MOVEABLE + \
            com_sun_star_awt_WindowAttribute_SIZEABLE + \
            com_sun_star_awt_VclWindowPeerAttribute_CLIPCHILDREN

        aDescriptor.WindowAttributes = gnDefaultWindowAttributes
        #create a new blank container window
        xPeer = None
        try:
            xPeer = xToolkit.createWindow(aDescriptor)
        except IllegalArgumentException:
            traceback.print_exc()

        #define some further properties of the frame window
        #if it's needed .-)
        #xPeer->setBackground(...);
        #create new empty frame and set window on it
        xFrame = None
        try:
            xFrame = xMSF.createInstance("com.sun.star.frame.Frame")
        except Exception:
            traceback.print_exc()

        xFrame.initialize(xPeer)
        #from now this frame is usable ...
        #and not part of the desktop tree.
        #You are alone with him .-)
        if listener is not None:
            Desktop.getDesktop(xMSF).addTerminateListener(listener)

        return xFrame
示例#12
0
 def createPreviewFrame(self, xmsf, xControl):
     controlPeer = xControl.Peer
     r = xControl.PosSize
     toolkit = xmsf.createInstance("com.sun.star.awt.Toolkit")
     aDescriptor = WindowDescriptor()
     aDescriptor.Type = SIMPLE
     aDescriptor.WindowServiceName = "window"
     aDescriptor.ParentIndex = -1
     aDescriptor.Parent = controlPeer
     #xWindowPeer; #argument !
     aDescriptor.Bounds = Rectangle(0, 0, r.Width, r.Height)
     aDescriptor.WindowAttributes = CLIPCHILDREN | SHOW
     self.xWindow = toolkit.createWindow(aDescriptor)
     self.xFrame = xmsf.createInstance("com.sun.star.frame.Frame")
     self.xFrame.initialize(self.xWindow)
     self.xWindow.setVisible(True)
示例#13
0
def create_dlg(toolkit, parent):
    from com.sun.star.awt.VclWindowPeerAttribute import OK, OK_CANCEL, YES_NO, YES_NO_CANCEL, RETRY_CANCEL, DEF_OK, DEF_CANCEL, DEF_RETRY, DEF_YES, DEF_NO
    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = "messbox"
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = parent
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = OK
    tk = parent.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    #msgbox.setMessageText("Hi there!")
    #msgbox.setCaptionText("a title")
    dlg = toolkit.createWindow(aDescriptor)
    return dlg
def messageBox(document, message):
    #doc = XSCRIPTCONTEXT.getDocument()
    window = document.CurrentController.Frame.ContainerWindow

    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = "infobox"
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = window
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = OK

    tk = window.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    msgbox.setCaptionText("Conversion to Unicode")
    msgbox.setMessageText(message)

    return msgbox.execute()
示例#15
0
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK):
    MsgType = MsgType.lower()
    #available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")
    if MsgType not in MsgTypes:
        MsgType = "messbox"
    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    aDescriptor.WindowAttributes = MsgButtons
    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    msgbox.setMessageText(MsgText)
    if MsgTitle:
        msgbox.setCaptionText(MsgTitle)
    return msgbox.execute()
示例#16
0
def MessageBox(MsgText,
               MsgTitle="GnuCash to Ooo",
               MsgType="messbox",
               MsgButtons=OK,
               ParentWin=None):
    global crout
    crout = 'MessageBox'
    global last_input_MessageBox
    ##    last_input_MessageBox = str(MsgText)

    if not ParentWin:
        doc = XSCRIPTCONTEXT.getDocument()
        try:
            ParentWin = doc.CurrentController.Frame.ContainerWindow
        except AttributeError:
            ParentWin = doc.Frame.ContainerWindow

    MsgType = MsgType.lower()

    #available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")

    if not (MsgType in MsgTypes):
        MsgType = "messbox"

    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = MsgButtons

    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)

    msgbox.setMessageText(MsgText)
    if MsgTitle:
        msgbox.setCaptionText(MsgTitle)

    return msgbox.execute()
示例#17
0
    def alert(self, msg, title = u'Alert'):
        """Opens an alert window with a message and title, and requires user to click 'Ok'"""
        parentWin = self.model.CurrentController.Frame.ContainerWindow

        aDescriptor = WindowDescriptor()
	aDescriptor.Type = MODALTOP
	aDescriptor.WindowServiceName = 'messbox'
	aDescriptor.ParentIndex = -1
	aDescriptor.Parent = parentWin
	aDescriptor.WindowAttributes = OK

        tk = parentWin.getToolkit()
        box = tk.createWindow(aDescriptor)

        box.setMessageText(msg)
        
        if title:
            box.setCaptionText(title)

        box.execute()
示例#18
0
def messagebox(tekst, ctx):
    desktop = ctx.ServiceManager.createInstanceWithContext(
        'com.sun.star.frame.Desktop', ctx)
    doc = desktop.getCurrentComponent()
    c = doc.getCurrentController()
    pw = c.Frame.ContainerWindow

    d = WindowDescriptor()
    d.Type = MODALTOP
    d.WindowServiceName = 'messbox'
    d.ParentIndex = -1
    d.Parent = pw
    d.WindowAttributes = OK

    tk = pw.getToolkit()

    mb = tk.createWindow(d)
    mb.setMessageText(tekst)
    mb.setCaptionText('Oei')
    return mb.execute()
def messageBox(document, message):
    #doc = XSCRIPTCONTEXT.getDocument()
    window = document.CurrentController.Frame.ContainerWindow

    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = "infobox"
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = window
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = OK

    tk = window.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    msgbox.setCaptionText("Conversion to Unicode")
    msgbox.setMessageText(message)

    return msgbox.execute()
示例#20
0
def messagebox(tekst, ctx):
    desktop = ctx.ServiceManager.createInstanceWithContext("com.sun.star.frame.Desktop", ctx)
    doc = desktop.getCurrentComponent()
    c = doc.getCurrentController()
    pw = c.Frame.ContainerWindow

    d = WindowDescriptor()
    d.Type = MODALTOP
    d.WindowServiceName = "messbox"
    d.ParentIndex = -1
    d.Parent = pw
    d.WindowAttributes = OK

    tk = pw.getToolkit()

    mb = tk.createWindow(d)
    mb.setMessageText(tekst)
    mb.setCaptionText("Oei")
    return mb.execute()
示例#21
0
文件: openplm.py 项目: amarh/openPLM
def MessageBox(ParentWin, MsgText, MsgTitle, MsgType="messbox", MsgButtons=OK):
    MsgType = MsgType.lower()
    #available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")
    if MsgType not in MsgTypes:
        MsgType = "messbox"
    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    aDescriptor.WindowAttributes = MsgButtons
    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    msgbox.setMessageText(MsgText)
    if MsgTitle :
        msgbox.setCaptionText(MsgTitle)
    return msgbox.execute()
示例#22
0
文件: gnuc2ooo.py 项目: 573/gnucash
def MessageBox(MsgText, MsgTitle="GnuCash to Ooo", MsgType="messbox", MsgButtons=OK, ParentWin=None):
    global crout
    crout = 'MessageBox'
    global last_input_MessageBox
##    last_input_MessageBox = str(MsgText)

    if not ParentWin:
            doc = XSCRIPTCONTEXT.getDocument()
            try:
                ParentWin = doc.CurrentController.Frame.ContainerWindow
            except AttributeError:               
                ParentWin = doc.Frame.ContainerWindow

    
    MsgType = MsgType.lower()
    
    #available msg types
    MsgTypes = ("messbox", "infobox", "errorbox", "warningbox", "querybox")
    
    if not ( MsgType in MsgTypes ):
        MsgType = "messbox"
    
    #describe window properties.
    aDescriptor = WindowDescriptor()
    aDescriptor.Type = MODALTOP
    aDescriptor.WindowServiceName = MsgType
    aDescriptor.ParentIndex = -1
    aDescriptor.Parent = ParentWin
    #aDescriptor.Bounds = Rectangle()
    aDescriptor.WindowAttributes = MsgButtons
    
    tk = ParentWin.getToolkit()
    msgbox = tk.createWindow(aDescriptor)
    
    msgbox.setMessageText(MsgText)
    if MsgTitle :
        msgbox.setCaptionText(MsgTitle)
        
    return msgbox.execute()
示例#23
0
def createWindow(toolkit, attr, props):  # ウィンドウタイトルは変更できない。attrはcom.sun.star.awt.WindowAttributeの和。propsはPositionX, PositionY, Width, Height, ParentIndex。
    aRect = Rectangle(X=props.pop("PositionX"), Y=props.pop("PositionY"), Width=props.pop("Width"), Height=props.pop("Height"))
    d = WindowDescriptor(Bounds=aRect, WindowAttributes=attr)
    for key, val in props.items():
        setattr(d, key, val)
    return toolkit.createWindow(d)  # ウィンドウピアを返す。
示例#24
0
def create_window(ctx, args):
    """ Creates docking window.
        @param ctx component context
        @param args arguments passed by the window content factory manager.
        @return new docking window
    """
    def create(name):
        return ctx.getServiceManager().createInstanceWithContext(name, ctx)

    if not args: return None

    frame = None  # frame of parent document window
    for arg in args:
        name = arg.Name
        if name == "ResourceURL":
            if arg.Value != RESOURCE_URL:
                return None
        elif name == "Frame":
            frame = arg.Value

    if frame is None: return None  # ToDo: raise exception

    global current_locale

    # this dialog has no title and placed at the top left corner.
    dialog1 = "vnd.sun.star.extension://com.addon.autotextaddon/dialogs_autotext/Dialog1.xdl"
    window = None
    if True:
        ctx = uno.getComponentContext()
        smgr = ctx.ServiceManager

        try:
            ui_locale = gettext.translation(
                'base',
                localedir=get_main_directory("com.addon.autotextaddon") +
                'python/locales',
                languages=[getLanguage()])
        except Exception as e:
            ui_locale = gettext.translation(
                'base',
                localedir=get_main_directory("com.addon.autotextaddon") +
                'python/locales',
                languages=["en"])

        ui_locale.install()
        _ = ui_locale.gettext
        toolkit = create("com.sun.star.awt.Toolkit")
        parent = frame.getContainerWindow()

        # Creates outer window
        # title name of this window is defined in WindowState configuration.
        desc = WindowDescriptor(
            SIMPLE, "window", parent, 0, Rectangle(0, 0, 400, 400),
            SHOW | SIZEABLE | MOVEABLE | CLOSEABLE | CLIPCHILDREN)
        window = toolkit.createWindow(desc)

        # Create inner window from dialog
        dp = create("com.sun.star.awt.ContainerWindowProvider")
        child = dp.createContainerWindow(dialog1, "", window, None)

        psm = uno.getComponentContext().ServiceManager
        dps = psm.createInstance("com.sun.star.text.AutoTextContainer")

        oRange = dps.getByName(current_group)
        ctx = uno.getComponentContext()
        smgr = ctx.ServiceManager

        # Initialize Dialog items

        #Initialize listeners
        action_listener = ActionListener(ctx, child)
        mouse_listener = MouseListener(ctx)

        # Autotext Listbox
        Autotext_Label = child.getControl("LabelListbox")
        Autotext_Label.Text = _("Auto Texts")

        GroupLabel = child.getControl("GroupLabel")
        GroupLabel.Text = _("Group")

        Preview_Label = child.getControl("LabelPreview")
        Preview_Label.Text = _("Preview")

        Autotext_ListBox = child.getControl("SavedAutotext")

        # there should be sorted entries by title and not name!

        Autotext_ListBox.addItems(update_auto_list(oRange), 0)

        Autotext_ListBox.addMouseListener(mouse_listener)
        #xray(smgr,ctx,Autotext_ListBox)
        OK_Button = child.getControl("OKButton")
        OK_Button.addActionListener(action_listener)
        OK_Button.setActionCommand('InsertAutoText')
        OK_Button.Label = _("Insert")

        AddSelection_Button = child.getControl("AddSelectionButton")
        AddSelection_Button.addActionListener(action_listener)
        AddSelection_Button.setActionCommand('AddSelectedAutoText')
        AddSelection_Button.Label = _("Add Selection")

        More_Button = child.getControl("MoreButton")
        More_Button.addActionListener(action_listener)
        More_Button.setActionCommand('MoreDispatch')
        More_Button.Label = _("More...")

        TeamList = child.getControl("GroupListBox")
        TeamList.addActionListener(ListBoxActionListener(ctx, child))

        global groups_to_insert
        global group_ids
        group_ids = dps.getElementNames()

        groups_to_insert = []

        for x in group_ids:
            groups_to_insert[len(groups_to_insert):] = [dps.getByName(x).Title]

        TeamList.addItems(groups_to_insert, 0)
        TeamList.getModel().SelectedItems = [group_ids.index(current_group)]

        child.setVisible(True)

        window.addWindowListener(WindowResizeListener(child))

        #child.setPosSize(0, 0, 0, 0, POS)  # if the dialog is not placed at
        # top left corner

    return window
def create_dockable_window(ctx, args):
    """ Creates docking window.
        @param ctx component context
        @param args arguments passed by the window content factory manager.
        @return new docking window
    """
    def create(name):
        return ctx.getServiceManager().createInstanceWithContext(name, ctx)

    if not args:
        return None

    frame = None  # frame of parent document window
    for arg in args:
        name = arg.Name
        if name == "ResourceURL":
            if arg.Value != RESOURCE_URL:
                return None
        elif name == "Frame":
            frame = arg.Value

    if frame is None:
        return None  # ToDo: raise exception

    # this dialog has no title and is placed at the top left corner.
    dialog1 = "vnd.sun.star.extension://tud.mci.tangram.Properties.DockingWindow/TitleDescDialog.xdl"
    window = None
    if True:
        try:
            toolkit = create("com.sun.star.awt.Toolkit")
            parent = frame.getContainerWindow()

            # Creates outer window (title name of this window is defined in WindowState configuration)
            desc = WindowDescriptor(
                SIMPLE, "window", parent, 0, Rectangle(0, 0, 100, 120),
                SHOW | SIZEABLE | MOVEABLE | CLOSEABLE | CLIPCHILDREN)
            window = toolkit.createWindow(desc)

            # Create inner window from dialog
            dp = create("com.sun.star.awt.ContainerWindowProvider")
            child = dp.createContainerWindow(dialog1, "", window, None)
            child.setVisible(True)
            child.setPosSize(
                0, 0, 0, 0,
                POS)  # if the dialog is not placed at top left corner

            window.addWindowListener(WindowResizeListener(child, window))

            controller = frame.getController()
            controller.addSelectionChangeListener(
                SelectionChangeListener(child, controller))

            tf_title = child.getControl("TextField_Title")
            listener1 = EditListener(1, controller, tf_title, child)
            tf_title.addKeyListener(listener1)
            tf_title.addFocusListener(listener1)
            tf_title.addTextListener(listener1)
            no_selection_text = tf_title.getText()

            tf_desc = child.getControl("TextField_Desc")
            listener2 = EditListener(2, controller, tf_desc, child)
            tf_desc.addKeyListener(listener2)
            tf_desc.addFocusListener(listener2)
            tf_desc.addTextListener(listener2)

            btn_save = child.getControl("CommandButton_Save")
            listener3 = ButtonListener(3, controller, child)
            btn_save.addActionListener(listener3)

            tf_title.setEnable(False)
            tf_desc.setEnable(False)
            btn_save.setEnable(False)
            tf_title.setText(str(no_selection_text))
            tf_desc.setText(str(no_selection_text))

        except Exception as e:
            print(e)
            #ctypes.windll.user32.MessageBoxA(0, str(e), "dialog add error", 1)

    return window
示例#26
0
def create_window(toolkit, parent, wtype, service, attrs, x, y, width, height):
    return toolkit.createWindow(
        WindowDescriptor(wtype, service, parent, -1, 
        Rectangle(x, y, width, height), attrs))