Revision 2135
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/InstallURSFiles.java (revision 2135) | ||
---|---|---|
1 | 1 |
package org.txm.annotation.urs; |
2 | 2 |
|
3 | 3 |
import java.io.File; |
4 |
import java.util.Calendar; |
|
4 | 5 |
|
6 |
import org.osgi.framework.Version; |
|
5 | 7 |
import org.txm.PostTXMHOMEInstallationStep; |
6 | 8 |
import org.txm.Toolbox; |
9 |
import org.txm.annotation.urs.preferences.URSPreferences; |
|
7 | 10 |
import org.txm.objects.Workspace; |
8 | 11 |
import org.txm.utils.BundleUtils; |
12 |
import org.txm.utils.DeleteDir; |
|
13 |
import org.txm.utils.logger.Log; |
|
9 | 14 |
|
10 | 15 |
/** |
11 | 16 |
* |
... | ... | |
21 | 26 |
@Override |
22 | 27 |
public boolean do_install(Workspace workspace) { |
23 | 28 |
|
29 |
String saved = URSPreferences.getInstance().getString(URSPreferences.VERSION); //$NON-NLS-1$ |
|
30 |
Version currentVersion = BundleUtils.getBundleVersion("org.txm.annotation.urs.rcp"); //$NON-NLS-1$ |
|
31 |
Log.finer("Testing saved version with current version="+currentVersion+" and saved="+saved); |
|
32 |
if (saved != null && saved.length() > 0) { |
|
33 |
Version savedVersion = new Version(saved); |
|
34 |
if (currentVersion.compareTo(savedVersion) <= 0) { |
|
35 |
Log.finer(Messages.DoInstallStep_5); |
|
36 |
//System.out.println("No post-installation of URS to do"); |
|
37 |
return true; // nothing to do |
|
38 |
} |
|
39 |
} |
|
40 |
|
|
24 | 41 |
File txmhomedir = new File(Toolbox.getTxmHomePath()); |
25 | 42 |
|
26 | 43 |
for (String folder : createfolders) { |
... | ... | |
30 | 47 |
File userDirectory = new File(scriptsDirectory, "user"); |
31 | 48 |
File macroDirectory = new File(userDirectory, "org/txm/macro"); |
32 | 49 |
File URSMacroDirectory = new File(macroDirectory, "urs"); |
50 |
|
|
51 |
if (URSMacroDirectory.exists()) { |
|
52 |
|
|
53 |
File backDirectory = new File(macroDirectory, "urs-"+Toolbox.dateformat.format(Calendar.getInstance().getTime())); |
|
54 |
System.out.println("Making a copy of previous URS macros directory: "+URSMacroDirectory+" to "+backDirectory); |
|
55 |
|
|
56 |
URSMacroDirectory.renameTo(backDirectory); |
|
57 |
DeleteDir.deleteDirectory(URSMacroDirectory); |
|
58 |
} |
|
33 | 59 |
|
34 | 60 |
String bundle_id = "org.txm.annotation.urs.rcp"; |
35 | 61 |
BundleUtils.copyFiles(bundle_id, "src/", "org/txm/macro", "urs", macroDirectory); |
36 | 62 |
|
63 |
// saving current version |
|
64 |
URSPreferences.getInstance().put(URSPreferences.VERSION, currentVersion.toString()); |
|
65 |
|
|
37 | 66 |
return URSMacroDirectory.exists() && URSMacroDirectory.listFiles().length > 0; |
38 | 67 |
} |
39 | 68 |
|
Also available in: Unified diff