Beanshell:Chain Copy/Paste/Move using PlugIns and CursorTool

From OpenJUMP Wiki
Revision as of 07:53, 13 May 2011 by Michaudm (talk | contribs) (Created page with 'Here is how you can use existing PlugIns or CursorTools to chain actions in a simple script <pre> // Import packages (you can also call classes directly using their full name) i…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Here is how you can use existing PlugIns or CursorTools to chain actions in a simple script

// Import packages (you can also call classes directly using their full name)
import com.vividsolutions.jump.workbench.ui.plugin.clipboard.*;
import com.vividsolutions.jump.workbench.ui.cursortool.editing.*;

// Get PlugIn context from WorkbenchContext
context = wc.createPlugInContext();

// Execute CopySelectedItemsPlugIn
new CopySelectedItemsPlugIn().execute(context);

// Notify the system that you're starting an undoable action
// (needed by the PasteItemsPlugIn)
wc.layerManager.undoableEditReceiver.startReceiving();

// Execute PasteItemsPlugIn
new PasteItemsPlugIn().execute(context);

// Set a new MoveSelectedItemsTool as the current CursorTool
// of the layerViewPanel
wc.layerViewPanel.setCurrentCursorTool(new MoveSelectedItemsTool(context.checkFactory));