01: package com.vividsolutions.jump.workbench.ui.style;
02:
03: import java.util.Collection;
04:
05: import com.vividsolutions.jump.I18N;
06: import com.vividsolutions.jump.workbench.WorkbenchContext;
07: import com.vividsolutions.jump.workbench.model.Layer;
08: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
09: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
10: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
11: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
12:
13: /**
14: * Copies the styles for a layer to a paste buffer
15: * @author Martin Davis
16: * @version 1.0
17: */
18:
19: public class CopyStylesPlugIn extends AbstractPlugIn {
20:
21: static Collection stylesBuffer = null;
22:
23: public CopyStylesPlugIn() {
24: }
25:
26: public String getName() {
27: return I18N.get("ui.style.CopyStylesPlugIn.copy-styles");
28: }
29:
30: public static MultiEnableCheck createEnableCheck(
31: final WorkbenchContext workbenchContext) {
32: EnableCheckFactory checkFactory = new EnableCheckFactory(
33: workbenchContext);
34: return new MultiEnableCheck()
35: .add(
36: checkFactory
37: .createWindowWithLayerNamePanelMustBeActiveCheck())
38: .add(
39: checkFactory
40: .createExactlyNLayersMustBeSelectedCheck(1));
41: }
42:
43: public boolean execute(PlugInContext context) throws Exception {
44: final Layer layer = context.getSelectedLayer(0);
45: stylesBuffer = layer.cloneStyles();
46: return true;
47: }
48: }
|