gvsig-raster / org.gvsig.raster.tools / trunk / org.gvsig.raster.tools / org.gvsig.raster.tools.app / org.gvsig.raster.tools.app.basic / src / main / java / org / gvsig / raster / tools / app / basic / raster / gui / wizard / PrepareLayerAskUsingTiles.java @ 978
History | View | Annotate | Download (4.86 KB)
1 |
/* gvSIG. Geographic Information System of the Valencian Government
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department
|
4 |
* of the Valencian Government (CIT)
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or
|
7 |
* modify it under the terms of the GNU General Public License
|
8 |
* as published by the Free Software Foundation; either version 2
|
9 |
* of the License, or (at your option) any later version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful,
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
* GNU General Public License for more details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License
|
17 |
* along with this program; if not, write to the Free Software
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
* MA 02110-1301, USA.
|
20 |
*
|
21 |
*/
|
22 |
package org.gvsig.raster.tools.app.basic.raster.gui.wizard; |
23 |
|
24 |
import java.awt.Component; |
25 |
import java.util.Map; |
26 |
|
27 |
import javax.swing.JOptionPane; |
28 |
|
29 |
import org.gvsig.andami.PluginServices; |
30 |
import org.gvsig.app.prepareAction.PrepareContext; |
31 |
import org.gvsig.app.prepareAction.PrepareContextView; |
32 |
import org.gvsig.app.prepareAction.PrepareDataStoreParameters; |
33 |
import org.gvsig.app.prepareAction.PrepareLayer; |
34 |
import org.gvsig.fmap.dal.DALLocator; |
35 |
import org.gvsig.fmap.dal.DataManager; |
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
37 |
import org.gvsig.fmap.dal.coverage.store.parameter.RasterDataParameters; |
38 |
import org.gvsig.fmap.dal.coverage.store.parameter.TileDataParameters; |
39 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
40 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
41 |
import org.gvsig.tools.exception.BaseException; |
42 |
|
43 |
public class PrepareLayerAskUsingTiles implements PrepareDataStoreParameters, PrepareLayer { |
44 |
private boolean askMe = true; |
45 |
private boolean answer = false; |
46 |
|
47 |
/*
|
48 |
* (non-Javadoc)
|
49 |
* @see org.gvsig.app.prepareAction.PrepareDataStoreParameters#prepare(org.gvsig.fmap.dal.DataStoreParameters, org.gvsig.app.prepareAction.PrepareContext)
|
50 |
*/
|
51 |
public DataStoreParameters prepare(DataStoreParameters storeParameters,
|
52 |
PrepareContext context) throws BaseException {
|
53 |
if(!(storeParameters instanceof RasterDataParameters)) |
54 |
return storeParameters;
|
55 |
if(askMe)
|
56 |
messageBoxYesOrNot(PluginServices.getText(this, "tiled_layer"), null); |
57 |
|
58 |
if(answer) {
|
59 |
DataManager manager = DALLocator.getDataManager(); |
60 |
TileDataParameters tileParams = null;
|
61 |
tileParams = (TileDataParameters) manager.createStoreParameters("Tile Store");
|
62 |
((FilesystemStoreParameters) tileParams).setFile(((FilesystemStoreParameters)storeParameters).getFile()); |
63 |
tileParams.setDataParameters(storeParameters); |
64 |
return tileParams;
|
65 |
} |
66 |
|
67 |
return storeParameters;
|
68 |
} |
69 |
|
70 |
public void post(DataStoreParameters storeParameters, PrepareContext context) { |
71 |
askMe = true;
|
72 |
} |
73 |
|
74 |
public void pre(DataStoreParameters storeParameters, PrepareContext context) { |
75 |
} |
76 |
|
77 |
public boolean askMe() { |
78 |
return askMe;
|
79 |
} |
80 |
|
81 |
public void setAskMe(boolean askMe) { |
82 |
this.askMe = askMe;
|
83 |
} |
84 |
|
85 |
/*
|
86 |
* (non-Javadoc)
|
87 |
* @see org.gvsig.app.prepareAction.PrepareLayer#prepare(org.gvsig.fmap.mapcontext.layers.FLayer, org.gvsig.app.prepareAction.PrepareContextView)
|
88 |
*/
|
89 |
public FLayer prepare(FLayer layer, PrepareContextView context) {
|
90 |
return layer;
|
91 |
} |
92 |
|
93 |
|
94 |
|
95 |
public void end(Object param) { |
96 |
|
97 |
} |
98 |
|
99 |
public String getDescription() { |
100 |
return "Prepare Tiles for Raster Layer"; |
101 |
} |
102 |
|
103 |
public String getName() { |
104 |
return "PrepareRasterLayerAskUsingTiles"; |
105 |
} |
106 |
|
107 |
public Object create() { |
108 |
return this; |
109 |
} |
110 |
|
111 |
public Object create(Object[] args) { |
112 |
return this; |
113 |
} |
114 |
|
115 |
@SuppressWarnings("unchecked") |
116 |
public Object create(Map args) { |
117 |
return this; |
118 |
} |
119 |
|
120 |
public void interrupted() { |
121 |
} |
122 |
|
123 |
/**
|
124 |
* Muestra un dialogo con un texto y un bot?n Si o No.
|
125 |
* @param msg Mensaje a mostrar en el dialogo.
|
126 |
* @param parentWindow Ventana desde la que se lanza el dialogo
|
127 |
* @return El bot?n seleccionado por el usuario. true si ha seleccionado "si"
|
128 |
* y false si ha seleccionado "no"
|
129 |
*/
|
130 |
public void messageBoxYesOrNot(String msg, Object parentWindow){ |
131 |
String string1 = PluginServices.getText(parentWindow, "yes"); |
132 |
String string2 = PluginServices.getText(parentWindow, "no"); |
133 |
String string3 = PluginServices.getText(parentWindow, "yes_dont_ask_more"); |
134 |
String string4 = PluginServices.getText(parentWindow, "no_dont_ask_more"); |
135 |
Object[] options = {string1, string2, string3, string4}; |
136 |
int n = JOptionPane.showOptionDialog((Component)PluginServices.getMainFrame(), |
137 |
"<html>" + PluginServices.getText(parentWindow, msg).replaceAll("\n", "<br>") + "</html>", |
138 |
PluginServices.getText(parentWindow, "confirmacion"),
|
139 |
JOptionPane.YES_NO_OPTION,
|
140 |
JOptionPane.QUESTION_MESSAGE,
|
141 |
null,
|
142 |
options, |
143 |
string1); |
144 |
answer = false;
|
145 |
if (n == 0) |
146 |
answer = true;
|
147 |
if (n == 2) { |
148 |
askMe = false;
|
149 |
answer = true;
|
150 |
} |
151 |
if (n == 3) |
152 |
askMe = false;
|
153 |
} |
154 |
} |