Exemplo n.º 1
0
	def on_done(self, paths, relative_to_project, name):
		if relative_to_project and s.get('new_files_relative_to_project_root'):
			paths = SideBarProject().getDirectories()
			if paths:
				paths = [SideBarItem(paths[0], False)]
			if not paths:
				paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
		else:
			paths = SideBarSelection(paths).getSelectedDirectoriesOrDirnames()
		if not paths:
			paths = SideBarProject().getDirectories()
			if paths:
				paths = [SideBarItem(paths[0], False)]
		if not paths:
			sublime.active_window().new_file()
		else:
			for item in paths:
				item = SideBarItem(item.join(name), False)
				if item.exists():
					sublime.error_message("Unable to create file, file or folder exists.")
					self.run(paths, name)
					return
				else:
					try:
						item.create()
						item.edit()
					except:
						sublime.error_message("Unable to create file:\n\n"+item.path())
						self.run(paths, name)
						return
			SideBarProject().refresh();
Exemplo n.º 2
0
	def run(self, paths = []):
		import webbrowser
		project = SideBarProject()
		url = project.getPreference('url')
		if url:
			if url[-1:] != '/':
				url = url+'/'
			for item in SideBarSelection(paths).getSelectedItems():
				webbrowser.open_new_tab(url + item.pathRelativeFromProjectEncoded())
		else:
			for item in SideBarSelection(paths).getSelectedItems():
				webbrowser.open_new_tab(item.uri())
			sublime.status_message('Preference "url" was not found in project file.\n"'+project.getProjectFile()+'", opening local file')
Exemplo n.º 3
0
	def run(self, paths = []):
		to_copy = []
		project = SideBarProject()
		url = project.getPreference('url_production')
		if url:
			if url[-1:] != '/':
				url = url+'/'
			for item in SideBarSelection(paths).getSelectedItems():
				if item.isUnderCurrentProject():
					to_copy.append(url + item.pathRelativeFromProjectEncoded())

		sublime.set_clipboard("\n".join(to_copy));
		if len(paths) > 1 :
			sublime.status_message("Items URL copied")
		else :
			sublime.status_message("Item URL copied")
Exemplo n.º 4
0
 def run(self, paths=[], confirmed='False'):
     if confirmed == 'False' and s.get('confirm_before_deleting', True):
         self.confirm([
             item.path()
             for item in SideBarSelection(paths).getSelectedItems()
         ], [
             item.pathWithoutProject()
             for item in SideBarSelection(paths).getSelectedItems()
         ])
     else:
         import sys
         try:
             path = os.path.join(sublime.packages_path(),
                                 'SideBarEnhancements')
             if path not in sys.path:
                 sys.path.append(path)
             import send2trash
             for item in SideBarSelection(
                     paths).getSelectedItemsWithoutChildItems():
                 if s.get(
                         'close_affected_buffers_when_deleting_even_if_dirty',
                         False):
                     item.close_associated_buffers()
                 send2trash.send2trash(item.path())
             SideBarProject().refresh()
         except:
             import functools
             self.window.run_command('hide_panel')
             self.window.show_input_panel(
                 "Permanently Delete:",
                 SideBarSelection(paths).getSelectedItems()[0].path(),
                 functools.partial(
                     self.on_done,
                     SideBarSelection(paths).getSelectedItems()[0].path()),
                 None, None)
Exemplo n.º 5
0
 def on_done(self, old, new):
     print 'on done'
     if s.get('close_affected_buffers_when_deleting_even_if_dirty', False):
         item = SideBarItem(new, os.path.isdir(new))
         item.close_associated_buffers()
     print 'closed associated buffers'
     self.remove(new)
     SideBarProject().refresh()
Exemplo n.º 6
0
	def run(self, paths = []):
		items = []
		for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
			items.append(SideBarProject().getDirectoryFromPath(item.path()))
		items = list(set(items))
		if items:
			self.window.run_command('hide_panel');
			self.window.run_command("show_panel", {"panel": "find_in_files", "where":",".join(items)})
Exemplo n.º 7
0
    def run(self, paths=[]):
        items = []
        project = SideBarProject()
        url = project.getPreference('url_production')
        if url:
            if url[-1:] != '/':
                url = url + '/'
            for item in SideBarSelection(paths).getSelectedItems():
                if item.isUnderCurrentProject():
                    items.append(url + item.pathRelativeFromProjectEncoded())

        if len(items) > 0:
            sublime.set_clipboard("\n".join(items))
            if len(items) > 1:
                sublime.status_message("Items URL copied")
            else:
                sublime.status_message("Item URL copied")
Exemplo n.º 8
0
 def run(self, paths=[], type=False):
     import webbrowser
     project = SideBarProject()
     if project.hasOpenedProject():
         if type == False or type == 'testing':
             url = project.getPreference('url')
         elif type == 'production':
             url = project.getPreference('url_production')
         else:
             url = project.getPreference('url')
         if url:
             if url[-1:] != '/':
                 url = url + '/'
             for item in SideBarSelection(paths).getSelectedItems():
                 if item.isUnderCurrentProject():
                     webbrowser.open_new_tab(
                         url + item.pathRelativeFromProjectEncoded())
                 else:
                     webbrowser.open_new_tab(item.uri())
         else:
             for item in SideBarSelection(paths).getSelectedItems():
                 webbrowser.open_new_tab(item.uri())
             sublime.status_message(
                 'Preference "url" was not found in project file.\n"' +
                 project.getProjectFile() + '", opening local file')
     else:
         for item in SideBarSelection(paths).getSelectedItems():
             webbrowser.open_new_tab(item.uri())
Exemplo n.º 9
0
 def run(self, paths=[]):
     project = SideBarProject()
     if project.hasOpenedProject():
         for item in SideBarSelection(paths).getSelectedItems():
             if item.isDirectory():
                 project.excludeDirectory(item.path())
             else:
                 project.excludeFile(item.path())
Exemplo n.º 10
0
    def run(self, paths=[]):
        items = []
        for directory in SideBarProject().getDirectories():
            items.append(directory)

        if len(items) > 0:
            sublime.set_clipboard("\n".join(items))
            if len(items) > 1:
                sublime.status_message("Items copied")
            else:
                sublime.status_message("Item copied")
Exemplo n.º 11
0
	def run(self, paths = []):
		global sidebar_instant_search
		if paths == [] and SideBarProject().getDirectories():
			paths = SideBarProject().getDirectories()
		else:
			paths = [item.path() for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames()]
		if paths == []:
			return
		view = self.window.new_file()
		view.settings().set('word_wrap', False)
		view.set_name('Instant File Search')
		view.set_syntax_file('Packages/SideBarEnhancements/SideBar Results.hidden-tmLanguage')
		view.set_scratch(True)
		edit = view.begin_edit()
		view.settings().set('sidebar_instant_search_paths', paths)
		view.replace(edit, sublime.Region(0, view.size()), "Type to search: ")
		view.end_edit(edit)
		view.sel().clear()
		view.sel().add(sublime.Region(16))
		sidebar_instant_search += 1
Exemplo n.º 12
0
	def on_done(self, old, new):
		item = SideBarItem(old, os.path.isdir(old))
		try:
			if not item.move(new):
				sublime.error_message("Unable to move, destination exists.")
				self.run([old], new)
				return
		except:
			sublime.error_message("Unable to move:\n\n"+old+"\n\nto\n\n"+new)
			self.run([old], new)
			return
		SideBarProject().refresh();
Exemplo n.º 13
0
	def run(self, paths = [], type = False):
		import webbrowser
		project = SideBarProject()
		if project.hasOpenedProject():
			if type == False or type == 'testing':
				url = project.getPreference('url')
			elif type == 'production':
				url = project.getPreference('url_production')
			else:
				url = project.getPreference('url')
			if url:
				if url[-1:] != '/':
					url = url+'/'
				for item in SideBarSelection(paths).getSelectedItems():
					if item.isUnderCurrentProject():
						webbrowser.open_new_tab(url + item.pathRelativeFromProjectEncoded())
					else:
						webbrowser.open_new_tab(item.uri())
			else:
				for item in SideBarSelection(paths).getSelectedItems():
					webbrowser.open_new_tab(item.uri())
				sublime.status_message('Preference "url" was not found in project file.\n"'+project.getProjectFile()+'", opening local file')
		else:
			for item in SideBarSelection(paths).getSelectedItems():
				webbrowser.open_new_tab(item.uri())
Exemplo n.º 14
0
	def run(self, paths = []):
		project = SideBarProject()
		if project.hasOpenedProject():
			for item in SideBarSelection(paths).getSelectedItems():
				if item.isDirectory():
					project.excludeDirectory(item.path())
				else:
					project.excludeFile(item.path())
Exemplo n.º 15
0
	def on_done(self, paths, name):
		for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
			item = SideBarItem(item.join(name), True)
			if item.exists():
				sublime.error_message("Unable to create folder, folder or file exists.")
				self.run(paths, name)
				return
			else:
				item.create()
				if not item.exists():
					sublime.error_message("Unable to create folder:\n\n"+item.path())
					self.run(paths, name)
					return
		SideBarProject().refresh();
Exemplo n.º 16
0
	def run(self, paths = [], confirmed = 'False'):

		if confirmed == 'False' and s.get('confirm_before_deleting', True):
			self.confirm([item.path() for item in SideBarSelection(paths).getSelectedItems()], [item.pathWithoutProject() for item in SideBarSelection(paths).getSelectedItems()])
		else:
			try:
				for item in SideBarSelection(paths).getSelectedItemsWithoutChildItems():
					if s.get('close_affected_buffers_when_deleting_even_if_dirty', False):
						item.close_associated_buffers()
					send2trash(item.path())
				SideBarProject().refresh();
			except:
				import functools
				self.window.run_command('hide_panel');
				self.window.show_input_panel("Permanently Delete:", SideBarSelection(paths).getSelectedItems()[0].path(), functools.partial(self.on_done, SideBarSelection(paths).getSelectedItems()[0].path()), None, None)
Exemplo n.º 17
0
	def on_done(self, old, new):
		item = SideBarItem(old, os.path.isdir(old))
		try:
			if not item.copy(new):
				sublime.error_message("Unable to duplicate, destination exists.")
				self.run([old], new)
				return
		except:
			sublime.error_message("Unable to copy:\n\n"+old+"\n\nto\n\n"+new)
			self.run([old], new)
			return
		item = SideBarItem(new, os.path.isdir(new))
		if item.isFile():
			item.edit();
		SideBarProject().refresh();
Exemplo n.º 18
0
	def on_done(self, old, branch, leaf):
		self.window.run_command('hide_panel');
		leaf = leaf.strip();
		new = os.path.join(branch, leaf)
		item = SideBarItem(old, os.path.isdir(old))
		try:
			if not item.move(new):
				sublime.error_message("Unable to rename, destination exists.")
				self.run([old], leaf)
				return
		except:
			sublime.error_message("Unable to rename:\n\n"+old+"\n\nto\n\n"+new)
			self.run([old], leaf)
			raise
			return
		SideBarProject().refresh();
Exemplo n.º 19
0
 def on_done(self, paths, name):
     for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
         item = SideBarItem(item.join(name), False)
         if item.exists():
             sublime.error_message(
                 "Unable to create file, file or folder exists.")
             self.run(paths, name)
             return
         else:
             try:
                 item.create()
                 item.edit()
             except:
                 sublime.error_message("Unable to create file:\n\n" +
                                       item.path())
                 self.run(paths, name)
                 return
     SideBarProject().refresh()
Exemplo n.º 20
0
 def run(self, paths=[], confirmed='False'):
     print '--------------'
     print 'deleting paths'
     print paths
     print 'confirmed'
     print confirmed
     if confirmed == 'False' and s.get('confirm_before_deleting', True):
         print 'confirmed == False and confirm_before_deleting == True'
         self.confirm([
             item.path()
             for item in SideBarSelection(paths).getSelectedItems()
         ], [
             item.pathWithoutProject()
             for item in SideBarSelection(paths).getSelectedItems()
         ])
     else:
         print 'trying send to trash'
         try:
             for item in SideBarSelection(
                     paths).getSelectedItemsWithoutChildItems():
                 if s.get(
                         'close_affected_buffers_when_deleting_even_if_dirty',
                         False):
                     item.close_associated_buffers()
                     print 'closed associated buffers'
                 print 'send2trash'
                 send2trash(item.path())
             SideBarProject().refresh()
             print 'file deleted'
             print 'file exists?' + str(os.path.exists(item.path()))
         except:
             print 'something failed'
             print 'trying Permanent deletion'
             import functools
             self.window.run_command('hide_panel')
             self.window.show_input_panel(
                 "Permanently Delete:",
                 SideBarSelection(paths).getSelectedItems()[0].path(),
                 functools.partial(
                     self.on_done,
                     SideBarSelection(paths).getSelectedItems()[0].path()),
                 None, None)
Exemplo n.º 21
0
	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:
			try:
				for item in SideBarSelection(paths).getSelectedDirectoriesOrDirnames():
					for content in os.listdir(item.path()):
						file = os.path.join(item.path(), content)
						if not SideBarSelection().isNone(file):
							send2trash(file)
					if s.get('close_affected_buffers_when_deleting_even_if_dirty', False):
						item.close_associated_buffers()
			except:
				pass
			SideBarProject().refresh();
Exemplo n.º 22
0
 def run(self, paths=[]):
     project = SideBarProject()
     if project.hasOpenedProject():
         for item in SideBarSelection(paths).getSelectedDirectories():
             project.rootAdd(item.path())
Exemplo n.º 23
0
	def run(self, paths = []):
		project = SideBarProject()
		if project.hasOpenedProject():
			for item in SideBarSelection(paths).getSelectedDirectories():
				project.rootAdd(item.path())
Exemplo n.º 24
0
	def run(self, paths = []):
		project = SideBarProject()
		if project.hasOpenedProject():
			SideBarItem(project.getProjectFile(), False).edit();
Exemplo n.º 25
0
    def run(self, paths=[], in_parent='False', test='True', replace='False'):
        s = sublime.load_settings(
            "SideBarEnhancements/Clipboard.sublime-settings")

        cut = s.get('cut', '')
        copy = s.get('copy', '')

        already_exists_paths = []

        if SideBarSelection(paths).len() > 0:
            if in_parent == 'False':
                location = SideBarSelection(paths).getSelectedItems()[0].path()
            else:
                location = SideBarSelection(
                    paths).getSelectedDirectoriesOrDirnames()[0].dirname()

            if os.path.isdir(location) == False:
                location = SideBarItem(os.path.dirname(location), True)
            else:
                location = SideBarItem(location, True)

            if cut != '':
                cut = cut.split("\n")
                for path in cut:
                    path = SideBarItem(path, os.path.isdir(path))
                    new = os.path.join(location.path(), path.name())
                    if test == 'True' and os.path.exists(new):
                        already_exists_paths.append(new)
                    elif test == 'False':
                        if os.path.exists(new) and replace == 'False':
                            pass
                        else:
                            try:
                                if not path.move(new, replace == 'True'):
                                    sublime.error_message(
                                        "Unable to cut and paste, destination exists."
                                    )
                                    return
                            except:
                                sublime.error_message("Unable to move:\n\n" +
                                                      path.path() +
                                                      "\n\nto\n\n" + new)
                                return

            if copy != '':
                copy = copy.split("\n")
                for path in copy:
                    path = SideBarItem(path, os.path.isdir(path))
                    new = os.path.join(location.path(), path.name())
                    if test == 'True' and os.path.exists(new):
                        already_exists_paths.append(new)
                    elif test == 'False':
                        if os.path.exists(new) and replace == 'False':
                            pass
                        else:
                            try:
                                if not path.copy(new, replace == 'True'):
                                    sublime.error_message(
                                        "Unable to copy and paste, destination exists."
                                    )
                                    return
                            except:
                                sublime.error_message("Unable to copy:\n\n" +
                                                      path.path() +
                                                      "\n\nto\n\n" + new)
                                return

            if test == 'True' and len(already_exists_paths):
                self.confirm(paths, in_parent, already_exists_paths)
            elif test == 'True' and not len(already_exists_paths):
                self.run(paths, in_parent, 'False', 'False')
            elif test == 'False':
                cut = s.set('cut', '')
                SideBarProject().refresh()
Exemplo n.º 26
0
 def run(self, paths=[]):
     project = SideBarProject()
     if project.hasOpenedProject():
         SideBarItem(project.getProjectFile(), False).edit()