Python sublime.ok_cancel_dialog() Examples

The following are 30 code examples of sublime.ok_cancel_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: commands.py    From sublime-text-virtualenv with MIT License 6 votes vote down vote up
def remove_virtualenv(self, index):
        """Request confirmation and delete the directory tree.

        Also set current virtualenv to None.
        """
        if index == -1:
            return

        venv = self.available_venvs[index][1]
        confirmed = sublime.ok_cancel_dialog(
            "Please confirm deletion of virtualenv at:\n\"{}\".".format(venv))
        if confirmed:
            try:
                shutil.rmtree(venv)
                logger.info("\"{}\" deleted.".format(venv))
            except (IOError, OSError):
                logger.error("Could not delete \"{}\".".format(venv))
            else:
                if venv == self.get_virtualenv():
                    self.set_virtualenv(None) 
Example #2
Source File: dired.py    From dired with MIT License 6 votes vote down vote up
def run(self, edit):
        files = self.get_marked() or self.get_selected()
        if files:
            # Yes, I know this is English.  Not sure how Sublime is translating.
            if len(files) == 1:
                msg = "Delete {}?".format(files[0])
            else:
                msg = "Delete {} items?".format(len(files))
            if sublime.ok_cancel_dialog(msg):
                for filename in files:
                    fqn = join(self.path, filename)
                    if isdir(fqn):
                        shutil.rmtree(fqn)
                    else:
                        os.remove(fqn)
                self.view.run_command('dired_refresh') 
Example #3
Source File: project_manager.py    From ProjectManager with MIT License 6 votes vote down vote up
def _remove_project(self, project):
        answer = sublime.ok_cancel_dialog('Remove "%s" from Project Manager?' % project)
        if answer is True:
            pfile = self.project_file_name(project)
            if self.which_project_dir(pfile):
                self.close_project_by_name(project)
                os.remove(self.project_file_name(project))
                os.remove(self.project_workspace(project))
            else:
                for pdir in self.projects_path:
                    j = JsonFile(os.path.join(pdir, 'library.json'))
                    data = j.load([])
                    if pfile in data:
                        data.remove(pfile)
                        j.save(data)
            sublime.status_message('Project "%s" is removed.' % project) 
Example #4
Source File: actions.py    From GitSavvy with MIT License 6 votes vote down vote up
def destructive(description):
    def decorator(fn):

        def wrapped_fn(*args, **kwargs):
            if GitSavvySettings().get("prompt_before_destructive_action"):
                message = (
                    "You are about to {desc}.  "
                    "This is a destructive action.  \n\n"
                    "Are you SURE you want to do this?  \n\n"
                    "(you can disable this prompt in "
                    "GitSavvy settings)").format(desc=description)
                if not sublime.ok_cancel_dialog(message):
                    return

            return fn(*args, **kwargs)

        return wrapped_fn

    return decorator 
Example #5
Source File: push.py    From GitSavvy with MIT License 6 votes vote down vote up
def do_push(self, remote, branch, force=False, force_with_lease=False, remote_branch=None):
        """
        Perform `git push remote branch`.
        """
        if self.savvy_settings.get("confirm_force_push", True):
            if force:
                if not sublime.ok_cancel_dialog(CONFIRM_FORCE_PUSH.format("--force")):
                    return
            elif force_with_lease:
                if not sublime.ok_cancel_dialog(CONFIRM_FORCE_PUSH.format("--force--with-lease")):
                    return

        self.window.status_message(START_PUSH_MESSAGE)
        self.push(
            remote,
            branch,
            set_upstream=self.set_upstream,
            force=force,
            force_with_lease=force_with_lease,
            remote_branch=remote_branch
        )
        self.window.status_message(END_PUSH_MESSAGE)
        util.view.refresh_gitsavvy(self.window.active_view()) 
Example #6
Source File: main_metadata.py    From SalesforceXyTools with Apache License 2.0 6 votes vote down vote up
def _backup_src(self, root_path):
        if self.retrieve_type == "src":
            src_path = self.sf_basic_config.get_src_dir()
            if os.path.exists(src_path):
                backup_dir = os.path.join(root_path, "src_backup")
                new_src_name = "src_" + datetime.now().strftime('%Y%m%d_%H%M%S')
                new_src_path = os.path.join(backup_dir, new_src_name)
                message = "The src folder is exist. Start to backup the src to %s ?" % (new_src_name)
                if sublime.ok_cancel_dialog(message, "OK!"): 
                    self.sublconsole.close_views(src_path)
                    if not os.path.exists(backup_dir):
                        os.makedirs(backup_dir)
                    self.sublconsole.showlog('start to backup source')
                    shutil.copytree(src_path, new_src_path)
                    self.sublconsole.showlog('start to delete src folder')
                    if os.path.exists(src_path):
                        shutil.rmtree(src_path) 
Example #7
Source File: main_toolbox.py    From SalesforceXyTools with Apache License 2.0 6 votes vote down vote up
def deploy_open_files(self, file_list, type):
        message = "Are you sure to deploy files?"
        self.sublconsole.showlog("Ready to deploy : \n" + "\n".join(file_list))
        if not sublime.ok_cancel_dialog(message, "Yes!"):
            self.sublconsole.showlog("Cancel deploy !")
            return
        self.copy_open_files(file_list)
        
        try:
            if self._is_not_exist():
                self.build_migration_tools(self.save_dir)
            cmd = [self.osutil.get_cd_cmd(self.save_dir), self._get_deploy_cmd(type)]
            self.osutil.os_run(cmd)
        except Exception as ex:
            self.sublconsole.showlog("Please set ant! https://ant.apache.org/")
            pass 
Example #8
Source File: jumping.py    From SublimeFileBrowser with MIT License 6 votes vote down vote up
def on_pick_point(self, index):
        if index == -1:
            return
        name, target = self.jump_points[index]
        if isdir(target):
            settings = load_settings('dired.sublime-settings')
            smart_jump = settings.get('dired_smart_jump', False)
            auto = self.new_window == 'auto'
            if self.new_window is True or ((not smart_jump) and auto) or (smart_jump and auto and len(self.view.window().views()) > 0):
                self.view.run_command("dired_open_in_new_window", {"project_folder": [target]})
            else:
                show(self.view.window(), target, view_id=self.view.id())
                status_message(u"Jumping to point '{0}' complete".format(unicodify(name)))
        else:
            # workaround ST3 bug https://github.com/SublimeText/Issues/issues/39
            self.view.window().run_command('hide_overlay')
            msg = u"Can't jump to '{0} → {1}'.\n\nRemove that jump point?".format(name, target)
            if ok_cancel_dialog(msg):
                points = load_jump_points()
                del points[name]
                save_jump_points(points)
                status_message(u"Jump point '{0}' was removed".format(name))
                self.view.run_command('dired_refresh') 
Example #9
Source File: dired_file_operations.py    From SublimeFileBrowser with MIT License 6 votes vote down vote up
def run(self, edit, trash=False):
        self.index = self.get_all()
        files = self.get_marked() or self.get_selected(parent=False)
        if not files:
            return sublime.status_message('Nothing chosen')

        msg, trash = self.setup_msg(files, trash)

        emit_event(u'ignore_view', self.view.id(), plugin=u'FileBrowserWFS')
        if trash:
            need_confirm = self.view.settings().get('dired_confirm_send2trash', True)
            msg = msg.replace('Delete', 'Delete to trash', 1)
            if not need_confirm or (need_confirm and sublime.ok_cancel_dialog(msg)):
                self._to_trash(files)
        elif not trash and sublime.ok_cancel_dialog(msg):
            self._delete(files)
        else:
            print("Cancel delete or something wrong in DiredDeleteCommand")
        emit_event(u'watch_view', self.view.id(), plugin=u'FileBrowserWFS') 
Example #10
Source File: send_code.py    From SendCode with MIT License 6 votes vote down vote up
def run(self, edit, code=None, cmd=None, prog=None, resolve=True, confirmation=None):
        # set CodeSender before get_code() because get_code may change cursor locations.

        if confirmation:
            ok = sublime.ok_cancel_dialog(confirmation)
            if not ok:
                return

        if not code and cmd:
            print("SendCode: argument `cmd` is deprecated, use `code` instead.")
            code = cmd

        getter = CodeGetter.initialize(self.view)
        sender = CodeSender.initialize(self.view, prog=prog, from_view=code is None)
        if code and resolve:
            code = getter.resolve(code)
        else:
            code = getter.get_code()

        sublime.set_timeout_async(lambda: sender.send_text(code)) 
Example #11
Source File: indices_delete_alias.py    From sublime-elasticsearch-client with MIT License 5 votes vote down vote up
def run_request(self, index=None, name=None):
        if not index or not name:
            self.show_alias_list_panel(self.run)
            return

        options = dict(
            index=index,
            name=name
        )

        if sublime.ok_cancel_dialog("Are you sure you want to delete?", ok_title='Delete'):
            return self.client.indices.delete_alias(**options) 
Example #12
Source File: delete_document.py    From sublime-elasticsearch-client with MIT License 5 votes vote down vote up
def run_request(self, id=None):
        if not id:
            self.show_input_panel('Document Id: ', '', self.run)
            return

        options = dict(
            index=self.settings.index,
            doc_type=self.settings.doc_type,
            id=id
        )

        if sublime.ok_cancel_dialog("Are you sure you want to delete?", ok_title='Delete'):
            return self.client.delete(**options) 
Example #13
Source File: project_manager.py    From ProjectManager with MIT License 5 votes vote down vote up
def clear_recent_projects(self):
        def clear_callback():
            answer = sublime.ok_cancel_dialog('Clear Recent Projects?')
            if answer is True:
                j = JsonFile(os.path.join(self.primary_dir, 'recent.json'))
                j.remove()
                self.window.run_command("clear_recent_projects_and_workspaces")

        sublime.set_timeout(clear_callback, 100) 
Example #14
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 #15
Source File: install_xdotool.py    From SendCode with MIT License 5 votes vote down vote up
def run(self, path=None):
        if not sublime.ok_cancel_dialog(
                "xdotool was not installed. " +
                "Do you want to download xdotool binary now?"):
            return
        self.progress_bar = ProgressBar("installing xdotool")
        self.progress_bar.start()
        if not path:
            path = os.path.join(sublime.packages_path(), "User", "SendCode", "xdotool")
        sublime.set_timeout_async(lambda: self.install_xdotool(path)) 
Example #16
Source File: lightningsave.py    From sublime-lightning with MIT License 5 votes vote down vote up
def get_md_dir(self, dir):
        working_dir = self.get_md_child_name(dir)
        if working_dir == "":
            working_dir = Helper.find_upstram_md(self, dir)
        if working_dir == "not found":
            if sublime.ok_cancel_dialog(
                    "Could not locate a src or metadata directory. "
                    "Create a metadata directory at " + dir + "?",
                    "Create Metadata"):
                working_dir = os.path.join(dir, "metadata")
                os.mkdir(working_dir)

        return working_dir 
Example #17
Source File: pull_request.py    From GitSavvy with MIT License 5 votes vote down vote up
def create_branch_for_pr(self, branch_name, checkout=False, ask_set_upstream=True):
        if not branch_name:
            return

        url = self.best_remote_url_for_pr()
        ref = self.pr["head"]["ref"]

        owner = self.pr["head"]["repo"]["owner"]["login"]
        if owner == self.base_remote.owner:
            owner = self.base_remote_name
            ask_set_upstream = False

        remote_ref = "{}/{}".format(owner, ref)
        set_upstream = sublime.ok_cancel_dialog(
            "Set upstream to '{}'?".format(remote_ref)) if ask_set_upstream else True

        self.window.status_message("Creating local branch for PR...")
        if set_upstream:
            if owner not in self.remotes.keys():
                self.git("remote", "add", owner, url)
            self.git("fetch", owner, ref)
            self.git("branch", branch_name, "FETCH_HEAD")
            self.git("branch", "-u", remote_ref, branch_name)
        else:
            self.git("fetch", url, ref)
            self.git("branch", branch_name, "FETCH_HEAD")

        if checkout:
            self.checkout_ref(branch_name)

        util.view.refresh_gitsavvy_interfaces(self.window, refresh_sidebar=True) 
Example #18
Source File: pull_request.py    From GitSavvy with MIT License 5 votes vote down vote up
def run_async(self):
        if not self.get_upstream_for_active_branch():
            if sublime.ok_cancel_dialog(PUSH_PROMPT):
                self.window.run_command(
                    "gs_github_push_and_create_pull_request",
                    {"set_upstream": True})

        else:
            remote_branch = self.get_active_remote_branch()
            if not remote_branch:
                sublime.message_dialog("Unable to determine remote.")
            else:
                status, secondary = self.get_branch_status()
                if secondary:
                    secondary = "\n".join(secondary)
                    if "ahead" in secondary or "behind" in secondary:
                        sublime.message_dialog(
                            "Your current branch is different from its remote counterpart.\n" +
                            secondary)
                        return

                owner = github.parse_remote(self.get_remotes()[remote_branch.remote]).owner
                self.open_comparision_in_browser(
                    owner,
                    remote_branch.name
                ) 
Example #19
Source File: push.py    From GitSavvy with MIT License 5 votes vote down vote up
def run_async(self):
        if not self.local_branch_name:
            self.local_branch_name = self.get_current_branch_name()

        upstream = self.get_local_branch(self.local_branch_name).tracking

        if upstream:
            remote, remote_branch = upstream.split("/", 1)
            self.do_push(
                remote,
                self.local_branch_name,
                remote_branch=remote_branch,
                force=self.force,
                force_with_lease=self.force_with_lease)
        elif self.savvy_settings.get("prompt_for_tracking_branch"):
            if sublime.ok_cancel_dialog(SET_UPSTREAM_PROMPT):
                self.window.run_command("gs_push_to_branch_name", {
                    "local_branch_name": self.local_branch_name,
                    "set_upstream": True,
                    "force": self.force,
                    "force_with_lease": self.force_with_lease
                })
        else:
            # if `prompt_for_tracking_branch` is false, ask for a remote and perform
            # push current branch to a remote branch with the same name
            self.window.run_command("gs_push_to_branch_name", {
                "local_branch_name": self.local_branch_name,
                "branch_name": self.local_branch_name,
                "set_upstream": False,
                "force": self.force,
                "force_with_lease": self.force_with_lease
            }) 
Example #20
Source File: remote.py    From GitSavvy with MIT License 5 votes vote down vote up
def on_enter_name(self, remote_name):
        self.git("remote", "add", remote_name, self.url)
        if sublime.ok_cancel_dialog("Your remote was added successfully.  Would you like to fetch from this remote?"):
            self.window.run_command("gs_fetch", {"remote": remote_name}) 
Example #21
Source File: commit.py    From GitSavvy with MIT License 5 votes vote down vote up
def run(self, edit):
        if self.view.settings().get("git_savvy.commit_on_close"):
            message_txt = extract_commit_message(self.view).strip()
            if message_txt:
                self.view.run_command("gs_commit_view_do_commit", {"message": message_txt})
            else:
                self.view.close()

        elif self.view.settings().get("git_savvy.prompt_on_abort_commit"):
            message_txt = extract_commit_message(self.view).strip()
            if not message_txt or sublime.ok_cancel_dialog(CONFIRM_ABORT):
                self.view.close()

        else:
            self.view.close() 
Example #22
Source File: init.py    From GitSavvy with MIT License 5 votes vote down vote up
def run(self):
        if self.savvy_settings.get("disable_git_init_prompt"):
            return

        active_view_id = self.window.active_view().id()
        if active_view_id not in views_with_offer_made and sublime.ok_cancel_dialog(NO_REPO_MESSAGE):
            self.window.run_command("gs_init")
        else:
            views_with_offer_made.add(active_view_id) 
Example #23
Source File: init.py    From GitSavvy with MIT License 5 votes vote down vote up
def on_enter_directory(self, path):
        self.suggested_git_root = os.path.expanduser(path)  # handle ~/%HOME%
        if self.suggested_git_root and os.path.exists(os.path.join(self.suggested_git_root, ".git")):
            sublime.ok_cancel_dialog(RECLONE_CANT_BE_DONE)
            return

        sublime.set_timeout_async(self.do_clone, 0) 
Example #24
Source File: init.py    From GitSavvy with MIT License 5 votes vote down vote up
def run_async(self):
        if sublime.ok_cancel_dialog(NO_CONFIG_MESSAGE, "OK"):
            self.get_name() 
Example #25
Source File: anaconda_go.py    From anaconda_go with GNU General Public License v3.0 5 votes vote down vote up
def plugin_loaded():
    if anaconda_required_version > anaconda_version:
        if sublime.ok_cancel_dialog(
            'AnacondaGO requires version {} or better of anaconda but '
            '{}'.format(
                '.'.join(str(i) for i in anaconda_required_version),
                '{} is installed'.format(
                    anaconda_version) if anaconda_version > (0, 0, 0) else 'is not installed'  # noqa
                ), 'Install Now'
        ):
            def on_installed():
                go.init()
                # sublime.message_dialog('Please, restart your Sublime Text')

            pkg = 'Package Control.package_control.package_installer'
            module = __import__(
                pkg, globals(), locals(), ['Package_installer'])
            t = module.PackageInstallerThread(
                module.PackageManager(), 'Anaconda', on_installed
            )
            t.start()
            module.ThreadProgress(
                t,
                'Installing dependency Anaconda',
                'Package Anaconda successfully installed',
            )
    else:
        go.init() 
Example #26
Source File: show_plugin_version.py    From JavaScriptEnhancements with MIT License 5 votes vote down vote up
def run(self):
    if sublime.ok_cancel_dialog("JavaScript Enhancements plugin version: "+PLUGIN_VERSION, "Copy"):
      sublime.set_clipboard(PLUGIN_VERSION) 
Example #27
Source File: nodes_shutdown.py    From sublime-elasticsearch-client with MIT License 5 votes vote down vote up
def run_request(self, node_id):
        self.update_command_name(node_id)

        if sublime.ok_cancel_dialog("Are you sure you want to shutdown?", ok_title='Shutdown'):
            options = dict()
            return self.client.nodes.shutdown(**options) 
Example #28
Source File: dired_misc.py    From SublimeFileBrowser with MIT License 5 votes vote down vote up
def run(self, edit):
        if not ST3:
            return sublime.status_message('This feature is available only in Sublime Text 3')
        path = self.path.rstrip(os.sep)
        msg = u"Set '{0}' as only one project folder (will remove all other folders from project)?".format(path)
        if sublime.ok_cancel_dialog(msg):
            data = self.view.window().project_data() or {'folders': {}}
            data['folders'] = [{'path': path}]
            self.view.window().set_project_data(data)
            self.view.window().run_command('dired_refresh') 
Example #29
Source File: dired_file_operations.py    From SublimeFileBrowser with MIT License 5 votes vote down vote up
def check_errors(self):
        msg = u'FileBrowser:\n\nSome files exist already, Cancel to skip all, OK to overwrite or rename.\n\n\t%s' % '\n\t'.join(self.errors.keys())
        self.actions = [['Overwrite', 'Folder cannot be overwritten'],
                        ['Duplicate', 'Item will be renamed automatically']]
        if self.errors and sublime.ok_cancel_dialog(msg):
            self.show_quick_panel() 
Example #30
Source File: main_metadata.py    From SalesforceXyTools with Apache License 2.0 5 votes vote down vote up
def delete_meta(self, sel_meta):
        self.sublconsole.debug('>>>delete meta')
        self.sublconsole.debug(sel_meta)
        message = "Are you sure to delete %s?  id=%s " % (sel_meta["fileName"], sel_meta["id"])
        if not sublime.ok_cancel_dialog(message, "Delete!!"): 
            self.sublconsole.showlog('cancel delete metadata: ' + sel_meta["fileName"])
            return
        self.sublconsole.showlog('start to delete metadata : ' + sel_meta["fileName"])
        if sel_meta["id"]:
            self.sel_meta = sel_meta
            self.sublconsole.thread_run(target=self.delete_meta_process)
        else:
            self.sublconsole.showlog('the id is empty : ' + sel_meta["fileName"])
        return