Example #1
0
def _override_context():
  """Utility that determines contexts attribute for always-active 
  commands so those commands don't show in the GUI when the plugin
  is inactive"""  
  if _CDjangoPluginActivator._instance._IsDjangoProject():
    return [wingapi.kContextNewMenu(_("Djang_o"), group=2)]
  else:
    return []
Example #2
0
   
def _cvs_update_available(filenames=wingapi.kArgFilename):
  if filenames is None or len(filenames) == 0:
    return False
  for filename in filenames:
    if not wingapi.IsUrl(filename):
      dir, version, date, flags = __read_entries_file(filename)
      if version is not None:
        return True
  return False
cvs_update.available = _cvs_update_available
cvs_update.label = _('CVS _Update')

cvs_update.contexts = [wingapi.kContextEditor(), 
                       wingapi.kContextProject(),
                       wingapi.kContextNewMenu(_("_CVS"), 1)]

def cvs_diff(filenames=wingapi.kArgFilename):
  """Perform cvs diff on the given files or directories.  The form of diff
  is controlled from the options dialog."""
  app = wingapi.gApplication
  diff_type = app.fSingletons.fFileAttribMgr[_kDiffTypeAttrib]
  if diff_type == 'default':
    cvs_ndiff(filenames)
  elif diff_type == 'context':
    cvs_cdiff(filenames)
  else:
    cvs_udiff(filenames)
   
cvs_diff.available = _cvs_update_available
cvs_diff.label = _('CVS _Diff')
Example #3
0
          f.write(txt)
        finally:
          f.close()
      except:
        errs.append(_("Unable to write %s to update INSTALLED_APPS"))
      else:
        actions.append(_("Added %s to INSTALLED_APPS in %s") % (appname, settings_py))
  
  title = _("The App was Created")
  msg = _("The application was created.  ")
  if errs:
    msg += _get_errors_list(errs)
  msg += _get_actions_list(actions)
  app.ShowMessageDialog(title, msg, modal=False)

django_start_app.contexts = [wingapi.kContextNewMenu(_("Djang_o"), group=2)]
django_start_app.label = _("Start New Django Application")
django_start_app.flags = { 'force_dialog_argentry': True }

def django_sync_db():
  """Run manage.py syncdb (or migrate in Django 1.8+)"""
  app = wingapi.gApplication
  cmdline, dirname, err = _get_base_cmdline()
  if err is not None:
    title = _("Failed to Sync/Migrate DB")
    msg = _("Could not sync/migrate db:  %s") % err
    app.ShowMessageDialog(title, msg)
    return
  
  ver = _get_django_version(' '.join(cmdline), dirname)
  if ver >= (1, 8):
Example #4
0
  
def _svn_update_available(filenames=wingapi.kArgFilename):
  if filenames is None or len(filenames) == 0:
    return False
  for filename in filenames:
    if not wingapi.IsUrl(filename):
      version, date, kind, author, url, exists = __read_entries_file(filename)
      if version is not None or kind == 'dir':
        return True
  return False
svn_update.available = _svn_update_available
svn_update.label = _('SVN _Update')

svn_update.contexts = [wingapi.kContextEditor(), 
                       wingapi.kContextProject(),
                       wingapi.kContextNewMenu(_("S_VN"), 1)]

def svn_revert(filenames=wingapi.kArgFilename):
  """Perform svn revert on the given files or directories"""
  def doit():
    __apply_svn_op(filenames, 'revert', cb=__message_completion)
  title = _("Discard Changes in Files?")
  msg = _("Are you sure you want to discard your changes to all the "
          "selected files and revert to the current state on this "
          "branch in Subversion?")
  buttons = [
    dialogs.CButtonSpec(_("OK"), doit),
    dialogs.CButtonSpec(_("Cancel"), None),
  ]
  dlg = messages.CMessageDialog(wingapi.gApplication.fSingletons, title, msg,
                                (), buttons)
Example #5
0
import os
import wingapi

def open_osx_terminal_in_project_dir():
    """
    open an osx Terminal.app console in the project directory by
    running an osascript.
    """
    term_cmd_str="cd "+_get_current_project_dir()
    _run_command_with_args_in_project_dir("osascript",
                    '-e tell application "Terminal"',
                    "-e activate",
                    '-e do script with command "'+term_cmd_str+'"',
                    "-e end tell")

open_osx_terminal_in_project_dir.contexts=[wingapi.kContextNewMenu('Sc_ripts')]

def open_osx_finder_in_project_dir():
    """
    open an osx finder window in the project directory.
    """
    _run_command_with_args_in_project_dir('open',_get_current_project_dir())

open_osx_finder_in_project_dir.contexts=[wingapi.kContextNewMenu('Sc_ripts')]
    
def _run_command_with_args_in_project_dir(command_str,*args):
    """
    runs a command (with args) in the project directory.
    """
    project_dir=_get_current_project_dir()
    _run_command_with_args_in_dir(command_str,project_dir,*args)
Example #6
0
version, build, code, name, date = wingapi.gApplication.GetProductInfo()
if code < 0x00000002:
  print _("Module doesn't work in Wing IDE Personal")
  raise NotImplementedError

# These top-level attributes are used as defaults if they are omitted
# in the command definitions below.  The values in this example are
# the same as the internal defaults that are used if these top-level
# attributes are also omitted.
_arginfo = {}
_arginfo['filename'] = _AI(_("File"),
                           datatype.CType(''), 
                           formbuilder.CFileSelectorGui(name_type=dialogs.kOpenFilename),
                           label=_("Update"))
_available = lambda: 1
_contexts = lambda: [wingapi.kContextNewMenu(_("Scripts")),]


#########################################################################  
# Commands
#########################################################################  

#-----------------------------------------------------------------------

# This is the command itself. Special args are indicated by using the
# constants from wingapi (such as kFilename here). For all other args, if
# no default arg values are given, Wing will automatically try to collect
# the arg values from the user. If any one arg is missing a value, all
# args will be included in the form presented to the user, with the
# omission only of args with valid special values.
# Note: Commands don't support * or ** args or nested lists in args.