Revision 4181 org.gvsig.raster.multifile/trunk/org.gvsig.raster.multifile/org.gvsig.raster.multifile.app.multifileclient/src/main/java/org/gvsig/raster/multifile/app/panel/BandSelectorNewLayerListener.java

View differences:

BandSelectorNewLayerListener.java
2 2
*
3 3
* Copyright (C) 2007-2008 Infrastructures and Transports Department
4 4
* of the Valencian Government (CIT)
5
* 
5
*
6 6
* This program is free software; you can redistribute it and/or
7 7
* modify it under the terms of the GNU General Public License
8 8
* as published by the Free Software Foundation; either version 2
9 9
* of the License, or (at your option) any later version.
10
* 
10
*
11 11
* This program is distributed in the hope that it will be useful,
12 12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13 13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 14
* GNU General Public License for more details.
15
* 
15
*
16 16
* You should have received a copy of the GNU General Public License
17 17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19 19
* MA  02110-1301, USA.
20
* 
20
*
21 21
*/
22 22
package org.gvsig.raster.multifile.app.panel;
23 23

  
24 24
import java.awt.event.ActionEvent;
25 25
import java.io.File;
26
import java.net.URI;
26 27
import java.util.ArrayList;
27 28
import java.util.List;
28 29

  
......
61 62
	public BandSelectorNewLayerListener(BandSelectorPanel bs) {
62 63
		super(bs);
63 64
	}
64
	
65

  
65 66
	public RasterDataStore getResult() {
66 67
		return mainRasterStore;
67 68
	}
68
	
69

  
69 70
	/**
70 71
	 * Listener para la gesti?n de los botones de a?adir, eliminar fichero y
71 72
	 * el combo de selecci?n de bandas.
......
87 88
	}
88 89

  
89 90
	public void actionButtonPressed(ButtonsPanelEvent e) {
90
		
91

  
91 92
	}
92 93

  
93 94
	@Override
94 95
	public void setNewBandsPositionInRendering() {
95
		
96

  
96 97
	}
97 98

  
98 99
	@Override
......
108 109
			File[] files = fileChooser.getSelectedFiles();
109 110
			if(files == null || files.length <= 0)
110 111
				return;
111
			
112

  
112 113
			JFileChooser.setLastPath(FilesystemExplorerWizardPanel.OPEN_LAYER_FILE_CHOOSER_ID, files[0]);
113 114
			int initPosition = 0;
114
			
115

  
115 116
			if(mainRasterStore == null) {
116 117
				initPosition = 1;
117 118
				MultiFileProvider provider = createMultiFileProvider(file, folder);
118 119
				MultiFileDataParameters newParamsMultifile = (MultiFileDataParameters)provider.getDataParameters();
119
				
120

  
120 121
				try {
121 122
					RasterDataStore firstDataStore = RasterLocator.getManager().getProviderServices().open(files[0].getAbsolutePath());
122 123
					newParamsMultifile.addProvider(firstDataStore);
......
132 133
				} catch (ProviderNotRegisteredException e) {
133 134
					log.debug("Error loading the main store", e);
134 135
				}
135
			} 
136
			}
136 137

  
137 138
			List<File> fileList = new ArrayList<File>();
138 139

  
139 140
			for (int i = initPosition; i < files.length; i++) {
140 141
				//Checks that the file does not exist
141
				String[] uris = mainRasterStore.getURIByProvider();
142
				URI[] uris = mainRasterStore.getURIByProvider();
142 143
				boolean exists = false;
143 144
				for (int j = 0; j < uris.length; j++) {
144
					if (uris[j].endsWith(files[i].getName())) {
145
					if (uris[j].getPath().endsWith(files[i].getName())) {
145 146
						RasterSwingLibrary.messageBoxError( Messages.getText("fichero_existe") + ": " + files[i].getAbsolutePath(), bandSetupPanel);
146 147
						exists = true;
147 148
						break;
......
153 154

  
154 155
			if(!checkStoresCompatibility(mainRasterStore, fileList))
155 156
				return;
156
			
157

  
157 158
			if(mainRasterStore.isMultiFile()) {
158 159
				for (int i = 0; i < fileList.size(); i++) {
159 160
					try {
160
						mainRasterStore.addFile(fileList.get(i).getAbsolutePath());
161
						mainRasterStore.addFile(fileList.get(i)); //.getAbsolutePath());
161 162
					} catch (InvalidSourceException e) {
162 163
						RasterSwingLibrary.messageBoxError(Messages.getText("addband_error"), bandSetupPanel, e);
163 164
					}
......
171 172
				} catch (NotInitializeException e) {
172 173
					RasterSwingLibrary.messageBoxError("table_not_initialize", this, e);
173 174
				}
174
			} 
175
		}		
175
			}
176
		}
176 177
	}
177 178

  
178 179
	@Override
179 180
	public void delFileBand() {
180 181
		if(mainRasterStore == null)
181 182
			return;
182
		
183

  
183 184
		Object[] objects = bandSetupPanel.getFileList().getJList().getSelectedValues();
184
		
185

  
185 186
		for (int i = objects.length - 1; i >= 0; i--) {
186 187
			if (bandSetupPanel.getFileList().getNFiles() > 1) {
187 188
				String pathName = objects[i].toString();
188
				mainRasterStore.removeFile(pathName);
189
				mainRasterStore.removeFile(new File(pathName));
189 190

  
190 191
				String file = pathName.substring(pathName.lastIndexOf(File.separator) + 1);
191 192
				file = file.substring(file.lastIndexOf("\\") + 1);
192 193
				bandSetupPanel.removeFile(file);
193 194
			}
194 195
		}
195
		
196

  
196 197
		setNewBandsPositionInRendering();
197 198
	}
198 199

  

Also available in: Unified diff