Revision 7304 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/CopyPasteExtension.java
CopyPasteExtension.java | ||
---|---|---|
5 | 5 |
import java.awt.datatransfer.DataFlavor; |
6 | 6 |
import java.awt.datatransfer.StringSelection; |
7 | 7 |
import java.awt.datatransfer.UnsupportedFlavorException; |
8 |
import java.awt.event.ActionEvent; |
|
9 | 8 |
import java.io.IOException; |
10 | 9 |
import java.io.StringReader; |
11 | 10 |
import java.io.StringWriter; |
... | ... | |
17 | 16 |
import java.util.Iterator; |
18 | 17 |
import java.util.Map; |
19 | 18 |
|
20 |
import javax.swing.JMenuItem; |
|
21 | 19 |
import javax.swing.JOptionPane; |
22 | 20 |
|
23 | 21 |
import org.exolab.castor.xml.MarshalException; |
... | ... | |
36 | 34 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
37 | 35 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
38 | 36 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
39 |
import com.iver.cit.gvsig.gui.layout.fframes.IFFrame; |
|
40 |
import com.iver.cit.gvsig.gui.project.OpenException; |
|
41 |
import com.iver.cit.gvsig.gui.project.SaveException; |
|
42 |
import com.iver.cit.gvsig.gui.toc.AbstractTocContextMenuAction; |
|
43 |
import com.iver.cit.gvsig.gui.toc.FPopupMenu; |
|
44 |
import com.iver.cit.gvsig.gui.toc.ITocItem; |
|
45 |
import com.iver.cit.gvsig.gui.toc.TocMenuEntry; |
|
46 |
import com.iver.cit.gvsig.project.AbstractDocumentContextMenuAction; |
|
47 | 37 |
import com.iver.cit.gvsig.project.Project; |
48 |
import com.iver.cit.gvsig.project.ProjectElement; |
|
49 |
import com.iver.cit.gvsig.project.ProjectMap; |
|
50 |
import com.iver.cit.gvsig.project.ProjectTable; |
|
51 |
import com.iver.cit.gvsig.project.ProjectView; |
|
38 |
import com.iver.cit.gvsig.project.documents.AbstractDocumentContextMenuAction; |
|
39 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
|
40 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
|
41 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
|
42 |
import com.iver.cit.gvsig.project.documents.layout.ProjectMap; |
|
43 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
|
44 |
import com.iver.cit.gvsig.project.documents.table.ProjectTable; |
|
45 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
|
46 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
|
47 |
import com.iver.cit.gvsig.project.documents.view.toc.ITocItem; |
|
52 | 48 |
import com.iver.utiles.XMLEntity; |
53 | 49 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
54 | 50 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
... | ... | |
170 | 166 |
return 0; |
171 | 167 |
} |
172 | 168 |
|
173 |
public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
|
|
169 |
public boolean isVisible(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
174 | 170 |
return true; |
175 | 171 |
} |
176 | 172 |
|
177 |
public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
|
|
173 |
public boolean isEnabled(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
178 | 174 |
return selectedItems.length > 0; |
179 | 175 |
} |
180 | 176 |
|
181 | 177 |
|
182 |
public void execute(ProjectElement item, ProjectElement[] selectedItems) {
|
|
178 |
public void execute(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
183 | 179 |
XMLEntity xml = this.utiles.generateXMLCopyDocuments(selectedItems); |
184 | 180 |
if (xml == null) { |
185 | 181 |
JOptionPane.showMessageDialog( |
... | ... | |
221 | 217 |
return 1; |
222 | 218 |
} |
223 | 219 |
|
224 |
public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
|
|
220 |
public boolean isVisible(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
225 | 221 |
return true; |
226 | 222 |
} |
227 | 223 |
|
228 |
public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
|
|
224 |
public boolean isEnabled(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
229 | 225 |
return selectedItems.length > 0; |
230 | 226 |
} |
231 | 227 |
|
232 | 228 |
|
233 |
public void execute(ProjectElement item, ProjectElement[] selectedItems) {
|
|
229 |
public void execute(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
234 | 230 |
XMLEntity xml = this.utiles.generateXMLCopyDocuments(selectedItems); |
235 | 231 |
if (xml == null) { |
236 | 232 |
JOptionPane.showMessageDialog( |
... | ... | |
292 | 288 |
return this.type; |
293 | 289 |
} |
294 | 290 |
|
295 |
public boolean isVisible(ProjectElement item, ProjectElement[] selectedItems) {
|
|
291 |
public boolean isVisible(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
296 | 292 |
return true; |
297 | 293 |
} |
298 | 294 |
|
299 |
public boolean isEnabled(ProjectElement item, ProjectElement[] selectedItems) {
|
|
295 |
public boolean isEnabled(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
300 | 296 |
String sourceString = this.utiles.getFromClipboard(); |
301 | 297 |
if (sourceString == null) return false; |
302 | 298 |
|
... | ... | |
310 | 306 |
} |
311 | 307 |
|
312 | 308 |
|
313 |
public void execute(ProjectElement item, ProjectElement[] selectedItems) {
|
|
309 |
public void execute(ProjectDocument item, ProjectDocument[] selectedItems) {
|
|
314 | 310 |
String sourceString = this.utiles.getFromClipboard(); |
315 | 311 |
if (sourceString == null) return; |
316 | 312 |
|
... | ... | |
584 | 580 |
* para copiar los elementos de selectedItems en |
585 | 581 |
* otro proyecto |
586 | 582 |
*/ |
587 |
public XMLEntity generateXMLCopyDocuments(ProjectElement[] selectedItems) {
|
|
583 |
public XMLEntity generateXMLCopyDocuments(ProjectDocument[] selectedItems) {
|
|
588 | 584 |
if (selectedItems.length == 0) return null; |
589 | 585 |
|
590 | 586 |
if (selectedItems[0] instanceof ProjectView) { |
... | ... | |
763 | 759 |
|
764 | 760 |
Project project = this.getProject(); |
765 | 761 |
|
766 |
Hashtable viewsConflits = this.getConflicts(xmlViews,project.getViews());
|
|
762 |
Hashtable viewsConflits = this.getConflicts(xmlViews,project.getDocuments("ProjectView"));
|
|
767 | 763 |
|
768 |
Hashtable tablesConflits = this.getConflicts(xmlTables,project.getTables());
|
|
764 |
Hashtable tablesConflits = this.getConflicts(xmlTables,project.getDocuments("ProjectTable"));
|
|
769 | 765 |
|
770 | 766 |
if (viewsConflits != null && viewsConflits.size() > 0) { |
771 | 767 |
int option = JOptionPane.showConfirmDialog( |
... | ... | |
880 | 876 |
|
881 | 877 |
Project project = this.getProject(); |
882 | 878 |
|
883 |
Hashtable mapsConflits = this.getConflicts(xmlMaps,project.getMaps());
|
|
879 |
Hashtable mapsConflits = this.getConflicts(xmlMaps,project.getDocuments("ProjectMap"));
|
|
884 | 880 |
|
885 |
Hashtable viewsConflits = this.getConflicts(xmlViews,project.getViews());
|
|
881 |
Hashtable viewsConflits = this.getConflicts(xmlViews,project.getDocuments("ProjectView"));
|
|
886 | 882 |
|
887 |
Hashtable tablesConflits = this.getConflicts(xmlTables,project.getTables());
|
|
883 |
Hashtable tablesConflits = this.getConflicts(xmlTables,project.getDocuments("ProjectTable"));
|
|
888 | 884 |
|
889 | 885 |
|
890 | 886 |
if (mapsConflits != null && mapsConflits.size() > 0) { |
... | ... | |
1113 | 1109 |
XMLEntity child = xml.getChild(iXML); |
1114 | 1110 |
Iterator iter = elements.iterator(); |
1115 | 1111 |
while (iter.hasNext()) { |
1116 |
ProjectElement element = (ProjectElement)iter.next();
|
|
1112 |
ProjectDocument element = (ProjectDocument)iter.next();
|
|
1117 | 1113 |
if (element.getName().equalsIgnoreCase(child.getStringProperty("name"))) { |
1118 | 1114 |
conflits.put(new Integer(iXML),child); |
1119 | 1115 |
break; |
... | ... | |
1187 | 1183 |
for (int i = 0; i < numTables; i++) { |
1188 | 1184 |
try{ |
1189 | 1185 |
ProjectTable ptable = (ProjectTable) ProjectTable.createFromXML(xmlTables.getChild(i), project); |
1190 |
project.addTable(ptable);
|
|
1186 |
project.addDocument(ptable);
|
|
1191 | 1187 |
/* |
1192 | 1188 |
if (ptable.getSeedViewInfo()!=null && ptable.getAndamiView()!=null) { // open the view, if it was open, and restore its dimensions |
1193 | 1189 |
PluginServices.getMDIManager().addView(ptable.getAndamiView()); |
... | ... | |
1247 | 1243 |
child = xmlViews.getChild(i); |
1248 | 1244 |
|
1249 | 1245 |
ProjectView pv = (ProjectView) ProjectView.createFromXML(child, project); |
1250 |
project.addView(pv);
|
|
1246 |
project.addDocument(pv);
|
|
1251 | 1247 |
|
1252 | 1248 |
} |
1253 | 1249 |
return true; |
... | ... | |
1267 | 1263 |
child = xmlMaps.getChild(i); |
1268 | 1264 |
|
1269 | 1265 |
ProjectMap pm = (ProjectMap) ProjectMap.createFromXML(child, project); |
1270 |
project.addMap(pm);
|
|
1266 |
project.addDocument(pm);
|
|
1271 | 1267 |
|
1272 | 1268 |
} |
1273 | 1269 |
return true; |
... | ... | |
1493 | 1489 |
Project project = ((ProjectExtension)PluginServices.getExtension(ProjectExtension.class)).getProject(); |
1494 | 1490 |
ProjectTable pt = project.getTable((AlphanumericData) actives[i]); |
1495 | 1491 |
|
1496 |
ArrayList tables = project.getTables();
|
|
1492 |
ArrayList tables = project.getDocuments("ProjectTable");
|
|
1497 | 1493 |
for (int j = 0; j < tables.size(); j++) { |
1498 | 1494 |
if (tables.get(j) == pt){ |
1499 |
project.delTable(j);
|
|
1495 |
project.delDocument((ProjectDocument)tables.get(j));
|
|
1500 | 1496 |
break; |
1501 | 1497 |
} |
1502 | 1498 |
} |
... | ... | |
1513 | 1509 |
return true; |
1514 | 1510 |
} |
1515 | 1511 |
|
1516 |
public boolean removeDocuments(ProjectElement[] selectedItems) {
|
|
1512 |
public boolean removeDocuments(ProjectDocument[] selectedItems) {
|
|
1517 | 1513 |
Project p = this.getProject(); |
1518 |
ProjectElement element;
|
|
1514 |
ProjectDocument element;
|
|
1519 | 1515 |
int index; |
1520 | 1516 |
for (int i=selectedItems.length-1;i>=0;i--) { |
1521 | 1517 |
|
... | ... | |
1531 | 1527 |
//return false; |
1532 | 1528 |
} else { |
1533 | 1529 |
PluginServices.getMDIManager().closeSingletonWindow(element); |
1534 |
p.delMap(p.getMaps().indexOf(element));
|
|
1530 |
p.delDocument(element);
|
|
1535 | 1531 |
} |
1536 | 1532 |
} else if (element instanceof ProjectTable) { |
1537 | 1533 |
if (element.isLocked()) { |
... | ... | |
1543 | 1539 |
//return false; |
1544 | 1540 |
} else { |
1545 | 1541 |
PluginServices.getMDIManager().closeSingletonWindow(element); |
1546 |
p.delTable(p.getTables().indexOf(element));
|
|
1542 |
p.delDocument(element);
|
|
1547 | 1543 |
} |
1548 | 1544 |
} else { |
1549 | 1545 |
if (element.isLocked()) { |
... | ... | |
1554 | 1550 |
//return false; |
1555 | 1551 |
} else { |
1556 | 1552 |
PluginServices.getMDIManager().closeSingletonWindow(element); |
1557 |
p.delView(p.getViews().indexOf(element));
|
|
1553 |
p.delDocument(element);
|
|
1558 | 1554 |
} |
1559 | 1555 |
} |
1560 | 1556 |
} |
Also available in: Unified diff