Revision 506

tmp/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 506)
41 41
import org.eclipse.swt.widgets.Shell;
42 42
import org.eclipse.ui.PlatformUI;
43 43
import org.eclipse.ui.statushandlers.StatusManager;
44
import org.osgi.framework.Version;
44 45
import org.txm.core.preferences.TXMPreferences;
46
import org.txm.rcp.Activator;
45 47
import org.txm.rcp.Messages;
48
import org.txm.rcp.TxmPreferences;
49
import org.txm.rcp.preferences.AdvancePreferencePage;
46 50
import org.txm.rcp.preferences.RCPPreferences;
47 51
import org.txm.utils.logger.Log;
48 52
import org.txm.utils.zip.GZip;
49 53

  
50 54
public class TXMUpdateHandler extends UpdateHandler {
51 55

  
52
	public static final String UPDATESITE = "http://textometrie.ens-lyon.fr/dist/VERSION"; //
53
	//public static final String UPDATESITE = "file:"+System.getProperty("user.home")+"/TEMP/updates"; // LOCAL TEST ONLY
54
	public static final String ID = TXMUpdateHandler.class.getCanonicalName();
56
	public static final String UPDATESITE = "http://textometrie.ens-lyon.fr/dist"; //
57
	// "file:"+System.getProperty("user.home")+"/TEMP/updates"; // LOCAL TEST ONLY
58
	public static final String ID = "org.txm.rcpapplication.p2.plugins.TXMUpdateHandler";
55 59
	
56 60
	/**
57 61
	 * Execute the command.
......
103 107
//				System.out.println("Details: "+aboutFile.getAbsolutePath() +" exists "+aboutFile.exists()+" can be read "+aboutFile.canRead()+" can be writen "+aboutFile.canWrite());
104 108
//			} else {
105 109
				Log.warning("Looking for TXM updates...");
106
				super.execute(event);
110
				Object ret = super.execute(event);
111
				Log.warning("Done.");
107 112
//			}
108 113
		} catch(Exception e) {
109 114
			System.out.println("Could not update TXM: "+e);
......
183 188
	}
184 189

  
185 190
	public static void addDefaultUpdateSites(IProvisioningAgent agent) {
186
		String uriDefault = UPDATESITE+"/main/stable";
191
		Version v = Activator.getDefault().getBundle().getVersion();
192
		String version =  ""+v.getMajor()+"."+v.getMinor()+"."+v.getMicro();
193
		String uriBase = UPDATESITE+"/"+version+"/main";
194
		String uriDefault = uriBase+"/stable";
187 195
		try {
188 196
			URI repoUriDefault = new URI(uriDefault);
189 197
			addURL(agent, repoUriDefault);
......
194 202
			Log.printStackTrace(e);
195 203
		}
196 204
		
197
		//FIXME: should be defined in the preference initializer 
198 205
		String updateLevel = TXMPreferences.getString(RCPPreferences.UPDATE_LEVEL, null, RCPPreferences.PREFERENCES_NODE, "STABLE");
199 206
		boolean alphaMode = false;
200 207
		boolean betaMode = false;
......
208 215
		}
209 216
		Log.info("Update levels: dev="+devMode+" alpha="+alphaMode+" beta="+betaMode);
210 217

  
211
		String uriDev = UPDATESITE+"/main/dev";//$NON-NLS-1$
218
		String uriDev = uriBase+"/dev";//$NON-NLS-1$
212 219
		try {
213 220
			URI repoUriDev = new URI(uriDev);
214 221
			if (devMode) {
......
221 228
			e.printStackTrace();
222 229
		}
223 230
		
224
		String uriAlpha = UPDATESITE+"/main/alpha";//$NON-NLS-1$
231
		String uriAlpha = uriBase+"/alpha";//$NON-NLS-1$
225 232
		try {
226 233
			URI repoUriAlpha = new URI(uriAlpha);
227 234
			if (alphaMode) {
......
234 241
			e.printStackTrace();
235 242
		}
236 243

  
237
		String uriBeta = UPDATESITE+"/main/beta";//$NON-NLS-1$
244
		String uriBeta = uriBase+"/beta";//$NON-NLS-1$
238 245
		try {
239 246
			URI repoUriBeta = new URI(uriBeta);
240 247
			if (betaMode) {
......
248 255
	}
249 256
	
250 257
	public static void addDefaultPluginSites(IProvisioningAgent agent) {
251
		String uriDefault = UPDATESITE+"/ext/stable";
258
		Version v = Activator.getDefault().getBundle().getVersion();
259
		String version =  ""+v.getMajor()+"."+v.getMinor()+"."+v.getMicro();
260
		String uriBase = UPDATESITE+"/"+version+"/ext";
261
		
262
		String uriDefault = uriBase+"/stable";
252 263
		try {
253 264
			URI repoUriDefault = new URI(uriDefault);
254 265
			addURL(agent, repoUriDefault);
......
258 269
			Log.severe("Could not add update default repository: " + uriDefault);
259 270
			Log.printStackTrace(e);
260 271
		}
261
		//FIXME: should be defined in the preference initializer 
262
		String updateLevel = TXMPreferences.getString(RCPPreferences.UPDATE_LEVEL, null, RCPPreferences.PREFERENCES_NODE, "STABLE"); //$NON-NLS-1$
272
		
273
		String updateLevel = TXMPreferences.getString(RCPPreferences.UPDATE_LEVEL, null, RCPPreferences.PREFERENCES_NODE, "STABLE");
263 274
		boolean alphaMode = false;
264 275
		boolean betaMode = false;
265 276
		boolean devMode = false;
......
272 283
		}
273 284
		Log.info("Update levels: dev="+devMode+" alpha="+alphaMode+" beta="+betaMode);
274 285

  
275
		String uriDev = UPDATESITE+"/ext/dev";//$NON-NLS-1$
286
		String uriDev = uriBase+"/dev";//$NON-NLS-1$
276 287
		try {
277 288
			URI repoUriDev = new URI(uriDev);
278 289
			if (devMode) {
......
285 296
			e.printStackTrace();
286 297
		}
287 298
		
288
		String uriAlpha = UPDATESITE+"/ext/alpha";//$NON-NLS-1$
299
		String uriAlpha = uriBase+"/alpha";//$NON-NLS-1$
289 300
		try {
290 301
			URI repoUriAlpha = new URI(uriAlpha);
291 302
			if (alphaMode) {
......
298 309
			e.printStackTrace();
299 310
		}
300 311

  
301
		String uriBeta = UPDATESITE+"/ext/beta";//$NON-NLS-1$
312
		String uriBeta = uriBase+"/beta";//$NON-NLS-1$
302 313
		try {
303 314
			URI repoUriBeta = new URI(uriBeta);
304 315
			if (betaMode) {
......
530 541
	
531 542
	
532 543
	
533
}
544
}

Also available in: Unified diff