Révision 853
| tmp/org.txm.synopticeditor.rcp/META-INF/MANIFEST.MF (revision 853) | ||
|---|---|---|
| 11 | 11 |
org.eclipse.jface.text;bundle-version="3.9.2";visibility:=reexport, |
| 12 | 12 |
org.txm.links.rcp;bundle-version="1.0.0" |
| 13 | 13 |
Export-Package: org.txm.edition.rcp.editors, |
| 14 |
org.txm.edition.rcp.editors.ext, |
|
| 15 | 14 |
org.txm.edition.rcp.handlers, |
| 16 | 15 |
org.txm.edition.rcp.messages, |
| 17 | 16 |
org.txm.edition.rcp.preferences |
| tmp/org.txm.synopticeditor.rcp/schema/org.txm.edition.rcp.editors.ext.ToolbarButton.exsd (revision 853) | ||
|---|---|---|
| 1 |
<?xml version='1.0' encoding='UTF-8'?> |
|
| 2 |
<!-- Schema file written by PDE --> |
|
| 3 |
<schema targetNamespace="org.txm.edition.rcp" xmlns="http://www.w3.org/2001/XMLSchema"> |
|
| 4 |
<annotation> |
|
| 5 |
<appinfo> |
|
| 6 |
<meta.schema plugin="org.txm.edition.rcp" id="org.txm.edition.rcp.editors.ext.ToolbarButton" name="Synoptic Editor bottom button"/> |
|
| 7 |
</appinfo> |
|
| 8 |
<documentation> |
|
| 9 |
Add a button in the SynapticEditor bottom toolbar |
|
| 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="Button"/> |
|
| 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="Button"> |
|
| 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.edition.rcp.editors.ext.ToolbarButton:"/> |
|
| 59 |
</appinfo> |
|
| 60 |
</annotation> |
|
| 61 |
</attribute> |
|
| 62 |
</complexType> |
|
| 63 |
</element> |
|
| 64 |
|
|
| 65 |
<annotation> |
|
| 66 |
<appinfo> |
|
| 67 |
<meta.section type="since"/> |
|
| 68 |
</appinfo> |
|
| 69 |
<documentation> |
|
| 70 |
TXM 0.8.0 |
|
| 71 |
</documentation> |
|
| 72 |
</annotation> |
|
| 73 |
|
|
| 74 |
<annotation> |
|
| 75 |
<appinfo> |
|
| 76 |
<meta.section type="examples"/> |
|
| 77 |
</appinfo> |
|
| 78 |
<documentation> |
|
| 79 |
[Enter extension point usage example here.] |
|
| 80 |
</documentation> |
|
| 81 |
</annotation> |
|
| 82 |
|
|
| 83 |
<annotation> |
|
| 84 |
<appinfo> |
|
| 85 |
<meta.section type="apiinfo"/> |
|
| 86 |
</appinfo> |
|
| 87 |
<documentation> |
|
| 88 |
[Enter API information here.] |
|
| 89 |
</documentation> |
|
| 90 |
</annotation> |
|
| 91 |
|
|
| 92 |
<annotation> |
|
| 93 |
<appinfo> |
|
| 94 |
<meta.section type="implementation"/> |
|
| 95 |
</appinfo> |
|
| 96 |
<documentation> |
|
| 97 |
[Enter information about supplied implementation of this extension point.] |
|
| 98 |
</documentation> |
|
| 99 |
</annotation> |
|
| 100 |
|
|
| 101 |
|
|
| 102 |
</schema> |
|
| tmp/org.txm.synopticeditor.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 853) | ||
|---|---|---|
| 70 | 70 |
import org.eclipse.ui.PlatformUI; |
| 71 | 71 |
import org.eclipse.ui.commands.ICommandService; |
| 72 | 72 |
import org.eclipse.ui.handlers.IHandlerService; |
| 73 |
import org.txm.edition.rcp.editors.ext.ToolbarButton; |
|
| 74 | 73 |
import org.txm.edition.rcp.messages.SynopticEditionUIMessages; |
| 75 | 74 |
import org.txm.objects.Edition; |
| 76 | 75 |
import org.txm.objects.Text; |
| ... | ... | |
| 104 | 103 |
private GLComposite controlsArea; |
| 105 | 104 |
// private GLComposite annotationWidgetsArea; |
| 106 | 105 |
// private TXMEditorToolBar supplementaryButtonToolbar; |
| 107 |
private HashSet<ToolbarButton> toolbarButtons = new HashSet<ToolbarButton>(); |
|
| 108 | 106 |
private ISelectionProvider selProvider; |
| 109 | 107 |
|
| 108 |
//TODO finish editor conversion |
|
| 109 |
public Text getResult() {
|
|
| 110 |
for (EditionPanel panel : editionPanels.values()) {
|
|
| 111 |
return panel.getCurrentText(); |
|
| 112 |
} |
|
| 113 |
return null; |
|
| 114 |
} |
|
| 115 |
|
|
| 110 | 116 |
/** |
| 111 | 117 |
* Instantiates a new txm browser. |
| 112 | 118 |
*/ |
| ... | ... | |
| 173 | 179 |
|
| 174 | 180 |
public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
|
| 175 | 181 |
for(EditionPanel panel : editionPanels.values()) {
|
| 176 |
panel.removeHighlightWordsById(color, wordids); |
|
| 182 |
if (!panel.isDisposed()) {
|
|
| 183 |
panel.removeHighlightWordsById(color, wordids); |
|
| 184 |
} |
|
| 177 | 185 |
} |
| 178 | 186 |
} |
| 179 | 187 |
|
| 180 | 188 |
public void removeHighlightWordsById(RGBA color, String wordid) {
|
| 181 | 189 |
for(EditionPanel panel : editionPanels.values()) {
|
| 182 |
panel.removeHighlightWordsById(color, wordid); |
|
| 190 |
if (!panel.isDisposed()) {
|
|
| 191 |
panel.removeHighlightWordsById(color, wordid); |
|
| 192 |
} |
|
| 183 | 193 |
} |
| 184 | 194 |
} |
| 185 | 195 |
|
| ... | ... | |
| 205 | 215 |
// |
| 206 | 216 |
// } |
| 207 | 217 |
|
| 208 |
public void dispose() {
|
|
| 209 |
if (releaseExtensions()) {
|
|
| 210 |
super.dispose(); |
|
| 211 |
} |
|
| 212 |
} |
|
| 213 |
|
|
| 214 |
private boolean releaseExtensions() {
|
|
| 215 |
boolean error = false; |
|
| 216 |
for (ToolbarButton tb : toolbarButtons) {
|
|
| 217 |
try {
|
|
| 218 |
tb.onClose(); |
|
| 219 |
} catch(Exception e) {
|
|
| 220 |
Log.printStackTrace(e); |
|
| 221 |
System.out.println("Error while closing editor toolbar button: "+e);
|
|
| 222 |
error = true; |
|
| 223 |
} |
|
| 224 |
} |
|
| 225 |
return !error; |
|
| 226 |
} |
|
| 227 |
|
|
| 228 | 218 |
/** |
| 229 | 219 |
* First page. |
| 230 | 220 |
*/ |
| ... | ... | |
| 455 | 445 |
lastText.setImage(IImageKeys.getImage(IImageKeys.CTRLFASTFORWARDEND)); |
| 456 | 446 |
lastText.setToolTipText(SynopticEditionUIMessages.SynopticEditionEditor_11); |
| 457 | 447 |
|
| 458 |
// browse available extension points |
|
| 459 |
try {
|
|
| 460 |
IConfigurationElement[] config = Platform.getExtensionRegistry() |
|
| 461 |
.getConfigurationElementsFor(ToolbarButton.class.getName()); |
|
| 462 |
//Log.warning(Messages.ApplicationWorkbenchAdvisor_15+config.length); |
|
| 463 |
for (IConfigurationElement e : config) {
|
|
| 464 |
Object o = e.createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 465 |
if (o instanceof ToolbarButton) {
|
|
| 466 |
ToolbarButton tb = ((ToolbarButton) o); |
|
| 467 |
ToolItem b = tb.getToolbarButton(getTopToolbar(), this); |
|
| 468 |
|
|
| 469 |
toolbarButtons.add(tb); |
|
| 470 |
} |
|
| 471 |
} |
|
| 472 |
} catch (Exception ex) {
|
|
| 473 |
System.out.println(ex.getMessage()); |
|
| 474 |
Log.printStackTrace(ex); |
|
| 475 |
} |
|
| 476 |
|
|
| 477 | 448 |
page_text.addKeyListener(new KeyListener() {
|
| 478 | 449 |
|
| 479 | 450 |
@Override |
| ... | ... | |
| 665 | 636 |
} |
| 666 | 637 |
|
| 667 | 638 |
@Override |
| 668 |
public void doSave(IProgressMonitor monitor) {
|
|
| 669 |
for (ToolbarButton b : toolbarButtons) {
|
|
| 670 |
b.save(); |
|
| 671 |
} |
|
| 672 |
firePropertyChange(IEditorPart.PROP_DIRTY); |
|
| 673 |
} |
|
| 674 |
|
|
| 675 |
@Override |
|
| 676 | 639 |
public void doSaveAs() {
|
| 677 | 640 |
return; |
| 678 | 641 |
} |
| ... | ... | |
| 680 | 643 |
@Override |
| 681 | 644 |
public void init(IEditorSite site, IEditorInput input) |
| 682 | 645 |
throws PartInitException {
|
| 683 |
setSite(site); |
|
| 684 |
setInput(input); |
|
| 646 |
super.init(site, input); |
|
| 685 | 647 |
|
| 686 | 648 |
corpus = ((SynopticEditorInput) getEditorInput()).getCorpus(); |
| 687 |
corpus = corpus.getMainCorpus(); |
|
| 649 |
corpus = corpus.getMainCorpus(); // get the main corpus of the corpus
|
|
| 688 | 650 |
text = ((SynopticEditorInput) getEditorInput()).getText(); |
| 689 | 651 |
editionNames = ((SynopticEditorInput) getEditorInput()).getEditions(); |
| 690 |
|
|
| 691 |
IPartListener2 pl = new IPartListener2() {
|
|
| 692 |
// ... Other methods |
|
| 693 |
public void partClosed(IWorkbenchPartReference partRef) {
|
|
| 694 |
if (partRef.getId().equals(ID)) { // called after this.doSave()
|
|
| 695 |
//System.out.println("EVENT partClosed");
|
|
| 696 |
for (ToolbarButton b : toolbarButtons) {
|
|
| 697 |
if (b.isDirty()) b.discardChanges(); |
|
| 698 |
} |
|
| 699 |
} |
|
| 700 |
} |
|
| 701 |
|
|
| 702 |
@Override |
|
| 703 |
public void partActivated(IWorkbenchPartReference partRef) { }
|
|
| 704 |
|
|
| 705 |
@Override |
|
| 706 |
public void partBroughtToTop(IWorkbenchPartReference partRef) { }
|
|
| 707 |
|
|
| 708 |
@Override |
|
| 709 |
public void partDeactivated(IWorkbenchPartReference partRef) { }
|
|
| 710 |
|
|
| 711 |
@Override |
|
| 712 |
public void partOpened(IWorkbenchPartReference partRef) { }
|
|
| 713 |
|
|
| 714 |
@Override |
|
| 715 |
public void partHidden(IWorkbenchPartReference partRef) { }
|
|
| 716 |
|
|
| 717 |
@Override |
|
| 718 |
public void partVisible(IWorkbenchPartReference partRef) { }
|
|
| 719 |
|
|
| 720 |
@Override |
|
| 721 |
public void partInputChanged(IWorkbenchPartReference partRef) { }
|
|
| 722 |
|
|
| 723 |
}; |
|
| 724 |
this.getEditorSite().getPage().addPartListener(pl); |
|
| 725 | 652 |
} |
| 726 | 653 |
|
| 727 |
@Override |
|
| 728 |
public boolean isDirty() {
|
|
| 729 |
boolean dirty = false; |
|
| 730 |
for (ToolbarButton b : toolbarButtons) {
|
|
| 731 |
dirty = dirty || b.isDirty(); |
|
| 732 |
} |
|
| 733 |
return dirty; |
|
| 734 |
} |
|
| 735 |
|
|
| 736 | 654 |
public boolean isDisposed() {
|
| 737 | 655 |
return editionsArea.isDisposed(); |
| 738 | 656 |
} |
| ... | ... | |
| 753 | 671 |
} |
| 754 | 672 |
updatePageLabel(); |
| 755 | 673 |
|
| 756 |
for (ToolbarButton button : this.toolbarButtons) {
|
|
| 757 |
button.onBackToText(text, line_wordid); |
|
| 758 |
} |
|
| 674 |
notifyExtensions("onBackToText");
|
|
| 759 | 675 |
} |
| 760 | 676 |
|
| 761 | 677 |
public void reloadPage() {
|
| tmp/org.txm.synopticeditor.rcp/plugin.xml (revision 853) | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 |
<?eclipse version="3.4"?> |
| 3 | 3 |
<plugin> |
| 4 |
<extension-point id="org.txm.edition.rcp.editors.ext.ToolbarButton" name="Synoptic Editor toolbar button" schema="schema/org.txm.edition.rcp.editors.ext.ToolbarButton.exsd"/> |
|
| 5 | 4 |
<extension |
| 6 | 5 |
point="org.eclipse.ui.menus"> |
| 7 | 6 |
<menuContribution |
| tmp/org.txm.rcp.feature/feature.xml (revision 853) | ||
|---|---|---|
| 187 | 187 |
version="0.0.0" |
| 188 | 188 |
optional="true"/> |
| 189 | 189 |
|
| 190 |
<includes |
|
| 191 |
id="org.txm.annotation.kr.feature" |
|
| 192 |
version="0.0.0"/> |
|
| 193 |
|
|
| 190 | 194 |
<requires> |
| 191 | 195 |
<import plugin="org.eclipse.core.runtime" version="3.10.0" match="greaterOrEqual"/> |
| 192 | 196 |
<import plugin="org.eclipse.osgi.util" version="3.2.0" match="greaterOrEqual"/> |
| tmp/org.txm.analec.rcp/src/visuAnalec/donnees/Corpus.java (revision 853) | ||
|---|---|---|
| 561 | 561 |
* @param newNom |
| 562 | 562 |
* @return |
| 563 | 563 |
*/ |
| 564 |
private void ajouterType(Class<? extends Element> classe, String type) {
|
|
| 564 |
public void ajouterType(Class<? extends Element> classe, String type) {
|
|
| 565 | 565 |
structure.ajouterType(classe, type); |
| 566 | 566 |
if (classe==Unite.class) {
|
| 567 | 567 |
unites.put(type, new ArrayList<Unite>()); |
| tmp/org.txm.analec.rcp/src/org/txm/analec/toolbarbutton/StartButton.java (revision 853) | ||
|---|---|---|
| 1 |
package org.txm.analec.toolbarbutton; |
|
| 2 |
|
|
| 3 |
import java.util.Arrays; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 6 |
import org.eclipse.core.runtime.IStatus; |
|
| 7 |
import org.eclipse.core.runtime.Status; |
|
| 8 |
import org.eclipse.swt.SWT; |
|
| 9 |
import org.eclipse.swt.events.SelectionAdapter; |
|
| 10 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 11 |
import org.eclipse.swt.events.SelectionListener; |
|
| 12 |
import org.eclipse.swt.graphics.Point; |
|
| 13 |
import org.eclipse.swt.graphics.Rectangle; |
|
| 14 |
import org.eclipse.swt.widgets.Composite; |
|
| 15 |
import org.eclipse.swt.widgets.Group; |
|
| 16 |
import org.eclipse.swt.widgets.Menu; |
|
| 17 |
import org.eclipse.swt.widgets.MenuItem; |
|
| 18 |
import org.eclipse.swt.widgets.ToolBar; |
|
| 19 |
import org.eclipse.swt.widgets.ToolItem; |
|
| 20 |
import org.txm.analec.AnalecCorpora; |
|
| 21 |
import org.txm.analec.toolbar.URSAnnotationToolbar; |
|
| 22 |
import org.txm.analec.toolbar.SchemaToolbar; |
|
| 23 |
import org.txm.analec.toolbar.UnitToolbar; |
|
| 24 |
import org.txm.analec.view.ElementPropertiesView; |
|
| 25 |
import org.txm.analec.view.ElementSearchView; |
|
| 26 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
|
| 27 |
import org.txm.edition.rcp.editors.ext.ToolbarButton; |
|
| 28 |
import org.txm.objects.Text; |
|
| 29 |
import org.txm.rcp.IImageKeys; |
|
| 30 |
import org.txm.rcp.editors.TXMEditorToolBar; |
|
| 31 |
import org.txm.rcp.swt.GLComposite; |
|
| 32 |
import org.txm.rcp.swt.listeners.DropdownSelectionListener; |
|
| 33 |
import org.txm.rcp.utils.JobHandler; |
|
| 34 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 35 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
|
| 36 |
|
|
| 37 |
import visuAnalec.Message; |
|
| 38 |
import visuAnalec.Message.TypeMessage; |
|
| 39 |
import visuAnalec.donnees.Corpus; |
|
| 40 |
import visuAnalec.donnees.Corpus.CorpusListener; |
|
| 41 |
import visuAnalec.vue.Vue; |
|
| 42 |
|
|
| 43 |
public class StartButton extends ToolbarButton {
|
|
| 44 |
|
|
| 45 |
private Corpus analecCorpus; |
|
| 46 |
protected ToolItem openCloseButton; |
|
| 47 |
protected ToolItem saveButton; |
|
| 48 |
//protected Button drop_b; |
|
| 49 |
private MainCorpus corpus; |
|
| 50 |
|
|
| 51 |
// listen to corpus structure modification -> enable/disable the button |
|
| 52 |
// and to new annotations -> set the star modifier to the Corpus view |
|
| 53 |
protected CorpusListener corpusListener = new CorpusListener() {
|
|
| 54 |
@Override |
|
| 55 |
public void traiterEvent(final Message e) {
|
|
| 56 |
if (corpus == null) return; |
|
| 57 |
|
|
| 58 |
//System.out.println("StartButton.corpusListener.traiterEvent: "+e);
|
|
| 59 |
if (openCloseButton !=null && !openCloseButton.isDisposed()) {
|
|
| 60 |
|
|
| 61 |
openCloseButton.getDisplay().syncExec(new Runnable() {
|
|
| 62 |
@Override |
|
| 63 |
public void run() {
|
|
| 64 |
if (e.getType() == TypeMessage.MODIF_STRUCTURE) {
|
|
| 65 |
boolean ready = AnalecCorpora.isAnnotationStructureReady(corpus); |
|
| 66 |
StartButton.this.setEnabled(ready); |
|
| 67 |
//if (!ready && utoolbar != null && !utoolbar.isDisposed()) utoolbar.clearHighlight(); |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
if (e.getType() == TypeMessage.MODIF_ELEMENT) {
|
|
| 71 |
StartButton.this.setEnabled(AnalecCorpora.isAnnotationStructureReady(corpus)); |
|
| 72 |
if (!corpus.isModified()) {
|
|
| 73 |
corpus.setIsModified(true); // to show the * in corpora view |
|
| 74 |
updateCorporaView(corpus); |
|
| 75 |
} |
|
| 76 |
|
|
| 77 |
} else if (e.getType() == TypeMessage.CORPUS_SAVED) {
|
|
| 78 |
openCloseButton.setEnabled(false); |
|
| 79 |
if (corpus.isModified()) {
|
|
| 80 |
corpus.setIsModified(false); // to remove the * in corpora view |
|
| 81 |
updateCorporaView(corpus); |
|
| 82 |
} |
|
| 83 |
} |
|
| 84 |
} |
|
| 85 |
}); |
|
| 86 |
|
|
| 87 |
if (utoolbar != null && !utoolbar.isDisposed()) {
|
|
| 88 |
|
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
} |
|
| 92 |
}; |
|
| 93 |
private String name; |
|
| 94 |
protected boolean open = false; |
|
| 95 |
protected Composite toolbar; |
|
| 96 |
protected URSAnnotationToolbar utoolbar; |
|
| 97 |
private Vue vue; |
|
| 98 |
/** |
|
| 99 |
* the annotation tool widgets are added here |
|
| 100 |
*/ |
|
| 101 |
private Group annotationWidgetGroup; |
|
| 102 |
|
|
| 103 |
protected ToolItem createButton(TXMEditorToolBar toolbar, SynopticEditionEditor syneditor) {
|
|
| 104 |
this.editor = syneditor; |
|
| 105 |
this.toolbar = toolbar; |
|
| 106 |
|
|
| 107 |
corpus = editor.getCorpus().getMainCorpus(); |
|
| 108 |
name = corpus.getName(); |
|
| 109 |
analecCorpus = AnalecCorpora.getCorpus(name); |
|
| 110 |
vue = AnalecCorpora.getVue(name); |
|
| 111 |
analecCorpus.addEventListener(corpusListener); |
|
| 112 |
|
|
| 113 |
SelectionListener openCloseSelectionListener = new SelectionListener() {
|
|
| 114 |
@Override |
|
| 115 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 116 |
|
|
| 117 |
@Override |
|
| 118 |
public void widgetSelected(SelectionEvent e) {
|
|
| 119 |
if (!open) { // if no annotation is started, default annotation mode is Unit
|
|
| 120 |
openToolbar(UnitToolbar.class); |
|
| 121 |
} |
|
| 122 |
} |
|
| 123 |
}; |
|
| 124 |
String[] modes = {Messages.StartButton_0, Messages.StartButton_1};
|
|
| 125 |
SelectionListener unitStartSelectionListener = new SelectionListener() {
|
|
| 126 |
|
|
| 127 |
@Override |
|
| 128 |
public void widgetSelected(SelectionEvent e) {
|
|
| 129 |
if (open) {
|
|
| 130 |
endCurrentAnnotationMode(); |
|
| 131 |
} |
|
| 132 |
openToolbar(UnitToolbar.class); |
|
| 133 |
|
|
| 134 |
} |
|
| 135 |
|
|
| 136 |
@Override |
|
| 137 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 138 |
}; |
|
| 139 |
SelectionListener schemaStartSelectionListener = new SelectionListener() {
|
|
| 140 |
|
|
| 141 |
@Override |
|
| 142 |
public void widgetSelected(SelectionEvent e) {
|
|
| 143 |
if (open) {
|
|
| 144 |
endCurrentAnnotationMode(); |
|
| 145 |
} |
|
| 146 |
openToolbar(SchemaToolbar.class); |
|
| 147 |
} |
|
| 148 |
|
|
| 149 |
@Override |
|
| 150 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 151 |
}; |
|
| 152 |
SelectionListener[] modeListeners = {unitStartSelectionListener, schemaStartSelectionListener};
|
|
| 153 |
annotationWidgetGroup = toolbar.installAlternativesGroup("URS annotation", "Start URS annotation", IImageKeys.PENCIL_OPEN, IImageKeys.PENCIL_CLOSE, true, openCloseSelectionListener, Arrays.asList(modes), Arrays.asList(modeListeners));
|
|
| 154 |
annotationWidgetGroup.setLayout(GLComposite.createDefaultLayout(1)); |
|
| 155 |
saveButton = new ToolItem(toolbar, SWT.PUSH); |
|
| 156 |
saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE)); |
|
| 157 |
openCloseButton = toolbar.getGroupButton("URS annotation");
|
|
| 158 |
|
|
| 159 |
setButtonToStartMode(); |
|
| 160 |
|
|
| 161 |
return openCloseButton; |
|
| 162 |
} |
|
| 163 |
|
|
| 164 |
/** |
|
| 165 |
* return true is the current annotation mode has been ended |
|
| 166 |
*/ |
|
| 167 |
private boolean endCurrentAnnotationMode() {
|
|
| 168 |
|
|
| 169 |
|
|
| 170 |
if (utoolbar != null) {
|
|
| 171 |
|
|
| 172 |
setButtonToStartMode(); |
|
| 173 |
|
|
| 174 |
utoolbar.clearHighlight(); |
|
| 175 |
utoolbar.dispose(); |
|
| 176 |
|
|
| 177 |
if (utoolbar.getEditorClickListener() != null) |
|
| 178 |
editor.getEditionPanel(0).getBrowser().removeMouseListener(utoolbar.getEditorClickListener()); |
|
| 179 |
if (utoolbar.getMenuListener() != null) |
|
| 180 |
editor.getEditionPanel(0).getBrowser().getMenu().removeMenuListener(utoolbar.getMenuListener()); |
|
| 181 |
if (utoolbar.getEditorKeyListener() != null) |
|
| 182 |
editor.getEditionPanel(0).getBrowser().removeKeyListener(utoolbar.getEditorKeyListener()); |
|
| 183 |
editor.layout(true); |
|
| 184 |
utoolbar = null; |
|
| 185 |
editor.layout(true); |
|
| 186 |
|
|
| 187 |
ElementPropertiesView.closeView(); |
|
| 188 |
ElementSearchView.closeView(); |
|
| 189 |
|
|
| 190 |
return true; |
|
| 191 |
} |
|
| 192 |
|
|
| 193 |
return false; |
|
| 194 |
} |
|
| 195 |
|
|
| 196 |
public boolean onClose() {
|
|
| 197 |
|
|
| 198 |
ElementPropertiesView.closeView(); |
|
| 199 |
ElementSearchView.closeView(); |
|
| 200 |
analecCorpus.removeEventListener(corpusListener); |
|
| 201 |
|
|
| 202 |
return true; |
|
| 203 |
} |
|
| 204 |
|
|
| 205 |
/** |
|
| 206 |
* manage the opening of AnnotationToolbar |
|
| 207 |
* |
|
| 208 |
* Close the current annotation if any |
|
| 209 |
* @param clazz |
|
| 210 |
*/ |
|
| 211 |
private void openToolbar(Class<? extends URSAnnotationToolbar> clazz) {
|
|
| 212 |
if (utoolbar != null && utoolbar.getClass().equals(clazz)) return; |
|
| 213 |
if (utoolbar != null) {
|
|
| 214 |
if (endCurrentAnnotationMode()) {
|
|
| 215 |
|
|
| 216 |
} |
|
| 217 |
} |
|
| 218 |
|
|
| 219 |
if (analecCorpus.getStructure().isVide()) {
|
|
| 220 |
System.out.println(Messages.StartButton_6+name+Messages.StartButton_7); |
|
| 221 |
return; |
|
| 222 |
} |
|
| 223 |
|
|
| 224 |
setButtonToSaveMode(); |
|
| 225 |
|
|
| 226 |
open = true; |
|
| 227 |
|
|
| 228 |
if (clazz.equals(UnitToolbar.class)) |
|
| 229 |
utoolbar = new UnitToolbar(annotationWidgetGroup, StartButton.this, SWT.NONE, editor, analecCorpus, vue); |
|
| 230 |
else |
|
| 231 |
utoolbar = new SchemaToolbar(annotationWidgetGroup, StartButton.this, SWT.NONE, editor, analecCorpus, vue); |
|
| 232 |
|
|
| 233 |
if (utoolbar.getEditorClickListener() != null) |
|
| 234 |
editor.getEditionPanel(0).getBrowser().addMouseListener(utoolbar.getEditorClickListener()); |
|
| 235 |
if (utoolbar.getMenuListener() != null) |
|
| 236 |
editor.getEditionPanel(0).getBrowser().getMenu().addMenuListener(utoolbar.getMenuListener()); |
|
| 237 |
if (utoolbar.getEditorKeyListener() != null) |
|
| 238 |
editor.getEditionPanel(0).getBrowser().addKeyListener(utoolbar.getEditorKeyListener()); |
|
| 239 |
} |
|
| 240 |
|
|
| 241 |
private void setButtonToSaveMode() {
|
|
| 242 |
if (analecCorpus.getStructure().isVide()) {
|
|
| 243 |
System.out.println(Messages.StartButton_9+name+Messages.StartButton_10); |
|
| 244 |
return; |
|
| 245 |
} |
|
| 246 |
|
|
| 247 |
saveButton.setEnabled(analecCorpus.isModifie()); // enable if corpus is not saved |
|
| 248 |
open = true; |
|
| 249 |
} |
|
| 250 |
|
|
| 251 |
private void setButtonToStartMode() {
|
|
| 252 |
saveButton.setEnabled(false); |
|
| 253 |
open = false; |
|
| 254 |
} |
|
| 255 |
|
|
| 256 |
|
|
| 257 |
public void setEnabled(boolean state) {
|
|
| 258 |
if (openCloseButton != null) openCloseButton.setEnabled(state); |
|
| 259 |
} |
|
| 260 |
|
|
| 261 |
public void updateCorporaView(final MainCorpus corpus) {
|
|
| 262 |
CorporaView.refreshObject(corpus); |
|
| 263 |
} |
|
| 264 |
|
|
| 265 |
@Override |
|
| 266 |
public void save() {
|
|
| 267 |
if (isDirty() && toolbar != null && !toolbar.isDisposed()) {
|
|
| 268 |
AnalecCorpora.saveCorpus(analecCorpus); |
|
| 269 |
} |
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
@Override |
|
| 273 |
public boolean isDirty() {
|
|
| 274 |
return corpus.isModified(); |
|
| 275 |
} |
|
| 276 |
|
|
| 277 |
public void fireIsDirty() {
|
|
| 278 |
editor.fireIsDirty(); |
|
| 279 |
} |
|
| 280 |
|
|
| 281 |
@Override |
|
| 282 |
public void discardChanges() {
|
|
| 283 |
if (corpus.isModified()) {
|
|
| 284 |
AnalecCorpora.revert(corpus); |
|
| 285 |
analecCorpus = AnalecCorpora.getCorpus(name); |
|
| 286 |
vue = AnalecCorpora.getVue(name); |
|
| 287 |
analecCorpus.addEventListener(corpusListener); |
|
| 288 |
CorporaView.refreshObject(corpus); |
|
| 289 |
} |
|
| 290 |
} |
|
| 291 |
|
|
| 292 |
public SynopticEditionEditor getEditor() {
|
|
| 293 |
return editor; |
|
| 294 |
} |
|
| 295 |
|
|
| 296 |
@Override |
|
| 297 |
public void onBackToText(Text text, String line_wordid) {
|
|
| 298 |
if (this.utoolbar != null && !this.utoolbar.isDisposed()) {
|
|
| 299 |
this.utoolbar.onBackToText(text, line_wordid); |
|
| 300 |
} |
|
| 301 |
} |
|
| 302 |
} |
|
| tmp/org.txm.analec.rcp/src/org/txm/analec/toolbar/UnitToolbar.java (revision 853) | ||
|---|---|---|
| 18 | 18 |
import org.eclipse.swt.events.SelectionEvent; |
| 19 | 19 |
import org.eclipse.swt.events.SelectionListener; |
| 20 | 20 |
import org.eclipse.swt.layout.GridData; |
| 21 |
import org.eclipse.swt.layout.GridLayout; |
|
| 22 | 21 |
import org.eclipse.swt.widgets.Button; |
| 23 | 22 |
import org.eclipse.swt.widgets.Combo; |
| 24 | 23 |
import org.eclipse.swt.widgets.Composite; |
| ... | ... | |
| 28 | 27 |
import org.eclipse.swt.widgets.Listener; |
| 29 | 28 |
import org.eclipse.swt.widgets.Menu; |
| 30 | 29 |
import org.eclipse.swt.widgets.MenuItem; |
| 30 |
import org.txm.analec.AnalecCorpora; |
|
| 31 | 31 |
import org.txm.analec.preferences.AnalecPreferences; |
| 32 |
import org.txm.analec.toolbarbutton.StartButton; |
|
| 33 | 32 |
import org.txm.analec.view.ElementPropertiesView; |
| 34 | 33 |
import org.txm.analec.widgets.NavigationField; |
| 34 |
import org.txm.annotation.rcp.editor.AnnotationExtension; |
|
| 35 | 35 |
import org.txm.core.preferences.TXMPreferences; |
| 36 |
import org.txm.core.results.TXMResult; |
|
| 36 | 37 |
import org.txm.edition.rcp.editors.EditionPanel; |
| 37 | 38 |
import org.txm.edition.rcp.editors.RGBA; |
| 38 | 39 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
| ... | ... | |
| 40 | 41 |
import org.txm.objects.Page; |
| 41 | 42 |
import org.txm.objects.Text; |
| 42 | 43 |
import org.txm.rcp.IImageKeys; |
| 44 |
import org.txm.rcp.editors.TXMEditor; |
|
| 45 |
import org.txm.rcp.swt.GLComposite; |
|
| 43 | 46 |
import org.txm.rcp.swt.dialog.ConfirmDialog; |
| 44 | 47 |
import org.txm.searchengine.cqp.AbstractCqiClient; |
| 45 | 48 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| ... | ... | |
| 68 | 71 |
private Button createButton; |
| 69 | 72 |
private Button deleteButton; |
| 70 | 73 |
private Button editButton; |
| 71 |
|
|
| 72 | 74 |
|
| 75 |
|
|
| 73 | 76 |
private KeyListener editorKeyListener; |
| 74 | 77 |
private MouseListener editorMouseListener; |
| 75 | 78 |
private int fixingAnnotationLimits = 0; |
| ... | ... | |
| 91 | 94 |
private Button editLeftButton; |
| 92 | 95 |
private Button editRightButton; |
| 93 | 96 |
|
| 94 |
public UnitToolbar(Composite toolbarsArea, StartButton button, int style, SynopticEditionEditor syneditor, Corpus analecCorpus, Vue vue) {
|
|
| 95 |
super(toolbarsArea, "Schema", button, style); |
|
| 97 |
public UnitToolbar() { }
|
|
| 96 | 98 |
|
| 99 |
@Override |
|
| 100 |
public boolean install(TXMEditor<? extends TXMResult> txmeditor, AnnotationExtension extension, Composite parent) throws Exception {
|
|
| 101 |
super.install(txmeditor, extension, parent); |
|
| 102 |
|
|
| 103 |
annotationArea.getLayout().numColumns = 10; |
|
| 104 |
annotationArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
|
| 97 | 105 |
|
| 98 | 106 |
String color_palette = TXMPreferences.getString(AnalecPreferences.COLOR_PALETTE, AnalecPreferences.PREFERENCES_NODE); //$NON-NLS-1$ |
| 99 | 107 |
if ("yellow".equals(color_palette)) { //$NON-NLS-1$
|
| ... | ... | |
| 110 | 118 |
|
| 111 | 119 |
} |
| 112 | 120 |
|
| 113 |
this.button = button; |
|
| 114 |
this.editor = syneditor; |
|
| 121 |
this.button = extension.getSaveButton(); |
|
| 115 | 122 |
this.maincorpus = this.editor.getCorpus().getMainCorpus(); |
| 116 | 123 |
try {
|
| 117 | 124 |
maxCorpusPosition = maincorpus.getSize(); |
| ... | ... | |
| 119 | 126 |
System.out.println(Messages.UnitToolbar_3+maincorpus+Messages.UnitToolbar_4+e.getLocalizedMessage()); |
| 120 | 127 |
Log.printStackTrace(e); |
| 121 | 128 |
} |
| 122 |
this.analecCorpus = analecCorpus; |
|
| 123 | 129 |
analecCorpus.addEventListener(this); |
| 124 |
this.vue = vue; |
|
| 125 |
this.getLayout().numColumns = 10; |
|
| 126 |
this.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
|
| 127 | 130 |
|
| 128 |
l = new Label(this, SWT.NONE); |
|
| 131 |
|
|
| 132 |
l = new Label(annotationArea, SWT.NONE); |
|
| 129 | 133 |
l.setText(Messages.UnitToolbar_5); |
| 130 | 134 |
l.setToolTipText(Messages.UnitToolbar_6); |
| 131 | 135 |
l.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false)); |
| 132 |
|
|
| 133 |
typeCombo = new Combo(this, SWT.NONE|SWT.READ_ONLY);
|
|
| 136 |
|
|
| 137 |
typeCombo = new Combo(annotationArea, SWT.NONE|SWT.READ_ONLY);
|
|
| 134 | 138 |
typeCombo.setToolTipText(Messages.UnitToolbar_7); |
| 135 | 139 |
GridData gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
| 136 | 140 |
gdata.minimumWidth = 100; |
| ... | ... | |
| 155 | 159 |
onIdentifiantComboSelected(event); |
| 156 | 160 |
} |
| 157 | 161 |
}); |
| 158 |
|
|
| 162 |
|
|
| 159 | 163 |
//l = new Label(this, SWT.NONE); |
| 160 |
|
|
| 161 |
createButton = new Button(this, SWT.PUSH);
|
|
| 164 |
|
|
| 165 |
createButton = new Button(annotationArea, SWT.PUSH);
|
|
| 162 | 166 |
createButton.setText(Messages.UnitToolbar_8); |
| 163 | 167 |
gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
| 164 | 168 |
createButton.setLayoutData(gdata); |
| ... | ... | |
| 171 | 175 |
onCreateButtonSelected(e); |
| 172 | 176 |
} |
| 173 | 177 |
}); |
| 174 |
|
|
| 175 |
deleteButton = new Button(this, SWT.PUSH);
|
|
| 178 |
|
|
| 179 |
deleteButton = new Button(annotationArea, SWT.PUSH);
|
|
| 176 | 180 |
gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
| 177 | 181 |
deleteButton.setLayoutData(gdata); |
| 178 | 182 |
deleteButton.setImage(IImageKeys.getImage("platform:/plugin/org.txm.rcp/icons/cross.png")); //$NON-NLS-1$
|
| ... | ... | |
| 186 | 190 |
} |
| 187 | 191 |
}); |
| 188 | 192 |
|
| 189 |
l = new Label(this, SWT.NONE);
|
|
| 190 |
|
|
| 191 |
editLeftButton = new Button(this, SWT.TOGGLE);
|
|
| 193 |
l = new Label(annotationArea, SWT.NONE);
|
|
| 194 |
|
|
| 195 |
editLeftButton = new Button(annotationArea, SWT.TOGGLE);
|
|
| 192 | 196 |
gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false); |
| 193 | 197 |
editLeftButton.setLayoutData(gdata); |
| 194 | 198 |
editLeftButton.setText("[ ↔"); //$NON-NLS-1$
|
| ... | ... | |
| 202 | 206 |
} |
| 203 | 207 |
}); |
| 204 | 208 |
|
| 205 |
editButton = new Button(this, SWT.TOGGLE);
|
|
| 209 |
editButton = new Button(annotationArea, SWT.TOGGLE);
|
|
| 206 | 210 |
editButton.setText("[↔]"); //$NON-NLS-1$
|
| 207 | 211 |
editButton.setToolTipText(Messages.UnitToolbar_14); |
| 208 | 212 |
editButton.addSelectionListener(new SelectionListener() {
|
| ... | ... | |
| 214 | 218 |
} |
| 215 | 219 |
}); |
| 216 | 220 |
|
| 217 |
editRightButton = new Button(this, SWT.TOGGLE);
|
|
| 221 |
editRightButton = new Button(annotationArea, SWT.TOGGLE);
|
|
| 218 | 222 |
editRightButton.setText("↔ ]"); //$NON-NLS-1$
|
| 219 | 223 |
editRightButton.setToolTipText(Messages.UnitToolbar_16); |
| 220 | 224 |
editRightButton.addSelectionListener(new SelectionListener() {
|
| ... | ... | |
| 225 | 229 |
onEditButtonSelected(e,2); |
| 226 | 230 |
} |
| 227 | 231 |
}); |
| 228 |
|
|
| 229 |
toolbarsArea.layout(); |
|
| 230 |
toolbarsArea.getParent().layout(true); |
|
| 231 |
editor.getEditionArea().layout(); |
|
| 232 | 232 |
|
| 233 |
annotationArea.layout(); |
|
| 234 |
annotationArea.getParent().layout(true); |
|
| 235 |
editor.layout(true); |
|
| 236 |
|
|
| 233 | 237 |
reloadUnits(); // reloads types |
| 234 | 238 |
reloadIdentifiants(); |
| 235 | 239 |
|
| ... | ... | |
| 238 | 242 |
editButton.setEnabled(false); |
| 239 | 243 |
editLeftButton.setEnabled(false); |
| 240 | 244 |
editRightButton.setEnabled(false); |
| 241 |
|
|
| 245 |
|
|
| 242 | 246 |
//drop_b.setEnabled(false); |
| 243 | 247 |
if (typesUnitesAVoir.length > 0) {
|
| 244 | 248 |
typeCombo.select(1); |
| ... | ... | |
| 249 | 253 |
|
| 250 | 254 |
ElementPropertiesView.openView(); |
| 251 | 255 |
editor.updateWordStyles(); |
| 256 |
|
|
| 257 |
return true; |
|
| 252 | 258 |
} |
| 253 | 259 |
|
| 254 | 260 |
public void clearHighlight() {
|
| 255 | 261 |
if (previousSelectedUnitIDS != null) {
|
| 256 |
editor.removeHighlightWordsById(selected_unit_color, previousSelectedUnitIDS); |
|
| 257 |
editor.removeFontWeightWordsById(previousSelectedUnitIDS); |
|
| 262 |
if (editor.isDisposed()){
|
|
| 263 |
editor.removeHighlightWordsById(selected_unit_color, previousSelectedUnitIDS); |
|
| 264 |
editor.removeFontWeightWordsById(previousSelectedUnitIDS); |
|
| 265 |
} |
|
| 258 | 266 |
previousSelectedUnitIDS = null; // release memory |
| 259 | 267 |
} |
| 260 | 268 |
if (previousSelectedTypeUnitIDS != null) {
|
| ... | ... | |
| 262 | 270 |
previousSelectedTypeUnitIDS = null; // release memory |
| 263 | 271 |
} |
| 264 | 272 |
|
| 265 |
createButton.setEnabled(false); |
|
| 266 |
deleteButton.setEnabled(false); |
|
| 267 |
editButton.setEnabled(false); |
|
| 273 |
if (!createButton.isDisposed()) createButton.setEnabled(false);
|
|
| 274 |
if (!deleteButton.isDisposed()) deleteButton.setEnabled(false);
|
|
| 275 |
if (!editButton.isDisposed()) editButton.setEnabled(false);
|
|
| 268 | 276 |
//drop_b.setEnabled(false); |
| 269 | 277 |
} |
| 270 | 278 |
|
| ... | ... | |
| 368 | 376 |
} |
| 369 | 377 |
|
| 370 | 378 |
String[] ids = panel.getWordSelection(); // may be null |
| 371 |
|
|
| 379 |
|
|
| 372 | 380 |
if (fixingAnnotationLimits > 0) {
|
| 373 | 381 |
if (debug) System.out.println(" EDITING ANNOTATION POSITION mode="+fixingAnnotationLimits); //$NON-NLS-1$
|
| 374 | 382 |
onFixingAnnotationLimits(ids); |
| ... | ... | |
| 378 | 386 |
if (ids == null) { // clear selection
|
| 379 | 387 |
if (debug) System.out.println(" NO WORD SELECTION"); //$NON-NLS-1$
|
| 380 | 388 |
navigationField.setSelectionIndex(0); // clear selection |
| 381 |
|
|
| 389 |
|
|
| 382 | 390 |
return; |
| 383 | 391 |
} |
| 384 |
|
|
| 392 |
|
|
| 385 | 393 |
org.txm.searchengine.cqp.corpus.Corpus c = UnitToolbar.this.editor.getCorpus(); |
| 386 | 394 |
|
| 387 | 395 |
try {
|
| ... | ... | |
| 445 | 453 |
editRightButton.setSelection(false); |
| 446 | 454 |
fixingAnnotationLimits = 0; |
| 447 | 455 |
typeCombo.setEnabled(true); |
| 448 |
|
|
| 456 |
|
|
| 449 | 457 |
navigationField.setEnabled(true); |
| 450 | 458 |
createButton.setEnabled(true); |
| 451 | 459 |
deleteButton.setEnabled(true); |
| ... | ... | |
| 475 | 483 |
public void keyReleased(KeyEvent e) {
|
| 476 | 484 |
int mask = SWT.CTRL; |
| 477 | 485 |
if (Util.isMac()) mask = SWT.COMMAND; |
| 478 |
|
|
| 486 |
|
|
| 479 | 487 |
if (((e.stateMask & mask) == mask)) {
|
| 480 | 488 |
if (e.keyCode == SWT.SPACE) {
|
| 481 | 489 |
int i = navigationField.getSelectionIndex(); |
| ... | ... | |
| 486 | 494 |
selectPrevious(); |
| 487 | 495 |
} else if (e.keyCode == SWT.ARROW_RIGHT) {
|
| 488 | 496 |
selectNext(); |
| 489 |
// } else if (e.keyCode == SWT.PAGE_UP) { // clash with Eclipse CTRL+PAGE_UP binding
|
|
| 490 |
// select10Previous(); |
|
| 491 |
// } else if (e.keyCode == SWT.PAGE_DOWN) { // clash with Eclipse CTRL+PAGE_DOWN binding
|
|
| 492 |
// select10Next(); |
|
| 497 |
// } else if (e.keyCode == SWT.PAGE_UP) { // clash with Eclipse CTRL+PAGE_UP binding
|
|
| 498 |
// select10Previous();
|
|
| 499 |
// } else if (e.keyCode == SWT.PAGE_DOWN) { // clash with Eclipse CTRL+PAGE_DOWN binding
|
|
| 500 |
// select10Next();
|
|
| 493 | 501 |
} else if (e.keyCode == SWT.END) {
|
| 494 | 502 |
selectLast(); |
| 495 | 503 |
} else if (e.keyCode == SWT.HOME) {
|
| ... | ... | |
| 640 | 648 |
private void highlightUnite(Unite unite, boolean focus, int clickedWordPosition) {
|
| 641 | 649 |
int start = unite.getDeb(); |
| 642 | 650 |
int end = unite.getFin(); |
| 643 |
// System.out.println("HU: start="+start+" end="+end+" -> "+(end-start+1));
|
|
| 651 |
// System.out.println("HU: start="+start+" end="+end+" -> "+(end-start+1));
|
|
| 644 | 652 |
int len = end-start+1; |
| 645 | 653 |
if (len < 0) {
|
| 646 | 654 |
System.out.println("Error: can not highlight unit="+unite+": start > end."); //$NON-NLS-1$ //$NON-NLS-2$
|
| ... | ... | |
| 660 | 668 |
} |
| 661 | 669 |
|
| 662 | 670 |
String ids[] = CQPSearchEngine.getCqiClient().cpos2Str(maincorpus.getProperty("id").getQualifiedName(), positions); //$NON-NLS-1$
|
| 663 |
// System.out.println("Highlight words with ids="+Arrays.toString(ids));
|
|
| 671 |
// System.out.println("Highlight words with ids="+Arrays.toString(ids));
|
|
| 664 | 672 |
|
| 665 | 673 |
//positions = new int[]{positions[0]};
|
| 666 | 674 |
Property text_id = maincorpus.getStructuralUnit("text").getProperty("id"); //$NON-NLS-1$ //$NON-NLS-2$
|
| ... | ... | |
| 673 | 681 |
firstWordId = ids[clickedWordPosition]; |
| 674 | 682 |
firstWordTextId = text_ids[clickedWordPosition]; |
| 675 | 683 |
} |
| 676 |
|
|
| 677 | 684 |
|
| 685 |
|
|
| 678 | 686 |
EditionPanel panel = editor.getEditionPanel(0); |
| 679 | 687 |
Edition e = panel.getEdition(); |
| 680 | 688 |
org.txm.objects.Corpus corpus = e.getText().getCorpus(); |
| 681 |
// System.out.println("firstWordTextId="+firstWordTextId);
|
|
| 689 |
// System.out.println("firstWordTextId="+firstWordTextId);
|
|
| 682 | 690 |
Text newText = corpus.getText(firstWordTextId); // get the new text |
| 683 |
// System.out.println("positions="+Arrays.toString(positions));
|
|
| 684 |
// System.out.println("firstWordId="+firstWordId);
|
|
| 685 |
// System.out.println("firstWordTextId="+firstWordTextId);
|
|
| 686 |
// System.out.println("newText="+newText+" e="+e);
|
|
| 691 |
// System.out.println("positions="+Arrays.toString(positions));
|
|
| 692 |
// System.out.println("firstWordId="+firstWordId);
|
|
| 693 |
// System.out.println("firstWordTextId="+firstWordTextId);
|
|
| 694 |
// System.out.println("newText="+newText+" e="+e);
|
|
| 687 | 695 |
Edition newEdition = newText.getEdition(e.getName()); // get the edition of the new text |
| 688 | 696 |
Page p = newEdition.getPageForWordId(firstWordId); // find out the page containing the word |
| 689 |
// System.out.println("page="+p+" current page="+panel.getCurrentPage());
|
|
| 690 |
|
|
| 697 |
// System.out.println("page="+p+" current page="+panel.getCurrentPage());
|
|
| 698 |
|
|
| 691 | 699 |
previousSelectedUnitIDS = Arrays.asList(ids); |
| 692 | 700 |
editor.addHighlightWordsById(selected_unit_color, previousSelectedUnitIDS); |
| 693 | 701 |
editor.addFontWeightWordsById(EditionPanel.WEIGHT_BOLD, previousSelectedUnitIDS); |
| ... | ... | |
| 734 | 742 |
setFocusInPropertiesView(); |
| 735 | 743 |
editor.fireIsDirty(); |
| 736 | 744 |
} |
| 737 |
|
|
| 745 |
|
|
| 738 | 746 |
if (e != null) editor.updateWordStyles(); |
| 739 | 747 |
} |
| 740 | 748 |
|
| ... | ... | |
| 758 | 766 |
highlightType(); |
| 759 | 767 |
} |
| 760 | 768 |
editor.fireIsDirty(); |
| 761 |
|
|
| 769 |
|
|
| 762 | 770 |
if (e != null) editor.updateWordStyles(); |
| 763 | 771 |
} |
| 764 | 772 |
|
| ... | ... | |
| 814 | 822 |
previousSelectedUnitIDS = null; // release memory |
| 815 | 823 |
} |
| 816 | 824 |
highlightType(); |
| 817 |
|
|
| 825 |
|
|
| 818 | 826 |
clearPropertiesView(); // unload the selected element if any |
| 819 | 827 |
createButton.setEnabled(false); |
| 820 | 828 |
deleteButton.setEnabled(false); |
| ... | ... | |
| 843 | 851 |
editRightButton.setEnabled(true); |
| 844 | 852 |
//drop_b.setEnabled(true); |
| 845 | 853 |
} |
| 846 |
|
|
| 854 |
|
|
| 847 | 855 |
if (e != null) editor.updateWordStyles(); |
| 848 | 856 |
} |
| 849 | 857 |
|
| ... | ... | |
| 920 | 928 |
|
| 921 | 929 |
@Override |
| 922 | 930 |
public void traiterEvent(Message e) {
|
| 923 |
if (this.isDisposed()) return;
|
|
| 931 |
if (annotationArea.isDisposed()) return;
|
|
| 924 | 932 |
|
| 925 | 933 |
if (e.getType().equals(TypeMessage.MODIF_STRUCTURE)) {
|
| 926 | 934 |
//System.out.println("UnitToolbar.traiterEvent: Update toolbar ");
|
| 927 |
UnitToolbar.this.getDisplay().syncExec(new Runnable() {
|
|
| 935 |
UnitToolbar.this.annotationArea.getDisplay().syncExec(new Runnable() {
|
|
| 928 | 936 |
@Override |
| 929 | 937 |
public void run() {
|
| 930 | 938 |
setEnable(!analecCorpus.isVide()); |
| ... | ... | |
| 933 | 941 |
}); |
| 934 | 942 |
} else if (e.getType().equals(TypeMessage.MODIF_ELEMENT)) {
|
| 935 | 943 |
//System.out.println("UnitToolbar.traiterEvent: Update toolbar ");
|
| 936 |
UnitToolbar.this.getDisplay().syncExec(new Runnable() {
|
|
| 944 |
UnitToolbar.this.annotationArea.getDisplay().syncExec(new Runnable() {
|
|
| 937 | 945 |
@Override |
| 938 | 946 |
public void run() {
|
| 939 | 947 |
//reloadUnits(); |
| ... | ... | |
| 989 | 997 |
highlightUnite(unite, true, offset); |
| 990 | 998 |
|
| 991 | 999 |
updatePropertiesView(unite); |
| 992 |
|
|
| 1000 |
|
|
| 993 | 1001 |
return true; |
| 994 | 1002 |
} |
| 995 | 1003 |
|
| 996 |
|
|
| 1004 |
|
|
| 997 | 1005 |
navigationField.setSelectionIndex(0); |
| 998 |
|
|
| 1006 |
|
|
| 999 | 1007 |
return false; |
| 1000 | 1008 |
} |
| 1001 | 1009 |
|
| ... | ... | |
| 1065 | 1073 |
|
| 1066 | 1074 |
@Override |
| 1067 | 1075 |
public void onBackToText(Text text, String id) {
|
| 1068 |
if (id.length() > 0) |
|
| 1076 |
if (id.length() > 0) {
|
|
| 1069 | 1077 |
try {
|
| 1070 | 1078 |
tryHighlightingUnitsWord(id, this.getCQPCorpus()); |
| 1071 | 1079 |
} catch (CqiClientException e) {
|
| 1072 | 1080 |
// TODO Auto-generated catch block |
| 1073 | 1081 |
e.printStackTrace(); |
| 1074 | 1082 |
} |
| 1083 |
} |
|
| 1075 | 1084 |
} |
| 1085 |
|
|
| 1086 |
@Override |
|
| 1087 |
public Class<? extends TXMResult> getAnnotatedTXMResultClass() {
|
|
| 1088 |
return Text.class; |
|
| 1089 |
} |
|
| 1090 |
|
|
| 1091 |
@Override |
|
| 1092 |
public boolean save() {
|
|
| 1093 |
return AnalecCorpora.saveCorpus(analecCorpus); |
|
| 1094 |
} |
|
| 1095 |
|
|
| 1096 |
@Override |
|
| 1097 |
public String getName() {
|
|
| 1098 |
return "Unit"; |
|
| 1099 |
} |
|
| 1100 |
|
|
| 1101 |
@Override |
|
| 1102 |
public boolean notifyStartOfCompute() throws Exception {
|
|
| 1103 |
// TODO Auto-generated method stub |
|
| 1104 |
return false; |
|
| 1105 |
} |
|
| 1106 |
|
|
| 1107 |
@Override |
|
| 1108 |
public boolean notifyEndOfCompute() throws Exception {
|
|
| 1109 |
// TODO Auto-generated method stub |
|
| 1110 |
return false; |
|
| 1111 |
} |
|
| 1112 |
|
|
| 1113 |
@Override |
|
| 1114 |
public void notifyEndOfRefresh() throws Exception {
|
|
| 1115 |
// TODO Auto-generated method stub |
|
| 1116 |
|
|
| 1117 |
} |
|
| 1118 |
|
|
| 1119 |
@Override |
|
| 1120 |
public void notifyStartOfCreatePartControl() throws Exception {
|
|
| 1121 |
// TODO Auto-generated method stub |
|
| 1122 |
|
|
| 1123 |
} |
|
| 1124 |
|
|
| 1125 |
@Override |
|
| 1126 |
public void notifyStartOfRefresh() throws Exception {
|
|
| 1127 |
// TODO Auto-generated method stub |
|
| 1128 |
|
|
| 1129 |
} |
|
| 1076 | 1130 |
} |
| tmp/org.txm.analec.rcp/src/org/txm/analec/toolbar/SchemaToolbar.java (revision 853) | ||
|---|---|---|
| 16 | 16 |
import org.eclipse.swt.events.SelectionEvent; |
| 17 | 17 |
import org.eclipse.swt.events.SelectionListener; |
| 18 | 18 |
import org.eclipse.swt.layout.GridData; |
| 19 |
import org.eclipse.swt.layout.GridLayout; |
|
| 20 | 19 |
import org.eclipse.swt.widgets.Button; |
| 21 | 20 |
import org.eclipse.swt.widgets.Combo; |
| 22 | 21 |
import org.eclipse.swt.widgets.Composite; |
| ... | ... | |
| 26 | 25 |
import org.eclipse.swt.widgets.Listener; |
| 27 | 26 |
import org.eclipse.swt.widgets.Menu; |
| 28 | 27 |
import org.eclipse.swt.widgets.MenuItem; |
| 29 |
import org.txm.Toolbox; |
|
| 30 |
import org.txm.analec.preferences.AnalecPreferencePage; |
|
| 28 |
import org.txm.analec.AnalecCorpora; |
|
| 31 | 29 |
import org.txm.analec.preferences.AnalecPreferences; |
| 32 |
import org.txm.analec.toolbarbutton.StartButton; |
|
| 33 | 30 |
import org.txm.analec.view.ElementPropertiesView; |
| 34 | 31 |
import org.txm.analec.widgets.NavigationField; |
| 32 |
import org.txm.annotation.rcp.editor.AnnotationExtension; |
|
| 35 | 33 |
import org.txm.core.preferences.TXMPreferences; |
| 34 |
import org.txm.core.results.TXMResult; |
|
| 36 | 35 |
import org.txm.edition.rcp.editors.EditionPanel; |
| 37 | 36 |
import org.txm.edition.rcp.editors.RGBA; |
| 38 | 37 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
| ... | ... | |
| 40 | 39 |
import org.txm.objects.Page; |
| 41 | 40 |
import org.txm.objects.Text; |
| 42 | 41 |
import org.txm.rcp.IImageKeys; |
| 43 |
import org.txm.rcp.TxmPreferences;
|
|
| 42 |
import org.txm.rcp.editors.TXMEditor;
|
|
| 44 | 43 |
import org.txm.rcp.swt.dialog.ConfirmDialog; |
| 45 | 44 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
| 46 | 45 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| ... | ... | |
| 52 | 51 |
|
| 53 | 52 |
import visuAnalec.Message; |
| 54 | 53 |
import visuAnalec.Message.TypeMessage; |
| 55 |
import visuAnalec.donnees.Corpus; |
|
| 56 | 54 |
import visuAnalec.elements.Element; |
| 57 | 55 |
import visuAnalec.elements.Schema; |
| 58 | 56 |
import visuAnalec.elements.Unite; |
| 59 |
import visuAnalec.vue.Vue; |
|
| 60 | 57 |
|
| 61 | 58 |
public class SchemaToolbar extends URSAnnotationToolbar {
|
| 62 | 59 |
|
| ... | ... | |
| 86 | 83 |
// private Combo unitTypeCombo; |
| 87 | 84 |
private NavigationField subNavigationField; |
| 88 | 85 |
|
| 89 |
public SchemaToolbar(Composite toolbarsArea, StartButton button, int style, SynopticEditionEditor syneditor, Corpus analecCorpus, Vue vue) {
|
|
| 90 |
super(toolbarsArea, "Unit", button, style); |
|
| 86 |
public SchemaToolbar() { }
|
|
| 87 |
|
|
| 88 |
@Override |
|
| 89 |
public boolean install(TXMEditor<? extends TXMResult> txmeditor, AnnotationExtension extension, Composite parent) throws Exception {
|
|
| 90 |
super.install(txmeditor, extension, parent); |
|
| 91 | 91 |
|
| 92 |
annotationArea.getLayout().numColumns = 7; |
|
| 93 |
annotationArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
|
| 94 |
|
|
| 92 | 95 |
String color_palette = TXMPreferences.getString(AnalecPreferences.COLOR_PALETTE, AnalecPreferences.PREFERENCES_NODE); |
| 93 | 96 |
if ("yellow".equals(color_palette)) { //$NON-NLS-1$
|
| 94 | 97 |
this.highlighted_unit_color = URSAnnotationToolbar.lightyellow; |
| ... | ... | |
| 104 | 107 |
|
| 105 | 108 |
} |
| 106 | 109 |
|
| 107 |
this.editor = syneditor; |
|
| 108 |
this.analecCorpus = analecCorpus; |
|
| 110 |
this.editor = (SynopticEditionEditor) txmeditor; |
|
| 109 | 111 |
analecCorpus.addEventListener(this); |
| 110 |
this.vue = vue; |
|
| 111 |
this.getLayout().numColumns = 7; |
|
| 112 |
this.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); |
|
| 113 | 112 |
|
| 114 |
l = new Label(this, SWT.NONE);
|
|
| 113 |
l = new Label(annotationArea, SWT.NONE);
|
|
| 115 | 114 |
l.setText("Type de schéma : ");
|
| 116 | 115 |
l.setToolTipText("Type de schéma");
|
| 117 | 116 |
|
| 118 | 117 |
this.maincorpus = this.editor.getCorpus().getMainCorpus(); |
| 119 |
typeCombo = new Combo(this, SWT.NONE|SWT.READ_ONLY);
|
|
| 118 |
typeCombo = new Combo(annotationArea, SWT.NONE|SWT.READ_ONLY);
|
|
| 120 | 119 |
typeCombo.setToolTipText("Type de schéma");
|
| 121 | 120 |
GridData gdata = new GridData(GridData.FILL, GridData.CENTER, false, false); |
| 122 | 121 |
gdata.minimumWidth = 100; |
| ... | ... | |
| 142 | 141 |
} |
| 143 | 142 |
}); |
| 144 | 143 |
|
| 145 |
deleteSchemaButton = new Button(this, SWT.PUSH);
|
|
| 144 |
deleteSchemaButton = new Button(annotationArea, SWT.PUSH);
|
|
| 146 | 145 |
deleteSchemaButton.setImage(IImageKeys.getImage("platform:/plugin/org.txm.rcp/icons/cross.png")); //$NON-NLS-1$
|
| 147 | 146 |
deleteSchemaButton.setToolTipText("Supprimer le schéma");
|
| 148 | 147 |
deleteSchemaButton.setEnabled(false); |
| ... | ... | |
| 155 | 154 |
} |
| 156 | 155 |
}); |
| 157 | 156 |
|
| 158 |
l = new Label(this, SWT.NONE);
|
|
| 157 |
l = new Label(annotationArea, SWT.NONE);
|
|
| 159 | 158 |
l.setText("Unités :");
|
| 160 | 159 |
subNavigationField = new NavigationField(this, SWT.NONE); |
| 161 | 160 |
gdata = new GridData(GridData.FILL, GridData.FILL, true, false); |
| ... | ... | |
| 167 | 166 |
} |
| 168 | 167 |
}); |
| 169 | 168 |
|
| 170 |
deleteUniteButton = new Button(this, SWT.PUSH);
|
|
| 169 |
deleteUniteButton = new Button(annotationArea, SWT.PUSH);
|
|
| 171 | 170 |
deleteUniteButton.setImage(IImageKeys.getImage("platform:/plugin/org.txm.rcp/icons/cross.png")); //$NON-NLS-1$
|
| 172 | 171 |
deleteUniteButton.setToolTipText("Supprimer l'unité de la chaîne");
|
| 173 | 172 |
deleteUniteButton.setEnabled(false); |
| ... | ... | |
| 180 | 179 |
} |
| 181 | 180 |
}); |
| 182 | 181 |
|
| 183 |
toolbarsArea.layout();
|
|
| 184 |
toolbarsArea.getParent().layout(true);
|
|
| 182 |
annotationArea.layout();
|
|
| 183 |
annotationArea.getParent().layout(true);
|
|
| 185 | 184 |
editor.getEditionArea().layout(); |
| 186 | 185 |
|
| 187 | 186 |
reloadTypeSchemas(); // reloads ids also |
| ... | ... | |
| 205 | 204 |
// editButton.setEnabled(false); |
| 206 | 205 |
editor.updateWordStyles(); |
| 207 | 206 |
ElementPropertiesView.openView(); |
| 207 |
|
|
| 208 |
return true; |
|
| 208 | 209 |
} |
| 209 | 210 |
|
| 210 | 211 |
protected void testIfAwordSpanIsSelected() {
|
| ... | ... | |
| 244 | 245 |
previousSelectedUniteIDS = null; // release memory |
| 245 | 246 |
} |
| 246 | 247 |
|
| 247 |
deleteUniteButton.setEnabled(false); |
|
| 248 |
if (!deleteUniteButton.isDisposed()) deleteUniteButton.setEnabled(false);
|
|
| 248 | 249 |
} |
| 249 | 250 |
|
| 250 | 251 |
public MouseListener getEditorClickListener() {
|
| ... | ... | |
| 777 | 778 |
|
| 778 | 779 |
@Override |
| 779 | 780 |
public void traiterEvent(Message e) {
|
| 780 |
if (this.isDisposed()) return;
|
|
| 781 |
if (annotationArea.isDisposed()) return;
|
|
| 781 | 782 |
|
| 782 | 783 |
if (e.getType().equals(TypeMessage.MODIF_STRUCTURE)) {
|
| 783 | 784 |
//System.out.println("SchemaToolbar.traiterEvent: Update toolbar ");
|
| 784 |
SchemaToolbar.this.getDisplay().syncExec(new Runnable() {
|
|
| 785 |
SchemaToolbar.this.annotationArea.getDisplay().syncExec(new Runnable() {
|
|
| 785 | 786 |
@Override |
| 786 | 787 |
public void run() {
|
| 787 | 788 |
setEnable(!analecCorpus.isVide()); |
| ... | ... | |
| 790 | 791 |
}); |
| 791 | 792 |
} else if (e.getType().equals(TypeMessage.MODIF_ELEMENT)) {
|
| 792 | 793 |
//System.out.println("SchemaToolbar.traiterEvent: Update toolbar ");
|
| 793 |
SchemaToolbar.this.getDisplay().syncExec(new Runnable() {
|
|
| 794 |
SchemaToolbar.this.annotationArea.getDisplay().syncExec(new Runnable() {
|
|
| 794 | 795 |
@Override |
| 795 | 796 |
public void run() {
|
| 796 | 797 |
//reloadUnits(); |
| ... | ... | |
| 930 | 931 |
// TODO Auto-generated method stub |
| 931 | 932 |
|
| 932 | 933 |
} |
| 934 |
|
|
| 935 |
@Override |
|
| 936 |
public Class<? extends TXMResult> getAnnotatedTXMResultClass() {
|
|
| 937 |
return Text.class; |
|
| 938 |
} |
|
| 939 |
|
|
| 940 |
@Override |
|
| 941 |
public boolean save() {
|
|
| 942 |
return AnalecCorpora.saveCorpus(analecCorpus); |
|
| 943 |
} |
|
| 944 |
|
|
| 945 |
@Override |
|
| 946 |
public String getName() {
|
|
| 947 |
return "Schema annotation"; |
|
| 948 |
} |
|
| 949 |
|
|
| 950 |
@Override |
|
| 951 |
public boolean notifyStartOfCompute() throws Exception {
|
|
| 952 |
// TODO Auto-generated method stub |
|
| 953 |
return false; |
|
| 954 |
} |
|
| 955 |
|
|
| 956 |
@Override |
|
| 957 |
public boolean notifyEndOfCompute() throws Exception {
|
|
| 958 |
// TODO Auto-generated method stub |
|
| 959 |
return false; |
|
| 960 |
} |
|
| 961 |
|
|
| 962 |
@Override |
|
| 963 |
public void notifyEndOfRefresh() throws Exception {
|
|
| 964 |
// TODO Auto-generated method stub |
|
| 965 |
|
|
| 966 |
} |
|
| 967 |
|
|
| 968 |
@Override |
|
| 969 |
public void notifyStartOfCreatePartControl() throws Exception {
|
|
| 970 |
// TODO Auto-generated method stub |
|
| 971 |
|
|
| 972 |
} |
|
| 973 |
|
|
| 974 |
@Override |
|
| 975 |
public void notifyStartOfRefresh() throws Exception {
|
|
| 976 |
// TODO Auto-generated method stub |
|
| 977 |
|
|
| 978 |
} |
|
| 933 | 979 |
} |
| tmp/org.txm.analec.rcp/src/org/txm/analec/toolbar/URSAnnotationToolbar.java (revision 853) | ||
|---|---|---|
| 3 | 3 |
import java.util.List; |
| 4 | 4 |
|
| 5 | 5 |
import org.apache.commons.lang.StringUtils; |
| 6 |
import org.eclipse.swt.SWT; |
|
| 6 | 7 |
import org.eclipse.swt.events.KeyListener; |
| 7 | 8 |
import org.eclipse.swt.events.MenuListener; |
| 8 | 9 |
import org.eclipse.swt.events.MouseListener; |
| 9 | 10 |
import org.eclipse.swt.widgets.Composite; |
| 10 |
import org.txm.analec.toolbarbutton.StartButton; |
|
| 11 |
import org.eclipse.swt.widgets.ToolItem; |
|
| 12 |
import org.txm.analec.AnalecCorpora; |
|
| 13 |
import org.txm.analec.toolbarbutton.Messages; |
|
| 11 | 14 |
import org.txm.analec.view.ElementPropertiesView; |
| 15 |
import org.txm.analec.view.ElementSearchView; |
|
| 16 |
import org.txm.annotation.rcp.editor.AnnotationArea; |
|
| 17 |
import org.txm.annotation.rcp.editor.AnnotationExtension; |
|
| 18 |
import org.txm.core.results.TXMResult; |
|
| 12 | 19 |
import org.txm.edition.rcp.editors.EditionPanel; |
| 13 | 20 |
import org.txm.edition.rcp.editors.RGBA; |
| 14 | 21 |
import org.txm.edition.rcp.editors.SynopticEditionEditor; |
| 15 | 22 |
import org.txm.objects.Text; |
| 23 |
import org.txm.rcp.editors.TXMEditor; |
|
| 16 | 24 |
import org.txm.rcp.swt.GLComposite; |
| 25 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 17 | 26 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
| 18 | 27 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 19 | 28 |
import org.txm.searchengine.cqp.corpus.QueryResult; |
| ... | ... | |
| 21 | 30 |
import org.txm.searchengine.cqp.corpus.query.Query; |
| 22 | 31 |
import org.txm.utils.logger.Log; |
| 23 | 32 |
|
| 33 |
import visuAnalec.Message; |
|
| 34 |
import visuAnalec.Message.TypeMessage; |
|
| 24 | 35 |
import visuAnalec.donnees.Corpus; |
| 25 | 36 |
import visuAnalec.donnees.Corpus.CorpusListener; |
| 26 | 37 |
import visuAnalec.elements.Element; |
| 38 |
import visuAnalec.elements.Unite; |
|
| 27 | 39 |
import visuAnalec.vue.Vue; |
| 28 | 40 |
|
| 29 |
public abstract class URSAnnotationToolbar extends GLComposite implements CorpusListener {
|
|
| 30 |
|
|
| 41 |
public abstract class URSAnnotationToolbar extends AnnotationArea implements CorpusListener {
|
|
| 42 |
|
|
| 31 | 43 |
//see https://groupes.renater.fr/wiki/txm-info/public/specs_charte_graphique |
| 32 | 44 |
public static final RGBA blue = new RGBA(152, 159, 201, 0.7f); |
| 33 | 45 |
public static final RGBA lightblue = new RGBA(185, 193, 239, 0.4f); |
| ... | ... | |
| 35 | 47 |
public static final RGBA lightgreen = new RGBA(206, 240, 83, 0.5f); |
| 36 | 48 |
public static final RGBA yellow = new RGBA(255,255,50, 1f); |
| 37 | 49 |
public static final RGBA lightyellow = new RGBA(255,255,176, 0.5f); |
| 38 |
|
|
| 50 |
|
|
| 39 | 51 |
protected Corpus analecCorpus; |
| 40 | 52 |
protected Vue vue; |
| 41 | 53 |
protected MainCorpus maincorpus; |
| 42 | 54 |
protected SynopticEditionEditor editor; |
| 43 |
protected StartButton button; |
|
| 44 |
|
|
| 45 |
public URSAnnotationToolbar(Composite parent, String name, StartButton button, int style) {
|
|
| 46 |
super(parent, style, name); |
|
| 47 |
this.button = button; |
|
| 48 |
} |
|
| 49 |
|
|
| 55 |
protected ToolItem button; |
|
| 56 |
|
|
| 57 |
public URSAnnotationToolbar() { }
|
|
| 58 |
|
|
| 50 | 59 |
public abstract void selectFirst(); |
| 51 | 60 |
public abstract void selectPrevious(); |
| 52 | 61 |
public abstract void select10Previous(); |
| ... | ... | |
| 55 | 64 |
public abstract void selectLast(); |
| 56 | 65 |
public abstract void select(Element currentElement); |
| 57 | 66 |
|
| 67 |
@Override |
|
| 68 |
public boolean install(TXMEditor<? extends TXMResult> txmeditor, AnnotationExtension extension, Composite parent) throws Exception {
|
|
| 69 |
|
|
| 70 |
this.editor = (SynopticEditionEditor) txmeditor; |
|
| 71 |
this.maincorpus = (MainCorpus) this.editor.getCorpus(); |
|
| 72 |
analecCorpus = AnalecCorpora.getCorpus(maincorpus.getName()); |
|
| 73 |
vue = AnalecCorpora.getVue(maincorpus.getName()); |
|
| 74 |
|
|
| 75 |
annotationArea = new GLComposite(parent, SWT.NONE, "Unit annotation"); |
|
| 76 |
|
|
| 77 |
if (getEditorClickListener() != null) |
|
| 78 |
editor.getEditionPanel(0).getBrowser().addMouseListener(getEditorClickListener()); |
|
| 79 |
if (getMenuListener() != null) |
|
| 80 |
editor.getEditionPanel(0).getBrowser().getMenu().addMenuListener(getMenuListener()); |
|
| 81 |
if (getEditorKeyListener() != null) |
|
| 82 |
editor.getEditionPanel(0).getBrowser().addKeyListener(getEditorKeyListener()); |
|
| 83 |
|
|
| 84 |
if (analecCorpus.getStructure().isVide()) {
|
|
| 85 |
analecCorpus.ajouterType(Unite.class, "Entity"); |
|
| 86 |
analecCorpus.ajouterProp(Unite.class, "Entity", "Property"); |
|
| 87 |
} |
|
| 88 |
|
|
| 89 |
button = extension.getSaveButton(); |
|
| 90 |
button.setEnabled(analecCorpus.isModifie()); |
|
| 91 |
return true; |
|
| 92 |
} |
|
| 93 |
|
|
| 94 |
|
|
| 58 | 95 |
public Corpus getAnalecCorpus() {
|
| 59 | 96 |
return analecCorpus; |
| 60 | 97 |
} |
| 61 |
|
|
| 98 |
|
|
| 62 | 99 |
protected void updatePropertiesView(Element element) {
|
| 63 | 100 |
ElementPropertiesView view = ElementPropertiesView.openView(); |
| 64 | 101 |
if (view != null) view.loadElement(this.maincorpus, this.analecCorpus, element, this); |
| 65 | 102 |
} |
| 66 |
|
|
| 103 |
|
|
| 104 |
public boolean isDirty() {
|
|
| 105 |
if (analecCorpus != null) return analecCorpus.isModifie(); |
|
| 106 |
return false; |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
public boolean isDisposed() {
|
|
| 110 |
return annotationArea == null || annotationArea.isDisposed(); |
|
| 111 |
} |
|
| 112 |
|
|
| 67 | 113 |
protected void clearPropertiesView() {
|
| 68 | 114 |
ElementPropertiesView view = ElementPropertiesView.openView(); |
| 69 | 115 |
if (view != null) {
|
| 70 | 116 |
view.unloadElement(this.analecCorpus, this); |
| 71 | 117 |
} |
| 72 | 118 |
} |
| 73 |
|
|
| 119 |
|
|
| 74 | 120 |
protected static void setFocusInPropertiesView() {
|
| 75 | 121 |
ElementPropertiesView view = ElementPropertiesView.openView(); |
| 76 | 122 |
if (view != null) {
|
| 77 | 123 |
view.setFocusOnProperty(); |
| 78 | 124 |
} |
| 79 | 125 |
} |
| 80 |
|
|
| 126 |
|
|
| 81 | 127 |
protected int[] getSelectionStartEndWordPositions() {
|
| 82 | 128 |
EditionPanel panel = this.editor.getEditionPanel(0); |
| 83 | 129 |
String text_name = panel.getEdition().getText().getName(); |
| 84 | 130 |
String[] sel = panel.getWordSelection(); |
| 85 | 131 |
if (sel == null) {
|
| 86 |
Log.info(Messages.AnnotationToolbar_0);
|
|
| 132 |
Log.info("Error: no word selection");
|
|
| 87 | 133 |
return null; |
| 88 | 134 |
} |
| 89 | 135 |
//System.out.println("Selection="+sel);
|
| ... | ... | |
| 94 | 140 |
} |
| 95 | 141 |
return null; |
| 96 | 142 |
} |
| 97 |
|
|
| 143 |
|
|
| 98 | 144 |
protected int[] getStartEndWordPositions(MainCorpus c, String[] ids, String text_name) throws CqiClientException {
|
| 99 | 145 |
//System.out.println("IDS="+Arrays.toString(ids));
|
| 100 | 146 |
Query query = new Query("[_.text_id=\""+text_name+"\" & id=\""+StringUtils.join(ids, "|")+"\"]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
| ... | ... | |
| 109 | 155 |
// |
| 110 | 156 |
// } |
| 111 | 157 |
if (matches.size() == 0) {
|
| 112 |
System.out.println(Messages.AnnotationToolbar_6+matches.size()+Messages.AnnotationToolbar_7+query);
|
|
| 158 |
System.out.println("Error: no match for query="+query);
|
|
| 113 | 159 |
return null; |
| 114 | 160 |
} else {
|
| 115 | 161 |
start = matches.get(0).getStart(); |
| ... | ... | |
| 118 | 164 |
result.drop(); |
| 119 | 165 |
return new int[]{start, end};
|
Formats disponibles : Unified diff