Révision 2550
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/actions/CreateSubcorpusDialog.java (revision 2550) | ||
|---|---|---|
| 30 | 30 |
import java.util.List; |
| 31 | 31 |
|
| 32 | 32 |
import org.eclipse.jface.dialogs.Dialog; |
| 33 |
import org.eclipse.jface.dialogs.IDialogConstants; |
|
| 33 | 34 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 34 | 35 |
import org.eclipse.swt.SWT; |
| 35 | 36 |
import org.eclipse.swt.events.SelectionEvent; |
| ... | ... | |
| 168 | 169 |
// First tab |
| 169 | 170 |
TabItem simpleTab = new TabItem(tabFolder, SWT.NONE); |
| 170 | 171 |
simpleTab.setText(TXMUIMessages.simple); |
| 171 |
simplePanel = new SimpleSubcorpusPanel(tabFolder, SWT.NONE, this, corpus); |
|
| 172 |
simplePanel = new SimpleSubcorpusPanel(tabFolder, SWT.NONE, this.getButton(IDialogConstants.OK_ID), corpus);
|
|
| 172 | 173 |
simpleTab.setControl(simplePanel); |
| 173 | 174 |
|
| 174 | 175 |
// Second tab: assisted mode |
| ... | ... | |
| 229 | 230 |
|
| 230 | 231 |
@Override |
| 231 | 232 |
public Button getButton(int id) {
|
| 232 |
return this.getButton(id);
|
|
| 233 |
return super.getButton(id);
|
|
| 233 | 234 |
} |
| 234 | 235 |
|
| 235 | 236 |
/* |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 2550) | ||
|---|---|---|
| 200 | 200 |
public void widgetSelected(SelectionEvent e) {
|
| 201 | 201 |
if (e.doit) {
|
| 202 | 202 |
setVisible(groupTitle, openCloseButton.getSelection()); |
| 203 |
selectionListener.widgetSelected(e); |
|
| 203 | 204 |
} |
| 204 | 205 |
} |
| 205 | 206 |
|
| ... | ... | |
| 208 | 209 |
}); |
| 209 | 210 |
|
| 210 | 211 |
org.txm.rcp.swt.listeners.DropdownSelectionListener listenerOne = openCloseButton.getDropDownListener(); |
| 211 |
listenerOne.setDefaultSelectionListener(selectionListener); |
|
| 212 |
//listenerOne.setDefaultSelectionListener(selectionListener);
|
|
| 212 | 213 |
for (int i = 0 ; i < modes.size() && i < modeSelectionListeners.size(); i++) {
|
| 213 | 214 |
MenuItem item1 = new MenuItem(listenerOne.getMenu(), SWT.PUSH); |
| 214 | 215 |
item1.setText(modes.get(i)); |
| ... | ... | |
| 334 | 335 |
c.setEnabled(enabled); |
| 335 | 336 |
} |
| 336 | 337 |
} |
| 337 |
|
|
| 338 |
|
|
| 339 |
public boolean isVisible(String id) {
|
|
| 340 |
if (!groups.containsKey(id)) return false; |
|
| 341 |
|
|
| 342 |
if (groups.get(id).isDisposed()) return false; |
|
| 343 |
|
|
| 344 |
return groups.get(id).isVisible(); |
|
| 345 |
} |
|
| 338 | 346 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/toolbar/DropDownCheckToolItem.java (revision 2550) | ||
|---|---|---|
| 53 | 53 |
return; // drop down clicked |
| 54 | 54 |
} |
| 55 | 55 |
selected = !selected; |
| 56 |
if (closeIcon != null) {
|
|
| 57 |
if (getSelection()) {
|
|
| 58 |
setImage(closeIcon); |
|
| 59 |
} else {
|
|
| 60 |
setImage(openIcon); |
|
| 61 |
} |
|
| 62 |
} |
|
| 56 |
updateIcon(); |
|
| 63 | 57 |
} |
| 64 | 58 |
|
| 65 | 59 |
@Override |
| ... | ... | |
| 70 | 64 |
this.addSelectionListener(listener); |
| 71 | 65 |
} |
| 72 | 66 |
|
| 67 |
public void updateIcon() {
|
|
| 68 |
if (closeIcon != null) {
|
|
| 69 |
if (getSelection()) {
|
|
| 70 |
setImage(closeIcon); |
|
| 71 |
} else {
|
|
| 72 |
setImage(openIcon); |
|
| 73 |
} |
|
| 74 |
} |
|
| 75 |
} |
|
| 76 |
|
|
| 73 | 77 |
public boolean getSelection() {
|
| 74 | 78 |
return selected; |
| 75 | 79 |
} |
| ... | ... | |
| 80 | 84 |
|
| 81 | 85 |
public void setSelection(boolean selected) {
|
| 82 | 86 |
this.selected = selected; |
| 87 |
updateIcon(); |
|
| 83 | 88 |
} |
| 84 | 89 |
|
| 85 | 90 |
@Override |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/SimpleSubcorpusPanel.java (revision 2550) | ||
|---|---|---|
| 14 | 14 |
import org.eclipse.swt.events.SelectionListener; |
| 15 | 15 |
import org.eclipse.swt.layout.GridData; |
| 16 | 16 |
import org.eclipse.swt.layout.GridLayout; |
| 17 |
import org.eclipse.swt.widgets.Button; |
|
| 17 | 18 |
import org.eclipse.swt.widgets.Combo; |
| 18 | 19 |
import org.eclipse.swt.widgets.Composite; |
| 19 | 20 |
import org.eclipse.swt.widgets.Label; |
| ... | ... | |
| 24 | 25 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 25 | 26 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
| 26 | 27 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
| 28 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
| 29 |
import org.txm.searchengine.cqp.corpus.query.SubcorpusCQLQuery; |
|
| 27 | 30 |
import org.txm.utils.logger.Log; |
| 28 | 31 |
|
| 29 | 32 |
public class SimpleSubcorpusPanel extends Composite {
|
| ... | ... | |
| 36 | 39 |
Combo structuralUnitsCombo; |
| 37 | 40 |
Combo propertyCombo; |
| 38 | 41 |
ListViewer valueCombo; |
| 39 |
|
|
| 42 |
|
|
| 40 | 43 |
List<StructuralUnit> structuralUnitsFinal; |
| 41 |
private CreateSubcorpusDialog dialog;
|
|
| 44 |
private Button validationButton;
|
|
| 42 | 45 |
private CQPCorpus corpus; |
| 43 | 46 |
|
| 44 |
public SimpleSubcorpusPanel(Composite parent, int style, CreateSubcorpusDialog dialog, CQPCorpus corpus) {
|
|
| 47 |
public SimpleSubcorpusPanel(Composite parent, int style, Button validationButton, CQPCorpus corpus) {
|
|
| 45 | 48 |
super(parent, style); |
| 46 | 49 |
|
| 47 |
this.dialog = dialog;
|
|
| 50 |
this.validationButton = validationButton;
|
|
| 48 | 51 |
this.corpus = corpus; |
| 49 | 52 |
|
| 50 | 53 |
GridLayout layout = new GridLayout(2, false); |
| ... | ... | |
| 71 | 74 |
|
| 72 | 75 |
valueCombo = new ListViewer(this, SWT.MULTI |SWT.V_SCROLL | SWT.BORDER | SWT.VIRTUAL); |
| 73 | 76 |
valueCombo.setContentProvider(new ArrayContentProvider()); |
| 74 |
// valueCombo.setLabelProvider(new LabelProvider() {
|
|
| 75 |
// |
|
| 76 |
// @Override |
|
| 77 |
// public String getText(Object element) {
|
|
| 78 |
// return Activator.getSomeService().key2Value((Integer) element); |
|
| 79 |
// } |
|
| 80 |
// |
|
| 81 |
// }); |
|
| 77 |
// valueCombo.setLabelProvider(new LabelProvider() {
|
|
| 78 |
//
|
|
| 79 |
// @Override
|
|
| 80 |
// public String getText(Object element) {
|
|
| 81 |
// return Activator.getSomeService().key2Value((Integer) element);
|
|
| 82 |
// }
|
|
| 83 |
//
|
|
| 84 |
// });
|
|
| 82 | 85 |
GridData data = new GridData(GridData.FILL,GridData.FILL, true, false); |
| 83 | 86 |
data.heightHint = 100; |
| 84 | 87 |
valueCombo.getList().setLayoutData(data); |
| 85 |
|
|
| 86 | 88 |
|
| 89 |
|
|
| 87 | 90 |
// Load StructuralUnit |
| 88 | 91 |
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 89 | 92 |
List<StructuralUnit> structuralUnits = null; |
| ... | ... | |
| 108 | 111 |
} |
| 109 | 112 |
|
| 110 | 113 |
if (structuralUnitsCombo.getItemCount() == 0) {
|
| 111 |
dialog.getButton(IDialogConstants.OK_ID).setEnabled(false); |
|
| 114 |
if(validationButton != null) {
|
|
| 115 |
validationButton.setEnabled(false); |
|
| 116 |
} |
|
| 112 | 117 |
} else {
|
| 113 | 118 |
String[] items = structuralUnitsCombo.getItems(); |
| 114 | 119 |
structuralUnitsCombo.select(0); |
| ... | ... | |
| 165 | 170 |
selectedValues = ((IStructuredSelection)sel).toList(); |
| 166 | 171 |
} |
| 167 | 172 |
} |
| 168 |
|
|
| 173 |
|
|
| 169 | 174 |
@Override |
| 170 | 175 |
public void widgetDefaultSelected(SelectionEvent e) {
|
| 171 | 176 |
// TODO Auto-generated method stub |
| 172 |
|
|
| 177 |
|
|
| 173 | 178 |
} |
| 174 | 179 |
}); |
| 175 | 180 |
|
| ... | ... | |
| 196 | 201 |
|
| 197 | 202 |
|
| 198 | 203 |
valueCombo.setInput(values); |
| 199 |
|
|
| 204 |
|
|
| 200 | 205 |
if (valueCombo.getList().getItemCount() > 0) {
|
| 201 | 206 |
valueCombo.getList().select(0); |
| 202 | 207 |
selectedValues = new ArrayList<String>(); |
| ... | ... | |
| 242 | 247 |
} |
| 243 | 248 |
reloadValues(); |
| 244 | 249 |
} |
| 250 |
|
|
| 251 |
public String getQueryString() {
|
|
| 252 |
String regexp = ""; //$NON-NLS-1$ |
|
| 253 |
for (String v : selectedValues) {
|
|
| 254 |
regexp += CQLQuery.addBackSlash(v) + "|"; //$NON-NLS-1$ |
|
| 255 |
} |
|
| 256 |
regexp = regexp.substring(0, regexp.length() - 1); |
|
| 257 |
|
|
| 258 |
SubcorpusCQLQuery query = new SubcorpusCQLQuery(this.selectedStructuralUnit, this.selectedStructuralUnitProperty, regexp, selectedValues); |
|
| 259 |
|
|
| 260 |
return query.getQueryString(); |
|
| 261 |
} |
|
| 245 | 262 |
|
| 246 | 263 |
} |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/listeners/DropdownSelectionListener.java (revision 2550) | ||
|---|---|---|
| 34 | 34 |
menu.setVisible(true); |
| 35 | 35 |
event.doit = false; |
| 36 | 36 |
} else {
|
| 37 |
defaultListener.widgetSelected(event); |
|
| 37 |
if (defaultListener != null) {
|
|
| 38 |
defaultListener.widgetSelected(event); |
|
| 39 |
} |
|
| 38 | 40 |
} |
| 39 | 41 |
} |
| 40 | 42 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Subcorpus.java (revision 2550) | ||
|---|---|---|
| 112 | 112 |
* {@link CQPCorpus#createSubcorpus(CQLQuery, String)}
|
| 113 | 113 |
*/ |
| 114 | 114 |
@Override |
| 115 |
protected boolean _compute() throws Exception {
|
|
| 115 |
protected boolean __compute() throws Exception {
|
|
| 116 |
if (pID == null || pID.length() == 0) {
|
|
| 117 |
pID = subcorpusNamePrefix + getNextSubcorpusCounter().toString(); |
|
| 118 |
} |
|
| 119 |
|
|
| 116 | 120 |
if (this.pQuery != null) {
|
| 117 | 121 |
this.qresult = null; // reset |
| 122 |
String parent_id = this.getCorpusParent().getQualifiedCqpId(); |
|
| 123 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(parent_id, this.pID, CQLQuery.fixQuery(this.pQuery.getQueryString())); |
|
| 118 | 124 |
|
| 119 |
CorpusManager.getCorpusManager().getCqiClient().cqpQuery(this.getCorpusParent().getQualifiedCqpId(), this.pID, CQLQuery.fixQuery(this.pQuery.getQueryString())); |
|
| 120 |
|
|
| 121 | 125 |
this.qresult = new QueryResult(this.pID, this.userName, this.getCorpusParent(), this.pQuery); // getCorpusParent().query(pQuery, this.pID, true); |
| 122 | 126 |
} |
| 123 | 127 |
return qresult != null; |
| ... | ... | |
| 134 | 138 |
} |
| 135 | 139 |
// created directly from a query |
| 136 | 140 |
else {
|
| 137 |
return TXMCoreMessages.bind(SearchEngineCoreMessages.info_computingTheP0SubCorpusOfP1CommaQueryP2, this.getSimpleName(), this.getParent().getName(), this.getQuery().getQueryString());
|
|
| 141 |
return TXMCoreMessages.bind(SearchEngineCoreMessages.info_computingTheP0SubCorpusOfP1CommaQueryP2, this.getSimpleName(), this.getParent().getName(), this.getQuery()); |
|
| 138 | 142 |
} |
| 139 | 143 |
} |
| 140 | 144 |
|
| 141 |
|
|
| 142 | 145 |
/* |
| 143 | 146 |
* retro compatibility method for import.xml file |
| 144 | 147 |
* @see org.txm.searchengine.cqp.corpus.Corpus#getLocale() |
| ... | ... | |
| 198 | 201 |
|
| 199 | 202 |
@Override |
| 200 | 203 |
public boolean canCompute() {
|
| 201 |
return pID != null && userName != null && (pQuery != null || qresult != null); |
|
| 204 |
return userName != null && userName.length() > 0 && |
|
| 205 |
((pQuery != null && pQuery.getQueryString().length() > 0 ) || qresult != null); |
|
| 202 | 206 |
} |
| 203 | 207 |
|
| 204 | 208 |
/* |
| ... | ... | |
| 249 | 253 |
|
| 250 | 254 |
@Override |
| 251 | 255 |
public List<Match> getMatches() {
|
| 256 |
if (qresult == null) { // not computed
|
|
| 257 |
return new ArrayList<>(); |
|
| 258 |
} |
|
| 252 | 259 |
try {
|
| 253 | 260 |
return qresult.getMatches(); |
| 254 | 261 |
} |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Part.java (revision 2550) | ||
|---|---|---|
| 78 | 78 |
} |
| 79 | 79 |
|
| 80 | 80 |
@Override |
| 81 |
protected boolean _compute() throws Exception {
|
|
| 81 |
protected boolean __compute() throws Exception {
|
|
| 82 | 82 |
|
| 83 | 83 |
try {
|
| 84 |
super._compute(); |
|
| 84 |
super.__compute();
|
|
| 85 | 85 |
} |
| 86 | 86 |
catch (Exception e) {
|
| 87 | 87 |
try {
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/Partition.java (revision 2550) | ||
|---|---|---|
| 106 | 106 |
* @param parent |
| 107 | 107 |
* @throws NullPointerException |
| 108 | 108 |
*/ |
| 109 |
public Partition(CQPCorpus parent) throws NullPointerException {
|
|
| 109 |
public Partition(CQPCorpus parent) {
|
|
| 110 | 110 |
super(parent); |
| 111 | 111 |
} |
| 112 | 112 |
|
| ... | ... | |
| 118 | 118 |
super(parametersNodePath); |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 |
|
|
| 122 | 121 |
/** |
| 123 | 122 |
* Computes the Partition using a list of queries. |
| 124 | 123 |
* |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 2550) | ||
|---|---|---|
| 226 | 226 |
*/ |
| 227 | 227 |
protected String lang = null; |
| 228 | 228 |
|
| 229 |
/** The corpus lexical units properties. */ |
|
| 229 |
/** stores The corpus lexical units properties. */
|
|
| 230 | 230 |
protected List<WordProperty> lexicalUnitsProperties; |
| 231 | 231 |
|
| 232 | 232 |
/** The size in token */ |
| ... | ... | |
| 675 | 675 |
return createSubcorpus(query, subcorpusName); |
| 676 | 676 |
} |
| 677 | 677 |
|
| 678 |
protected final boolean _compute() throws Exception {
|
|
| 679 |
//reset the internal variable that store information |
|
| 680 |
|
|
| 681 |
lexicalUnitsProperties = null; |
|
| 682 |
size = -1; |
|
| 683 |
nbtext = -1; |
|
| 684 |
textEndLimits = null; |
|
| 685 |
textids = null; |
|
| 686 |
structuralUnits = null; |
|
| 687 |
symbol = null; |
|
| 688 |
textIdStructuralUnitProperty = null; |
|
| 689 |
textLimits = null; |
|
| 690 |
textStructuralUnit = null; |
|
| 691 |
wordProperty = null; |
|
| 692 |
|
|
| 693 |
|
|
| 694 |
return __compute(); |
|
| 695 |
} |
|
| 696 |
|
|
| 697 |
protected abstract boolean __compute() throws Exception; |
|
| 698 |
|
|
| 678 | 699 |
/** |
| 679 | 700 |
* Create a subcorpus from a structural unit, a property on this structural unit |
| 680 | 701 |
* and a value for this property. |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 2550) | ||
|---|---|---|
| 115 | 115 |
} |
| 116 | 116 |
|
| 117 | 117 |
@Override |
| 118 |
protected boolean _compute() throws Exception {
|
|
| 118 |
protected boolean __compute() throws Exception {
|
|
| 119 | 119 |
|
| 120 | 120 |
if (!CQPSearchEngine.isInitialized()) {
|
| 121 | 121 |
Log.warning("** TXM can't load MainCorpus when CQP search engine is not ready.");
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/PartitionPreferences.java (revision 2550) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.cqp.core.preferences; |
|
| 2 |
|
|
| 3 |
import org.osgi.service.prefs.Preferences; |
|
| 4 |
import org.txm.core.preferences.TXMPreferences; |
|
| 5 |
|
|
| 6 |
public class PartitionPreferences extends TXMPreferences {
|
|
| 7 |
|
|
| 8 |
public static String EDITORMODE = "editor_mode"; |
|
| 9 |
|
|
| 10 |
public PartitionPreferences() {
|
|
| 11 |
// TODO Auto-generated constructor stub |
|
| 12 |
} |
|
| 13 |
|
|
| 14 |
/** |
|
| 15 |
* Gets the instance. |
|
| 16 |
* @return the instance |
|
| 17 |
*/ |
|
| 18 |
public static TXMPreferences getInstance() {
|
|
| 19 |
if (!TXMPreferences.instances.containsKey(PartitionPreferences.class)) {
|
|
| 20 |
new PartitionPreferences(); |
|
| 21 |
} |
|
| 22 |
return TXMPreferences.instances.get(PartitionPreferences.class); |
|
| 23 |
} |
|
| 24 |
|
|
| 25 |
@Override |
|
| 26 |
public void initializeDefaultPreferences() {
|
|
| 27 |
super.initializeDefaultPreferences(); |
|
| 28 |
|
|
| 29 |
Preferences preferences = this.getDefaultPreferencesNode(); |
|
| 30 |
|
|
| 31 |
preferences.putBoolean(EDITORMODE, false); |
|
| 32 |
} |
|
| 33 |
} |
|
| 0 | 34 | |
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/core/preferences/SubcorpusPreferences.java (revision 2550) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.cqp.core.preferences; |
|
| 2 |
|
|
| 3 |
import org.osgi.service.prefs.Preferences; |
|
| 4 |
import org.txm.core.preferences.TXMPreferences; |
|
| 5 |
|
|
| 6 |
public class SubcorpusPreferences extends TXMPreferences {
|
|
| 7 |
|
|
| 8 |
public static String EDITORMODE = "editor_mode"; |
|
| 9 |
|
|
| 10 |
public SubcorpusPreferences() {
|
|
| 11 |
// TODO Auto-generated constructor stub |
|
| 12 |
} |
|
| 13 |
|
|
| 14 |
/** |
|
| 15 |
* Gets the instance. |
|
| 16 |
* @return the instance |
|
| 17 |
*/ |
|
| 18 |
public static TXMPreferences getInstance() {
|
|
| 19 |
if (!TXMPreferences.instances.containsKey(SubcorpusPreferences.class)) {
|
|
| 20 |
new SubcorpusPreferences(); |
|
| 21 |
} |
|
| 22 |
return TXMPreferences.instances.get(SubcorpusPreferences.class); |
|
| 23 |
} |
|
| 24 |
|
|
| 25 |
@Override |
|
| 26 |
public void initializeDefaultPreferences() {
|
|
| 27 |
super.initializeDefaultPreferences(); |
|
| 28 |
|
|
| 29 |
Preferences preferences = this.getDefaultPreferencesNode(); |
|
| 30 |
|
|
| 31 |
preferences.putBoolean(EDITORMODE, false); |
|
| 32 |
} |
|
| 33 |
} |
|
| 0 | 34 | |
| tmp/org.txm.searchengine.cqp.core/plugin.xml (revision 2550) | ||
|---|---|---|
| 12 | 12 |
<initializer |
| 13 | 13 |
class="org.txm.searchengine.cqp.CQPPreferences"> |
| 14 | 14 |
</initializer> |
| 15 |
<initializer |
|
| 16 |
class="org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences"> |
|
| 17 |
</initializer> |
|
| 18 |
<initializer |
|
| 19 |
class="org.txm.searchengine.cqp.core.preferences.PartitionPreferences"> |
|
| 20 |
</initializer> |
|
| 15 | 21 |
</extension> |
| 16 | 22 |
|
| 17 | 23 |
|
| tmp/org.txm.searchengine.cqp.core/META-INF/MANIFEST.MF (revision 2550) | ||
|---|---|---|
| 1 | 1 |
Manifest-Version: 1.0 |
| 2 |
Export-Package: org.txm.importer.cwb,org.txm.searchengine.cqp,org.txm. |
|
| 3 |
searchengine.cqp.clientExceptions,org.txm.searchengine.cqp.core.funct |
|
| 4 |
ions.preview,org.txm.searchengine.cqp.core.functions.selection,org.tx |
|
| 5 |
m.searchengine.cqp.core.functions.summary,org.txm.searchengine.cqp.co |
|
| 6 |
re.messages,org.txm.searchengine.cqp.core.tests,org.txm.searchengine. |
|
| 7 |
cqp.corpus,org.txm.searchengine.cqp.corpus.query,org.txm.searchengine |
|
| 8 |
.cqp.serverException |
|
| 2 |
Export-Package: org.txm.importer.cwb, |
|
| 3 |
org.txm.searchengine.cqp, |
|
| 4 |
org.txm.searchengine.cqp.clientExceptions, |
|
| 5 |
org.txm.searchengine.cqp.core.functions.preview, |
|
| 6 |
org.txm.searchengine.cqp.core.functions.selection, |
|
| 7 |
org.txm.searchengine.cqp.core.functions.summary, |
|
| 8 |
org.txm.searchengine.cqp.core.messages, |
|
| 9 |
org.txm.searchengine.cqp.core.preferences, |
|
| 10 |
org.txm.searchengine.cqp.core.tests, |
|
| 11 |
org.txm.searchengine.cqp.corpus, |
|
| 12 |
org.txm.searchengine.cqp.corpus.query, |
|
| 13 |
org.txm.searchengine.cqp.serverException |
|
| 9 | 14 |
Bundle-SymbolicName: org.txm.searchengine.cqp.core;singleton:=true |
| 10 | 15 |
Bundle-Version: 1.1.0.qualifier |
| 11 | 16 |
Bundle-Name: %Bundle-Name |
| tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 2550) | ||
|---|---|---|
| 109 | 109 |
SelectionListener openCloseSelectionListener = new SelectionListener() {
|
| 110 | 110 |
@Override |
| 111 | 111 |
public void widgetSelected(SelectionEvent e) {
|
| 112 |
if (annotationAreas.size() > 0) {
|
|
| 113 |
return; // do nothing |
|
| 112 |
if (editor.getTopToolbar().isVisible(GROUP_NAME)) {
|
|
| 113 |
if (annotationAreas.size() == 0) {
|
|
| 114 |
openDefaultAnnotationMode(e); |
|
| 115 |
} |
|
| 114 | 116 |
} else {
|
| 115 |
openDefaultAnnotationMode(e); |
|
| 117 |
for (AnnotationArea a : annotationAreas) {
|
|
| 118 |
a.close(); |
|
| 119 |
} |
|
| 120 |
annotationAreas.clear(); |
|
| 116 | 121 |
} |
| 117 | 122 |
} |
| 118 | 123 |
|
| tmp/org.txm.searchengine.cqp.rcp/plugin.xml (revision 2550) | ||
|---|---|---|
| 25 | 25 |
</commandParameter> |
| 26 | 26 |
</command> |
| 27 | 27 |
<command |
| 28 |
defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus"
|
|
| 28 |
defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.ComputeSubCorpus"
|
|
| 29 | 29 |
id="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus" |
| 30 | 30 |
name="%command.name"> |
| 31 | 31 |
<commandParameter |
| ... | ... | |
| 33 | 33 |
name="%commandParameter.name.0" |
| 34 | 34 |
optional="true"> |
| 35 | 35 |
</commandParameter> |
| 36 |
<commandParameter |
|
| 37 |
id="edit" |
|
| 38 |
name="edit" |
|
| 39 |
optional="true"> |
|
| 40 |
</commandParameter> |
|
| 36 | 41 |
</command> |
| 37 | 42 |
<command |
| 38 | 43 |
defaultHandler="org.txm.searchengine.cqp.rcp.handlers.base.Substraction" |
| ... | ... | |
| 155 | 160 |
</visibleWhen> |
| 156 | 161 |
</command> |
| 157 | 162 |
<command |
| 163 |
commandId="org.txm.searchengine.cqp.rcp.handlers.base.CreateSubCorpus" |
|
| 164 |
icon="icons/functions/subcorpus.png" |
|
| 165 |
label="Edit..." |
|
| 166 |
style="push"> |
|
| 167 |
<visibleWhen |
|
| 168 |
checkEnabled="false"> |
|
| 169 |
<reference |
|
| 170 |
definitionId="OneCorpusSelected"> |
|
| 171 |
</reference> |
|
| 172 |
</visibleWhen> |
|
| 173 |
<parameter |
|
| 174 |
name="edit" |
|
| 175 |
value="true"> |
|
| 176 |
</parameter> |
|
| 177 |
</command> |
|
| 178 |
<command |
|
| 158 | 179 |
commandId="org.txm.searchengine.cqp.rcp.handlers.base.ComputePartition" |
| 159 | 180 |
icon="icons/functions/partition.png" |
| 160 | 181 |
style="push"> |
| ... | ... | |
| 292 | 313 |
id="org.txm.searchengine.cqp.rcp.preferences.CQPPreferencePage" |
| 293 | 314 |
name="CQP"> |
| 294 | 315 |
</page> |
| 316 |
<page |
|
| 317 |
category="org.txm.rcp.preferences.UserPreferencePage" |
|
| 318 |
class="org.txm.searchengine.cqp.rcp.preferences.SubcorpusPreferencePage" |
|
| 319 |
id="org.txm.searchengine.cqp.rcp.preferences.SubcorpusPreferencePage" |
|
| 320 |
name="Subcorpus"> |
|
| 321 |
</page> |
|
| 322 |
<page |
|
| 323 |
category="org.txm.rcp.preferences.UserPreferencePage" |
|
| 324 |
class="org.txm.searchengine.cqp.rcp.preferences.PartitionPreferencePage" |
|
| 325 |
id="org.txm.searchengine.cqp.rcp.preferences.PartitionPreferencePage" |
|
| 326 |
name="Partition"> |
|
| 327 |
</page> |
|
| 295 | 328 |
</extension> |
| 296 | 329 |
<extension |
| 297 | 330 |
point="org.eclipse.core.runtime.adapters"> |
| ... | ... | |
| 345 | 378 |
</with> |
| 346 | 379 |
</definition> |
| 347 | 380 |
</extension> |
| 381 |
<extension |
|
| 382 |
point="org.eclipse.ui.editors"> |
|
| 383 |
<editor |
|
| 384 |
class="org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor" |
|
| 385 |
default="false" |
|
| 386 |
icon="icons/functions/subcorpus.png" |
|
| 387 |
id="org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor" |
|
| 388 |
name="Subcorpus"> |
|
| 389 |
</editor> |
|
| 390 |
<editor |
|
| 391 |
class="org.txm.searchengine.cqp.rcp.editor.PartitionEditor" |
|
| 392 |
default="false" |
|
| 393 |
icon="icons/functions/partition.png" |
|
| 394 |
id="org.txm.searchengine.cqp.rcp.editor.PartitionEditor" |
|
| 395 |
name="Partition"> |
|
| 396 |
</editor> |
|
| 397 |
</extension> |
|
| 348 | 398 |
|
| 349 | 399 |
</plugin> |
| tmp/org.txm.searchengine.cqp.rcp/META-INF/MANIFEST.MF (revision 2550) | ||
|---|---|---|
| 1 | 1 |
Manifest-Version: 1.0 |
| 2 |
Export-Package: org.txm.searchengine.cqp.rcp.adapters,org.txm.searchen |
|
| 3 |
gine.cqp.rcp.handlers.base,org.txm.searchengine.cqp.rcp.messages,org. |
|
| 4 |
txm.searchengine.cqp.rcp.preferences |
|
| 2 |
Export-Package: org.txm.searchengine.cqp.rcp.adapters, |
|
| 3 |
org.txm.searchengine.cqp.rcp.dialogs, |
|
| 4 |
org.txm.searchengine.cqp.rcp.editor, |
|
| 5 |
org.txm.searchengine.cqp.rcp.handlers.base, |
|
| 6 |
org.txm.searchengine.cqp.rcp.messages, |
|
| 7 |
org.txm.searchengine.cqp.rcp.preferences |
|
| 5 | 8 |
Bundle-SymbolicName: org.txm.searchengine.cqp.rcp;singleton:=true |
| 6 | 9 |
Bundle-Version: 1.0.0.qualifier |
| 7 | 10 |
Bundle-Name: %Bundle-Name |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/CreateSubCorpus.java (revision 2550) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.searchengine.cqp.rcp.handlers.base; |
|
| 29 |
|
|
| 30 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 31 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 32 |
import org.eclipse.core.commands.ExecutionException; |
|
| 33 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 34 |
import org.eclipse.core.runtime.IStatus; |
|
| 35 |
import org.eclipse.core.runtime.Status; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 37 |
import org.eclipse.jface.window.Window; |
|
| 38 |
import org.eclipse.osgi.util.NLS; |
|
| 39 |
import org.eclipse.swt.widgets.Shell; |
|
| 40 |
import org.eclipse.ui.IWorkbenchWindow; |
|
| 41 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 42 |
import org.txm.Toolbox; |
|
| 43 |
import org.txm.rcp.JobsTimer; |
|
| 44 |
import org.txm.rcp.actions.CreateSubcorpusDialog; |
|
| 45 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 46 |
import org.txm.rcp.utils.JobHandler; |
|
| 47 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 48 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
| 49 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
| 50 |
import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages; |
|
| 51 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
| 52 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
| 53 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
| 54 |
import org.txm.utils.logger.Log; |
|
| 55 |
|
|
| 56 |
// TODO: Auto-generated Javadoc |
|
| 57 |
/** |
|
| 58 |
* Command which creates a subcorpus from a Corpus @ author mdecorde. |
|
| 59 |
*/ |
|
| 60 |
public class CreateSubCorpus extends AbstractHandler {
|
|
| 61 |
|
|
| 62 |
/** The selection. */ |
|
| 63 |
private IStructuredSelection selection; |
|
| 64 |
|
|
| 65 |
/* |
|
| 66 |
* (non-Javadoc) |
|
| 67 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 68 |
*/ |
|
| 69 |
@Override |
|
| 70 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 71 |
|
|
| 72 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 73 |
if (selection == null) {
|
|
| 74 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
|
| 75 |
return null; |
|
| 76 |
} |
|
| 77 |
Object firstElement = selection.getFirstElement(); |
|
| 78 |
|
|
| 79 |
if (!(firstElement instanceof CQPCorpus)) {
|
|
| 80 |
System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement); |
|
| 81 |
return null; |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
final CQPCorpus corpus = (CQPCorpus) firstElement; |
|
| 85 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
| 86 |
final CreateSubcorpusDialog d = new CreateSubcorpusDialog(shell, corpus); |
|
| 87 |
int code = d.open(); |
|
| 88 |
if (code == Window.OK) {
|
|
| 89 |
JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.creatingASubcorpusOnP0, corpus.getName())) {
|
|
| 90 |
|
|
| 91 |
@Override |
|
| 92 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 93 |
this.runInit(monitor); |
|
| 94 |
JobsTimer.start(); |
|
| 95 |
try {
|
|
| 96 |
monitor.beginTask(TXMUIMessages.creatingASubcorpusInTheSearchEngine, 100); |
|
| 97 |
final Subcorpus subcorpus; |
|
| 98 |
|
|
| 99 |
if (d.isAdvancedSelected() || d.isAssistedSelected()) {
|
|
| 100 |
CQLQuery q = new CQLQuery(d.getQuery()); |
|
| 101 |
|
|
| 102 |
// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0QueryColonP1, corpus.getName(), q.getQueryString())); |
|
| 103 |
|
|
| 104 |
subcorpus = corpus.createSubcorpus(q, d.getName()); |
|
| 105 |
} |
|
| 106 |
else {
|
|
| 107 |
// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0StructsColonP1AmpPropsP2ColonP3, |
|
| 108 |
// new Object[] { corpus.getName(), d.getStructuralUnit(),
|
|
| 109 |
// d.getStructuralUnitProperty(), d.getValues() })); |
|
| 110 |
|
|
| 111 |
// Escape regex char of prop values |
|
| 112 |
// List<String> values = d.getValues(); |
|
| 113 |
// for(int i = 0 ; i < values.size() ; i++) |
|
| 114 |
// values.set(i, Query.addBackSlash(values.get(i))); |
|
| 115 |
|
|
| 116 |
subcorpus = corpus.createSubcorpus( |
|
| 117 |
d.getStructuralUnit(), d.getStructuralUnitProperty(), |
|
| 118 |
d.getValues(), d.getName()); |
|
| 119 |
} |
|
| 120 |
|
|
| 121 |
if (subcorpus == null) {
|
|
| 122 |
monitor.done(); |
|
| 123 |
Log.severe(TXMUIMessages.errorColonSubcorpusWasNotCreated); |
|
| 124 |
return Status.CANCEL_STATUS; |
|
| 125 |
} |
|
| 126 |
|
|
| 127 |
// System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName())); |
|
| 128 |
monitor.worked(50); |
|
| 129 |
|
|
| 130 |
monitor.subTask(TXMUIMessages.refreshingCorpora); |
|
| 131 |
syncExec(new Runnable() {
|
|
| 132 |
|
|
| 133 |
@Override |
|
| 134 |
public void run() {
|
|
| 135 |
CorporaView.refresh(); |
|
| 136 |
// System.out.println("expand");
|
|
| 137 |
CorporaView.expand(subcorpus.getParent()); |
|
| 138 |
} |
|
| 139 |
}); |
|
| 140 |
|
|
| 141 |
monitor.worked(100); |
|
| 142 |
} |
|
| 143 |
catch (ThreadDeath td) {
|
|
| 144 |
return Status.CANCEL_STATUS; |
|
| 145 |
} |
|
| 146 |
catch (CqiClientException e) {
|
|
| 147 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
| 148 |
Log.severe(e.toString()); |
|
| 149 |
|
|
| 150 |
try {
|
|
| 151 |
System.out.println(NLS.bind(CQPSearchEngineCoreMessages.lastCQPErrorColon, CQPSearchEngine.getCqiClient().getLastCQPError())); |
|
| 152 |
} |
|
| 153 |
catch (Exception e1) {
|
|
| 154 |
System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon + e1); |
|
| 155 |
org.txm.utils.logger.Log.printStackTrace(e1); |
|
| 156 |
} |
|
| 157 |
} |
|
| 158 |
finally {
|
|
| 159 |
monitor.done(); |
|
| 160 |
JobsTimer.stopAndPrint(); |
|
| 161 |
} |
|
| 162 |
return Status.OK_STATUS; |
|
| 163 |
} |
|
| 164 |
}; |
|
| 165 |
jobhandler.startJob(); |
|
| 166 |
} |
|
| 167 |
return null; |
|
| 168 |
} |
|
| 169 |
|
|
| 170 |
} |
|
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputeSubCorpus.java (revision 2550) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.searchengine.cqp.rcp.handlers.base; |
|
| 29 |
|
|
| 30 |
import org.eclipse.core.commands.AbstractHandler; |
|
| 31 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 32 |
import org.eclipse.core.commands.ExecutionException; |
|
| 33 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 34 |
import org.eclipse.core.runtime.IStatus; |
|
| 35 |
import org.eclipse.core.runtime.Status; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredSelection; |
|
| 37 |
import org.eclipse.jface.window.Window; |
|
| 38 |
import org.eclipse.osgi.util.NLS; |
|
| 39 |
import org.eclipse.swt.widgets.Shell; |
|
| 40 |
import org.eclipse.ui.handlers.HandlerUtil; |
|
| 41 |
import org.txm.rcp.JobsTimer; |
|
| 42 |
import org.txm.rcp.actions.CreateSubcorpusDialog; |
|
| 43 |
import org.txm.rcp.editors.TXMEditor; |
|
| 44 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 45 |
import org.txm.rcp.utils.JobHandler; |
|
| 46 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 47 |
import org.txm.searchengine.cqp.CQPSearchEngine; |
|
| 48 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
| 49 |
import org.txm.searchengine.cqp.core.messages.CQPSearchEngineCoreMessages; |
|
| 50 |
import org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences; |
|
| 51 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
| 52 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
| 53 |
import org.txm.searchengine.cqp.corpus.query.CQLQuery; |
|
| 54 |
import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor; |
|
| 55 |
import org.txm.utils.logger.Log; |
|
| 56 |
|
|
| 57 |
/** |
|
| 58 |
* Command which creates a subcorpus from a Corpus @ author mdecorde. |
|
| 59 |
*/ |
|
| 60 |
public class ComputeSubCorpus extends AbstractHandler {
|
|
| 61 |
|
|
| 62 |
/** The selection. */ |
|
| 63 |
private IStructuredSelection selection; |
|
| 64 |
|
|
| 65 |
/* |
|
| 66 |
* (non-Javadoc) |
|
| 67 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 68 |
*/ |
|
| 69 |
@Override |
|
| 70 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 71 |
if (SubcorpusPreferences.getInstance().getBoolean(SubcorpusPreferences.EDITORMODE)) {
|
|
| 72 |
return execute_editor(event); |
|
| 73 |
} else {
|
|
| 74 |
return execute_dialog(event); |
|
| 75 |
} |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
public Object execute_editor(ExecutionEvent event) throws ExecutionException {
|
|
| 79 |
|
|
| 80 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 81 |
if (selection == null) {
|
|
| 82 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
|
| 83 |
return null; |
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
String edit = event.getParameter("edit"); //$NON-NLS-1$
|
|
| 87 |
|
|
| 88 |
Object firstElement = selection.getFirstElement(); |
|
| 89 |
Subcorpus sub = null; |
|
| 90 |
if (firstElement instanceof CQPCorpus) {
|
|
| 91 |
if (firstElement instanceof Subcorpus && "true".equals(edit)) {
|
|
| 92 |
sub = (Subcorpus) firstElement; |
|
| 93 |
} else {
|
|
| 94 |
sub = new Subcorpus((CQPCorpus)firstElement); |
|
| 95 |
} |
|
| 96 |
} |
|
| 97 |
return TXMEditor.openEditor(sub , SubcorpusEditor.class.getName()); |
|
| 98 |
} |
|
| 99 |
|
|
| 100 |
/* |
|
| 101 |
* (non-Javadoc) |
|
| 102 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
|
| 103 |
*/ |
|
| 104 |
public Object execute_dialog(ExecutionEvent event) throws ExecutionException {
|
|
| 105 |
|
|
| 106 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 107 |
if (selection == null) {
|
|
| 108 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
|
| 109 |
return null; |
|
| 110 |
} |
|
| 111 |
Object firstElement = selection.getFirstElement(); |
|
| 112 |
|
|
| 113 |
if (!(firstElement instanceof CQPCorpus)) {
|
|
| 114 |
System.out.println(TXMUIMessages.selectionIsNotACorpusColon + firstElement); |
|
| 115 |
return null; |
|
| 116 |
} |
|
| 117 |
|
|
| 118 |
final CQPCorpus corpus = (CQPCorpus) firstElement; |
|
| 119 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
|
| 120 |
final CreateSubcorpusDialog d = new CreateSubcorpusDialog(shell, corpus); |
|
| 121 |
int code = d.open(); |
|
| 122 |
if (code == Window.OK) {
|
|
| 123 |
JobHandler jobhandler = new JobHandler(NLS.bind(TXMUIMessages.creatingASubcorpusOnP0, corpus.getName())) {
|
|
| 124 |
|
|
| 125 |
@Override |
|
| 126 |
protected IStatus run(IProgressMonitor monitor) {
|
|
| 127 |
this.runInit(monitor); |
|
| 128 |
JobsTimer.start(); |
|
| 129 |
try {
|
|
| 130 |
monitor.beginTask(TXMUIMessages.creatingASubcorpusInTheSearchEngine, 100); |
|
| 131 |
final Subcorpus subcorpus; |
|
| 132 |
|
|
| 133 |
if (d.isAdvancedSelected() || d.isAssistedSelected()) {
|
|
| 134 |
CQLQuery q = new CQLQuery(d.getQuery()); |
|
| 135 |
|
|
| 136 |
// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0QueryColonP1, corpus.getName(), q.getQueryString())); |
|
| 137 |
|
|
| 138 |
subcorpus = corpus.createSubcorpus(q, d.getName()); |
|
| 139 |
} |
|
| 140 |
else {
|
|
| 141 |
// System.out.println(NLS.bind(TXMUIMessages.computeSubCorpusOnP0StructsColonP1AmpPropsP2ColonP3, |
|
| 142 |
// new Object[] { corpus.getName(), d.getStructuralUnit(),
|
|
| 143 |
// d.getStructuralUnitProperty(), d.getValues() })); |
|
| 144 |
|
|
| 145 |
// Escape regex char of prop values |
|
| 146 |
// List<String> values = d.getValues(); |
|
| 147 |
// for(int i = 0 ; i < values.size() ; i++) |
|
| 148 |
// values.set(i, Query.addBackSlash(values.get(i))); |
|
| 149 |
|
|
| 150 |
subcorpus = corpus.createSubcorpus( |
|
| 151 |
d.getStructuralUnit(), d.getStructuralUnitProperty(), |
|
| 152 |
d.getValues(), d.getName()); |
|
| 153 |
} |
|
| 154 |
|
|
| 155 |
if (subcorpus == null) {
|
|
| 156 |
monitor.done(); |
|
| 157 |
Log.severe(TXMUIMessages.errorColonSubcorpusWasNotCreated); |
|
| 158 |
return Status.CANCEL_STATUS; |
|
| 159 |
} |
|
| 160 |
|
|
| 161 |
// System.out.println(NLS.bind(TXMUIMessages.doneColonP0Created, subcorpus.getName())); |
|
| 162 |
monitor.worked(50); |
|
| 163 |
|
|
| 164 |
monitor.subTask(TXMUIMessages.refreshingCorpora); |
|
| 165 |
syncExec(new Runnable() {
|
|
| 166 |
|
|
| 167 |
@Override |
|
| 168 |
public void run() {
|
|
| 169 |
CorporaView.refresh(); |
|
| 170 |
// System.out.println("expand");
|
|
| 171 |
CorporaView.expand(subcorpus.getParent()); |
|
| 172 |
} |
|
| 173 |
}); |
|
| 174 |
|
|
| 175 |
monitor.worked(100); |
|
| 176 |
} |
|
| 177 |
catch (ThreadDeath td) {
|
|
| 178 |
return Status.CANCEL_STATUS; |
|
| 179 |
} |
|
| 180 |
catch (CqiClientException e) {
|
|
| 181 |
org.txm.utils.logger.Log.printStackTrace(e); |
|
| 182 |
Log.severe(e.toString()); |
|
| 183 |
|
|
| 184 |
try {
|
|
| 185 |
System.out.println(NLS.bind(CQPSearchEngineCoreMessages.lastCQPErrorColon, CQPSearchEngine.getCqiClient().getLastCQPError())); |
|
| 186 |
} |
|
| 187 |
catch (Exception e1) {
|
|
| 188 |
System.out.println(TXMUIMessages.failedToGetLastCQPErrorColon + e1); |
|
| 189 |
org.txm.utils.logger.Log.printStackTrace(e1); |
|
| 190 |
} |
|
| 191 |
} |
|
| 192 |
finally {
|
|
| 193 |
monitor.done(); |
|
| 194 |
JobsTimer.stopAndPrint(); |
|
| 195 |
} |
|
| 196 |
return Status.OK_STATUS; |
|
| 197 |
} |
|
| 198 |
}; |
|
| 199 |
jobhandler.startJob(); |
|
| 200 |
} |
|
| 201 |
return null; |
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
} |
|
| 0 | 205 | |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/handlers/base/ComputePartition.java (revision 2550) | ||
|---|---|---|
| 43 | 43 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 44 | 44 |
import org.txm.rcp.JobsTimer; |
| 45 | 45 |
import org.txm.rcp.actions.CreatePartitionDialog; |
| 46 |
import org.txm.rcp.editors.TXMEditor; |
|
| 46 | 47 |
import org.txm.rcp.messages.TXMUIMessages; |
| 47 | 48 |
import org.txm.rcp.utils.JobHandler; |
| 48 | 49 |
import org.txm.rcp.views.corpora.CorporaView; |
| 50 |
import org.txm.searchengine.cqp.core.preferences.PartitionPreferences; |
|
| 49 | 51 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
| 50 | 52 |
import org.txm.searchengine.cqp.corpus.Part; |
| 51 | 53 |
import org.txm.searchengine.cqp.corpus.Partition; |
| 54 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
| 55 |
import org.txm.searchengine.cqp.rcp.editor.PartitionEditor; |
|
| 56 |
import org.txm.searchengine.cqp.rcp.editor.SubcorpusEditor; |
|
| 52 | 57 |
import org.txm.utils.logger.Log; |
| 53 | 58 |
|
| 54 | 59 |
/** |
| ... | ... | |
| 72 | 77 |
*/ |
| 73 | 78 |
@Override |
| 74 | 79 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
| 80 |
if (PartitionPreferences.getInstance().getBoolean(PartitionPreferences.EDITORMODE)) {
|
|
| 81 |
return execute_editor(event); |
|
| 82 |
} else {
|
|
| 83 |
return execute_dialog(event); |
|
| 84 |
} |
|
| 85 |
} |
|
| 86 |
|
|
| 87 |
/* |
|
| 88 |
* (non-Javadoc) |
|
| 89 |
* @see |
|
| 90 |
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands |
|
| 91 |
* .ExecutionEvent) |
|
| 92 |
*/ |
|
| 93 |
public Object execute_editor(ExecutionEvent event) throws ExecutionException {
|
|
| 75 | 94 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
| 95 |
if (selection == null) {
|
|
| 96 |
System.out.println(TXMUIMessages.noSelectionForColon + HandlerUtil.getActiveWorkbenchWindow(event).getActivePage().getActiveEditor()); |
|
| 97 |
return null; |
|
| 98 |
} |
|
| 99 |
Object firstElement = selection.getFirstElement(); |
|
| 100 |
Partition part = null; |
|
| 101 |
if (firstElement instanceof CQPCorpus) {
|
|
| 102 |
part = new Partition((CQPCorpus)firstElement); |
|
| 103 |
} else if (firstElement instanceof Partition) {
|
|
| 104 |
part = (Partition)firstElement; |
|
| 105 |
} |
|
| 106 |
return TXMEditor.openEditor(part , PartitionEditor.class.getName()); |
|
| 107 |
} |
|
| 108 |
/* |
|
| 109 |
* (non-Javadoc) |
|
| 110 |
* @see |
|
| 111 |
* org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands |
|
| 112 |
* .ExecutionEvent) |
|
| 113 |
*/ |
|
| 114 |
public Object execute_dialog(ExecutionEvent event) throws ExecutionException {
|
|
| 115 |
selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
| 76 | 116 |
|
| 77 | 117 |
final CQPCorpus corpus = (CQPCorpus) selection.getFirstElement(); |
| 78 | 118 |
Shell shell = HandlerUtil.getActiveWorkbenchWindowChecked(event).getShell(); |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/SubcorpusPreferencePage.java (revision 2550) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.searchengine.cqp.rcp.preferences; |
|
| 29 |
|
|
| 30 |
|
|
| 31 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
| 32 |
import org.eclipse.jface.preference.DirectoryFieldEditor; |
|
| 33 |
import org.eclipse.jface.preference.FieldEditor; |
|
| 34 |
import org.eclipse.jface.preference.FileFieldEditor; |
|
| 35 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
|
| 36 |
import org.eclipse.jface.preference.StringFieldEditor; |
|
| 37 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
| 38 |
import org.eclipse.ui.IWorkbench; |
|
| 39 |
import org.osgi.service.prefs.Preferences; |
|
| 40 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
| 41 |
import org.txm.rcp.Application; |
|
| 42 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
| 43 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
| 44 |
import org.txm.searchengine.cqp.core.preferences.SubcorpusPreferences; |
|
| 45 |
import org.txm.searchengine.cqp.rcp.messages.CQPUIMessages; |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 |
* CQP search engine preferences page. |
|
| 49 |
* |
|
| 50 |
* @author mdecorde |
|
| 51 |
* @author sjacquot |
|
| 52 |
* |
|
| 53 |
*/ |
|
| 54 |
public class SubcorpusPreferencePage extends TXMPreferencePage {
|
|
| 55 |
|
|
| 56 |
/** The cqi_server_is_remote. */ |
|
| 57 |
private BooleanFieldEditor editor_mode; |
|
| 58 |
|
|
| 59 |
/** |
|
| 60 |
* Instantiates a new cQP preference page. |
|
| 61 |
*/ |
|
| 62 |
public SubcorpusPreferencePage() {
|
|
| 63 |
super(); |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
/** |
|
| 67 |
* Creates the field editors. Field editors are abstractions of the common |
|
| 68 |
* GUI blocks needed to manipulate various types of preferences. Each field |
|
| 69 |
* editor knows how to save and restore itself. |
|
| 70 |
*/ |
|
| 71 |
@Override |
|
| 72 |
public void createFieldEditors() {
|
|
| 73 |
|
|
| 74 |
editor_mode = new BooleanFieldEditor(SubcorpusPreferences.EDITORMODE, "Create subcorpus using the editor mode", BooleanFieldEditor.DEFAULT, getFieldEditorParent()); |
|
| 75 |
addField(editor_mode); |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/* |
|
| 79 |
* (non-Javadoc) |
|
| 80 |
* |
|
| 81 |
* @see |
|
| 82 |
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
|
| 83 |
*/ |
|
| 84 |
@Override |
|
| 85 |
public void init(IWorkbench workbench) {
|
|
| 86 |
this.setPreferenceStore(new TXMPreferenceStore(new SubcorpusPreferences().getPreferencesNodeQualifier())); |
|
| 87 |
} |
|
| 88 |
} |
|
| 0 | 89 | |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/preferences/PartitionPreferencePage.java (revision 2550) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.searchengine.cqp.rcp.preferences; |
|
| 29 |
|
|
| 30 |
|
|
| 31 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
| 32 |
import org.eclipse.jface.preference.DirectoryFieldEditor; |
|
| 33 |
import org.eclipse.jface.preference.FieldEditor; |
|
| 34 |
import org.eclipse.jface.preference.FileFieldEditor; |
|
| 35 |
import org.eclipse.jface.preference.IntegerFieldEditor; |
|
| 36 |
import org.eclipse.jface.preference.StringFieldEditor; |
|
| 37 |
import org.eclipse.jface.util.PropertyChangeEvent; |
|
| 38 |
import org.eclipse.ui.IWorkbench; |
|
| 39 |
import org.osgi.service.prefs.Preferences; |
|
| 40 |
import org.txm.libs.cqp.CQPLibPreferences; |
|
| 41 |
import org.txm.rcp.Application; |
|
| 42 |
import org.txm.rcp.preferences.TXMPreferencePage; |
|
| 43 |
import org.txm.rcp.preferences.TXMPreferenceStore; |
|
| 44 |
import org.txm.searchengine.cqp.core.preferences.PartitionPreferences; |
|
| 45 |
import org.txm.searchengine.cqp.rcp.messages.CQPUIMessages; |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 |
* CQP search engine preferences page. |
|
| 49 |
* |
|
| 50 |
* @author mdecorde |
|
| 51 |
* @author sjacquot |
|
| 52 |
* |
|
| 53 |
*/ |
|
| 54 |
public class PartitionPreferencePage extends TXMPreferencePage {
|
|
| 55 |
|
|
| 56 |
/** The cqi_server_is_remote. */ |
|
| 57 |
private BooleanFieldEditor editor_mode; |
|
| 58 |
|
|
| 59 |
/** |
|
| 60 |
* Instantiates a new cQP preference page. |
|
| 61 |
*/ |
|
| 62 |
public PartitionPreferencePage() {
|
|
| 63 |
super(); |
|
| 64 |
} |
|
| 65 |
|
|
| 66 |
/** |
|
| 67 |
* Creates the field editors. Field editors are abstractions of the common |
|
| 68 |
* GUI blocks needed to manipulate various types of preferences. Each field |
|
| 69 |
* editor knows how to save and restore itself. |
|
| 70 |
*/ |
|
| 71 |
@Override |
|
| 72 |
public void createFieldEditors() {
|
|
| 73 |
|
|
| 74 |
editor_mode = new BooleanFieldEditor(PartitionPreferences.EDITORMODE, "Create partitions using the editor mode", BooleanFieldEditor.DEFAULT, getFieldEditorParent()); |
|
| 75 |
addField(editor_mode); |
|
| 76 |
} |
|
| 77 |
|
|
| 78 |
/* |
|
| 79 |
* (non-Javadoc) |
|
| 80 |
* |
|
| 81 |
* @see |
|
| 82 |
* org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) |
|
| 83 |
*/ |
|
| 84 |
@Override |
|
| 85 |
public void init(IWorkbench workbench) {
|
|
| 86 |
this.setPreferenceStore(new TXMPreferenceStore(new PartitionPreferences().getPreferencesNodeQualifier())); |
|
| 87 |
} |
|
| 88 |
} |
|
| 0 | 89 | |
| tmp/org.txm.searchengine.cqp.rcp/src/org/txm/searchengine/cqp/rcp/editor/SubcorpusEditor.java (revision 2550) | ||
|---|---|---|
| 1 |
package org.txm.searchengine.cqp.rcp.editor; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
import java.util.List; |
|
| 5 |
|
|
| 6 |
import org.apache.commons.lang.StringUtils; |
|
| 7 |
import org.eclipse.osgi.util.NLS; |
|
| 8 |
import org.eclipse.swt.SWT; |
|
| 9 |
import org.eclipse.swt.events.KeyEvent; |
|
| 10 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 11 |
import org.eclipse.swt.events.SelectionListener; |
|
| 12 |
import org.eclipse.swt.layout.GridData; |
|
| 13 |
import org.eclipse.swt.layout.GridLayout; |
|
| 14 |
import org.eclipse.swt.widgets.Control; |
|
| 15 |
import org.eclipse.swt.widgets.Group; |
|
| 16 |
import org.eclipse.swt.widgets.Label; |
|
| 17 |
import org.eclipse.swt.widgets.Text; |
|
| 18 |
import org.eclipse.swt.widgets.ToolItem; |
|
| 19 |
import org.eclipse.ui.IPartListener; |
|
| 20 |
import org.eclipse.ui.IWorkbenchPart; |
|
| 21 |
import org.txm.core.preferences.TXMPreferences; |
|
| 22 |
import org.txm.core.results.Parameter; |
|
| 23 |
import org.txm.core.results.TXMResult; |
|
| 24 |
import org.txm.rcp.IImageKeys; |
|
| 25 |
import org.txm.rcp.editors.TXMEditor; |
|
| 26 |
import org.txm.rcp.editors.listeners.ComputeKeyListener; |
|
| 27 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 28 |
import org.txm.rcp.swt.widget.AssistedChoiceQueryWidget; |
|
| 29 |
import org.txm.rcp.swt.widget.ComplexSubcorpusPanel; |
|
| 30 |
import org.txm.rcp.swt.widget.structures.SimpleSubcorpusPanel; |
|
| 31 |
import org.txm.rcp.views.corpora.CorporaView; |
|
| 32 |
import org.txm.searchengine.cqp.corpus.Subcorpus; |
|
| 33 |
import org.txm.searchengine.cqp.corpus.query.Match; |
|
| 34 |
|
|
| 35 |
public class SubcorpusEditor extends TXMEditor<Subcorpus> {
|
|
| 36 |
|
|
| 37 |
protected static final String ASSISTANTS_GROUPNAME = "Assistants"; |
|
| 38 |
private Label nameLabel; |
|
| 39 |
@Parameter(key = TXMPreferences.USER_NAME) |
|
| 40 |
|
|
| 41 |
private Text nameText; |
|
| 42 |
|
|
| 43 |
private Label queryLabel; |
|
| 44 |
|
|
| 45 |
@Parameter(key = TXMPreferences.QUERY) |
|
| 46 |
private AssistedChoiceQueryWidget queryWidget; |
|
| 47 |
|
|
| 48 |
Label matchesInfo; |
|
| 49 |
Text matchStartsEndsInfo; |
|
| 50 |
private Group modeGroups; |
|
| 51 |
private ToolItem refreshQueryButton; |
|
| 52 |
|
|
| 53 |
@Override |
|
| 54 |
public void _createPartControl() throws Exception {
|
|
| 55 |
|
|
| 56 |
getSite().getPage().addPartListener(new IPartListener() {
|
|
| 57 |
|
|
| 58 |
@Override |
|
| 59 |
public void partOpened(IWorkbenchPart part) { }
|
|
| 60 |
|
|
| 61 |
@Override |
|
| 62 |
public void partDeactivated(IWorkbenchPart part) { }
|
|
| 63 |
|
|
| 64 |
@Override |
|
| 65 |
public void partClosed(IWorkbenchPart part) {
|
|
| 66 |
TXMResult r = getResult(); |
|
| 67 |
if (!r.hasBeenComputedOnce()) {
|
|
| 68 |
r.delete(); |
|
| 69 |
CorporaView.refresh(); |
|
| 70 |
} |
|
| 71 |
} |
|
| 72 |
|
|
| 73 |
@Override |
|
| 74 |
public void partBroughtToTop(IWorkbenchPart part) { }
|
|
| 75 |
|
|
| 76 |
@Override |
|
| 77 |
public void partActivated(IWorkbenchPart part) { }
|
|
| 78 |
}); |
|
| 79 |
|
|
| 80 |
// Modified computing listeners to manage multi lines query widgets |
|
| 81 |
ComputeKeyListener computeKeyListener = new ComputeKeyListener(this) {
|
|
| 82 |
|
|
| 83 |
@Override |
|
| 84 |
public void keyPressed(KeyEvent e) {
|
|
| 85 |
|
|
| 86 |
if (queryWidget.getQuery() == null) return; |
|
| 87 |
if (!queryWidget.getQuery().getSearchEngine().hasMultiLineQueries()) super.keyPressed(e); |
|
| 88 |
} |
|
| 89 |
}; |
|
| 90 |
|
|
| 91 |
getMainParametersComposite().getLayout().numColumns = 4; |
|
| 92 |
|
|
| 93 |
nameLabel = new Label(getMainParametersComposite(), SWT.NONE); |
|
| 94 |
nameLabel.setText(TXMUIMessages.name); |
|
| 95 |
nameLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
| 96 |
|
|
| 97 |
nameText = new Text(this.getMainParametersComposite(), SWT.BORDER); |
|
| 98 |
GridData gdata = new GridData(SWT.FILL, SWT.CENTER, true, false); |
|
| 99 |
nameText.setLayoutData(gdata); |
|
| 100 |
gdata.widthHint = 150; |
|
| 101 |
nameText.addModifyListener(computeKeyListener); |
|
| 102 |
|
|
| 103 |
queryLabel = new Label(getMainParametersComposite(), SWT.NONE); |
|
| 104 |
queryLabel.setText(TXMUIMessages.ampQuery); |
|
| 105 |
queryLabel.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false)); |
|
| 106 |
|
|
| 107 |
queryWidget = new AssistedChoiceQueryWidget(this.getMainParametersComposite(), SWT.BORDER|SWT.DROP_DOWN | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL, getResult()); |
|
| 108 |
queryWidget.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true)); |
|
| 109 |
queryWidget.addKeyListener(computeKeyListener); |
|
| 110 |
queryWidget.getQueryWidget().addModifyListener(computeKeyListener); |
|
| 111 |
|
|
| 112 |
ArrayList<String> modes = new ArrayList<String>(); |
|
| 113 |
final ArrayList<SelectionListener> listeners = new ArrayList<SelectionListener>(); |
|
| 114 |
|
|
| 115 |
// MODE TABS |
|
| 116 |
SelectionListener openCloseSelectionListener = new SelectionListener() {
|
|
| 117 |
@Override |
|
| 118 |
public void widgetSelected(SelectionEvent e) {
|
|
| 119 |
|
|
| 120 |
boolean v = getTopToolbar().isVisible(ASSISTANTS_GROUPNAME); |
|
| 121 |
if (!v) { // not visible remove all composites
|
|
| 122 |
if (modeGroups.getChildren().length > 0) {
|
|
| 123 |
Control c = modeGroups.getChildren()[0]; |
|
| 124 |
if (c instanceof SimpleSubcorpusPanel) {
|
|
| 125 |
SimpleSubcorpusPanel ssp = (SimpleSubcorpusPanel)c; |
|
| 126 |
String q = ssp.getQueryString(); |
|
| 127 |
if (q.length() > 0) {
|
|
| 128 |
queryWidget.setText(q); |
|
| 129 |
} |
|
| 130 |
} else if (c instanceof ComplexSubcorpusPanel) {
|
|
| 131 |
ComplexSubcorpusPanel ssp = (ComplexSubcorpusPanel)c; |
|
| 132 |
GridData gdata = new GridData(GridData.FILL, GridData.FILL, true, true); |
|
| 133 |
ssp.setLayoutData(gdata); |
|
| 134 |
gdata.heightHint = 600; |
|
| 135 |
String q = ssp.getQueryString(); |
|
| 136 |
if (q.length() > 0) {
|
|
| 137 |
queryWidget.setText(q); |
|
| 138 |
} |
|
| 139 |
} |
|
| 140 |
for (Control c2 : modeGroups.getChildren()) c2.dispose(); |
|
| 141 |
} |
|
| 142 |
} else {
|
|
| 143 |
|
|
| 144 |
for (Control c : modeGroups.getChildren()) c.dispose(); |
|
| 145 |
|
|
| 146 |
if (modeGroups.getChildren().length == 0) {
|
|
| 147 |
listeners.get(0).widgetSelected(e); |
|
| 148 |
} |
|
| 149 |
} |
|
| 150 |
} |
|
| 151 |
|
|
| 152 |
@Override |
|
| 153 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 154 |
}; |
|
| 155 |
|
|
| 156 |
modes.add("Simple");
|
|
| 157 |
modes.add("Assisted");
|
|
| 158 |
|
|
| 159 |
listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea
|
|
| 160 |
|
|
| 161 |
@Override |
|
| 162 |
public void widgetSelected(SelectionEvent e) {
|
|
| 163 |
try {
|
|
| 164 |
for (Control c : modeGroups.getChildren()) c.dispose(); |
|
| 165 |
|
|
| 166 |
getTopToolbar().setVisible(ASSISTANTS_GROUPNAME, true); |
|
| 167 |
|
|
| 168 |
SimpleSubcorpusPanel panel = new SimpleSubcorpusPanel(modeGroups, SWT.BORDER, null, getResult().getCorpusParent()); |
|
| 169 |
panel.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); |
|
| 170 |
|
|
| 171 |
modeGroups.layout(true); |
|
| 172 |
getResultArea().getParent().layout(true); |
|
| 173 |
|
|
| 174 |
} catch (Exception e1) {
|
|
| 175 |
// TODO Auto-generated catch block |
|
| 176 |
e1.printStackTrace(); |
|
| 177 |
} |
|
| 178 |
} |
|
| 179 |
|
|
| 180 |
@Override |
|
Formats disponibles : Unified diff