Révision 1975
| tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/handlers/ComputeLexicalTable.java (revision 1975) | ||
|---|---|---|
| 76 | 76 |
Object selection = this.getCorporaViewSelectedObject(event); |
| 77 | 77 |
LexicalTable lexicalTable = null; |
| 78 | 78 |
|
| 79 |
// Creating from Index |
|
| 79 |
// Creating from PartitionIndex
|
|
| 80 | 80 |
if (selection instanceof PartitionIndex) {
|
| 81 | 81 |
|
| 82 | 82 |
IWorkbenchWindow window = TXMWindows.getActiveWindow(); |
| 83 |
List<PartitionIndex> vocabularies = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList(); |
|
| 83 |
// FIXME: SJ: why using a list here? is the command should be launchable from more than one index? |
|
| 84 |
// In not, clean and simplify the code |
|
| 85 |
List<PartitionIndex> partitionIndexes = ((IStructuredSelection) HandlerUtil.getCurrentSelection(event)).toList(); |
|
| 84 | 86 |
|
| 85 | 87 |
ArrayList<String> choices = new ArrayList<String>(); |
| 86 | 88 |
choices.add(LexicalTableUIMessages.useAllOccurrences); |
| ... | ... | |
| 93 | 95 |
|
| 94 | 96 |
int ret = dialog.open(); |
| 95 | 97 |
boolean useAllOccurrences = false; |
| 96 |
//System.out.println("ret= "+ret);
|
|
| 97 | 98 |
if (ret == ListDialog.OK) {
|
| 98 |
//System.out.println("ok");
|
|
| 99 | 99 |
if(dialog.getResult().length == 0) {
|
| 100 | 100 |
return null; |
| 101 | 101 |
} |
| ... | ... | |
| 103 | 103 |
if(sel.equals(LexicalTableUIMessages.useAllOccurrences)) {
|
| 104 | 104 |
useAllOccurrences = true; |
| 105 | 105 |
} |
| 106 |
} else {
|
|
| 107 |
//System.out.println("cancel");
|
|
| 106 |
} |
|
| 107 |
else {
|
|
| 108 | 108 |
return false; |
| 109 | 109 |
} |
| 110 |
|
|
| 111 | 110 |
|
| 112 |
//computeWithVocabularies(vocabularies, useAllOccurrences); |
|
| 113 |
|
|
| 114 |
|
|
| 115 |
if (vocabularies.size() == 0) {
|
|
| 111 |
if (partitionIndexes.size() == 0) {
|
|
| 116 | 112 |
return false; |
| 117 | 113 |
} |
| 118 | 114 |
|
| 119 |
vocabularies = vocabularies.subList(0, 1);
|
|
| 120 |
for (PartitionIndex voc : vocabularies) {
|
|
| 121 |
if (!voc.isComputedWithPartition()) {
|
|
| 122 |
System.out.println(LexicalTableUIMessages.canNotCreateALexicalTableWithAnIndexCreatedOnACorpus);
|
|
| 115 |
partitionIndexes = partitionIndexes.subList(0, 1);
|
|
| 116 |
for (PartitionIndex partitionIndex : partitionIndexes) {
|
|
| 117 |
if (!partitionIndex.isComputedWithPartition()) {
|
|
| 118 |
Log.warning(LexicalTableUIMessages.canNotCreateALexicalTableWithAnIndexCreatedOnACorpus);
|
|
| 123 | 119 |
StatusLine.setMessage(LexicalTableUIMessages.canNotCreateALexicalTableWithAnIndexCreatedOnACorpus); |
| 124 | 120 |
return false; |
| 125 | 121 |
} |
| 126 | 122 |
} |
| 127 | 123 |
|
| 128 |
List<WordProperty> properties = vocabularies.get(0).getProperties();
|
|
| 129 |
for (PartitionIndex voc : vocabularies) {
|
|
| 130 |
if (!properties.equals(voc.getProperties())) {
|
|
| 124 |
List<WordProperty> properties = partitionIndexes.get(0).getProperties();
|
|
| 125 |
for (PartitionIndex partitionIndex : partitionIndexes) {
|
|
| 126 |
if (!properties.equals(partitionIndex.getProperties())) {
|
|
| 131 | 127 |
Log.warning(NLS.bind(LexicalTableUIMessages.vocabulariesMustShareTheSamePropertiesColonP0, properties)); |
| 132 | 128 |
return false; |
| 133 | 129 |
} |
| 134 | 130 |
} |
| 135 | 131 |
|
| 136 |
final PartitionIndex firstIndex = vocabularies.get(0);
|
|
| 132 |
final PartitionIndex firstIndex = partitionIndexes.get(0);
|
|
| 137 | 133 |
Partition firstPartition = firstIndex.getPartition(); |
| 138 |
for (PartitionIndex voc : vocabularies) {
|
|
| 139 |
if (!firstPartition.equals(voc.getPartition())) {
|
|
| 134 |
for (PartitionIndex partitionIndex : partitionIndexes) {
|
|
| 135 |
if (!firstPartition.equals(partitionIndex.getPartition())) {
|
|
| 140 | 136 |
Log.warning(NLS.bind(LexicalTableUIMessages.vocabulariesMustShareTheSamePartitionColonP0, firstPartition)); |
| 141 | 137 |
return false; |
| 142 | 138 |
} |
| ... | ... | |
| 147 | 143 |
lexicalTable = new LexicalTable(firstIndex); |
| 148 | 144 |
lexicalTable.setUseAllOccurrences(useAllOccurrences); |
| 149 | 145 |
lexicalTable.setUnitProperty(property); |
| 146 |
// transmit index fmin/fmax parameters |
|
| 147 |
lexicalTable.setFMinFilter(firstIndex.getFilterFmin()); |
|
| 148 |
lexicalTable.setVMaxFilter(firstIndex.getFilterVmax()); |
|
| 149 |
|
|
| 150 | 150 |
|
| 151 | 151 |
|
| 152 | 152 |
|
| 153 |
// FIXME: useless? |
|
| 153 |
|
|
| 154 |
// FIXME: SJ: became useless? |
|
| 154 | 155 |
//return null; |
| 155 | 156 |
// } else if (s instanceof QueryIndex) {
|
| 156 | 157 |
// List<QueryIndex> qindexes = selection.toList(); |
Formats disponibles : Unified diff