svn-gvsig-desktop / trunk / applications / appgvSIG / src / com / iver / cit / gvsig / project / documents / contextMenu / actions / PasteDocumentContextMenuAction.java @ 9532
History | View | Annotate | Download (1.99 KB)
1 |
package com.iver.cit.gvsig.project.documents.contextMenu.actions; |
---|---|
2 |
|
3 |
import java.awt.Component; |
4 |
|
5 |
import javax.swing.JOptionPane; |
6 |
|
7 |
import com.iver.andami.PluginServices; |
8 |
import com.iver.cit.gvsig.ProjectExtension; |
9 |
import com.iver.cit.gvsig.project.Project; |
10 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
11 |
import com.iver.cit.gvsig.project.documents.gui.ProjectWindow; |
12 |
|
13 |
public class PasteDocumentContextMenuAction extends |
14 |
AbstractClipboardDocumentContextMenuAction { |
15 |
|
16 |
public int getOrder() { |
17 |
return 2; |
18 |
} |
19 |
|
20 |
public boolean isVisible(ProjectDocument item, ProjectDocument[] selectedItems) { |
21 |
return true; |
22 |
} |
23 |
|
24 |
public boolean isEnabled(ProjectDocument item, ProjectDocument[] selectedItems) { |
25 |
String sourceString = PluginServices.getFromClipboard();
|
26 |
if (sourceString == null) return false; |
27 |
|
28 |
ProjectExtension projectExtension = (ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
29 |
Project project = projectExtension.getProject(); |
30 |
String docType = ((ProjectWindow)projectExtension.getProjectWindow()).getDocumentSelected();
|
31 |
|
32 |
return project.isValidXMLForImport(sourceString,docType);
|
33 |
} |
34 |
|
35 |
|
36 |
public void execute(ProjectDocument item, ProjectDocument[] selectedItems) { |
37 |
String sourceString = PluginServices.getFromClipboard();
|
38 |
if (sourceString == null) return; |
39 |
|
40 |
ProjectExtension projectExtension = (ProjectExtension)PluginServices.getExtension(ProjectExtension.class); |
41 |
Project project = projectExtension.getProject(); |
42 |
String docType = ((ProjectWindow)projectExtension.getProjectWindow()).getDocumentSelected();
|
43 |
|
44 |
try {
|
45 |
project.importFromXML(sourceString,docType); |
46 |
} catch (Exception e) { |
47 |
JOptionPane.showMessageDialog(
|
48 |
(Component)PluginServices.getMainFrame(),
|
49 |
"<html>"+PluginServices.getText(this,"No_ha_sido_posible_realizar_la_operacion")+"</html>",//Mensaje |
50 |
PluginServices.getText(this,"pegar"),//titulo |
51 |
JOptionPane.ERROR_MESSAGE
|
52 |
); |
53 |
} |
54 |
project.setModified(true);
|
55 |
} |
56 |
|
57 |
public String getText() { |
58 |
return PluginServices.getText(this, "pegar"); |
59 |
} |
60 |
|
61 |
|
62 |
|
63 |
} |