Revision 39204 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/util/BaseOpenErrorHandler.java

View differences:

BaseOpenErrorHandler.java
33 33
		this.exception=e;
34 34
		this.parameters=parameters;
35 35
		Throwable cause = null;
36
		boolean retry = false;
36 37

  
37
		if (this.exception instanceof InvocationTargetException){
38
		/*if (this.exception instanceof InvocationTargetException){
38 39
			cause = this.exception.getCause();
39 40
		} else {
40 41
			cause = this.exception;
41
		}
42
		if (cause instanceof InitializeException){
43
			if (cause.getCause() instanceof OpenException){
44
				if ( this.parameters instanceof FilesystemStoreParameters){
42
		}*/
43
		//if (cause instanceof InitializeException){
44
			//if (cause.getCause() instanceof OpenException){
45
				if ( this.parameters instanceof FilesystemStoreParameters) {
45 46
					FilesystemStoreParameters filesystemStoreParameters = (FilesystemStoreParameters)this.parameters;
46 47
					File searchedFile = filesystemStoreParameters.getFile();
47 48
					File file = null;
48
					if( searchedFile != null && !searchedFile.exists() ){
49
					if( searchedFile != null && !searchedFile.exists() ) {
49 50
						file = chooseAlternateFile(searchedFile);
50 51
						if( file!=null){
51 52
							filesystemStoreParameters.setFile(file);
53
							retry = true;
52 54
						} else {
53 55
							return false;
54 56
						}
55 57
					}
56 58

  
57
					if (this.parameters instanceof SHPStoreParameters){
59
					if (this.parameters instanceof SHPStoreParameters) {
58 60
						SHPStoreParameters shpStoreParameters = (SHPStoreParameters)this.parameters;
59 61
						File searchedDBFFile = shpStoreParameters.getDBFFile();
60
						if (searchedDBFFile!=null && !searchedDBFFile.exists()){
62
						if (searchedDBFFile!=null && !searchedDBFFile.exists()) {
61 63
							File possibleDbfFile = null;
62 64
							if (file != null){
63 65
								possibleDbfFile = SHP.getDbfFile(file);
64 66
							}
65
							if (possibleDbfFile != null && possibleDbfFile.exists()){
67
							if (possibleDbfFile != null && possibleDbfFile.exists()) {
66 68
								shpStoreParameters.setDBFFile(possibleDbfFile);
69
								retry = true;
67 70
							} else {
68 71
								File dbfFile = chooseAlternateFile(searchedDBFFile);
69 72
								if (dbfFile != null){
70 73
									shpStoreParameters.setDBFFile(dbfFile);
74
									retry = true;
71 75
								} else {
72 76
									return false;
73 77
								}
74 78
							}
75 79
						}
76 80
						File searchedSHXFile = shpStoreParameters.getSHXFile();
77
						if (searchedDBFFile!=null && !searchedSHXFile.exists()){
81
						if (searchedDBFFile!=null && !searchedSHXFile.exists()) {
78 82
							File possibleShxFile = null;
79 83
							if (file != null){
80 84
								possibleShxFile = SHP.getShxFile(file);
81 85
							}
82
							if (possibleShxFile != null && possibleShxFile.exists()){
86
							if (possibleShxFile != null && possibleShxFile.exists()) {
83 87
								shpStoreParameters.setSHXFile(possibleShxFile);
88
								retry = true;
84 89
							} else {
85 90
								File shxFile = chooseAlternateFile(searchedSHXFile);
86
								if (shxFile != null){
91
								if (shxFile != null) {
87 92
									shpStoreParameters.setSHXFile(shxFile);
93
									retry = true;
88 94
								} else {
89 95
									return false;
90 96
								}
91 97
							}
92 98
						}
93 99
					}
94
					return true;
95 100
				}
96
			}
97
		}
98
		return false;
101
			//}
102
		//}
103
		return retry;
99 104
	}
100 105
	
101 106
	private File chooseAlternateFile(File searchedFile){

Also available in: Unified diff