PageRenderTime 415ms CodeModel.GetById 371ms app.highlight 11ms RepoModel.GetById 10ms app.codeStats 0ms

/jEdit/tags/jedit-4-5-pre1/org/gjt/sp/jedit/browser.actions.xml

#
XML | 264 lines | 222 code | 35 blank | 7 comment | 0 complexity | ef1aef4ebf86c91775c92f6b78ccdf35 MD5 | raw file
  1<?xml version="1.0"?>
  2
  3<!DOCTYPE ACTIONS SYSTEM "actions.dtd">
  4
  5<!-- VFS browser action table                                                -->
  6<!-- Copyright (C) 2003 Slava Pestov                                         -->
  7
  8<!-- :tabSize=8:indentSize=8:noTabs=false:                                   -->
  9<!-- :folding=indent:collapseFolds=1:mode=jedit-actions:		     -->
 10
 11<!-- Actions are the 'glue' that binds menu item selections and keystrokes   -->
 12<!-- to jEdit's APIs. For simplicity and compactness, they are written in    -->
 13<!-- the BeanShell scripting language.                                       -->
 14
 15<ACTIONS>
 16
 17<ACTION NAME="vfs.browser.browse">
 18	<CODE>
 19		if (files.length != 0)
 20			browser.setDirectory(files[0].path);
 21	</CODE>
 22</ACTION>
 23
 24<ACTION NAME="vfs.browser.previous">
 25	<CODE>
 26		browser.previousDirectory();
 27	</CODE>
 28</ACTION>
 29
 30<ACTION NAME="vfs.browser.next">
 31	<CODE>
 32		browser.nextDirectory();
 33	</CODE>
 34</ACTION>
 35
 36<ACTION NAME="vfs.browser.closedialog">
 37	<CODE>
 38		browser.dispose();
 39	</CODE>
 40</ACTION>
 41
 42
 43<ACTION NAME="vfs.browser.browse-window">
 44	<CODE>
 45		for(int i = 0; i &lt; files.length; i++)
 46		{
 47			VFSBrowser.browseDirectoryInNewWindow(view,
 48				files[i].path);
 49		}
 50	</CODE>
 51</ACTION>
 52
 53<ACTION NAME="vfs.browser.close">
 54	<CODE>
 55		for(int i = 0; i &lt; files.length; i++)
 56		{
 57			Buffer buffer = jEdit.getBuffer(files[i].path);
 58			if(buffer != null)
 59				jEdit.closeBuffer(view,buffer);
 60		}
 61	</CODE>
 62</ACTION>
 63
 64<ACTION NAME="vfs.browser.copy-path">
 65	<CODE>
 66        org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable transferable =
 67            new org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable(files);
 68		Registers.setRegister('$',transferable);
 69	</CODE>
 70</ACTION>
 71
 72<ACTION NAME="vfs.browser.paste">
 73	<CODE>
 74        if (files.length != 1)
 75            return;
 76        org.gjt.sp.jedit.io.VFSFile file = files[0];
 77        String targetPath;
 78        switch (file.getType())
 79        {
 80            case org.gjt.sp.jedit.io.VFSFile.FILESYSTEM:
 81                return;
 82            case org.gjt.sp.jedit.io.VFSFile.FILE:
 83                targetPath = MiscUtilities.getParentOfPath(file.getPath());
 84                break;
 85            case org.gjt.sp.jedit.io.VFSFile.DIRECTORY:
 86                targetPath = file.getPath();
 87                break;
 88        }
 89
 90        java.awt.datatransfer.Transferable transferable = Registers.getRegister('$').getTransferable();
 91        if (transferable.isDataFlavorSupported(org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable.jEditFileList))
 92        {
 93            List copiedFiles = (List) transferable.getTransferData(org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable.jEditFileList);
 94            Iterator iterator = copiedFiles.iterator();
 95            while (iterator.hasNext())
 96            {
 97                org.gjt.sp.jedit.io.VFSFile f = (org.gjt.sp.jedit.io.VFSFile) iterator.next();
 98                if (f.getType() == org.gjt.sp.jedit.io.VFSFile.FILE)
 99                {
100                    ThreadUtilities.runInBackground(new CopyFileWorker(view, f.getPath(), targetPath));
101                }
102            }
103        }
104        else if (transferable.isDataFlavorSupported(java.awt.datatransfer.DataFlavor.javaFileListFlavor))
105        {
106            List copiedFiles = (List) transferable.getTransferData(java.awt.datatransfer.DataFlavor.javaFileListFlavor);
107            Iterator iterator = copiedFiles.iterator();
108            while (iterator.hasNext())
109            {
110                File f = (File) iterator.next();
111                if (f.isFile())
112                {
113                    ThreadUtilities.runInBackground(new CopyFileWorker(view, f.getAbsolutePath(), targetPath));
114                }
115            }
116        }
117	</CODE>
118</ACTION>
119
120<ACTION NAME="vfs.browser.delete">
121	<CODE>
122		if (files.length != 0)
123			browser.delete(files);
124	</CODE>
125</ACTION>
126
127<ACTION NAME="vfs.browser.home">
128	<CODE>
129		browser.setDirectory(System.getProperty("user.home"));
130	</CODE>
131</ACTION>
132
133<ACTION NAME="vfs.browser.insert">
134	<CODE>
135		browser.filesActivated(VFSBrowser.M_INSERT,false);
136	</CODE>
137</ACTION>
138
139<ACTION NAME="vfs.browser.new-directory">
140	<CODE>
141		browser.mkdir();
142	</CODE>
143</ACTION>
144
145<ACTION NAME="vfs.browser.new-file">
146	<CODE>
147		browser.newFile();
148	</CODE>
149</ACTION>
150
151<ACTION NAME="vfs.browser.open">
152	<CODE>
153		browser.filesActivated(VFSBrowser.M_OPEN,false);
154	</CODE>
155</ACTION>
156
157<ACTION NAME="vfs.browser.open-desktop">
158	<CODE>
159	if (files.length != 1) return;
160	f = new java.io.File(files[0].getPath());
161	if (!f.exists()) return;
162	cmd = null;
163	if (OperatingSystem.isWindows()) {
164		cmd = "rundll32 SHELL32.DLL,ShellExec_RunDLL " + 
165		"\"" + f.getCanonicalPath() + "\"";
166	}
167	else if (OperatingSystem.isMacOS()) {
168		cmd = "open " + f.getCanonicalPath();
169	}
170	else if (OperatingSystem.isX11()) {
171		cmd = "xdg-open " + f.getCanonicalPath();
172	}
173	else {
174		java.awt.Desktop.getDesktop().open(f);
175		return;
176	}
177	Runtime.getRuntime().exec(cmd);
178	</CODE>
179</ACTION>
180
181
182<ACTION NAME="vfs.browser.open-view">
183	<CODE>
184		browser.filesActivated(VFSBrowser.M_OPEN_NEW_VIEW,false);
185	</CODE>
186</ACTION>
187
188<ACTION NAME="vfs.browser.open-plain-view">
189	<CODE>
190		browser.filesActivated(VFSBrowser.M_OPEN_NEW_PLAIN_VIEW,false);
191	</CODE>
192</ACTION>
193
194<ACTION NAME="vfs.browser.open-split">
195	<CODE>
196		browser.filesActivated(VFSBrowser.M_OPEN_NEW_SPLIT,false);
197	</CODE>
198</ACTION>
199
200<ACTION NAME="vfs.browser.properties">
201	<CODE>
202	   	browser.fileProperties(files);
203	</CODE>
204</ACTION>
205
206<ACTION NAME="vfs.browser.reload">
207	<CODE>
208		browser.reloadDirectory();
209	</CODE>
210</ACTION>
211
212<ACTION NAME="vfs.browser.rename">
213	<CODE>
214		if (files.length != 0)
215			browser.rename(files[0]);
216	</CODE>
217</ACTION>
218
219<ACTION NAME="vfs.browser.roots">
220	<CODE>
221		browser.rootDirectory();
222	</CODE>
223</ACTION>
224
225<ACTION NAME="vfs.browser.search-directory">
226	<CODE>
227		browser.searchInDirectory();
228	</CODE>
229</ACTION>
230
231<ACTION NAME="vfs.browser.show-hidden-files">
232	<CODE>
233		browser.setShowHiddenFiles(!browser.getShowHiddenFiles());
234		browser.reloadDirectory();
235	</CODE>
236	<IS_SELECTED>
237		/* NOTE: I do NOT want plugins creating check box menu items
238		 * in jEdit 4.2! The API is not stable, note the _comp hack...
239		 * in 4.3 I will finish the full action API refactoring and
240		 * IS_SELECTED blocks in browser actions will have access to
241		 * the browser variable just like the CODE block above.
242		 *
243		 * Love, Slava */
244		VFSBrowser browser = GUIUtilities.getComponentParent(_comp,
245			VFSBrowser.class);
246		return browser.getShowHiddenFiles();
247		browser = null;
248	</IS_SELECTED>
249</ACTION>
250
251<ACTION NAME="vfs.browser.synchronize">
252	<CODE>
253		browser.setDirectory(view.getBuffer().getDirectory());
254	</CODE>
255</ACTION>
256
257<ACTION NAME="vfs.browser.up">
258	<CODE>
259		browser.setDirectory(MiscUtilities.getParentOfPath(
260			browser.getDirectory()));
261	</CODE>
262</ACTION>
263
264</ACTIONS>