Difference between revisions of "Beanshell:Chain Copy/Paste/Move using PlugIns and CursorTool"

From OpenJUMP Wiki
Jump to navigation Jump to search
(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…')
 
(No difference)

Latest revision as of 07:53, 13 May 2011

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));