Révision 2526

tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/OpenWelcomePage.java (revision 2526)
40 40
import org.txm.utils.logger.Log;
41 41

  
42 42
/**
43
 * Open the internal browser of TXM with a file 
43
 * Open the internal browser of TXM with a file
44 44
 * 
45 45
 * @author mdecorde.
46 46
 */
47 47
public class OpenWelcomePage extends AbstractHandler {
48

  
48
	
49 49
	/** The Constant ID. */
50 50
	public final static String ID = "org.txm.rcp.commands.OpenWelcomePage"; //$NON-NLS-1$
51

  
52
	/* (non-Javadoc)
51
	
52
	/*
53
	 * (non-Javadoc)
53 54
	 * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
54 55
	 */
55 56
	@Override
56 57
	public Object execute(ExecutionEvent event) throws ExecutionException {
57
		openWelcomePage();
58
		return null;
58
		return openWelcomePage();
59 59
	}
60

  
61
	public static void openWelcomePage() {
60
	
61
	public static boolean openWelcomePage() {
62 62
		
63
		try { // ensure network is enable
64
			URL url = new URL("http://textometrie.ens-lyon.fr/html/welcome/welcome.html");
65
			url.openStream().close();
66
		}
67
		catch (Exception e) {
68
			return false;
69
		}
70
		
63 71
		String locale = Locale.getDefault().getLanguage();
64 72
		String version = Platform.getBundle(Activator.PLUGIN_ID).getVersion().toString();
65 73
		int idx = version.lastIndexOf("."); //$NON-NLS-1$
66 74
		if (idx > 0) version = version.substring(0, idx); // remove the "qualifier" part
67 75
		
68
		String urlString = "http://textometrie.ens-lyon.fr/html/welcome/"+version+"/"+locale+"/welcome.html";
76
		String urlString = "http://textometrie.ens-lyon.fr/html/welcome/" + version + "/" + locale + "/welcome.html";
69 77
		try {
70 78
			URL url = new URL(urlString);
71 79
			try {
72 80
				url.openStream().close();
73
			} catch (IOException e) {
74
				Log.severe(e.getMessage());
75
				Log.printStackTrace(e);
76
				urlString = "http://textometrie.ens-lyon.fr/html/welcome/"+version+"/en/welcome.html";
81
			}
82
			catch (IOException e) {
83
				Log.finer(e.getMessage());
84
				// Log.printStackTrace(e);
85
				urlString = "http://textometrie.ens-lyon.fr/html/welcome/" + version + "/en/welcome.html";
77 86
				url = new URL(urlString);
78 87
			}
79
			OpenBrowser.openfile(urlString); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
80
		} catch (MalformedURLException e) {
88
			return OpenBrowser.openfile(urlString) != null;
89
		}
90
		catch (MalformedURLException e) {
81 91
			Log.severe(e.getMessage());
82 92
			Log.printStackTrace(e);
93
			return false;
83 94
		}
84 95
	}
85
}
96
}

Formats disponibles : Unified diff