Révision 543
| tmp/org.txm.core/src/java/org/txm/objects/TxmObject.java (revision 543) | ||
|---|---|---|
| 263 | 263 |
@Override |
| 264 | 264 |
public void clean() {
|
| 265 | 265 |
// TODO Auto-generated method stub |
| 266 |
|
|
| 267 | 266 |
} |
| 268 | 267 |
|
| 269 | 268 |
@Override |
| ... | ... | |
| 283 | 282 |
// TODO Auto-generated method stub |
| 284 | 283 |
return false; |
| 285 | 284 |
} |
| 286 |
|
|
| 287 |
/* (non-Javadoc) |
|
| 288 |
* @see org.txm.objects.TxmObject#removeChildren(org.txm.objects.TxmObject) |
|
| 289 |
*/ |
|
| 290 |
public TxmObject removeChildren(TxmObject o) {
|
|
| 291 |
if (super.removeResult(o)) {
|
|
| 292 |
getSelfElement().removeChild(o.getSelfElement()); |
|
| 293 |
} |
|
| 294 |
return o; |
|
| 295 |
} |
|
| 296 |
|
|
| 297 |
/* (non-Javadoc) |
|
| 298 |
* @see org.txm.objects.TxmObject#hasChildren(org.txm.objects.TxmObject) |
|
| 299 |
*/ |
|
| 300 |
public boolean hasChildren(TxmObject o) {
|
|
| 301 |
return this.getResults(TxmObject.class).contains(o); |
|
| 302 |
} |
|
| 303 |
|
|
| 304 | 285 |
} |
| tmp/org.txm.referencer.rcp/src/org/txm/rcp/editors/referencer/ReferencerEditor.java (revision 543) | ||
|---|---|---|
| 99 | 99 |
QueryWidget querywidget; |
| 100 | 100 |
|
| 101 | 101 |
/** The props area. */ |
| 102 |
protected PropertiesSelector propsArea; |
|
| 102 |
protected PropertiesSelector<Property> propsArea;
|
|
| 103 | 103 |
|
| 104 | 104 |
/** The pattern area. */ |
| 105 |
protected PropertiesSelector patternArea; |
|
| 105 |
protected PropertiesSelector<Property> patternArea;
|
|
| 106 | 106 |
|
| 107 | 107 |
/** The navigation area. */ |
| 108 | 108 |
NavigationWidget navigationArea; |
| tmp/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 543) | ||
|---|---|---|
| 131 | 131 |
|
| 132 | 132 |
private ArrayList<Property> availableRightSortProperties; |
| 133 | 133 |
|
| 134 |
/** |
|
| 135 |
* |
|
| 136 |
* @param corpus |
|
| 137 |
* @param v |
|
| 138 |
* @return a list of word properties read from a String |
|
| 139 |
*/ |
|
| 140 |
public static List<Property> stringToProperties(Corpus corpus, String v) {
|
|
| 141 |
|
|
| 142 |
ArrayList<Property> props = new ArrayList<Property>(); |
|
| 143 |
if (v == null) return props; |
|
| 144 |
if (v.length() == 0) return props; |
|
| 145 |
|
|
| 146 |
String[] split = v.split("\t");
|
|
| 147 |
for (String s : split) {
|
|
| 148 |
Property prop; |
|
| 149 |
try {
|
|
| 150 |
prop = corpus.getProperty(s); |
|
| 151 |
} catch (CqiClientException e) {
|
|
| 152 |
System.out.println("Error: "+v+" property not found in "+corpus);
|
|
| 153 |
Log.printStackTrace(e); |
|
| 154 |
return null; |
|
| 155 |
} |
|
| 156 |
if (prop != null) {
|
|
| 157 |
props.add(prop); |
|
| 158 |
} |
|
| 159 |
} |
|
| 160 |
return props; |
|
| 161 |
} |
|
| 162 |
|
|
| 163 |
/** |
|
| 164 |
* |
|
| 165 |
* @param corpus |
|
| 166 |
* @param v |
|
| 167 |
* @return a list of word and structure properties read from a String |
|
| 168 |
*/ |
|
| 169 |
public static ReferencePattern stringToReferencePattern(Corpus corpus, String v) {
|
|
| 170 |
try {
|
|
| 171 |
ReferencePattern props = new ReferencePattern(); |
|
| 172 |
if (v == null) return props; |
|
| 173 |
if (v.length() == 0) return props; |
|
| 174 |
|
|
| 175 |
String[] split = v.split("\t");
|
|
| 176 |
for (String s : split) {
|
|
| 177 |
if (s.contains("_")) {
|
|
| 178 |
String[] split2 = s.split("_", 2);
|
|
| 179 |
StructuralUnit su = corpus.getStructuralUnit(split2[0]); |
|
| 180 |
if (su != null) {
|
|
| 181 |
Property prop = su.getProperty(split2[1]); |
|
| 182 |
if (prop != null) {
|
|
| 183 |
props.addProperty(prop); |
|
| 184 |
} |
|
| 185 |
} |
|
| 186 |
} else {
|
|
| 187 |
Property prop = corpus.getProperty(s); |
|
| 188 |
if (prop != null) {
|
|
| 189 |
props.addProperty(prop); |
|
| 190 |
} |
|
| 191 |
} |
|
| 192 |
} |
|
| 193 |
return props; |
|
| 194 |
} catch (Exception e) {
|
|
| 195 |
System.out.println("Error: "+v+" property not found in "+corpus);
|
|
| 196 |
return null; |
|
| 197 |
} |
|
| 198 |
} |
|
| 199 |
|
|
| 200 | 134 |
public Concordance(Corpus corpus) {
|
| 201 | 135 |
|
| 202 | 136 |
super(corpus); |
| ... | ... | |
| 215 | 149 |
|
| 216 | 150 |
try {
|
| 217 | 151 |
String propertyNames = this.getStringParameterValue(ConcordancePreferences.KEYWORD_VIEW_PROPERTIES); |
| 218 |
this.pViewKeywordProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 152 |
this.pViewKeywordProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 219 | 153 |
this.availableKeywordViewProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 220 | 154 |
this.availableKeywordViewProperties.removeAll(pViewKeywordProperties); |
| 221 | 155 |
|
| 222 | 156 |
propertyNames = this.getStringParameterValue(ConcordancePreferences.LEFT_VIEW_PROPERTIES); |
| 223 |
this.pViewLeftProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 157 |
this.pViewLeftProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 224 | 158 |
this.availableLeftViewProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 225 | 159 |
this.availableLeftViewProperties.removeAll(pViewLeftProperties); |
| 226 | 160 |
|
| 227 | 161 |
propertyNames = this.getStringParameterValue(ConcordancePreferences.RIGHT_VIEW_PROPERTIES); |
| 228 |
this.pViewRightProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 162 |
this.pViewRightProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 229 | 163 |
this.availableRightViewProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 230 | 164 |
this.availableRightViewProperties.removeAll(pViewRightProperties); |
| 231 | 165 |
|
| 232 | 166 |
propertyNames = this.getStringParameterValue(ConcordancePreferences.KEYWORD_ANALYSIS_PROPERTIES); |
| 233 |
this.pAnalysisKeywordProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 167 |
this.pAnalysisKeywordProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 234 | 168 |
this.availableKeywordSortProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 235 | 169 |
this.availableKeywordSortProperties.removeAll(pAnalysisKeywordProperties); |
| 236 | 170 |
|
| 237 | 171 |
propertyNames = this.getStringParameterValue(ConcordancePreferences.LEFT_ANALYSIS_PROPERTIES); |
| 238 |
this.pAnalysisLeftProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 172 |
this.pAnalysisLeftProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 239 | 173 |
this.availableLeftSortProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 240 | 174 |
this.availableLeftSortProperties.removeAll(pAnalysisLeftProperties); |
| 241 | 175 |
|
| 242 | 176 |
propertyNames = this.getStringParameterValue(ConcordancePreferences.RIGHT_ANALYSIS_PROPERTIES); |
| 243 |
this.pAnalysisRightProperties = Concordance.stringToProperties(corpus, propertyNames);
|
|
| 177 |
this.pAnalysisRightProperties = Property.stringToProperties(corpus, propertyNames);
|
|
| 244 | 178 |
this.availableRightSortProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
| 245 | 179 |
this.availableRightSortProperties.removeAll(pAnalysisRightProperties); |
| 246 | 180 |
|
| ... | ... | |
| 254 | 188 |
this.pViewRefPattern = new ReferencePattern(refProperty); |
| 255 | 189 |
} |
| 256 | 190 |
} else {
|
| 257 |
this.pViewRefPattern = Concordance.stringToReferencePattern(corpus, refPropertyNames);
|
|
| 191 |
this.pViewRefPattern = ReferencePattern.stringToReferencePattern(corpus, refPropertyNames);
|
|
| 258 | 192 |
} |
| 259 | 193 |
|
| 260 | 194 |
refPropertyNames = this.getStringParameterValue(ConcordancePreferences.ANALYSIS_REFERENCEPATTERN); |
| ... | ... | |
| 267 | 201 |
this.pAnalysisRefPattern = new ReferencePattern(refProperty); |
| 268 | 202 |
} |
| 269 | 203 |
} else {
|
| 270 |
this.pAnalysisRefPattern = Concordance.stringToReferencePattern(corpus, refPropertyNames);
|
|
| 204 |
this.pAnalysisRefPattern = ReferencePattern.stringToReferencePattern(corpus, refPropertyNames);
|
|
| 271 | 205 |
} |
| 272 | 206 |
} catch (CqiClientException e) {
|
| 273 | 207 |
// TODO Auto-generated catch block |
| ... | ... | |
| 1203 | 1137 |
if (p instanceof List<?>) this.pAnalysisLeftProperties = (List<Property>)p; |
| 1204 | 1138 |
else {
|
| 1205 | 1139 |
String v = p.toString(); |
| 1206 |
this.pAnalysisLeftProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1140 |
this.pAnalysisLeftProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1207 | 1141 |
} |
| 1208 | 1142 |
} |
| 1209 | 1143 |
|
| ... | ... | |
| 1212 | 1146 |
if (p instanceof List<?>) this.pAnalysisRightProperties = (List<Property>)p; |
| 1213 | 1147 |
else {
|
| 1214 | 1148 |
String v = p.toString(); |
| 1215 |
this.pAnalysisRightProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1149 |
this.pAnalysisRightProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1216 | 1150 |
} |
| 1217 | 1151 |
} |
| 1218 | 1152 |
|
| ... | ... | |
| 1221 | 1155 |
if (p instanceof List<?>) this.pAnalysisKeywordProperties = (List<Property>)p; |
| 1222 | 1156 |
else {
|
| 1223 | 1157 |
String v = p.toString(); |
| 1224 |
this.pAnalysisKeywordProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1158 |
this.pAnalysisKeywordProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1225 | 1159 |
} |
| 1226 | 1160 |
} |
| 1227 | 1161 |
|
| ... | ... | |
| 1230 | 1164 |
if (p instanceof List<?>) this.pViewLeftProperties = (List<Property>)p; |
| 1231 | 1165 |
else {
|
| 1232 | 1166 |
String v = p.toString(); |
| 1233 |
this.pViewLeftProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1167 |
this.pViewLeftProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1234 | 1168 |
} |
| 1235 | 1169 |
} |
| 1236 | 1170 |
|
| ... | ... | |
| 1239 | 1173 |
if (p instanceof List<?>) this.pViewRightProperties = (List<Property>)p; |
| 1240 | 1174 |
else {
|
| 1241 | 1175 |
String v = p.toString(); |
| 1242 |
this.pViewRightProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1176 |
this.pViewRightProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1243 | 1177 |
} |
| 1244 | 1178 |
} |
| 1245 | 1179 |
|
| ... | ... | |
| 1248 | 1182 |
if (p instanceof List<?>) this.pViewKeywordProperties = (List<Property>)p; |
| 1249 | 1183 |
else {
|
| 1250 | 1184 |
String v = p.toString(); |
| 1251 |
this.pViewKeywordProperties = Concordance.stringToProperties(getCorpus(), v);
|
|
| 1185 |
this.pViewKeywordProperties = Property.stringToProperties(getCorpus(), v);
|
|
| 1252 | 1186 |
} |
| 1253 | 1187 |
} |
| 1254 | 1188 |
|
| ... | ... | |
| 1257 | 1191 |
if (p instanceof ReferencePattern) this.pViewRefPattern = (ReferencePattern)p; |
| 1258 | 1192 |
else {
|
| 1259 | 1193 |
String v = p.toString(); |
| 1260 |
this.pViewRefPattern = Concordance.stringToReferencePattern(getCorpus(), v);
|
|
| 1194 |
this.pViewRefPattern = ReferencePattern.stringToReferencePattern(getCorpus(), v);
|
|
| 1261 | 1195 |
} |
| 1262 | 1196 |
} |
| 1263 | 1197 |
|
| ... | ... | |
| 1266 | 1200 |
if (p instanceof ReferencePattern) this.pAnalysisRefPattern = (ReferencePattern)p; |
| 1267 | 1201 |
else {
|
| 1268 | 1202 |
String v = p.toString(); |
| 1269 |
this.pAnalysisRefPattern = Concordance.stringToReferencePattern(getCorpus(), v);
|
|
| 1203 |
this.pAnalysisRefPattern = ReferencePattern.stringToReferencePattern(getCorpus(), v);
|
|
| 1270 | 1204 |
} |
| 1271 | 1205 |
} |
| 1272 | 1206 |
|
| tmp/org.txm.internalview.core/src/org/txm/functions/internal/InternalView.java (revision 543) | ||
|---|---|---|
| 1 | 1 |
package org.txm.functions.internal; |
| 2 | 2 |
|
| 3 | 3 |
import java.io.File; |
| 4 |
import java.io.PrintWriter; |
|
| 4 | 5 |
import java.util.ArrayList; |
| 5 | 6 |
import java.util.Collection; |
| 6 | 7 |
import java.util.HashMap; |
| 7 | 8 |
import java.util.LinkedHashMap; |
| 8 | 9 |
import java.util.List; |
| 9 | 10 |
|
| 11 |
import org.apache.commons.lang.StringUtils; |
|
| 10 | 12 |
import org.txm.core.results.TXMParameters; |
| 11 | 13 |
import org.txm.core.results.TXMResult; |
| 12 | 14 |
import org.txm.internalview.core.Messages; |
| ... | ... | |
| 19 | 21 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 20 | 22 |
import org.txm.searchengine.cqp.corpus.query.Match; |
| 21 | 23 |
import org.txm.searchengine.cqp.corpus.query.Query; |
| 24 |
import org.txm.utils.io.IOUtils; |
|
| 22 | 25 |
|
| 23 | 26 |
public class InternalView extends TXMResult {
|
| 24 | 27 |
|
| 25 |
Corpus corpus; |
|
| 26 |
List<Property> pProperties; |
|
| 27 |
StructuralUnit pStructure; |
|
| 28 |
List<StructuralUnitProperty> pStructProperties; |
|
| 29 |
Integer pCurrentStruct = -1; |
|
| 28 |
protected List<Property> availablesProperties; |
|
| 29 |
protected List<StructuralUnit> availableStructs; |
|
| 30 |
protected List<StructuralUnitProperty> availableStructuralUnitProperties; |
|
| 31 |
protected Corpus corpus; |
|
| 32 |
protected List<Match> matches = new ArrayList<Match>(); |
|
| 33 |
protected int nmatches = 0; |
|
| 34 |
|
|
| 35 |
protected Integer pCurrentPage = -1; |
|
| 36 |
protected List<Property> pProperties; |
|
| 30 | 37 |
|
| 31 |
int nmatches = 0;
|
|
| 32 |
List<Match> matches = new ArrayList<Match>();
|
|
| 38 |
protected List<StructuralUnitProperty> pStructProperties;
|
|
| 39 |
protected StructuralUnit pStructure;
|
|
| 33 | 40 |
|
| 34 |
|
|
| 35 | 41 |
public InternalView(Corpus corpus) {
|
| 36 | 42 |
super(corpus); |
| 37 | 43 |
this.corpus = corpus; |
| 44 |
|
|
| 45 |
try {
|
|
| 46 |
String propNames = this.getStringParameterValue(InternalViewPreferences.PROPERTIES); |
|
| 47 |
pProperties = Property.stringToProperties(corpus, propNames); |
|
| 48 |
availablesProperties = new ArrayList<Property>(corpus.getOrderedProperties()); |
|
| 49 |
availablesProperties.removeAll(pProperties); |
|
| 50 |
|
|
| 51 |
propNames = this.getStringParameterValue(InternalViewPreferences.STRUCTURALUNITS); |
|
| 52 |
availableStructs = corpus.getStructuralUnits(); |
|
| 53 |
pStructure = StructuralUnit.stringToStructuralUnits(corpus, propNames).get(0); |
|
| 54 |
availableStructs.remove(pStructure); |
|
| 55 |
|
|
| 56 |
propNames = this.getStringParameterValue(InternalViewPreferences.STRUCTURALUNITPROPERTIES); |
|
| 57 |
availableStructuralUnitProperties = pStructure.getProperties(); |
|
| 58 |
pStructProperties = StructuralUnitProperty.stringToStructuralUnitProperties(corpus, propNames); |
|
| 59 |
availableStructuralUnitProperties.removeAll(pStructProperties); |
|
| 60 |
|
|
| 61 |
} catch (CqiClientException e) {
|
|
| 62 |
e.printStackTrace(); |
|
| 63 |
} |
|
| 38 | 64 |
} |
| 39 | 65 |
|
| 40 |
public void setParameters(List<Property> properties, StructuralUnit struct, List<StructuralUnitProperty> structProperties, Integer currentStructure) {
|
|
| 41 |
if (properties != null) this.pProperties = properties; |
|
| 42 |
if (struct != null) this.pStructure = struct; |
|
| 43 |
if (structProperties != null) this.pStructProperties = structProperties; |
|
| 44 |
if (currentStructure != null) this.pCurrentStruct = currentStructure; |
|
| 45 |
|
|
| 46 |
dirty = true; |
|
| 66 |
@Override |
|
| 67 |
protected boolean _compute(boolean update) throws Exception {
|
|
| 68 |
//find struct start-end |
|
| 69 |
Query query = new Query("<"+pStructure.getName()+"> [] expand to "+pStructure); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 70 |
//System.out.println(query); |
|
| 71 |
QueryResult result = corpus.query(query, "test", false); //$NON-NLS-1$ |
|
| 72 |
nmatches = result.getNMatch(); |
|
| 73 |
if (nmatches > 0) {
|
|
| 74 |
matches = result.getMatches(); |
|
| 75 |
} |
|
| 76 |
result.drop(); |
|
| 77 |
//System.out.println(matches); |
|
| 78 |
dirty = false; |
|
| 79 |
return nmatches > 0; |
|
| 47 | 80 |
} |
| 48 | 81 |
|
| 49 |
public String getStructInfos() {
|
|
| 82 |
@Override |
|
| 83 |
public boolean canCompute() {
|
|
| 84 |
return corpus != null && |
|
| 85 |
pStructure != null && |
|
| 86 |
pProperties != null && |
|
| 87 |
pProperties.size() > 0 && |
|
| 88 |
pStructProperties != null && |
|
| 89 |
pStructProperties.size() > 0; |
|
| 90 |
} |
|
| 50 | 91 |
|
| 51 |
try {
|
|
| 52 |
if (pStructProperties.size() > 0) {
|
|
| 53 |
String str = Messages.InternalView_3; |
|
| 54 |
for (Property sup : pStructProperties) {
|
|
| 55 |
int[] array = {getCurrentSegmentNo()};
|
|
| 56 |
str += " "+sup.getName()+"="+CQPEngine.getCqiClient().struc2Str(sup.getQualifiedName(), array)[0]; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 57 |
} |
|
| 58 |
return str; |
|
| 59 |
} |
|
| 60 |
} catch (Exception e) {
|
|
| 61 |
System.out.println(Messages.InternalView_6+e.getMessage()); |
|
| 62 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
| 63 |
} |
|
| 64 |
return Messages.InternalView_7; |
|
| 92 |
@Override |
|
| 93 |
public void clean() {
|
|
| 94 |
// TODO Auto-generated method stub |
|
| 65 | 95 |
} |
| 66 | 96 |
|
| 67 |
public HashMap<Property, List<String>> getNext() throws CqiClientException {
|
|
| 68 |
int next = pCurrentStruct + 1; |
|
| 69 |
if (next < nmatches) {
|
|
| 70 |
return getPage(next); |
|
| 71 |
} |
|
| 72 |
return new HashMap<Property, List<String>>(); |
|
| 97 |
public List<Property> getAvailableProperties() {
|
|
| 98 |
return availablesProperties; |
|
| 73 | 99 |
} |
| 74 | 100 |
|
| 75 |
public HashMap<Property, List<String>> getPrevious() throws CqiClientException {
|
|
| 76 |
int previous = pCurrentStruct - 1; |
|
| 77 |
if (previous >= 0 && previous < nmatches) {
|
|
| 78 |
return getPage(previous); |
|
| 79 |
} |
|
| 80 |
return new HashMap<Property, List<String>>(); |
|
| 101 |
public List<StructuralUnit> getAvailableStructs() {
|
|
| 102 |
return availableStructs; |
|
| 81 | 103 |
} |
| 82 | 104 |
|
| 83 |
public HashMap<Property, List<String>> getFirst() throws CqiClientException {
|
|
| 84 |
if (0 < nmatches) {
|
|
| 85 |
return getPage(0); |
|
| 86 |
} |
|
| 87 |
return new HashMap<Property, List<String>>(); |
|
| 105 |
public Corpus getCorpus() {
|
|
| 106 |
return corpus; |
|
| 88 | 107 |
} |
| 89 | 108 |
|
| 90 |
public HashMap<Property, List<String>> getLast() throws CqiClientException {
|
|
| 91 |
if (nmatches - 1 >= 0) {
|
|
| 92 |
return getPage(nmatches - 1); |
|
| 109 |
public String getCurrentLocation() {
|
|
| 110 |
return ""+(pCurrentPage+1); //$NON-NLS-1$ |
|
| 111 |
} |
|
| 112 |
|
|
| 113 |
public HashMap<Property, List<String>> getCurrentPage() throws CqiClientException {
|
|
| 114 |
if (pCurrentPage == null || pCurrentPage < 0) {
|
|
| 115 |
pCurrentPage = 0; |
|
| 93 | 116 |
} |
| 94 |
return new HashMap<Property, List<String>>(); |
|
| 117 |
HashMap<Property, List<String>> current = getPage(pCurrentPage); |
|
| 118 |
return current; |
|
| 95 | 119 |
} |
| 96 | 120 |
|
| 121 |
public Integer getCurrentSegmentNo() {
|
|
| 122 |
return pCurrentPage; |
|
| 123 |
} |
|
| 124 |
|
|
| 125 |
public String getDetails() {
|
|
| 126 |
return corpus.getName()+" "+pStructure.getName()+" "+(pCurrentPage+1); //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 127 |
} |
|
| 128 |
|
|
| 129 |
public Integer getFirst() throws CqiClientException {
|
|
| 130 |
pCurrentPage = 0; |
|
| 131 |
return pCurrentPage; |
|
| 132 |
} |
|
| 133 |
|
|
| 134 |
public Integer getLast() throws CqiClientException {
|
|
| 135 |
pCurrentPage = nmatches -1; |
|
| 136 |
return pCurrentPage; |
|
| 137 |
} |
|
| 138 |
|
|
| 139 |
public String getLocationTail() {
|
|
| 140 |
if (nmatches > 0) |
|
| 141 |
return " / "+nmatches; //$NON-NLS-1$ |
|
| 142 |
return ""; |
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
@Override |
|
| 146 |
public String getName() {
|
|
| 147 |
if (pStructure != null) return pStructure.getName()+" "+pCurrentPage; |
|
| 148 |
return corpus.getName(); |
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
public Integer getNext() throws CqiClientException {
|
|
| 152 |
if (pCurrentPage < nmatches -1 ) {
|
|
| 153 |
pCurrentPage++; |
|
| 154 |
} |
|
| 155 |
return pCurrentPage; |
|
| 156 |
} |
|
| 157 |
|
|
| 158 |
public int getNSegment() {
|
|
| 159 |
return nmatches; |
|
| 160 |
} |
|
| 161 |
|
|
| 97 | 162 |
/** |
| 98 | 163 |
* get the ith page and set the current page number to i |
| 99 | 164 |
* |
| ... | ... | |
| 113 | 178 |
for (Property prop : pProperties) {
|
| 114 | 179 |
rez.put(prop, Match.getValuesForProperty(prop, p)); |
| 115 | 180 |
} |
| 116 |
pCurrentStruct = i;
|
|
| 181 |
pCurrentPage = i;
|
|
| 117 | 182 |
} |
| 118 | 183 |
return rez; |
| 119 | 184 |
} |
| 120 | 185 |
|
| 121 |
public void printNext() throws CqiClientException {
|
|
| 122 |
HashMap<Property, List<String>> seg = getNext(); |
|
| 123 |
if (seg.size() > 0) |
|
| 124 |
System.out.println(seg); |
|
| 186 |
public Integer getPrevious() throws CqiClientException {
|
|
| 187 |
pCurrentPage = Math.max(0, pCurrentPage-1); |
|
| 188 |
return pCurrentPage; |
|
| 125 | 189 |
} |
| 126 | 190 |
|
| 127 |
public void printPrevious() throws CqiClientException {
|
|
| 128 |
HashMap<Property, List<String>> seg = getPrevious(); |
|
| 129 |
if (seg.size() > 0) |
|
| 130 |
System.out.println(seg); |
|
| 131 |
} |
|
| 132 |
|
|
| 133 |
public void printSeg(HashMap<Property, List<String>> seg) {
|
|
| 134 |
Collection<List<String>> values = seg.values(); |
|
| 135 |
if(values.size() == 0) return; |
|
| 136 |
|
|
| 137 |
for(List<String> list : values) {
|
|
| 138 |
for(String value : list) |
|
| 139 |
System.out.print("\t"+value); //$NON-NLS-1$
|
|
| 140 |
System.out.println(); |
|
| 141 |
} |
|
| 142 |
System.out.println(); |
|
| 143 |
} |
|
| 144 |
|
|
| 145 |
public Corpus getCorpus() {
|
|
| 146 |
return corpus; |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
public StructuralUnit getStructuralUnit() {
|
|
| 150 |
return pStructure; |
|
| 151 |
} |
|
| 152 |
|
|
| 153 | 191 |
public List<Property> getProperties() {
|
| 154 | 192 |
return pProperties; |
| 155 | 193 |
} |
| 156 | 194 |
|
| 157 |
public Integer getCurrentSegmentNo() {
|
|
| 158 |
return pCurrentStruct; |
|
| 159 |
} |
|
| 160 |
|
|
| 161 |
public int getNSegment() {
|
|
| 162 |
return nmatches; |
|
| 163 |
} |
|
| 164 |
|
|
| 165 | 195 |
public int getSegmentLength() {
|
| 166 | 196 |
if (matches.size() == 0) return 0; |
| 167 |
if (matches.size() < pCurrentStruct) return 0;
|
|
| 168 |
if (pCurrentStruct == null) return 0;
|
|
| 197 |
if (matches.size() < pCurrentPage) return 0;
|
|
| 198 |
if (pCurrentPage == null) return 0;
|
|
| 169 | 199 |
|
| 170 |
Match m = matches.get(pCurrentStruct);
|
|
| 200 |
Match m = matches.get(pCurrentPage);
|
|
| 171 | 201 |
return m.size(); |
| 172 | 202 |
} |
| 173 | 203 |
|
| 174 |
public boolean isFirst() {
|
|
| 175 |
return pCurrentStruct == 0; |
|
| 204 |
@Override |
|
| 205 |
public String getSimpleName() {
|
|
| 206 |
return getName(); |
|
| 176 | 207 |
} |
| 177 | 208 |
|
| 178 |
public boolean isLast() {
|
|
| 179 |
return pCurrentStruct == nmatches - 1; |
|
| 180 |
} |
|
| 209 |
public String getStructInfos() {
|
|
| 181 | 210 |
|
| 182 |
public String getLocationTail() {
|
|
| 183 |
if (nmatches > 0) |
|
| 184 |
return " / "+nmatches; //$NON-NLS-1$ |
|
| 185 |
return ""; |
|
| 211 |
try {
|
|
| 212 |
if (pStructProperties.size() > 0) {
|
|
| 213 |
String str = Messages.InternalView_3; |
|
| 214 |
for (Property sup : pStructProperties) {
|
|
| 215 |
int[] array = {getCurrentSegmentNo()};
|
|
| 216 |
str += " "+sup.getName()+"="+CQPEngine.getCqiClient().struc2Str(sup.getQualifiedName(), array)[0]; //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 217 |
} |
|
| 218 |
return str; |
|
| 219 |
} |
|
| 220 |
} catch (Exception e) {
|
|
| 221 |
System.out.println(Messages.InternalView_6+e.getMessage()); |
|
| 222 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
| 223 |
} |
|
| 224 |
return Messages.InternalView_7; |
|
| 186 | 225 |
} |
| 187 | 226 |
|
| 188 |
public String getCurrentLocation() {
|
|
| 189 |
return ""+(pCurrentStruct+1); //$NON-NLS-1$
|
|
| 227 |
public StructuralUnit getStructuralUnit() {
|
|
| 228 |
return pStructure;
|
|
| 190 | 229 |
} |
| 191 | 230 |
|
| 192 |
public String getDetails() {
|
|
| 193 |
// TODO Auto-generated method stub |
|
| 194 |
return corpus.getName()+" "+pStructure.getName()+" "+(pCurrentStruct+1); //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 231 |
public boolean isFirst() {
|
|
| 232 |
return pCurrentPage == 0; |
|
| 195 | 233 |
} |
| 196 | 234 |
|
| 197 |
@Override |
|
| 198 |
public String getName() {
|
|
| 199 |
// TODO Auto-generated method stub |
|
| 200 |
return null; |
|
| 235 |
public boolean isLast() {
|
|
| 236 |
return pCurrentPage == nmatches - 1; |
|
| 201 | 237 |
} |
| 202 | 238 |
|
| 203 |
@Override |
|
| 204 |
public String getSimpleName() {
|
|
| 205 |
// TODO Auto-generated method stub |
|
| 206 |
return null; |
|
| 239 |
public void printSeg(HashMap<Property, List<String>> seg) {
|
|
| 240 |
Collection<List<String>> values = seg.values(); |
|
| 241 |
if(values.size() == 0) return; |
|
| 242 |
|
|
| 243 |
for(List<String> list : values) {
|
|
| 244 |
for(String value : list) |
|
| 245 |
System.out.print("\t"+value); //$NON-NLS-1$
|
|
| 246 |
System.out.println(); |
|
| 247 |
} |
|
| 248 |
System.out.println(); |
|
| 207 | 249 |
} |
| 208 | 250 |
|
| 209 |
@Override |
|
| 210 |
public void clean() {
|
|
| 211 |
// TODO Auto-generated method stub |
|
| 212 |
|
|
| 251 |
public void setParameters(List<Property> properties, StructuralUnit struct, List<StructuralUnitProperty> structProperties, Integer currentStructure) {
|
|
| 252 |
if (properties != null) this.pProperties = properties; |
|
| 253 |
if (struct != null) this.pStructure = struct; |
|
| 254 |
if (structProperties != null) this.pStructProperties = structProperties; |
|
| 255 |
if (currentStructure != null) this.pCurrentPage = currentStructure; |
|
| 256 |
|
|
| 257 |
dirty = true; |
|
| 213 | 258 |
} |
| 214 | 259 |
|
| 215 | 260 |
@Override |
| 216 |
public boolean canCompute() {
|
|
| 217 |
return corpus != null && pStructure != null && pProperties != null && pProperties.size() > 0 && pStructProperties != null && pStructProperties.size() > 0;
|
|
| 261 |
public boolean setParameters(TXMParameters parameters) {
|
|
| 262 |
return false;
|
|
| 218 | 263 |
} |
| 219 | 264 |
|
| 220 |
@Override |
|
| 221 |
protected boolean _compute(boolean update) throws Exception {
|
|
| 222 |
//find struct start-end |
|
| 223 |
Query query = new Query("<"+pStructure.getName()+"> [] expand to "+pStructure); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 224 |
//System.out.println(query); |
|
| 225 |
QueryResult result = corpus.query(query, "test", false); //$NON-NLS-1$ |
|
| 226 |
nmatches = result.getNMatch(); |
|
| 227 |
if (nmatches > 0) {
|
|
| 228 |
matches = result.getMatches(); |
|
| 229 |
} |
|
| 230 |
result.drop(); |
|
| 231 |
//System.out.println(matches); |
|
| 232 |
dirty = false; |
|
| 233 |
return nmatches > 0; |
|
| 265 |
public void setStructuralUnit(StructuralUnit structuralUnit) {
|
|
| 266 |
this.pStructure = structuralUnit; |
|
| 234 | 267 |
} |
| 235 | 268 |
|
| 236 | 269 |
@Override |
| 237 | 270 |
public boolean toTxt(File outfile, String encoding, String colseparator, String txtseparator) throws Exception {
|
| 238 |
// TODO Auto-generated method stub |
|
| 271 |
PrintWriter writer = IOUtils.getWriter(outfile, encoding); |
|
| 272 |
for (int ipage = 0 ; ipage < nmatches ; ipage++) { // run through all pages
|
|
| 273 |
LinkedHashMap<Property, List<String>> page = getPage(ipage); |
|
| 274 |
for (Property p : pProperties) {
|
|
| 275 |
writer.println(StringUtils.join(page.get(p), colseparator)); |
|
| 276 |
} |
|
| 277 |
writer.println("\n\n");
|
|
| 278 |
} |
|
| 279 |
writer.close(); |
|
| 239 | 280 |
return false; |
| 240 | 281 |
} |
| 241 | 282 |
|
| 242 |
@Override |
|
| 243 |
public boolean setParameters(TXMParameters parameters) {
|
|
| 244 |
return false; |
|
| 283 |
public void setStructuralUnitProperties(ArrayList<StructuralUnitProperty> supList) {
|
|
| 284 |
this.pStructProperties = supList; |
|
| 245 | 285 |
} |
| 246 | 286 |
|
| 247 |
public HashMap<Property, List<String>> getCurrentPage() throws CqiClientException {
|
|
| 248 |
if (pCurrentStruct == null || pCurrentStruct < 0) {
|
|
| 249 |
return getFirst(); |
|
| 250 |
} |
|
| 251 |
HashMap<Property, List<String>> current = getPage(pCurrentStruct); |
|
| 252 |
return current; |
|
| 287 |
public List<StructuralUnitProperty> getAvailableStructuralUnitProperties() {
|
|
| 288 |
return availableStructuralUnitProperties; |
|
| 253 | 289 |
} |
| 254 | 290 |
|
| 255 |
@Override |
|
| 256 |
public boolean saveParameters() {
|
|
| 257 |
// TODO Auto-generated method stub |
|
| 258 |
return false; |
|
| 291 |
public List<StructuralUnitProperty> getStructuralUnitProperties() {
|
|
| 292 |
return pStructProperties; |
|
| 259 | 293 |
} |
| 260 | 294 |
} |
| tmp/org.txm.internalview.core/src/org/txm/functions/internal/InternalViewPreferences.java (revision 543) | ||
|---|---|---|
| 9 | 9 |
|
| 10 | 10 |
public static String PREFERENCES_NODE = FrameworkUtil.getBundle(InternalViewPreferences.class).getSymbolicName(); |
| 11 | 11 |
|
| 12 |
/** the selected word properties */ |
|
| 13 |
public static final String PROPERTIES = "properties"; |
|
| 14 |
/** the selected structural units */ |
|
| 15 |
public static final String STRUCTURALUNITS = "structuralunits"; |
|
| 16 |
/** the selected structure properties */ |
|
| 17 |
public static final String STRUCTURALUNITPROPERTIES = "structuralunitsproperties"; |
|
| 18 |
/** the current page number */ |
|
| 19 |
public static final String CURRENTPAGE = "current_page"; |
|
| 20 |
|
|
| 12 | 21 |
@Override |
| 13 | 22 |
public void initializeDefaultPreferences() {
|
| 14 | 23 |
Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE); |
| 24 |
|
|
| 25 |
preferences.put(PROPERTIES, "word"); |
|
| 26 |
preferences.put(STRUCTURALUNITS, "text"); |
|
| 27 |
preferences.putInt(CURRENTPAGE, 0); |
|
| 15 | 28 |
} |
| 16 | 29 |
} |
| tmp/org.txm.internalview.rcp/src/org/txm/internal/rcp/editors/InternalViewEditor.java (revision 543) | ||
|---|---|---|
| 5 | 5 |
import java.util.HashSet; |
| 6 | 6 |
import java.util.List; |
| 7 | 7 |
|
| 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 9 |
import org.eclipse.core.runtime.IStatus; |
|
| 10 |
import org.eclipse.core.runtime.Status; |
|
| 11 | 8 |
import org.eclipse.jface.action.MenuManager; |
| 12 | 9 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
| 13 | 10 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
| ... | ... | |
| 37 | 34 |
import org.txm.internalview.rcp.AdapterFactory; |
| 38 | 35 |
import org.txm.internalview.rcp.Messages; |
| 39 | 36 |
import org.txm.rcp.IImageKeys; |
| 40 |
import org.txm.rcp.JobsTimer; |
|
| 41 | 37 |
import org.txm.rcp.editors.TXMEditorPart; |
| 42 | 38 |
import org.txm.rcp.editors.TXMResultEditorInput; |
| 43 | 39 |
import org.txm.rcp.editors.TableKeyListener; |
| 44 | 40 |
import org.txm.rcp.swt.widget.NavigationWidget; |
| 45 | 41 |
import org.txm.rcp.swt.widget.PropertiesSelector; |
| 46 |
import org.txm.rcp.utils.JobHandler; |
|
| 47 | 42 |
import org.txm.rcp.views.corpora.CorporaView; |
| 48 | 43 |
import org.txm.searchengine.cqp.CQPEngine; |
| 49 | 44 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| ... | ... | |
| 59 | 54 |
|
| 60 | 55 |
public static final String ID = InternalViewEditor.class.getName(); |
| 61 | 56 |
|
| 62 |
Corpus corpus; |
|
| 63 |
InternalView internalView; |
|
| 57 |
protected Corpus corpus; |
|
| 58 |
protected InternalView internalView; |
|
| 59 |
|
|
| 60 |
protected Combo structCombo; |
|
| 61 |
|
|
| 62 |
protected PropertiesSelector<Property> propSelector; |
|
| 63 |
protected PropertiesSelector<StructuralUnitProperty> structSelector; |
|
| 64 |
protected TableViewer viewer; |
|
| 65 |
protected Table table; |
|
| 66 |
protected NavigationWidget navigation; |
|
| 67 |
protected HashMap<Property, List<String>> lines; |
|
| 64 | 68 |
|
| 65 |
Combo structCombo; |
|
| 66 |
List<StructuralUnit> availableStructs; |
|
| 67 |
PropertiesSelector propSelector; |
|
| 68 |
PropertiesSelector structSelector; |
|
| 69 |
List<Property> availables; |
|
| 70 |
List<Property> selected; |
|
| 71 |
TableViewer viewer; |
|
| 72 |
Table table; |
|
| 73 |
NavigationWidget navigation; |
|
| 74 |
HashMap<Property, List<String>> line; |
|
| 69 |
protected Label structInfos; |
|
| 70 |
protected Composite formPanel; |
|
| 71 |
protected Composite navigationPanel; |
|
| 72 |
protected Composite resultPanel; |
|
| 75 | 73 |
|
| 76 |
Label structInfos; |
|
| 77 |
private Composite formPanel; |
|
| 78 |
private Composite navigationPanel; |
|
| 79 |
private Composite resultPanel; |
|
| 80 |
|
|
| 81 | 74 |
/* (non-Javadoc) |
| 82 | 75 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
| 83 | 76 |
*/ |
| ... | ... | |
| 112 | 105 |
return false; |
| 113 | 106 |
} |
| 114 | 107 |
|
| 115 |
@Override |
|
| 116 |
public void computeResult() {
|
|
| 117 |
|
|
| 118 |
final StructuralUnit struct = this.availableStructs.get(this.structCombo.getSelectionIndex()); |
|
| 108 |
public void updateParameters() {
|
|
| 109 |
final StructuralUnit struct = internalView.getAvailableStructs().get(this.structCombo.getSelectionIndex()); |
|
| 119 | 110 |
final List<Property> properties = propSelector.getProperties(); |
| 120 | 111 |
final List<StructuralUnitProperty> supList = new ArrayList<StructuralUnitProperty>(); |
| 121 |
List<Property> pList = structSelector.getProperties(); |
|
| 112 |
List<StructuralUnitProperty> pList = structSelector.getProperties();
|
|
| 122 | 113 |
for (Property property : pList) if (property instanceof StructuralUnitProperty) supList.add((StructuralUnitProperty) property); |
| 123 | 114 |
|
| 124 | 115 |
Integer currentPage = internalView.getCurrentSegmentNo(); |
| 125 | 116 |
if (currentPage == null) currentPage = 0; |
| 126 | 117 |
internalView.setParameters(properties, struct, supList, currentPage); |
| 118 |
} |
|
| 119 |
|
|
| 120 |
@Override |
|
| 121 |
public void refresh(boolean update) {
|
|
| 127 | 122 |
|
| 128 |
JobHandler jobhandler = new JobHandler(Messages.InternalViewEditor_1) {
|
|
| 129 |
@Override |
|
| 130 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 131 |
this.runInit(monitor); |
|
| 132 |
JobsTimer.start(); |
|
| 133 |
monitor.beginTask(Messages.InternalViewEditor_2, 100); |
|
| 134 |
try {
|
|
| 135 |
if (!(internalView.canCompute() && internalView.isDirty())) |
|
| 136 |
return Status.CANCEL_STATUS; |
|
| 137 |
|
|
| 138 |
internalView.compute(false, monitor); |
|
| 139 |
firePropertyChange(PROP_DIRTY); // refresh the dirtiness state |
|
| 140 |
line = internalView.getCurrentPage(); // get the first page if pCurrentPage is not set |
|
| 141 |
monitor.beginTask(Messages.InternalViewEditor_3, 100); |
|
| 142 |
this.syncExec(new Runnable() {
|
|
| 143 |
@Override |
|
| 144 |
public void run() {
|
|
| 145 |
try {
|
|
| 146 |
fillResultArea(); |
|
| 147 |
CorporaView.refresh(); |
|
| 148 |
} catch (CqiClientException e) {
|
|
| 149 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 150 |
} |
|
| 151 |
} |
|
| 152 |
}); |
|
| 153 |
} catch (ThreadDeath td) {
|
|
| 154 |
return Status.CANCEL_STATUS; |
|
| 155 |
} catch(Exception e) {
|
|
| 156 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 157 |
} finally {
|
|
| 158 |
monitor.done(); |
|
| 159 |
JobsTimer.stopAndPrint(); |
|
| 160 |
} |
|
| 161 |
return Status.OK_STATUS; |
|
| 162 |
} |
|
| 163 |
}; |
|
| 164 |
jobhandler.schedule(); |
|
| 123 |
// JobHandler jobhandler = new JobHandler(Messages.InternalViewEditor_1) {
|
|
| 124 |
// @Override |
|
| 125 |
// protected IStatus run(IProgressMonitor monitor) {
|
|
| 126 |
// this.runInit(monitor); |
|
| 127 |
// JobsTimer.start(); |
|
| 128 |
// monitor.beginTask(Messages.InternalViewEditor_2, 100); |
|
| 129 |
// try {
|
|
| 130 |
try {
|
|
| 131 |
lines = internalView.getCurrentPage(); |
|
| 132 |
fillResultArea(); |
|
| 133 |
CorporaView.refresh(); |
|
| 134 |
} catch (CqiClientException e) {
|
|
| 135 |
// TODO Auto-generated catch block |
|
| 136 |
e.printStackTrace(); |
|
| 137 |
} // get the first page if pCurrentPage is not set |
|
| 138 |
// monitor.beginTask(Messages.InternalViewEditor_3, 100); |
|
| 139 |
// this.syncExec(new Runnable() {
|
|
| 140 |
// @Override |
|
| 141 |
// public void run() {
|
|
| 142 |
// try {
|
|
| 143 |
|
|
| 144 |
// } catch (CqiClientException e) {
|
|
| 145 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 146 |
// } |
|
| 147 |
// } |
|
| 148 |
// }); |
|
| 149 |
// } catch (ThreadDeath td) {
|
|
| 150 |
// return Status.CANCEL_STATUS; |
|
| 151 |
// } catch(Exception e) {
|
|
| 152 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 153 |
// } finally {
|
|
| 154 |
// monitor.done(); |
|
| 155 |
// JobsTimer.stopAndPrint(); |
|
| 156 |
// } |
|
| 157 |
// return Status.OK_STATUS; |
|
| 158 |
// } |
|
| 159 |
// }; |
|
| 160 |
// jobhandler.schedule(); |
|
| 165 | 161 |
} |
| 166 | 162 |
|
| 167 | 163 |
public void fillResultArea() throws CqiClientException |
| 168 | 164 |
{
|
| 169 | 165 |
initColumns(); |
| 170 |
viewer.setInput(line); |
|
| 166 |
lines = internalView.getCurrentPage(); |
|
| 167 |
viewer.setInput(lines); |
|
| 171 | 168 |
viewer.refresh(); |
| 172 | 169 |
|
| 173 | 170 |
navigation.setInfoLineText(""+(internalView.getCurrentSegmentNo()+1), internalView.getLocationTail()); //$NON-NLS-1$
|
| ... | ... | |
| 208 | 205 |
structComboLabel.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, true)); |
| 209 | 206 |
structCombo = new Combo(formPanel, SWT.NONE); |
| 210 | 207 |
structCombo.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, true)); |
| 208 |
structCombo.addSelectionListener(new SelectionListener() {
|
|
| 209 |
@Override |
|
| 210 |
public void widgetSelected(SelectionEvent e) {
|
|
| 211 |
internalView.setStructuralUnit(internalView.getAvailableStructs().get(structCombo.getSelectionIndex())); |
|
| 212 |
try {
|
|
| 213 |
internalView.getFirst(); |
|
| 214 |
fillResultArea(); |
|
| 215 |
} catch (CqiClientException e1) {
|
|
| 216 |
System.out.println("Error: "+e1.getLocalizedMessage());
|
|
| 217 |
Log.printStackTrace(e1); |
|
| 218 |
} |
|
| 219 |
} |
|
| 220 |
|
|
| 221 |
@Override |
|
| 222 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 223 |
}); |
|
| 211 | 224 |
propSelector = new PropertiesSelector(formPanel, SWT.NONE); |
| 212 | 225 |
propSelector.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, true)); |
| 213 | 226 |
propSelector.setLayout(new GridLayout(3, false)); |
| ... | ... | |
| 216 | 229 |
public void widgetSelected(SelectionEvent e) {
|
| 217 | 230 |
internalView.setParameters(propSelector.getProperties(), null, null, null); |
| 218 | 231 |
try {
|
| 219 |
line = internalView.getPage(internalView.getCurrentSegmentNo()); |
|
| 220 | 232 |
fillResultArea(); |
| 221 | 233 |
} catch (CqiClientException e1) {
|
| 222 | 234 |
System.out.println("Error: "+e1.getLocalizedMessage());
|
| ... | ... | |
| 237 | 249 |
public void widgetSelected(SelectionEvent e) {
|
| 238 | 250 |
ArrayList<StructuralUnitProperty> supList = new ArrayList<StructuralUnitProperty>(); |
| 239 | 251 |
for (Property property : structSelector.getProperties()) if (property instanceof StructuralUnitProperty) supList.add((StructuralUnitProperty) property); |
| 240 |
internalView.setParameters(null, null, supList, null);
|
|
| 252 |
internalView.setStructuralUnitProperties(supList);
|
|
| 241 | 253 |
try {
|
| 242 |
line = internalView.getPage(internalView.getCurrentSegmentNo());
|
|
| 254 |
lines = internalView.getCurrentPage();
|
|
| 243 | 255 |
fillResultArea(); |
| 244 | 256 |
} catch (CqiClientException e1) {
|
| 245 | 257 |
System.out.println("Error: "+e1.getLocalizedMessage());
|
| ... | ... | |
| 260 | 272 |
@Override |
| 261 | 273 |
public void widgetSelected(SelectionEvent e) {
|
| 262 | 274 |
internalView.setParameters(null, null, null, 0); |
| 263 |
computeResult();
|
|
| 275 |
TXMEditorPart.compute(getResultData(), true, InternalViewEditor.this);
|
|
| 264 | 276 |
} |
| 265 | 277 |
|
| 266 | 278 |
@Override |
| 267 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 268 |
// TODO Auto-generated method stub |
|
| 269 |
} |
|
| 279 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 270 | 280 |
}); |
| 271 | 281 |
|
| 272 | 282 |
navigation = new NavigationWidget(navigationPanel, SWT.NONE); |
| ... | ... | |
| 295 | 305 |
public void widgetSelected(SelectionEvent e) {
|
| 296 | 306 |
if (internalView != null) {
|
| 297 | 307 |
try {
|
| 298 |
line = internalView.getFirst();
|
|
| 308 |
internalView.getFirst(); |
|
| 299 | 309 |
fillResultArea(); // one segment at time |
| 300 | 310 |
|
| 301 | 311 |
navigation.setFirstEnabled(false); |
| ... | ... | |
| 317 | 327 |
public void widgetSelected(SelectionEvent e) {
|
| 318 | 328 |
if (internalView != null) {
|
| 319 | 329 |
try {
|
| 320 |
line = internalView.getPrevious();
|
|
| 330 |
internalView.getPrevious(); |
|
| 321 | 331 |
fillResultArea(); // one segment at time |
| 322 | 332 |
|
| 323 | 333 |
navigation.setFirstEnabled(true); |
| ... | ... | |
| 339 | 349 |
public void widgetSelected(SelectionEvent e) {
|
| 340 | 350 |
if (internalView != null) {
|
| 341 | 351 |
try {
|
| 342 |
line = internalView.getNext();
|
|
| 352 |
internalView.getNext(); |
|
| 343 | 353 |
fillResultArea(); // one segment at time |
| 344 | 354 |
|
| 345 | 355 |
navigation.setFirstEnabled(true); |
| ... | ... | |
| 361 | 371 |
public void widgetSelected(SelectionEvent e) {
|
| 362 | 372 |
if (internalView != null) {
|
| 363 | 373 |
try {
|
| 364 |
line = internalView.getLast();
|
|
| 374 |
internalView.getLast(); |
|
| 365 | 375 |
fillResultArea(); // one segment at time |
| 366 | 376 |
|
| 367 | 377 |
navigation.setFirstEnabled(true); |
| ... | ... | |
| 427 | 437 |
|
| 428 | 438 |
createContextMenu(); |
| 429 | 439 |
|
| 430 |
computeResult();
|
|
| 440 |
TXMEditorPart.compute(getResultData(), true, InternalViewEditor.this);
|
|
| 431 | 441 |
} |
| 432 | 442 |
|
| 433 | 443 |
protected boolean goToPage(int next) throws CqiClientException {
|
| 434 |
line = internalView.getPage(next); |
|
| 444 |
lines = internalView.getPage(next);
|
|
| 435 | 445 |
fillResultArea(); // one segment at time |
| 436 | 446 |
|
| 437 | 447 |
if (next == 0) {
|
| ... | ... | |
| 453 | 463 |
} |
| 454 | 464 |
|
| 455 | 465 |
private void reloadStructuralUnitProperties() {
|
| 456 |
StructuralUnit struct = availableStructs.get(structCombo.getSelectionIndex()); |
|
| 457 |
ArrayList<Property> availables = new ArrayList<Property>(struct.getOrderedProperties()); |
|
| 458 |
for (int i = 0 ; i < availables.size() ; i++) {
|
|
| 459 |
String name = availables.get(i).getName(); |
|
| 460 |
if (name.equals("base") || name.equals("project")) //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 461 |
availables.remove(i--); |
|
| 462 |
} |
|
| 463 |
ArrayList<Property> selected = new ArrayList<Property>(); |
|
| 464 |
if (availables.size() > 0) {
|
|
| 465 |
selected.add(availables.remove(0)); |
|
| 466 |
} |
|
| 467 |
structSelector.setProperties(availables, selected); |
|
| 466 |
|
|
| 467 |
structSelector.setProperties(internalView.getAvailableStructuralUnitProperties(), internalView.getStructuralUnitProperties()); |
|
| 468 | 468 |
} |
| 469 | 469 |
|
| 470 | 470 |
HashMap<Property, TableViewerColumn> columns = new HashMap<Property, TableViewerColumn>(); |
| ... | ... | |
| 531 | 531 |
|
| 532 | 532 |
} |
| 533 | 533 |
|
| 534 |
|
|
| 535 | 534 |
public String buildQuery() {
|
| 536 | 535 |
TableColumn[] cols = viewer.getTable().getColumns(); |
| 537 | 536 |
TableItem[] items = viewer.getTable().getItems(); |
| ... | ... | |
| 629 | 628 |
|
| 630 | 629 |
protected void initializeFields() {
|
| 631 | 630 |
try { // init combos
|
| 632 |
availables = new ArrayList<Property>(corpus.getOrderedProperties()); |
|
| 633 |
availableStructs = corpus.getStructuralUnits(); |
|
| 634 | 631 |
|
| 635 |
selected = new ArrayList<Property>();
|
|
| 632 |
propSelector.setProperties(internalView.getAvailableProperties(), internalView.getProperties());
|
|
| 636 | 633 |
|
| 637 |
if (internalView.getProperties() != null && internalView.getProperties().size() > 0) {
|
|
| 638 |
selected = internalView.getProperties(); |
|
| 639 |
availables.removeAll(selected); |
|
| 640 |
propSelector.setProperties(availables, selected); |
|
| 641 |
} else {
|
|
| 642 |
availables.remove(corpus.getProperty("word")); //$NON-NLS-1$
|
|
| 643 |
selected.add(corpus.getProperty("word")); //$NON-NLS-1$
|
|
| 644 |
propSelector.setCorpus(corpus); |
|
| 645 |
} |
|
| 646 |
|
|
| 647 | 634 |
if (internalView.getCurrentSegmentNo() != null) {
|
| 648 | 635 |
Integer n = internalView.getCurrentSegmentNo(); |
| 649 | 636 |
n++; |
| 650 | 637 |
navigation.setInfoLineText(n.toString(), internalView.getLocationTail()); |
| 651 | 638 |
} |
| 652 | 639 |
|
| 653 |
for (StructuralUnit struct : availableStructs)
|
|
| 640 |
for (StructuralUnit struct : internalView.getAvailableStructs())
|
|
| 654 | 641 |
structCombo.add(struct.toString()); |
| 655 |
if (availableStructs.size() > 0) {
|
|
| 642 |
if (internalView.getAvailableStructs().size() > 0) {
|
|
| 656 | 643 |
int hasS = -1; |
| 657 | 644 |
int hasP = -1; |
| 658 |
for (int i = 0 ; i < availableStructs.size() ; i++) {
|
|
| 659 |
if (availableStructs.get(i).getName().equals("s")) hasS = i; //$NON-NLS-1$
|
|
| 660 |
else if (availableStructs.get(i).getName().equals("p")) hasP = i; //$NON-NLS-1$
|
|
| 645 |
for (int i = 0 ; i < internalView.getAvailableStructs().size() ; i++) {
|
|
| 646 |
if (internalView.getAvailableStructs().get(i).getName().equals("s")) hasS = i; //$NON-NLS-1$
|
|
| 647 |
else if (internalView.getAvailableStructs().get(i).getName().equals("p")) hasP = i; //$NON-NLS-1$
|
|
| 661 | 648 |
} |
| 662 | 649 |
|
| 663 | 650 |
if (hasS > 0) {
|
| ... | ... | |
| 680 | 667 |
|
| 681 | 668 |
reloadStructuralUnitProperties(); |
| 682 | 669 |
} |
| 683 |
} catch (CqiClientException e) {
|
|
| 670 |
} catch (Exception e) {
|
|
| 684 | 671 |
System.out.println(Messages.InternalViewEditor_10); |
| 685 | 672 |
org.txm.rcp.utils.Logger.printStackTrace(e); |
| 686 | 673 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnit.java (revision 543) | ||
|---|---|---|
| 32 | 32 |
import java.util.List; |
| 33 | 33 |
|
| 34 | 34 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 35 |
import org.txm.utils.logger.Log; |
|
| 35 | 36 |
|
| 36 | 37 |
// TODO: Auto-generated Javadoc |
| 37 | 38 |
/** |
| ... | ... | |
| 151 | 152 |
Collections.sort(props); |
| 152 | 153 |
return props; |
| 153 | 154 |
} |
| 155 |
|
|
| 156 |
public static List<StructuralUnit> stringToStructuralUnits(Corpus corpus, String v) {
|
|
| 157 |
ArrayList<StructuralUnit> structs = new ArrayList<StructuralUnit>(); |
|
| 158 |
if (v == null) return structs; |
|
| 159 |
if (v.length() == 0) return structs; |
|
| 160 |
|
|
| 161 |
String[] split = v.split("\t");
|
|
| 162 |
for (String s : split) {
|
|
| 163 |
StructuralUnit struc; |
|
| 164 |
try {
|
|
| 165 |
struc = corpus.getStructuralUnit(s); |
|
| 166 |
} catch (CqiClientException e) {
|
|
| 167 |
System.out.println("Error: "+v+" structure not found in "+corpus);
|
|
| 168 |
Log.printStackTrace(e); |
|
| 169 |
return null; |
|
| 170 |
} |
|
| 171 |
if (struc != null) {
|
|
| 172 |
structs.add(struc); |
|
| 173 |
} |
|
| 174 |
} |
|
| 175 |
return structs; |
|
| 176 |
} |
|
| 154 | 177 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/StructuralUnitProperty.java (revision 543) | ||
|---|---|---|
| 52 | 52 |
/** The strucutral unit. */ |
| 53 | 53 |
private StructuralUnit structuralUnit; |
| 54 | 54 |
|
| 55 |
public static List<StructuralUnitProperty> stringToStructuralUnitProperties(Corpus corpus, String v) {
|
|
| 56 |
ArrayList<StructuralUnitProperty> structs = new ArrayList<StructuralUnitProperty>(); |
|
| 57 |
if (v == null) return structs; |
|
| 58 |
if (v.length() == 0) return structs; |
|
| 59 |
|
|
| 60 |
String[] split = v.split("\t");
|
|
| 61 |
for (String s : split) {
|
|
| 62 |
String[] split2 = s.split("_", 2);
|
|
| 63 |
if (split2.length != 2) continue; |
|
| 64 |
try {
|
|
| 65 |
StructuralUnit struc = corpus.getStructuralUnit(split2[0]); |
|
| 66 |
StructuralUnitProperty struc_p = struc.getProperty(split2[1]); |
|
| 67 |
if (struc_p != null) {
|
|
| 68 |
structs.add(struc_p); |
|
| 69 |
} |
|
| 70 |
} catch (CqiClientException e) {
|
|
| 71 |
System.out.println("Error: "+v+" structure property not found in "+corpus);
|
|
| 72 |
Log.printStackTrace(e); |
|
| 73 |
return null; |
|
| 74 |
} |
|
| 75 |
|
|
| 76 |
} |
|
| 77 |
return structs; |
|
| 78 |
} |
|
| 79 |
|
|
| 55 | 80 |
/** |
| 56 | 81 |
* Instantiates a new structural unit property. |
| 57 | 82 |
* |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Property.java (revision 543) | ||
|---|---|---|
| 28 | 28 |
package org.txm.searchengine.cqp.corpus; |
| 29 | 29 |
|
| 30 | 30 |
import java.io.Serializable; |
| 31 |
import java.util.ArrayList; |
|
| 32 |
import java.util.List; |
|
| 31 | 33 |
|
| 34 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
| 35 |
import org.txm.utils.logger.Log; |
|
| 36 |
|
|
| 32 | 37 |
/** |
| 33 | 38 |
* An abstract CQP corpus property. Represents a <strong>type</strong>, not a the value for a specific unit. |
| 34 | 39 |
* |
| ... | ... | |
| 40 | 45 |
|
| 41 | 46 |
private static final long serialVersionUID = -7769130002380230833L; |
| 42 | 47 |
|
| 48 |
/** |
|
| 49 |
* |
|
| 50 |
* @param corpus |
|
| 51 |
* @param v |
|
| 52 |
* @return a list of word properties read from a String |
|
| 53 |
*/ |
|
| 54 |
public static List<Property> stringToProperties(Corpus corpus, String v) {
|
|
| 55 |
|
|
| 56 |
ArrayList<Property> props = new ArrayList<Property>(); |
|
| 57 |
if (v == null) return props; |
|
| 58 |
if (v.length() == 0) return props; |
|
| 59 |
|
|
| 60 |
String[] split = v.split("\t");
|
|
| 61 |
for (String s : split) {
|
|
| 62 |
Property prop; |
|
| 63 |
try {
|
|
| 64 |
prop = corpus.getProperty(s); |
|
| 65 |
} catch (CqiClientException e) {
|
|
| 66 |
System.out.println("Error: "+v+" property not found in "+corpus);
|
|
| 67 |
Log.printStackTrace(e); |
|
| 68 |
return null; |
|
| 69 |
} |
|
| 70 |
if (prop != null) {
|
|
| 71 |
props.add(prop); |
|
| 72 |
} |
|
| 73 |
} |
|
| 74 |
return props; |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
|
|
| 43 | 78 |
/** The name. */ |
| 44 | 79 |
protected String name; |
| 45 | 80 |
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java (revision 543) | ||
|---|---|---|
| 32 | 32 |
import java.util.List; |
| 33 | 33 |
|
| 34 | 34 |
import org.txm.core.messages.TXMCoreMessages; |
| 35 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 35 | 36 |
import org.txm.searchengine.cqp.corpus.Property; |
| 37 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
|
| 36 | 38 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 37 | 39 |
|
| 38 | 40 |
// TODO: Auto-generated Javadoc |
| ... | ... | |
| 47 | 49 |
private List<Property> properties = new ArrayList<Property>(); |
| 48 | 50 |
|
| 49 | 51 |
/** |
| 52 |
* |
|
| 53 |
* @param corpus |
|
| 54 |
* @param v |
|
| 55 |
* @return a list of word and structure properties read from a String |
|
| 56 |
*/ |
|
| 57 |
public static ReferencePattern stringToReferencePattern(Corpus corpus, String v) {
|
|
| 58 |
try {
|
|
| 59 |
ReferencePattern props = new ReferencePattern(); |
|
| 60 |
if (v == null) return props; |
|
| 61 |
if (v.length() == 0) return props; |
|
| 62 |
|
|
| 63 |
String[] split = v.split("\t");
|
|
| 64 |
for (String s : split) {
|
|
| 65 |
if (s.contains("_")) {
|
|
| 66 |
String[] split2 = s.split("_", 2);
|
|
| 67 |
StructuralUnit su = corpus.getStructuralUnit(split2[0]); |
|
| 68 |
if (su != null) {
|
|
| 69 |
Property prop = su.getProperty(split2[1]); |
|
| 70 |
if (prop != null) {
|
|
| 71 |
props.addProperty(prop); |
|
| 72 |
} |
|
| 73 |
} |
|
| 74 |
} else {
|
|
| 75 |
Property prop = corpus.getProperty(s); |
|
| 76 |
if (prop != null) {
|
|
| 77 |
props.addProperty(prop); |
|
| 78 |
} |
|
| 79 |
} |
|
| 80 |
} |
|
| 81 |
return props; |
|
| 82 |
} catch (Exception e) {
|
|
| 83 |
System.out.println("Error: "+v+" property not found in "+corpus);
|
|
| 84 |
return null; |
|
| 85 |
} |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
/** |
|
| 50 | 89 |
* Instantiates a new reference pattern. |
| 51 | 90 |
*/ |
| 52 | 91 |
public ReferencePattern() {
|
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/ViewPropertySelectionDialog.java (revision 543) | ||
|---|---|---|
| 50 | 50 |
/** |
| 51 | 51 |
* the dialog box called to select the view properties @ author mdecorde. |
| 52 | 52 |
*/ |
| 53 |
public class ViewPropertySelectionDialog extends Dialog {
|
|
| 53 |
public class ViewPropertySelectionDialog<P extends Property> extends Dialog {
|
|
| 54 | 54 |
|
| 55 | 55 |
/** The available properties. */ |
| 56 |
final private List<Property> availableProperties;
|
|
| 56 |
final private List<P> availableProperties; |
|
| 57 | 57 |
|
| 58 | 58 |
/** The selected properties. */ |
| 59 |
final private List<Property> selectedProperties;
|
|
| 59 |
final private List<P> selectedProperties; |
|
| 60 | 60 |
|
| 61 | 61 |
/** The maxprops. */ |
| 62 | 62 |
int maxprops = -1; |
| ... | ... | |
| 75 | 75 |
* @param selectedProperties the selected properties |
| 76 | 76 |
*/ |
| 77 | 77 |
public ViewPropertySelectionDialog(IShellProvider parentShell, |
| 78 |
List<Property> availableProperties,
|
|
| 79 |
List<Property> selectedProperties) {
|
|
| 78 |
List<P> availableProperties, |
|
| 79 |
List<P> selectedProperties) {
|
|
| 80 | 80 |
super(parentShell); |
| 81 | 81 |
|
| 82 | 82 |
this.availableProperties = availableProperties; |
| ... | ... | |
| 92 | 92 |
* @param selectedProperties the selected properties |
| 93 | 93 |
*/ |
| 94 | 94 |
public ViewPropertySelectionDialog(Shell shell, |
| 95 |
List<Property> availableProperties,
|
|
| 96 |
List<Property> selectedProperties) {
|
|
| 95 |
List<P> availableProperties, |
|
| 96 |
List<P> selectedProperties) {
|
|
| 97 | 97 |
super(shell); |
| 98 | 98 |
|
| 99 | 99 |
this.availableProperties = availableProperties; |
| ... | ... | |
| 110 | 110 |
* @param maxprops the maxprops |
| 111 | 111 |
*/ |
| 112 | 112 |
public ViewPropertySelectionDialog(Shell shell, |
| 113 |
List<Property> availableProperties,
|
|
| 114 |
List<Property> selectedProperties, int maxprops) {
|
|
| 113 |
List<P> availableProperties, |
|
| 114 |
List<P> selectedProperties, int maxprops) {
|
|
| 115 | 115 |
super(shell); |
| 116 | 116 |
|
| 117 | 117 |
this.availableProperties = availableProperties; |
| ... | ... | |
| 125 | 125 |
* |
| 126 | 126 |
* @return the selected properties |
| 127 | 127 |
*/ |
| 128 |
public List<Property> getSelectedProperties() {
|
|
| 128 |
public List<P> getSelectedProperties() {
|
|
| 129 | 129 |
return selectedProperties; |
| 130 | 130 |
} |
| 131 | 131 |
|
| ... | ... | |
| 209 | 209 |
public void widgetSelected(SelectionEvent e) {
|
| 210 | 210 |
int index = selectedPropertiesView.getSelectionIndex(); |
| 211 | 211 |
if (index > 0) {
|
| 212 |
Property selectedP = selectedProperties.get(index);
|
|
| 213 |
Property upperP = selectedProperties.get(index - 1);
|
|
| 212 |
P selectedP = selectedProperties.get(index); |
|
| 213 |
P upperP = selectedProperties.get(index - 1); |
|
| 214 | 214 |
|
| 215 | 215 |
selectedProperties.set(index, upperP); |
| 216 | 216 |
selectedProperties.set(index - 1, selectedP); |
| ... | ... | |
| 226 | 226 |
public void widgetSelected(SelectionEvent e) {
|
| 227 | 227 |
int index = selectedPropertiesView.getSelectionIndex(); |
| 228 | 228 |
if (index < selectedProperties.size() - 1 && index >= 0) {
|
| 229 |
Property selectedP = selectedProperties.get(index);
|
|
| 230 |
Property bellowP = selectedProperties.get(index + 1);
|
|
| 229 |
P selectedP = selectedProperties.get(index); |
|
| 230 |
P bellowP = selectedProperties.get(index + 1); |
|
| 231 | 231 |
|
| 232 | 232 |
selectedProperties.set(index, bellowP); |
| 233 | 233 |
selectedProperties.set(index + 1, selectedP); |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/PropertiesSelector.java (revision 543) | ||
|---|---|---|
| 28 | 28 |
package org.txm.rcp.swt.widget; |
| 29 | 29 |
|
| 30 | 30 |
import java.util.ArrayList; |
| 31 |
import java.util.Collection; |
|
| 31 | 32 |
import java.util.List; |
| 32 | 33 |
|
| 33 | 34 |
import org.eclipse.osgi.util.NLS; |
| ... | ... | |
| 50 | 51 |
/** |
| 51 | 52 |
* Allow to choose a structural property @ author mdecorde. |
| 52 | 53 |
*/ |
| 53 |
public class PropertiesSelector extends Composite {
|
|
| 54 |
public class PropertiesSelector<P extends Property> extends Composite {
|
|
| 54 | 55 |
|
| 55 | 56 |
/** The corpus. */ |
| 56 | 57 |
Corpus corpus; |
| 57 | 58 |
|
| 58 | 59 |
/** The properties. */ |
| 59 |
List<Property> properties;
|
|
| 60 |
List<P> properties; |
|
| 60 | 61 |
|
| 61 | 62 |
/** The availableprops. */ |
| 62 |
List<Property> availableprops;
|
|
| 63 |
List<P> availableprops; |
|
| 63 | 64 |
|
| 64 | 65 |
/** The maxprops. */ |
| 65 | 66 |
int maxprops = -1; |
| ... | ... | |
| 179 | 180 |
*/ |
| 180 | 181 |
public void setCorpus(Corpus corpus) {
|
| 181 | 182 |
this.corpus = corpus; |
| 182 |
this.properties = new ArrayList<Property>();
|
|
| 183 |
this.properties = new ArrayList<P>(); |
|
| 183 | 184 |
if (corpus == null) |
| 184 | 185 |
return; |
| 185 | 186 |
try {
|
| 186 |
availableprops = new ArrayList<Property>();
|
|
| 187 |
availableprops.addAll(corpus.getOrderedProperties()); |
|
| 187 |
availableprops = new ArrayList<P>(); |
|
| 188 |
availableprops.addAll((Collection<? extends P>) corpus.getOrderedProperties());
|
|
| 188 | 189 |
//availableprops.addAll(corpus.getStructuralUnitProperties()); |
| 189 | 190 |
|
| 190 | 191 |
for (int i = 0; i < availableprops.size(); i++) {
|
| ... | ... | |
| 196 | 197 |
} |
| 197 | 198 |
|
| 198 | 199 |
if (availableprops.size() > 0) {
|
| 199 |
this.properties = new ArrayList<Property>();
|
|
| 200 |
this.properties = new ArrayList<P>(); |
|
| 200 | 201 |
for (int i = 0 ; i < availableprops.size() ; i++) {
|
| 201 | 202 |
if (availableprops.get(i).getName().equals("word")) { //$NON-NLS-1$
|
| 202 | 203 |
properties.add(availableprops.get(i)); |
| ... | ... | |
| 216 | 217 |
* |
| 217 | 218 |
* @return the properties |
| 218 | 219 |
*/ |
| 219 |
public List<Property> getProperties() {
|
|
| 220 |
public List<P> getProperties() {
|
|
| 220 | 221 |
return this.properties; |
| 221 | 222 |
} |
| 222 | 223 |
|
| ... | ... | |
| 225 | 226 |
* |
| 226 | 227 |
* @return the Available properties |
| 227 | 228 |
*/ |
| 228 |
public List<Property> getAvailableProperties() {
|
|
| 229 |
public List<P> getAvailableProperties() {
|
|
| 229 | 230 |
return this.availableprops; |
| 230 | 231 |
} |
| 231 | 232 |
|
| ... | ... | |
| 235 | 236 |
* @param available the available |
| 236 | 237 |
* @param selected the selected |
| 237 | 238 |
*/ |
| 238 |
public void setProperties(List<Property> available, List<Property> selected) {
|
|
| 239 |
public void setProperties(List<P> available, List<P> selected) {
|
|
| 239 | 240 |
// System.out.println("initialize prop selector with: "+available+" and "+selected);
|
| 240 | 241 |
availableprops = available; |
| 241 | 242 |
this.properties = selected; |
| ... | ... | |
| 254 | 255 |
|
| 255 | 256 |
public void clear() {
|
| 256 | 257 |
setText(""); //$NON-NLS-1$
|
| 257 |
setProperties(new ArrayList<Property>(), new ArrayList<Property>());
|
|
| 258 |
setProperties(new ArrayList<P>(), new ArrayList<P>());
|
|
| 258 | 259 |
} |
| 259 | 260 |
|
| 260 | 261 |
ArrayList<Listener> listeners = new ArrayList<Listener>(); |
Formats disponibles : Unified diff