Révision 3522
| trunk/org.txm.texts.rcp/plugin.xml (revision 3522) | ||
|---|---|---|
| 23 | 23 |
checkEnabled="false"> |
| 24 | 24 |
<or> |
| 25 | 25 |
<reference |
| 26 |
definitionId="OneMainCorpusSelected">
|
|
| 26 |
definitionId="OneCorpusSelected"> |
|
| 27 | 27 |
</reference> |
| 28 | 28 |
</or> |
| 29 | 29 |
</visibleWhen> |
| ... | ... | |
| 41 | 41 |
checkEnabled="false"> |
| 42 | 42 |
<or> |
| 43 | 43 |
<reference |
| 44 |
definitionId="OneMainCorpusSelected">
|
|
| 44 |
definitionId="OneCorpusSelected"> |
|
| 45 | 45 |
</reference> |
| 46 | 46 |
</or> |
| 47 | 47 |
</visibleWhen> |
| ... | ... | |
| 59 | 59 |
checkEnabled="false"> |
| 60 | 60 |
<or> |
| 61 | 61 |
<reference |
| 62 |
definitionId="OneMainCorpusSelected">
|
|
| 62 |
definitionId="OneCorpusSelected"> |
|
| 63 | 63 |
</reference> |
| 64 | 64 |
</or> |
| 65 | 65 |
</visibleWhen> |
| trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/ComputeTextView.java (revision 3522) | ||
|---|---|---|
| 5 | 5 |
import org.txm.core.preferences.TXMPreferences; |
| 6 | 6 |
import org.txm.rcp.editors.TXMEditor; |
| 7 | 7 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
| 8 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
| 8 | 9 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 9 | 10 |
import org.txm.texts.core.TextsView; |
| 10 | 11 |
|
| ... | ... | |
| 29 | 30 |
Object selection = this.getCorporaViewSelectedObject(event); |
| 30 | 31 |
|
| 31 | 32 |
// Creating from Corpus |
| 32 |
if (selection instanceof MainCorpus) {
|
|
| 33 |
MainCorpus corpus = (MainCorpus) selection;
|
|
| 33 |
if (selection instanceof CQPCorpus) {
|
|
| 34 |
CQPCorpus corpus = (CQPCorpus) selection;
|
|
| 34 | 35 |
concordance = new TextsView(corpus); |
| 35 | 36 |
} |
| 36 | 37 |
// Reopening existing result |
| trunk/org.txm.texts.rcp/src/org/txm/texts/rcp/TextsViewEditor.java (revision 3522) | ||
|---|---|---|
| 105 | 105 |
|
| 106 | 106 |
|
| 107 | 107 |
TextsView tv = getResult(); |
| 108 |
if (viewer.getTable().getColumns().length == 0 || viewer.getTable().getColumns().length != tv.getColumns().size()) {
|
|
| 109 |
if (viewer.getTable().getColumns().length > 0) {
|
|
| 108 |
int currentDisplayedColumns = viewer.getTable().getColumns().length; |
|
| 109 |
int numberOfColumnsToDisplay = (tv.getColumns().size() + 3); |
|
| 110 |
if ( currentDisplayedColumns == 0 || |
|
| 111 |
currentDisplayedColumns != numberOfColumnsToDisplay) {
|
|
| 112 |
|
|
| 113 |
if (viewer.getTable().getColumns().length > 0) { // get rid of current columns
|
|
| 110 | 114 |
for (TableColumn column : viewer.getTable().getColumns()) {
|
| 111 | 115 |
column.dispose(); |
| 112 | 116 |
} |
| trunk/org.txm.texts.core/src/org/txm/texts/core/TextsView.java (revision 3522) | ||
|---|---|---|
| 12 | 12 |
import org.txm.core.results.TXMParameters; |
| 13 | 13 |
import org.txm.core.results.TXMResult; |
| 14 | 14 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 15 |
import org.txm.searchengine.cqp.corpus.MainCorpus;
|
|
| 15 |
import org.txm.searchengine.cqp.corpus.CQPCorpus;
|
|
| 16 | 16 |
import org.txm.searchengine.cqp.corpus.Property; |
| 17 | 17 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 18 | 18 |
import org.txm.utils.TXMProgressMonitor; |
| ... | ... | |
| 31 | 31 |
|
| 32 | 32 |
private LinkedHashMap<String, ArrayList<String>> result; |
| 33 | 33 |
|
| 34 |
public MainCorpus getCorpus() {
|
|
| 35 |
return (MainCorpus)parent;
|
|
| 34 |
public CQPCorpus getCorpus() {
|
|
| 35 |
return (CQPCorpus)parent;
|
|
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
public TextsView(MainCorpus corpus) {
|
|
| 38 |
public TextsView(CQPCorpus corpus) {
|
|
| 39 | 39 |
|
| 40 | 40 |
super(corpus); |
| 41 | 41 |
} |
| ... | ... | |
| 114 | 114 |
@Override |
| 115 | 115 |
public String getName() {
|
| 116 | 116 |
|
| 117 |
return "Texts ("+pColumns.toString()+")";
|
|
| 117 |
return "Texts ("+pColumns+")";
|
|
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 | 120 |
@Override |
| TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3522) | ||
|---|---|---|
| 6 | 6 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 7 | 7 |
import org.eclipse.core.runtime.IStatus; |
| 8 | 8 |
import org.eclipse.core.runtime.Status; |
| 9 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
| 10 | 9 |
import org.eclipse.jface.viewers.ISelection; |
| 11 | 10 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 12 | 11 |
import org.eclipse.jface.window.Window; |
| ... | ... | |
| 28 | 27 |
public class SaveAnnotationsAndUpdateCorpus extends AbstractHandler {
|
| 29 | 28 |
|
| 30 | 29 |
public static final String ID = SaveAnnotationsAndUpdateCorpus.class.getCanonicalName(); |
| 31 |
MainCorpus corpus = null; |
|
| 32 | 30 |
|
| 33 | 31 |
@Override |
| 34 | 32 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 35 | 33 |
|
| 36 | 34 |
ISelection sel = HandlerUtil.getCurrentSelection(event); |
| 37 |
if (!(sel instanceof IStructuredSelection)) return null; |
|
| 35 |
if (!(sel instanceof IStructuredSelection)) {
|
|
| 36 |
Log.info("No available selection to target the corpus annotations to save");
|
|
| 37 |
return null; |
|
| 38 |
} |
|
| 38 | 39 |
IStructuredSelection selection = (IStructuredSelection) sel; |
| 39 | 40 |
|
| 40 |
|
|
| 41 |
MainCorpus corpus = null; |
|
| 42 |
|
|
| 41 | 43 |
if (HandlerUtil.getActiveEditor(event) instanceof ConcordanceEditor) {
|
| 42 | 44 |
corpus = ((ConcordanceEditor) HandlerUtil.getActiveEditor(event)).getCorpus().getMainCorpus(); |
| 43 | 45 |
} else {
|
| 44 | 46 |
Object s = selection.getFirstElement(); |
| 45 |
if ((s instanceof MainCorpus)) {
|
|
| 47 |
if (s == null) {
|
|
| 48 |
Log.info("No available selection to target the corpus annotations to save");
|
|
| 49 |
return null; |
|
| 50 |
} else if ((s instanceof MainCorpus)) {
|
|
| 46 | 51 |
corpus = (MainCorpus) s; |
| 52 |
} else if (s instanceof TXMResult) {
|
|
| 53 |
corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
| 54 |
} else {
|
|
| 55 |
Log.info("No available selection to target the corpus annotations to save");
|
|
| 47 | 56 |
return null; |
| 48 |
} else if (!(s instanceof TXMResult)) {
|
|
| 49 |
corpus = ((TXMResult) s).getFirstParent(MainCorpus.class); |
|
| 50 | 57 |
} |
| 51 | 58 |
} |
| 52 | 59 |
|
| 53 | 60 |
try {
|
| 54 |
|
|
| 55 | 61 |
if (!KRAnnotationEngine.needToSaveAnnotations(corpus)) {
|
| 56 |
Log.info("No annotation to save.");
|
|
| 62 |
Log.info(NLS.bind("No CQP annotation found to save in the {0} corpus.", corpus));
|
|
| 57 | 63 |
return null; |
| 58 | 64 |
} |
| 59 | 65 |
|
| ... | ... | |
| 83 | 89 |
if (job == null) {
|
| 84 | 90 |
return null; |
| 85 | 91 |
} |
| 86 |
|
|
| 92 |
final MainCorpus fcorpus = corpus; |
|
| 93 |
|
|
| 87 | 94 |
if (job.getState() == Status.OK_STATUS.getCode()) {
|
| 88 | 95 |
if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE)) {
|
| 89 | 96 |
|
| ... | ... | |
| 95 | 102 |
|
| 96 | 103 |
try {
|
| 97 | 104 |
monitor.setTaskName("Updating corpus");
|
| 98 |
if (corpus != null && UpdateCorpus.update(corpus, false, KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)) != null) {
|
|
| 105 |
if (fcorpus != null && UpdateCorpus.update(fcorpus, false, KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)) != null) {
|
|
| 99 | 106 |
monitor.worked(50); |
| 100 | 107 |
this.syncExec(new Runnable() {
|
| 101 | 108 |
|
| 102 | 109 |
@Override |
| 103 | 110 |
public void run() {
|
| 104 |
CorporaView.refreshObject(corpus); |
|
| 111 |
CorporaView.refreshObject(fcorpus);
|
|
| 105 | 112 |
} |
| 106 | 113 |
}); |
| 107 | 114 |
return Status.OK_STATUS; |
| TXM/trunk/org.txm.annotation.kr.rcp/plugin.xml (revision 3522) | ||
|---|---|---|
| 252 | 252 |
icon="icons/functions/pencil_save.png" |
| 253 | 253 |
label="%command.label.111" |
| 254 | 254 |
style="push"> |
| 255 |
<visibleWhen |
|
| 256 |
checkEnabled="false"> |
|
| 257 |
<reference |
|
| 258 |
definitionId="CorpusNeedtoSaveAnnotation"> |
|
| 259 |
</reference> |
|
| 260 |
</visibleWhen> |
|
| 261 | 255 |
</command> |
| 262 | 256 |
</menuContribution> |
| 263 | 257 |
<menuContribution |
| ... | ... | |
| 286 | 280 |
mode="FORCE_TEXT" |
| 287 | 281 |
style="push" |
| 288 | 282 |
tooltip="CQP"> |
| 289 |
<visibleWhen |
|
| 290 |
checkEnabled="false"> |
|
| 291 |
<reference |
|
| 292 |
definitionId="CorpusNeedtoSaveAnnotation"> |
|
| 293 |
</reference> |
|
| 294 |
</visibleWhen> |
|
| 295 | 283 |
</command> |
| 296 | 284 |
</menuContribution> |
| 297 | 285 |
<menuContribution |
| TXM/trunk/org.txm.chartsengine.graphstream.core/src/org/txm/chartsengine/graphstream/core/GSChartsEngine.java (revision 3522) | ||
|---|---|---|
| 10 | 10 |
import org.txm.chartsengine.core.ChartsEngine; |
| 11 | 11 |
import org.txm.chartsengine.core.results.ChartResult; |
| 12 | 12 |
import org.txm.chartsengine.graphstream.core.preferences.GSChartsEnginePreferences; |
| 13 |
import org.txm.utils.logger.Log; |
|
| 13 | 14 |
|
| 14 | 15 |
/** |
| 15 | 16 |
* GraphStream charts engine. |
| ... | ... | |
| 120 | 121 |
|
| 121 | 122 |
@Override |
| 122 | 123 |
public ArrayList<String> getSupportedOutputFileFormats() {
|
| 123 |
System.err.println("ECEChartsEngine.getSupportedOutputFileFormats(): not yet implemented.");
|
|
| 124 |
Log.fine("ECEChartsEngine.getSupportedOutputFileFormats(): not yet implemented.");
|
|
| 124 | 125 |
ArrayList<String> formats = new ArrayList<>(1); |
| 125 | 126 |
formats.add(OUTPUT_FORMAT_NONE); |
| 126 | 127 |
return formats; |
| TXM/trunk/org.txm.connlu.core/src/org/txm/conllu/core/function/UDSearch.java (revision 3522) | ||
|---|---|---|
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 | 4 |
import java.util.ArrayList; |
| 5 |
import java.util.Arrays; |
|
| 5 | 6 |
import java.util.HashMap; |
| 6 | 7 |
import java.util.List; |
| 7 | 8 |
|
| ... | ... | |
| 83 | 84 |
|
| 84 | 85 |
String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX)); |
| 85 | 86 |
|
| 87 |
String[] Tvalues = null; |
|
| 88 |
if (T != null && corpus.getProperty(T) != null && !T.equals(prefix+"form")) {
|
|
| 89 |
Tvalues = corpus.getProperty(T).cpos2Str(positions); |
|
| 90 |
} |
|
| 91 |
String[] NTvalues = null; |
|
| 92 |
if (NT != null && corpus.getProperty(NT) != null) {
|
|
| 93 |
NTvalues = corpus.getProperty(NT).cpos2Str(positions); |
|
| 94 |
} |
|
| 86 | 95 |
HashMap<String, String[]> values = new HashMap<>(); |
| 87 | 96 |
for (String p : ImportCoNLLUAnnotations.UD_PROPERTY_NAMES) {
|
| 88 | 97 |
values.put(prefix+p, corpus.getProperty(prefix+p).cpos2Str(positions)); |
| ... | ... | |
| 103 | 112 |
for (String l : conll) {
|
| 104 | 113 |
Log.info(l); |
| 105 | 114 |
} |
| 106 |
return UDPrintTree.print(svgFile, conll) != null; |
|
| 115 |
return UDPrintTree.print(svgFile, conll, Tvalues, NTvalues) != null;
|
|
| 107 | 116 |
} |
| 108 | 117 |
catch (Throwable e) {
|
| 109 | 118 |
Log.warning("Error while drawing SVG: "+e+ " at "+e.getStackTrace()[0]);
|
| ... | ... | |
| 112 | 121 |
} |
| 113 | 122 |
} |
| 114 | 123 |
|
| 124 |
protected String[] getAvailableProperties() throws CqiClientException {
|
|
| 125 |
List<WordProperty> props = corpus.getProperties(); |
|
| 126 |
String[] sprops = new String[props.size()]; |
|
| 127 |
|
|
| 128 |
for (int i = 0 ; i < props.size() ; i++) {
|
|
| 129 |
sprops[i] = props.get(i).getName(); |
|
| 130 |
} |
|
| 131 |
|
|
| 132 |
Arrays.sort(sprops); |
|
| 133 |
return sprops; |
|
| 134 |
} |
|
| 135 |
|
|
| 115 | 136 |
public String[] getAvailableTProperties() {
|
| 116 | 137 |
|
| 117 |
String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX)); |
|
| 118 |
|
|
| 119 |
String[] properties = new String[ImportCoNLLUAnnotations.UD_PROPERTY_NAMES.length]; |
|
| 120 |
for (int p = 0 ; p < ImportCoNLLUAnnotations.UD_PROPERTY_NAMES.length ; p++) {
|
|
| 121 |
properties[p] = prefix+ImportCoNLLUAnnotations.UD_PROPERTY_NAMES[p]; |
|
| 138 |
// String prefix = UDPreferences.getInstance().getProjectPreferenceValue(corpus.getProject(), UDPreferences.UDPREFIX, UDPreferences.getInstance().getString(UDPreferences.UDPREFIX)); |
|
| 139 |
// |
|
| 140 |
// String[] properties = new String[ImportCoNLLUAnnotations.UD_PROPERTY_NAMES.length]; |
|
| 141 |
// for (int p = 0 ; p < ImportCoNLLUAnnotations.UD_PROPERTY_NAMES.length ; p++) {
|
|
| 142 |
// properties[p] = prefix+ImportCoNLLUAnnotations.UD_PROPERTY_NAMES[p]; |
|
| 143 |
// } |
|
| 144 |
try {
|
|
| 145 |
return getAvailableProperties(); |
|
| 122 | 146 |
} |
| 123 |
return properties; |
|
| 147 |
catch (CqiClientException e) {
|
|
| 148 |
// TODO Auto-generated catch block |
|
| 149 |
e.printStackTrace(); |
|
| 150 |
return new String[0]; |
|
| 151 |
} |
|
| 124 | 152 |
} |
| 125 | 153 |
|
| 126 | 154 |
public String[] getAvailableNTProperties() {
|
| 127 |
return getAvailableTProperties();
|
|
| 155 |
return new String[0];
|
|
| 128 | 156 |
} |
| 129 | 157 |
|
| 130 | 158 |
@Override |
| TXM/trunk/org.txm.libs.deptreeviz/src/org/txm/libs/deptreeviz/UDPrintTree.java (revision 3522) | ||
|---|---|---|
| 3 | 3 |
import java.io.File; |
| 4 | 4 |
import java.io.IOException; |
| 5 | 5 |
import java.io.PrintWriter; |
| 6 |
import java.lang.reflect.Field; |
|
| 7 |
import java.util.ArrayList; |
|
| 6 | 8 |
import java.util.Arrays; |
| 7 | 9 |
import java.util.List; |
| 8 | 10 |
|
| 9 | 11 |
|
| 10 | 12 |
import io.gitlab.nats.deptreeviz.DepTree; |
| 11 | 13 |
import io.gitlab.nats.deptreeviz.SimpleParse; |
| 14 |
import io.gitlab.nats.deptreeviz.SimpleWord; |
|
| 12 | 15 |
|
| 13 | 16 |
public class UDPrintTree {
|
| 14 | 17 |
|
| 15 |
public static File print(File file, List<String> conll) {
|
|
| 18 |
public static File print(File file, List<String> conll, String[] Tvalues, String[] NTvalues) {
|
|
| 16 | 19 |
try {
|
| 17 |
PrintWriter w = new PrintWriter(file); |
|
| 20 |
PrintWriter pw = new PrintWriter(file);
|
|
| 18 | 21 |
|
| 19 | 22 |
SimpleParse p = SimpleParse.fromConll(conll); |
| 20 |
DepTree dt = new DepTree<>(p); |
|
| 23 |
List<SimpleWord> words = p.getWords(); |
|
| 24 |
List<String> labels = p.getVerticesLabels().get("SYN");
|
|
| 25 |
if (Tvalues != null && Tvalues.length == words.size()) {
|
|
| 26 |
|
|
| 27 |
for (int i = 0 ; i < words.size() ; i++) {
|
|
| 28 |
SimpleWord w = words.get(i); |
|
| 29 |
|
|
| 30 |
Field fword = SimpleWord.class.getDeclaredField("word");
|
|
| 31 |
fword.setAccessible(true); |
|
| 32 |
fword.set(w, w.getWord()+"/"+Tvalues[i]); |
|
| 33 |
} |
|
| 34 |
} |
|
| 35 |
|
|
| 36 |
if (NTvalues != null && NTvalues.length == words.size()) {
|
|
| 37 |
ArrayList<String> tmp = (ArrayList)labels; |
|
| 38 |
tmp.clear(); |
|
| 39 |
for (int i = 0 ; i < words.size() ; i++) {
|
|
| 40 |
tmp.add(NTvalues[i]); |
|
| 41 |
} |
|
| 42 |
} |
|
| 43 |
DepTree<SimpleParse, SimpleWord> dt = new DepTree<SimpleParse, SimpleWord>(p); |
|
| 21 | 44 |
//dt.setShowingReferent(true); |
| 22 |
dt.writeTree(w); |
|
| 45 |
//dt.setShowingCat(true); |
|
| 46 |
dt.writeTree(pw); |
|
| 23 | 47 |
//w.close(); |
| 24 | 48 |
return file; |
| 25 | 49 |
} |
| ... | ... | |
| 44 | 68 |
); |
| 45 | 69 |
|
| 46 | 70 |
|
| 47 |
System.out.println("FILE: "+print(file, conll));
|
|
| 71 |
System.out.println("FILE: "+print(file, conll, null, null));
|
|
| 48 | 72 |
} |
| 49 | 73 |
|
| 50 | 74 |
} |
| TXM/trunk/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/SaveCorpus.java (revision 3522) | ||
|---|---|---|
| 12 | 12 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 13 | 13 |
import org.txm.annotation.urs.URSCorpora; |
| 14 | 14 |
import org.txm.annotation.urs.view.ElementPropertiesView; |
| 15 |
import org.txm.core.results.TXMResult; |
|
| 15 | 16 |
import org.txm.annotation.urs.Messages; |
| 16 | 17 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
| 17 | 18 |
import org.txm.rcp.TXMWindows; |
| ... | ... | |
| 21 | 22 |
|
| 22 | 23 |
import visuAnalec.donnees.Corpus; |
| 23 | 24 |
import visuAnalec.fichiers.FichiersJava; |
| 25 |
import visuAnalec.vue.Vue; |
|
| 24 | 26 |
|
| 25 | 27 |
public class SaveCorpus extends AbstractHandler {
|
| 26 | 28 |
|
| ... | ... | |
| 36 | 38 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 37 | 39 |
|
| 38 | 40 |
Object first = CorporaView.getFirstSelectedObject(); |
| 39 |
if (!(first instanceof org.txm.searchengine.cqp.corpus.CQPCorpus)) {
|
|
| 41 |
MainCorpus mainCorpus = null; |
|
| 42 |
if (first instanceof org.txm.searchengine.cqp.corpus.MainCorpus) {
|
|
| 43 |
mainCorpus = (MainCorpus)first; |
|
| 44 |
} else if (first instanceof TXMResult) {
|
|
| 45 |
mainCorpus = ((TXMResult)first).getFirstParent(MainCorpus.class); |
|
| 46 |
} else {
|
|
| 40 | 47 |
Log.warning(NLS.bind(Messages.SaveCorpus_0, first)); |
| 41 | 48 |
return null; |
| 42 | 49 |
} |
| 43 |
final MainCorpus mainCorpus = ((org.txm.searchengine.cqp.corpus.CQPCorpus)first).getMainCorpus(); |
|
| 44 | 50 |
save(mainCorpus, event); |
| 45 | 51 |
|
| 46 | 52 |
return null; |
| ... | ... | |
| 48 | 54 |
|
| 49 | 55 |
public static boolean save(final MainCorpus mainCorpus, ExecutionEvent event) {
|
| 50 | 56 |
|
| 57 |
if (!URSCorpora.hasCorpus(mainCorpus)) {
|
|
| 58 |
Log.warning("** No Analec corpus associated to the CQP corpus: "+mainCorpus);
|
|
| 59 |
return false; |
|
| 60 |
} |
|
| 61 |
|
|
| 51 | 62 |
Corpus corpus = URSCorpora.getCorpus(mainCorpus); |
| 52 | 63 |
|
| 53 | 64 |
if (corpus == null) {
|
| 54 |
Log.severe("No Analec corpus associated to the CQP corpus: "+mainCorpus.getCqpId());
|
|
| 65 |
Log.warning("** No Analec corpus associated to the CQP corpus: "+mainCorpus.getCqpId());
|
|
| 55 | 66 |
return false; |
| 56 | 67 |
} |
| 57 | 68 |
|
| ... | ... | |
| 60 | 71 |
view.applyAll(); |
| 61 | 72 |
} |
| 62 | 73 |
|
| 74 |
Vue vue = URSCorpora.getVue(corpus); |
|
| 75 |
if (!corpus.isModifie() && !vue.isModifiee()) {
|
|
| 76 |
Log.warning("** No changes to save in "+mainCorpus.getCqpId());
|
|
| 77 |
return false; |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
|
|
| 63 | 81 |
File binaryCorpusDirectory = mainCorpus.getProjectDirectory(); |
| 64 |
File fichierCorpus = new File(binaryCorpusDirectory, "/analec/"+mainCorpus.getID()+".ec"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 82 |
File fichierCorpus = URSCorpora.getECFile(mainCorpus);
|
|
| 65 | 83 |
|
| 66 | 84 |
Log.info(NLS.bind(Messages.SaveCorpus_3, fichierCorpus)); |
| 67 | 85 |
if (!URSCorpora.saveCorpus(mainCorpus)) {
|
| TXM/trunk/org.txm.analec.rcp/src/org/txm/annotation/urs/messages.properties (revision 3522) | ||
|---|---|---|
| 197 | 197 |
|
| 198 | 198 |
NavigationField_5 = <identifier> |
| 199 | 199 |
|
| 200 |
SaveCorpus_0 = Selection is not a main corpus: {0}
|
|
| 200 |
SaveCorpus_0 = Selection is not a main corpus ({0})
|
|
| 201 | 201 |
|
| 202 | 202 |
SaveCorpus_3 = Saving the annotations ({0})
|
| 203 | 203 |
|
| TXM/trunk/org.txm.analec.rcp/src/org/txm/annotation/urs/URSCorpora.java (revision 3522) | ||
|---|---|---|
| 10 | 10 |
import org.txm.objects.CorpusBuild; |
| 11 | 11 |
import org.txm.objects.Project; |
| 12 | 12 |
import org.txm.utils.DeleteDir; |
| 13 |
import org.txm.utils.logger.Log; |
|
| 13 | 14 |
|
| 14 | 15 |
import visuAnalec.donnees.Corpus; |
| 15 | 16 |
import visuAnalec.fichiers.FichiersJava; |
| ... | ... | |
| 18 | 19 |
/** |
| 19 | 20 |
* Manages Analec corpus: the corpus are associated with the TXM MainCorpus objects |
| 20 | 21 |
* |
| 22 |
* Use URSCorpora.getCorpus(mcorpus) to start using Analec annotations |
|
| 23 |
* |
|
| 24 |
* Test if a corpus has Analec annotations URSCorpora.hasCorpus(mcorpus) |
|
| 25 |
* |
|
| 26 |
* Save changes with URSCorpora.saveCorpus(mcorpus) |
|
| 27 |
* |
|
| 21 | 28 |
* @author mdecorde |
| 22 | 29 |
* |
| 23 | 30 |
*/ |
| ... | ... | |
| 26 | 33 |
private static final HashMap<CorpusBuild, Corpus> corpora = new HashMap<>(); |
| 27 | 34 |
|
| 28 | 35 |
private static final HashMap<CorpusBuild, Vue> vues = new HashMap<>(); |
| 29 |
|
|
| 36 |
|
|
| 30 | 37 |
/** |
| 31 | 38 |
* Create the ec file if needed, store a reference to the corpus if not already done. |
| 32 | 39 |
* |
| ... | ... | |
| 35 | 42 |
*/ |
| 36 | 43 |
public static Corpus getCorpus(CorpusBuild mcorpus) {
|
| 37 | 44 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
| 38 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ec"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 39 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ecv"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 45 |
File fichierCorpus = getECFile(mcorpus);
|
|
| 46 |
File fichierVue = getECVFile(mcorpus);
|
|
| 40 | 47 |
Corpus corpus = null; |
| 41 | 48 |
if (URSCorpora.corpora.containsKey(mcorpus)) {
|
| 42 | 49 |
corpus = URSCorpora.corpora.get(mcorpus); |
| ... | ... | |
| 66 | 73 |
// TODO: does not work :( |
| 67 | 74 |
if (fichierVue.exists()) {
|
| 68 | 75 |
if (!FichiersJava.ouvrirVue(vue, fichierVue)) {
|
| 69 |
System.out.println("Warning: Fail to open corpus Vue file: " + fichierVue);
|
|
| 76 |
Log.warning("Warning: Fail to open corpus Vue file: " + fichierVue);
|
|
| 70 | 77 |
// return null; |
| 71 | 78 |
} |
| 72 | 79 |
String[] types = vue.getTypesUnitesAVoir(); |
| ... | ... | |
| 77 | 84 |
else {
|
| 78 | 85 |
vue.retablirVueParDefaut(); // |
| 79 | 86 |
if (!FichiersJava.enregistrerVue(vue, fichierVue)) {
|
| 80 |
System.out.println("Warning: Fail to create corpus Vue file: " + fichierVue);
|
|
| 87 |
Log.warning("Warning: Fail to create corpus Vue file: " + fichierVue);
|
|
| 81 | 88 |
// return null; |
| 82 | 89 |
} |
| 83 | 90 |
} |
| ... | ... | |
| 93 | 100 |
return !URSCorpora.corpora.get(mcorpus).getStructure().isVide(); |
| 94 | 101 |
} |
| 95 | 102 |
else {
|
| 96 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ec"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 103 |
File fichierCorpus = getECFile(mcorpus);
|
|
| 97 | 104 |
if (fichierCorpus.exists()) {
|
| 98 | 105 |
return !getCorpus(mcorpus).getStructure().isVide(); |
| 99 | 106 |
} |
| ... | ... | |
| 143 | 150 |
*/ |
| 144 | 151 |
public static boolean saveCorpus(CorpusBuild mcorpus) {
|
| 145 | 152 |
mcorpus = mcorpus.getRootCorpusBuild(); // ensure this is the root CorpusBuild |
| 146 |
Corpus corpus = getCorpus(mcorpus); |
|
| 147 |
Vue vue = getVue(mcorpus); |
|
| 148 |
File dir = new File(mcorpus.getProjectDirectory(), "analec/"); //$NON-NLS-1$ |
|
| 149 |
dir.mkdir(); |
|
| 150 |
File fichierCorpus = new File(dir, mcorpus + ".ec"); //$NON-NLS-1$ |
|
| 151 |
File fichierVueCorpus = new File(dir, mcorpus + ".ecv"); //$NON-NLS-1$ |
|
| 152 |
return FichiersJava.enregistrerCorpus(corpus, fichierCorpus) |
|
| 153 |
&& FichiersJava.enregistrerVue(vue, fichierVueCorpus); |
|
| 153 |
if (hasCorpus(mcorpus)) {
|
|
| 154 |
Corpus corpus = getCorpus(mcorpus); |
|
| 155 |
Vue vue = getVue(mcorpus); |
|
| 156 |
|
|
| 157 |
File fichierCorpus = getECFile(mcorpus); |
|
| 158 |
File fichierVueCorpus = getECVFile(mcorpus); |
|
| 159 |
fichierCorpus.getParentFile().mkdirs(); |
|
| 160 |
|
|
| 161 |
return FichiersJava.enregistrerCorpus(corpus, fichierCorpus) && FichiersJava.enregistrerVue(vue, fichierVueCorpus); |
|
| 162 |
} else {
|
|
| 163 |
return false; |
|
| 164 |
} |
|
| 154 | 165 |
} |
| 155 | 166 |
|
| 156 | 167 |
public static Vue getVue(Corpus corpus) {
|
| ... | ... | |
| 219 | 230 |
Corpus analec_corpus = URSCorpora.getCorpus(mcorpus); |
| 220 | 231 |
analec_corpus.fermer(); |
| 221 | 232 |
} |
| 222 |
|
|
| 233 |
|
|
| 223 | 234 |
URSCorpora.removeCorpus(mcorpus); |
| 224 | 235 |
|
| 225 |
File fichierCorpus = new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ec"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 226 |
File fichierVue = new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ecv"); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 236 |
File fichierCorpus = getECFile(mcorpus);
|
|
| 237 |
File fichierVue = getECVFile(mcorpus);
|
|
| 227 | 238 |
fichierCorpus.delete(); |
| 228 | 239 |
fichierVue.delete(); |
| 229 | 240 |
} |
| 230 | 241 |
else if (r instanceof Project) {
|
| 231 | 242 |
Project project = ((Project) r); |
| 232 | 243 |
if ("clean".equals(state)) {
|
| 233 |
File analecDir = new File(project.getProjectDirectory(), "analec"); |
|
| 244 |
File analecDir = new File(project.getProjectDirectory(), "analec"); //$NON-NLS
|
|
| 234 | 245 |
if (analecDir.exists()) {
|
| 235 | 246 |
DeleteDir.deleteDirectory(analecDir); |
| 236 | 247 |
} |
| ... | ... | |
| 268 | 279 |
|
| 269 | 280 |
@Override |
| 270 | 281 |
public boolean hasAnnotationsToSave(CorpusBuild mcorpus) {
|
| 271 |
|
|
| 282 |
|
|
| 272 | 283 |
return hasAnnotationsToSaveStatic(mcorpus); |
| 273 | 284 |
} |
| 274 | 285 |
|
| ... | ... | |
| 284 | 295 |
* @param mcorpus |
| 285 | 296 |
* @return true is an Analec corpus is already instanced |
| 286 | 297 |
*/ |
| 287 |
private static boolean hasCorpus(CorpusBuild mcorpus) {
|
|
| 298 |
public static boolean hasCorpus(CorpusBuild mcorpus) {
|
|
| 288 | 299 |
|
| 289 |
return corpora.containsKey(mcorpus); |
|
| 300 |
if (!corpora.containsKey(mcorpus)) {
|
|
| 301 |
return getECFile(mcorpus).exists(); |
|
| 302 |
} |
|
| 303 |
|
|
| 304 |
return true; |
|
| 290 | 305 |
} |
| 306 |
|
|
| 307 |
public static File getECFile(CorpusBuild mcorpus) {
|
|
| 308 |
return new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ec"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 309 |
} |
|
| 310 |
|
|
| 311 |
public static File getECVFile(CorpusBuild mcorpus) {
|
|
| 312 |
return new File(mcorpus.getProjectDirectory(), "analec/" + mcorpus.getID() + ".ecv"); //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 313 |
} |
|
| 291 | 314 |
} |
| TXM/trunk/org.txm.analec.rcp/src/org/txm/annotation/urs/messages_fr.properties (revision 3522) | ||
|---|---|---|
| 197 | 197 |
|
| 198 | 198 |
NavigationField_5 = <identifiant> |
| 199 | 199 |
|
| 200 |
SaveCorpus_0 = La sélection n''est pas un corpus racine : {0}
|
|
| 200 |
SaveCorpus_0 = La sélection n''est pas un corpus racine ({0})
|
|
| 201 | 201 |
|
| 202 | 202 |
SaveCorpus_3 = Enregistrement des annotations URS ({0})
|
| 203 | 203 |
|
| TXM/trunk/org.txm.analec.rcp/plugin.xml (revision 3522) | ||
|---|---|---|
| 110 | 110 |
<command |
| 111 | 111 |
commandId="org.txm.annotation.urs.commands.SaveCorpus" |
| 112 | 112 |
style="push"> |
| 113 |
<visibleWhen |
|
| 114 |
checkEnabled="false"> |
|
| 115 |
<reference |
|
| 116 |
definitionId="CorpusNeedtoSaveURSAnnotation"> |
|
| 117 |
</reference> |
|
| 118 |
</visibleWhen> |
|
| 119 | 113 |
</command> |
| 120 | 114 |
<menu |
| 121 | 115 |
id="menu.urs.tools" |
| ... | ... | |
| 271 | 265 |
mode="FORCE_TEXT" |
| 272 | 266 |
style="push" |
| 273 | 267 |
tooltip="URS"> |
| 274 |
<visibleWhen |
|
| 275 |
checkEnabled="false"> |
|
| 276 |
<reference |
|
| 277 |
definitionId="CorpusNeedtoSaveURSAnnotation"> |
|
| 278 |
</reference> |
|
| 279 |
</visibleWhen> |
|
| 280 | 268 |
</command> |
| 281 | 269 |
</menuContribution> |
| 282 | 270 |
<menuContribution |
| TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 3522) | ||
|---|---|---|
| 1583 | 1583 |
Field resultField = BeanParameters.getField(this.getResult(), parameter.key()); |
| 1584 | 1584 |
if (resultField != null) {
|
| 1585 | 1585 |
// multiple |
| 1586 |
if (resultField.getType().isAssignableFrom(List.class)) {
|
|
| 1586 |
if (resultField.getType().isAssignableFrom(List.class) || resultField.getType().isAssignableFrom(ArrayList.class)) {
|
|
| 1587 | 1587 |
value = new ArrayList<>(((PropertiesSelector<Property>) object).getSelectedProperties()); |
| 1588 | 1588 |
// need to copy the list otherwise the properties selector modify the result itself through reference |
| 1589 | 1589 |
} |
| ... | ... | |
| 1591 | 1591 |
value = new ReferencePattern(((PropertiesSelector<Property>) object).getSelectedProperties()); |
| 1592 | 1592 |
} |
| 1593 | 1593 |
// single |
| 1594 |
else {
|
|
| 1594 |
else if (resultField.getType().isAssignableFrom(Property.class)){
|
|
| 1595 | 1595 |
value = ((PropertiesSelector<Property>) object).getSelectedProperties().get(0); |
| 1596 | 1596 |
} |
| 1597 | 1597 |
} |
Formats disponibles : Unified diff