Revision 24759 branches/v2_0_0_prep/applications/appgvSIG/src/com/iver/cit/gvsig/project/Project.java
Project.java | ||
---|---|---|
60 | 60 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
61 | 61 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
62 | 62 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
63 |
import org.gvsig.tools.exception.DriverException; |
|
63 | 64 |
|
64 | 65 |
import com.iver.andami.PluginServices; |
65 | 66 |
import com.iver.andami.messages.NotificationManager; |
... | ... | |
166 | 167 |
.getProjectDocumentFactory().getPriority(); |
167 | 168 |
int priority2 = ((ProjectDocument) o2) |
168 | 169 |
.getProjectDocumentFactory().getPriority(); |
169 |
if (priority1 >= priority2) |
|
170 |
if (priority1 >= priority2) {
|
|
170 | 171 |
return 1; |
172 |
} |
|
171 | 173 |
return -1; |
172 | 174 |
} |
173 | 175 |
return 0; |
... | ... | |
294 | 296 |
} |
295 | 297 |
|
296 | 298 |
private boolean isModifiedDocuments() { |
297 |
ProjectDocument[] documents=(ProjectDocument[])getDocuments().toArray(new ProjectDocument[0]);
|
|
299 |
ProjectDocument[] documents=getDocuments().toArray(new ProjectDocument[0]); |
|
298 | 300 |
for (int i=0;i<documents.length;i++) { |
299 | 301 |
if (documents[i].isModified()) { |
300 | 302 |
return true; |
... | ... | |
386 | 388 |
public void setModified(boolean b) { |
387 | 389 |
modified = b; |
388 | 390 |
if (modified==false) { |
389 |
ProjectDocument[] documents=(ProjectDocument[])getDocuments().toArray(new ProjectDocument[0]);
|
|
391 |
ProjectDocument[] documents=getDocuments().toArray(new ProjectDocument[0]); |
|
390 | 392 |
for (int i=0;i<documents.length;i++) { |
391 | 393 |
documents[i].setModified(false); |
392 | 394 |
} |
... | ... | |
515 | 517 |
* @return lista de objetos de tipo camera |
516 | 518 |
*/ |
517 | 519 |
public Object[] getCameras() { |
518 |
return (Object[]) this.cameras.toArray(new Object[0]);
|
|
520 |
return this.cameras.toArray(new Object[0]); |
|
519 | 521 |
} |
520 | 522 |
|
521 | 523 |
/** |
... | ... | |
676 | 678 |
int numDocuments = 0; |
677 | 679 |
for (int i = 0; i < documents.size(); i++) { |
678 | 680 |
try { |
679 |
XMLEntity xmlchild = ((ProjectDocument) documents.get(i))
|
|
681 |
XMLEntity xmlchild = (documents.get(i)) |
|
680 | 682 |
.getXMLEntity(); |
681 | 683 |
xmlchild.putProperty("tagName","document"+i); |
682 | 684 |
xml.addChild(xmlchild); |
... | ... | |
872 | 874 |
} |
873 | 875 |
|
874 | 876 |
// try to open the views |
875 |
if (xml.contains("numExtents")) |
|
877 |
if (xml.contains("numExtents")) {
|
|
876 | 878 |
childNumb += xml.getIntProperty("numExtents"); |
877 |
if (xml.contains("data-source-count")) |
|
879 |
} |
|
880 |
if (xml.contains("data-source-count")) { |
|
878 | 881 |
childNumb += xml.getIntProperty("data-source-count"); |
882 |
} |
|
879 | 883 |
int limit = 0; |
880 |
if (xml.contains("numViews")) |
|
884 |
if (xml.contains("numViews")) {
|
|
881 | 885 |
limit = xml.getIntProperty("numViews")+childNumb; |
886 |
} |
|
882 | 887 |
|
883 | 888 |
XMLEntity view; |
884 | 889 |
for (int i = childNumb; i < limit; i++) { |
... | ... | |
898 | 903 |
} |
899 | 904 |
} |
900 | 905 |
|
901 |
if (xml.contains("numViews")) |
|
906 |
if (xml.contains("numViews")) {
|
|
902 | 907 |
childNumb += xml.getIntProperty("numViews"); |
908 |
} |
|
903 | 909 |
|
904 |
if (xml.contains("numMaps")) |
|
910 |
if (xml.contains("numMaps")) {
|
|
905 | 911 |
limit = childNumb + xml.getIntProperty("numMaps"); |
912 |
} |
|
906 | 913 |
|
907 | 914 |
// try to open the maps |
908 | 915 |
XMLEntity map; |
... | ... | |
950 | 957 |
"ViewInfoProperties") |
951 | 958 |
&& child.contains("documentType")) { |
952 | 959 |
boolean isClosed = true; |
953 |
if (child.contains("isClosed")) |
|
960 |
if (child.contains("isClosed")) {
|
|
954 | 961 |
isClosed = child.getBooleanProperty("isClosed"); |
962 |
} |
|
955 | 963 |
if (isClosed == false) { |
956 | 964 |
WindowInfo windowProps = WindowInfo |
957 | 965 |
.createFromXMLEntity(child); |
... | ... | |
961 | 969 |
.getStringProperty("documentType"); |
962 | 970 |
ProjectDocument pd = this.getProjectDocumentByName( |
963 | 971 |
documentName, documentType); |
964 |
if (pd==null) continue; |
|
972 |
if (pd==null) { |
|
973 |
continue; |
|
974 |
} |
|
965 | 975 |
IWindow win = null; |
966 | 976 |
if (pd instanceof ProjectDocument |
967 | 977 |
&& child.getChildrenCount()>0 |
... | ... | |
970 | 980 |
WindowData windowData = new WindowData(); |
971 | 981 |
windowData.setXMLEntity(child.getChild(0)); |
972 | 982 |
pd.storeWindowData(windowData); |
973 |
win = ((ProjectDocument)pd).createWindow();
|
|
983 |
win = (pd).createWindow(); |
|
974 | 984 |
} else { |
975 | 985 |
win = pd.createWindow(); |
976 | 986 |
} |
... | ... | |
1052 | 1062 |
|
1053 | 1063 |
// Recogiendo el numero de cameras |
1054 | 1064 |
int numCameras = 0; |
1055 |
if (xml.contains("numCameras")) |
|
1065 |
if (xml.contains("numCameras")) {
|
|
1056 | 1066 |
numCameras = xml.getIntProperty("numCameras"); |
1067 |
} |
|
1057 | 1068 |
|
1058 | 1069 |
// Recogiendo todo las camaras |
1059 | 1070 |
for (int i = childNumber; i < (childNumber + numCameras); i++) { |
... | ... | |
1101 | 1112 |
e.showMessageError(childXML.getName()+"\n "+childXML.getStringProperty("className")); |
1102 | 1113 |
} |
1103 | 1114 |
} |
1104 |
ProjectDocument[] sortDocKeys = (ProjectDocument[]) p.sortedDocuments
|
|
1115 |
ProjectDocument[] sortDocKeys = p.sortedDocuments |
|
1105 | 1116 |
.keySet().toArray(new ProjectDocument[0]); |
1106 |
Integer[] sortDocValues = (Integer[]) p.sortedDocuments.values()
|
|
1117 |
Integer[] sortDocValues = p.sortedDocuments.values() |
|
1107 | 1118 |
.toArray(new Integer[0]); |
1108 | 1119 |
|
1109 | 1120 |
i=0; |
... | ... | |
1216 | 1227 |
for (int v = 0; v < views.size(); v++) { |
1217 | 1228 |
ProjectView pView = (ProjectView) views.get(v); |
1218 | 1229 |
FLayers layers = pView.getMapContext().getLayers(); |
1219 |
if (isView(layers, layer)) |
|
1230 |
if (isView(layers, layer)) {
|
|
1220 | 1231 |
return pView.getName(); |
1232 |
} |
|
1221 | 1233 |
} |
1222 | 1234 |
|
1223 | 1235 |
throw new RuntimeException("The layer '"+layer.getName()+"' is not in a view"); |
... | ... | |
1262 | 1274 |
* @return DOCUMENT ME! |
1263 | 1275 |
*/ |
1264 | 1276 |
public IProjection getProjection() { |
1265 |
if (projection == null) |
|
1277 |
if (projection == null) {
|
|
1266 | 1278 |
projection = Project.defaultProjection; |
1279 |
} |
|
1267 | 1280 |
return projection; |
1268 | 1281 |
} |
1269 | 1282 |
|
... | ... | |
1642 | 1655 |
public ArrayList<ProjectDocument> getDocumentsByType(String registerName) { |
1643 | 1656 |
ArrayList<ProjectDocument> docuArray = new ArrayList<ProjectDocument>(); |
1644 | 1657 |
for (int i = 0; i < documents.size(); i++) { |
1645 |
ProjectDocument projectDocument = (ProjectDocument) documents
|
|
1658 |
ProjectDocument projectDocument = documents |
|
1646 | 1659 |
.get(i); |
1647 | 1660 |
ProjectDocumentFactory pdf = projectDocument |
1648 | 1661 |
.getProjectDocumentFactory(); |
1649 |
if (pdf == null) |
|
1662 |
if (pdf == null) {
|
|
1650 | 1663 |
continue; |
1664 |
} |
|
1651 | 1665 |
if (pdf.getRegisterName().equals(registerName)) { |
1652 | 1666 |
docuArray.add(projectDocument); |
1653 | 1667 |
} |
... | ... | |
1663 | 1677 |
public ArrayList<ProjectDocument> getDocuments() { |
1664 | 1678 |
ArrayList<ProjectDocument> docuArray = new ArrayList<ProjectDocument>(); |
1665 | 1679 |
for (int i = 0; i < documents.size(); i++) { |
1666 |
ProjectDocument projectDocument = (ProjectDocument) documents
|
|
1680 |
ProjectDocument projectDocument = documents |
|
1667 | 1681 |
.get(i); |
1668 | 1682 |
docuArray.add(projectDocument); |
1669 | 1683 |
} |
... | ... | |
1719 | 1733 |
// TODO es millorable? |
1720 | 1734 |
XMLEntity xml = PluginServices.getPluginServices("com.iver.cit.gvsig") |
1721 | 1735 |
.getPersistentXML(); |
1722 |
if (xml.contains("DefaultSelectionColor")) |
|
1736 |
if (xml.contains("DefaultSelectionColor")) {
|
|
1723 | 1737 |
defaultSelectionColor = StringUtilities.string2Color(xml |
1724 | 1738 |
.getStringProperty("DefaultSelectionColor")); |
1739 |
} |
|
1725 | 1740 |
return defaultSelectionColor; |
1726 | 1741 |
} |
1727 | 1742 |
|
... | ... | |
1748 | 1763 |
} |
1749 | 1764 |
} |
1750 | 1765 |
} |
1751 |
if (defaultMapUnits == -1) |
|
1766 |
if (defaultMapUnits == -1) {
|
|
1752 | 1767 |
defaultMapUnits = MapContext.getDistancePosition("Metros"); |
1768 |
} |
|
1753 | 1769 |
} |
1754 | 1770 |
return defaultMapUnits; |
1755 | 1771 |
} |
... | ... | |
1778 | 1794 |
} |
1779 | 1795 |
} |
1780 | 1796 |
} |
1781 |
if (defaultDistanceUnits == -1) |
|
1797 |
if (defaultDistanceUnits == -1) {
|
|
1782 | 1798 |
defaultDistanceUnits = MapContext.getDistancePosition("Metros"); |
1799 |
} |
|
1783 | 1800 |
} |
1784 | 1801 |
return defaultDistanceUnits; |
1785 | 1802 |
} |
... | ... | |
1984 | 2001 |
} |
1985 | 2002 |
|
1986 | 2003 |
private boolean checkExportXMLRootNode(XMLEntity xml) { |
1987 |
if (!xml.contains("applicationName")) |
|
2004 |
if (!xml.contains("applicationName")) {
|
|
1988 | 2005 |
return false; |
1989 |
if (!xml.getStringProperty("applicationName").equalsIgnoreCase("gvSIG")) |
|
2006 |
} |
|
2007 |
if (!xml.getStringProperty("applicationName").equalsIgnoreCase("gvSIG")) { |
|
1990 | 2008 |
return false; |
2009 |
} |
|
1991 | 2010 |
|
1992 |
if (!xml.contains("version")) |
|
2011 |
if (!xml.contains("version")) {
|
|
1993 | 2012 |
return false; |
2013 |
} |
|
1994 | 2014 |
if (!xml.getStringProperty("version") |
1995 |
.equalsIgnoreCase(Version.format())) |
|
2015 |
.equalsIgnoreCase(Version.format())) {
|
|
1996 | 2016 |
return false; |
2017 |
} |
|
1997 | 2018 |
|
1998 | 2019 |
return true; |
1999 | 2020 |
} |
Also available in: Unified diff