PyutPlugin.py :  » UML » Python-UML-Tool » pyut-1.4.0 » src » plugins » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » UML » Python UML Tool 
Python UML Tool » pyut 1.4.0 » src » plugins » PyutPlugin.py
#!/usr/bin/env python
# -*- coding: UTF-8 -*-
__author__  = "Laurent Burgbacher <lb@alawa.ch>"
__version__ = "$Revision: 1.6 $"
__date__    = "2002-02-14"
#from wxPython.wx import *
import wx, os

class PyutPlugin:
    """
    Standard plugin tools
    """
   
    #>------------------------------------------------------------------------

    def __init__(self, umlFrame, ctrl):
        """
        Constructor.

        @param UmlFrame umlFrame : the umlframe of pyut
        @param Mediator ctrl : mediator to use
        @author C.Dutoit
        """
        self._umlFrame = umlFrame
        self._ctrl = ctrl
        self._verbose = False


    #>------------------------------------------------------------------------

    def logMessage(self, module, msg):
        if self._verbose:
            print "%s> %s" % (module, msg)


    #>------------------------------------------------------------------------

    def _askForFileImport(self, multiple=False):
        """
        Called by plugin to ask which file must be imported

        @param Boolean multiple : True for multiple file selection
        @return filename or "" for multiple=False, filenames[] or [] else
                "", [] indicates that the user pressed the cancel button
        @since 1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        format=self.getInputFormat()
        if multiple:
            dlg = wx.FileDialog(
                self._umlFrame,
                "Choose files to import",
                wildcard = format[0] + " (*." + format[1] + ")|*." + format[1],
                defaultDir = self._ctrl.getCurrentDir(),
                style = wx.OPEN | wx.FILE_MUST_EXIST | wx.MULTIPLE | wx.CHANGE_DIR
            )
            dlg.ShowModal()
            if dlg.GetReturnCode()==5101: #Cancel
                return([], "")
            return (dlg.GetFilenames(), dlg.GetDirectory())
        else:
            file = wx.FileSelector(
                "Choose a file to import",
                wildcard = format[0] + " (*." + format[1] + ")|*." + format[1],
                #default_path = self.__ctrl.getCurrentDir(),
                flags = wx.OPEN | wx.FILE_MUST_EXIST | wx.CHANGE_DIR
            )
            return file
        #self.__ctrl.setCurrentDir(file.GetPath())


    #>------------------------------------------------------------------------

    def _askForFileExport(self):
        """
        Called by plugin to ask which file must be exported

        @since 1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        format=self.getOutputFormat()
        file = wx.FileSelector(
            "Choose a file name to export",
            wildcard = format[0] + " (*." + format[1] + ")|*." + format[1],
            #default_path = self.__ctrl.getCurrentDir(),
            flags = wx.SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR
        )
        #self.__ctrl.setCurrentDir(file.GetPath())
        return file



    #>------------------------------------------------------------------------

    def _askForDirectoryImport(self):
        """
        Called by plugin to ask which file must be imported

        @since 1.3
        @return The directory or "" if canceled by user
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        dir = wx.DirDialog(self._umlFrame, "Choose a directory to import", \
            defaultPath = self._ctrl.getCurrentDir())
#TODO : add this when supported...(cd)         style=wx.DD_NEW_DIR_BUTTON)
        if dir.ShowModal()==wx.ID_CANCEL:
            dir.Destroy()
            return ""
        else:
            directory=dir.GetPath()
            self._ctrl.setCurrentDir(directory)
            dir.Destroy()
            return directory

    #>------------------------------------------------------------------------

    def _askForDirectoryExport(self):
        """
        Called by plugin to ask for an output directory

        @since 1.2
        @author C.Dutoit <dutoitc@hotmail.com>
        """
        dir = wx.DirDialog(self._umlFrame, "Choose a destination directory", \
            defaultPath = self._ctrl.getCurrentDir())
#TODO : add this when supported...(cd)         style=wx.DD_NEW_DIR_BUTTON)
        dir.SetPath(os.getcwd())
        if dir.ShowModal()==wx.ID_CANCEL:
            dir.Destroy()
            return ""
        else:
            directory=dir.GetPath()
            self._ctrl.setCurrentDir(directory)
            dir.Destroy()
            return directory


www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.