Révision 2709
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 2709) | ||
---|---|---|
152 | 152 |
|
153 | 153 |
Log.fine("Opening edition of " + corpus); //$NON-NLS-1$ |
154 | 154 |
try { |
155 |
Text text = null; |
|
156 |
if (corpus instanceof Subcorpus) { |
|
157 |
Subcorpus sub = (Subcorpus) corpus; |
|
158 |
sub.compute(false); |
|
159 |
List<Match> matches = sub.getMatches(); |
|
160 |
if (matches.size() > 0) { |
|
161 |
StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$ |
|
162 |
Property text_id = text_su.getProperty("id"); //$NON-NLS-1$ |
|
163 |
|
|
164 |
textid = matches.get(0).getValueForProperty(text_id); |
|
165 |
if (textid != null) text = corpus.getProject().getText(textid); |
|
166 |
} |
|
155 |
String[] availables = corpus.getCorpusTextIdsList(); |
|
156 |
if (availables.length == 0) { |
|
157 |
Log.warning(NLS.bind("Error: No text in the {0} corpus", corpus)); |
|
158 |
return null; |
|
167 | 159 |
} |
160 |
Text text = corpus.getProject().getText(availables[0]); |
|
161 |
if (text == null) { |
|
162 |
Log.warning(NLS.bind("Error: No {0}text in the {1} corpus", availables[0], corpus)); |
|
163 |
return null; |
|
164 |
} |
|
168 | 165 |
// QueryResult result = corpus.query(new Query("<text> []"), "get_edition", false); //$NON-NLS-1$ //$NON-NLS-2$ |
169 | 166 |
// StructuralUnit text_su = corpus.getStructuralUnit("text"); //$NON-NLS-1$ |
170 | 167 |
// Property text_id = text_su.getProperty("id"); //$NON-NLS-1$ |
... | ... | |
174 | 171 |
|
175 | 172 |
// if (textid != null) text = maincorpus.getText(textid); |
176 | 173 |
|
177 |
if (text == null) { |
|
178 |
text = maincorpus.getProject().getFirstText(); |
|
179 |
|
|
180 |
if (text == null) { |
|
181 |
System.out.println(NLS.bind(EditionUIMessages.couldNotFindFirstTextOfP0IDInTheCorpus, textid)); |
|
182 |
return null; |
|
183 |
} |
|
184 |
|
|
185 |
textid = text.getName(); |
|
186 |
} |
|
187 |
|
|
188 | 174 |
// String[] editions = {maincorpus.getDefaultEdition()}; |
189 | 175 |
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); |
190 | 176 |
IWorkbenchPage page = window.getActivePage(); |
Formats disponibles : Unified diff