def go():    
    """
    The stuff we ought to do
    """
    # Never ever commit egg-info, it breaks lots of stuff
    
    query = MessageDialog.openQuestion(window.getShell(), "Plone Development References Set-up", "This will modify your workspace preferences to be suitable for Plone development. For details please consult the user guide. Continue?") 

    if not query:
        return
    
    # Compiled .PO files
    # Plone will compile these on start up
    add_ignore_mask("*.mo")
    
    # Never commit EGGs. Many broken tools (paster!) 
    # populate / download eggs to source folder
    # also note that capitalization may vary  
    add_ignore_mask("*.egg-info")
    add_ignore_mask("*.egg")
    add_ignore_mask("*.EGG")
    add_ignore_mask("*.EGG-INFO")
    
    # Eclipse settings files
    add_ignore_mask(".project")
    add_ignore_mask(".pydevproject")
    
    # Following are buildout or setuptools generated folders
    add_ignore_mask("bin")
    add_ignore_mask("build")
    add_ignore_mask("develop-eggs")
    add_ignore_mask("downloads")
    add_ignore_mask("eggs")
    add_ignore_mask("fake-eggs")
    add_ignore_mask("parts")
    add_ignore_mask("dist")


    # Not entirely sure what this folder is, but this hidden
    # folder appears in Eclipse project root on OSX
    add_ignore_mask(".settings")
    
    # Following files are in nested buildouts
    add_ignore_mask(".installed.cfg")
    add_ignore_mask(".mr.developer.cfg")
    
    # Nested version control checkouts in the source tree
    add_ignore_mask(".hg")
    add_ignore_mask(".git")
    add_ignore_mask(".bzr")
    
    use_utf8()
    dont_fuck_up_tabs()
    associate_zope_file_types()
    require_restart()
def require_restart():
    """ Need to restart because preference changes are not reflected otherwise.
    
    TODO: There must be a smarter way...
    """
    
    query = MessageDialog.openQuestion(window.getShell(), "Eclipse restart required", "Eclipse restart is required to make changes effective. Restart now?") 

    if query:
        workbench = window.getWorkbench()
        workbench.restart();
def check_we_are_src():
    """ Check whether workspace is set up according to instructions
    
    @return: False if this is not going to work
    """
    workspace = ResourcesPlugin.getWorkspace()    
    root = workspace.getRoot()
    location = root.getRawLocation()
    path = location.toOSString()
    
    if path.endswith("src") or path.endswith("products"): # products is a special case made for my Danish friend
    

        return True
    
    else:        
        query = MessageDialog.openQuestion(window.getShell(), 
                                           "Workspace is not correctly set up", 
                                           "Workspace folder should be src/ folder of buildout.  The current workspace folder '" + path + "' does not look like one. Scan checked out projects from this folder?") 
        return query
def check_omelette():
    """
    @return: True if omelette is available and user would like to import it
    """

    # workspace is org.eclipse.core.internal.resources.Workspace
    # http://help.eclipse.org/galileo/topic/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/resources/IWorkspace.html
    workspace = ResourcesPlugin.getWorkspace()    
    root = workspace.getRoot()
    
    # location will be IPath object, we need string presentation of the path
    # 
    location = root.getRawLocation()
    path = location.toOSString()
    omelette_path = os.path.join(path, "..", "parts", "omelette")
    omelette_path = os.path.normpath(omelette_path)

    if os.path.exists(omelette_path):                
        query = MessageDialog.openQuestion(window.getShell(), "Omelette detected", "Omelette buildout part contains all Python files used by Plone in symlinked structure. Importing omelette folder to workspace makes Python name completion to work. However, it is a very heavy task - loooong 'Building workspace' operation must be done when the workspace is refreshed. Unless you have a very powerful computer your computer will probably melt down to smoldering ashes. Alternatively toggle on 'Analyze open editors only' setting in PyDev preferences. Import omelette?") 
        return query
    else:
        return False