root / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / view / toc / actions / CopyLayersTocMenuEntry.java @ 29598
History | View | Annotate | Download (2.05 KB)
1 |
package org.gvsig.app.project.documents.view.toc.actions; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import org.gvsig.andami.PluginServices; |
8 |
import org.gvsig.app.extension.ProjectExtension; |
9 |
import org.gvsig.app.project.Project; |
10 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
11 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
12 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
13 |
import org.gvsig.utils.XMLEntity; |
14 |
|
15 |
|
16 |
public class CopyLayersTocMenuEntry extends AbstractTocContextMenuAction { |
17 |
private CopyPasteLayersUtiles utiles = CopyPasteLayersUtiles.getInstance();
|
18 |
|
19 |
public String getGroup() { |
20 |
return "copyPasteLayer"; |
21 |
} |
22 |
|
23 |
public int getGroupOrder() { |
24 |
return 60; |
25 |
} |
26 |
|
27 |
public int getOrder() { |
28 |
return 0; |
29 |
} |
30 |
|
31 |
public String getText() { |
32 |
return PluginServices.getText(this, "copiar"); |
33 |
} |
34 |
|
35 |
public boolean isEnabled(ITocItem item, FLayer[] selectedItems) { |
36 |
if ( selectedItems.length >= 1 && isTocItemBranch(item)){ |
37 |
for (int i=0;i< selectedItems.length;i++) { |
38 |
if (selectedItems[i].isEditing()){
|
39 |
return false; |
40 |
} |
41 |
} |
42 |
return true; |
43 |
} |
44 |
return false; |
45 |
|
46 |
} |
47 |
|
48 |
|
49 |
public void execute(ITocItem item, FLayer[] selectedItems) { |
50 |
XMLEntity xml = this.utiles.generateXMLCopyLayers(selectedItems);
|
51 |
if (xml == null) { |
52 |
JOptionPane.showMessageDialog(
|
53 |
(Component)PluginServices.getMainFrame(),
|
54 |
"<html>"+PluginServices.getText(this,"No_ha_sido_posible_realizar_la_operacion")+"</html>",//Mensaje |
55 |
PluginServices.getText(this,"copiar"),//titulo |
56 |
JOptionPane.ERROR_MESSAGE
|
57 |
); |
58 |
return;
|
59 |
} |
60 |
|
61 |
String data = xml.toString();
|
62 |
if (data == null) { |
63 |
JOptionPane.showMessageDialog(
|
64 |
(Component)PluginServices.getMainFrame(),
|
65 |
"<html>"+PluginServices.getText(this,"No_ha_sido_posible_realizar_la_operacion")+"</html>",//Mensaje |
66 |
PluginServices.getText(this,"copiar"),//titulo |
67 |
JOptionPane.ERROR_MESSAGE
|
68 |
); |
69 |
return;
|
70 |
} |
71 |
|
72 |
PluginServices.putInClipboard(data); |
73 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
74 |
project.setModified(true);
|
75 |
} |
76 |
|
77 |
|
78 |
} |