Révision 844
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 844) | ||
|---|---|---|
| 1 | 1 |
package org.txm.rcp.editors; |
| 2 | 2 |
|
| 3 |
import java.util.ArrayList; |
|
| 3 | 4 |
import java.util.HashMap; |
| 5 |
import java.util.List; |
|
| 4 | 6 |
|
| 5 | 7 |
import org.eclipse.jface.action.ToolBarManager; |
| 6 | 8 |
import org.eclipse.swt.SWT; |
| ... | ... | |
| 181 | 183 |
* @param choicesSelectionListeners the corresponding mode selectionListener |
| 182 | 184 |
*/ |
| 183 | 185 |
public Group installAlternativesGroup(final String groupTitle, String buttonToolTip, String openIconFilePath, String closeIconFilePath, boolean showGroup, |
| 184 |
SelectionListener selectionListener, String[] modes, SelectionListener[] modeSelectionListeners) {
|
|
| 186 |
SelectionListener selectionListener, List<String> modes, List<SelectionListener> modeSelectionListeners) {
|
|
| 185 | 187 |
|
| 186 | 188 |
final DropDownCheckToolItem openCloseButton = new DropDownCheckToolItem(this, buttonToolTip, openIconFilePath, closeIconFilePath); |
| 187 | 189 |
|
| ... | ... | |
| 200 | 202 |
|
| 201 | 203 |
org.txm.rcp.swt.listeners.DropdownSelectionListener listenerOne = openCloseButton.getDropDownListener(); |
| 202 | 204 |
listenerOne.setDefaultSelectionListener(selectionListener); |
| 203 |
for (int i = 0 ; i < modes.length && i < modeSelectionListeners.length; i++) {
|
|
| 205 |
for (int i = 0 ; i < modes.size() && i < modeSelectionListeners.size(); i++) {
|
|
| 204 | 206 |
MenuItem item1 = new MenuItem(listenerOne.getMenu(), SWT.PUSH); |
| 205 |
item1.setText(modes[i]);
|
|
| 206 |
item1.addSelectionListener(modeSelectionListeners[i]);
|
|
| 207 |
item1.setText(modes.get(i));
|
|
| 208 |
item1.addSelectionListener(modeSelectionListeners.get(i));
|
|
| 207 | 209 |
} |
| 208 | 210 |
|
| 209 | 211 |
final Group group = new Group(subWidgetComposite, SWT.NONE); |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java (revision 844) | ||
|---|---|---|
| 19 | 19 |
|
| 20 | 20 |
boolean selected = false; |
| 21 | 21 |
private DropdownSelectionListener dropDownListener; |
| 22 |
private SelectionListener listener; |
|
| 22 | 23 |
|
| 23 | 24 |
/** |
| 24 | 25 |
* |
| ... | ... | |
| 44 | 45 |
this.setText(title); |
| 45 | 46 |
} |
| 46 | 47 |
|
| 47 |
this.addSelectionListener(new SelectionListener() {
|
|
| 48 |
listener = new SelectionListener() {
|
|
| 48 | 49 |
|
| 49 | 50 |
@Override |
| 50 | 51 |
public void widgetSelected(SelectionEvent e) {
|
| 51 |
if (!e.doit) {
|
|
| 52 |
if (e != null && !e.doit) {
|
|
| 52 | 53 |
return; // drop down clicked |
| 53 | 54 |
} |
| 54 | 55 |
selected = !selected; |
| ... | ... | |
| 65 | 66 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 66 | 67 |
// TODO Auto-generated method stub |
| 67 | 68 |
} |
| 68 |
}); |
|
| 69 |
}; |
|
| 70 |
this.addSelectionListener(listener); |
|
| 69 | 71 |
} |
| 70 | 72 |
|
| 71 | 73 |
public boolean getSelection() {
|
| 72 | 74 |
return selected; |
| 73 | 75 |
} |
| 74 | 76 |
|
| 77 |
public void select() {
|
|
| 78 |
listener.widgetSelected(null); |
|
| 79 |
} |
|
| 80 |
|
|
| 75 | 81 |
public void setSelection(boolean selected) {
|
| 76 | 82 |
this.selected = selected; |
| 77 | 83 |
} |
| tmp/org.txm.synopticeditor.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 844) | ||
|---|---|---|
| 328 | 328 |
editionsArea = getResultArea(); |
| 329 | 329 |
|
| 330 | 330 |
controlsArea = getBottomToolbar().installGLComposite("controls", 15, false);
|
| 331 |
|
|
| 331 |
controlsArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
|
| 332 | 332 |
//spacer |
| 333 | 333 |
new Label(controlsArea, SWT.NONE).setText(" "); //$NON-NLS-1$
|
| 334 | 334 |
|
| ... | ... | |
| 379 | 379 |
} |
| 380 | 380 |
|
| 381 | 381 |
// Navigation buttons |
| 382 |
|
|
| 383 |
Button first = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 384 |
Button previous = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 385 |
page_text = new org.eclipse.swt.widgets.Text(controlsArea, SWT.BORDER); |
|
| 386 |
page_label = new Label(controlsArea, SWT.NONE); |
|
| 387 |
Button next = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 388 |
Button last = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 389 |
|
|
| 390 |
|
|
| 391 |
Button firstText = new Button(controlsArea, SWT.FLAT); |
|
| 392 |
Button previousText = new Button(controlsArea, SWT.FLAT); |
|
| 393 |
new Label(controlsArea, SWT.NONE).setText(" ");
|
|
| 394 |
Button nextText = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 395 |
Button lastText = new Button(controlsArea, SWT.FLAT|SWT.PUSH); |
|
| 396 |
|
|
| 382 |
GLComposite pageNavigationComposite = new GLComposite(controlsArea, SWT.NONE, "page buttons"); |
|
| 383 |
pageNavigationComposite.getLayout().numColumns = 6; |
|
| 384 |
Button first = new Button(pageNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 385 |
Button previous = new Button(pageNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 386 |
page_text = new org.eclipse.swt.widgets.Text(pageNavigationComposite, SWT.BORDER); |
|
| 387 |
page_label = new Label(pageNavigationComposite, SWT.NONE); |
|
| 388 |
Button next = new Button(pageNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 389 |
Button last = new Button(pageNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 390 |
pageNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, true, false)); |
|
| 391 |
|
|
| 392 |
GLComposite textNavigationComposite = new GLComposite(controlsArea, SWT.NONE, "text buttons"); |
|
| 393 |
textNavigationComposite.getLayout().numColumns = 6; |
|
| 394 |
Button firstText = new Button(textNavigationComposite, SWT.FLAT); |
|
| 395 |
Button previousText = new Button(textNavigationComposite, SWT.FLAT); |
|
| 396 |
new Label(textNavigationComposite, SWT.NONE).setText(" ");
|
|
| 397 |
Button nextText = new Button(textNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 398 |
Button lastText = new Button(textNavigationComposite, SWT.FLAT|SWT.PUSH); |
|
| 399 |
textNavigationComposite.setLayoutData(new GridData(GridData.CENTER, GridData.FILL, false, false)); |
|
| 397 | 400 |
// Layouts data |
| 398 | 401 |
|
| 399 | 402 |
editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); |
| 400 | 403 |
|
| 401 |
GridData buttonGridData = new GridData(GridData.FILL,GridData.CENTER, false, false); |
|
| 402 |
buttonGridData.widthHint = 30; |
|
| 403 |
buttonGridData.heightHint = 30; |
|
| 404 |
firstText.setLayoutData(buttonGridData); |
|
| 405 |
previousText.setLayoutData(buttonGridData); |
|
| 406 |
GridData centerButtonGridData = new GridData(GridData.END,GridData.CENTER, true, true); |
|
| 407 |
centerButtonGridData.widthHint = 30; |
|
| 408 |
centerButtonGridData.heightHint = 30; |
|
| 409 |
first.setLayoutData(centerButtonGridData); |
|
| 410 |
previous.setLayoutData(buttonGridData); |
|
| 404 |
// GridData buttonGridData = new GridData(GridData.END,GridData.CENTER, true, false); |
|
| 405 |
// buttonGridData.widthHint = 30; |
|
| 406 |
// buttonGridData.heightHint = 30; |
|
| 407 |
// firstText.setLayoutData(buttonGridData); |
|
| 408 |
// buttonGridData = new GridData(GridData.CENTER,GridData.CENTER, false, false); |
|
| 409 |
// buttonGridData.widthHint = 30; |
|
| 410 |
// buttonGridData.heightHint = 30; |
|
| 411 |
// previousText.setLayoutData(buttonGridData); |
|
| 412 |
// GridData centerButtonGridData = new GridData(GridData.END,GridData.CENTER, true, true); |
|
| 413 |
// centerButtonGridData.widthHint = 30; |
|
| 414 |
// centerButtonGridData.heightHint = 30; |
|
| 415 |
// first.setLayoutData(centerButtonGridData); |
|
| 416 |
// previous.setLayoutData(buttonGridData); |
|
| 411 | 417 |
|
| 412 | 418 |
// set sizes |
| 413 | 419 |
|
| 414 |
GridData gdata = new GridData(GridData.END,GridData.CENTER, false, false); |
|
| 415 |
gdata.minimumWidth = 40; |
|
| 416 |
gdata.widthHint = 40; |
|
| 417 |
page_text.setLayoutData(gdata); |
|
| 418 |
page_label.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); |
|
| 420 |
// GridData gdata = new GridData(GridData.END,GridData.CENTER, false, false); |
|
| 421 |
// gdata.minimumWidth = 40; |
|
| 422 |
// gdata.widthHint = 40; |
|
| 423 |
// page_text.setLayoutData(gdata); |
|
| 424 |
// page_label.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, false)); |
|
| 425 |
// |
|
| 426 |
// next.setLayoutData(buttonGridData); |
|
| 427 |
// centerButtonGridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, true); |
|
| 428 |
// centerButtonGridData.widthHint = 30; |
|
| 429 |
// centerButtonGridData.heightHint = 30; |
|
| 430 |
// last.setLayoutData(centerButtonGridData); |
|
| 431 |
// nextText.setLayoutData(buttonGridData); |
|
| 432 |
// lastText.setLayoutData(buttonGridData); |
|
| 419 | 433 |
|
| 420 |
next.setLayoutData(buttonGridData); |
|
| 421 |
centerButtonGridData = new GridData(GridData.BEGINNING, GridData.CENTER, true, true); |
|
| 422 |
centerButtonGridData.widthHint = 30; |
|
| 423 |
centerButtonGridData.heightHint = 30; |
|
| 424 |
last.setLayoutData(centerButtonGridData); |
|
| 425 |
nextText.setLayoutData(buttonGridData); |
|
| 426 |
lastText.setLayoutData(buttonGridData); |
|
| 427 | 434 |
|
| 428 |
|
|
| 429 |
if (editionsChooser != null) |
|
| 430 |
editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, true)); |
|
| 435 |
// if (editionsChooser != null) |
|
| 436 |
// editionsChooser.setLayoutData(new GridData(GridData.BEGINNING,GridData.CENTER, false, true)); |
|
| 431 | 437 |
//else spacer.setLayoutData(new GridData(GridData.END,GridData.CENTER, true, true)); |
| 432 | 438 |
|
| 433 | 439 |
// set labels |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPSearchEngine.java (revision 844) | ||
|---|---|---|
| 54 | 54 |
Log.warning("Killing CQP and RServe process if any");
|
| 55 | 55 |
killSearchEngine(); |
| 56 | 56 |
|
| 57 |
|
|
| 58 | 57 |
boolean remote = Boolean.parseBoolean(TXMPreferences.getString(CQPLibPreferences.CQI_SERVER_IS_REMOTE, CQPLibPreferences.PREFERENCES_NODE)); |
| 59 | 58 |
state = false; |
| 60 | 59 |
// test if must-have properties for CWB are set |
| tmp/org.txm.analec.rcp/src/org/txm/analec/toolbarbutton/StartButton.java (revision 844) | ||
|---|---|---|
| 1 | 1 |
package org.txm.analec.toolbarbutton; |
| 2 | 2 |
|
| 3 |
import java.util.Arrays; |
|
| 4 |
|
|
| 3 | 5 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 4 | 6 |
import org.eclipse.core.runtime.IStatus; |
| 5 | 7 |
import org.eclipse.core.runtime.Status; |
| ... | ... | |
| 148 | 150 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
| 149 | 151 |
}; |
| 150 | 152 |
SelectionListener[] modeListeners = {unitStartSelectionListener, schemaStartSelectionListener};
|
| 151 |
annotationWidgetGroup = toolbar.installAlternativesGroup("URS annotation", "Start URS annotation", IImageKeys.PENCIL_OPEN, IImageKeys.PENCIL_CLOSE, true, openCloseSelectionListener, modes, modeListeners);
|
|
| 153 |
annotationWidgetGroup = toolbar.installAlternativesGroup("URS annotation", "Start URS annotation", IImageKeys.PENCIL_OPEN, IImageKeys.PENCIL_CLOSE, true, openCloseSelectionListener, Arrays.asList(modes), Arrays.asList(modeListeners));
|
|
| 152 | 154 |
annotationWidgetGroup.setLayout(GLComposite.createDefaultLayout(1)); |
| 153 | 155 |
saveButton = new ToolItem(toolbar, SWT.PUSH); |
| 154 | 156 |
saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE)); |
| tmp/org.txm.chartsengine.jfreechart.rcp/src/org/txm/chartsengine/jfreechart/rcp/testers/__IsJFCComposite.java (revision 844) | ||
|---|---|---|
| 20 | 20 |
Object expectedValue) {
|
| 21 | 21 |
|
| 22 | 22 |
//FIXME: Debug |
| 23 |
// System.out.println("IsJFCComposite.test() recevier = " + receiver.getClass().getSimpleName());
|
|
| 24 |
// System.out.println("IsJFCComposite.test() property = " + property);
|
|
| 25 |
// System.out.println("IsJFCComposite.test() args = " + args);
|
|
| 26 |
// System.out.println("IsJFCComposite.test() expectedValue = " + expectedValue);
|
|
| 27 |
|
|
| 23 |
System.out.println("IsJFCComposite.test() recevier = " + receiver.getClass());
|
|
| 24 |
System.out.println("IsJFCComposite.test() property = " + property);
|
|
| 25 |
System.out.println("IsJFCComposite.test() args = " + args);
|
|
| 26 |
System.out.println("IsJFCComposite.test() expectedValue = " + expectedValue);
|
|
| 27 |
|
|
| 28 | 28 |
// ChartEditor editor = SWTChartsComponentsProvider.getActiveChartEditor(null); |
| 29 | 29 |
// return (editor != null && editor.getComposite() instanceof JFCComposite); |
| 30 | 30 |
return true; |
| tmp/org.txm.chartsengine.jfreechart.rcp/plugin.xml (revision 844) | ||
|---|---|---|
| 27 | 27 |
commandId="org.txm.chartsengine.jfreechart.rcp.handlers.OpenJFCChartPropertiesEditor" |
| 28 | 28 |
icon="icons/silk_chart_edit.png" |
| 29 | 29 |
style="push"> |
| 30 |
<visibleWhen |
|
| 31 |
checkEnabled="false"> |
|
| 32 |
<test |
|
| 33 |
property="org.txm.chartsengine.enginetype" |
|
| 34 |
value="true"> |
|
| 35 |
</test> |
|
| 36 |
</visibleWhen> |
|
| 30 | 37 |
</command> |
| 31 | 38 |
</menuContribution> |
| 32 | 39 |
</extension> |
| ... | ... | |
| 61 | 68 |
name="JFC composite context"> |
| 62 | 69 |
</context> |
| 63 | 70 |
</extension> |
| 71 |
<extension |
|
| 72 |
point="org.eclipse.core.expressions.propertyTesters"> |
|
| 73 |
<propertyTester |
|
| 74 |
class="org.txm.chartsengine.jfreechart.rcp.testers.__IsJFCComposite" |
|
| 75 |
id="org.txm.chartsengine.jfreechart.rcp.testers.__IsJFCComposite" |
|
| 76 |
namespace="org.txm.chartsengine" |
|
| 77 |
properties="enginetype" |
|
| 78 |
type="java.lang.Object"> |
|
| 79 |
</propertyTester> |
|
| 80 |
</extension> |
|
| 64 | 81 |
|
| 65 | 82 |
</plugin> |
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationInjector.java (revision 844) | ||
|---|---|---|
| 140 | 140 |
|
| 141 | 141 |
boolean mustChangeAnaValue = false; |
| 142 | 142 |
boolean inAna = false; |
| 143 |
private boolean inForm; |
|
| 144 |
private boolean mustChangeWordValue; |
|
| 143 | 145 |
|
| 144 | 146 |
protected void processStartElement() throws XMLStreamException, IOException {
|
| 145 | 147 |
|
| ... | ... | |
| 197 | 199 |
} |
| 198 | 200 |
|
| 199 | 201 |
super.processStartElement(); // write the tag |
| 200 |
} else if ("ana".equals(localname)) {
|
|
| 202 |
|
|
| 203 |
} else if ("form".equals(localname) && inW) {
|
|
| 204 |
if (currentTokenAnnotations.containsKey("word")) {
|
|
| 205 |
Annotation a = currentTokenAnnotations.get("word");
|
|
| 206 |
//System.out.println("Updating token annotation with: " + a);
|
|
| 207 |
|
|
| 208 |
String value = a.getValue(); |
|
| 209 |
if ("#del".equals(value))
|
|
| 210 |
value = ""; |
|
| 211 |
if (value == null) |
|
| 212 |
value = "ERROR"; |
|
| 213 |
|
|
| 214 |
try {
|
|
| 215 |
writer.writeStartElement("form");
|
|
| 216 |
writer.writeCharacters(value); |
|
| 217 |
mustChangeWordValue = true; |
|
| 218 |
} catch (XMLStreamException e) {
|
|
| 219 |
// TODO Auto-generated catch block |
|
| 220 |
e.printStackTrace(); |
|
| 221 |
} |
|
| 222 |
|
|
| 223 |
currentTokenAnnotations.remove("word"); // annotation updated
|
|
| 224 |
} else {
|
|
| 225 |
super.processStartElement(); |
|
| 226 |
} |
|
| 227 |
} else if ("ana".equals(localname) && inW) {
|
|
| 201 | 228 |
inAna = true; |
| 202 | 229 |
String type = parser.getAttributeValue(null, "type").substring(1); |
| 203 | 230 |
if (currentTokenAnnotations.containsKey(type)) {
|
| ... | ... | |
| 323 | 350 |
if (inAna && mustChangeAnaValue) {
|
| 324 | 351 |
// nothing content is already written |
| 325 | 352 |
//System.out.println("skip ana value because we replace it");
|
| 353 |
} else if (inW && mustChangeWordValue) {
|
|
| 354 |
// nothing content is already written |
|
| 355 |
//System.out.println("skip form value because we replace it");
|
|
| 326 | 356 |
} else {
|
| 327 | 357 |
super.processCharacters(); |
| 328 | 358 |
} |
| ... | ... | |
| 384 | 414 |
} |
| 385 | 415 |
|
| 386 | 416 |
position_counter++; |
| 387 |
} else if ("ana".equals(localname)) {
|
|
| 417 |
} else if ("form".equals(localname) && inW) {
|
|
| 388 | 418 |
//if (!mustChangeAnaValue) |
| 389 | 419 |
super.processEndElement(); |
| 420 |
mustChangeWordValue = false; |
|
| 421 |
inForm = false; |
|
| 422 |
} else if ("ana".equals(localname) && inW) {
|
|
| 423 |
//if (!mustChangeAnaValue) |
|
| 424 |
super.processEndElement(); |
|
| 390 | 425 |
inAna = false; |
| 391 | 426 |
mustChangeAnaValue = false; |
| 392 | 427 |
} else if (previousEndAnnotations != null) { // force delete annotations
|
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/repository/KnowledgeRepositoryManager.java (revision 844) | ||
|---|---|---|
| 211 | 211 |
return kr; |
| 212 | 212 |
} |
| 213 | 213 |
|
| 214 |
public static void registerKnowledgeRepository(KnowledgeRepository kr) {
|
|
| 215 |
repositories.put(kr.getName(), kr); |
|
| 216 |
} |
|
| 217 |
|
|
| 214 | 218 |
public static boolean[] mustLoginToKnowledgeRepository(String kr_name, |
| 215 | 219 |
MainCorpus corpus) {
|
| 216 | 220 |
|
| tmp/org.txm.annotation.rcp/plugin.xml (revision 844) | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 |
<?eclipse version="3.4"?> |
| 3 | 3 |
<plugin> |
| 4 |
<extension-point id="org.txm.annotation.rcp.editor.AnnotationArea" name="org.txm.annotation.rcp.editor.AnnotationArea" schema="schema/org.txm.annotation.rcp.editor.AnnotationArea.exsd"/> |
|
| 4 | 5 |
<extension |
| 5 | 6 |
point="org.eclipse.ui.commands"> |
| 6 | 7 |
<command |
| ... | ... | |
| 320 | 321 |
name="Annotation"> |
| 321 | 322 |
</concextension> |
| 322 | 323 |
</extension> |
| 324 |
<extension |
|
| 325 |
point="org.txm.annotation.rcp.editor.AnnotationArea"> |
|
| 326 |
<annotationtoolbar |
|
| 327 |
class="org.txm.annotation.rcp.concordance.KRAnnotation" |
|
| 328 |
position="3"> |
|
| 329 |
</annotationtoolbar> |
|
| 330 |
<annotationtoolbar |
|
| 331 |
class="org.txm.annotation.rcp.concordance.WordAnnotationToolbar" |
|
| 332 |
position="1"> |
|
| 333 |
</annotationtoolbar> |
|
| 334 |
<annotationtoolbar |
|
| 335 |
class="org.txm.annotation.rcp.concordance.SimpleKRAnnotation" |
|
| 336 |
position="2"> |
|
| 337 |
</annotationtoolbar> |
|
| 338 |
</extension> |
|
| 323 | 339 |
</plugin> |
| tmp/org.txm.annotation.rcp/schema/org.txm.annotation.rcp.editor.AnnotationArea.exsd (revision 844) | ||
|---|---|---|
| 1 |
<?xml version='1.0' encoding='UTF-8'?> |
|
| 2 |
<!-- Schema file written by PDE --> |
|
| 3 |
<schema targetNamespace="org.txm.annotation.rcp" xmlns="http://www.w3.org/2001/XMLSchema"> |
|
| 4 |
<annotation> |
|
| 5 |
<appinfo> |
|
| 6 |
<meta.schema plugin="org.txm.annotation.rcp" id="org.txm.annotation.rcp.editor.AnnotationArea" name="org.txm.annotation.rcp.editor.AnnotationArea"/> |
|
| 7 |
</appinfo> |
|
| 8 |
<documentation> |
|
| 9 |
An annotation toolbar opened by the Annotation start button |
|
| 10 |
</documentation> |
|
| 11 |
</annotation> |
|
| 12 |
|
|
| 13 |
<element name="extension"> |
|
| 14 |
<annotation> |
|
| 15 |
<appinfo> |
|
| 16 |
<meta.element /> |
|
| 17 |
</appinfo> |
|
| 18 |
</annotation> |
|
| 19 |
<complexType> |
|
| 20 |
<choice minOccurs="1" maxOccurs="unbounded"> |
|
| 21 |
<element ref="annotationtoolbar"/> |
|
| 22 |
</choice> |
|
| 23 |
<attribute name="point" type="string" use="required"> |
|
| 24 |
<annotation> |
|
| 25 |
<documentation> |
|
| 26 |
|
|
| 27 |
</documentation> |
|
| 28 |
</annotation> |
|
| 29 |
</attribute> |
|
| 30 |
<attribute name="id" type="string"> |
|
| 31 |
<annotation> |
|
| 32 |
<documentation> |
|
| 33 |
|
|
| 34 |
</documentation> |
|
| 35 |
</annotation> |
|
| 36 |
</attribute> |
|
| 37 |
<attribute name="name" type="string"> |
|
| 38 |
<annotation> |
|
| 39 |
<documentation> |
|
| 40 |
|
|
| 41 |
</documentation> |
|
| 42 |
<appinfo> |
|
| 43 |
<meta.attribute translatable="true"/> |
|
| 44 |
</appinfo> |
|
| 45 |
</annotation> |
|
| 46 |
</attribute> |
|
| 47 |
</complexType> |
|
| 48 |
</element> |
|
| 49 |
|
|
| 50 |
<element name="annotationtoolbar"> |
|
| 51 |
<complexType> |
|
| 52 |
<attribute name="class" type="string" use="required"> |
|
| 53 |
<annotation> |
|
| 54 |
<documentation> |
|
| 55 |
|
|
| 56 |
</documentation> |
|
| 57 |
<appinfo> |
|
| 58 |
<meta.attribute kind="java" basedOn="org.txm.annotation.rcp.editor.AnnotationArea:"/> |
|
| 59 |
</appinfo> |
|
| 60 |
</annotation> |
|
| 61 |
</attribute> |
|
| 62 |
<attribute name="position" type="string" use="required"> |
|
| 63 |
<annotation> |
|
| 64 |
<documentation> |
|
| 65 |
|
|
| 66 |
</documentation> |
|
| 67 |
<appinfo> |
|
| 68 |
<meta.attribute kind="java" basedOn="java.lang.Integer:"/> |
|
| 69 |
</appinfo> |
|
| 70 |
</annotation> |
|
| 71 |
</attribute> |
|
| 72 |
</complexType> |
|
| 73 |
</element> |
|
| 74 |
|
|
| 75 |
<annotation> |
|
| 76 |
<appinfo> |
|
| 77 |
<meta.section type="since"/> |
|
| 78 |
</appinfo> |
|
| 79 |
<documentation> |
|
| 80 |
[Enter the first release in which this extension point appears.] |
|
| 81 |
</documentation> |
|
| 82 |
</annotation> |
|
| 83 |
|
|
| 84 |
<annotation> |
|
| 85 |
<appinfo> |
|
| 86 |
<meta.section type="examples"/> |
|
| 87 |
</appinfo> |
|
| 88 |
<documentation> |
|
| 89 |
[Enter extension point usage example here.] |
|
| 90 |
</documentation> |
|
| 91 |
</annotation> |
|
| 92 |
|
|
| 93 |
<annotation> |
|
| 94 |
<appinfo> |
|
| 95 |
<meta.section type="apiinfo"/> |
|
| 96 |
</appinfo> |
|
| 97 |
<documentation> |
|
| 98 |
[Enter API information here.] |
|
| 99 |
</documentation> |
|
| 100 |
</annotation> |
|
| 101 |
|
|
| 102 |
<annotation> |
|
| 103 |
<appinfo> |
|
| 104 |
<meta.section type="implementation"/> |
|
| 105 |
</appinfo> |
|
| 106 |
<documentation> |
|
| 107 |
[Enter information about supplied implementation of this extension point.] |
|
| 108 |
</documentation> |
|
| 109 |
</annotation> |
|
| 110 |
|
|
| 111 |
|
|
| 112 |
</schema> |
|
| 0 | 113 | |
| tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationArea.java (revision 844) | ||
|---|---|---|
| 1 | 1 |
package org.txm.annotation.rcp.editor; |
| 2 | 2 |
|
| 3 |
import java.util.List; |
|
| 4 |
import java.util.Locale; |
|
| 5 |
|
|
| 3 | 6 |
import org.eclipse.swt.widgets.Composite; |
| 7 |
import org.txm.annotation.core.repository.AnnotationType; |
|
| 8 |
import org.txm.concordance.core.functions.Line; |
|
| 4 | 9 |
import org.txm.core.results.TXMResult; |
| 5 | 10 |
import org.txm.rcp.editors.TXMEditor; |
| 6 | 11 |
import org.txm.rcp.swt.GLComposite; |
| 12 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 7 | 13 |
|
| 8 | 14 |
/** |
| 9 | 15 |
* A widget to show in a to annotate a Result within a TXMEditor |
| ... | ... | |
| 11 | 17 |
* @author mdecorde |
| 12 | 18 |
* |
| 13 | 19 |
*/ |
| 14 |
public abstract class AnnotationArea extends GLComposite {
|
|
| 20 |
public abstract class AnnotationArea<T extends TXMResult> {
|
|
| 15 | 21 |
|
| 16 |
protected TXMEditor<? extends TXMResult> editor; |
|
| 22 |
protected TXMEditor<T> editor; |
|
| 23 |
protected GLComposite annotationArea; |
|
| 17 | 24 |
|
| 18 |
public AnnotationArea(TXMEditor<? extends TXMResult> editor, String name, Composite parent, int style) {
|
|
| 19 |
super(parent, style, name); |
|
| 20 |
|
|
| 21 |
this.editor = editor; |
|
| 25 |
public AnnotationArea() {
|
|
| 22 | 26 |
} |
| 23 | 27 |
|
| 24 | 28 |
/** |
| 25 |
* use this if you need something to be done when the extension is discovered |
|
| 26 |
* |
|
| 29 |
* TODO not done, should ask the |
|
| 27 | 30 |
* @return |
| 28 | 31 |
*/ |
| 29 |
public abstract boolean install(); |
|
| 32 |
public String getLocale() {
|
|
| 33 |
return Locale.getDefault().getCountry(); |
|
| 34 |
} |
|
| 30 | 35 |
|
| 31 | 36 |
/** |
| 32 |
* use this to build your extension widgets |
|
| 37 |
* use this if you need something to be done when the extension is discovered |
|
| 38 |
* |
|
| 33 | 39 |
* @return |
| 40 |
* @throws Exception |
|
| 34 | 41 |
*/ |
| 35 |
public abstract boolean open();
|
|
| 42 |
public abstract boolean install(TXMEditor<? extends TXMResult> editor, Corpus corpus, Composite parent) throws Exception;
|
|
| 36 | 43 |
|
| 37 | 44 |
/** |
| 38 | 45 |
* use this to dispose your extension widgets (and save eventually) |
| 39 | 46 |
* |
| 40 | 47 |
* @return |
| 41 | 48 |
*/ |
| 42 |
public abstract boolean close(); |
|
| 49 |
public boolean close() {
|
|
| 50 |
if (annotationArea != null && !annotationArea.isDisposed()) {
|
|
| 51 |
annotationArea.dispose(); |
|
| 52 |
} |
|
| 53 |
_close(); |
|
| 54 |
|
|
| 55 |
return true; |
|
| 56 |
} |
|
| 43 | 57 |
|
| 58 |
protected abstract void _close(); |
|
| 59 |
|
|
| 44 | 60 |
/** |
| 45 | 61 |
* use this to save the annotations |
| 46 | 62 |
* |
| ... | ... | |
| 48 | 64 |
*/ |
| 49 | 65 |
public abstract boolean save(); |
| 50 | 66 |
|
| 51 |
public String getAnnotationName() {
|
|
| 52 |
return getName(); |
|
| 67 |
public abstract String getName(); |
|
| 68 |
|
|
| 69 |
public GLComposite getAnnotationArea() {
|
|
| 70 |
return annotationArea; |
|
| 53 | 71 |
} |
| 54 | 72 |
|
| 55 | 73 |
public TXMEditor<? extends TXMResult> getEditor() {
|
| 56 | 74 |
return editor; |
| 57 | 75 |
} |
| 76 |
|
|
| 77 |
/** |
|
| 78 |
* Called BEFORE the TXMResult is computed |
|
| 79 |
* |
|
| 80 |
* @return |
|
| 81 |
* @throws Exception |
|
| 82 |
*/ |
|
| 83 |
public abstract boolean notifyStartOfCompute() throws Exception; |
|
| 84 |
|
|
| 85 |
/** |
|
| 86 |
* Called AFTER the TXMResult is computed |
|
| 87 |
* @return |
|
| 88 |
* @throws Exception |
|
| 89 |
*/ |
|
| 90 |
public abstract boolean notifyEndOfCompute() throws Exception; |
|
| 91 |
|
|
| 92 |
|
|
| 93 |
public boolean isAnnotationEnable() {
|
|
| 94 |
return annotationArea != null; |
|
| 95 |
} |
|
| 96 |
|
|
| 97 |
/** |
|
| 98 |
* Called after the editor has been refreshed (after the result has been computed) |
|
| 99 |
* |
|
| 100 |
* @param lines |
|
| 101 |
* @param from |
|
| 102 |
* @param to |
|
| 103 |
* @throws Exception |
|
| 104 |
*/ |
|
| 105 |
public abstract void update(List<Line> lines, int from, int to) throws Exception; |
|
| 58 | 106 |
} |
| tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/SimpleKRAnnotation.java (revision 844) | ||
|---|---|---|
| 1 |
package org.txm.annotation.rcp.concordance; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.HashMap; |
|
| 5 |
import java.util.List; |
|
| 6 |
import java.util.Vector; |
|
| 7 |
import java.util.logging.Level; |
|
| 8 |
|
|
| 9 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 10 |
import org.eclipse.core.runtime.IStatus; |
|
| 11 |
import org.eclipse.core.runtime.Status; |
|
| 12 |
import org.eclipse.jface.dialogs.InputDialog; |
|
| 13 |
import org.eclipse.jface.dialogs.MessageDialog; |
|
| 14 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 15 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
|
| 16 |
import org.eclipse.jface.viewers.ComboViewer; |
|
| 17 |
import org.eclipse.jface.viewers.ISelection; |
|
| 18 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 19 |
import org.eclipse.jface.viewers.TableViewer; |
|
| 20 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
| 21 |
import org.eclipse.swt.SWT; |
|
| 22 |
import org.eclipse.swt.events.KeyEvent; |
|
| 23 |
import org.eclipse.swt.events.KeyListener; |
|
| 24 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 25 |
import org.eclipse.swt.events.SelectionListener; |
|
| 26 |
import org.eclipse.swt.graphics.Point; |
|
| 27 |
import org.eclipse.swt.layout.GridData; |
|
| 28 |
import org.eclipse.swt.widgets.Button; |
|
| 29 |
import org.eclipse.swt.widgets.Combo; |
|
| 30 |
import org.eclipse.swt.widgets.Composite; |
|
| 31 |
import org.eclipse.swt.widgets.Display; |
|
| 32 |
import org.eclipse.swt.widgets.Group; |
|
| 33 |
import org.eclipse.swt.widgets.Label; |
|
| 34 |
import org.eclipse.swt.widgets.TableColumn; |
|
| 35 |
import org.eclipse.swt.widgets.Text; |
|
| 36 |
import org.eclipse.ui.dialogs.ListDialog; |
|
| 37 |
import org.txm.annotation.core.Annotation; |
|
| 38 |
import org.txm.annotation.core.AnnotationManager; |
|
| 39 |
import org.txm.annotation.core.KRAnnotationEngine; |
|
| 40 |
import org.txm.annotation.core.repository.AnnotationType; |
|
| 41 |
import org.txm.annotation.core.repository.KnowledgeRepository; |
|
| 42 |
import org.txm.annotation.core.repository.KnowledgeRepositoryManager; |
|
| 43 |
import org.txm.annotation.core.repository.LocalKnowledgeRepository; |
|
| 44 |
import org.txm.annotation.core.repository.TypedValue; |
|
| 45 |
import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository; |
|
| 46 |
import org.txm.annotation.rcp.commands.SaveAnnotations; |
|
| 47 |
import org.txm.annotation.rcp.editor.AnnotationArea; |
|
| 48 |
import org.txm.annotation.rcp.views.knowledgerepositories.KRView; |
|
| 49 |
import org.txm.concordance.core.functions.Concordance; |
|
| 50 |
import org.txm.concordance.core.functions.Line; |
|
| 51 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
|
| 52 |
import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener; |
|
| 53 |
import org.txm.concordance.rcp.messages.ConcordanceUIMessages; |
|
| 54 |
import org.txm.core.results.TXMResult; |
|
| 55 |
import org.txm.rcp.IImageKeys; |
|
| 56 |
import org.txm.rcp.editors.TXMEditor; |
|
| 57 |
import org.txm.rcp.swt.GLComposite; |
|
| 58 |
import org.txm.rcp.swt.dialog.ConfirmDialog; |
|
| 59 |
import org.txm.rcp.swt.provider.SimpleLabelProvider; |
|
| 60 |
import org.txm.rcp.utils.JobHandler; |
|
| 61 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 62 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
| 63 |
import org.txm.searchengine.cqp.corpus.Corpus; |
|
| 64 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 65 |
import org.txm.utils.logger.Log; |
|
| 66 |
|
|
| 67 |
public class SimpleKRAnnotation extends AnnotationArea<Concordance> {
|
|
| 68 |
|
|
| 69 |
ConcordanceEditor editor; |
|
| 70 |
|
|
| 71 |
public SimpleKRAnnotation() {
|
|
| 72 |
|
|
| 73 |
} |
|
| 74 |
|
|
| 75 |
/** |
|
| 76 |
* the limit number of annotation when a confirm dialog box is shown |
|
| 77 |
*/ |
|
| 78 |
protected static final int NALERTAFFECTANNOTATIONS = 100; |
|
| 79 |
public static final String EMPTYTEXT = ""; |
|
| 80 |
|
|
| 81 |
/** The annotation service */ |
|
| 82 |
protected AnnotationManager annotManager; |
|
| 83 |
|
|
| 84 |
//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false); |
|
| 85 |
|
|
| 86 |
protected Point annotationSize; |
|
| 87 |
|
|
| 88 |
protected Text annotationValuesText; |
|
| 89 |
protected ComboViewer annotationTypesCombo; |
|
| 90 |
|
|
| 91 |
protected TableColumn annotationColumn; |
|
| 92 |
|
|
| 93 |
protected Combo addRemoveCombo; |
|
| 94 |
protected Combo affectCombo; |
|
| 95 |
protected Button affectAnnotationButton; |
|
| 96 |
|
|
| 97 |
protected KnowledgeRepository currentKnowledgeRepository = null; |
|
| 98 |
protected Vector<AnnotationType> typesList = new Vector<AnnotationType>(); |
|
| 99 |
|
|
| 100 |
protected Label withLabel; |
|
| 101 |
|
|
| 102 |
protected AnnotationType tagAnnotationType; // the tag annotation type if annotation mode is simple |
|
| 103 |
|
|
| 104 |
protected TypedValue value_to_add; |
|
| 105 |
|
|
| 106 |
protected Concordance concordance; |
|
| 107 |
|
|
| 108 |
private Corpus corpus; |
|
| 109 |
|
|
| 110 |
private ConcordanceAnnotations annotations = null; |
|
| 111 |
private Button addTypedValueLink; |
|
| 112 |
|
|
| 113 |
|
|
| 114 |
@Override |
|
| 115 |
public String getName() {
|
|
| 116 |
return "Tag Annotation"; |
|
| 117 |
} |
|
| 118 |
|
|
| 119 |
public boolean install(TXMEditor ceditor, final Corpus corpus, Composite parent) throws Exception{
|
|
| 120 |
this.editor = (ConcordanceEditor)ceditor; |
|
| 121 |
this.corpus = corpus; |
|
| 122 |
this.concordance = editor.getConcordance(); |
|
| 123 |
this.annotations = new ConcordanceAnnotations(editor.getConcordance()); |
|
| 124 |
this.annotManager = KRAnnotationEngine.getAnnotationManager(corpus); |
|
| 125 |
|
|
| 126 |
TableViewer viewer = editor.getLineTableViewer(); |
|
| 127 |
|
|
| 128 |
// RESULT |
|
| 129 |
|
|
| 130 |
int position = 3; // after keyword column |
|
| 131 |
TableViewerColumn annotationColumnViewer = new TableViewerColumn(viewer, SWT.CENTER, position); |
|
| 132 |
annotationColumn = annotationColumnViewer.getColumn(); |
|
| 133 |
annotationColumn.setText(ConcordanceUIMessages.ConcordancesEditor_15); |
|
| 134 |
annotationColumn.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_17); |
|
| 135 |
annotationColumn.pack(); |
|
| 136 |
annotationColumn.setAlignment(SWT.CENTER); |
|
| 137 |
|
|
| 138 |
annotationColumn.addControlListener(new ConcordanceColumnSizeControlListener(annotationColumn)); |
|
| 139 |
annotationColumnViewer.setLabelProvider(new ColumnLabelProvider() {
|
|
| 140 |
|
|
| 141 |
@Override |
|
| 142 |
public String getText(Object element) {
|
|
| 143 |
Line line = (Line)element; |
|
| 144 |
AnnotationLine annotationLine = annotations.getAnnotationLine(line); |
|
| 145 |
if (annotationLine == null) return EMPTYTEXT ; |
|
| 146 |
if (annotationLine.getAnnotation()!=null) {
|
|
| 147 |
String value = annotationLine.getAnnotationValue().getStandardName(); |
|
| 148 |
Annotation a = annotationLine.getAnnotation(); |
|
| 149 |
if (value == null) value = a.getValue(); |
|
| 150 |
|
|
| 151 |
if (a.getStart() < line.matchGetStart() - line.getLeftContextSize()) {
|
|
| 152 |
value = "… "+value; |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
if (a.getEnd() > line.matchGetEnd() + line.getRightContextSize()) {
|
|
| 156 |
value = value+" …"; |
|
| 157 |
} |
|
| 158 |
return value; |
|
| 159 |
} else {
|
|
| 160 |
return EMPTYTEXT; |
|
| 161 |
} |
|
| 162 |
} |
|
| 163 |
}); |
|
| 164 |
|
|
| 165 |
List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus()); |
|
| 166 |
typesList.clear(); |
|
| 167 |
Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
|
|
| 168 |
|
|
| 169 |
KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(corpus.getMainCorpus().getName()); |
|
| 170 |
if (kr == null) {
|
|
| 171 |
HashMap<String, HashMap<String, ?>> conf = new HashMap<String, HashMap<String, ?>>(); |
|
| 172 |
kr = KnowledgeRepositoryManager.createKnowledgeRepository(corpus.getMainCorpus().getName(), conf); |
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
currentKnowledgeRepository = kr; |
|
| 176 |
Log.warning(" KR: "+kr); //$NON-NLS-1$
|
|
| 177 |
List<AnnotationType> krtypes = kr.getAllAnnotationTypes(); |
|
| 178 |
|
|
| 179 |
boolean createTagAnnotationType = true; |
|
| 180 |
for (AnnotationType type : krtypes) {
|
|
| 181 |
if (type.getName().equals("span")) { //$NON-NLS-1$
|
|
| 182 |
createTagAnnotationType = false; |
|
| 183 |
} |
|
| 184 |
} |
|
| 185 |
if (createTagAnnotationType) {
|
|
| 186 |
tagAnnotationType = kr.addType("span", "span");//corresponds to an "undef" type //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 187 |
typesList.add(tagAnnotationType); |
|
| 188 |
} else {
|
|
| 189 |
tagAnnotationType = kr.getType("span"); //$NON-NLS-1$
|
|
| 190 |
} |
|
| 191 |
annotations.setViewAnnotation(tagAnnotationType); |
|
| 192 |
|
|
| 193 |
Log.warning("Available annotation types: "+typesList);
|
|
| 194 |
|
|
| 195 |
annotationArea = new GLComposite(parent, SWT.NONE, "Concordance Annotation area"); |
|
| 196 |
annotationArea.getLayout().numColumns = 12; |
|
| 197 |
annotationArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
|
| 198 |
|
|
| 199 |
addRemoveCombo = new Combo(annotationArea, SWT.READ_ONLY); |
|
| 200 |
String affectLabel = currentKnowledgeRepository.getString(getLocale(), "ConcordancesEditor_22"); |
|
| 201 |
if (affectLabel == null) affectLabel= ConcordanceUIMessages.ConcordancesEditor_22; |
|
| 202 |
String removeLabel = currentKnowledgeRepository.getString(getLocale(), "ConcordancesEditor_24"); |
|
| 203 |
if (removeLabel == null) removeLabel= ConcordanceUIMessages.ConcordancesEditor_24; |
|
| 204 |
String items[] = {affectLabel, removeLabel};
|
|
| 205 |
addRemoveCombo.setItems(items); |
|
| 206 |
addRemoveCombo.select(0); |
|
| 207 |
addRemoveCombo.addSelectionListener(new SelectionListener() {
|
|
| 208 |
@Override |
|
| 209 |
public void widgetSelected(SelectionEvent e) {
|
|
| 210 |
if (addRemoveCombo.getSelectionIndex() == 0) { // add
|
|
| 211 |
annotationValuesText.setEnabled(true); |
|
| 212 |
String withLabelText = currentKnowledgeRepository.getString(getLocale(), "ConcordancesEditor_83"); |
|
| 213 |
if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83; |
|
| 214 |
withLabel.setText(withLabelText); |
|
| 215 |
} else { // remove
|
|
| 216 |
annotationValuesText.setEnabled(false); |
|
| 217 |
withLabel.setText(""); //$NON-NLS-1$
|
|
| 218 |
} |
|
| 219 |
withLabel.redraw(); |
|
| 220 |
annotationArea.layout(); |
|
| 221 |
updateAnnotationWidgetStates(); |
|
| 222 |
} |
|
| 223 |
@Override |
|
| 224 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 225 |
}); |
|
| 226 |
GridData gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false); |
|
| 227 |
gdata.widthHint = 90; |
|
| 228 |
addRemoveCombo.setLayoutData(gdata); |
|
| 229 |
|
|
| 230 |
withLabel = new Label(annotationArea, SWT.NONE); |
|
| 231 |
String withLabelText = currentKnowledgeRepository.getString(getLocale(), "ConcordancesEditor_83"); |
|
| 232 |
if (withLabelText == null) withLabelText= ConcordanceUIMessages.ConcordancesEditor_83; |
|
| 233 |
withLabel.setText(withLabelText); |
|
| 234 |
withLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
| 235 |
|
|
| 236 |
annotationValuesText = new Text(annotationArea, SWT.BORDER); |
|
| 237 |
annotationValuesText.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_32); |
|
| 238 |
GridData gdata2 = new GridData(SWT.FILL, SWT.CENTER, false, false); |
|
| 239 |
gdata2.widthHint = 200; |
|
| 240 |
annotationValuesText.setLayoutData(gdata2); |
|
| 241 |
annotationValuesText.addKeyListener(new KeyListener() {
|
|
| 242 |
@Override |
|
| 243 |
public void keyReleased(KeyEvent e) {
|
|
| 244 |
if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
|
|
| 245 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection()); |
|
| 246 |
} |
|
| 247 |
} |
|
| 248 |
|
|
| 249 |
@Override |
|
| 250 |
public void keyPressed(KeyEvent e) { }
|
|
| 251 |
}); |
|
| 252 |
|
|
| 253 |
if (currentKnowledgeRepository instanceof LocalKnowledgeRepository) {
|
|
| 254 |
addTypedValueLink = new Button(annotationArea, SWT.PUSH); |
|
| 255 |
addTypedValueLink.setText("..."); //$NON-NLS-1$
|
|
| 256 |
addTypedValueLink.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_77); |
|
| 257 |
addTypedValueLink.setEnabled(true); |
|
| 258 |
addTypedValueLink.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
| 259 |
addTypedValueLink.addSelectionListener(new SelectionListener() {
|
|
| 260 |
@Override |
|
| 261 |
public void widgetSelected(SelectionEvent e) {
|
|
| 262 |
if (currentKnowledgeRepository == null) return; |
|
| 263 |
if (!(currentKnowledgeRepository instanceof LocalKnowledgeRepository)) return; |
|
| 264 |
|
|
| 265 |
AnnotationType type = getSelectedAnnotationType(); |
|
| 266 |
if (type == null) return; |
|
| 267 |
|
|
| 268 |
LocalKnowledgeRepository kr = (LocalKnowledgeRepository)currentKnowledgeRepository; |
|
| 269 |
|
|
| 270 |
ListDialog dialog = new ListDialog(e.widget.getDisplay().getActiveShell()); |
|
| 271 |
dialog.setTitle(ConcordanceUIMessages.ConcordancesEditor_99);//+"valeurs de "+type.getName()); |
|
| 272 |
dialog.setContentProvider(new ArrayContentProvider()); |
|
| 273 |
dialog.setLabelProvider(new SimpleLabelProvider() {
|
|
| 274 |
public String getColumnText(Object element, int columnIndex) {
|
|
| 275 |
if (element instanceof TypedValue) |
|
| 276 |
return ((TypedValue)element).getId(); |
|
| 277 |
return element.toString(); |
|
| 278 |
} |
|
| 279 |
}); |
|
| 280 |
List<TypedValue> values; |
|
| 281 |
try {
|
|
| 282 |
values = kr.getValues(type); |
|
| 283 |
} catch (Exception e1) {
|
|
| 284 |
e1.printStackTrace(); |
|
| 285 |
return; |
|
| 286 |
} |
|
| 287 |
dialog.setInput(values); |
|
| 288 |
if (dialog.open() == InputDialog.OK) {
|
|
| 289 |
TypedValue value = (TypedValue) dialog.getResult()[0]; |
|
| 290 |
String name = value.getId(); |
|
| 291 |
if (name.trim().length() == 0) return; |
|
| 292 |
|
|
| 293 |
annotationValuesText.setText(name); |
|
| 294 |
} else {
|
|
| 295 |
|
|
| 296 |
} |
|
| 297 |
} |
|
| 298 |
|
|
| 299 |
@Override |
|
| 300 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 301 |
}); |
|
| 302 |
} |
|
| 303 |
|
|
| 304 |
affectCombo = new Combo(annotationArea, SWT.READ_ONLY); |
|
| 305 |
affectCombo.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
| 306 |
String items2[] = {ConcordanceUIMessages.ConcordancesEditor_35, ConcordanceUIMessages.ConcordancesEditor_49};
|
|
| 307 |
affectCombo.setItems(items2); |
|
| 308 |
affectCombo.select(0); |
|
| 309 |
gdata = new GridData(SWT.CENTER, SWT.CENTER, false, false); |
|
| 310 |
gdata.widthHint = 140; |
|
| 311 |
affectCombo.setLayoutData(gdata); |
|
| 312 |
|
|
| 313 |
affectAnnotationButton = new Button(annotationArea, SWT.PUSH); |
|
| 314 |
affectAnnotationButton.setText(ConcordanceUIMessages.ConcordancesEditor_85); |
|
| 315 |
affectAnnotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_116); |
|
| 316 |
affectAnnotationButton.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false)); |
|
| 317 |
affectAnnotationButton.addSelectionListener(new SelectionListener() {
|
|
| 318 |
@Override |
|
| 319 |
public void widgetSelected(SelectionEvent e) {
|
|
| 320 |
int isel = affectCombo.getSelectionIndex(); |
|
| 321 |
if (isel == 0) { // selected line
|
|
| 322 |
affectAnnotationToSelection(editor.getLineTableViewer().getSelection()); |
|
| 323 |
} else { // all
|
|
| 324 |
try {
|
|
| 325 |
List<Match> matches = concordance.getMatches(); |
|
| 326 |
affectMatchesToSelection(matches); |
|
| 327 |
} catch (CqiClientException e1) {
|
|
| 328 |
Log.severe(ConcordanceUIMessages.ConcordancesEditor_53+e1); |
|
| 329 |
Log.printStackTrace(e1); |
|
| 330 |
return; |
|
| 331 |
} |
|
| 332 |
} |
|
| 333 |
} |
|
| 334 |
|
|
| 335 |
@Override |
|
| 336 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 337 |
}); |
|
| 338 |
Button saveAnnotationsButton = new Button(annotationArea, SWT.PUSH); |
|
| 339 |
saveAnnotationsButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_76); |
|
| 340 |
saveAnnotationsButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE)); |
|
| 341 |
|
|
| 342 |
saveAnnotationsButton.addSelectionListener(new SelectionListener() {
|
|
| 343 |
@Override |
|
| 344 |
public void widgetSelected(SelectionEvent e) {
|
|
| 345 |
save(); |
|
| 346 |
} |
|
| 347 |
|
|
| 348 |
@Override |
|
| 349 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 350 |
}); |
|
| 351 |
|
|
| 352 |
updateAnnotationWidgetStates(); |
|
| 353 |
editor.layout(true); |
|
| 354 |
|
|
| 355 |
return true; |
|
| 356 |
} |
|
| 357 |
|
|
| 358 |
protected void affectAnnotationToSelection(ISelection selection) {
|
|
| 359 |
|
|
| 360 |
final IStructuredSelection lineSelection = (IStructuredSelection) selection; |
|
| 361 |
List<Line> lines = lineSelection.toList(); |
|
| 362 |
ArrayList<Match> matches = new ArrayList<Match>(); |
|
| 363 |
for (Line l : lines) {
|
|
| 364 |
matches.add(l.getMatch()); |
|
| 365 |
} |
|
| 366 |
|
|
| 367 |
affectMatchesToSelection(matches); |
|
| 368 |
} |
|
| 369 |
|
|
| 370 |
protected AnnotationType getSelectedAnnotationType() {
|
|
| 371 |
if (annotationTypesCombo != null) {
|
|
| 372 |
IStructuredSelection isel = (IStructuredSelection)annotationTypesCombo.getSelection(); |
|
| 373 |
if (isel.isEmpty()) {
|
|
| 374 |
return null; |
|
| 375 |
} |
|
| 376 |
return (AnnotationType) isel.getFirstElement(); |
|
| 377 |
} else { // simple mode
|
|
| 378 |
return tagAnnotationType; |
|
| 379 |
} |
|
| 380 |
} |
|
| 381 |
|
|
| 382 |
protected void affectMatchesToSelection(final List<Match> matches) {
|
|
| 383 |
final AnnotationType type = getSelectedAnnotationType(); |
|
| 384 |
final String svalue = annotationValuesText.getText(); |
|
| 385 |
final boolean doAffect = addRemoveCombo.getSelectionIndex() == 0; // add is default |
|
| 386 |
|
|
| 387 |
JobHandler job = new JobHandler(ConcordanceUIMessages.ConcordancesEditor_36, true) {
|
|
| 388 |
@Override |
|
| 389 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 390 |
this.runInit(monitor); |
|
| 391 |
try {
|
|
| 392 |
if (doAffect) {
|
|
| 393 |
affectAnnotationValues(matches, type, svalue, this); |
|
| 394 |
} else {
|
|
| 395 |
deleteAnnotationValues(matches, type, this); |
|
| 396 |
} |
|
| 397 |
} catch(Exception e) {
|
|
| 398 |
Log.severe(ConcordanceUIMessages.ConcordancesEditor_40+e); |
|
| 399 |
Log.printStackTrace(e); |
|
| 400 |
return Status.CANCEL_STATUS; |
|
| 401 |
} catch(ThreadDeath td) {
|
|
| 402 |
System.out.println("Annotation canceled by user.");
|
|
| 403 |
return Status.CANCEL_STATUS; |
|
| 404 |
} |
|
| 405 |
|
|
| 406 |
return Status.OK_STATUS; |
|
| 407 |
} |
|
| 408 |
}; |
|
| 409 |
job.startJob(true); |
|
| 410 |
} |
|
| 411 |
|
|
| 412 |
public void updateAnnotationWidgetStates() {
|
|
| 413 |
if (annotationArea == null) return; // :) |
|
| 414 |
|
|
| 415 |
if (addRemoveCombo.getSelectionIndex() == 0) { // add is default
|
|
| 416 |
|
|
| 417 |
if (getSelectedAnnotationType() != null) {
|
|
| 418 |
annotationValuesText.setEnabled(true); |
|
| 419 |
|
|
| 420 |
affectAnnotationButton.setEnabled(true); |
|
| 421 |
affectCombo.setEnabled(true); |
|
| 422 |
} else {
|
|
| 423 |
annotationValuesText.setEnabled(false); |
|
| 424 |
|
|
| 425 |
affectAnnotationButton.setEnabled(false); |
|
| 426 |
affectCombo.setEnabled(false); |
|
| 427 |
} |
|
| 428 |
} else {
|
|
| 429 |
annotationValuesText.setEnabled(false); |
|
| 430 |
|
|
| 431 |
if (getSelectedAnnotationType() != null) {
|
|
| 432 |
affectAnnotationButton.setEnabled(true); |
|
| 433 |
affectCombo.setEnabled(true); |
|
| 434 |
} else {
|
|
| 435 |
affectAnnotationButton.setEnabled(false); |
|
| 436 |
affectCombo.setEnabled(false); |
|
| 437 |
} |
|
| 438 |
} |
|
| 439 |
|
|
| 440 |
|
|
| 441 |
if (addTypedValueLink != null) {
|
|
| 442 |
addTypedValueLink.setEnabled(getSelectedAnnotationType() != null); |
|
| 443 |
} |
|
| 444 |
} |
|
| 445 |
|
|
| 446 |
protected void deleteAnnotationValues(List<Match> matches, AnnotationType type, JobHandler job) {
|
|
| 447 |
|
|
| 448 |
if (matches.size() == 0) {
|
|
| 449 |
System.out.println("No lines selected. Aborting."); //$NON-NLS-1$
|
|
| 450 |
return; |
|
| 451 |
} |
|
| 452 |
|
|
| 453 |
if (type == null) {
|
|
| 454 |
return; |
|
| 455 |
} |
|
| 456 |
|
|
| 457 |
try {
|
|
| 458 |
if (annotManager != null && annotManager.deleteAnnotations(type, matches, job)) {
|
|
| 459 |
if (Log.getLevel().intValue() < Level.WARNING.intValue()) annotManager.checkData(); |
|
| 460 |
editor.refresh(false); |
|
| 461 |
} else {
|
|
| 462 |
return; |
|
| 463 |
} |
|
| 464 |
} catch (Exception e1) {
|
|
| 465 |
System.out.println(ConcordanceUIMessages.ConcordancesEditor_54+e1); |
|
| 466 |
Log.printStackTrace(e1); |
|
| 467 |
return; |
|
| 468 |
} |
|
| 469 |
|
|
| 470 |
job.syncExec(new Runnable() {
|
|
| 471 |
@Override |
|
| 472 |
public void run() {
|
|
| 473 |
try {
|
|
| 474 |
editor.refresh(false); |
|
| 475 |
} catch (Exception e) {
|
|
| 476 |
// TODO Auto-generated catch block |
|
| 477 |
e.printStackTrace(); |
|
| 478 |
} |
|
| 479 |
} |
|
| 480 |
}); |
|
| 481 |
} |
|
| 482 |
|
|
| 483 |
protected void affectAnnotationValues(final List<Match> matches, final AnnotationType type, final String svalue, JobHandler job) {
|
|
| 484 |
value_to_add = null; // reset |
|
| 485 |
if (matches.size() == 0) {
|
|
| 486 |
System.out.println("No line selected. Aborting."); //$NON-NLS-1$
|
|
| 487 |
return; |
|
| 488 |
} |
|
| 489 |
if (type == null) return; // no type, no annotation |
|
| 490 |
|
|
| 491 |
job.syncExec(new Runnable() {
|
|
| 492 |
@Override |
|
| 493 |
public void run() {
|
|
| 494 |
if (matches.size() > NALERTAFFECTANNOTATIONS) {
|
|
| 495 |
ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), |
|
| 496 |
"confirm_annotate", //$NON-NLS-1$ |
|
| 497 |
ConcordanceUIMessages.ConcordancesEditor_86, |
|
| 498 |
ConcordanceUIMessages.ConcordancesEditor_87+matches.size()+ConcordanceUIMessages.ConcordancesEditor_108); |
|
| 499 |
|
|
| 500 |
if (dialog.open() == ConfirmDialog.CANCEL) {
|
|
| 501 |
System.out.println("Annotation aborted by user."); //$NON-NLS-1$
|
|
| 502 |
matches.clear(); |
|
| 503 |
} |
|
| 504 |
} |
|
| 505 |
} |
|
| 506 |
}); |
|
| 507 |
|
|
| 508 |
// get value from combo text value |
|
| 509 |
Log.warning(ConcordanceUIMessages.ConcordancesEditor_57+svalue); |
|
| 510 |
final KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository()); |
|
| 511 |
value_to_add = kr.getValue(type, svalue); |
|
| 512 |
|
|
| 513 |
|
|
| 514 |
if (value_to_add == null && kr instanceof LocalKnowledgeRepository) { // create or not the annotation is simple mode
|
|
| 515 |
job.syncExec(new Runnable() {
|
|
| 516 |
@Override |
|
| 517 |
public void run() {
|
|
| 518 |
String title = kr.getString(getLocale(), "ConcordancesEditor_110"); |
|
| 519 |
String content = kr.getString(getLocale(), "ConcordancesEditor_112"); |
|
| 520 |
if (title == null ) title = ConcordanceUIMessages.ConcordancesEditor_110; |
|
| 521 |
if (content == null ) content = ConcordanceUIMessages.ConcordancesEditor_112; |
|
| 522 |
ConfirmDialog dialog = new ConfirmDialog(Display.getCurrent().getActiveShell(), |
|
| 523 |
"create_value", //$NON-NLS-1$ |
|
| 524 |
ConcordanceUIMessages.bind(title, svalue, type.getName()), |
|
| 525 |
ConcordanceUIMessages.bind(content, svalue, type.getName())); |
|
| 526 |
if (dialog.open() == ConfirmDialog.CANCEL) {
|
|
| 527 |
System.out.println("Annotation aborted by user."); //$NON-NLS-1$
|
|
| 528 |
return; |
|
| 529 |
} else {
|
|
| 530 |
value_to_add = kr.addValue(svalue, svalue, type.getId()); |
|
| 531 |
KRView.refresh(); |
|
| 532 |
} |
|
| 533 |
} |
|
| 534 |
}); |
|
| 535 |
} |
|
| 536 |
|
|
| 537 |
if (value_to_add == null && kr instanceof LocalKnowledgeRepository) return; // canceled |
|
| 538 |
|
|
| 539 |
if (value_to_add == null) {
|
|
| 540 |
job.syncExec(new Runnable() {
|
|
| 541 |
@Override |
|
| 542 |
public void run() {
|
|
| 543 |
String mess = ConcordanceUIMessages.bind(ConcordanceUIMessages.ConcordancesEditor_58, svalue); |
|
| 544 |
System.out.println(mess); |
|
| 545 |
MessageDialog.openError(Display.getCurrent().getActiveShell(), "Annotation canceled", mess); //$NON-NLS-1$ |
|
| 546 |
} |
|
| 547 |
}); |
|
| 548 |
return; |
|
| 549 |
} |
|
| 550 |
|
|
| 551 |
Log.info(ConcordanceUIMessages.ConcordancesEditor_59+value_to_add+ConcordanceUIMessages.ConcordancesEditor_60+matches); |
|
| 552 |
|
|
| 553 |
// finally we can 'try' to create the annotations \o/ |
|
| 554 |
try {
|
|
| 555 |
HashMap<Match, List<Annotation>> existingAnnots = annotManager.createAnnotations(type, value_to_add, matches, job); |
|
| 556 |
|
|
| 557 |
// did we had problems ? |
|
| 558 |
if (existingAnnots!=null && existingAnnots.size() > 0) {
|
|
| 559 |
String message = ConcordanceUIMessages.ConcordancesEditor_61+value_to_add.getStandardName()+ |
|
| 560 |
ConcordanceUIMessages.ConcordancesEditor_62; |
|
| 561 |
for (Match m : existingAnnots.keySet()) {
|
|
| 562 |
message += ConcordanceUIMessages.ConcordancesEditor_63+m+ConcordanceUIMessages.ConcordancesEditor_64; |
|
| 563 |
|
|
| 564 |
for (Annotation existingAnnot : existingAnnots.get(m)) {
|
|
| 565 |
if (existingAnnot.getStart() < m.getStart()){
|
|
| 566 |
message += ConcordanceUIMessages.ConcordancesEditor_65+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_66+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_67+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_68; |
|
| 567 |
} else {
|
|
| 568 |
message += ConcordanceUIMessages.ConcordancesEditor_69+existingAnnot.getType()+ConcordanceUIMessages.ConcordancesEditor_70+existingAnnot.getStart()+ConcordanceUIMessages.ConcordancesEditor_71+existingAnnot.getEnd()+ConcordanceUIMessages.ConcordancesEditor_72; |
|
| 569 |
} |
|
| 570 |
} |
|
| 571 |
} |
|
| 572 |
final String final_message = message; |
|
| 573 |
job.syncExec(new Runnable() {
|
|
| 574 |
@Override |
|
| 575 |
public void run() {
|
|
| 576 |
MessageDialog.openInformation(editor.getSite().getShell(), ConcordanceUIMessages.ConcordancesEditor_73, final_message); |
|
| 577 |
} |
|
| 578 |
}); |
|
| 579 |
} |
|
| 580 |
|
|
| 581 |
if (Log.getLevel().intValue() < Level.WARNING.intValue() && annotManager != null) {
|
|
| 582 |
annotManager.checkData(); |
|
| 583 |
} |
|
| 584 |
} catch (Exception e1) {
|
|
| 585 |
System.out.println(ConcordanceUIMessages.ConcordancesEditor_74+e1); |
|
| 586 |
Log.printStackTrace(e1); |
|
| 587 |
return; |
|
| 588 |
} |
|
| 589 |
|
|
| 590 |
job.syncExec(new Runnable() {
|
|
| 591 |
@Override |
|
| 592 |
public void run() {
|
|
| 593 |
try {
|
|
| 594 |
editor.refresh(false); |
|
| 595 |
} catch (Exception e) {
|
|
| 596 |
// TODO Auto-generated catch block |
|
| 597 |
e.printStackTrace(); |
|
| 598 |
} |
|
| 599 |
} |
|
| 600 |
}); |
|
| 601 |
} |
|
| 602 |
|
|
| 603 |
public boolean notifyStartOfCompute() throws Exception {
|
|
| 604 |
if (annotationArea != null) {
|
|
| 605 |
AnnotationType type = getSelectedAnnotationType(); |
|
| 606 |
if (type != null) {
|
|
| 607 |
annotations.setViewAnnotation(type); |
|
| 608 |
annotations.setAnnotationOverlap(true); |
|
| 609 |
} |
|
| 610 |
} |
|
| 611 |
return true; |
|
| 612 |
} |
|
| 613 |
|
|
| 614 |
public boolean notifyEndOfCompute() throws Exception {
|
|
| 615 |
updateAnnotationWidgetStates(); |
|
| 616 |
|
|
| 617 |
// update annotation column width |
|
| 618 |
if (annotationArea != null) {
|
|
| 619 |
annotationColumn.pack(); |
|
| 620 |
|
|
| 621 |
annotationColumn.setResizable(true); |
|
| 622 |
} else {
|
|
| 623 |
annotationColumn.setWidth(0); |
|
| 624 |
} |
|
| 625 |
|
|
| 626 |
return true; |
|
| 627 |
} |
|
| 628 |
|
|
| 629 |
|
|
| 630 |
public boolean isAnnotationEnable() {
|
|
| 631 |
return annotationArea != null; |
|
| 632 |
} |
|
| 633 |
|
|
| 634 |
public void update(List<Line> lines, int from, int to) throws Exception {
|
|
| 635 |
annotations.getLines(lines, from, to); |
|
| 636 |
} |
|
| 637 |
|
|
| 638 |
@Override |
|
| 639 |
public boolean save() {
|
|
| 640 |
try {
|
|
| 641 |
AnnotationManager am = KRAnnotationEngine.getAnnotationManager(corpus); |
|
| 642 |
if (am != null && am.hasChanges()) {
|
|
| 643 |
// && MessageDialog.openConfirm(e.display.getActiveShell(), "Confirm annotation save", "Saving annotation will close this editor. Are you sure you want to save annotations right now ?") |
|
| 644 |
JobHandler saveJob = SaveAnnotations.save(corpus.getMainCorpus()); |
|
| 645 |
if (saveJob.getResult() == Status.CANCEL_STATUS) {
|
|
| 646 |
// update editor corpus |
|
| 647 |
System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
|
|
| 648 |
} |
|
| 649 |
} |
|
| 650 |
} catch(Exception ex) {
|
|
| 651 |
ex.printStackTrace(); |
|
| 652 |
return false; |
|
| 653 |
} |
|
| 654 |
return true; |
|
| 655 |
} |
|
| 656 |
|
|
| 657 |
@Override |
|
| 658 |
protected void _close() {
|
|
| 659 |
annotationColumn.dispose(); |
|
| 660 |
} |
|
| 661 |
} |
|
| 0 | 662 | |
| tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/concordance/KRConcordanceAnnotationExtension.java (revision 844) | ||
|---|---|---|
| 1 | 1 |
package org.txm.annotation.rcp.concordance; |
| 2 | 2 |
|
| 3 |
import java.io.File; |
|
| 4 | 3 |
import java.util.ArrayList; |
| 4 |
import java.util.Arrays; |
|
| 5 |
import java.util.Comparator; |
|
| 5 | 6 |
import java.util.HashMap; |
| 6 | 7 |
import java.util.List; |
| 7 | 8 |
import java.util.Vector; |
| 8 | 9 |
import java.util.logging.Level; |
| 9 | 10 |
|
| 11 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 10 | 12 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 11 | 13 |
import org.eclipse.core.runtime.IStatus; |
| 14 |
import org.eclipse.core.runtime.Platform; |
|
| 12 | 15 |
import org.eclipse.core.runtime.Status; |
| 13 |
import org.eclipse.jface.dialogs.InputDialog; |
|
| 14 | 16 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 15 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 16 |
import org.eclipse.jface.viewers.ColumnLabelProvider; |
|
| 17 | 17 |
import org.eclipse.jface.viewers.ComboViewer; |
| 18 | 18 |
import org.eclipse.jface.viewers.ISelection; |
| 19 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
|
| 20 | 19 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 21 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
|
| 22 |
import org.eclipse.jface.viewers.TableViewer; |
|
| 23 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
| 24 |
import org.eclipse.swt.SWT; |
|
| 25 |
import org.eclipse.swt.events.KeyEvent; |
|
| 26 |
import org.eclipse.swt.events.KeyListener; |
|
| 27 | 20 |
import org.eclipse.swt.events.SelectionEvent; |
| 28 | 21 |
import org.eclipse.swt.events.SelectionListener; |
| 29 | 22 |
import org.eclipse.swt.graphics.Point; |
| 30 |
import org.eclipse.swt.layout.GridData; |
|
| 31 | 23 |
import org.eclipse.swt.layout.GridLayout; |
| 32 | 24 |
import org.eclipse.swt.widgets.Button; |
| 33 | 25 |
import org.eclipse.swt.widgets.Combo; |
| 34 |
import org.eclipse.swt.widgets.Composite; |
|
| 35 | 26 |
import org.eclipse.swt.widgets.Display; |
| 36 | 27 |
import org.eclipse.swt.widgets.Group; |
| 37 | 28 |
import org.eclipse.swt.widgets.Label; |
| 38 | 29 |
import org.eclipse.swt.widgets.TableColumn; |
| 39 | 30 |
import org.eclipse.swt.widgets.Text; |
| 40 |
import org.eclipse.swt.widgets.ToolItem; |
|
| 41 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 42 |
import org.eclipse.ui.PartInitException; |
|
| 43 |
import org.eclipse.ui.dialogs.ListDialog; |
|
| 44 | 31 |
import org.txm.annotation.core.Annotation; |
| 45 | 32 |
import org.txm.annotation.core.AnnotationManager; |
| 46 | 33 |
import org.txm.annotation.core.KRAnnotationEngine; |
| 47 |
import org.txm.annotation.core.preferences.AnnotationPreferences; |
|
| 48 | 34 |
import org.txm.annotation.core.repository.AnnotationType; |
| 49 | 35 |
import org.txm.annotation.core.repository.KnowledgeRepository; |
| 50 | 36 |
import org.txm.annotation.core.repository.KnowledgeRepositoryManager; |
| 51 | 37 |
import org.txm.annotation.core.repository.LocalKnowledgeRepository; |
| 52 |
import org.txm.annotation.core.repository.SQLKnowledgeRepository; |
|
| 53 | 38 |
import org.txm.annotation.core.repository.TypedValue; |
| 54 |
import org.txm.annotation.rcp.commands.InitializeKnowledgeRepository; |
|
| 55 |
import org.txm.annotation.rcp.commands.SaveAnnotations; |
|
| 56 |
import org.txm.annotation.rcp.commands.krview.OpenKRView; |
|
| 39 |
import org.txm.annotation.rcp.editor.AnnotationArea; |
|
| 57 | 40 |
import org.txm.annotation.rcp.messages.AnnotationUIMessages; |
| 58 | 41 |
import org.txm.annotation.rcp.views.knowledgerepositories.KRView; |
| 59 | 42 |
import org.txm.concordance.core.functions.Concordance; |
| 60 | 43 |
import org.txm.concordance.core.functions.Line; |
| 61 | 44 |
import org.txm.concordance.rcp.editors.ConcordanceEditor; |
| 62 |
import org.txm.concordance.rcp.editors.ConcordanceEditor.ConcordanceColumnSizeControlListener; |
|
| 63 | 45 |
import org.txm.concordance.rcp.editors.ConcordanceEditorExtension; |
| 64 | 46 |
import org.txm.concordance.rcp.messages.ConcordanceUIMessages; |
| 65 |
import org.txm.core.preferences.TXMPreferences; |
|
| 66 |
import org.txm.rcp.IImageKeys; |
|
| 67 |
import org.txm.rcp.commands.OpenBrowser; |
|
| 68 |
import org.txm.rcp.preferences.RCPPreferences; |
|
| 69 |
import org.txm.rcp.swt.GLComposite; |
|
| 70 | 47 |
import org.txm.rcp.swt.dialog.ConfirmDialog; |
| 71 |
import org.txm.rcp.swt.provider.SimpleLabelProvider; |
|
| 72 | 48 |
import org.txm.rcp.utils.JobHandler; |
| 73 | 49 |
import org.txm.rcp.views.corpora.CorporaView; |
| 74 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
| 75 | 50 |
import org.txm.searchengine.cqp.corpus.Corpus; |
| 76 | 51 |
import org.txm.searchengine.cqp.corpus.query.Match; |
| 77 |
import org.txm.utils.AsciiUtils; |
|
| 78 | 52 |
import org.txm.utils.logger.Log; |
| 79 | 53 |
|
| 80 | 54 |
public class KRConcordanceAnnotationExtension extends ConcordanceEditorExtension {
|
| ... | ... | |
| 91 | 65 |
//boolean annotation_expert_mode = TxmPreferences.getBoolean(AnnotationPreferencePage.MODE, false); |
| 92 | 66 |
|
| 93 | 67 |
/** The annotation area. */ |
| 94 |
protected GLComposite annotationArea;
|
|
| 68 |
protected AnnotationArea annotationArea;
|
|
| 95 | 69 |
|
| 96 | 70 |
protected Point annotationSize; |
| 97 | 71 |
|
| ... | ... | |
| 131 | 105 |
|
| 132 | 106 |
private Corpus corpus; |
| 133 | 107 |
|
| 134 |
private ConcordanceAnnotations annotations = null; |
|
| 135 | 108 |
private Group controlArea; |
| 109 |
private SelectionListener defaultListener; |
|
| 136 | 110 |
|
| 111 |
|
|
| 137 | 112 |
public KRConcordanceAnnotationExtension() {
|
| 138 | 113 |
|
| 139 | 114 |
} |
| ... | ... | |
| 146 | 121 |
@Override |
| 147 | 122 |
public boolean installWidgets() throws Exception {
|
| 148 | 123 |
|
| 149 |
List<String> krlist = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus); |
|
| 150 |
// CONTROLS |
|
| 151 |
if (krlist.size() == 0) { // shown only if corpus has a registered KR
|
|
| 152 |
return false; |
|
| 153 |
} |
|
| 154 |
|
|
| 155 | 124 |
SelectionListener openCloseSelectionListener = new SelectionListener() {
|
| 156 | 125 |
@Override |
| 157 | 126 |
public void widgetSelected(SelectionEvent e) {
|
| 158 | 127 |
if (annotationArea != null) {
|
| 159 |
// //@TODO Closing the annotation tool bar |
|
| 160 |
// //System.out.println("must hide");
|
|
| 161 |
// annotationSize = annotationArea.getSize(); |
|
| 162 |
// annotationArea.dispose(); |
|
| 163 |
// annotationArea = null; |
|
| 164 |
// annotationButton.getParent().layout(true); |
|
| 165 |
// annotationButton.setToolTipText(ConcordanceUIMessages.ConcordancesEditor_75); |
|
| 166 |
// annotationButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL)); |
|
| 167 |
// annotationColumn.setWidth(0); |
|
| 168 |
// annotationColumn.setResizable(false); |
|
| 128 |
return; // do nothing |
|
| 169 | 129 |
} else {
|
| 170 |
if (annotationArea == null) {
|
|
| 171 |
if (!composeAnnotationArea(controlArea)) {
|
|
| 172 |
return; |
|
| 173 |
} |
|
| 174 |
} |
|
| 175 |
if (annotationArea == null) return; |
|
| 176 |
|
|
| 177 |
annotationColumn.pack(); |
|
| 178 |
|
|
| 179 |
// annotSize = annotationArea.getSize(); |
|
| 180 |
// Point size = controlArea.getSize(); |
|
| 181 |
// controlArea.setSize(size.x, size.y + annotSize.y); |
|
| 182 |
// GridData data = (GridData) annotationArea.getLayoutData(); |
|
| 183 |
// data.heightHint = annotSize.y; |
|
| 184 |
// data.minimumHeight = annotSize.y; |
|
| 185 |
// annotationArea.setSize(annotSize); |
|
| 186 |
// controlArea.layout(true); |
|
| 187 |
// controlArea.getParent().layout(); |
|
| 188 |
|
|
| 189 |
if (concordance != null) {
|
|
| 190 |
AnnotationType type = getSelectedAnnotationType(); |
|
| 191 |
if (type != null) {
|
|
| 192 |
annotations.setViewAnnotation(type); |
|
| 193 |
annotations.setAnnotationOverlap(true); |
|
| 194 |
editor.fillDisplayArea(); |
|
| 195 |
} |
|
| 196 |
} |
|
| 197 |
|
|
| 198 |
CorporaView.refreshObject(corpus); |
|
| 130 |
openDefaultAnnotationMode(e); |
|
| 199 | 131 |
} |
| 200 | 132 |
} |
| 201 | 133 |
|
| 202 | 134 |
@Override |
| 203 | 135 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
| 204 | 136 |
}; |
| 205 |
|
|
| 206 |
String[] modes = {"Mots (propriétés)",
|
|
| 207 |
"Séquences de mots (catégorie)", |
|
Formats disponibles : Unified diff