Save Tab Sets

Feature Request: Saved Tab Sets

I use DTP for multiple projects, and these projects often involve having several tabs for specific documents. Currently, when I switch projects, I need to open each doc manually in a new tab before I can continue working on the project.

It would be a big help if I could save the tabs that are open, allowing me to reopen them all at the same time. When I switch to a new project, simply choosing that saved tab set would put me back where I was.

Have you looked into DEVONthink’s Workspaces? The Workspaces commands are available from the Go menu.

From the DEVONthink manual:

WORKSPACES
Workspaces save the content and positions of all open windows so that you can restore them later. This is, e.g., ideal if you are working with the same set of windows over and over again. Save them as a workspace and recall them whenever you need them again.

Add: Saves the currently open windows as a workspace.

Edit: Opens a window that allows you to edit saved workspaces. Click on a workspace name to change it, reorder by dragging, and delete with the . button.

Workspaces: Restores to a previously saved workspace.

Ah, thanks. I didn’t see that.

Having tried it for a bit, it’s almost what I need, but not quite. Managing it from the Go menu isn’t really convenient, and I don’t really want it to change the entire window, which is what this does (the sidebars change size, the list area at the top changes columns, etc.).

It would be much more useful to do something like what Pathfinder does, where you can create, save and load tab sets without changing anything else. Though, Pathfinder doesn’t have an “Update Set” feature, which would also be highly useful.

Perhaps you’ll find these scripts useful. They’re not exactly what you’re looking for, but they’re close.

They open whatever records are selected, into tabs in the current window or in a new window (depending on which script you run). Some usage scenarios are:

  • Select multiple records in the records list. Run the script. Those records will be opened in tabs in the current window or new window (depending on which script you run).
  • Select a Group in the sidebar. Run the script. The records contained in the Group will be opened in tabs in the current window or in a new window (depending on which script you run).
  • Create a Group and put replicants into it. Select the Group. The records referred to by the replicants in the Group will be opened in tabs in the current window or in a new window (depending on which script you run).
  • Select more than one Group in the sidebar. Run the script. Everything contained in all of the selected Groups will be opened in the current window or in a new window (depending on which script you run).

Note that if you have any Groups in your selection, any Groups contained within them will be opened as Groups, and their records will not be opened.

I have not tested the scripts using all of the different views (I tend to stay in 3-pane all the time).

There is one annoying glitch with the “current window” version that I can’t figure out: it opens a tab that has no content and no name. I’ll post again if I track this down, or maybe someone else knows the secret?


-- Open Selected Records Into Tabs In Current Window.scpt

tell application id "com.devon-technologies.thinkpro2"
	try
		set theSelection to selection
		if theSelection = {} then
			error "Please select some items."
			return
		end if
		
		repeat with theItem in theSelection
			set theType to type of theItem
			if theType = group then
				set theChildren to children of theItem
				repeat with theChild in theChildren
					open tab for record theChild in front window
				end repeat
			else
				open tab for record theItem in front window
			end if
		end repeat
	on error error_message number error_number
		hide progress indicator
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell


-- Open Selected Records Into Tabs In New Window.scpt

tell application id "com.devon-technologies.thinkpro2"
	try
		set theSelection to selection
		if theSelection = {} then
			error "Please select some items."
			return
		end if
		
		set firstTime to true
		repeat with theItem in theSelection
			set theType to type of theItem
			if theType = group then
				set theChildren to children of theItem
				repeat with theChild in theChildren
					if firstTime is equal to true then
						-- create a new window for the first record.
						set theWindow to open window for record theChild
					else
						-- open a new tab in the window.
						open tab for record theChild in theWindow
					end if
					set firstTime to false
				end repeat
			else
				if firstTime is equal to true then
					-- create a new window for the first record.
					set theWindow to open window for record theItem
				else
					-- open a new tab in the window.
					open tab for record theItem in theWindow
				end if
			end if
			set firstTime to false
		end repeat
	on error error_message number error_number
		if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
	end try
end tell

One more variation: use the script below to cause all records in a Group to open in a new window when a Group is selected. This, I think, is more what RobH is after.

This is just the previous Open Selected Records Into Tabs In New Window.scpt wrapped in an on triggered()/end triggered block.

The same effect can be used with the Open Selected Records Into Tabs In New Window.scpt script by similarly wrapping it.

on triggered() code will execute only in the views As Columns, As Split, and 3-Pane.


-- Open Selected Records Into Tabs In New Window (Triggered).scpt

on triggered(theRecord)
	tell application id "com.devon-technologies.thinkpro2"
		try
			set theSelection to selection
			if theSelection = {} then
				error "Please select some items."
				return
			end if
			
			set firstTime to true
			repeat with theItem in theSelection
				set theType to type of theItem
				if theType = group then
					set theChildren to children of theItem
					repeat with theChild in theChildren
						if firstTime is equal to true then
							-- create a new window for the first record.
							set theWindow to open window for record theChild
						else
							-- open a new tab in the window.
							open tab for record theChild in theWindow
						end if
						set firstTime to false
					end repeat
				else
					if firstTime is equal to true then
						-- create a new window for the first record.
						set theWindow to open window for record theItem
					else
						-- open a new tab in the window.
						open tab for record theItem in theWindow
					end if
				end if
				set firstTime to false
			end repeat
		on error error_message number error_number
			if the error_number is not -128 then display alert "DEVONthink Pro" message error_message as warning
		end try
	end tell
end triggered

Also, the non-triggeresd scripts work in all Views. In the As Tags view, you must first navigate to documents in the records list and run the script to open the selected records in the current or new window.

When running either of the non-triggered scripts in As List view, the selected records will always open in a new window.

I’ll check into using these scripts when I get a chance, though it’s not really what I’m looking for, as the entries I want visible are in different groups.

WHAT WOULD BE HELPFUL though, would be the addition of a “Save…” function so I can easily update the current Workspace without having to retype the name every time.

This will:

tell application id "com.devon-technologies.thinkpro2"
	set workspaceSave to save workspace "<insert workspace name here>"
end tell

Insert a workspace name to adjust for your own use. If you save the script in ~/Library/Application Support/DEVONthink Pro 2/Scripts/Toolbar, and restart DEVONthink, then you’ll be able to add the script to any toolbar – after a DEVONthink restart, the script will appear at the list of all the icons displayed when you use View > Customize Toolbar …

That works well. Thank you.