30 |
30 |
import java.net.URL;
|
31 |
31 |
import java.util.Locale;
|
32 |
32 |
|
|
33 |
import javax.net.ssl.HttpsURLConnection;
|
|
34 |
|
33 |
35 |
import org.eclipse.core.commands.AbstractHandler;
|
34 |
36 |
import org.eclipse.core.commands.ExecutionEvent;
|
35 |
37 |
import org.eclipse.core.commands.ExecutionException;
|
36 |
38 |
import org.eclipse.core.runtime.Platform;
|
|
39 |
import org.eclipse.osgi.util.NLS;
|
37 |
40 |
import org.txm.rcp.Activator;
|
38 |
41 |
import org.txm.utils.logger.Log;
|
39 |
42 |
|
... | ... | |
54 |
57 |
public static final String URL_TXMDEPOT = GITPAGES+"txm-software/";
|
55 |
58 |
public static final String HTMLPAGES = URL_TEXTOMETRIE + "html/";
|
56 |
59 |
public static final String FILESPAGES = URL_TEXTOMETRIE + "files/";
|
57 |
|
|
|
60 |
|
58 |
61 |
public static final String TEXTOMETRIE = "textometrie"; //$NON-NLS-1$
|
59 |
62 |
public static final String TEXTOMETRIE_DOCS = "textometrie_docs"; //$NON-NLS-1$
|
60 |
63 |
public static final String SF = "sf"; //$NON-NLS-1$
|
... | ... | |
84 |
87 |
|
85 |
88 |
return null;
|
86 |
89 |
}
|
87 |
|
|
|
90 |
|
88 |
91 |
static public String getValidURL(String urltoTest, String alternativeUrl) {
|
89 |
92 |
try {
|
90 |
93 |
URL url = new URL(urltoTest);
|
91 |
|
try {
|
|
94 |
if (url.getProtocol().equals("https")) {
|
|
95 |
HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
|
|
96 |
connection.disconnect();
|
|
97 |
} else {
|
92 |
98 |
url.openStream().close();
|
93 |
|
} catch (Exception e) {
|
94 |
|
Log.severe(e.getMessage());
|
95 |
|
Log.printStackTrace(e);
|
96 |
|
return alternativeUrl;
|
97 |
99 |
}
|
|
100 |
|
98 |
101 |
} catch (Exception e) {
|
99 |
|
Log.severe(e.getMessage());
|
100 |
|
// Log.printStackTrace(e);
|
|
102 |
Log.fine(NLS.bind("Error while testing the \"{0}\" web page: {1}", urltoTest, e.getMessage()));
|
|
103 |
return alternativeUrl;
|
101 |
104 |
}
|
102 |
105 |
return urltoTest;
|
103 |
106 |
}
|
... | ... | |
109 |
112 |
* @return the txm browser
|
110 |
113 |
*/
|
111 |
114 |
static public Object openfile(String key) {
|
112 |
|
|
|
115 |
|
113 |
116 |
String version = Platform.getBundle(Activator.PLUGIN_ID).getVersion().toString();
|
114 |
117 |
int idx = version.lastIndexOf("."); //$NON-NLS-1$
|
115 |
118 |
if (idx > 0) version = version.substring(0, idx); // remove the "qualifier" part
|
116 |
|
|
|
119 |
|
117 |
120 |
String locale = Locale.getDefault().getLanguage();
|
118 |
|
|
|
121 |
|
119 |
122 |
if (TEXTOMETRIE.equals(key)) {
|
120 |
123 |
return OpenBrowser.openfile(getValidURL(URL_TEXTOMETRIE+locale, URL_TEXTOMETRIE)); //$NON-NLS-1$
|
121 |
124 |
} else if (FAQ.equals(key)) {
|