Revision 39136 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/view/toc/actions/CopyLayersTocMenuEntry.java
CopyLayersTocMenuEntry.java | ||
---|---|---|
4 | 4 |
|
5 | 5 |
import javax.swing.JOptionPane; |
6 | 6 |
|
7 |
import org.slf4j.Logger; |
|
8 |
import org.slf4j.LoggerFactory; |
|
9 |
|
|
7 | 10 |
import org.gvsig.andami.PluginServices; |
8 |
import org.gvsig.app.extension.ProjectExtension; |
|
9 |
import org.gvsig.app.project.Project; |
|
10 | 11 |
import org.gvsig.app.project.documents.view.toc.AbstractTocContextMenuAction; |
11 | 12 |
import org.gvsig.app.project.documents.view.toc.ITocItem; |
12 | 13 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
13 |
import org.gvsig.utils.XMLEntity; |
|
14 |
import org.gvsig.i18n.Messages; |
|
15 |
import org.gvsig.tools.persistence.PersistentState; |
|
14 | 16 |
|
15 | 17 |
|
16 | 18 |
public class CopyLayersTocMenuEntry extends AbstractTocContextMenuAction { |
17 |
private CopyPasteLayersUtiles utiles = CopyPasteLayersUtiles.getInstance(); |
|
18 |
|
|
19 |
|
|
20 |
private static Logger logger = |
|
21 |
LoggerFactory.getLogger(CopyLayersTocMenuEntry.class); |
|
22 |
|
|
19 | 23 |
public String getGroup() { |
20 | 24 |
return "copyPasteLayer"; |
21 | 25 |
} |
... | ... | |
47 | 51 |
|
48 | 52 |
|
49 | 53 |
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 | 54 |
|
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 |
} |
|
55 |
PersistentState lyrs_state = null; |
|
56 |
|
|
57 |
try { |
|
58 |
lyrs_state = CopyPasteLayersUtils.getAsFLayersPersistentState( |
|
59 |
selectedItems, this.getMapContext()); |
|
60 |
/* |
|
61 |
* Saving layers data to clipboard. |
|
62 |
* Files and URLs are not relativized |
|
63 |
*/ |
|
64 |
CopyPasteLayersUtils.saveToClipboard(lyrs_state); |
|
65 |
|
|
66 |
/* |
|
67 |
* This code does not look right: why modified? |
|
68 |
* |
|
69 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
|
70 |
project.setModified(true); |
|
71 |
*/ |
|
71 | 72 |
|
72 |
PluginServices.putInClipboard(data); |
|
73 |
Project project=((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
|
74 |
project.setModified(true); |
|
73 |
} catch (Exception e) { |
|
74 |
|
|
75 |
JOptionPane.showMessageDialog( |
|
76 |
(Component)PluginServices.getMainFrame(), |
|
77 |
Messages.getText("No_ha_sido_posible_realizar_la_operacion") |
|
78 |
+ "\n\n" + e.getMessage(), |
|
79 |
Messages.getText("copiar"), |
|
80 |
JOptionPane.ERROR_MESSAGE |
|
81 |
); |
|
82 |
logger.info("While copying layers.", e); |
|
83 |
return; |
|
84 |
} |
|
75 | 85 |
} |
76 | 86 |
|
77 | 87 |
|
Also available in: Unified diff