Revision 309

View differences:

org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.swing/org.gvsig.raster.osm.swing.impl/src/main/java/org/gvsig/raster/osm/swing/impl/AddOSMLayerPanelImpl.java
44 44
import javax.swing.BorderFactory;
45 45
import javax.swing.JButton;
46 46
import javax.swing.JComponent;
47
import javax.swing.JLabel;
47 48
import javax.swing.JOptionPane;
48 49
import javax.swing.JPanel;
49 50
import javax.swing.JScrollPane;
......
54 55

  
55 56
import org.gvsig.i18n.Messages;
56 57
import org.gvsig.raster.osm.swing.AddOSMLayerPanel;
58
import org.gvsig.tools.ToolsLocator;
59
import org.gvsig.tools.i18n.I18nManager;
57 60

  
58 61
import org.slf4j.Logger;
59 62
import org.slf4j.LoggerFactory;
......
71 74
	private JTable               tableServerList     = null;
72 75
	private String               propertiesFileName  = "osmservers.properties";
73 76
	private JPanel               buttonsPanel        = null;
77
    private JPanel               crsWarningPanel     = null;
74 78
	private JPanel               selectedServerPanel = null;
75 79
	private String[]             columnNames         = null;
76 80
	private JButton              addServerButton     = null;
......
78 82
	private JButton              removeServerButton  = null;
79 83
	private AddServerPanel       serverPanel         = null;
80 84
	private MouseListener        mouseListener       = null;
85
    private JLabel               crsWarningLabel     = null;
86
    private boolean              showCrsWarning      = false;
81 87

  
82
	public AddOSMLayerPanelImpl(File pathToServerList) {
83
		if(pathToServerList != null)
84
			this.pathToServerList = pathToServerList;
85
		else
86
			this.pathToServerList = new File(System.getProperty("user.home"));
87
		columnNames = new String[]{
88
			Messages.getText("name"),
89
			Messages.getText("url"),
90
			Messages.getText("levels"),
91
			Messages.getText("format"),};
92
		init();
93
	}
94 88

  
89
    public AddOSMLayerPanelImpl(File pathToServerList) {
90
        this(pathToServerList, false);
91
    }
92

  
93
    public AddOSMLayerPanelImpl(File pathToServerList, boolean showCrsWarning) {
94
        if (pathToServerList != null) {
95
            this.pathToServerList = pathToServerList;
96
        } else {
97
            this.pathToServerList = new File(System.getProperty("user.home"));
98
        }
99
        this.showCrsWarning = showCrsWarning;
100
        columnNames =
101
            new String[] {
102
                Messages.getText("name"),
103
                Messages.getText("url"),
104
                Messages.getText("levels"),
105
                Messages.getText("format"),
106
            };
107
        init();
108
    }
109

  
95 110
	private void init() {
96 111
		GridBagConstraints gridBagConstraints;
97 112
		setLayout(new GridBagLayout());
......
124 139

  
125 140
		gridBagConstraints.gridy = 3;
126 141
		add(getJPanelButtonsPanel(), gridBagConstraints);
142
		if(this.showCrsWarning){
143
		    gridBagConstraints.gridy = 4;
144
		    add(getJPanelCrsWarningPanel(), gridBagConstraints);
145
		}
127 146
	}
128 147

  
129 148
	private JPanel getJPanelButtonsPanel() {
......
143 162
		return buttonsPanel;
144 163
	}
145 164

  
165
	   private JPanel getJPanelCrsWarningPanel() {
166
        if (crsWarningPanel == null) {
167
            FlowLayout fl = new FlowLayout();
168
            crsWarningPanel = new JPanel(fl);
169
            // if(this.showCrsWarning){
170
            I18nManager i18nManager = ToolsLocator.getI18nManager();
171
            StringBuilder builder = new StringBuilder();
172
            builder.append("<html><font color=\"red\">");
173
            builder.append(i18nManager.getTranslation("_crs_warning"));
174
            builder.append("</font></body></html>");
175
            crsWarningLabel = new JLabel(Messages.getText(builder.toString()));
176
            crsWarningPanel.add(crsWarningLabel, fl);
177
            // }
178
        }
179
	        return crsWarningPanel;
180
	    }
181

  
146 182
	private JPanel getJPanelSelectedServer() {
147 183
		if(selectedServerPanel == null) {
148 184
			selectedServerPanel = new JPanel(new BorderLayout());
org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.swing/org.gvsig.raster.osm.swing.impl/src/main/java/org/gvsig/raster/osm/swing/impl/DefaultOSMSwingManager.java
32 32

  
33 33
/**
34 34
 * Default implementation of the {@link DefaultOSMSwingManager}.
35
 * 
35
 *
36 36
 * @author gvSIG Team
37 37
 * @version $Id$
38 38
 */
......
41 41
    private I18nManager i18nmanager = null;
42 42

  
43 43
    public DefaultOSMSwingManager() {
44
        this.i18nmanager = ToolsLocator.getI18nManager();       
44
        this.i18nmanager = ToolsLocator.getI18nManager();
45 45
    }
46 46

  
47 47
    public String getTranslation(String key) {
48 48
        return this.i18nmanager.getTranslation(key);
49 49
    }
50
    
50

  
51 51
	/**
52 52
	 * Obtiene la traducci?n de la cadena de texto
53 53
	 * @param text Cadena a traducir
......
68 68
    public AddOSMLayerPanel createAddOSMLayerPanel(File pathToServerList) {
69 69
    	return new AddOSMLayerPanelImpl(pathToServerList);
70 70
    }
71
	
71

  
72
    public AddOSMLayerPanel createAddOSMLayerPanel(File pathToServerList, boolean showCrsWaring) {
73
        return new AddOSMLayerPanelImpl(pathToServerList, showCrsWaring);
74
    }
75

  
72 76
}
org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.swing/org.gvsig.raster.osm.swing.api/src/main/java/org/gvsig/raster/osm/swing/OSMSwingManager.java
29 29
 * This class is responsible of the management of the library's swing user
30 30
 * interface. It is the swing library's main entry point, and provides all the
31 31
 * services to manage library swing components.
32
 * 
32
 *
33 33
 * @see RasterWindowManager
34 34
 * @see JValidationServicePanel
35 35
 * @author gvSIG team
......
39 39

  
40 40
    /**
41 41
     * Returns the translation of a string.
42
     * 
42
     *
43 43
     * @param key
44 44
     *            String to translate
45 45
     * @return a String with the translation of the string passed by parameter
......
53 53
     * @return
54 54
     */
55 55
    public AddOSMLayerPanel createAddOSMLayerPanel(File pathToServerList);
56
   
56

  
57
    /**
58
     * Creates <b>AddOSMLayerPanel</b>
59
     * @param pathToServerList
60
     *        Path to the directory where the server list is stored
61
     * @param showCrsWarning
62
     * @return
63
     */
64
    public AddOSMLayerPanel createAddOSMLayerPanel(File pathToServerList, boolean showCrsWarning);
65

  
57 66
}
org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.app.osmclient/src/main/java/org/gvsig/raster/osm/app/osmclient/AddOSMLayerWizard.java
88 88

  
89 89
	public AddOSMLayerWizard() {
90 90
		super();
91
		initialize();
92 91
	}
93 92

  
94 93
	/**
......
105 104
		gridBagConstraints.weighty = 1.0;
106 105
		gridBagConstraints.insets = new Insets(6, 6, 6, 6);
107 106

  
108
		apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()));
107
		boolean showCrsWarning = false;
108
		IProjection osmProjection = CRSFactory.getCRS("EPSG:3857");
109
        if(getMapCtrl()!=null && !(getMapCtrl().getProjection().equals(osmProjection))){
110
            showCrsWarning = true;
111
        }
112
		apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()),showCrsWarning);
109 113

  
110 114
		//Copying osmservers.properties
111 115
		if(!new File(apiUI.getPropertiesFilePath()).exists()) {
......
118 122
			FileUtils utils = RasterLocator.getManager().getFileUtils();
119 123
			try {
120 124
				utils.copyFile(f.getAbsolutePath(), Launcher.getAppHomeDir() + File.separator);
121
				apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()));
125
				apiUI = OSMSwingLocator.getSwingManager().createAddOSMLayerPanel(new File(Launcher.getAppHomeDir()),showCrsWarning);
122 126
			} catch (FileNotFoundException e) {
123 127
				logger.info("File not found copying osmservers.properties", e);
124 128
			} catch (IOException e) {
......
333 337

  
334 338
	@Override
335 339
	public void initWizard() {
336

  
340
	    initialize();
337 341
	}
338 342

  
339 343
	public void mouseClicked(MouseEvent e) {
org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/text_en.properties
3 3
server_not_selected=There is not a server selected
4 4
error_loading_epsg=Error loading EPSG:3785 in database from OSM plug-in.\n Checks if JCRS plug-in is installed and running. \nThis projection is not available.
5 5
dont_remind_me_anymore=Don't remind me anymore
6
ok=OK
6
ok=OK
7

  
8
_crs_warning=The projection of the view is not appropriate to load layers of this service.
org.gvsig.raster.osm/trunk/org.gvsig.raster.osm/org.gvsig.raster.osm.app.osmclient/src/main/resources-plugin/text.properties
1 1
error_creating_the_view=Error creando una vista nueva. Pruebe creando una manualmente.
2
error_creating_parameters=Error creando los par?metros
2
error_creating_parameters=Error creando los par\u00e1metros
3 3
server_not_selected=No hay un servidor seleccionado
4
error_loading_epsg=Error cargando el EPSG:3785 desde el plugin de OSM.\n Comprueba que la extensi?n JCRS est? instalada y funcionando. \n Esta proyecci?n no estar? disponible aunque la \n carga de tiles deber?a funcionar correctamente.
5
dont_remind_me_anymore=No me lo recuerdes m?s
6
ok=OK
4
error_loading_epsg=Error cargando el EPSG:3785 desde el plugin de OSM.\n Comprueba que la extensi\u00f3n JCRS est\u00e1 instalada y funcionando. \n Esta proyecci\u00f3n no estar\u00e1 disponible aunque la \n carga de tiles deber\u00eda funcionar correctamente.
5
dont_remind_me_anymore=No me lo recuerdes m\u00e1s
6
ok=OK
7

  
8
_crs_warning=La proyecci\u00f3n de la vista no es la adecuada para cargar capas de este servicio.

Also available in: Unified diff