Révision 740
| tmp/org.txm.rcp/plugin.xml (revision 740) | ||
|---|---|---|
| 2852 | 2852 |
</with> |
| 2853 | 2853 |
</definition> |
| 2854 | 2854 |
<definition |
| 2855 |
id="WasNotFirstTXMRun"> |
|
| 2856 |
<systemTest |
|
| 2857 |
property="org.txm.rcp.wasfirstrun" |
|
| 2858 |
value="false"> |
|
| 2859 |
</systemTest> |
|
| 2860 |
</definition> |
|
| 2861 |
<definition |
|
| 2862 | 2855 |
id="OneLexicalTableAbleSelected"> |
| 2863 | 2856 |
<with |
| 2864 | 2857 |
variable="selection"> |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 740) | ||
|---|---|---|
| 177 | 177 |
|
| 178 | 178 |
engine.setTheme(theme, true); |
| 179 | 179 |
} |
| 180 |
|
|
| 181 |
private void openCGU() {
|
|
| 182 |
String cgu = TxmPreferences.get("cgu");
|
|
| 183 |
if (!"true".equals(cgu)) {
|
|
| 184 |
//System.out.println("Opening CGU...");
|
|
| 185 |
//Display.getCurrent() works because this code is run during the splash screen |
|
| 186 |
String[] dialogButtonLabels = {"OK", "Cancel"};
|
|
| 187 |
CGUMessageDialog dialog = new CGUMessageDialog(Display.getCurrent().getActiveShell(), |
|
| 188 |
TXMUIMessages.CGU_TITLE, |
|
| 189 |
IImageKeys.getImage(IImageKeys.TXM_ICON), |
|
| 190 |
TXMUIMessages.CGU_MESSAGE, |
|
| 191 |
IImageKeys.getImage(IImageKeys.TXM), |
|
| 192 |
TXMUIMessages.CGU_CHECKMESSAGE, |
|
| 193 |
dialogButtonLabels, 0) {
|
|
| 194 |
}; |
|
| 195 |
boolean ret = (dialog.open() == MessageDialog.OK) && dialog.hasCheckBeenPressed(); |
|
| 196 |
if (ret) {
|
|
| 197 |
TxmPreferences.set("cgu", "true");
|
|
| 198 |
} else {
|
|
| 199 |
System.exit(0); |
|
| 200 |
} |
|
| 201 |
} |
|
| 202 |
} |
|
| 180 | 203 |
|
| 181 | 204 |
/** |
| 182 | 205 |
* initialization code done after the splash screen call a job which does the |
| ... | ... | |
| 194 | 217 |
protected IStatus run(IProgressMonitor monitor) {
|
| 195 | 218 |
JobsTimer.start(); |
| 196 | 219 |
this.runInit(monitor); |
| 197 |
monitor.worked(1); |
|
| 198 | 220 |
try {
|
| 199 | 221 |
// CGU popup |
| 200 | 222 |
this.syncExec(new Runnable() {
|
| 201 | 223 |
@Override |
| 202 | 224 |
public void run() {
|
| 203 |
String cgu = TxmPreferences.get("cgu");
|
|
| 204 |
if (!"true".equals(cgu)) {
|
|
| 205 |
//System.out.println("Opening CGU...");
|
|
| 206 |
//Display.getCurrent() works because this code is run during the splash screen |
|
| 207 |
String[] dialogButtonLabels = {"OK", "Cancel"};
|
|
| 208 |
CGUMessageDialog dialog = new CGUMessageDialog(Display.getCurrent().getActiveShell(), |
|
| 209 |
TXMUIMessages.CGU_TITLE, |
|
| 210 |
IImageKeys.getImage(IImageKeys.TXM_ICON), |
|
| 211 |
TXMUIMessages.CGU_MESSAGE, |
|
| 212 |
IImageKeys.getImage(IImageKeys.TXM), |
|
| 213 |
TXMUIMessages.CGU_CHECKMESSAGE, |
|
| 214 |
dialogButtonLabels, 0) {
|
|
| 215 |
}; |
|
| 216 |
boolean ret = (dialog.open() == MessageDialog.OK) && dialog.hasCheckBeenPressed(); |
|
| 217 |
if (ret) {
|
|
| 218 |
TxmPreferences.set("cgu", "true");
|
|
| 219 |
} else {
|
|
| 220 |
System.exit(0); |
|
| 221 |
} |
|
| 222 |
} |
|
| 225 |
openCGU(); |
|
| 226 |
printTXMVersion(); // print TXM version in the console |
|
| 223 | 227 |
} |
| 224 | 228 |
}); |
| 225 | 229 |
|
| 226 | 230 |
monitor.beginTask("Starting TXM", 100);
|
| 227 |
monitor.subTask("Initialize");
|
|
| 228 |
// init with properties |
|
| 229 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 230 |
@Override |
|
| 231 |
public void run() {
|
|
| 232 |
printTXMVersion(); // print TXM version in the console |
|
| 233 |
} |
|
| 234 |
}); |
|
| 235 |
Thread.sleep(1000);// let the startup messages be displayed |
|
| 236 |
setPreferencesConfiguration(); // remove some preference pages |
|
| 237 | 231 |
|
| 238 |
//fixUpdateProfile(); |
|
| 239 |
|
|
| 240 |
// SET PREFERENCES IF THIS IS THE FIRST RUN |
|
| 241 | 232 |
monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_2); |
| 242 | 233 |
Log.warning(TXMUIMessages.ApplicationWorkbenchAdvisor_72); |
| 243 |
if (!loadInstallPreferences(this)) {
|
|
| 234 |
if (!checkInstallDirectory(this)) {
|
|
| 244 | 235 |
monitor.done(); |
| 245 | 236 |
System.err.println(TXMUIMessages.ApplicationWorkbenchAdvisor_init_failed); |
| 246 | 237 |
return Status.CANCEL_STATUS; |
| 247 | 238 |
} |
| 248 | 239 |
monitor.worked(10); |
| 249 | 240 |
|
| 250 |
// CHECK IF THIS IS THE FIRST RUN |
|
| 251 | 241 |
monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_3); |
| 252 | 242 |
Log.warning(TXMUIMessages.ApplicationWorkbenchAdvisor_73); |
| 253 | 243 |
if (!checkTXMHOME(this, monitor)) {
|
| ... | ... | |
| 263 | 253 |
monitor.done(); |
| 264 | 254 |
return Status.CANCEL_STATUS; |
| 265 | 255 |
} |
| 266 |
monitor.worked(30); |
|
| 256 |
|
|
| 257 |
// restore corpora if TXMHOME has been created |
|
| 258 |
if (txmHomeRestored) {
|
|
| 259 |
createBackUpDirectory(monitor); |
|
| 260 |
reloadCorporaFromBackUpDirectory(monitor); |
|
| 261 |
} |
|
| 267 | 262 |
|
| 268 |
// CLOSE Empty editors |
|
| 269 |
closeEmptyEditors(); |
|
| 270 |
|
|
| 271 |
|
|
| 272 | 263 |
monitor.done(); |
| 273 | 264 |
} catch (Exception e) {
|
| 274 | 265 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_75+e); |
| ... | ... | |
| 301 | 292 |
} |
| 302 | 293 |
} |
| 303 | 294 |
|
| 304 |
public static void closeEmptyEditors() {
|
|
| 295 |
public static void closeEmptyEditors() {
|
|
| 305 | 296 |
Log.info("Closing empty editors...");
|
| 306 | 297 |
String REF = "org.eclipse.ui.internal.emptyEditorTab"; |
| 307 | 298 |
|
| ... | ... | |
| 524 | 515 |
* @param jobHandler : the init job |
| 525 | 516 |
* @return true, if successful |
| 526 | 517 |
*/ |
| 527 |
private boolean loadInstallPreferences(JobHandler jobHandler) {
|
|
| 518 |
private boolean checkInstallDirectory(JobHandler jobHandler) {
|
|
| 528 | 519 |
try {
|
| 529 | 520 |
installPreferenceRestored = false; |
| 530 | 521 |
boolean needTosetInstallPreference = testTXMINSTALLPreferenceAndDirectory(); |
| ... | ... | |
| 544 | 535 |
String installpath = Platform.getInstallLocation().getURL().getFile(); // the TXM.exe file path |
| 545 | 536 |
File installDirectory = new File(installpath); |
| 546 | 537 |
//installDirectory = installDirectory.getCanonicalFile(); |
| 547 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR, installDirectory.getAbsolutePath()); |
|
| 548 |
|
|
| 538 |
|
|
| 549 | 539 |
//TODO: ensure all preferences of install.prefs file are now stored in the default preferences |
| 550 | 540 |
// File preferenceFile = new File(installDirectory, "install.prefs"); //$NON-NLS-1$ |
| 551 | 541 |
// if (preferenceFile.exists()) {
|
| ... | ... | |
| 584 | 574 |
// } |
| 585 | 575 |
|
| 586 | 576 |
installPreferenceRestored = true; |
| 577 |
|
|
| 578 |
if (installDirectory == null || !installDirectory.exists()) {
|
|
| 579 |
Log.severe("Error: The provided install directory does not exists. Aborting.");
|
|
| 580 |
return false; |
|
| 581 |
} |
|
| 582 |
|
|
| 583 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR, installDirectory.getAbsolutePath()); |
|
| 584 |
|
|
| 587 | 585 |
return true; |
| 588 | 586 |
} |
| 589 | 587 |
} catch (Exception e) {
|
| ... | ... | |
| 658 | 656 |
@Override |
| 659 | 657 |
public void close() throws SecurityException { }
|
| 660 | 658 |
}; |
| 659 |
/** |
|
| 660 |
* internal variable to know if the txm home directory has been created |
|
| 661 |
*/ |
|
| 662 |
private boolean txmHomeRestored; |
|
| 661 | 663 |
{
|
| 662 | 664 |
Log.addHandler(severeDialobBoxHandler); |
| 663 | 665 |
severeDialobBoxHandler.setLevel(Level.SEVERE); |
| ... | ... | |
| 670 | 672 |
// check if TXMHOME of the user is set and exists |
| 671 | 673 |
needToRestoreTXMHOME = testTXMHOMEPreferenceAndDirectory(); |
| 672 | 674 |
|
| 673 |
System.setProperty("org.txm.rcp.wasfirstrun", Boolean.toString(needToRestoreTXMHOME || installPreferenceRestored)); //$NON-NLS-1$
|
|
| 674 | 675 |
if (needToRestoreTXMHOME || installPreferenceRestored) {
|
| 675 | 676 |
|
| 676 | 677 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_7); |
| 677 |
try {
|
|
| 678 |
Log.info(TXMUIMessages.ApplicationWorkbenchAdvisor_68); |
|
| 679 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 680 |
@Override |
|
| 681 |
public void run() {
|
|
| 682 |
setDefaultTheme(); |
|
| 683 |
} |
|
| 684 |
}); |
|
| 685 |
} catch(Exception e) {
|
|
| 686 |
Log.warning(TXMUIMessages.ApplicationWorkbenchAdvisor_69+e); |
|
| 687 |
Log.printStackTrace(e); |
|
| 688 |
} |
|
| 689 | 678 |
|
| 690 | 679 |
try {
|
| 691 |
Log.info("Checking TXM install directory.");
|
|
| 692 |
installDirectory = new File(TXMPreferences.getString(TBXPreferences.INSTALL_DIR, TBXPreferences.PREFERENCES_NODE)); |
|
| 693 |
if (!installDirectory.exists()) { // the TXM install directory could not be read !! :o
|
|
| 694 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 695 |
@Override |
|
| 696 |
public void run() {
|
|
| 697 |
DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN); |
|
| 698 |
dialog.setText("TXM install directory is not set, Please select it.");
|
|
| 699 |
String path = dialog.open(); |
|
| 700 |
if (path != null) {
|
|
| 701 |
installDirectory = new File(path); |
|
| 702 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR, path); |
|
| 703 |
} |
|
| 704 |
} |
|
| 705 |
}); |
|
| 706 |
} |
|
| 707 |
if (installDirectory == null || !installDirectory.exists()) {
|
|
| 708 |
Log.severe("Error: The provided install directory does not exists. Aborting.");
|
|
| 709 |
return false; |
|
| 710 |
} |
|
| 711 | 680 |
Log.info(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_8, TXMPreferences.getString(TBXPreferences.INSTALL_DIR, TBXPreferences.PREFERENCES_NODE))); |
| 712 | 681 |
|
| 713 | 682 |
Log.info("Checking TXM user directory.");
|
| ... | ... | |
| 726 | 695 |
|
| 727 | 696 |
txmhomedir.mkdirs(); // creates the directory if needed |
| 728 | 697 |
|
| 729 |
if (!txmhomedir.exists()) { // the TXM user directory could not be created !! :o
|
|
| 730 |
Log.warning(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_12, txmhomedir)); |
|
| 731 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 732 |
@Override |
|
| 733 |
public void run() {
|
|
| 734 |
DirectoryDialog dialog = new DirectoryDialog(Display.getCurrent().getActiveShell(), SWT.OPEN); |
|
| 735 |
dialog.setText("Please choose the TXM user directory to use.");
|
|
| 736 |
String path = dialog.open(); |
|
| 737 |
if (path != null) {
|
|
| 738 |
txmhomedir = new File(path); |
|
| 739 |
txmhomedir.mkdirs(); |
|
| 740 |
} |
|
| 741 |
} |
|
| 742 |
}); |
|
| 743 |
} |
|
| 744 |
if (txmhomedir == null || !txmhomedir.exists()) {
|
|
| 698 |
if (!txmhomedir.exists()) {
|
|
| 745 | 699 |
Log.severe("Error: The provided TXMHOME directory does not exists: "+txmhomedir+". Aborting");
|
| 746 | 700 |
return false; |
| 747 | 701 |
} |
| 748 |
Log.info("TXM User directory is set to: "+txmhomedir);
|
|
| 749 | 702 |
|
| 750 |
backup = new File(txmhomedir, "corpus-backup"); //$NON-NLS-1$
|
|
| 751 |
oldbackup = new File(txmhomedir, "corpus-backup-old"); //$NON-NLS-1$
|
|
| 752 |
errorbackup = new File(txmhomedir, "corpus-backup-error"); //$NON-NLS-1$
|
|
| 703 |
// save preference if USER_TXM_HOME has changed
|
|
| 704 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE,
|
|
| 705 |
TBXPreferences.USER_TXM_HOME, txmhomedir.getAbsolutePath());
|
|
| 753 | 706 |
|
| 754 |
corporaDir = new File(txmhomedir, "corpora"); //$NON-NLS-1$ |
|
| 755 |
File[] corporaDirFiles = corporaDir.listFiles(); |
|
| 756 |
if (corporaDir.exists() && corporaDirFiles != null && corporaDirFiles.length > 0) { // if the txmhomedir is not empty, try to restore its content
|
|
| 757 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 758 |
@Override |
|
| 759 |
public void run() {
|
|
| 760 |
Display display = Display.getDefault(); |
|
| 761 |
Shell shell = display.getActiveShell(); |
|
| 762 |
go = MessageDialog.openConfirm(shell, TXMUIMessages.ApplicationWorkbenchAdvisor_28, NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_27, txmhomedir)); |
|
| 763 |
} |
|
| 764 |
}); |
|
| 765 |
|
|
| 766 |
if (go) {
|
|
| 767 |
monitor.setTaskName(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_30, backup.getAbsolutePath())); |
|
| 768 |
backup.mkdir(); |
|
| 769 |
|
|
| 770 |
if (!backup.exists()) {
|
|
| 771 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_34 + backup); |
|
| 772 |
return false; |
|
| 773 |
} |
|
| 774 |
|
|
| 775 |
//$NON-NLS-1$ |
|
| 776 |
if (oldbackup.exists()) {
|
|
| 777 |
Log.info(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_16, oldbackup)); |
|
| 778 |
DeleteDir.deleteDirectory(oldbackup); // ]8) |
|
| 779 |
} |
|
| 780 |
|
|
| 781 |
File[] corpDirs = corporaDir.listFiles(); |
|
| 782 |
ArrayList<String> moved = new ArrayList<String>(); |
|
| 783 |
ArrayList<String> failed = new ArrayList<String>(); |
|
| 784 |
|
|
| 785 |
if (corpDirs != null) {
|
|
| 786 |
Arrays.sort(corpDirs); |
|
| 787 |
System.out.print(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_30, backup.getAbsolutePath())); |
|
| 788 |
for (File corpusdir : corpDirs) {
|
|
| 789 |
File backCorpus = new File(backup, corpusdir.getName()); |
|
| 790 |
if (corpusdir.canRead() && corpusdir.isDirectory()) {
|
|
| 791 |
System.out.print("."); //$NON-NLS-1$
|
|
| 792 |
if (backCorpus.exists()) {
|
|
| 793 |
moved.add(corpusdir.getName()); |
|
| 794 |
oldbackup.mkdir(); |
|
| 795 |
backCorpus.renameTo(new File(oldbackup, corpusdir.getName())); |
|
| 796 |
} |
|
| 797 |
|
|
| 798 |
if (!corpusdir.renameTo(backCorpus)) {
|
|
| 799 |
failed.add(corpusdir.getName()); |
|
| 800 |
} |
|
| 801 |
} |
|
| 802 |
} |
|
| 803 |
System.out.println(); |
|
| 804 |
} |
|
| 805 |
if (moved.size() > 0) {
|
|
| 806 |
Log.info(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_18,oldbackup,StringUtils.join(moved,", "))); //$NON-NLS-1$ |
|
| 807 |
} |
|
| 808 |
if (failed.size() > 0) {
|
|
| 809 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_44+failed+TXMUIMessages.ApplicationWorkbenchAdvisor_37+backup); |
|
| 810 |
} |
|
| 811 |
} |
|
| 812 |
} |
|
| 707 |
|
|
| 708 |
Log.info("TXM User directory is set to: "+txmhomedir);
|
|
| 709 |
|
|
| 710 |
txmHomeRestored = true; |
|
| 813 | 711 |
} catch (Exception e) {
|
| 814 | 712 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
| 815 | 713 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_47+" "+e.getLocalizedMessage()); //$NON-NLS-1$ |
| ... | ... | |
| 818 | 716 |
} |
| 819 | 717 |
|
| 820 | 718 |
|
| 821 |
// create or update the workspace & create TXM default.xml workspace file |
|
| 822 |
Toolbox.workspace = Workspace.createOrUpdate(txmhomedir); //$NON-NLS-1$ |
|
| 719 |
|
|
| 823 | 720 |
|
| 824 |
// test |
|
| 825 |
if (Toolbox.workspace == null) {
|
|
| 826 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_31); |
|
| 827 |
return false;
|
|
| 828 |
}
|
|
| 721 |
|
|
| 722 |
} // end if
|
|
| 723 |
|
|
| 724 |
return true;
|
|
| 725 |
} |
|
| 829 | 726 |
|
| 830 |
try {
|
|
| 831 |
TXMPreferences.put(TBXPreferences.PREFERENCES_NODE, |
|
| 832 |
TBXPreferences.USER_TXM_HOME, txmhomedir.getAbsolutePath()); |
|
| 833 |
} catch (Exception e) {
|
|
| 834 |
Log.severe(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_41, e.getLocalizedMessage())); |
|
| 835 |
System.out.println(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_41, e.getLocalizedMessage())); |
|
| 836 |
return false; |
|
| 837 |
} |
|
| 727 |
private void createBackUpDirectory(IProgressMonitor monitor) {
|
|
| 728 |
|
|
| 729 |
backup = new File(txmhomedir, "corpus-backup"); //$NON-NLS-1$ |
|
| 730 |
oldbackup = new File(txmhomedir, "corpus-backup-old"); //$NON-NLS-1$ |
|
| 731 |
errorbackup = new File(txmhomedir, "corpus-backup-error"); //$NON-NLS-1$ |
|
| 732 |
|
|
| 733 |
corporaDir = new File(txmhomedir, "corpora"); //$NON-NLS-1$ |
|
| 734 |
|
|
| 735 |
File[] corporaDirFiles = corporaDir.listFiles(); |
|
| 736 |
if (corporaDir.exists() && corporaDirFiles != null && corporaDirFiles.length > 0) { // if the txmhomedir is not empty, try to restore its content
|
|
| 737 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 738 |
@Override |
|
| 739 |
public void run() {
|
|
| 740 |
Display display = Display.getDefault(); |
|
| 741 |
Shell shell = display.getActiveShell(); |
|
| 742 |
go = MessageDialog.openConfirm(shell, TXMUIMessages.ApplicationWorkbenchAdvisor_28, NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_27, txmhomedir)); |
|
| 743 |
} |
|
| 744 |
}); |
|
| 838 | 745 |
|
| 839 |
try {
|
|
| 840 |
ArrayList<String> basenames = new ArrayList<String>(); |
|
| 841 |
ArrayList<String> sampleCorpusLoaded = new ArrayList<String>(); |
|
| 842 |
|
|
| 843 |
String installdirpath = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR); |
|
| 844 |
File sampleCorporaDirectory = new File(installdirpath, "samples"); |
|
| 845 |
// load corpora from the install directory |
|
| 846 |
if (sampleCorporaDirectory.exists()) { //$NON-NLS-1$
|
|
| 847 |
Log.info(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
| 848 |
monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
| 849 |
//File corporaDir = new File(txmhomedir.getAbsolutePath(), "corpora"); //$NON-NLS-1$ |
|
| 850 |
corporaDir.mkdir(); |
|
| 746 |
if (go) {
|
|
| 747 |
monitor.setTaskName(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_30, backup.getAbsolutePath())); |
|
| 748 |
backup.mkdir(); |
|
| 851 | 749 |
|
| 852 |
File[] sampleCorpusFiles = sampleCorporaDirectory.listFiles(); //$NON-NLS-1$ |
|
| 750 |
if (!backup.exists()) {
|
|
| 751 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_34 + backup); |
|
| 752 |
return; |
|
| 753 |
} |
|
| 853 | 754 |
|
| 854 |
if (sampleCorpusFiles != null) for (File zipFile : sampleCorpusFiles) {
|
|
| 855 |
try {
|
|
| 856 |
String filename = zipFile.getName(); |
|
| 857 |
File basedir; |
|
| 858 |
String basedirname; |
|
| 859 |
if (filename.endsWith(".txm") || filename.endsWith(".zip")) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 860 |
if (!zipFile.canRead()) {
|
|
| 861 |
System.out.println(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_45, zipFile)); |
|
| 862 |
continue; // go to next binary file |
|
| 863 |
} |
|
| 755 |
//$NON-NLS-1$ |
|
| 756 |
if (oldbackup.exists()) {
|
|
| 757 |
Log.info(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_16, oldbackup)); |
|
| 758 |
DeleteDir.deleteDirectory(oldbackup); // ]8) |
|
| 759 |
} |
|
| 864 | 760 |
|
| 865 |
//build binary dir path
|
|
| 866 |
basedirname = Zip.getRoot(zipFile);
|
|
| 867 |
basedir = new File(corporaDir, basedirname);
|
|
| 761 |
File[] corpDirs = corporaDir.listFiles();
|
|
| 762 |
ArrayList<String> moved = new ArrayList<String>();
|
|
| 763 |
ArrayList<String> failed = new ArrayList<String>();
|
|
| 868 | 764 |
|
| 869 |
try {
|
|
| 870 |
Zip.decompress(zipFile.getAbsolutePath(), corporaDir.getAbsolutePath(), false);
|
|
| 871 |
} catch (IOException e) {
|
|
| 872 |
System.out.println(NLS.bind(TXMUIMessages.AddBase_31, e));
|
|
| 873 |
}
|
|
| 874 |
} else if (zipFile.isDirectory()) {
|
|
| 875 |
basedir = zipFile;
|
|
| 876 |
} else {
|
|
| 877 |
System.out.println(NLS.bind(TXMUIMessages.AddBase_22, zipFile));
|
|
| 878 |
System.out.println(TXMUIMessages.AddBase_25);
|
|
| 879 |
continue;
|
|
| 765 |
if (corpDirs != null) {
|
|
| 766 |
Arrays.sort(corpDirs);
|
|
| 767 |
System.out.print(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_30, backup.getAbsolutePath()));
|
|
| 768 |
for (File corpusdir : corpDirs) {
|
|
| 769 |
File backCorpus = new File(backup, corpusdir.getName());
|
|
| 770 |
if (corpusdir.canRead() && corpusdir.isDirectory()) {
|
|
| 771 |
System.out.print("."); //$NON-NLS-1$
|
|
| 772 |
if (backCorpus.exists()) {
|
|
| 773 |
moved.add(corpusdir.getName());
|
|
| 774 |
oldbackup.mkdir();
|
|
| 775 |
backCorpus.renameTo(new File(oldbackup, corpusdir.getName()));
|
|
| 880 | 776 |
} |
| 881 | 777 |
|
| 882 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(basedir); |
|
| 883 |
if (base != null) {
|
|
| 884 |
basenames.add(base.getName()); |
|
| 885 |
sampleCorpusLoaded.add(base.getName()); |
|
| 778 |
if (!corpusdir.renameTo(backCorpus)) {
|
|
| 779 |
failed.add(corpusdir.getName()); |
|
| 886 | 780 |
} |
| 887 |
} catch (Exception e) {
|
|
| 888 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_51+zipFile); |
|
| 889 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 890 | 781 |
} |
| 891 | 782 |
} |
| 783 |
System.out.println(); |
|
| 892 | 784 |
} |
| 785 |
if (moved.size() > 0) {
|
|
| 786 |
Log.info(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_18,oldbackup,StringUtils.join(moved,", "))); //$NON-NLS-1$ |
|
| 787 |
} |
|
| 788 |
if (failed.size() > 0) {
|
|
| 789 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_44+failed+TXMUIMessages.ApplicationWorkbenchAdvisor_37+backup); |
|
| 790 |
} |
|
| 791 |
} |
|
| 792 |
} |
|
| 793 |
} |
|
| 893 | 794 |
|
| 894 |
// after loading sample corpora, restore older corpus |
|
| 895 |
if (backup.exists()) {
|
|
| 896 |
System.out.print(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
| 897 |
monitor.setTaskName(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
| 795 |
private void reloadCorporaFromBackUpDirectory(IProgressMonitor monitor) {
|
|
| 796 |
ArrayList<String> basenames = new ArrayList<String>(); |
|
| 797 |
ArrayList<String> sampleCorpusLoaded = new ArrayList<String>(); |
|
| 798 |
|
|
| 799 |
String installdirpath = TXMPreferences.getString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.INSTALL_DIR); |
|
| 800 |
File sampleCorporaDirectory = new File(installdirpath, "samples"); |
|
| 801 |
// load corpora from the install directory |
|
| 802 |
if (sampleCorporaDirectory.exists()) { //$NON-NLS-1$
|
|
| 803 |
Log.info(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
| 804 |
monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_11); |
|
| 805 |
//File corporaDir = new File(txmhomedir.getAbsolutePath(), "corpora"); //$NON-NLS-1$ |
|
| 806 |
corporaDir.mkdir(); |
|
| 898 | 807 |
|
| 899 |
File[] corpusDirs = backup.listFiles();
|
|
| 808 |
File[] sampleCorpusFiles = sampleCorporaDirectory.listFiles(); //$NON-NLS-1$
|
|
| 900 | 809 |
|
| 901 |
if (corpusDirs != null) {
|
|
| 810 |
if (sampleCorpusFiles != null) for (File zipFile : sampleCorpusFiles) {
|
|
| 811 |
try {
|
|
| 812 |
String filename = zipFile.getName(); |
|
| 813 |
File basedir; |
|
| 814 |
String basedirname; |
|
| 815 |
if (filename.endsWith(".txm") || filename.endsWith(".zip")) { //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 816 |
if (!zipFile.canRead()) {
|
|
| 817 |
System.out.println(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_45, zipFile)); |
|
| 818 |
continue; // go to next binary file |
|
| 819 |
} |
|
| 902 | 820 |
|
| 903 |
for (File corpusDir : corpusDirs) { // fix corpus name lowercase letters
|
|
| 904 |
if (!corpusDir.getName().equals(corpusDir.getName().toUpperCase())) {
|
|
| 905 |
File upperCasedCorpusDir = new File(corpusDir.getParentFile(), corpusDir.getName().toUpperCase()); |
|
| 906 |
if (!upperCasedCorpusDir.exists()) {
|
|
| 907 |
corpusDir.renameTo(upperCasedCorpusDir); |
|
| 908 |
} |
|
| 909 |
} |
|
| 821 |
//build binary dir path |
|
| 822 |
basedirname = Zip.getRoot(zipFile); |
|
| 823 |
basedir = new File(corporaDir, basedirname); |
|
| 824 |
|
|
| 825 |
try {
|
|
| 826 |
Zip.decompress(zipFile.getAbsolutePath(), corporaDir.getAbsolutePath(), false); |
|
| 827 |
} catch (IOException e) {
|
|
| 828 |
System.out.println(NLS.bind(TXMUIMessages.AddBase_31, e)); |
|
| 910 | 829 |
} |
| 911 |
corpusDirs = backup.listFiles(); |
|
| 830 |
} else if (zipFile.isDirectory()) {
|
|
| 831 |
basedir = zipFile; |
|
| 832 |
} else {
|
|
| 833 |
System.out.println(NLS.bind(TXMUIMessages.AddBase_22, zipFile)); |
|
| 834 |
System.out.println(TXMUIMessages.AddBase_25); |
|
| 835 |
continue; |
|
| 836 |
} |
|
| 912 | 837 |
|
| 913 |
ArrayList<String> notMoved = new ArrayList<String>(); |
|
| 914 |
ArrayList<File> broken = new ArrayList<File>(); |
|
| 838 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(basedir); |
|
| 839 |
if (base != null) {
|
|
| 840 |
basenames.add(base.getName()); |
|
| 841 |
sampleCorpusLoaded.add(base.getName()); |
|
| 842 |
} |
|
| 843 |
} catch (Exception e) {
|
|
| 844 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_51+zipFile); |
|
| 845 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 846 |
} |
|
| 847 |
} |
|
| 848 |
} |
|
| 915 | 849 |
|
| 916 |
for (File corpusDir : corpusDirs) {
|
|
| 917 |
if (!corpusDir.isDirectory()) continue; // ignore |
|
| 918 |
System.out.print("."); //$NON-NLS-1$
|
|
| 919 |
File outdir = new File(corporaDir, corpusDir.getName()); |
|
| 920 |
if (outdir.exists()) {
|
|
| 921 |
//System.out.println("This setup provides a new version of the "+corpusDir.getName()+" sample corpus. Skipping the backup of "+corpusDir);
|
|
| 922 |
notMoved.add(corpusDir.getName()); |
|
| 923 |
continue; |
|
| 924 |
} |
|
| 850 |
// after loading sample corpora, restore older corpus |
|
| 851 |
if (backup.exists()) {
|
|
| 852 |
System.out.print(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
| 853 |
monitor.setTaskName(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup)); |
|
| 925 | 854 |
|
| 926 |
try {
|
|
| 927 |
Convert5To6 converter = new Convert5To6(corpusDir, outdir); |
|
| 928 |
if (converter.is5(true)) {
|
|
| 929 |
if (!converter.start()) {
|
|
| 930 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_22+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_23); |
|
| 931 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_54+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_55); |
|
| 932 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_56); |
|
| 855 |
File[] corpusDirs = backup.listFiles(); |
|
| 856 |
|
|
| 857 |
if (corpusDirs != null) {
|
|
| 858 |
|
|
| 859 |
for (File corpusDir : corpusDirs) { // fix corpus name lowercase letters
|
|
| 860 |
if (!corpusDir.getName().equals(corpusDir.getName().toUpperCase())) {
|
|
| 861 |
File upperCasedCorpusDir = new File(corpusDir.getParentFile(), corpusDir.getName().toUpperCase()); |
|
| 862 |
if (!upperCasedCorpusDir.exists()) {
|
|
| 863 |
corpusDir.renameTo(upperCasedCorpusDir); |
|
| 864 |
} |
|
| 865 |
} |
|
| 866 |
} |
|
| 867 |
corpusDirs = backup.listFiles(); |
|
| 868 |
|
|
| 869 |
ArrayList<String> notMoved = new ArrayList<String>(); |
|
| 870 |
ArrayList<File> broken = new ArrayList<File>(); |
|
| 871 |
|
|
| 872 |
for (File corpusDir : corpusDirs) {
|
|
| 873 |
if (!corpusDir.isDirectory()) continue; // ignore |
|
| 874 |
System.out.print("."); //$NON-NLS-1$
|
|
| 875 |
File outdir = new File(corporaDir, corpusDir.getName()); |
|
| 876 |
if (outdir.exists()) {
|
|
| 877 |
//System.out.println("This setup provides a new version of the "+corpusDir.getName()+" sample corpus. Skipping the backup of "+corpusDir);
|
|
| 878 |
notMoved.add(corpusDir.getName()); |
|
| 879 |
continue; |
|
| 880 |
} |
|
| 881 |
|
|
| 882 |
try {
|
|
| 883 |
Convert5To6 converter = new Convert5To6(corpusDir, outdir); |
|
| 884 |
if (converter.is5(true)) {
|
|
| 885 |
if (!converter.start()) {
|
|
| 886 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_22+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_23); |
|
| 887 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_54+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_55); |
|
| 888 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_56); |
|
| 889 |
broken.add(corpusDir); |
|
| 890 |
} else {
|
|
| 891 |
//System.out.println(Messages.ApplicationWorkbenchAdvisor_57+outdir); |
|
| 892 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
| 893 |
basenames.add(base.getName()); |
|
| 894 |
} |
|
| 895 |
} else {
|
|
| 896 |
if (Convert5To6.is6(corpusDir)) {
|
|
| 897 |
if (corpusDir.renameTo(outdir)) {
|
|
| 898 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
| 899 |
if (base == null) {
|
|
| 900 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_58+outdir); |
|
| 901 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
| 902 |
outdir.renameTo(corpusDir); |
|
| 933 | 903 |
broken.add(corpusDir); |
| 934 | 904 |
} else {
|
| 935 |
//System.out.println(Messages.ApplicationWorkbenchAdvisor_57+outdir); |
|
| 936 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
| 937 | 905 |
basenames.add(base.getName()); |
| 938 | 906 |
} |
| 939 | 907 |
} else {
|
| 940 |
if (Convert5To6.is6(corpusDir)) {
|
|
| 941 |
if (corpusDir.renameTo(outdir)) {
|
|
| 942 |
Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir); |
|
| 943 |
if (base == null) {
|
|
| 944 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_58+outdir); |
|
| 945 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
| 946 |
outdir.renameTo(corpusDir); |
|
| 947 |
broken.add(corpusDir); |
|
| 948 |
} else {
|
|
| 949 |
basenames.add(base.getName()); |
|
| 950 |
} |
|
| 951 |
} else {
|
|
| 952 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_24+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_26+outdir); |
|
| 953 |
broken.add(corpusDir); |
|
| 954 |
} |
|
| 955 |
} else {
|
|
| 956 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_60+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_61); |
|
| 957 |
broken.add(corpusDir); |
|
| 958 |
} |
|
| 908 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_24+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_26+outdir); |
|
| 909 |
broken.add(corpusDir); |
|
| 959 | 910 |
} |
| 960 |
} catch (Throwable e) {
|
|
| 961 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
| 962 |
System.out.println(TXMUIMessages.ERROR+e); |
|
| 963 |
outdir.renameTo(corpusDir); |
|
| 964 |
} |
|
| 965 |
} |
|
| 966 |
System.out.println(); |
|
| 967 |
if (sampleCorpusLoaded.size() > 0) {
|
|
| 968 |
if (sampleCorpusLoaded.size() == 1) {
|
|
| 969 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43_single, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
| 970 | 911 |
} else {
|
| 971 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
| 912 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_60+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_61); |
|
| 913 |
broken.add(corpusDir); |
|
| 972 | 914 |
} |
| 973 | 915 |
} |
| 974 |
|
|
| 975 |
if (broken.size() > 0) {
|
|
| 976 |
errorbackup.mkdir(); |
|
| 977 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_48, StringUtils.join(broken, ", "), errorbackup)); //$NON-NLS-1$ |
|
| 978 |
for(File corpusDir : broken) {
|
|
| 979 |
if (corpusDir.exists()) |
|
| 980 |
corpusDir.renameTo(new File(errorbackup, corpusDir.getName())); |
|
| 981 |
} |
|
| 982 |
} |
|
| 916 |
} catch (Throwable e) {
|
|
| 917 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir); |
|
| 918 |
System.out.println(TXMUIMessages.ERROR+e); |
|
| 919 |
outdir.renameTo(corpusDir); |
|
| 983 | 920 |
} |
| 984 | 921 |
} |
| 985 |
|
|
| 986 |
Toolbox.workspace.save(); |
|
| 987 |
|
|
| 988 |
// init with properties |
|
| 989 |
if (Toolbox.initialize(TBXPreferences.class, monitor)) {
|
|
| 990 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_ready); |
|
| 991 |
} else {
|
|
| 992 |
System.err.println(TXMUIMessages.ApplicationWorkbenchAdvisor_init_failed); |
|
| 993 |
return false; |
|
| 922 |
System.out.println(); |
|
| 923 |
if (sampleCorpusLoaded.size() > 0) {
|
|
| 924 |
if (sampleCorpusLoaded.size() == 1) {
|
|
| 925 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43_single, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
| 926 |
} else {
|
|
| 927 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$ |
|
| 928 |
} |
|
| 994 | 929 |
} |
| 995 | 930 |
|
| 996 |
if (Toolbox.isInitialized()) {
|
|
| 997 |
monitor.setTaskName("Executing start.groovy script...");
|
|
| 998 |
callStartScript();
|
|
| 999 |
monitor.setTaskName("Saving workspace...");
|
|
| 1000 |
Toolbox.workspace.save();
|
|
| 1001 |
} else {
|
|
| 1002 |
return false;
|
|
| 931 |
if (broken.size() > 0) {
|
|
| 932 |
errorbackup.mkdir();
|
|
| 933 |
System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_48, StringUtils.join(broken, ", "), errorbackup)); //$NON-NLS-1$
|
|
| 934 |
for(File corpusDir : broken) {
|
|
| 935 |
if (corpusDir.exists())
|
|
| 936 |
corpusDir.renameTo(new File(errorbackup, corpusDir.getName()));
|
|
| 937 |
}
|
|
| 1003 | 938 |
} |
| 1004 |
} catch (Exception e) {
|
|
| 1005 |
Log.severe(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_52, e.getLocalizedMessage())); |
|
| 1006 |
System.err.println(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_52, e.getLocalizedMessage())); |
|
| 1007 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 1008 |
return false; |
|
| 1009 | 939 |
} |
| 1010 |
} // end if |
|
| 1011 |
|
|
| 1012 |
return true; |
|
| 940 |
} |
|
| 1013 | 941 |
} |
| 1014 | 942 |
|
| 1015 | 943 |
/** |
| ... | ... | |
| 1098 | 1026 |
|
| 1099 | 1027 |
/** |
| 1100 | 1028 |
* after TXMHOME AND INSTALLDIR are ok, we start launch the Toolbox after |
| 1101 |
* init, we refresh the views (corpora, bases and query). |
|
| 1102 |
* |
|
| 1029 |
* init, |
|
| 1030 |
* <p> |
|
| 1031 |
* we refresh the views (corpora, bases and query). |
|
| 1032 |
* <p> |
|
| 1033 |
* we close empty editors |
|
| 1034 |
* <p> |
|
| 1035 |
* we remove some preferences pages not useful |
|
| 1036 |
* |
|
| 1103 | 1037 |
* @param jobHandler the job |
| 1104 | 1038 |
* @return true, if successful |
| 1105 | 1039 |
* @throws Exception |
| ... | ... | |
| 1119 | 1053 |
try {
|
| 1120 | 1054 |
monitor.worked(1); |
| 1121 | 1055 |
monitor.setTaskName("Initializing Toolbox (engines and corpora)...");
|
| 1122 |
Toolbox.initialize(TBXPreferences.class, monitor); |
|
| 1056 |
// init with Eclipse preference stores |
|
| 1057 |
if (Toolbox.initialize(TBXPreferences.class, monitor)) {
|
|
| 1058 |
System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_ready); |
|
| 1059 |
} else {
|
|
| 1060 |
System.err.println(TXMUIMessages.ApplicationWorkbenchAdvisor_init_failed); |
|
| 1061 |
return; |
|
| 1062 |
} |
|
| 1123 | 1063 |
monitor.setTaskName("Calling start script...");
|
| 1124 | 1064 |
callStartScript(); |
| 1125 | 1065 |
} |
| ... | ... | |
| 1132 | 1072 |
monitor.done(); |
| 1133 | 1073 |
} |
| 1134 | 1074 |
}); |
| 1075 |
|
|
| 1076 |
Log.warning(TXMUIMessages.ApplicationWorkbenchAdvisor_88); |
|
| 1077 |
RestartTXM.reloadViews(); // reload views |
|
| 1078 |
|
|
| 1079 |
if (Toolbox.isInitialized()) {
|
|
| 1080 |
StatusLine.setMessage(TXMUIMessages.ApplicationWorkbenchAdvisor_ready); |
|
| 1081 |
} else {
|
|
| 1082 |
StatusLine.setMessage(TXMUIMessages.ApplicationWorkbenchAdvisor_init_failed); |
|
| 1083 |
} |
|
| 1084 |
|
|
| 1085 |
setDefaultTheme(); |
|
| 1086 |
|
|
| 1087 |
// CLOSE Empty&Error editors |
|
| 1088 |
closeEmptyEditors(); |
|
| 1089 |
|
|
| 1090 |
// remove some preference pages |
|
| 1091 |
setPreferencesConfiguration(); |
|
| 1092 |
|
|
| 1135 | 1093 |
} |
| 1136 | 1094 |
catch(Exception e) {
|
| 1137 |
// TODO Auto-generated catch block
|
|
| 1095 |
System.out.println("Error during UI initialization: "+e.getLocalizedMessage());
|
|
| 1138 | 1096 |
e.printStackTrace(); |
| 1139 | 1097 |
} |
| 1140 | 1098 |
} |
| ... | ... | |
| 1172 | 1130 |
// } |
| 1173 | 1131 |
// } |
| 1174 | 1132 |
|
| 1175 |
// reload corpora and bases views |
|
| 1176 |
Display.getDefault().syncExec(new Runnable() {
|
|
| 1177 |
@Override |
|
| 1178 |
public void run() {
|
|
| 1179 |
Log.warning(TXMUIMessages.ApplicationWorkbenchAdvisor_88); |
|
| 1180 |
RestartTXM.reloadViews(); |
|
| 1181 |
|
|
| 1182 |
if (Toolbox.isInitialized()) {
|
|
| 1183 |
StatusLine.setMessage(TXMUIMessages.ApplicationWorkbenchAdvisor_ready); |
|
| 1184 |
} else {
|
|
| 1185 |
StatusLine.setMessage(TXMUIMessages.ApplicationWorkbenchAdvisor_init_failed); |
|
| 1186 |
} |
|
| 1187 |
} |
|
| 1188 |
}); |
|
| 1189 |
|
|
| 1190 | 1133 |
//TxmPreferences.dump(); |
| 1191 | 1134 |
return true; |
| 1192 | 1135 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/DeleteObject.java (revision 740) | ||
|---|---|---|
| 172 | 172 |
if (allObjectDeleted.size() > 0) {
|
| 173 | 173 |
|
| 174 | 174 |
if (shouldRestartToolbox) {
|
| 175 |
org.txm.Toolbox.restartWorkspace(); |
|
| 175 |
org.txm.Toolbox.restartWorkspace(null);
|
|
| 176 | 176 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
| 177 | 177 |
|
| 178 | 178 |
System.err.println(TXMUIMessages.AddBase_10); |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/ConvertCorpus.java (revision 740) | ||
|---|---|---|
| 58 | 58 |
System.out.println(TXMUIMessages.ConvertCorpus_0); |
| 59 | 59 |
return Status.CANCEL_STATUS; |
| 60 | 60 |
} |
| 61 |
|
|
| 62 |
this.acquireSemaphore(); |
|
| 63 |
org.txm.Toolbox.restartWorkspace(monitor); |
|
| 64 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
|
| 65 |
this.releaseSemaphore(); |
|
| 66 |
|
|
| 67 |
syncExec(new Runnable() {
|
|
| 68 |
@Override |
|
| 69 |
public void run() {
|
|
| 70 |
RestartTXM.reloadViews(); |
|
| 71 |
} |
|
| 72 |
}); |
|
| 73 |
|
|
| 61 | 74 |
} catch (Throwable e) {
|
| 62 | 75 |
System.out.println(NLS.bind(TXMUIMessages.RunGroovyScript_8, |
| 63 | 76 |
e)); |
| ... | ... | |
| 66 | 79 |
monitor.done(); |
| 67 | 80 |
} |
| 68 | 81 |
|
| 69 |
this.acquireSemaphore(); |
|
| 70 |
org.txm.Toolbox.restartWorkspace(); |
|
| 71 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
|
| 72 |
this.releaseSemaphore(); |
|
| 73 |
|
|
| 74 |
syncExec(new Runnable() {
|
|
| 75 |
@Override |
|
| 76 |
public void run() {
|
|
| 77 |
RestartTXM.reloadViews(); |
|
| 78 |
} |
|
| 79 |
}); |
|
| 82 |
|
|
| 80 | 83 |
} catch (ThreadDeath td) {
|
| 81 | 84 |
monitor.done(); |
| 82 | 85 |
return Status.CANCEL_STATUS; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 740) | ||
|---|---|---|
| 117 | 117 |
System.out.println(TXMUIMessages.LoadBinaryCorpus_15+backup); |
| 118 | 118 |
return; |
| 119 | 119 |
} |
| 120 |
org.txm.Toolbox.restartWorkspace(); |
|
| 120 |
org.txm.Toolbox.restartWorkspace(null);
|
|
| 121 | 121 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
| 122 | 122 |
} |
| 123 | 123 |
} |
| ... | ... | |
| 208 | 208 |
|
| 209 | 209 |
this.acquireSemaphore(); |
| 210 | 210 |
//Toolbox.updateProperties(ApplicationWorkbenchAdvisor.getProperties()); |
| 211 |
org.txm.Toolbox.restartWorkspace(); |
|
| 211 |
org.txm.Toolbox.restartWorkspace(monitor);
|
|
| 212 | 212 |
Toolbox.getEngineManager(EngineType.SEARCH).restartEngines(); |
| 213 | 213 |
this.releaseSemaphore(); |
| 214 | 214 |
|
| tmp/trunk/org.txm.setups/BuildLinux64bit.sh (revision 740) | ||
|---|---|---|
| 70 | 70 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/TXM/\/usr\/share\/TXM_$VERSION/g" {} \;
|
| 71 | 71 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/applications\/TXM.desktop/\/usr\/share\/applications\/TXM_$VERSION.desktop/g" {} \;
|
| 72 | 72 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/applications\/TXM debug.desktop/\/usr\/share\/applications\/TXM_$VERSION debug.desktop/g" {} \;
|
| 73 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/doc/\txm/\/usr\/share\/doc/\txm-$VERSION/g" {} \;
|
|
| 74 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/lintiant/overrides/\txm/\/usr\/share\/lintiant/overrides/\txm-$VERSION/g" {} \;
|
|
| 73 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/doc\/txm/\/usr\/share\/doc\/txm-$VERSION/g" {} \;
|
|
| 74 |
find "$APP/DEBIAN/preinst" -type f -exec sed -i "s/\/usr\/share\/lintiant\/overrides\/txm/\/usr\/share\/lintiant\/overrides\/txm-$VERSION/g" {} \;
|
|
| 75 | 75 |
find "$APP/DEBIAN/postinst" -type f -exec sed -i "s/\/usr\/lib\/TXM/\/usr\/lib\/TXM_$VERSION/g" {} \;
|
| 76 | 76 |
find "$APP/DEBIAN/postinst" -type f -exec sed -i "s/TXM\&/TXM-{VERSION}\&/g" {} \;
|
| 77 | 77 |
find "$APP/DEBIAN/control" -type f -exec sed -i "s/Package: txm/Package: txm-${VERSION}/g" {} \;
|
| tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/InstallRUserPart.java (revision 740) | ||
|---|---|---|
| 13 | 13 |
File dir = new File(workspace.getLocation(), "R/libraries"); |
| 14 | 14 |
dir.mkdirs(); |
| 15 | 15 |
|
| 16 |
File scriptsDirectory = new File(workspace.getLocation(), "scripts"); |
|
| 17 |
File samplesDirectory = new File(scriptsDirectory, "samples/R"); |
|
| 18 |
samplesDirectory.mkdirs(); |
|
| 19 |
BundleUtils.copyFiles("org.txm.statsengine.r.core", "", "", "R", scriptsDirectory);
|
|
| 16 |
File scriptsDirectory = new File(workspace.getLocation(), "scripts/samples"); |
|
| 17 |
scriptsDirectory.mkdirs(); |
|
| 18 |
BundleUtils.copyFiles("org.txm.statsengine.r.core", "", "", "R/", scriptsDirectory);
|
|
| 20 | 19 |
|
| 21 |
return dir.exists() && samplesDirectory.exists();
|
|
| 20 |
return dir.exists() && scriptsDirectory.exists();
|
|
| 22 | 21 |
} |
| 23 | 22 |
|
| 24 | 23 |
@Override |
| tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/preferences/RPreferences.java (revision 740) | ||
|---|---|---|
| 161 | 161 |
Log.info("Updating R preferences for R plugin version="+currentVersion);
|
| 162 | 162 |
|
| 163 | 163 |
|
| 164 |
|
|
| 165 |
|
|
| 166 | 164 |
Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+" and "+execFile.getAbsolutePath());
|
| 167 | 165 |
TXMPreferences.put(RPreferences.PREFERENCES_NODE, RPreferences.VERSION, currentVersion.toString()); |
| 168 | 166 |
|
| tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/InstallGroovyFiles.java (revision 740) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.util.HashMap; |
|
| 5 |
|
|
| 6 |
import org.txm.PostTXMHOMEInstallationStep; |
|
| 7 |
import org.txm.objects.Workspace; |
|
| 8 |
import org.txm.utils.BundleUtils; |
|
| 9 |
import org.txm.utils.DeleteDir; |
|
| 10 |
|
|
| 11 |
public class InstallGroovyFiles extends PostTXMHOMEInstallationStep {
|
|
| 12 |
|
|
| 13 |
@Override |
|
| 14 |
public boolean install(Workspace workspace) {
|
|
| 15 |
File txmhomedir = workspace.getLocation(); |
|
| 16 |
|
|
| 17 |
String createfolders[] = {"scripts", "scripts/lib", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
| 18 |
"scripts/macro", "scripts/user", "scripts/import"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
| 19 |
|
|
| 20 |
for (String folder : createfolders) {
|
|
| 21 |
new File(txmhomedir, folder).mkdirs(); |
|
| 22 |
} |
|
| 23 |
File scriptsDirectory = new File(txmhomedir, "scripts"); |
|
| 24 |
File importDirectory = new File(scriptsDirectory, "import"); |
|
| 25 |
File macroDirectory = new File(scriptsDirectory, "macro/org/txm"); |
|
| 26 |
File samplesDirectory = new File(scriptsDirectory, "samples/groovy"); |
|
| 27 |
|
|
| 28 |
HashMap<String, String> publishedImports = new HashMap<String, String>(); |
|
| 29 |
String IMPORTERPACKAGE="org/txm/importer/"; |
|
| 30 |
publishedImports.put(IMPORTERPACKAGE+"alceste","alcesteLoader.groovy"); |
|
| 31 |
publishedImports.put(IMPORTERPACKAGE+"discours","discoursLoader.groovy"); |
|
| 32 |
publishedImports.put(IMPORTERPACKAGE+"bfm","bfmLoader.groovy"); |
|
| 33 |
publishedImports.put(IMPORTERPACKAGE+"frantext","frantextLoader.groovy"); |
|
| 34 |
publishedImports.put(IMPORTERPACKAGE+"hyperbase","hyperbaseLoader.groovy"); |
|
| 35 |
publishedImports.put(IMPORTERPACKAGE+"txt","txtLoader.groovy"); |
|
| 36 |
publishedImports.put(IMPORTERPACKAGE+"xml","xmlLoader.groovy"); |
|
| 37 |
publishedImports.put(IMPORTERPACKAGE+"factiva","factivaLoader.groovy"); |
|
| 38 |
publishedImports.put(IMPORTERPACKAGE+"factiva","factivamailLoader.groovy"); |
|
| 39 |
publishedImports.put(IMPORTERPACKAGE+"xmltxm","xmltxmLoader.groovy"); |
|
| 40 |
publishedImports.put(IMPORTERPACKAGE+"transcriber","transcriberLoader.groovy"); |
|
| 41 |
publishedImports.put(IMPORTERPACKAGE+"tmx","tmxLoader.groovy"); |
|
| 42 |
publishedImports.put(IMPORTERPACKAGE+"doc","docLoader.groovy"); |
|
| 43 |
publishedImports.put(IMPORTERPACKAGE+"wtc","wtcLoader.groovy"); |
|
| 44 |
|
|
| 45 |
String bundle_id = "org.txm.groovy.core"; |
|
| 46 |
for (String p : publishedImports.keySet()) {
|
|
| 47 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/"+p, publishedImports.get(p), importDirectory); |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
// copy published macros |
|
| 51 |
macroDirectory.mkdirs(); |
|
| 52 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "macro/", macroDirectory); |
|
| 53 |
|
|
| 54 |
// copy sample Groovy scripts |
|
| 55 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "export/", samplesDirectory); |
|
| 56 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "functions/", samplesDirectory); |
|
| 57 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "importer/", samplesDirectory); |
|
| 58 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "sw/", samplesDirectory); |
|
| 59 |
BundleUtils.copyFiles(bundle_id, "src/", "groovy/org/txm", "tal/", samplesDirectory); |
|
| 60 |
|
|
| 61 |
return scriptsDirectory.exists(); |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
@Override |
|
| 65 |
public String getName() {
|
|
| 66 |
return "Groovy (org.txm.groovy.core)"; |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
} |
|
| 0 | 70 | |
| tmp/org.txm.groovy.core/src/groovy/org/txm/groovy/core/InstallGroovyFiles.java (revision 740) | ||
|---|---|---|
| 1 |
package org.txm.groovy.core; |
|
| 2 |
|
|
| 3 |
import java.io.File; |
|
| 4 |
import java.util.HashMap; |
|
| 5 |
|
|
| 6 |
import org.txm.PostTXMHOMEInstallationStep; |
|
| 7 |
import org.txm.objects.Workspace; |
|
| 8 |
import org.txm.utils.BundleUtils; |
|
| 9 |
import org.txm.utils.DeleteDir; |
|
| 10 |
|
|
| 11 |
public class InstallGroovyFiles extends PostTXMHOMEInstallationStep {
|
|
| 12 |
|
|
| 13 |
@Override |
|
| 14 |
public boolean install(Workspace workspace) {
|
|
| 15 |
File txmhomedir = workspace.getLocation(); |
|
| 16 |
|
|
| 17 |
String createfolders[] = {"scripts", "scripts/lib", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
| 18 |
"scripts/macro", "scripts/user", "scripts/import"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
| 19 |
|
|
| 20 |
for (String folder : createfolders) {
|
|
| 21 |
new File(txmhomedir, folder).mkdirs(); |
|
| 22 |
} |
|
| 23 |
File scriptsDirectory = new File(txmhomedir, "scripts"); |
|
| 24 |
File importDirectory = new File(scriptsDirectory, "import"); |
|
| 25 |
File macroDirectory = new File(scriptsDirectory, "macro/org/txm"); |
|
| 26 |
File samplesDirectory = new File(scriptsDirectory, "samples/groovy"); |
|
| 27 |
|
|
| 28 |
HashMap<String, String> publishedImports = new HashMap<String, String>(); |
|
| 29 |
String IMPORTERPACKAGE="org/txm/importer/"; |
|
| 30 |
publishedImports.put(IMPORTERPACKAGE+"alceste","alcesteLoader.groovy"); |
|
| 31 |
publishedImports.put(IMPORTERPACKAGE+"discours","discoursLoader.groovy"); |
|
| 32 |
publishedImports.put(IMPORTERPACKAGE+"bfm","bfmLoader.groovy"); |
|
| 33 |
publishedImports.put(IMPORTERPACKAGE+"frantext","frantextLoader.groovy"); |
|
| 34 |
publishedImports.put(IMPORTERPACKAGE+"hyperbase","hyperbaseLoader.groovy"); |
|
| 35 |
publishedImports.put(IMPORTERPACKAGE+"txt","txtLoader.groovy"); |
|
| 36 |
publishedImports.put(IMPORTERPACKAGE+"xml","xmlLoader.groovy"); |
|
| 37 |
publishedImports.put(IMPORTERPACKAGE+"factiva","factivaLoader.groovy"); |
|
| 38 |
publishedImports.put(IMPORTERPACKAGE+"factiva","factivamailLoader.groovy"); |
|
| 39 |
publishedImports.put(IMPORTERPACKAGE+"xmltxm","xmltxmLoader.groovy"); |
|
| 40 |
publishedImports.put(IMPORTERPACKAGE+"transcriber","transcriberLoader.groovy"); |
|
| 41 |
publishedImports.put(IMPORTERPACKAGE+"tmx","tmxLoader.groovy"); |
|
| 42 |
publishedImports.put(IMPORTERPACKAGE+"doc","docLoader.groovy"); |
|
| 43 |
publishedImports.put(IMPORTERPACKAGE+"wtc","wtcLoader.groovy"); |
|
| 44 |
|
|
| 45 |
String bundle_id = "org.txm.groovy.core"; |
|
| 46 |
for (String p : publishedImports.keySet()) {
|
|
| 47 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", p, publishedImports.get(p), importDirectory); |
|
| 48 |
} |
|
| 49 |
|
|
| 50 |
// copy published macros |
|
| 51 |
macroDirectory.mkdirs(); |
|
| 52 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "macro", macroDirectory); |
|
| 53 |
|
|
| 54 |
// copy sample Groovy scripts |
|
| 55 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "export", samplesDirectory); |
|
| 56 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "functions", samplesDirectory); |
|
| 57 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "importer", samplesDirectory); |
|
| 58 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "sw", samplesDirectory); |
|
| 59 |
BundleUtils.copyFiles(bundle_id, "src/groovy/", "org/txm", "tal", samplesDirectory); |
|
| 60 |
|
|
| 61 |
return scriptsDirectory.exists(); |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
@Override |
|
| 65 |
public String getName() {
|
|
| 66 |
return "Groovy (org.txm.groovy.core)"; |
|
| 67 |
} |
|
| 68 |
|
|
| 69 |
} |
|
| tmp/org.txm.groovy.core/build.properties (revision 740) | ||
|---|---|---|
| 3 | 3 |
bin.includes = META-INF/,\ |
| 4 | 4 |
.,\ |
| 5 | 5 |
bin/,\ |
| 6 |
plugin.xml |
|
| 6 |
plugin.xml,\ |
|
| 7 |
src/groovy/ |
|
| 7 | 8 |
jars.compile.order = . |
| tmp/org.txm.utils/src/org/txm/utils/zip/Zip.java (revision 740) | ||
|---|---|---|
| 31 | 31 |
import java.io.BufferedOutputStream; |
| 32 | 32 |
import java.io.File; |
| 33 | 33 |
import java.io.FileInputStream; |
| 34 |
import java.io.FileNotFoundException; |
|
| 34 | 35 |
import java.io.FileOutputStream; |
| 35 | 36 |
import java.io.IOException; |
| 36 | 37 |
import java.io.InputStream; |
| ... | ... | |
| 44 | 45 |
import java.util.zip.ZipInputStream; |
| 45 | 46 |
import java.util.zip.ZipOutputStream; |
| 46 | 47 |
|
| 48 |
import org.apache.commons.lang.StringUtils; |
|
| 47 | 49 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 48 | 50 |
import org.txm.utils.logger.Log; |
| 49 | 51 |
|
| ... | ... | |
| 425 | 427 |
public static boolean extractOneFile(File zipFile, String path, File outputFile) {
|
| 426 | 428 |
return extractOneFile(zipFile, path, outputFile, false); |
| 427 | 429 |
} |
| 428 |
|
|
| 430 |
|
|
| 429 | 431 |
/** |
| 430 | 432 |
* Extract one file from an archive given a relative path in the archive |
| 431 | 433 |
* |
| 432 | 434 |
* @param zipFile the archive |
| 433 |
* @param path the relative path in the archive |
|
| 435 |
* @param path the relative path in the archive of the file to extract (file or directory)
|
|
| 434 | 436 |
* @param outputFile the output file |
| 435 | 437 |
* @param replaceOnlyIfNewer if true the file is replaced only if the archive file is more recent |
| 436 | 438 |
* @return true if success |
| 437 | 439 |
*/ |
| 438 | 440 |
public static boolean extractOneFile(File zipFile, String path, File outputFile, boolean replaceOnlyIfNewer) {
|
| 441 |
|
|
| 442 |
boolean copySubEntries = false; // internal variable to copy entries of a directory |
|
| 443 |
boolean pathFound = false; // internal variable to know if path was found |
|
| 444 |
|
|
| 439 | 445 |
try {
|
| 440 | 446 |
long oldFileTime = outputFile.lastModified(); |
| 441 | 447 |
|
| ... | ... | |
| 443 | 449 |
new FileInputStream(zipFile.getCanonicalFile()))); |
| 444 | 450 |
ZipEntry ze; |
| 445 | 451 |
|
| 452 |
|
|
| 446 | 453 |
// Parcourt tous les fichiers |
| 447 | 454 |
while (null != (ze = zis.getNextEntry())) {
|
| 448 | 455 |
//System.out.println("P="+ze.getName());
|
| 449 |
if (ze.getName().equals(path)) { // this is the file to extract !
|
|
| 456 |
String currentpath = ze.getName(); |
|
| 457 |
if (currentpath.equals(path)) { // this is the file to extract !
|
|
| 450 | 458 |
if (replaceOnlyIfNewer && ze.getTime() < oldFileTime) { // don't replace the file
|
| 451 | 459 |
zis.close(); |
| 452 | 460 |
return true; |
| 453 | 461 |
} |
| 454 |
|
|
| 455 |
OutputStream fos = new BufferedOutputStream(new FileOutputStream(outputFile)); |
|
| 456 |
|
|
| 457 |
// Ecriture des fichiers |
|
| 458 |
try {
|
|
| 459 |
try {
|
|
| 460 |
final byte[] buf = new byte[8192]; |
|
| 461 |
int bytesRead; |
|
| 462 |
while (-1 != (bytesRead = zis.read(buf))) |
|
| 463 |
fos.write(buf, 0, bytesRead); |
|
| 464 |
} finally {
|
|
| 465 |
fos.close(); |
|
| 466 |
zis.close(); |
|
| 467 |
} |
|
| 468 |
} catch (final IOException ioe) {
|
|
| 469 |
throw ioe; |
|
| 470 |
} |
|
| 471 |
|
|
| 472 |
return true; |
|
| 462 |
if (ze.isDirectory()) { // the path point a directory
|
|
| 463 |
copySubEntries = true; |
|
| 464 |
outputFile.mkdirs(); |
|
| 465 |
pathFound = true; |
|
| 466 |
} else { // the path point a file
|
|
| 467 |
writeFileEntry(zis, outputFile); |
|
| 468 |
pathFound = true; |
|
| 469 |
} |
|
| 470 |
} else if (currentpath.startsWith(path) && copySubEntries) {
|
|
| 471 |
String subpath = currentpath.substring(path.length()); |
|
| 472 |
|
|
| 473 |
if (ze.isDirectory()) { // a sub directory of the pointed path
|
|
| 474 |
new File(outputFile, subpath).mkdirs(); |
|
| 475 |
} else { // a sub file of the pointed path (directory)
|
|
| 476 |
writeFileEntry(zis, new File(outputFile, subpath)); |
|
| 477 |
} |
|
| 478 |
} else {
|
|
| 479 |
copySubEntries = false; // stop copying sub entries |
|
| 473 | 480 |
} |
| 474 | 481 |
} |
| 475 |
System.out.println("Error: "+path+" not found.");
|
|
| 482 |
if (!pathFound) {
|
|
| 483 |
System.out.println("Error: "+path+" not found.");
|
|
| 484 |
} |
|
| 476 | 485 |
|
| 477 | 486 |
if (zis != null) {
|
| 478 | 487 |
try {
|
| ... | ... | |
| 486 | 495 |
Log.printStackTrace(e); |
| 487 | 496 |
} |
| 488 | 497 |
|
| 489 |
return false; // no suitable entry found
|
|
| 498 |
return pathFound; // no suitable entry found
|
|
| 490 | 499 |
} |
| 491 | 500 |
|
| 492 | 501 |
/** |
| 502 |
* Write the current Zis entry to a file |
|
| 503 |
* @param zis |
|
| 504 |
* @param outputFile |
|
| 505 |
* @throws IOException |
|
| 506 |
*/ |
|
| 507 |
private static void writeFileEntry(ZipInputStream zis, File outputFile) throws IOException {
|
|
| 508 |
OutputStream fos = new BufferedOutputStream(new FileOutputStream(outputFile)); |
|
| 509 |
|
|
| 510 |
// Ecriture des fichiers |
|
| 511 |
try {
|
|
| 512 |
try {
|
|
| 513 |
final byte[] buf = new byte[8192]; |
|
| 514 |
int bytesRead; |
|
| 515 |
while (-1 != (bytesRead = zis.read(buf))) |
|
| 516 |
fos.write(buf, 0, bytesRead); |
|
| 517 |
} finally {
|
|
| 518 |
fos.close(); |
|
| 519 |
} |
|
| 520 |
} catch (final IOException ioe) {
|
|
| 521 |
throw ioe; |
|
| 522 |
} |
|
| 523 |
} |
|
| 524 |
|
|
| 525 |
/** |
|
| 493 | 526 |
* Try to get the root folder of the archive. If there is no root folder, the Zip filename is used |
| 494 | 527 |
* |
| 495 | 528 |
* @param zipFile |
| ... | ... | |
| 553 | 586 |
// System.out.println(list); |
| 554 | 587 |
// System.out.println("outdir: "+list.get(0));
|
| 555 | 588 |
// System.out.println("outdir fixed: "+Zip.getRoot(zipFile));
|
| 556 |
File toolboxJar = new File("/usr/lib/TXM/TXM/plugins/org.txm.toolbox_0.7.0.201509251550.jar");
|
|
| 557 |
File script = new File("/home/mdecorde/TEMP/xmlLoader.groovy");
|
|
| 558 |
script.delete(); |
|
| 559 |
System.out.println("Zip result: "+Zip.extractOneFile(toolboxJar, "org/txm/importer/xml/xmlLoader.groovy", script));
|
|
| 560 |
System.out.println("Done: exists="+script.exists()+" size="+script.length());
|
|
| 589 |
File dir = new File("/home/mdecorde/workspace079/org.txm.setups/exportRCP/linux.gtk.x86_64/TXM/plugins");
|
|
| 590 |
File jarFile = new File(dir, "org.txm.statsengine.r.core_1.0.0.201805091353.jar"); |
|
| 591 |
File outDir = new File("/home/mdecorde/TEMP");
|
|
| 592 |
//System.out.println(StringUtils.join(Zip.listFiles(jarFile), "\n")); |
|
| 593 |
System.out.println("Zip result: "+Zip.extractOneFile(jarFile, "R/", outDir));
|
|
| 594 |
|
|
| 561 | 595 |
} |
| 562 | 596 |
} |
| 563 | 597 |
|
| tmp/org.txm.utils/src/org/txm/utils/io/FileCopy.java (revision 740) | ||
|---|---|---|
| 147 | 147 |
|
| 148 | 148 |
// is it a directory ? |
| 149 | 149 |
if (src.isDirectory()) {
|
| 150 |
|
|
| 150 | 151 |
if (!dest.exists()) { // does the destination already exist?
|
| 151 | 152 |
// if not create the file hierarchy |
| 152 |
if (!dest.mkdirs()) {
|
|
| 153 |
dest.mkdirs(); |
|
| 154 |
if (!dest.exists()) {
|
|
| 153 | 155 |
throw new IOException(UtilsCoreMessages.FileCopy_4 |
| 154 | 156 |
+ dest.getAbsolutePath() + "."); //$NON-NLS-1$ |
| 155 | 157 |
} |
| tmp/org.txm.core/.settings/org.eclipse.jdt.core.prefs (revision 740) | ||
|---|---|---|
| 1 | 1 |
eclipse.preferences.version=1 |
| 2 | 2 |
org.eclipse.jdt.core.builder.resourceCopyExclusionFilter=*.launch,*.groovy |
| 3 | 3 |
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled |
| 4 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
|
|
| 5 |
org.eclipse.jdt.core.compiler.compliance=1.6
|
|
| 4 |
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
|
|
| 5 |
org.eclipse.jdt.core.compiler.compliance=1.7
|
|
| 6 | 6 |
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error |
| 7 | 7 |
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error |
| 8 |
org.eclipse.jdt.core.compiler.source=1.6 |
|
| 8 |
org.eclipse.jdt.core.compiler.source=1.7 |
|
| tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 740) | ||
|---|---|---|
| 48 | 48 |
import org.eclipse.core.runtime.Platform; |
| 49 | 49 |
import org.eclipse.core.runtime.SafeRunner; |
| 50 | 50 |
import org.osgi.framework.Bundle; |
| 51 |
import org.osgi.framework.Version; |
|
| 51 | 52 |
import org.eclipse.core.runtime.preferences.DefaultScope; |
| 52 | 53 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
| 54 |
import org.eclipse.osgi.util.NLS; |
|
| 53 | 55 |
import org.txm.core.messages.TXMCoreMessages; |
| 54 | 56 |
import org.txm.core.preferences.TBXPreferences; |
| 55 | 57 |
import org.txm.core.preferences.TXMPreferences; |
| 56 | 58 |
import org.txm.objects.Workspace; |
| 59 |
import org.txm.utils.BundleUtils; |
|
| 57 | 60 |
import org.txm.utils.OSDetector; |
| 58 | 61 |
import org.txm.utils.logger.Log; |
| 59 | 62 |
|
| ... | ... | |
| 71 | 74 |
private static LinkedHashMap<EngineType, EnginesManager<?>> engines = new LinkedHashMap<EngineType, EnginesManager<?>>(); |
| 72 | 75 |
|
| 73 | 76 |
private static boolean initializing = false; |
| 74 |
|
|
| 77 |
|
|
| 75 | 78 |
/** The state. */ |
| 76 | 79 |
private static boolean state = false; |
| 77 | 80 |
|
| ... | ... | |
| 80 | 83 |
private static void addEngineManager(EnginesManager<?> engine) {
|
| 81 | 84 |
engines.put(engine.getEnginesType(), engine); |
| 82 | 85 |
} |
| 83 |
|
|
| 86 |
|
|
| 84 | 87 |
/** |
| 85 | 88 |
* if searchengine or statengine or workspace is not ready then the toolbox |
| 86 | 89 |
* is not ready. |
| ... | ... | |
| 124 | 127 |
public static String getParam(String key) {
|
| 125 | 128 |
return TXMPreferences.getString(key, TBXPreferences.PREFERENCES_NODE); |
| 126 | 129 |
} |
| 127 |
|
|
| 130 |
|
|
| 128 | 131 |
public static EnginesManager<?> getEngineManager(EngineType et) {
|
| 129 |
|
|
| 132 |
|
|
| 130 | 133 |
if (engines == null) {
|
| 131 | 134 |
return null; |
| 132 | 135 |
} |
| ... | ... | |
| 140 | 143 |
public static String getTXMHOMEPATH() {
|
| 141 | 144 |
return TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE); |
| 142 | 145 |
} |
| 143 |
|
|
| 146 |
|
|
| 144 | 147 |
/** |
| 145 | 148 |
* Initializes the toolbox with the parameters read in the file |
| 146 | 149 |
* textometrie.properties found in the user home directory |
| ... | ... | |
| 171 | 174 |
public static boolean initialize(Class preferencesStore) throws Exception {
|
| 172 | 175 |
return initialize(preferencesStore, null); |
| 173 | 176 |
} |
| 174 |
|
|
| 177 |
|
|
| 175 | 178 |
/** |
| 176 | 179 |
* Initializes the Toolbox using the INSTANCE SCOPE preferences of TXMPreferences |
| 177 | 180 |
* |
| ... | ... | |
| 193 | 196 |
} catch(Exception e) {
|
| 194 | 197 |
System.out.println("Error while pre-installing plugins: " + e.getLocalizedMessage());
|
| 195 | 198 |
} |
| 196 |
|
|
| 199 |
|
|
| 197 | 200 |
try {
|
| 198 | 201 |
Log.info(TXMCoreMessages.Toolbox_4 + TBXPreferences.getID()); |
| 199 | 202 |
|
| 200 | 203 |
// initialize workspace : list of corpus loaded in TXM |
| 201 |
state = startWorkspace(); |
|
| 204 |
// copy shared files if needed |
|
| 205 |
state = startWorkspace(monitor); |
|
| 202 | 206 |
|
| 207 |
|
|
| 203 | 208 |
Log.warning("Initializing logger");
|
| 204 | 209 |
String level = TXMPreferences.getString(TBXPreferences.LOG_LEVEL, TBXPreferences.PREFERENCES_NODE); |
| 205 | 210 |
if (level == "") {
|
| ... | ... | |
| 214 | 219 |
else {
|
| 215 | 220 |
Log.setPrintInFile(Boolean.parseBoolean(TXMPreferences.getString(TBXPreferences.LOG_IN_FILE, TBXPreferences.PREFERENCES_NODE))); |
| 216 | 221 |
} |
| 217 |
|
|
| 222 |
|
|
| 218 | 223 |
} catch (Exception e) {
|
| 219 | 224 |
initializing = false; |
| 220 | 225 |
throw e; |
| 221 | 226 |
} |
| 222 |
|
|
| 227 |
|
|
| 223 | 228 |
try {
|
| 224 | 229 |
startsEngineManagers(monitor); |
| 225 | 230 |
} catch (Exception e) {
|
| 226 | 231 |
initializing = false; |
| 227 | 232 |
throw e; |
| 228 | 233 |
} |
| 229 |
|
|
| 234 |
|
|
| 230 | 235 |
Log.info("Toolbox states: "+TXMCoreMessages.Toolbox_22 + state); //$NON-NLS-1$
|
| 231 |
|
|
| 236 |
|
|
| 232 | 237 |
try {
|
| 233 | 238 |
if (monitor != null) {
|
| 234 | 239 |
monitor.subTask("Loading extensions (post-installation)...");
|
| ... | ... | |
| 237 | 242 |
} catch(Exception e) {
|
| 238 | 243 |
System.out.println("Error while post-installaing plugins: "+e.getLocalizedMessage());
|
| 239 | 244 |
} |
| 240 |
|
|
| 241 |
|
|
| 245 |
|
|
| 246 |
|
|
| 242 | 247 |
// FIXME: persistence tests |
| 243 | 248 |
if (TBXPreferences.getBoolean(TBXPreferences.AUTO_SAVE_RESULTS, TBXPreferences.PREFERENCES_NODE)) {
|
| 244 | 249 |
System.out.println("Toolbox.initialize(): reloading persitent results...");
|
| ... | ... | |
| 260 | 265 |
} |
| 261 | 266 |
} |
| 262 | 267 |
} |
| 263 |
|
|
| 264 |
|
|
| 265 |
|
|
| 268 |
|
|
| 269 |
|
|
| 270 |
|
|
| 266 | 271 |
initializing = false; |
| 267 | 272 |
return checkState(); |
| 268 | 273 |
} |
| ... | ... | |
| 336 | 341 |
public static boolean isInitialized() {
|
| 337 | 342 |
return checkState(); |
| 338 | 343 |
} |
| 339 |
|
|
| 344 |
|
|
| 340 | 345 |
public static boolean isInitializing() {
|
| 341 | 346 |
return initializing; |
| 342 | 347 |
} |
| 343 | 348 |
|
| 344 |
|
|
| 349 |
|
|
| 345 | 350 |
/** |
| 346 | 351 |
* Allow to install a TXM extension AFTER the Toolbox is initialized |
| 347 | 352 |
*/ |
| ... | ... | |
| 374 | 379 |
} |
| 375 | 380 |
} |
| 376 | 381 |
} |
| 377 |
|
|
| 382 |
|
|
| 378 | 383 |
/** |
| 379 | 384 |
* Allow to install a TXM extension BEFORE the Toolbox is initialized |
| 380 | 385 |
*/ |
| ... | ... | |
| 430 | 435 |
* |
| 431 | 436 |
* @return true, if successful |
| 432 | 437 |
*/ |
| 433 |
public static boolean restartWorkspace() {
|
|
| 438 |
public static boolean restartWorkspace(IProgressMonitor monitor) {
|
|
| 434 | 439 |
try {
|
| 435 | 440 |
shutdownWorkspace(); |
| 436 |
startWorkspace(); |
|
| 441 |
startWorkspace(monitor);
|
|
| 437 | 442 |
} catch (Exception e) {
|
| 438 | 443 |
Log.severe("Error while restarting workspace: "+e.getLocalizedMessage());
|
| 439 | 444 |
} |
| ... | ... | |
| 444 | 449 |
* Shut the toolbox down. |
| 445 | 450 |
*/ |
| 446 | 451 |
public static void shutdown() {
|
| 447 |
|
|
| 452 |
|
|
| 448 | 453 |
stopEngineManagers(); |
| 449 |
|
|
| 454 |
|
|
| 450 | 455 |
if(Toolbox.workspace != null) |
| 451 | 456 |
Toolbox.workspace.save(); |
| 452 | 457 |
Toolbox.workspace = null; |
| 453 | 458 |
state = false; |
| 454 |
|
|
| 459 |
|
|
| 455 | 460 |
//save preferences |
| 456 | 461 |
IPreferencesService service = Platform.getPreferencesService(); |
| 457 | 462 |
try {
|
| 458 |
service.getRootNode().flush(); |
|
| 459 |
// .childrenNames()) {
|
|
| 460 |
// System.out.println("********************************************************************************************************"); //$NON-NLS-1$
|
|
| 461 |
// System.out.println(" scope: " + children); //$NON-NLS-1$
|
|
| 462 |
// String[] subchildren = service.getRootNode().node(children).childrenNames(); |
|
| 463 |
// Arrays.sort(subchildren); |
|
| 464 |
// for (String children2 : subchildren) {
|
|
| 465 |
// System.out.println(" node: "+ children2); //$NON-NLS-1$
|
|
| 466 |
// service.getRootNode().node(children).node(children2).keys(); |
|
| 467 |
// Arrays.sort(keys); |
|
| 468 |
// for (String key2 : keys) {
|
|
| 469 |
// System.out.println(" " + key2 + " = " + service.getRootNode().node(children).node(children2).get(key2, null)); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 470 |
// } |
|
| 471 |
// } |
|
| 472 |
// } |
|
| 463 |
service.getRootNode().flush(); |
|
| 464 |
// .childrenNames()) {
|
|
| 465 |
// System.out.println("********************************************************************************************************"); //$NON-NLS-1$
|
|
| 466 |
// System.out.println(" scope: " + children); //$NON-NLS-1$
|
|
| 467 |
// String[] subchildren = service.getRootNode().node(children).childrenNames(); |
|
| 468 |
// Arrays.sort(subchildren); |
|
| 469 |
// for (String children2 : subchildren) {
|
|
| 470 |
// System.out.println(" node: "+ children2); //$NON-NLS-1$
|
|
| 471 |
// service.getRootNode().node(children).node(children2).keys(); |
|
Formats disponibles : Unified diff