You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opennlp.apache.org by jo...@apache.org on 2011/10/13 00:04:57 UTC
svn commit: r1182597 -
/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
Author: joern
Date: Wed Oct 12 22:04:57 2011
New Revision: 1182597
URL: http://svn.apache.org/viewvc?rev=1182597&view=rev
Log:
OPENNLP-312 Improved selection handling after a possible entity is remved from the list through confirmation.
Modified:
incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
Modified: incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java
URL: http://svn.apache.org/viewvc/incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java?rev=1182597&r1=1182596&r2=1182597&view=diff
==============================================================================
--- incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java (original)
+++ incubator/opennlp/sandbox/caseditor-opennlp-plugin/src/main/java/org/apache/opennlp/caseditor/namefinder/EntityContentProvider.java Wed Oct 12 22:04:57 2011
@@ -40,6 +40,7 @@ import org.eclipse.core.runtime.jobs.IJo
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.widgets.Display;
@@ -131,20 +132,36 @@ public class EntityContentProvider imple
entity.setLinkedAnnotation(annotation);
entity.setConfidence(null);
- EntityContentProvider.this.entityListViewer.remove(entity);
- EntityContentProvider.this.candidateEntities.remove(entity);
+ int selectionIndex = EntityContentProvider.this.entityListViewer.
+ getTable().getSelectionIndex();
+ entityListViewer.remove(entity);
+ candidateEntities.remove(entity);
- EntityContentProvider.this.confirmedEntities.add(entity);
+ confirmedEntities.add(entity);
// Delete all other entities which match
for (int i = 1; i < entityList.size(); i++) {
Entity removeEntity = entityList.get(i);
if (!removeEntity.isConfirmed()) {
- EntityContentProvider.this.entityListViewer.remove(removeEntity);
- EntityContentProvider.this.candidateEntities.remove(removeEntity);
+ entityListViewer.remove(removeEntity);
+ candidateEntities.remove(removeEntity);
}
}
+
+ if (selectionIndex < entityListViewer.
+ getTable().getItemCount()) {
+ entityListViewer.setSelection(
+ new StructuredSelection(entityListViewer.getElementAt(selectionIndex)));
+ }
+ else {
+ if (entityListViewer.getTable().getItemCount() > 0) {
+ entityListViewer.setSelection(new StructuredSelection(
+ entityListViewer.getElementAt(
+ entityListViewer.getTable().getItemCount() - 1)));
+ }
+ }
+
}
else {
Entity newEntity = new Entity(annotation.getBegin(), annotation.getEnd(),