Revision 40971 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/project/documents/actions/CutDocumentAction.java

View differences:

CutDocumentAction.java
29 29

  
30 30
import javax.swing.JOptionPane;
31 31

  
32
import org.slf4j.Logger;
33
import org.slf4j.LoggerFactory;
34

  
32 35
import org.gvsig.andami.PluginServices;
36
import org.gvsig.app.ApplicationLocator;
33 37
import org.gvsig.app.project.Project;
34 38
import org.gvsig.app.project.ProjectManager;
35 39
import org.gvsig.app.project.documents.AbstractDocumentAction;
36 40
import org.gvsig.app.project.documents.Document;
41
import org.gvsig.i18n.Messages;
37 42

  
38 43

  
39 44
public class CutDocumentAction extends AbstractDocumentAction {
40 45
	
46
    private static Logger logger = LoggerFactory.getLogger(
47
        CutDocumentAction.class);
48
    
41 49
	public CutDocumentAction() {
42 50
		super("cut");
43 51
		this.order = 0;
......
59 67
	}
60 68

  
61 69
	public void execute(Document document, List<Document> documents) {
62
		
70

  
71
        List<Document> docs = new ArrayList<Document>(documents);
72
        if(document != null &&   !docs.contains(document)) {
73
            docs.add(document);
74
        }
75
        // Now "docs" has all docs involved
76
        try {
77
            CopyPasteDocsUtils.saveToClipboard(docs);
78
        } catch (Exception e) {
79
            
80
            logger.info("While copying docs to clipboard in cut operation.", e);
81
            JOptionPane.showMessageDialog(
82
                ApplicationLocator.getManager().getRootComponent(),
83
                Messages.getText("_Clipboard_error") + ":\n"
84
                + CopyPasteDocsUtils.getLastMessage(e),
85
                title,
86
                JOptionPane.ERROR_MESSAGE);
87
            /*
88
             * Clear clipboard after error
89
             */
90
            try {
91
                CopyPasteDocsUtils.clearClipboard(null);
92
            } catch (Exception exc) {
93
                logger.error("While clearing clipboard.", exc);
94
            }
95
        }
96
        
97
	    // ==================================================
98
	    
63 99
		Project project = ProjectManager.getInstance().getCurrentProject();
64
		
65
		List<Document> docs = new ArrayList<Document>(documents);
66
		if( !docs.contains(documents)) {
67
			docs.add(document);
68
		}
69
		String data = project.exportDocumentsAsText(docs);
70
		PluginServices.putInClipboard(data);
71

  
72

  
73
		for (Document doc : documents) {
100
		for (Document doc : docs) {
74 101
			if (doc.isLocked()) {
75 102
				JOptionPane.showMessageDialog(
76 103
						(Component)PluginServices.getMainFrame(),
......
88 115
    		return;
89 116
    	}
90 117

  
91
		this.removeDocuments(documents,project);
118
		this.removeDocuments(docs,project);
92 119

  
93 120
	}
94 121

  

Also available in: Unified diff