Python sublime 模块,ok_cancel_dialog() 实例源码

我们从Python开源项目中,提取了以下44个代码示例,用于说明如何使用sublime.ok_cancel_dialog()

项目:imagepaste    作者:robinchenyu    | 项目源码 | 文件源码
def paste(self):
        # ImageFile.LOAD_TRUNCATED_IMAGES = True
        dirname = os.path.dirname(__file__)
        command = ['/usr/bin/python3', os.path.join(dirname, 'bin/imageutil.py'), 'grab']
        abs_fn, rel_fn = self.get_filename()
        tempfile1 = "/tmp/imagepaste1.png"
        command.append(tempfile1)

        out = self.run_command(" ".join(command))
        if out[:4] == "grab":
            ret = sublime.ok_cancel_dialog("save to file?")
            print("ret %r" % ret)
            if ret:
                shutil.move(tempfile1, abs_fn)
                return rel_fn
            else:
                return None
        # im = ImageGrab.grabclipboard()
        # if im:
        #   abs_fn, rel_fn = self.get_filename()
        #   im.save(abs_fn,'PNG')   
        #   return rel_fn
        else:
            print('clipboard buffer is not image!')
            return None
项目:sublime-text-3-packages    作者:nickjj    | 项目源码 | 文件源码
def run(self):
        """Run the command."""
        if not sublime.ok_cancel_dialog(
            'You will be asked for the linter name. Please enter the name '
            'of the linter binary (including dashes), NOT the name of the language being linted. '
            'For example, to lint CSS with csslint, the linter name is '
            '“csslint”, NOT “css”.',
            'I understand'
        ):
            return

        self.window.show_input_panel(
            'Linter name:',
            '',
            on_done=self.copy_linter,
            on_change=None,
            on_cancel=None)
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def run(self):
        """Run the command."""
        if not sublime.ok_cancel_dialog(
            'You will be asked for the linter name. Please enter the name '
            'of the linter binary (including dashes), NOT the name of the language being linted. '
            'For example, to lint CSS with csslint, the linter name is '
            '“csslint”, NOT “css”.',
            'I understand'
        ):
            return

        self.window.show_input_panel(
            'Linter name:',
            '',
            on_done=self.copy_linter,
            on_change=None,
            on_cancel=None)
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_node_js_path_provided(self, path):
        log_debug("Node.js path provided: " + path)
        if os.path.exists(path):
            log_debug("Node.js path is valid")
            settings = self.load_settings()
            if EI_BUILDER_SETTINGS not in settings:
                settings[EI_BUILDER_SETTINGS] = {}
            builder_settings = settings[EI_BUILDER_SETTINGS]
            builder_settings[EI_ST_PR_NODE_PATH] = path
            self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings)
        else:
            if sublime.ok_cancel_dialog(STR_INVALID_NODE_JS_PATH):
                self.prompt_for_node_js_path(False)

        # Loop back to the main settings check
        self.check_settings()
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_builder_cli_path_provided(self, path):
        log_debug("Builder CLI path provided: " + path)
        if os.path.exists(path):
            log_debug("Builder CLI path is valid")
            settings = self.load_settings()
            if EI_BUILDER_SETTINGS not in settings:
                settings[EI_BUILDER_SETTINGS] = {}
            builder_settings = settings[EI_BUILDER_SETTINGS]
            builder_settings[EI_ST_PR_BUILDER_CLI] = path
            self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings)
        else:
            if sublime.ok_cancel_dialog(STR_INVALID_BUILDER_CLI_PATH):
                self.prompt_for_node_js_path(False)

        # Loop back to the main settings check
        self.check_settings()
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_model_name_provided(self, name):
        response, code = HTTP.post(self.env.project_manager.get_build_api_key(),
                                   PL_BUILD_API_URL_V4 + "models/", '{"name" : "' + name + '" }')

        if not HTTP.is_response_code_valid(code) \
                and sublime.ok_cancel_dialog(STR_MODEL_NAME_EXISTS):
            self.create_new_model(False)
            return
        elif not HTTP.is_response_code_valid(code):
            sublime.message_dialog(STR_MODEL_FAILED_TO_CREATE)
            return

        # Save newly created model to the project settings
        settings = self.load_settings()
        settings[EI_MODEL_ID] = response.get("model").get("id")
        settings[EI_MODEL_NAME] = response.get("model").get("name")
        self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings)

        self.update_model_name_in_status(query_model_name=False)

        # Reset the logs
        self.env.log_manager.reset()

        # Check settings
        self.check_settings(selecting_or_creating_model=True)
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def add_device(self, need_to_confirm=True):
        model = self.load_this_model()
        if not model:
            sublime.message_dialog(STR_MODEL_NOT_ASSIGNED)
            return

        if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_ADD_DEVICE): return

        device_ids = model.get("devices")
        (device_ids, device_names) = self.load_devices(exclude_device_ids=device_ids)

        if len(device_ids) == 0:
            sublime.message_dialog(STR_NO_DEVICES_AVAILABLE)
            return

        self.env.tmp_model = model
        self.env.tmp_device_ids = device_ids
        self.window.show_quick_panel(device_names, self.on_device_to_add_selected)
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_build_api_key_provided(self, key):
        log_debug("build api key provided: " + key)
        if HTTP.is_build_api_key_valid(key):
            log_debug("build API key is valid")
            self.env.project_manager.save_settings(PR_AUTH_INFO_FILE, {
                EI_BUILD_API_KEY: key,
                EI_BUILDER_SETTINGS: {
                    EI_GITHUB_USER: None,
                    EI_GITHUB_TOKEN: None
                }
            })
        else:
            if sublime.ok_cancel_dialog(STR_INVALID_API_KEY):
                self.prompt_for_build_api_key(False)

        # Loop back to the main settings check
        self.check_settings()
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def _delete_file(self, filepath):
        if not filepath:
            return
        elif not os.path.isfile(filepath):
            sublime.error_message("%s is not a file" % filepath)
            return

        if not sublime.ok_cancel_dialog("Delete this file?\n%s" % filepath):
            return

        vcs_tracking = (self.file_tracked_by_git(filepath) and
                        self.settings.get(VCS_MANAGEMENT_SETTING))

        self.close_view(filepath)

        if vcs_tracking:
            self._git_rm(filepath)
        else:
            self._execute_delete_file(filepath)

        self.refresh_sidebar()
项目:CMakeBuilder    作者:rwols    | 项目源码 | 文件源码
def _create_project(self):
        os.makedirs(self.project_dir, exist_ok=True)
        if not os.path.exists(self.project_dir):
            sublime.error_message("Could not create directory %s" % self.project_dir)
        os.makedirs(os.path.join(self.project_dir, "src"), exist_ok=True)
        with open(os.path.join(self.project_dir, "CMakeLists.txt"), "w") as f:
            f.write(CMAKELISTS_FILE.format(self.project_name, self.type))
        with open(os.path.join(self.project_dir, "src", "main." + self.suffix), "w") as f:
            if self.type == "C":
                f.write(CFILE)
            else:
                f.write(CXXFILE)
        with open(os.path.join(self.project_dir, "src", "CMakeLists.txt"), "w") as f:
            f.write(CMAKELISTS_SRC_FILE.format(self.suffix))
        project_file = os.path.join(self.project_dir, self.project_name + ".sublime-project")
        with open(project_file, "w") as f:
            f.write(PROJECTFILE)
        if sublime.ok_cancel_dialog('Select the file %s in "%s" in the upcoming prompt...' % (self.project_name + ".sublime-project", self.project_dir)):
            sublime.run_command("prompt_open_project_or_workspace")
项目:sublime-dired    作者:Twizzledrizzle    | 项目源码 | 文件源码
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')
项目:sublime-solium-gutter    作者:sey    | 项目源码 | 文件源码
def run_script_on_file(self, temp_file_path):
    try:
      node_path = PluginUtils.get_node_path()
      script_path = PLUGIN_FOLDER + "/scripts/run.js"
      file_path = self.view.file_name()
      cmd = [node_path, script_path, temp_file_path, file_path or "?"]
      output = SoliumGutterCommand.get_output(cmd)
      print(output)
      if output.find(OUTPUT_VALID) != -1:
        output = output.decode('utf-8');
        return output
      print(output)
      raise Exception(output)
    except:
      # Something bad happened.
      print("Unexpected error({0}): {1}".format(sys.exc_info()[0], sys.exc_info()[1]))

      # Usually, it's just node.js not being found. Try to alleviate the issue.
      msg = "Node.js was not found in the default path. Please specify the location."
      if not sublime.ok_cancel_dialog(msg):
        msg = "You won't be able to use this plugin without specifying the path to node.js."
        sublime.error_message(msg)
      else:
        PluginUtils.open_sublime_settings(self.view.window())
项目:VintageousPlus    作者:trishume    | 项目源码 | 文件源码
def replace_confirming(self, edit, pattern, compiled_rx, replacement,
                replace_count, target_region):
        last_row = row_at(self.view, target_region.b - 1)
        start = target_region.begin()

        while True:
            match = self.view.find(pattern, start)

            # no match or match out of range -- stop
            if (match == R(-1)) or (row_at(self.view, match.a) > last_row):
                self.view.show(first_sel(self.view).begin())
                return

            size_before = self.view.size()

            with adding_regions(self.view, 's_confirm', [match], 'comment'):
                self.view.show(match.a, True)
                if sublime.ok_cancel_dialog("Confirm replacement?"):
                    text = self.view.substr(match)
                    substituted = re.sub(compiled_rx, replacement, text, count=replace_count)
                    self.view.replace(edit, match, substituted)

            start = match.b + (self.view.size() - size_before)
项目:RemoteCpp    作者:ruibm    | 项目源码 | 文件源码
def on_text_command(self, view, command_name, args):
    # log('cmd={cmd} args={args}'.format(cmd=command_name, args=args))
    if RemoteCppListFilesCommand.owns_view(view) and \
        command_name == 'insert' and args['characters'] == '\n':
      all_lines = get_multiple_sel_lines(view)
      paths = []
      for line in all_lines:
        if self._is_valid_path(line):
          paths.append(line)
      def run_in_background():
        for path in paths:
          file = File(cwd=s_cwd(), path=path)
          Commands.open_file(view, file.to_args())
      if len(paths) > 10:
        msg = ('This will open {0} files which could be slow. \n'
               'Are you sure you want to do that?').format(len(paths),)
        button_text = 'Open {0} Files'.format(len(paths))
        if not sublime.ok_cancel_dialog(msg, button_text):
          return None
      THREAD_POOL.run(run_in_background)
    return None
项目:NeoVintageous    作者:NeoVintageous    | 项目源码 | 文件源码
def replace_confirming(self, edit, pattern, compiled_rx, replacement,
                           replace_count, target_region):
        last_row = row_at(self.view, target_region.b - 1)
        start = target_region.begin()

        while True:
            match = self.view.find(pattern, start)

            # no match or match out of range -- stop
            if (match == Region(-1)) or (row_at(self.view, match.a) > last_row):
                self.view.show(first_sel(self.view).begin())
                return

            size_before = self.view.size()

            with adding_regions(self.view, 's_confirm', [match], 'comment'):
                self.view.show(match.a, True)
                if ok_cancel_dialog("Confirm replacement?"):
                    text = self.view.substr(match)
                    substituted = re.sub(compiled_rx, replacement, text, count=replace_count)
                    self.view.replace(edit, match, substituted)

            start = match.b + (self.view.size() - size_before)


# https://vimhelp.appspot.com/change.txt.html#:delete
项目:PhaserSublimePackage    作者:PhaserEditor2D    | 项目源码 | 文件源码
def report_error(message, project):
  if sublime.ok_cancel_dialog(message, "Disable Tern"):
    project.disabled = True
项目:PhaserSublimePackage    作者:PhaserEditor2D    | 项目源码 | 文件源码
def plugin_loaded():
  global arghints_enabled, renderer, tern_command, tern_arguments
  global arg_completion_enabled
  arghints_enabled = get_setting("tern_argument_hints", False)
  arg_completion_enabled = get_setting("tern_argument_completion", False)

  if "show_popup" in dir(sublime.View):
    default_output_style = "tooltip"
  else:
    default_output_style = "status"
  output_style = get_setting("tern_output_style", get_setting("tern_argument_hints_type", default_output_style))
  renderer = create_renderer(output_style)
  tern_arguments = get_setting("tern_arguments", [])
  if not isinstance(tern_arguments, list):
    tern_arguments = [tern_arguments]
  tern_command = get_setting("tern_command", None)
  if tern_command is None:
    if not os.path.isdir(os.path.join(plugin_dir, "node_modules/tern")):
      if sublime.ok_cancel_dialog(
          "It appears Tern has not been installed. Do you want tern_for_sublime to try and install it? "
          "(Note that this will only work if you already have node.js and npm installed on your system.)"
          "\n\nTo get rid of this dialog, either uninstall tern_for_sublime, or set the tern_command setting.",
          "Yes, install."):
        try:
          if hasattr(subprocess, "check_output"):
            subprocess.check_output(["npm", "install"], cwd=plugin_dir)
          else:
            subprocess.check_call(["npm", "install"], cwd=plugin_dir)
        except (IOError, OSError) as e:
          msg = "Installation failed. Try doing 'npm install' manually in " + plugin_dir + "."
          if hasattr(e, "output"):
            msg += " Error message was:\n\n" + e.output
          sublime.error_message(msg)
          return
    tern_command = ["node",  os.path.join(plugin_dir, "node_modules/tern/bin/tern"), "--no-port-file"]
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def run(self, pack_textures=True):
        path = INFOS.addon.media_path
        if pack_textures:
            utils.texturepacker(media_path=path,
                                settings=sublime.load_settings(SETTINGS_FILE))
        utils.make_archive(folderpath=path,
                           archive=os.path.join(path, os.path.basename(path) + ".zip"))
        if sublime.ok_cancel_dialog("Zip file created!\nDo you want to show it with a file browser?"):
            webbrowser.open(path)
项目:KodiDevKit    作者:phil65    | 项目源码 | 文件源码
def on_done(self, index):
        if index == -1:
            return None
        media_path = os.path.join(INFOS.addon.theme_path, self.themes[index])
        utils.texturepacker(media_path=media_path,
                            settings=sublime.load_settings(SETTINGS_FILE),
                            xbt_filename=self.themes[index] + ".xbt")
        if sublime.ok_cancel_dialog("Theme file created!\nDo you want to show it with a file browser?"):
            webbrowser.open(media_path)
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def run(self, paths = []):
    feature_name = get_feature_name(get_path(paths))
    if sublime.ok_cancel_dialog('Remove Feature: %s?' % feature_name, 'Remove'):
      run_script(get_path(paths), 'rm_feature', [feature_name])
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def run(self, paths = []):
    p = get_path(paths)
    feature_name = None
    component_name = get_filename_without_ext(get_path(paths))
    args = component_name
    if is_feature_component(p):
      feature_name = get_feature_name(p)
      args = '%s/%s' % (feature_name, component_name)

    if sublime.ok_cancel_dialog('Remove Component: %s?' % args, 'Remove'):
      Window().run_command('close')
      run_script(get_path(paths), 'rm_component', [args])
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def run(self, paths = []):
    feature_name = get_feature_name(get_path(paths))
    page_name = get_filename_without_ext(get_path(paths))
    if sublime.ok_cancel_dialog('Remove Page: %s/%s?' % (feature_name, page_name), 'Remove'):
      Window().run_command('close')
      run_script(get_path(paths), 'rm_page', ['%s/%s' % (feature_name, page_name)])
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def run(self, paths = []):
    p = get_path(paths)
    featureName = get_feature_name(p)
    actionName = get_filename_without_ext(p)
    if sublime.ok_cancel_dialog('Remove Action: %s/%s?' % (featureName, actionName), 'Remove'):
      Window().run_command('close')
      run_script(p, 'rm_action', ['%s/%s' % (featureName, actionName)])
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def on_done(self, paths, relative_to_project, name):
    if sublime.ok_cancel_dialog('Remove Action: %s?' % name, 'Remove'):
      run_script(get_path(paths), 'rm_action', name.split(' '))
项目:.sublime    作者:cxdongjack    | 项目源码 | 文件源码
def run(self, paths = [], confirmed = 'False'):

        if confirmed == 'False' and s.get('confirm_before_deleting', True):
            if sublime.platform() == 'osx':
                if sublime.ok_cancel_dialog('Delete the selected items?'):
                    self.run(paths, 'True')
            else:
                self.confirm([item.path() for item in SideBarSelection(paths).getSelectedItems()], [item.pathWithoutProject() for item in SideBarSelection(paths).getSelectedItems()])
        else:
            SideBarDeleteThread(paths).start()
项目:.sublime    作者:cxdongjack    | 项目源码 | 文件源码
def _delete_threaded(self, paths):
        key = 'delete-'+str(time.time())
        window_set_status(key, 'Deleting…')
        try:
            from .send2trash import send2trash
            for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
                if s.get('close_affected_buffers_when_deleting_even_if_dirty', False):
                    item.closeViews()
                if s.get('disable_send_to_trash', False):
                    if sublime.platform() == 'windows':
                        self.remove('\\\\?\\'+item.path());
                    else:
                        self.remove(item.path());
                else:
                    send2trash(item.path())
            SideBarProject().refresh();
        except:
            should_confirm = s.get('confirm_before_permanently_deleting', True)
            if not should_confirm or sublime.ok_cancel_dialog('There is no trash bin, permanently delete?', 'Yes, Permanent Deletion'):
                for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
                    if s.get('close_affected_buffers_when_deleting_even_if_dirty', False):
                        item.closeViews()
                    if sublime.platform() == 'windows':
                        self.remove('\\\\?\\'+item.path());
                    else:
                        self.remove(item.path());
                SideBarProject().refresh();
        window_set_status(key, '')
项目:.sublime    作者:cxdongjack    | 项目源码 | 文件源码
def run(self, paths = [], confirmed = 'False'):

        if confirmed == 'False' and s.get('confirm_before_deleting', True):
            if sublime.platform() == 'osx':
                if sublime.ok_cancel_dialog('empty the content of the folder?'):
                    self.run(paths, 'True')
            else:
                self.confirm([item.path() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()], [item.pathWithoutProject() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()])
        else:
            key = 'move-'+str(time.time())
            SideBarEmptyThread(paths, key).start()
项目:.sublime    作者:cxdongjack    | 项目源码 | 文件源码
def overwrite(self):
        overwrite = sublime.ok_cancel_dialog("Destination exists", "Delete, and overwrite")
        if overwrite:
            from SideBarEnhancements.send2trash import send2trash
            send2trash(self.path())
            return True
        else:
            return False
项目:Log-Highlight    作者:poucotm    | 项目源码 | 文件源码
def run(self, edit):
        ret = sublime.ok_cancel_dialog('Erase Customized Log Highlight Syntax & Theme ?')
        if ret:
            try:
                wins_l = sublime.windows()
                for w in wins_l:
                    s_view = w.get_output_panel('loghighlight')
                    if s_view:
                        w.run_command("hide_panel", {"panel": "output.loghighlight"})
                        s_view.set_syntax_file('Packages/Log Highlight/Log Highlight.tmLanguage')
                        s_view.settings().set('color_scheme', 'Packages/Log Highlight/Log Highlight.hidden-tmTheme')
                    view_l = w.views()
                    for v in view_l:
                        if check_syntax(v):
                            v.set_syntax_file('Packages/Log Highlight/Log Highlight.tmLanguage')
                            v.settings().set('color_scheme', 'Packages/Log Highlight/Log Highlight.hidden-tmTheme')

                usr_syntax = os.path.join(sublime.packages_path(), 'User/Log Highlight.tmLanguage')
                if os.path.exists(usr_syntax):
                    os.remove(usr_syntax)

                usr_theme = os.path.join(sublime.packages_path(), 'User/Log Highlight.hidden-tmTheme')
                if os.path.exists(usr_theme):
                    os.remove(usr_theme)

            except Exception:
                disp_exept()

##  Log Highlight  ____________________________________________

# to prevent re-run in short time
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def run_script_on_file(self, temp_file_path):
    try:
      node_path = PluginUtils.get_node_path()
      script_path = PLUGIN_FOLDER + "/scripts/run.js"
      file_path = self.view.file_name()
      cmd = [node_path, script_path, temp_file_path, file_path or "?", USER_FOLDER]
      output = PluginUtils.get_output(cmd)

      # Make sure the correct/expected output is retrieved.
      if output.find(OUTPUT_VALID) != -1:
        return output

      msg = "Command " + '" "'.join(cmd) + " created invalid output."
      print(output)
      raise Exception(msg)

    except:
      # Something bad happened.
      print("Unexpected error({0}): {1}".format(sys.exc_info()[0], sys.exc_info()[1]))

      # Usually, it's just node.js not being found. Try to alleviate the issue.
      msg = "Node.js was not found in the default path. Please specify the location."
      if not sublime.ok_cancel_dialog(msg):
        msg = "You won't be able to use this plugin without specifying the path to node.js."
        sublime.error_message(msg)
      else:
        PluginUtils.open_sublime_settings(self.view.window())
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def prompt_for_node_js_path(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_NODE_JS_PATH): return
        AnfNewProject(self.window, STR_NODE_JS_PATH, self.on_node_js_path_provided).run("/")
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def prompt_for_builder_cli_path(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_BUILDER_CLI_PATH): return
        AnfNewProject(self.window, STR_BUILDER_CLI_PATH, self.on_builder_cli_path_provided).run("/")
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def prompt_for_build_api_key(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_PROVIDE_BUILD_API_KEY): return
        self.window.show_input_panel(STR_BUILD_API_KEY, "", self.on_build_api_key_provided, None, None)
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def select_device(self, need_to_confirm=True):
        model = self.load_this_model()
        if not model:
            sublime.message_dialog(STR_MODEL_NOT_ASSIGNED)
            return

        device_ids = model.get("devices")
        if not device_ids or not len(device_ids):
            sublime.message_dialog(STR_MODEL_HAS_NO_DEVICES)
            return

        if need_to_confirm and not sublime.ok_cancel_dialog(STR_SELECT_DEVICE): return
        (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids)
        self.window.show_quick_panel(device_names, self.on_device_selected)
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_project_path_provided(self, path):
        log_debug("Project path specified: " + path)
        # self.__tmp_project_path = path
        if os.path.exists(path):
            if not sublime.ok_cancel_dialog(STR_FOLDER_EXISTS.format(path)):
                return
        self.create_project(path)
        # self.prompt_for_build_api_key()
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def prompt_model_to_remove_device(self, need_to_confirm=True):
        if need_to_confirm and not sublime.ok_cancel_dialog(STR_MODEL_REMOVE_DEVICE): return

        model = self.load_this_model()
        device_ids = model.get("devices") if model else None

        if not device_ids or len(device_ids) == 0:
            sublime.message_dialog(STR_MODEL_NO_DEVICES_TO_REMOVE)
            return

        (Env.For(self.window).tmp_device_ids, device_names) = self.load_devices(input_device_ids=device_ids)
        self.window.show_quick_panel(device_names, self.on_remove_device_selected)
项目:CMakeBuilder    作者:rwols    | 项目源码 | 文件源码
def _on_done_project_dir(self, text):
        self.project_dir = os.path.join(text, self.project_name)
        if os.path.exists(self.project_dir):
            sublime.error_message('The directory "%s" already exists!' % self.project_dir)
            return
        msg = 'The new project location will be "%s".\n\nPress OK to continue...' % (self.project_dir)
        if sublime.ok_cancel_dialog(msg):
            self.window.show_quick_panel([["C", "A project suitable for C"], ["C++", "A project suitable for C++"], ["C and C++", "A project suitable for both C and C++"]], self._on_done_select_project_type)
项目:VUEFormatter    作者:baixuexiyang    | 项目源码 | 文件源码
def run_script_on_file(self, temp_file_path):
    try:
      node_path = PluginUtils.get_node_path()
      script_path = PLUGIN_FOLDER + "/scripts/index.js"
      file_path = self.view.file_name()
      cmd = [node_path, script_path, temp_file_path, file_path or "?", USER_FOLDER]
      output = PluginUtils.get_output(cmd)

      # Make sure the correct/expected output is retrieved.
      if output.find(OUTPUT_VALID) != -1:
        return output

      msg = "Command " + '" "'.join(cmd) + " created invalid output."
      print(output)
      raise Exception(msg)

    except:
      # Something bad happened.
      print("Unexpected error({0}): {1}".format(sys.exc_info()[0], sys.exc_info()[1]))

      # Usually, it's just node.js not being found. Try to alleviate the issue.
      msg = "Node.js was not found in the default path. Please specify the location."
      if not sublime.ok_cancel_dialog(msg):
        msg = "You won't be able to use this plugin without specifying the path to node.js."
        sublime.error_message(msg)
      else:
        PluginUtils.open_sublime_settings(self.view.window())
项目:new-file-pro    作者:KevinHoo    | 项目源码 | 文件源码
def overwrite(self):
        overwrite = sublime.ok_cancel_dialog("Destination exists", "Delete, and overwrite")
        if overwrite:
            from SideBarEnhancements.send2trash import send2trash
            send2trash(self.path())
            return True
        else:
            return False
项目:RemoteCpp    作者:ruibm    | 项目源码 | 文件源码
def run(self, edit):
    view = self.view
    file = STATE.file(self.view.file_name())
    title = 'Delete file:\n\n{0}'.format(file.remote_path())
    if sublime.ok_cancel_dialog(title, 'Delete'):
      log("Deleting the file...")
      cmd_str = 'rm -f {remote_path}'.format(remote_path=file.remote_path())
      ssh_cmd(cmd_str)
      self.view.close()
      STATE.update_list(cwd=s_cwd(view), files_to_rm=[file])
项目:rekit-sublime    作者:supnate    | 项目源码 | 文件源码
def run(self, paths = []):
    p = get_path(paths)
    rekitRoot = get_rekit_root(p)
    targetName = get_filename_without_ext(p)
    featureName = None
    if is_reducer(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/redux/reducer.test.js' % featureName)
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_reducer_test'
          run_script(p, script, [featureName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
    if is_action(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/redux/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_action_test'
          if is_async_action(p):
            script = 'add_async_action_test';
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)

      return
    elif is_page(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_page_test'
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)

    elif is_feature_component(p):
      featureName = get_feature_name(p)
      testPath = os.path.join(rekitRoot, 'test/app/features/%s/%s.test.js' % (featureName, targetName))
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_component_test'
          run_script(p, script, [featureName + '/' + targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
    elif is_component(p):
      testPath = os.path.join(rekitRoot, 'test/app/components/%s.test.js' % targetName)
      if not os.path.exists(testPath):
        if sublime.ok_cancel_dialog('The test file doesn\'t exist, create it? '):
          script = 'add_component_test'
          run_script(p, script, [targetName], on_done=functools.partial(self.on_test_created, testPath))
      else:
        Window().open_file(testPath)
项目:SalesforceXyTools    作者:exiahuang    | 项目源码 | 文件源码
def main_handle(self):

        self.sftype = self.sf.get_sobject(self.picked_name)

        sftypedesc = self.sftype.describe()

        # util.show_in_new_tab(util.get_dto_class(self.picked_name, sftypedesc["fields"], self.is_custom_only))


        sub_folder = AUTO_CODE_DIR
        sfdc_name_map = codecreator.get_sfdc_namespace(self.picked_name)

        is_open = False
        save_path_list = []

        # dto Code
        dto_code, class_name = codecreator.get_dto_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['dto_file']
        save_path = util.save_and_open_in_panel(dto_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # dao Code
        dao_code = codecreator.get_dao_class(self.picked_name, sftypedesc["fields"], self.sf, self.is_custom_only)
        file_name = sfdc_name_map['dao_file']
        save_path = util.save_and_open_in_panel(dao_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # controller code
        controller_code, class_name = codecreator.get_controller_class(self.picked_name)
        file_name = sfdc_name_map['controller_file']
        save_path = util.save_and_open_in_panel(controller_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # visualforce code
        vf_code, class_name = codecreator.get_vf_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['vf_file']
        save_path = util.save_and_open_in_panel(vf_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # list controller code
        list_controller_code, class_name = codecreator.get_list_controller_class(self.picked_name)
        file_name = sfdc_name_map['list_controller_file']
        save_path = util.save_and_open_in_panel(list_controller_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # visualforce code
        list_vf_code, class_name = codecreator.get_list_vf_class(self.picked_name, sftypedesc["fields"], self.is_custom_only, self.include_validate)
        file_name = sfdc_name_map['list_vf_file']
        save_path = util.save_and_open_in_panel(list_vf_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        # SfdcXyController
        src_code = codecreator.get_sfdcxycontroller()
        file_name = 'SfdcXyController.cls'
        save_path = util.save_and_open_in_panel(src_code, file_name, is_open, sub_folder )
        save_path_list.append(save_path)

        if sublime.ok_cancel_dialog('Create Source Over,Do you want to open the sources? '):
            for save_path in save_path_list:
                util.open_file(save_path)
项目:sublimeTextConfig    作者:luoye-fe    | 项目源码 | 文件源码
def run(self, edit: sublime.Edit) -> None:
        if self.data is not None:
            self.replace(edit)
            return

        aggresive_level = get_settings(self.view, 'aggressive', 0)
        if aggresive_level > 0:
            if not sublime.ok_cancel_dialog(
                'You have an aggressive level of {} this may cause '
                'anaconda to change things that you don\'t really want to '
                'change.\n\nAre you sure do you want to continue?'.format(
                    aggresive_level
                )
            ):
                return

        self.code = self.view.substr(sublime.Region(0, self.view.size()))
        settings = {
            'aggressive': aggresive_level,
            'list-fixes': get_settings(self.view, 'list-fixes', False),
            'autoformat_ignore': get_settings(
                self.view, 'autoformat_ignore', []
            ),
            'autoformat_select': get_settings(
                self.view, 'autoformat_select', []
            ),
            'pep8_max_line_length': get_settings(
                self.view, 'pep8_max_line_length', 79
            )
        }
        try:
            messages = {
                'start': 'Autoformatting please wait... ',
                'end': 'Autoformatting done!',
                'fail': 'Autoformatting failed, buffer not changed.',
                'timeout': 'Autoformatting failed, buffer not changed.',
            }
            self.pbar = ProgressBar(messages)
            self.pbar.start()
            self.view.set_read_only(True)

            data = {
                'vid': self.view.id(),
                'code': self.code,
                'method': 'pep8',
                'settings': settings,
                'handler': 'autoformat'
            }
            timeout = get_settings(self.view, 'auto_formatting_timeout', 1)

            callback = Callback(timeout=timeout)
            callback.on(success=self.get_data)
            callback.on(error=self.on_failure)
            callback.on(timeout=self.on_failure)

            Worker().execute(callback, **data)
        except:
            logging.error(traceback.format_exc())
项目:ElectricImp-Sublime    作者:electricimp    | 项目源码 | 文件源码
def on_model_selected(self, index):
        # Selection was canceled, nothing to do here
        if index == -1:
            return

        model_id, model_name = self.__tmp_all_models[index]

        self.__tmp_all_models = None  # We don't need it anymore
        log_debug("Model selected id: " + model_id)

        # Save newly created model to the project settings
        settings = self.load_settings()
        settings[EI_MODEL_ID] = model_id
        settings[EI_MODEL_NAME] = model_name
        self.env.project_manager.save_settings(PR_SETTINGS_FILE, settings)

        # Reset the logs
        self.env.log_manager.reset()

        # Update the Model name in the status bar
        self.update_model_name_in_status(query_model_name=False)

        if not sublime.ok_cancel_dialog(STR_MODEL_CONFIRM_PULLING_MODEL_CODE):
            return

        # Pull the latest code from the Model
        source_dir = self.env.project_manager.get_source_directory_path()
        agent_file = os.path.join(source_dir, PR_AGENT_FILE_NAME)
        device_file = os.path.join(source_dir, PR_DEVICE_FILE_NAME)

        revisions, code = HTTP.get(self.env.project_manager.get_build_api_key(),
                                   PL_BUILD_API_URL_V4 + "models/" + model_id + "/revisions")
        if len(revisions["revisions"]) > 0:
            latest_revision_url = PL_BUILD_API_URL_V4 + "models/" + model_id + "/revisions/" + \
                                  str(revisions["revisions"][0]["version"])
            source, code = HTTP.get(self.env.project_manager.get_build_api_key(), latest_revision_url)
            with open(agent_file, "w", encoding="utf-8") as file:
                file.write(source["revision"]["agent_code"])
            with open(device_file, "w", encoding="utf-8") as file:
                file.write(source["revision"]["device_code"])
        else:
            # Create initial source files
            with open(agent_file, "w", encoding="utf-8") as file:
                file.write(STR_INITIAL_SRC_CONTENT.format("Agent"))
            with open(device_file, "w", encoding="utf-8") as file:
                file.write(STR_INITIAL_SRC_CONTENT.format("Device"))