01: package com.vividsolutions.jump.workbench.ui.style;
02:
03: import com.vividsolutions.jump.I18N;
04: import com.vividsolutions.jump.workbench.WorkbenchContext;
05: import com.vividsolutions.jump.workbench.model.Layer;
06: import com.vividsolutions.jump.workbench.plugin.AbstractPlugIn;
07: import com.vividsolutions.jump.workbench.plugin.EnableCheckFactory;
08: import com.vividsolutions.jump.workbench.plugin.MultiEnableCheck;
09: import com.vividsolutions.jump.workbench.plugin.PlugInContext;
10:
11: /**
12: * Pastes the styles from the internal style paste buffer to a layer
13: * @author Martin Davis
14: * @version 1.0
15: */
16:
17: public class PasteStylesPlugIn extends AbstractPlugIn {
18:
19: public static MultiEnableCheck createEnableCheck(
20: final WorkbenchContext workbenchContext) {
21: EnableCheckFactory checkFactory = new EnableCheckFactory(
22: workbenchContext);
23: return new MultiEnableCheck()
24: .add(
25: checkFactory
26: .createWindowWithLayerNamePanelMustBeActiveCheck())
27: .add(
28: checkFactory
29: .createAtLeastNLayersMustBeSelectedCheck(1));
30: }
31:
32: public PasteStylesPlugIn() {
33: }
34:
35: public String getName() {
36: return I18N.get("ui.style.PasteStylesPlugIn.paste-styles");
37: }
38:
39: public boolean execute(PlugInContext context) throws Exception {
40: if (CopyStylesPlugIn.stylesBuffer == null)
41: return false;
42: Layer[] selectedLayers = context.getSelectedLayers();
43: for (int i = 0; i < selectedLayers.length; i++) {
44: pasteStyles(selectedLayers[i]);
45: }
46: return true;
47: }
48:
49: private void pasteStyles(Layer layer) {
50: layer.setStyles(CopyStylesPlugIn.stylesBuffer);
51: }
52: }
|