Révision 2220
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 2220) | ||
|---|---|---|
| 28 | 28 |
package org.txm.rcp; |
| 29 | 29 |
|
| 30 | 30 |
import java.io.File; |
| 31 |
import java.io.IOException; |
|
| 31 | 32 |
import java.io.InputStream; |
| 32 | 33 |
import java.io.PrintStream; |
| 33 | 34 |
import java.lang.reflect.InvocationTargetException; |
| ... | ... | |
| 112 | 113 |
import org.txm.rcp.perspective.TXMPerspective; |
| 113 | 114 |
import org.txm.rcp.preferences.RCPPreferences; |
| 114 | 115 |
import org.txm.rcp.utils.JobHandler; |
| 116 |
import org.txm.utils.BundleUtils; |
|
| 115 | 117 |
import org.txm.utils.DeleteDir; |
| 116 | 118 |
import org.txm.utils.io.IOUtils; |
| 117 | 119 |
import org.txm.utils.logger.Log; |
| ... | ... | |
| 282 | 284 |
} |
| 283 | 285 |
|
| 284 | 286 |
public static void printTXMVersion() {
|
| 285 |
// build the properties given to the Toolbox |
|
| 286 |
// String version = Activator.getDefault().getBundle().getVersion().toString(); // "0.7.7.201412160925"; |
|
| 287 |
// System.out.println(BundleUtils.getBundle("org.txm.rcp.app"));
|
|
| 288 |
// for (IBundleGroupProvider bg : Platform.getBundleGroupProviders()) {
|
|
| 289 |
// System.out.println(bg); |
|
| 290 |
// for (IBundleGroup f : bg.getBundleGroups()) {
|
|
| 291 |
// System.out.println(f); |
|
| 292 |
// if (f.getIdentifier().equals("org.txm.rcp.app")) {
|
|
| 293 |
// version = f.getVersion(); |
|
| 294 |
// System.out.println(version); |
|
| 295 |
// } |
|
| 296 |
// } |
|
| 297 |
// } |
|
| 298 |
// org.eclipse.core.internal.runtime.Product product = (Product) Platform.getProduct(); |
|
| 299 |
// product.getDefiningBundle() |
|
| 300 |
// version = version.replaceAll("(.\\..\\..)\\.(....)(..)(..)(..)(..)", "$1 ($2-$3-$4 $5h$6)"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 301 |
|
|
| 302 |
|
|
| 303 |
ProvisioningUI pui = ProvisioningUI.getDefaultUI(); |
|
| 304 |
|
|
| 305 |
String profileId = pui.getProfileId(); |
|
| 306 |
IProvisioningAgent agent = pui.getSession().getProvisioningAgent(); |
|
| 307 |
IProfileRegistry profileRegistry = (IProfileRegistry) agent.getService(IProfileRegistry.SERVICE_NAME); |
|
| 308 |
IProfile iprofile = profileRegistry.getProfile(profileId); |
|
| 309 |
if (iprofile == null) {
|
|
| 310 |
System.out.println("TXM dev version...");
|
|
| 311 |
return; |
|
| 312 |
} |
|
| 313 |
Profile profile = (Profile)iprofile; |
|
| 314 |
Iterator<IInstallableUnit> everything = profile.everything(); |
|
| 315 | 287 |
|
| 316 | 288 |
String version = null; |
| 317 |
while (everything.hasNext()) {
|
|
| 318 |
IInstallableUnit iu = everything.next(); |
|
| 319 |
String id = iu.getId(); |
|
| 320 |
if ("org.txm.rcp.app".equals(id)) {
|
|
| 321 |
version = iu.getVersion().toString(); |
|
| 289 |
|
|
| 290 |
// try finding build date from the p2 artifacts file in installation directory |
|
| 291 |
String path = BundleUtils.getInstallDirectory(); |
|
| 292 |
if (path != null) {
|
|
| 293 |
File installDirectory = new File(path); |
|
| 294 |
//println "installDirectory=$installDirectory" |
|
| 295 |
if (installDirectory.exists()) {
|
|
| 296 |
File artifacts = new File(installDirectory, "p2/org.eclipse.equinox.p2.core/cache/artifacts.xml"); |
|
| 297 |
//println "artifacts=$artifacts" |
|
| 298 |
if (artifacts.exists() && artifacts.canRead()) {
|
|
| 299 |
try {
|
|
| 300 |
String content = IOUtils.getText(artifacts); |
|
| 301 |
String ARTIFACT = "<artifact classifier='binary' id='org.txm.rcp.app_root"; |
|
| 302 |
int start = content.indexOf(ARTIFACT); |
|
| 303 |
//println "start=$start" |
|
| 304 |
if (start > 0) {
|
|
| 305 |
String VERSION = "version='"; |
|
| 306 |
int versionStart = content.indexOf(VERSION, start+ARTIFACT.length()); |
|
| 307 |
//println "versionStart=$versionStart" |
|
| 308 |
if (versionStart > 0) {
|
|
| 309 |
int versionEnd = content.indexOf("'", versionStart+VERSION.length());
|
|
| 310 |
if (versionEnd > 0) {
|
|
| 311 |
version = content.substring(versionStart+VERSION.length(), versionEnd); |
|
| 312 |
System.out.println("VERSION="+version);
|
|
| 313 |
} |
|
| 314 |
} |
|
| 315 |
} |
|
| 316 |
} catch (IOException e) {
|
|
| 317 |
// TODO Auto-generated catch block |
|
| 318 |
e.printStackTrace(); |
|
| 319 |
} |
|
| 320 |
} |
|
| 322 | 321 |
} |
| 323 | 322 |
} |
| 324 | 323 |
|
| 324 |
|
|
| 325 | 325 |
if (version == null) {
|
| 326 | 326 |
version = Activator.getDefault().getBundle().getVersion().toString(); |
| 327 | 327 |
} |
| 328 | 328 |
|
| 329 |
DateFormat formatter = TXMResult.PRETTY_LOCALIZED_TIME_FORMAT; |
|
| 330 |
System.out.println(NLS.bind(TXMUIMessages.startingUpP0, Activator.getDefault().getBundle().getVersion().toString(), formatter.format(new Date(Activator.getDefault().getBundle().getLastModified())))); |
|
| 329 |
String date = version.replaceAll("(.\\..\\..)\\.(....)(..)(..)(..)(..)", "$2-$3-$4 $5h$6"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 330 |
|
|
| 331 |
System.out.println(NLS.bind(TXMUIMessages.startingUpP0, |
|
| 332 |
Activator.getDefault().getBundle().getVersion().toString(), date)); |
|
| 331 | 333 |
} |
| 332 | 334 |
|
| 333 | 335 |
private void setPreferencesConfiguration() {
|
| ... | ... | |
| 563 | 565 |
installPreferenceRestored = false; // reset and finally set true if the process ended correctly |
| 564 | 566 |
|
| 565 | 567 |
try {
|
| 566 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 567 |
@Override |
|
| 568 |
public void run() { OpenWelcomePage.openWelcomePage(); }
|
|
| 569 |
}); |
|
| 568 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 569 |
@Override
|
|
| 570 |
public void run() { OpenWelcomePage.openWelcomePage(); }
|
|
| 571 |
});
|
|
| 570 | 572 |
} catch(Exception e2) {}
|
| 571 |
|
|
| 573 |
|
|
| 572 | 574 |
// set the install directory preference |
| 573 | 575 |
String installpath = Platform.getInstallLocation().getURL().getFile(); // the TXM.exe file path |
| 574 | 576 |
File installDirectory = new File(installpath); |
| ... | ... | |
| 796 | 798 |
initialCorporaDirs.add(V080); |
| 797 | 799 |
initialCorporaDirs.add(V079); |
| 798 | 800 |
|
| 799 |
|
|
| 801 |
|
|
| 800 | 802 |
Display.getDefault().syncExec(new Runnable() {
|
| 801 | 803 |
@Override |
| 802 | 804 |
public void run() {
|
| ... | ... | |
| 970 | 972 |
public void run() {
|
| 971 | 973 |
try {
|
| 972 | 974 |
printTXMVersion(); |
| 973 |
|
|
| 975 |
|
|
| 974 | 976 |
jobHandler.setTaskName(TXMUIMessages.setDefaultTheme); |
| 975 | 977 |
setDefaultTheme(); |
| 976 | 978 |
|
| ... | ... | |
| 980 | 982 |
|
| 981 | 983 |
// remove some preference pages |
| 982 | 984 |
setPreferencesConfiguration(); |
| 983 |
|
|
| 985 |
|
|
| 984 | 986 |
new ProgressMonitorDialog(Display.getDefault().getActiveShell()).run(true, true, new IRunnableWithProgress() {
|
| 985 | 987 |
|
| 986 | 988 |
@Override |
| ... | ... | |
| 1014 | 1016 |
// restore corpora if TXMHOME has been created |
| 1015 | 1017 |
if (txmHomeRestored) {
|
| 1016 | 1018 |
installCorporaDirectory(monitor); |
| 1017 |
|
|
| 1019 |
|
|
| 1018 | 1020 |
Toolbox.workspace.saveParameters(true); |
| 1019 | 1021 |
ResourcesPlugin.getWorkspace().save(true, null); |
| 1020 | 1022 |
} |
| 1021 | 1023 |
monitor.worked(20); |
| 1022 |
|
|
| 1024 |
|
|
| 1023 | 1025 |
jobHandler.setTaskName(TXMUIMessages.toolboxReady); |
| 1024 | 1026 |
} catch (Exception e) {
|
| 1025 | 1027 |
// TODO Auto-generated catch block |
| ... | ... | |
| 1030 | 1032 |
monitor.done(); |
| 1031 | 1033 |
} |
| 1032 | 1034 |
|
| 1033 |
|
|
| 1035 |
|
|
| 1034 | 1036 |
}); |
| 1035 | 1037 |
|
| 1036 | 1038 |
Log.fine(TXMUIMessages.loadingViews); |
| 1037 | 1039 |
RestartTXM.reloadViews(); // reload views |
| 1038 | 1040 |
|
| 1039 |
|
|
| 1041 |
|
|
| 1040 | 1042 |
} |
| 1041 | 1043 |
catch(Exception e) {
|
| 1042 | 1044 |
Log.severe(TXMCoreMessages.bind(TXMUIMessages.errorDuringUIInitializationP0, e.getLocalizedMessage())); |
Formats disponibles : Unified diff