20 |
20 |
import org.txm.objects.EditionDefinition;
|
21 |
21 |
import org.txm.objects.Project;
|
22 |
22 |
import org.txm.rcp.messages.TXMUIMessages;
|
|
23 |
import org.txm.utils.LogMonitor;
|
23 |
24 |
import org.txm.utils.logger.Log;
|
24 |
25 |
import org.w3c.dom.Element;
|
25 |
26 |
import org.w3c.dom.NodeList;
|
26 |
27 |
|
27 |
28 |
public class ImportWizard extends Wizard implements INewWizard {
|
28 |
|
|
|
29 |
|
29 |
30 |
private SourceDirectoryPage page1 = new SourceDirectoryPage();
|
|
31 |
|
30 |
32 |
private Project project;
|
31 |
|
|
|
33 |
|
32 |
34 |
public ImportWizard() {
|
33 |
35 |
// TODO Auto-generated constructor stub
|
34 |
36 |
}
|
35 |
|
|
|
37 |
|
36 |
38 |
@Override
|
37 |
39 |
public void init(IWorkbench workbench, IStructuredSelection selection) {
|
38 |
40 |
// TODO Auto-generated method stub
|
39 |
|
|
|
41 |
|
40 |
42 |
}
|
41 |
|
|
|
43 |
|
42 |
44 |
@Override
|
43 |
45 |
public boolean performFinish() {
|
44 |
46 |
if (page1.isCompleted()) {
|
45 |
47 |
try {
|
46 |
48 |
File path = new File(page1.getSourcePath());
|
47 |
|
String name = page1.getCorpusName();//AsciiUtils.buildId(path.getName()).toUpperCase();
|
|
49 |
String name = page1.getCorpusName();// AsciiUtils.buildId(path.getName()).toUpperCase();
|
48 |
50 |
|
49 |
51 |
project = null;
|
50 |
52 |
|
... | ... | |
61 |
63 |
// get the more recent one
|
62 |
64 |
if (project != null && p.getLastComputingDate().compareTo(project.getLastComputingDate()) > 0) {
|
63 |
65 |
project = p;
|
64 |
|
} else {
|
|
66 |
}
|
|
67 |
else {
|
65 |
68 |
project = p;
|
66 |
69 |
}
|
67 |
70 |
}
|
... | ... | |
72 |
75 |
project = new Project(Toolbox.workspace, name);
|
73 |
76 |
}
|
74 |
77 |
project.setSourceDirectory(path.getAbsolutePath());
|
75 |
|
project.setDescription(System.getProperty("user.name")+"\n"+TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(Calendar.getInstance().getTime()));
|
|
78 |
project.setDescription(System.getProperty("user.name") + "\n" + TXMResult.PRETTY_LOCALIZED_TIME_FORMAT.format(Calendar.getInstance().getTime()));
|
76 |
79 |
project.setLang(Locale.getDefault().getLanguage().toLowerCase());
|
77 |
80 |
|
78 |
81 |
Log.info(NLS.bind(TXMUIMessages.theP0CorpusWillBeCreatedFromTheP1Directory, project.getName(), project.getSrcdir()));
|
... | ... | |
84 |
87 |
|
85 |
88 |
if (project.getAnnotate()) {
|
86 |
89 |
Log.info("The 'annotate' import parameter has been activated since TreeTagger is installed.");
|
87 |
|
} else {
|
|
90 |
}
|
|
91 |
else {
|
88 |
92 |
Log.info("The 'annotate' import parameter was not activated since TreeTagger is not installed.");
|
89 |
93 |
}
|
90 |
94 |
|
... | ... | |
95 |
99 |
params.load();
|
96 |
100 |
params.initializeProject(project);
|
97 |
101 |
}
|
98 |
|
} else {
|
|
102 |
}
|
|
103 |
else {
|
99 |
104 |
Date date = project.getLastComputingDate();
|
100 |
105 |
if (date == null) {
|
101 |
106 |
date = Calendar.getInstance().getTime(); // today
|
102 |
107 |
}
|
103 |
108 |
Log.info(NLS.bind(TXMUIMessages.theP1P0CorpusWillBeReplaced, project, date));
|
|
109 |
project.open(new LogMonitor());
|
104 |
110 |
}
|
105 |
111 |
|
106 |
|
// if (!project.hasEditionDefinition("default")) {
|
107 |
|
// EditionDefinition def = project.getEditionDefinition("default");
|
108 |
|
// def.setBuildEdition(true);
|
109 |
|
// def.setWordsPerPage(500);
|
110 |
|
// def.setPageBreakTag("pb");
|
111 |
|
// }
|
|
112 |
// if (!project.hasEditionDefinition("default")) {
|
|
113 |
// EditionDefinition def = project.getEditionDefinition("default");
|
|
114 |
// def.setBuildEdition(true);
|
|
115 |
// def.setWordsPerPage(500);
|
|
116 |
// def.setPageBreakTag("pb");
|
|
117 |
// }
|
112 |
118 |
|
113 |
119 |
project.setDoUpdate(false);
|
114 |
120 |
project.saveParameters();
|
115 |
121 |
return true;
|
116 |
|
} catch (Exception e) {
|
|
122 |
}
|
|
123 |
catch (Exception e) {
|
117 |
124 |
e.printStackTrace();
|
118 |
125 |
return false;
|
119 |
126 |
}
|
120 |
127 |
}
|
121 |
128 |
return false;
|
122 |
129 |
}
|
123 |
|
|
|
130 |
|
124 |
131 |
@Override
|
125 |
132 |
public void addPages() {
|
126 |
133 |
addPage(page1);
|
127 |
134 |
}
|
128 |
|
|
|
135 |
|
129 |
136 |
public Project getProject() {
|
130 |
137 |
return project;
|
131 |
138 |
}
|