Python sublime.message_dialog() Examples

The following are 30 code examples of sublime.message_dialog(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module sublime , or try the search function .
Example #1
Source File: bootstrapper.py    From SublimeScraps with MIT License 6 votes vote down vote up
def log(msg, *args, dialog=False, error=False, **kwargs):
    """
    Generate a message to the console and optionally as either a message or
    error dialog. The message will be formatted and dedented before being
    displayed, and will be prefixed with its origin.
    """
    msg = textwrap.dedent(msg.format(*args, **kwargs)).strip()

    if error:
        print("my_package error:")
        return sublime.error_message(msg)

    for line in msg.splitlines():
        print("my_package: {msg}".format(msg=line))

    if dialog:
        sublime.message_dialog(msg)


### --------------------------------------------------------------------------- 
Example #2
Source File: docphp.py    From docphp with MIT License 6 votes vote down vote up
def run(self, edit, languageName=None, set_fallback=False, is_init=False):
        view = self.view
        global currentView
        currentView = view

        if self.downloading:
            sublime.message_dialog('Another progress is working for checkout ' + self.downloading + '. Please try again later.')
            return

        self.languageList, index = getLanguageList(languageName)
        self.set_fallback = set_fallback

        if languageName:
            self.updateLanguage(index)
        else:
            currentView.window().show_quick_panel(self.languageList, self.updateLanguage, sublime.KEEP_OPEN_ON_FOCUS_LOST) 
Example #3
Source File: decorators.py    From SyncSettings with MIT License 6 votes vote down vote up
def check_settings(*props):
    def check_settings_wrapper(func):
        @wraps(func)
        def check_settings_inner(self, *args, **kwargs):
            for prop in props:
                if not settings.get(prop):
                    prop_text = 'properties' if len(args) > 1 else 'property'
                    msg = (
                        'Sync Settings:\n\n'
                        'The {} {}, must be defined. Edit your settings file.'
                    )
                    sublime.message_dialog(msg.format(prop_text, ' and '.join(props)))
                    sublime.active_window().run_command('open_file', {
                        'file': '${packages}/User/SyncSettings.sublime-settings'
                    })
                    return
            func(self, *args, **kwargs)
        return check_settings_inner
    return check_settings_wrapper 
Example #4
Source File: delete_and_create.py    From SyncSettings with MIT License 6 votes vote down vote up
def delete_and_create(self, should_create=False):
        gid = settings.get('gist_id')
        try:
            gist.Gist(
                token=settings.get('access_token'),
                http_proxy=settings.get('http_proxy'),
                https_proxy=settings.get('https_proxy')
            ).delete(gid)
            settings.update('gist_id', '')
            # delete information related to the deleted gist
            version.update_config_file({})
            if should_create:
                self.window.run_command('sync_settings_create_and_upload')
                pass
        except gist.NotFoundError as e:
            msg = (
                'Sync Settings:\n\n'
                '{}\n\n'
                'Please check if the access token was created with the gist scope.\n\n'
                'If the access token is correct, please, delete the value of `gist_id` property manually.'
            )
            sublime.message_dialog(msg.format(str(e)))
        except Exception as e:
            logger.exception(e)
            sublime.message_dialog('Sync Settings:\n\n{}'.format(str(e))) 
Example #5
Source File: lightningsave.py    From sublime-lightning with MIT License 6 votes vote down vote up
def show_list(self, data):
            m = json.loads(data)
            if len(m) == 0:
                sublime.message_dialog(
                    "There aren't any lightning components "
                    " in this org.")
                return

            print("data: " + str(m))
            self.messages.append(["All Bundles", "*", "Every Bundle",
                                  "All the lightning bundles "
                                  "in your org!"])
            print("And now here")
            for mm in m:
                x = [mm['MasterLabel'], mm['Id'], mm["DeveloperName"],
                     mm["Description"]]
                self.messages.append(x)

            self.window = sublime.active_window()
            self.window.show_quick_panel(self.messages,
                                         self.open_selected_bundle,
                                         sublime.MONOSPACE_FONT) 
Example #6
Source File: json_file.py    From ProjectManager with MIT License 6 votes vote down vote up
def load(self, default=[]):
        self.fdir = os.path.dirname(self.fpath)
        if not os.path.isdir(self.fdir):
            os.makedirs(self.fdir)
        if os.path.exists(self.fpath):
            with open(self.fpath, mode='r', encoding=self.encoding) as f:
                content = f.read()
                try:
                    data = sublime.decode_value(content)
                except Exception:
                    sublime.message_dialog('%s is bad!' % self.fpath)
                    raise
                if not data:
                    data = default
        else:
            with open(self.fpath, mode='w', encoding=self.encoding, newline='\n') as f:
                data = default
                f.write(sublime.encode_value(data, True))
        return data 
Example #7
Source File: project_manager.py    From ProjectManager with MIT License 6 votes vote down vote up
def run(self, action=None, caller=None):
        self.manager = Manager(self.window)

        if action is None:
            self.show_options()
        elif action == 'add_project':
            self.manager.add_project()
        elif action == 'import_sublime_project':
            self.manager.import_sublime_project()
        elif action == 'clear_recent_projects':
            self.manager.clear_recent_projects()
        elif action == 'remove_dead_projects':
            self.manager.clean_dead_projects()
        else:
            self.caller = caller
            callback = eval('self.on_' + action)
            self.projects, display = self.manager.display_projects()
            if not self.projects:
                sublime.message_dialog('Project list is empty.')
                return
            self.show_quick_panel(display, callback) 
Example #8
Source File: project_manager.py    From ProjectManager with MIT License 6 votes vote down vote up
def clean_dead_projects(self):
        projects_to_remove = []
        for pname, pi in self.projects_info.items():
            folder = pi['folder']
            if not os.path.exists(folder):
                projects_to_remove.append(pname)

        def remove_projects_iteratively():
            pname = projects_to_remove[0]
            self._remove_project(pname)
            projects_to_remove.remove(pname)
            if len(projects_to_remove) > 0:
                sublime.set_timeout(remove_projects_iteratively, 100)

        if len(projects_to_remove) > 0:
            sublime.set_timeout(remove_projects_iteratively, 100)
        else:
            sublime.message_dialog('No Dead Projects.') 
Example #9
Source File: installer.py    From JavaScript-Completions with MIT License 6 votes vote down vote up
def rmtree(self, path) :
    if node_variables.NODE_JS_OS == "win" :
      import string
      from ctypes import windll, c_int, c_wchar_p
      UNUSUED_DRIVE_LETTER = ""
      for letter in string.ascii_uppercase:
        if not os.path.exists(letter+":") :
          UNUSUED_DRIVE_LETTER = letter+":"
          break
      if not UNUSUED_DRIVE_LETTER :
        sublime.message_dialog("Can't remove node.js! UNUSUED_DRIVE_LETTER not found.")
        return
      DefineDosDevice = windll.kernel32.DefineDosDeviceW
      DefineDosDevice.argtypes = [ c_int, c_wchar_p, c_wchar_p ]
      DefineDosDevice(0, UNUSUED_DRIVE_LETTER, path)
      try:
        shutil.rmtree(UNUSUED_DRIVE_LETTER)
      except Exception as e:
        print("Error: "+traceback.format_exc())
      finally:
        DefineDosDevice(2, UNUSUED_DRIVE_LETTER, path)  
    else :
      shutil.rmtree(path) 
Example #10
Source File: fixup.py    From GitSavvy with MIT License 6 votes vote down vote up
def run(self):
        (staged_entries,
         unstaged_entries,
         untracked_entries,
         conflict_entries) = self.sort_status_entries(self.get_status())

        if len(unstaged_entries) + len(conflict_entries) > 0:
            sublime.message_dialog(
                "Unable to perform rebase actions while repo is in unclean state."
            )
            return
        if len(staged_entries) == 0:
            sublime.message_dialog(
                "No staged files."
            )
            return
        super().run() 
Example #11
Source File: SQLTools.py    From SublimeText-SQLTools with GNU General Public License v3.0 6 votes vote down vote up
def run():
        if not ST.conn:
            ST.selectConnectionQuickPanel(callback=lambda: Window().run_command('st_remove_saved_query'))
            return

        queriesList = queriesStore.all()
        if len(queriesList) == 0:
            sublime.message_dialog('No saved queries.')
            return

        options = []
        for alias, query in queriesList.items():
            options.append([str(alias), str(query)])
        options.sort()

        def cb(index):
            if index < 0:
                return None

            return queriesStore.delete(options[index][0])
        try:
            Window().show_quick_panel(options, cb)
        except Exception:
            pass 
Example #12
Source File: rebase.py    From GitSavvy with MIT License 6 votes vote down vote up
def run_async(self):
        short_hash = self.get_selected_short_hash()
        if not short_hash:
            return

        # Cannot squash first commit.
        if self.interface.entries[0].short_hash == short_hash:
            sublime.message_dialog("Unable to squash first commit.")
            return

        squash_idx, squash_entry, _ = self.get_idx_entry_and_prev(short_hash)

        if self.commit_is_merge(squash_entry.long_hash):
            sublime.message_dialog("Unable to squash a merge.")
            return

        self.squash_idx = squash_idx
        self.squash_entry = squash_entry

        if self.step:
            self.do_action(self.interface.entries[squash_idx - 1].long_hash)
        else:
            reversed_logs = list(reversed(self.interface.entries[0:squash_idx]))
            show_log_panel(reversed_logs, self.do_action) 
Example #13
Source File: docphp.py    From docphp with MIT License 6 votes vote down vote up
def checkoutLanguage(self):
        global language
        languageName = self.languageName
        if not self.downloadLanguageGZ(languageName):
            if getSetting('debug'):
                print('download error')
            return False

        setSetting('language', languageName)
        language = languageName
        languageSettings = currentSettings.get('languages')

        languageSettings[languageName] = 'gz'

        setSetting('languages', languageSettings)
        if self.set_fallback:
            setSetting('language_fallback', languageName)

        loadLanguage()

        sublime.message_dialog('Language ' + languageName + ' is checked out') 
Example #14
Source File: rebase.py    From GitSavvy with MIT License 6 votes vote down vote up
def run_async(self):
        short_hash = self.get_selected_short_hash()
        if not short_hash:
            return

        if self.interface.entries[-1].short_hash == short_hash:
            sublime.message_dialog("Unable to move last commit down.")
            return

        move_idx, move_entry, _ = self.get_idx_entry_and_prev(short_hash)
        self.move_idx = move_idx
        self.move_entry = move_entry

        if self.step:
            self.do_action(self.interface.entries[move_idx + 1].long_hash)
        else:
            logs = self.interface.entries[move_idx + 1:]
            show_log_panel(logs, self.do_action) 
Example #15
Source File: rebase.py    From GitSavvy with MIT License 6 votes vote down vote up
def run_async(self):
        short_hash = self.get_selected_short_hash()
        if not short_hash:
            return

        if self.interface.entries[0].short_hash == short_hash:
            sublime.message_dialog("Unable to move first commit up.")
            return

        move_idx, move_entry, _ = self.get_idx_entry_and_prev(short_hash)
        self.move_idx = move_idx
        self.move_entry = move_entry

        if self.step:
            self.do_action(self.interface.entries[move_idx - 1].long_hash)
        else:
            logs = list(reversed(self.interface.entries[:move_idx]))
            show_log_panel(logs, self.do_action) 
Example #16
Source File: graphvizer.py    From Graphvizer with GNU General Public License v2.0 6 votes vote down vote up
def on_pre_save(self, view):
		file_syntax = view.settings().get('syntax')
		if file_syntax != "Packages/Graphviz/DOT.sublime-syntax":
			return
		# The file is saved for the first time
		if view.settings().get("persistence") is None:
			sublime.message_dialog("This is the first time the file is saved, "\
								"so the image filename has been changed according to the filename. "\
								"Please close temp~.png and reopen image again using keyboard shortcuts or menus.")
			view.settings().set("persistence", True)
			self.rendering(view)

		# If `render_in_realtime` is enabled, we don't need to render on save as this
		# has been done in on_modified().
		if not st_settings.get("render_in_realtime"):
			self.rendering(view)

	# Trigger rendering if setting the file syntax to DOT 
Example #17
Source File: rebase.py    From GitSavvy with MIT License 6 votes vote down vote up
def run_async(self):
        for entry in self.interface.entries:
            if self.commit_is_merge(entry.long_hash):
                sublime.message_dialog("Unable to squash a merge.")
                return

        # Generate identical change templates with author/date metadata
        # in tact.  However, set do_commit to false for all but the last change,
        # in order for diffs to be rolled into that final commit.
        last_commit_idx = len(self.interface.entries) - 1
        commit_chain = self.perpare_rewrites(self.interface.entries)

        # Take the commit message from the commit-to-squash and append
        # it to the next commit's message.
        for idx, commit in enumerate(commit_chain):
            commit.modified = True
            if idx < last_commit_idx:
                commit.do_commit = False
                commit_chain[idx + 1].msg = commit.msg + "\n\n" + commit_chain[idx + 1].msg
                commit.msg = None
            else:
                commit.squashed = True

        self.make_changes(commit_chain, "squashed all commits") 
Example #18
Source File: SQLTools.py    From SublimeText-SQLTools with GNU General Public License v3.0 6 votes vote down vote up
def plugin_loaded():

    try:
        from package_control import events

        if events.install(__name__):
            logger.info('Installed %s!' % events.install(__name__))
        elif events.post_upgrade(__name__):
            logger.info('Upgraded to %s!' % events.post_upgrade(__name__))
            sublime.message_dialog(('{0} was upgraded.' +
                                    'If you have any problem,' +
                                    'just restart your Sublime Text.'
                                    ).format(__name__)
                                   )

    except Exception:
        pass

    startPlugin()
    reload() 
Example #19
Source File: lsp.py    From sublime-ide-r with MIT License 5 votes vote down vote up
def plugin_loaded():
        sublime.message_dialog(UNLOAD_MESSAGE) 
Example #20
Source File: project_manager.py    From ProjectManager with MIT License 5 votes vote down vote up
def import_sublime_project(self):
        pfile = pretty_path(self.window.project_file_name())
        if not pfile:
            sublime.message_dialog('Project file not found!')
            return
        if self.which_project_dir(pfile):
            sublime.message_dialog('This project was created by Project Manager!')
            return
        answer = sublime.ok_cancel_dialog('Import %s?' % os.path.basename(pfile))
        if answer is True:
            j = JsonFile(os.path.join(self.primary_dir, 'library.json'))
            data = j.load([])
            if pfile not in data:
                data.append(pfile)
                j.save(data) 
Example #21
Source File: sublimefunctions.py    From FileManager with MIT License 5 votes vote down vote up
def md(*t, **kwargs):
    sublime.message_dialog(kwargs.get("sep", "\n").join([str(el) for el in t])) 
Example #22
Source File: create_connection.py    From servicenow-sync with MIT License 5 votes vote down vote up
def run(self):
        if not self.window.folders():
            sublime.message_dialog("SNOW Sync Sublime plugin requires an open folder.")
            return
        else:
            self.dir = self.window.folders()[0]
            self.window.show_input_panel("Instance Name:", "", self.create_instance, None, None)

        return 
Example #23
Source File: new_file.py    From omnisharp-sublime with MIT License 5 votes vote down vote up
def get_code(self, type, namespace, filename):
        code = ''
        file_name = "%s.tmpl" % type
        isIOError = False

        tmpl_dir = 'Packages/' + self.PACKAGE_NAME + '/' + self.TMLP_DIR + '/'
        user_tmpl_dir = 'Packages/User/' + \
            self.PACKAGE_NAME + '/' + self.TMLP_DIR + '/'


        self.user_tmpl_path = os.path.join(user_tmpl_dir, file_name)
        self.tmpl_path = os.path.join(tmpl_dir, file_name)

        try:
            code = sublime.load_resource(self.user_tmpl_path)
        except IOError:
            try:
                code = sublime.load_resource(self.tmpl_path)
            except IOError:
                isIOError = True

        if isIOError:
            sublime.message_dialog('[Warning] No such file: ' + self.tmpl_path
                                   + ' or ' + self.user_tmpl_path)

        code = code.replace('${namespace}', namespace)
        code = code.replace('${classname}', filename)

        return code 
Example #24
Source File: tag.py    From GitSavvy with MIT License 5 votes vote down vote up
def smart_tag(self, release_type):
        tag_name = None
        last_tag_name = self.get_last_local_tag()
        if last_tag_name:
            tag_name = smart_incremented_tag(last_tag_name, release_type)

        if not tag_name:
            sublime.message_dialog(TAG_PARSE_FAIL_MESSAGE)
            return

        self.view.run_command("gs_tag_create", {"tag_name": tag_name}) 
Example #25
Source File: highlight_problems.py    From CppYCM with MIT License 5 votes vote down vote up
def on_selection_modified_async(self, view):
        if not is_cpp(view) or view.is_scratch():
            return
        # Not work in st3, output panel wouldn't call this callback
        # from ..commands.highlight_problems import output_panel
        # if output_panel and (view.id() == output_panel.id()):
        #     sublime.message_dialog('match!')
        # update_statusbar(view) 
Example #26
Source File: cppycmcompletion.py    From CppYCM with MIT License 5 votes vote down vote up
def plugin_loaded():
    if not check_ycmd_server():
        sublime.message_dialog('Ycmd is not found, see https://github.com/glymehrvrd/CppYCM#installation for install instructions.') 
Example #27
Source File: rebase.py    From GitSavvy with MIT License 5 votes vote down vote up
def do_action(self, target_commit):
        if not target_commit:
            return

        squash_idx, squash_entry, _ = self.get_idx_entry_and_prev(self.squash_entry.short_hash)
        target_idx, target_entry, before_target = \
            self.get_idx_entry_and_prev(self.get_short_hash(target_commit))

        if self.commit_is_merge(target_entry.long_hash):
            sublime.message_dialog("Unable to squash a merge.")
            return

        # Generate identical change templates with author/date metadata in tact.
        commit_chain = self.perpare_rewrites(self.interface.entries[target_idx:])
        commit_chain.insert(1, commit_chain.pop(squash_idx - target_idx))

        # The first commit (the one immediately previous to the selected commit) will
        # not be commited again.  However, the second commit (the selected) must include
        # the diff from the first, and all the meta-data for the squashed commit must
        # match the first.
        commit_chain[0].do_commit = False
        commit_chain[1].msg = commit_chain[0].msg + "\n\n" + commit_chain[1].msg
        commit_chain[1].datetime = commit_chain[0].datetime
        commit_chain[1].author = commit_chain[0].author

        self.make_changes(
            commit_chain,
            "squashed " + squash_entry.short_hash,
            before_target.long_hash
        ) 
Example #28
Source File: rebase.py    From GitSavvy with MIT License 5 votes vote down vote up
def run(self, edit):
        self.interface = ui.get_interface(self.view.id())

        (staged_entries,
         unstaged_entries,
         untracked_entries,
         conflict_entries) = self.sort_status_entries(self.get_status())

        if len(unstaged_entries) + len(conflict_entries) > 0:
            sublime.message_dialog(
                "Unable to manipulate commits while repo is in unclean state."
            )
            return

        sublime.set_timeout_async(self.run_async, 0) 
Example #29
Source File: fixup.py    From GitSavvy with MIT License 5 votes vote down vote up
def do_action(self, commit, **kwargs):
        commit = self.git("rev-parse", commit).strip()
        self.git("commit", "--fixup", commit)
        try:
            base_commit = self.git("rev-parse", "{}~1".format(commit)).strip()
            entries = self.log_rebase(base_commit, preserve=True)
            commit_chain = self.auto_squash(self.perpare_rewrites(entries))

            self.rewrite_active_branch(base_commit, commit_chain)
        except Exception as e:
            self.git("reset", "--soft", "HEAD^")
            sublime.message_dialog("Error encountered. Cannot autosquash fixup.")
            raise e
        finally:
            util.view.refresh_gitsavvy(self.window.active_view()) 
Example #30
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def run(self, dirs):
        """Sample doc string."""
        if (Helper(self.window).meets_forcecli_version("0.22.62")):
            self.dirs = dirs
            self.window.show_input_panel("Class Name:",
                                         "", self.on_done, None, None)
            pass
        else:
            sublime.message_dialog("This feature requires at least version"
                                   " 62 of the Force")