// This macros let the user save all open image and text windows in a so called workspace folder // and restore them all at once with the 'restore workspace' macro // a 'workspaces' directory must exist and be set up using the 'workspaces settings' macro // author jerome.mutterer@ibmp-ulp.u-strasbg.fr macro "Workspaces settings" { // declares a workspaces directory wsdir = getDirectory(" Select or create a Workspaces directory"); call("ij.Prefs.set", "workspaces.path", wsdir); } macro "Save Workspace [F1]" { line=""; // checks whether a workspaces directory has been declared path = call("ij.Prefs.get", "workspaces.path", "nopath"); if (path=="nopath") exit ("No 'workspaces' directory set up"); // Creates the save workspace dialog Dialog.create("Save Workspace "); Dialog.addString ("name",tstamp()+".ijw",20); Dialog.addCheckbox ("Close All windows", true); Dialog.show(); wsName = Dialog.getString(); caw= Dialog.getCheckbox(); if (!endsWith(wsName,".ijw")) wsName=wsName+".ijw"; wsPath = path+wsName; if (File.exists(wsPath)) exit("This workspace exists !\nChoose another name or \nDelete existing folder."); File.makeDirectory(wsPath); // start with saving non image windows. list = getList("window.titles"); if (list.length>0) for (i=0; i0) Dialog.addChoice ("existing WS",ews); else Dialog.addMessage("- no existing workspace"); Dialog.show(); path = path+Dialog.getChoice(); // get the contents.iws file and process it. str = File.openAsString(path+File.separator+"content.ijw"); lines=split(str,"\n"); for (i=0;i1) setSlice (e[5]); } } } // functions below function getIDs() { a = newArray(nImages); for (i=1;i<=nImages;i++) {selectImage(i);a[i-1]=getImageID();} return a; } function getEWS(path) { count=0; list=getFileList(path); wslist=list; for (i=0;i