<?xml version="1.0"?>

<!DOCTYPE ACTIONS SYSTEM "actions.dtd">

<!-- VFS browser action table                                                -->
<!-- Copyright (C) 2003 Slava Pestov                                         -->

<!-- :tabSize=8:indentSize=8:noTabs=false:                                   -->
<!-- :folding=indent:collapseFolds=1:mode=jedit-actions:		     -->

<!-- Actions are the 'glue' that binds menu item selections and keystrokes   -->
<!-- to jEdit's APIs. For simplicity and compactness, they are written in    -->
<!-- the BeanShell scripting language.                                       -->

<ACTIONS>

<ACTION NAME="vfs.browser.browse">
	<CODE>
		if (files.length != 0)
			browser.setDirectory(files[0].path);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.previous">
	<CODE>
		browser.previousDirectory();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.next">
	<CODE>
		browser.nextDirectory();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.closedialog">
	<CODE>
		browser.dispose();
	</CODE>
</ACTION>


<ACTION NAME="vfs.browser.browse-window">
	<CODE>
		for(int i = 0; i &lt; files.length; i++)
		{
			VFSBrowser.browseDirectoryInNewWindow(view,
				files[i].path);
		}
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.close">
	<CODE>
		for(int i = 0; i &lt; files.length; i++)
		{
			Buffer buffer = jEdit.getBuffer(files[i].path);
			if(buffer != null)
				jEdit.closeBuffer(view,buffer);
		}
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.copy-path">
	<CODE>
        org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable transferable =
            new org.gjt.sp.jedit.datatransfer.ListVFSFileTransferable(files);
		Registers.setRegister('$',transferable);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.paste">
	<CODE>
        if (files.length != 1)
            return;
	browser.paste(files[0]);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.delete">
	<CODE>
		if (files.length != 0)
			browser.delete(files);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.home">
	<CODE>
		browser.setDirectory(System.getProperty("user.home"));
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.insert">
	<CODE>
		browser.filesActivated(VFSBrowser.M_INSERT,false);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.new-directory">
	<CODE>
		browser.mkdir();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.new-file">
	<CODE>
		browser.newFile();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.open">
	<CODE>
		browser.filesActivated(VFSBrowser.M_OPEN,false);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.open-desktop">
	<CODE>
	if (files.length != 1) return;
	MiscUtilities.openInDesktop(files[0].getPath());
	</CODE>
</ACTION>


<ACTION NAME="vfs.browser.open-view">
	<CODE>
		browser.filesActivated(VFSBrowser.M_OPEN_NEW_VIEW,false);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.open-plain-view">
	<CODE>
		browser.filesActivated(VFSBrowser.M_OPEN_NEW_PLAIN_VIEW,false);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.open-split">
	<CODE>
		browser.filesActivated(VFSBrowser.M_OPEN_NEW_SPLIT,false);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.properties">
	<CODE>
	   	browser.fileProperties(files);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.reload">
	<CODE>
		browser.reloadDirectory();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.rename">
	<CODE>
		if (files.length != 0)
			browser.rename(files[0]);
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.roots">
	<CODE>
		browser.rootDirectory();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.search-directory">
	<CODE>
		browser.searchInDirectory();
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.show-hidden-files">
	<CODE>
		browser.setShowHiddenFiles(!browser.getShowHiddenFiles());
		browser.reloadDirectory();
	</CODE>
	<IS_SELECTED>
		/* NOTE: I do NOT want plugins creating check box menu items
		 * in jEdit 4.2! The API is not stable, note the _comp hack...
		 * in 4.3 I will finish the full action API refactoring and
		 * IS_SELECTED blocks in browser actions will have access to
		 * the browser variable just like the CODE block above.
		 *
		 * Love, Slava */
		VFSBrowser browser = GUIUtilities.getComponentParent(_comp,
			VFSBrowser.class);
		return browser.getShowHiddenFiles();
		browser = null;
	</IS_SELECTED>
</ACTION>

<ACTION NAME="vfs.browser.synchronize">
	<CODE>
		browser.setDirectory(view.getBuffer().getDirectory());
	</CODE>
</ACTION>

<ACTION NAME="vfs.browser.up">
	<CODE>
		browser.setDirectory(MiscUtilities.getParentOfPath(
			browser.getDirectory()));
	</CODE>
</ACTION>

</ACTIONS>
