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