Révision 1520

tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1520)
388 388
				String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
389 389

  
390 390
				// Skip Project object
391
				if(className.equals(Project.class.getName()))	{
391
				if(className.equals(Project.class.getName()))	{ // already loaded in loadProjectFromProjectScope
392 392
					continue;
393 393
				}
394 394

  
......
1152 1152
	 * 
1153 1153
	 * @param rcpProject
1154 1154
	 */
1155
	public static void loadProjectsFromProjectScope(IProject rcpProject) {
1155
	public static void loadProjectFromProjectScope(IProject rcpProject) {
1156 1156
		//IScopeContext projectScope = new ProjectScope(projects[i]);
1157 1157
		ArrayList<String> resultNodePaths = TXMPreferences.getAllResultsNodePaths("/project/" + rcpProject.getName() + "/");
1158 1158

  
......
1172 1172

  
1173 1173
				String className = TXMPreferences.preferencesRootNode.node(parametersNodePath).get("class", ""); //$NON-NLS-1$
1174 1174

  
1175
				if(!className.equals(Project.class.getName()))	{ // already constructed
1176
					//	Log.finest("Toolbox.initialize(): not a project, result skipped (classame = " + className + ").");
1175
				if(!className.equals(Project.class.getName()))	{ // only load Project class
1177 1176
					continue;
1178 1177
				}
1179 1178

  
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1520)
236 236
				rcpProject.open(new LogMonitor());
237 237
			}
238 238
			
239
			Project.loadProjectsFromProjectScope(rcpProject);
239
			Project.loadProjectFromProjectScope(rcpProject);
240 240
			
241 241
			Project b = this.getProject(binCorpusDir.getName());
242 242
			
......
375 375
		for (IProject project : projects) {
376 376
			try {
377 377
				project.open(monitor);
378
				Project.loadProjectsFromProjectScope(project);
378
				Project.loadProjectFromProjectScope(project);
379 379
			} catch (CoreException e) {
380 380
				// TODO Auto-generated catch block
381 381
				e.printStackTrace();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 1520)
92 92
errorColonElementNotRegistered=** Erreur \: élément non enregistré 
93 93
nextSessionNumber=Numéro de session suivant
94 94
metadataPreview=Aperçu des métadonnées
95
importStoppedColonCorpusNameDoesNotMatchesTheAZAZ09120PatternColonP0=Importation annulée \: le nom du corpus n'est pas conforme à la syntaxe ‘''[AZ] [- A-Z0-9] {1,20}''\: {0}.
95
corpusNameDoesNotMatchesTheAZAZ09120PatternColonP0=Le nom du corpus n'est pas conforme à la syntaxe ‘''[AZ] [- A-Z0-9] {1,20}''\: {0}.
96 96
goToParentFolder=Aller au dossier parent
97 97
savingImportParameters=Sauvegarde des paramètres d'importation…
98 98
leftContextSize=Taille du contexte gauche
......
145 145
thisDirectorySeemsToContainABinaryCorpus=Ce dossier semble contenir un corpus au format binaire
146 146
theCorpusAndTheCorpusP0WillBeDeleted=Le corpus {0} va être supprimé.
147 147
addingToSelection=Ajouter à la sélection
148
descriptionHTMLCompleteNameAuthorDateLicenseComment=Description - HTML (nom complet, auteur, date, licence, commentaire…)
148
completeNameAuthorDateLicenseComment=Nom complet, auteur, date, licence, commentaire…
149 149
iAcceptTheLicenceAndIUndertakeToCiteTXMForAcknowledgingMyUseOfTXMInMyResearchWorkSeeTheCitationSectionOfTheInfhttpColontextometrieenslyonfrspipphprubrique61SupPage=J'accepte la licence et je m'engage à citer TXM dans mes travaux de recherche \n(voir la section 'Citation de TXM' de la page <http\://textometrie.ens-lyon.fr/spip.php?rubrique61>)
150 150
saveScriptBeforeExecution=Enregistrer le script avant l'exécution
151 151
saveBeforeExecution=Enregistrer avant l'exécution ?
......
476 476
displayInFullText=Afficher en plein texte…
477 477
showHideCommandParameters=Afficher/Masquer les paramètres de commande
478 478
startsWith=commence par
479
withinStructure=limité aux structures
479
withinStructure=limité aux structures
480
description=Description
481
descriptionOfTheP0CorpusP1=Description du corpus {0} ({1})
482
aWord=un mot
483
aWordWithItsProperties=un mot avec les propriétés
484
removeTheLastWord=Retirer le dernier mot
485
withinAContextOf=dans un context de
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 1520)
223 223
	public static String deleteParameter; 
224 224
	public static String generalInformations; 
225 225
	public static String corpusNameOnlyCapsAndNoDigitAtBeginning; 
226
	public static String importStoppedColonCorpusNameDoesNotMatchesTheAZAZ09120PatternColonP0; 
227
	public static String descriptionHTMLCompleteNameAuthorDateLicenseComment; 
226
	public static String corpusNameDoesNotMatchesTheAZAZ09120PatternColonP0; 
227
	public static String completeNameAuthorDateLicenseComment; 
228 228
	public static String newFileColonP0; 
229 229
	public static String newFolderColonP0; 
230 230
	public static String macroName; 
......
549 549

  
550 550

  
551 551

  
552
	public static String withinStructure; 
552
	public static String withinStructure;
553 553

  
554 554

  
555

  
556
	public static String description;
557

  
558

  
559

  
560
	public static String descriptionOfTheP0CorpusP1;
561

  
562

  
563

  
564
	public static String aWord;
565
	public static String aWordWithItsProperties;
566

  
567

  
568

  
569
	public static String removeTheLastWord;
570

  
571

  
572

  
573
	public static String withinAContextOf; 
574

  
575

  
555 576
	
556 577
	static {
557 578
		// initialize resource bundle
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 1520)
90 90
folderP0ShouldNotBeDeleted=Folder {0} should not be deleted
91 91
errorColonElementNotRegistered=** Error\: element not registered
92 92
nextSessionNumber=Next session number
93
importStoppedColonCorpusNameDoesNotMatchesTheAZAZ09120PatternColonP0=Import canceled\: the corpus name does not conform to the syntax ''[AZ] [- A-Z0-9] {1,20}''\: {0}.
93
corpusNameDoesNotMatchesTheAZAZ09120PatternColonP0=The corpus name does not conform to the syntax ''[AZ] [- A-Z0-9] {1,20}''\: {0}.
94 94
metadataPreview=Metadata preview
95 95
savingImportParameters=Saving import parameters…
96 96
goToParentFolder=Go to parent folder
......
144 144
thisDirectorySeemsToContainABinaryCorpus=This folder seems to contain a binary corpus
145 145
theCorpusAndTheCorpusP0WillBeDeleted=The corpus {0} will be deleted.
146 146
addingToSelection=Add to selection
147
descriptionHTMLCompleteNameAuthorDateLicenseComment=Description - HTML (complete name, author, date, license, comment…)
147
completeNameAuthorDateLicenseComment=Complete name, author, date, license, comment…
148 148
iAcceptTheLicenceAndIUndertakeToCiteTXMForAcknowledgingMyUseOfTXMInMyResearchWorkSeeTheCitationSectionOfTheInfhttpColontextometrieenslyonfrspipphprubrique61SupPage=I accept the licence and I undertake to cite TXM for acknowledging my use of TXM in my research work \n(see the Citation section of the <http\://textometrie.ens-lyon.fr/spip.php?rubrique61> page).
149 149
saveScriptBeforeExecution=Save script before execution
150 150
saveBeforeExecution=Save before execution ?
......
475 475
displayInFullText=Display in full text…
476 476
showHideCommandParameters=Show/Hide command parameters
477 477
startsWith=starts with
478
withinStructure=within structure
478
withinStructure=within structure
479
description=Description
480
descriptionOfTheP0CorpusP1=Description of the {0} corpus ({1})
481
aWord=a word
482
aWordWithItsProperties=a word with properties
483
removeTheLastWord=Remove the last word
484
withinAContextOf=within a context of
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/sections/InfosSection.java (revision 1520)
24 24
	
25 25
	private static final int SECTION_SIZE = 2;
26 26
	Label corpusNameLabel; // color change if the corpus name is malformed
27
	Text corpusText;
28 27
	private Text descText;
29 28
	
30 29
	public InfosSection(FormToolkit toolkit2, ScrolledForm form2, Composite parent, int style) {
31 30
		super(toolkit2, form2, parent, style);
32 31
		
33 32
		//this = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR|ExpandableComposite.TWISTIE);
34
		this.section.setText(TXMUIMessages.generalInformations);
33
		this.section.setText(TXMUIMessages.description);
35 34
		section.setExpanded(true);
36 35
		
37 36
		TableWrapLayout layout = new TableWrapLayout();
......
46 45

  
47 46
		Composite sectionClient = toolkit.createComposite(this.section);
48 47
		TableWrapLayout slayout = new TableWrapLayout();
49
		slayout.numColumns = 2;
48
		slayout.numColumns = 1;
50 49
		sectionClient.setLayout(slayout);
51 50
		this.section.setClient(sectionClient);
52 51

  
53
		corpusNameLabel = toolkit.createLabel(sectionClient, TXMUIMessages.corpusNameOnlyCapsAndNoDigitAtBeginning, SWT.WRAP);
52
//		corpusNameLabel = toolkit.createLabel(sectionClient, TXMUIMessages.corpusNameOnlyCapsAndNoDigitAtBeginning, SWT.WRAP);
53
//		TableWrapData gdata = new TableWrapData();
54
//		corpusNameLabel.setLayoutData(gdata);
55
//
56
		Label label = toolkit.createLabel(sectionClient, TXMUIMessages.completeNameAuthorDateLicenseComment, SWT.WRAP);
54 57
		TableWrapData gdata = new TableWrapData();
55
		corpusNameLabel.setLayoutData(gdata);
56

  
57
		Label label = toolkit.createLabel(sectionClient, TXMUIMessages.descriptionHTMLCompleteNameAuthorDateLicenseComment, SWT.WRAP);
58
		gdata = new TableWrapData();
59 58
		label.setLayoutData(gdata);
60 59

  
61
		corpusText = toolkit.createText(sectionClient, "", SWT.BORDER); //$NON-NLS-1$
62
		gdata = new TableWrapData(TableWrapData.FILL, TableWrapData.TOP);
63
		corpusText.setLayoutData(gdata);
64
		corpusText.setEnabled(false);
65

  
66 60
		descText = toolkit.createText(sectionClient, "", SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); //$NON-NLS-1$
67 61
		gdata = new TableWrapData(TableWrapData.FILL, TableWrapData.FILL);
68 62
		gdata.heightHint = 50;
......
72 66

  
73 67
	@Override
74 68
	public void update(Project project) {
75
		section.setText(NLS.bind(TXMUIMessages.corpusInfosP0, project.getSrcdir())); //$NON-NLS-1$
69
		section.setText(NLS.bind(TXMUIMessages.descriptionOfTheP0CorpusP1, project.getName(), project.getSrcdir())); //$NON-NLS-1$
76 70
		
77
		corpusText.setText(project.getName());
78
		
79 71
		String descContent = project.getDescription(); //$NON-NLS-1$
80 72
		descContent = descContent.replace("<pre><br/>", ""); //$NON-NLS-1$ //$NON-NLS-2$
81 73
		descContent = descContent.replace("</pre>", ""); //$NON-NLS-1$ //$NON-NLS-2$
......
87 79

  
88 80
	@Override
89 81
	public boolean save(Project project) {
90
		System.out.println("");
91
		
92
		if (corpusText.getText().trim().length() == 0) {
93
			System.out.println(TXMUIMessages.corpusNameIsMandatory);
94
			return false;
95
		}
96
		
97
		if (!corpusText.getText().matches("[A-Z][-A-Z0-9]{1,20}")) { //$NON-NLS-1$
98
			System.out.println(NLS.bind(TXMUIMessages.importStoppedColonCorpusNameDoesNotMatchesTheAZAZ09120PatternColonP0, corpusText.getText()));
99
			return false;
100
		}
101
		
102
		project.setName(corpusText.getText());
103
		
104 82
		project.setDescription("<pre><br/>"+descText.getText().replace("\n", "<br/>")+"</pre>"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
105 83
		
106 84
		return true;
......
108 86

  
109 87
	@Override
110 88
	public boolean checkFields() {
111
		String corpusname = corpusText.getText();
112
		Log.warning("Checking corpus name validity with '[A-Z][-A-Z0-9]+': "+corpusname);
113
		if (!corpusname.matches("[A-Z][-A-Z0-9]+")) { //$NON-NLS-1$
114
			System.out.println(NLS.bind(TXMUIMessages.importStoppedColonCorpusNameDoesNotMatchesTheAZAZ09120PatternColonP0, corpusname));
115

  
116
			Device device = Display.getCurrent ();
117
			Color red = new Color (device, 255, 0, 0);
118
			corpusNameLabel.setBackground(red);
119

  
120
			return false;
121
		}
122 89
		corpusNameLabel.setBackground(corpusNameLabel.getParent().getBackground());
123 90
		return true;
124 91
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/CorpusPage.java (revision 1520)
1088 1088
	//	}
1089 1089
	//
1090 1090
	public String getRootDir() {
1091
		if (project == null) return null;
1092
		if (project.getSrcdir() == null) return null;
1091 1093
		return project.getSrcdir().getAbsolutePath();
1092 1094
	}
1093 1095
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/MetadataPage.java (revision 1520)
479 479
		//viewer2.setInput(null);
480 480
		//viewer2.refresh();
481 481
		if (main.getRootDir() == null) return;
482
		
482 483
		metadataFile = Metadatas.findMetadataFile(new File(main.getRootDir())); //$NON-NLS-1$
483 484
		Metadatas temp = null;
484 485
		if (metadataFile.exists()) {//if their is a metadata file OK
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/QueryAssistDialog.java (revision 1520)
48 48
import org.eclipse.swt.widgets.Control;
49 49
import org.eclipse.swt.widgets.Label;
50 50
import org.eclipse.swt.widgets.Shell;
51
import org.eclipse.swt.widgets.Spinner;
51 52
import org.eclipse.swt.widgets.Text;
52 53
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
53 54
import org.txm.searchengine.cqp.corpus.CQPCorpus;
......
56 57
import org.txm.searchengine.cqp.corpus.WordProperty;
57 58
import org.txm.rcp.IImageKeys;
58 59
import org.txm.rcp.messages.TXMUIMessages;
60
import org.txm.rcp.swt.GLComposite;
59 61
// TODO: Auto-generated Javadoc
60 62
/**
61 63
 * build a query with the help of simple questions @ author mdecorde.
62 64
 */
63 65
public class QueryAssistDialog extends Dialog {
64
	
66

  
65 67
	/** The self. */
66 68
	QueryAssistDialog self;
67
	
69

  
68 70
	/** The parent. */
69 71
	Composite parent;
70
	
72

  
71 73
	/** The main panel. */
72 74
	Composite mainPanel;
73
	
75

  
74 76
	/** The parent shell. */
75 77
	Shell parentShell;
76 78

  
77 79
	/** The query. */
78 80
	String query;
79
	
81

  
80 82
	/** The nbwords. */
81 83
	int nbwords = 0;
82
	
84

  
83 85
	/** The wordfields. */
84 86
	List<WordField> wordfields = new ArrayList<WordField>();
85
	
87

  
86 88
	/** The linkfields. */
87 89
	List<LinkField> linkfields = new ArrayList<LinkField>();
88 90

  
......
91 93

  
92 94
	/** The cherche label. */
93 95
	Label chercheLabel;
94
	
96

  
95 97
	/** The wordcontainer. */
96 98
	Composite wordcontainer;
97 99

  
......
103 105

  
104 106
	private ScrolledComposite scrollComposite;
105 107

  
108
	private Spinner withinN;
109

  
106 110
	/**
107 111
	 * Instantiates a new query assist dialog.
108 112
	 *
......
140 144
			this.self = this;
141 145
			this.parent = p;
142 146
			// System.out.println(parent.getLayout());
143
			GridLayout mainlayout = new GridLayout(1, false);
147
			GridLayout mainlayout = new GridLayout(2, false);
144 148
			mainPanel = new Composite(parent, SWT.NONE);
145 149
			mainPanel.setLayout(mainlayout);
146 150
			GridData gridData = new GridData(GridData.FILL, GridData.FILL, true, true);
......
149 153
			// directory
150 154
			chercheLabel = new Label(mainPanel, SWT.NONE);
151 155
			chercheLabel.setAlignment(SWT.CENTER);
152
			chercheLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, true, false));
156
			chercheLabel.setLayoutData(new GridData(GridData.BEGINNING, GridData.FILL, true, false, 2 , 1));
153 157
			chercheLabel.setText(TXMUIMessages.imLookingForColon);
154
			
158

  
155 159
			scrollComposite = new ScrolledComposite(mainPanel, SWT.V_SCROLL);
156
			scrollComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true));
160
			scrollComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true, 2, 1));
157 161

  
158 162
			wordcontainer = new Composite(scrollComposite, SWT.NONE);
159
			wordcontainer.setLayout(new GridLayout(1, true));
163
			wordcontainer.setLayout(new GridLayout(1, false));
160 164

  
161 165
			scrollComposite.setContent(wordcontainer);
162 166
			scrollComposite.setExpandVertical(true);
......
172 176
			addWordField();
173 177

  
174 178
			Composite withinComposite = new Composite(mainPanel, SWT.NONE);
175
			withinComposite.setLayout(new GridLayout(2, false));
179
			withinComposite.setLayout(new GridLayout(3, false));
180
			withinComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false, 2, 1));
176 181
			withinButton = new Button(withinComposite, SWT.CHECK);
177
			withinButton.setText(TXMUIMessages.withinStructure); //"within structure: "
182
			withinButton.setText(TXMUIMessages.withinAContextOf); //"within structure: "
178 183
			withinButton.setToolTipText("Check to add structure contraint");
179 184
			withinButton.addSelectionListener(new SelectionListener() {
180 185
				@Override
181 186
				public void widgetSelected(SelectionEvent e) {
182 187
					structsCombo.setEnabled(withinButton.getSelection());
188
					withinN.setEnabled(withinButton.getSelection());
183 189
				}
184
				
190

  
185 191
				@Override
186 192
				public void widgetDefaultSelected(SelectionEvent e) { }
187 193
			});
194
			
195
			withinN = new Spinner(withinComposite, SWT.CHECK);
196
			withinN.setToolTipText("context size");
197
			withinN.setMinimum(1);
198
			withinN.setMaximum(200);
199
			
188 200
			structsCombo = new Combo(withinComposite, SWT.READ_ONLY);
189
			structsCombo.setToolTipText("The available structures");
201
			structsCombo.setToolTipText("The available contexts");
190 202
			structsCombo.setEnabled(false);
191
			int iText = 0;
203
			structsCombo.add("<word>");
204
			
205
			int iText = -1;
206
			int iP = -1;
192 207
			List<StructuralUnit> sus = corpus.getOrderedStructuralUnits();
193 208
			for (int i = 0 ; i < sus.size() ; i++) {
194 209
				StructuralUnit su = sus.get(i);
195 210
				if (su.getName().equals("txmcorpus")) continue;
196 211
				structsCombo.add(su.getName());
212
				
197 213
				if (su.getName().equals("text")) iText = i;
214
				if (su.getName().equals("p")) iP = i;
198 215
			}
199
			if (structsCombo.getItemCount() > 0) structsCombo.select(iText);
200
			
216
			if (structsCombo.getItemCount() > 0) {
217
				if (iP >= 0) {
218
					structsCombo.select(iP+1);
219
				} else {
220
					structsCombo.select(iText+1);
221
				}
222
			}
223

  
201 224
			Button addwordButton = new Button(mainPanel, SWT.PUSH);
202 225
			addwordButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
203 226
			addwordButton.setText(TXMUIMessages.addAWord);
......
222 245
				}
223 246
			});
224 247

  
248
			//			Button removeWordButton = new Button(mainPanel, SWT.PUSH);
249
			//			removeWordButton.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
250
			//			removeWordButton.setText(TXMUIMessages.removeTheLastWord);
251
			//			removeWordButton.addSelectionListener(new SelectionListener() {
252
			//				@Override
253
			//				public void widgetSelected(SelectionEvent e) {
254
			//					if (nbwords > 1) {
255
			//						removeWordField();
256
			//						removeLinkField();
257
			//						
258
			//						parent.layout(true);
259
			//						mainPanel.layout(true);
260
			//						wordcontainer.layout(true);
261
			//						scrollComposite.layout(true);
262
			//						mainPanel.update();
263
			//						wordcontainer.update();
264
			//						Rectangle r = scrollComposite.getClientArea();
265
			//						scrollComposite.setMinSize(wordcontainer.computeSize(r.width, SWT.DEFAULT));
266
			//						updateShell();
267
			//					}
268
			//				}
269
			//
270
			//				@Override
271
			//				public void widgetDefaultSelected(SelectionEvent e) {
272
			//				}
273
			//			});
274

  
225 275
		} catch (Exception e) {
226 276
			org.txm.rcp.utils.Logger.printStackTrace(e);
227 277
		}
......
241 291
	private void addWordField() {
242 292
		nbwords++;
243 293
		WordField wf = new WordField(wordcontainer, SWT.NONE, nbwords);
294
		GridData gd = new GridData(GridData.FILL, GridData.CENTER, false, false);
295
		gd.minimumWidth = 200;
296
		wf.setLayoutData(gd);
244 297
		wordfields.add(wf);
245 298

  
246 299
		wordcontainer.update();
247 300
		mainPanel.update();
248 301
	}
249 302

  
303
	/**
304
	 * remove the last link field.
305
	 */
306
	protected void removeLinkField() {
307
		if (linkfields.size() > 0) {
308
			linkfields.remove(linkfields.size()-1).dispose();	
309
		}
310
	}
311

  
312
	/**
313
	 * remove the last word field.
314
	 */
315
	private void removeWordField() {
316
		if (nbwords == 0) return;
317

  
318
		nbwords--;
319

  
320
		wordfields.remove(nbwords).dispose();
321

  
322
		wordcontainer.update();
323
		mainPanel.update();
324
	}
325

  
250 326
	/* (non-Javadoc)
251 327
	 * @see org.eclipse.jface.dialogs.Dialog#okPressed()
252 328
	 */
......
261 337
			query += lf.getQuery();
262 338
			query += wf.getQuery();
263 339
		}
264
		
340

  
265 341
		if (withinButton != null && withinButton.getSelection() && structsCombo.getText().length() > 0) {
266
			query += " within "+structsCombo.getText(); //$NON-NLS-1$
342
			query += " within ";
343
			
344
			if (withinN.getSelection() > 1) {
345
				query += ""+withinN.getSelection()+" "; //$NON-NLS-1$
346
			}
347
			
348
			if (!structsCombo.getText().equals("<word>")) {
349
				query += structsCombo.getText(); //$NON-NLS-1$
350
			}
267 351
		}
268 352

  
269 353
		super.okPressed();
......
285 369
		return this.query;
286 370
	}
287 371

  
288
	/**
289
	 * The Class WordField.
290
	 */
291
	public class WordField extends Composite {
292
		
372
	public class WordPropertyField extends GLComposite {
373

  
374

  
293 375
		/** The prop combo. */
294 376
		Combo propCombo;
295
		
377

  
296 378
		/** The test combo. */
297 379
		Combo testCombo;
298
		
380

  
299 381
		/** The value t. */
300 382
		Text valueT;
301
		
302
		Button targetButton;
303
		
304
		Button removeButton;
305 383

  
306 384
		/**
307 385
		 * Instantiates a new word field.
......
310 388
		 * @param style the style
311 389
		 * @param no the no
312 390
		 */
313
		public WordField(Composite parent, int style, int no) {
314
			super(parent, style);
391
		public WordPropertyField(Composite parent, int style, int no) {
392
			super(parent, style, ""+no);
315 393

  
316
			this.setLayout(new GridLayout(5, false));
394
			this.getLayout().numColumns = 3;
317 395

  
318
			Label titleL = new Label(this, SWT.NONE);
319
			titleL.setText(NLS.bind(TXMUIMessages.aWordWithItsProperty, no));
320
			GridData datalayout = new GridData(GridData.FILL, GridData.CENTER, true, false);
321
			titleL.setLayoutData(datalayout);
322

  
323 396
			propCombo = new Combo(this, SWT.READ_ONLY | SWT.SINGLE);
324 397
			propCombo.setToolTipText("Property to test");
325 398
			if (properties != null) {
......
342 415
			gdata.widthHint = 150;
343 416
			gdata.minimumWidth = 150;
344 417
			valueT.setLayoutData(gdata);
345
			
418
		}
419
	}
420

  
421
	/**
422
	 * The Class WordField.
423
	 */
424
	public class WordField extends Composite {
425

  
426
		ArrayList<QueryAssistDialog.WordPropertyField> propertyFields = new ArrayList<QueryAssistDialog.WordPropertyField>();
427
//		Combo propertiesAllOrOne;
428

  
429
		Button targetButton;
430

  
431
		Button removeButton;
432
		GLComposite propertiesFieldComposite;
433
		private Label titleL;
434
		private int no;
435

  
436

  
437
		/**
438
		 * Instantiates a new word field.
439
		 *
440
		 * @param parent the parent
441
		 * @param style the style
442
		 * @param no the no
443
		 */
444
		public WordField(Composite parent, int style, int no) {
445
			super(parent, style);
446
			this.no = no;
447
			this.setLayout(new GridLayout(8, false));
448

  
449
			titleL = new Label(this, SWT.NONE);
450

  
451
			GridData datalayout = new GridData(GridData.FILL, GridData.CENTER, true, false);
452
			titleL.setLayoutData(datalayout);
453

  
454
			GridData buttonLayout = new GridData(GridData.FILL, GridData.CENTER, false, false);
455
			buttonLayout.widthHint=25;
456

  
457
			Button addPropertyButton = new Button(this, SWT.PUSH);
458
			addPropertyButton.setLayoutData(buttonLayout);
459
			addPropertyButton.setText("+");
460
			addPropertyButton.setToolTipText("add a property test");
461
			addPropertyButton.addSelectionListener(new SelectionListener() {
462
				@Override
463
				public void widgetSelected(SelectionEvent e) {
464
					addProperty();
465
				}
466

  
467
				@Override
468
				public void widgetDefaultSelected(SelectionEvent e) { }
469
			});
470

  
471
			Button removePropertyButton = new Button(this, SWT.PUSH);
472
			removePropertyButton.setLayoutData(buttonLayout);
473
			removePropertyButton.setText("-");
474
			removePropertyButton.setToolTipText("remove the last property test");
475
			removePropertyButton.addSelectionListener(new SelectionListener() {
476
				@Override
477
				public void widgetSelected(SelectionEvent e) {
478
					removeProperty();
479
				}
480

  
481
				@Override
482
				public void widgetDefaultSelected(SelectionEvent e) { }
483
			});
484

  
485
			propertiesFieldComposite = new GLComposite(this, SWT.NONE, "properties");
486
			GridData propertiesvlayout = new GridData(GridData.FILL, GridData.CENTER, true, false);
487
			propertiesFieldComposite.setLayoutData(propertiesvlayout);
488
			propertiesFieldComposite.getLayout().numColumns = 2;
489

  
490
//			propertiesAllOrOne = new Combo(this, SWT.SINGLE-SWT.READ_ONLY);
491
//			propertiesAllOrOne.setToolTipText("ALL=all properties test must match / ONE=one property match is enough");
492
//			propertiesAllOrOne.add("ALL");
493
//			propertiesAllOrOne.add("ONE");
494
//			propertiesAllOrOne.select(0);
495
//			propertiesAllOrOne.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false));
496

  
497
			addProperty();
498

  
346 499
			targetButton = new Button(this, SWT.CHECK);
347 500
			targetButton.setToolTipText("Check to target the word in the query");
348 501
			targetButton.addSelectionListener(new SelectionListener() {
349
				
350 502
				@Override
351 503
				public void widgetSelected(SelectionEvent e) {
352 504
					if (targetButton.getSelection()) {
......
356 508
						targetButton.setSelection(true);
357 509
					}
358 510
				}
359
				
511

  
360 512
				@Override
361 513
				public void widgetDefaultSelected(SelectionEvent e) { }
362 514
			});
363
			
364
			
365
//			removeButton = new Button(this, SWT.PUSH);
366
//			removeButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
367
//			removeButton.addSelectionListener(new SelectionListener() {
368
//				
369
//				@Override
370
//				public void widgetSelected(SelectionEvent e) {
371
//					
372
//					int idx = QueryAssistDialog.this.wordfields.indexOf(WordField.this);
373
//					System.out.println("field: "+idx);
374
//					System.out.println(QueryAssistDialog.this.linkfields);
375
//					if (QueryAssistDialog.this.linkfields.size() > 0) {
376
//						if (idx > 0) idx--;
377
//						LinkField field = QueryAssistDialog.this.linkfields.remove(idx);
378
//						field.dispose();
379
//					}
380
//					QueryAssistDialog.this.wordfields.remove(WordField.this);
381
//					QueryAssistDialog.this.nbwords--;
382
//					WordField.this.dispose();
383
//					
384
//					wordcontainer.update();
385
//					mainPanel.update();
386
//					
387
//
388
//					QueryAssistDialog.this.parent.layout(true);
389
//					QueryAssistDialog.this.mainPanel.layout(true);
390
//					QueryAssistDialog.this.wordcontainer.layout(true);
391
//					QueryAssistDialog.this.scrollComposite.layout(true);
392
//				}
393
//				
394
//				@Override
395
//				public void widgetDefaultSelected(SelectionEvent e) { }
396
//			});
515

  
516

  
517
			removeButton = new Button(this, SWT.PUSH);
518
			removeButton.setImage(IImageKeys.getImage(IImageKeys.ACTION_DELETE));
519
			removeButton.addSelectionListener(new SelectionListener() {
520

  
521
				@Override
522
				public void widgetSelected(SelectionEvent e) {
523
					if (nbwords < 2) return;
524

  
525
					int idx = QueryAssistDialog.this.wordfields.indexOf(WordField.this);
526
					//					System.out.println("field: "+idx);
527
					//					System.out.println(QueryAssistDialog.this.linkfields);
528
					if (QueryAssistDialog.this.linkfields.size() > 0) {
529
						if (idx > 0) idx--;
530
						LinkField field = QueryAssistDialog.this.linkfields.remove(idx);
531
						field.dispose();
532
					}
533
					QueryAssistDialog.this.wordfields.remove(WordField.this);
534
					QueryAssistDialog.this.nbwords--;
535
					WordField.this.dispose();
536

  
537
					wordcontainer.update();
538
					mainPanel.update();
539

  
540
					QueryAssistDialog.this.parent.layout(true);
541
					QueryAssistDialog.this.mainPanel.layout(true);
542
					QueryAssistDialog.this.wordcontainer.layout(true);
543
					QueryAssistDialog.this.scrollComposite.layout(true);
544
				}
545

  
546
				@Override
547
				public void widgetDefaultSelected(SelectionEvent e) { }
548
			});
397 549
		}
398 550

  
551
		private void addProperty() {
552
			WordPropertyField pField = new WordPropertyField(propertiesFieldComposite, SWT.NONE, propertyFields.size());
553
			pField.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false, 2, 1));
554
			propertyFields.add(pField);
555
			updateWidgets();
556
		}
557

  
558
		private void removeProperty() {
559
			if (propertyFields.size() > 0) {
560
				WordPropertyField pField = propertyFields.remove(propertyFields.size()-1);
561
				pField.dispose();
562
			}
563
			updateWidgets();
564
		}
565

  
566
		private void updateWidgets() {
567
//			propertiesAllOrOne.setEnabled(propertyFields.size() > 1);
568
//			propertiesAllOrOne.setVisible(propertyFields.size() > 1);
569
//			((GridData)propertiesAllOrOne.getLayoutData()).exclude = propertyFields.size() < 2;
570
			if (propertyFields.size() == 0) {
571
				titleL.setText(TXMUIMessages.aWord);
572
			} else if (propertyFields.size() == 1) {
573
				titleL.setText(NLS.bind(TXMUIMessages.aWordWithItsProperty, no));
574
			} else {
575
				titleL.setText(NLS.bind(TXMUIMessages.aWordWithItsProperties, no));
576
			}
577
			propertiesFieldComposite.layout();
578
			//	this.layout(true);
579
			//mainPanel.layout(true);
580
			wordcontainer.layout();
581
			wordcontainer.update();
582
			//mainPanel.update();
583
		}
584

  
399 585
		/**
400 586
		 * Gets the query.
401 587
		 *
......
407 593
				query += "@";
408 594
			}
409 595
			query += "["; //$NON-NLS-1$
410
			query += propCombo.getItem(propCombo.getSelectionIndex());
411
			if (testCombo.getSelectionIndex() == 0)// equals
412
				query += "=\"" + valueT.getText().replace("\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
413
			else if (testCombo.getSelectionIndex() == 1)// starts with
414
				query += "=\"" + valueT.getText().replace("\"", "\\\"") + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
415
			else if (testCombo.getSelectionIndex() == 2)// ends with
416
				query += "=\".*" + valueT.getText().replace("\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
417
			else if (testCombo.getSelectionIndex() == 3)// contains
418
				query += "=\".*" + valueT.getText().replace("\"", "\\\"") + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
596

  
597
			int nField = 0;
598
			for (WordPropertyField f : propertyFields) {
599
				Combo propCombo = f.propCombo;
600
				Combo testCombo = f.testCombo;
601
				Text valueT = f.valueT;
602
				if (nField > 0) {
603
					//query += " "+(propertiesAllOrOne.getText().equals("ALL")?"&":"|")+" ";
604
					query += " & ";
605
				}
606

  
607
				query += propCombo.getItem(propCombo.getSelectionIndex());
608
				if (testCombo.getSelectionIndex() == 0)// equals
609
					query += "=\"" + valueT.getText().replace("\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
610
				else if (testCombo.getSelectionIndex() == 1)// starts with
611
					query += "=\"" + valueT.getText().replace("\"", "\\\"") + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
612
				else if (testCombo.getSelectionIndex() == 2)// ends with
613
					query += "=\".*" + valueT.getText().replace("\"", "\\\"") + "\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
614
				else if (testCombo.getSelectionIndex() == 3)// contains
615
					query += "=\".*" + valueT.getText().replace("\"", "\\\"") + ".*\""; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
616

  
617
				nField++;
618
			}
419 619
			return query + "]"; //$NON-NLS-1$
420 620
		}
421 621
	}
......
424 624
	 * The Class LinkField.
425 625
	 */
426 626
	public class LinkField extends Composite {
427
		
627

  
428 628
		/** The link combo. */
429 629
		Combo linkCombo;
430 630

  
......
455 655
			if (linkCombo.getSelectionIndex() == 0) // followed
456 656
				return ""; //$NON-NLS-1$
457 657
			else if (linkCombo.getSelectionIndex() == 1)// at least 0 word
458
				return "[]{0,50}"; //$NON-NLS-1$
658
				return "[]{0,50} "; //$NON-NLS-1$
459 659
			else if (linkCombo.getSelectionIndex() == 2)// at least 1 word
460
				return "[]{1, 50}"; //$NON-NLS-1$
660
				return "[]{1, 50} "; //$NON-NLS-1$
461 661
			return ""; //$NON-NLS-1$
462 662
		}
463 663
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/SourceDirectoryPage.java (revision 1520)
13 13
import org.eclipse.swt.events.ModifyListener;
14 14
import org.eclipse.swt.events.SelectionEvent;
15 15
import org.eclipse.swt.events.SelectionListener;
16
import org.eclipse.swt.graphics.Color;
17
import org.eclipse.swt.graphics.Device;
16 18
import org.eclipse.swt.layout.GridData;
17 19
import org.eclipse.swt.layout.GridLayout;
18 20
import org.eclipse.swt.widgets.Button;
19 21
import org.eclipse.swt.widgets.Composite;
20 22
import org.eclipse.swt.widgets.DirectoryDialog;
23
import org.eclipse.swt.widgets.Display;
21 24
import org.eclipse.swt.widgets.Label;
22 25
import org.eclipse.swt.widgets.Text;
26
import org.txm.rcp.messages.TXMUIMessages;
23 27
import org.txm.rcp.preferences.RCPPreferences;
24 28
import org.txm.utils.AsciiUtils;
29
import org.txm.utils.logger.Log;
25 30

  
26 31
public class SourceDirectoryPage extends WizardPage {
27 32
	private Text corpusName;
......
29 34
	//    private Text descriptionText;
30 35

  
31 36
	private Composite container;
32
	private Label newOrEdit;
37
	private Label newOrEdit, corpusNameLabel;
33 38

  
34 39
	public SourceDirectoryPage() {
35 40
		super("Select source directory");
......
112 117
		newOrEdit = new Label(container, SWT.NONE);
113 118
		newOrEdit.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).create());
114 119

  
120
		corpusNameLabel = new Label(container, SWT.NONE);
121
		corpusNameLabel.setLayoutData(GridDataFactory.fillDefaults().span(3, 1).create());
122
		
115 123
		//        label1 = new Label(container, SWT.NONE);
116 124
		//        label1.setText("Description");
117 125
		//        
......
138 146
			} else {
139 147
				newOrEdit.setText(NLS.bind("The ''{0}'' corpus will be created.", getCorpusName()));
140 148
			}
149
			
150
			String corpusname = corpusName.getText();
151
			Log.warning("Checking corpus name validity with '[A-Z][-A-Z0-9]+': "+corpusname);
152
			if (!corpusname.matches("[A-Z][-A-Z0-9]+")) { //$NON-NLS-1$
153
				newOrEdit.setText(NLS.bind(TXMUIMessages.corpusNameDoesNotMatchesTheAZAZ09120PatternColonP0, corpusname));
154
				return false;
155
			}
141 156
		}
142 157

  
143 158
		return getCorpusName().length() > 0 && getSourcePath().length() > 0;
tmp/org.txm.rcp/plugin.xml (revision 1520)
2560 2560
            id="org.txm.rcp.commands.function.ExportResult"
2561 2561
            name="%command.name.24">
2562 2562
      </command>
2563
            <command
2564
                  defaultHandler="org.txm.rcp.handlers.export.ExportResultParameters"
2565
                  id="org.txm.rcp.handlers.export.ExportResultParameters"
2566
                  name="%command.name.35">
2563
      <command
2564
            defaultHandler="org.txm.rcp.handlers.export.ExportResultParameters"
2565
            id="org.txm.rcp.handlers.export.ExportResultParameters"
2566
            name="%command.name.35">
2567 2567
      </command>
2568 2568
      <command
2569 2569
            defaultHandler="org.txm.rcp.handlers.export.ExportSVG"
......
2571 2571
            name="%command.name.34">
2572 2572
      </command>
2573 2573
      <command
2574
            defaultHandler="org.txm.rcp.handlers.export.ImportResultParameters"
2575
            id="org.txm.rcp.handlers.export.ImportResultParameters"
2576
            name="%command.name.38">
2577
      </command>
2578
      <command
2579 2574
            defaultHandler="org.txm.rcp.handlers.export.ImportResult"
2580 2575
            id="org.txm.rcp.handlers.export.ImportResult"
2581 2576
            name="%command.name.39">

Formats disponibles : Unified diff