Révision 2947
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/MultiplePropertySelectionDialog.java (revision 2947) | ||
---|---|---|
46 | 46 |
import org.txm.rcp.messages.TXMUIMessages; |
47 | 47 |
import org.txm.searchengine.cqp.corpus.Property; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
49 |
import org.txm.searchengine.cqp.corpus.VirtualProperty; |
|
49 | 50 |
|
50 | 51 |
// TODO: Auto-generated Javadoc |
51 | 52 |
/** |
52 | 53 |
* The dialog box called to select the view properties. |
53 | 54 |
* |
54 |
* @ author mdecorde
|
|
55 |
* @ author mdecorde |
|
55 | 56 |
*/ |
56 | 57 |
public class MultiplePropertySelectionDialog<P extends Property> extends Dialog { |
57 |
|
|
58 |
|
|
58 | 59 |
/** The available properties. */ |
59 | 60 |
final private List<P> availableProperties; |
60 |
|
|
61 |
|
|
61 | 62 |
/** The selected properties. */ |
62 | 63 |
final private List<P> selectedProperties; |
63 |
|
|
64 |
|
|
64 | 65 |
/** The maxprops. */ |
65 | 66 |
int maxprops = -1; |
66 |
|
|
67 |
|
|
67 | 68 |
/** The available properties view. */ |
68 | 69 |
org.eclipse.swt.widgets.List availablePropertiesView; |
69 |
|
|
70 |
|
|
70 | 71 |
/** The selected properties view. */ |
71 | 72 |
org.eclipse.swt.widgets.List selectedPropertiesView; |
72 |
|
|
73 |
|
|
73 | 74 |
private ArrayList<P> cancelSelectedProperties; |
74 |
|
|
75 |
|
|
75 | 76 |
private ArrayList<P> cancelAvailableProperties; |
76 |
|
|
77 |
|
|
77 | 78 |
/** |
78 | 79 |
* Instantiates a new view property selection dialog. |
79 | 80 |
* |
... | ... | |
86 | 87 |
List<P> selectedProperties) { |
87 | 88 |
this(parentShell.getShell(), availableProperties, selectedProperties); |
88 | 89 |
} |
89 |
|
|
90 |
|
|
90 | 91 |
/** |
91 | 92 |
* Instantiates a new view property selection dialog. |
92 | 93 |
* |
... | ... | |
99 | 100 |
List<P> selectedProperties) { |
100 | 101 |
this(shell, availableProperties, selectedProperties, -1); |
101 | 102 |
} |
102 |
|
|
103 |
|
|
103 | 104 |
/** |
104 | 105 |
* Instantiates a new view property selection dialog. |
105 | 106 |
* |
... | ... | |
112 | 113 |
List<P> availableProperties, |
113 | 114 |
List<P> selectedProperties, int maxprops) { |
114 | 115 |
super(shell); |
115 |
|
|
116 |
|
|
116 | 117 |
this.availableProperties = availableProperties; |
117 | 118 |
this.selectedProperties = selectedProperties; |
118 |
this.cancelAvailableProperties = new ArrayList<P>(availableProperties);
|
|
119 |
this.cancelSelectedProperties = new ArrayList<P>(selectedProperties);
|
|
119 |
this.cancelAvailableProperties = new ArrayList<>(availableProperties); |
|
120 |
this.cancelSelectedProperties = new ArrayList<>(selectedProperties); |
|
120 | 121 |
|
121 | 122 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
122 | 123 |
this.maxprops = maxprops; |
123 | 124 |
} |
124 |
|
|
125 |
|
|
125 | 126 |
/** |
126 | 127 |
* Gets the selected properties. |
127 | 128 |
* |
... | ... | |
130 | 131 |
public List<P> getSelectedProperties() { |
131 | 132 |
return selectedProperties; |
132 | 133 |
} |
133 |
|
|
134 |
/* (non-Javadoc) |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
135 | 137 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
136 | 138 |
*/ |
137 | 139 |
@Override |
... | ... | |
140 | 142 |
newShell.setText(TXMUIMessages.common_displayOptions); |
141 | 143 |
newShell.setMinimumSize(300, 200); |
142 | 144 |
} |
143 |
|
|
144 |
/* (non-Javadoc) |
|
145 |
|
|
146 |
/* |
|
147 |
* (non-Javadoc) |
|
145 | 148 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
146 | 149 |
*/ |
147 | 150 |
@Override |
... | ... | |
149 | 152 |
// parent.setLayout(new FormLayout()); |
150 | 153 |
Composite mainArea = new Composite(parent, SWT.NONE); |
151 | 154 |
mainArea.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); |
152 |
|
|
155 |
|
|
153 | 156 |
// 4 columns |
154 | 157 |
GridLayout layout = new GridLayout(4, false); |
155 | 158 |
mainArea.setLayout(layout); |
156 |
|
|
159 |
|
|
157 | 160 |
availablePropertiesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.V_SCROLL); |
158 | 161 |
GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
159 | 162 |
availablePropertiesView.setLayoutData(gridData); |
160 |
|
|
163 |
|
|
161 | 164 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
162 | 165 |
selectionButtons.setLayout(new GridLayout(1, false)); |
163 | 166 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
164 | 167 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
165 |
|
|
168 |
|
|
166 | 169 |
selectedPropertiesView = new org.eclipse.swt.widgets.List(mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
167 | 170 |
gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
168 | 171 |
selectedPropertiesView.setLayoutData(gridData); |
169 |
|
|
172 |
|
|
170 | 173 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
171 | 174 |
orderButtons.setLayout(new GridLayout(1, false)); |
172 | 175 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
173 | 176 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
174 |
|
|
177 |
|
|
175 | 178 |
select.addSelectionListener(new SelectionAdapter() { |
179 |
|
|
176 | 180 |
@Override |
177 | 181 |
public void widgetSelected(SelectionEvent e) { |
178 | 182 |
int index = availablePropertiesView.getSelectionIndex(); |
179 | 183 |
if (maxprops == 1) { |
180 | 184 |
selectedProperties.add(availableProperties.get(index)); |
181 | 185 |
availableProperties.remove(index); |
182 |
|
|
186 |
|
|
183 | 187 |
availableProperties.add(selectedProperties.get(0)); |
184 | 188 |
selectedProperties.remove(0); |
185 |
} else { |
|
189 |
} |
|
190 |
else { |
|
186 | 191 |
if (maxprops > 0) { |
187 | 192 |
if (selectedProperties.size() >= maxprops) |
188 | 193 |
return; |
... | ... | |
196 | 201 |
availablePropertiesView.setSelection(index); |
197 | 202 |
} |
198 | 203 |
}); |
199 |
|
|
204 |
|
|
200 | 205 |
unselect.addSelectionListener(new SelectionAdapter() { |
206 |
|
|
201 | 207 |
@Override |
202 | 208 |
public void widgetSelected(SelectionEvent e) { |
203 | 209 |
deselectProperties(); |
204 | 210 |
} |
205 | 211 |
}); |
206 |
|
|
212 |
|
|
207 | 213 |
up.addSelectionListener(new SelectionAdapter() { |
214 |
|
|
208 | 215 |
@Override |
209 | 216 |
public void widgetSelected(SelectionEvent e) { |
210 | 217 |
int index = selectedPropertiesView.getSelectionIndex(); |
211 | 218 |
if (index > 0) { |
212 | 219 |
P selectedP = selectedProperties.get(index); |
213 | 220 |
P upperP = selectedProperties.get(index - 1); |
214 |
|
|
221 |
|
|
215 | 222 |
selectedProperties.set(index, upperP); |
216 | 223 |
selectedProperties.set(index - 1, selectedP); |
217 |
|
|
224 |
|
|
218 | 225 |
reload(); |
219 | 226 |
selectedPropertiesView.setSelection(index - 1); |
220 | 227 |
} |
221 | 228 |
} |
222 | 229 |
}); |
223 |
|
|
230 |
|
|
224 | 231 |
down.addSelectionListener(new SelectionAdapter() { |
232 |
|
|
225 | 233 |
@Override |
226 | 234 |
public void widgetSelected(SelectionEvent e) { |
227 | 235 |
int index = selectedPropertiesView.getSelectionIndex(); |
228 | 236 |
if (index < selectedProperties.size() - 1 && index >= 0) { |
229 | 237 |
P selectedP = selectedProperties.get(index); |
230 | 238 |
P bellowP = selectedProperties.get(index + 1); |
231 |
|
|
239 |
|
|
232 | 240 |
selectedProperties.set(index, bellowP); |
233 | 241 |
selectedProperties.set(index + 1, selectedP); |
234 |
|
|
242 |
|
|
235 | 243 |
reload(); |
236 | 244 |
selectedPropertiesView.setSelection(index + 1); |
237 | 245 |
} |
238 | 246 |
} |
239 | 247 |
}); |
240 |
|
|
248 |
|
|
241 | 249 |
availablePropertiesView.addMouseListener(new MouseAdapter() { |
250 |
|
|
242 | 251 |
@Override |
243 | 252 |
public void mouseDoubleClick(MouseEvent e) { |
244 |
|
|
245 |
if ( maxprops == 1) {
|
|
253 |
|
|
254 |
if (maxprops == 1) { |
|
246 | 255 |
int index = availablePropertiesView.getSelectionIndex(); |
247 |
//System.out.println("dl click, maxprops="+maxprops+" idx="+index); |
|
256 |
// System.out.println("dl click, maxprops="+maxprops+" idx="+index);
|
|
248 | 257 |
selectedProperties.add(availableProperties.get(index)); |
249 | 258 |
availableProperties.remove(index); |
250 |
|
|
259 |
|
|
251 | 260 |
availableProperties.add(selectedProperties.get(0)); |
252 | 261 |
selectedProperties.remove(0); |
253 |
|
|
262 |
|
|
254 | 263 |
reload(); |
255 |
|
|
256 |
} else { |
|
264 |
|
|
265 |
} |
|
266 |
else { |
|
257 | 267 |
int index = availablePropertiesView.getSelectionIndex(); |
258 | 268 |
if (index >= 0) { |
259 | 269 |
selectedProperties.add(availableProperties.get(index)); |
260 | 270 |
availableProperties.remove(index); |
261 |
|
|
271 |
|
|
262 | 272 |
reload(); |
263 | 273 |
availablePropertiesView.setSelection(index); |
264 | 274 |
} |
265 | 275 |
} |
266 | 276 |
} |
267 | 277 |
}); |
268 |
|
|
278 |
|
|
269 | 279 |
selectedPropertiesView.addMouseListener(new MouseAdapter() { |
280 |
|
|
270 | 281 |
@Override |
271 | 282 |
public void mouseDoubleClick(MouseEvent e) { |
272 | 283 |
deselectProperties(); |
273 | 284 |
} |
274 | 285 |
}); |
275 |
|
|
286 |
|
|
276 | 287 |
reload(); |
277 | 288 |
return mainArea; |
278 | 289 |
} |
279 |
|
|
290 |
|
|
280 | 291 |
private void deselectProperties() { |
281 | 292 |
if (selectedProperties.size() > 1) { |
282 | 293 |
int index = selectedPropertiesView.getSelectionIndex(); |
283 |
|
|
294 |
|
|
284 | 295 |
availableProperties.add(selectedProperties.get(index)); |
285 | 296 |
selectedProperties.remove(index); |
286 |
|
|
297 |
|
|
287 | 298 |
reload(); |
288 | 299 |
selectedPropertiesView.setSelection(index); |
289 | 300 |
} |
... | ... | |
299 | 310 |
} |
300 | 311 |
availablePropertiesView.removeAll(); |
301 | 312 |
for (Property property : availableProperties) { |
302 |
//if (!property.getName().equals("id")) //$NON-NLS-1$ |
|
303 |
if (property instanceof StructuralUnitProperty) {
|
|
304 |
availablePropertiesView.add(((StructuralUnitProperty)property).getFullName());
|
|
313 |
// if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
314 |
if (property instanceof VirtualProperty) {
|
|
315 |
availablePropertiesView.add(((VirtualProperty) property).getFullName());
|
|
305 | 316 |
} |
317 |
else if (property instanceof StructuralUnitProperty) { |
|
318 |
availablePropertiesView.add(((StructuralUnitProperty) property).getFullName()); |
|
319 |
} |
|
306 | 320 |
else { |
307 | 321 |
availablePropertiesView.add(property.getName()); |
308 | 322 |
} |
309 | 323 |
} |
310 | 324 |
selectedPropertiesView.removeAll(); |
311 | 325 |
for (Property property : selectedProperties) { |
312 |
//if (!property.getName().equals("id")) //$NON-NLS-1$ |
|
326 |
// if (!property.getName().equals("id")) //$NON-NLS-1$
|
|
313 | 327 |
if (property instanceof StructuralUnitProperty) { |
314 |
selectedPropertiesView.add(((StructuralUnitProperty)property).getFullName()); |
|
328 |
selectedPropertiesView.add(((StructuralUnitProperty) property).getFullName());
|
|
315 | 329 |
} |
316 | 330 |
else { |
317 | 331 |
selectedPropertiesView.add(property.getName()); |
318 | 332 |
} |
319 | 333 |
} |
320 |
|
|
334 |
|
|
321 | 335 |
availablePropertiesView.getParent().layout(); |
322 | 336 |
} |
323 |
|
|
324 |
/* (non-Javadoc) |
|
337 |
|
|
338 |
/* |
|
339 |
* (non-Javadoc) |
|
325 | 340 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
326 | 341 |
*/ |
327 | 342 |
@Override |
... | ... | |
330 | 345 |
super.okPressed(); |
331 | 346 |
} |
332 | 347 |
} |
333 |
|
|
334 |
/* (non-Javadoc) |
|
348 |
|
|
349 |
/* |
|
350 |
* (non-Javadoc) |
|
335 | 351 |
* @see org.eclipse.jface.dialogs.Dialog#okPressed() |
336 | 352 |
*/ |
337 | 353 |
@Override |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/dialog/SinglePropertySelectionDialog.java (revision 2947) | ||
---|---|---|
46 | 46 |
import org.txm.rcp.messages.TXMUIMessages; |
47 | 47 |
import org.txm.searchengine.cqp.corpus.Property; |
48 | 48 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
49 |
import org.txm.searchengine.cqp.corpus.VirtualProperty; |
|
49 | 50 |
|
50 | 51 |
// TODO: Auto-generated Javadoc |
51 | 52 |
/** |
... | ... | |
196 | 197 |
availablePropertiesView.removeAll(); |
197 | 198 |
for (Property property : allProperties) { |
198 | 199 |
// if (!property.getName().equals("id")) //$NON-NLS-1$ |
199 |
if (property instanceof StructuralUnitProperty) { |
|
200 |
if (property instanceof VirtualProperty) { |
|
201 |
availablePropertiesView.add(((VirtualProperty) property).getFullName()); |
|
202 |
} |
|
203 |
else if (property instanceof StructuralUnitProperty) { |
|
200 | 204 |
availablePropertiesView.add(((StructuralUnitProperty) property).getFullName()); |
201 | 205 |
} |
202 | 206 |
else { |
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineSortReferencePattern.java (revision 2947) | ||
---|---|---|
52 | 52 |
import org.txm.searchengine.cqp.corpus.Property; |
53 | 53 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
54 | 54 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
55 |
import org.txm.searchengine.cqp.corpus.VirtualProperty; |
|
56 |
|
|
55 | 57 |
/** |
56 | 58 |
* Action to build the reference pattern. |
57 | 59 |
* |
58 | 60 |
* @author mdecorde |
59 | 61 |
*/ |
60 | 62 |
public class DefineSortReferencePattern extends Action implements IWorkbenchAction { |
61 |
|
|
63 |
|
|
62 | 64 |
/** The Constant ID. */ |
63 | 65 |
private static final String ID = "org.txm.rcp.editors.concordances.definereferencepattern"; //$NON-NLS-1$ |
64 |
|
|
66 |
|
|
65 | 67 |
/** The window. */ |
66 | 68 |
private IWorkbenchWindow window; |
67 |
|
|
69 |
|
|
68 | 70 |
/** The concordance editor. */ |
69 | 71 |
private ConcordanceEditor concordanceEditor; |
70 |
|
|
72 |
|
|
71 | 73 |
/** |
72 | 74 |
* Instantiates a new define reference pattern. |
73 | 75 |
* |
... | ... | |
82 | 84 |
setText(TXMUIMessages.referencesAmpsortOptions); |
83 | 85 |
setToolTipText(TXMUIMessages.referencesSortOptions); |
84 | 86 |
} |
85 |
|
|
86 |
/* (non-Javadoc) |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
87 | 90 |
* @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose() |
88 | 91 |
*/ |
89 | 92 |
@Override |
90 |
public void dispose() { |
|
91 |
} |
|
92 |
|
|
93 |
/* (non-Javadoc)
|
|
93 |
public void dispose() {}
|
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc)
|
|
94 | 97 |
* @see org.eclipse.jface.action.Action#run() |
95 | 98 |
*/ |
96 | 99 |
@Override |
97 | 100 |
public void run() { |
98 | 101 |
List<StructuralUnit> structuralUnits = null; |
99 |
List<Property> availableReferenceItems = new ArrayList<Property>();
|
|
102 |
List<Property> availableReferenceItems = new ArrayList<>(); |
|
100 | 103 |
try { |
101 | 104 |
structuralUnits = concordanceEditor.getCorpus().getOrderedStructuralUnits(); |
102 | 105 |
availableReferenceItems.addAll(concordanceEditor.getCorpus().getOrderedProperties()); |
103 |
} catch (Exception e) { |
|
106 |
} |
|
107 |
catch (Exception e) { |
|
104 | 108 |
org.txm.utils.logger.Log.printStackTrace(e); |
105 | 109 |
} |
106 |
|
|
110 |
|
|
107 | 111 |
for (StructuralUnit unit : structuralUnits) { |
108 | 112 |
availableReferenceItems.addAll(unit.getOrderedProperties()); |
109 | 113 |
} |
110 |
|
|
114 |
|
|
111 | 115 |
// System.out.println("selected "+concordanceEditor.getSelectedReferences()); |
112 | 116 |
// System.out.println("before avail"+availableReferenceItems); |
113 | 117 |
availableReferenceItems.removeAll(concordanceEditor.getSelectedSortReferences()); |
114 |
|
|
118 |
|
|
119 |
availableReferenceItems.addAll(concordanceEditor.getCorpus().getVirtualProperties()); |
|
120 |
|
|
115 | 121 |
// System.out.println("after avail"+availableReferenceItems); |
116 | 122 |
DefineReferencePatternDialog d = null; |
117 | 123 |
d = new DefineReferencePatternDialog(window.getShell(), |
118 | 124 |
availableReferenceItems, concordanceEditor |
119 |
.getSelectedSortReferences()); |
|
120 |
|
|
125 |
.getSelectedSortReferences());
|
|
126 |
|
|
121 | 127 |
if (d.open() == Window.OK) { |
122 | 128 |
concordanceEditor.setRefSortPattern(new ReferencePattern(d |
123 | 129 |
.getSelectesdReferenceItems())); |
124 |
//System.out.println(concordanceEditor.getSortReferencePattern()); |
|
130 |
// System.out.println(concordanceEditor.getSortReferencePattern());
|
|
125 | 131 |
} |
126 | 132 |
} |
127 |
|
|
133 |
|
|
128 | 134 |
/** |
129 | 135 |
* The Class DefineReferencePatternDialog. |
130 | 136 |
*/ |
131 | 137 |
private class DefineReferencePatternDialog extends Dialog { |
132 |
|
|
138 |
|
|
133 | 139 |
/** The available reference items. */ |
134 | 140 |
private List<Property> availableReferenceItems; |
135 |
|
|
141 |
|
|
136 | 142 |
/** The selected reference items. */ |
137 | 143 |
private List<Property> selectedReferenceItems; |
138 |
|
|
144 |
|
|
139 | 145 |
/** |
140 | 146 |
* Instantiates a new define reference pattern dialog. |
141 | 147 |
* |
... | ... | |
147 | 153 |
List<Property> availableReferenceItems, |
148 | 154 |
List<Property> selectedReferences) { |
149 | 155 |
super(parentShell); |
150 |
|
|
156 |
|
|
151 | 157 |
this.availableReferenceItems = availableReferenceItems; |
152 | 158 |
this.selectedReferenceItems = selectedReferences; |
153 | 159 |
this.availableReferenceItems.removeAll(selectedReferences); |
154 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
|
|
160 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
155 | 161 |
} |
156 |
|
|
162 |
|
|
157 | 163 |
/** |
158 | 164 |
* Gets the selectesd reference items. |
159 | 165 |
* |
... | ... | |
162 | 168 |
public List<Property> getSelectesdReferenceItems() { |
163 | 169 |
return selectedReferenceItems; |
164 | 170 |
} |
165 |
|
|
166 |
/* (non-Javadoc) |
|
171 |
|
|
172 |
/* |
|
173 |
* (non-Javadoc) |
|
167 | 174 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
168 | 175 |
*/ |
169 | 176 |
@Override |
170 | 177 |
protected void configureShell(Shell shell) { |
171 | 178 |
super.configureShell(shell); |
172 | 179 |
shell.setText(TXMUIMessages.referencesSortOptions); |
173 |
|
|
180 |
|
|
174 | 181 |
shell.setSize(400, 500); |
175 | 182 |
shell.setLocation(shell.getParent().getLocation()); |
176 | 183 |
} |
177 |
|
|
178 |
/* (non-Javadoc) |
|
184 |
|
|
185 |
/* |
|
186 |
* (non-Javadoc) |
|
179 | 187 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
180 | 188 |
*/ |
181 | 189 |
@Override |
182 | 190 |
protected Control createDialogArea(Composite parent) { |
183 |
|
|
191 |
|
|
184 | 192 |
Composite mainArea = new Composite(parent, SWT.NONE); |
185 | 193 |
mainArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
186 | 194 |
true, true)); |
187 | 195 |
mainArea.setLayout(new GridLayout(4, false)); |
188 |
|
|
196 |
|
|
189 | 197 |
final org.eclipse.swt.widgets.List availbleItems = new org.eclipse.swt.widgets.List( |
190 | 198 |
mainArea, SWT.BORDER | SWT.V_SCROLL); |
191 | 199 |
for (Property property : availableReferenceItems) { |
192 |
if (property instanceof StructuralUnitProperty) { |
|
200 |
if (property instanceof VirtualProperty) { |
|
201 |
VirtualProperty sProperty = (VirtualProperty) property; |
|
202 |
availbleItems.add(sProperty.getFullName()); |
|
203 |
} |
|
204 |
else if (property instanceof StructuralUnitProperty) { |
|
193 | 205 |
StructuralUnitProperty sProperty = (StructuralUnitProperty) property; |
194 | 206 |
availbleItems.add(sProperty.getStructuralUnit().getName() |
195 | 207 |
+ ": " + property.getName()); //$NON-NLS-1$ |
196 |
} else { |
|
208 |
} |
|
209 |
else { |
|
197 | 210 |
availbleItems.add(property.getName()); |
198 | 211 |
} |
199 | 212 |
} |
200 |
|
|
213 |
|
|
201 | 214 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, |
202 | 215 |
true, true); |
203 |
//Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
|
204 |
//gridData.widthHint = size.x; |
|
216 |
// Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
|
217 |
// gridData.widthHint = size.x;
|
|
205 | 218 |
availbleItems.setLayoutData(gridData); |
206 |
|
|
219 |
|
|
207 | 220 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
208 | 221 |
selectionButtons.setLayout(new GridLayout(1, false)); |
209 | 222 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
210 | 223 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
211 |
|
|
224 |
|
|
212 | 225 |
final org.eclipse.swt.widgets.List selectedItems = new org.eclipse.swt.widgets.List( |
213 | 226 |
mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
214 | 227 |
selectedItems.setLayoutData(gridData); |
215 | 228 |
for (Property property : selectedReferenceItems) { |
229 |
if (property instanceof VirtualProperty) { |
|
230 |
VirtualProperty sProperty = (VirtualProperty) property; |
|
231 |
selectedItems.add(sProperty.getFullName()); |
|
232 |
} |
|
216 | 233 |
if (property instanceof StructuralUnitProperty) { |
217 | 234 |
StructuralUnitProperty sProperty = (StructuralUnitProperty) property; |
218 | 235 |
selectedItems.add(sProperty.getStructuralUnit().getName() |
219 | 236 |
+ ": " + property.getName()); //$NON-NLS-1$ |
220 |
} else { |
|
237 |
} |
|
238 |
else { |
|
221 | 239 |
selectedItems.add(property.getName()); |
222 | 240 |
} |
223 | 241 |
} |
224 |
|
|
225 |
//DBL CLICK Listeners |
|
242 |
|
|
243 |
// DBL CLICK Listeners
|
|
226 | 244 |
selectedItems.addMouseListener(new MouseListener() { |
245 |
|
|
227 | 246 |
@Override |
228 |
public void mouseUp(MouseEvent e) { }
|
|
229 |
|
|
247 |
public void mouseUp(MouseEvent e) {} |
|
248 |
|
|
230 | 249 |
@Override |
231 |
public void mouseDown(MouseEvent e) { }
|
|
232 |
|
|
250 |
public void mouseDown(MouseEvent e) {} |
|
251 |
|
|
233 | 252 |
@Override |
234 | 253 |
public void mouseDoubleClick(MouseEvent e) { |
235 | 254 |
int ind = selectedItems.getSelectionIndex(); |
236 | 255 |
availbleItems.add(selectedItems.getItem(ind)); |
237 | 256 |
selectedItems.remove(ind); |
238 | 257 |
availableReferenceItems |
239 |
.add(selectedReferenceItems.get(ind)); |
|
258 |
.add(selectedReferenceItems.get(ind));
|
|
240 | 259 |
selectedReferenceItems.remove(ind); |
241 |
selectedItems.setSelection(ind);
|
|
260 |
selectedItems.setSelection(ind); |
|
242 | 261 |
} |
243 | 262 |
}); |
244 | 263 |
availbleItems.addMouseListener(new MouseListener() { |
264 |
|
|
245 | 265 |
@Override |
246 |
public void mouseUp(MouseEvent e) { }
|
|
247 |
|
|
266 |
public void mouseUp(MouseEvent e) {} |
|
267 |
|
|
248 | 268 |
@Override |
249 |
public void mouseDown(MouseEvent e) { }
|
|
250 |
|
|
269 |
public void mouseDown(MouseEvent e) {} |
|
270 |
|
|
251 | 271 |
@Override |
252 | 272 |
public void mouseDoubleClick(MouseEvent e) { |
253 | 273 |
int ind = availbleItems.getSelectionIndex(); |
254 | 274 |
selectedItems.add(availbleItems.getItem(ind)); |
255 | 275 |
availbleItems.remove(ind); |
256 | 276 |
selectedReferenceItems |
257 |
.add(availableReferenceItems.get(ind)); |
|
277 |
.add(availableReferenceItems.get(ind));
|
|
258 | 278 |
availableReferenceItems.remove(ind); |
259 | 279 |
availbleItems.setSelection(ind); |
260 | 280 |
} |
261 | 281 |
}); |
262 |
|
|
282 |
|
|
263 | 283 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
264 | 284 |
orderButtons.setLayout(new GridLayout(1, false)); |
265 | 285 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
266 | 286 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
267 |
|
|
287 |
|
|
268 | 288 |
select.addSelectionListener(new SelectionAdapter() { |
289 |
|
|
269 | 290 |
@Override |
270 | 291 |
public void widgetSelected(SelectionEvent e) { |
271 | 292 |
int ind = availbleItems.getSelectionIndex(); |
272 | 293 |
selectedItems.add(availbleItems.getItem(ind)); |
273 | 294 |
availbleItems.remove(ind); |
274 | 295 |
selectedReferenceItems |
275 |
.add(availableReferenceItems.get(ind)); |
|
296 |
.add(availableReferenceItems.get(ind));
|
|
276 | 297 |
availableReferenceItems.remove(ind); |
277 | 298 |
availbleItems.setSelection(ind); |
278 | 299 |
} |
279 | 300 |
}); |
280 |
|
|
301 |
|
|
281 | 302 |
unselect.addSelectionListener(new SelectionAdapter() { |
303 |
|
|
282 | 304 |
@Override |
283 | 305 |
public void widgetSelected(SelectionEvent e) { |
284 | 306 |
int ind = selectedItems.getSelectionIndex(); |
285 | 307 |
availbleItems.add(selectedItems.getItem(ind)); |
286 | 308 |
selectedItems.remove(ind); |
287 | 309 |
availableReferenceItems |
288 |
.add(selectedReferenceItems.get(ind)); |
|
310 |
.add(selectedReferenceItems.get(ind));
|
|
289 | 311 |
selectedReferenceItems.remove(ind); |
290 |
selectedItems.setSelection(ind);
|
|
312 |
selectedItems.setSelection(ind); |
|
291 | 313 |
} |
292 | 314 |
}); |
293 |
|
|
315 |
|
|
294 | 316 |
up.addSelectionListener(new SelectionAdapter() { |
317 |
|
|
295 | 318 |
@Override |
296 | 319 |
public void widgetSelected(SelectionEvent e) { |
297 | 320 |
int ind = selectedItems.getSelectionIndex(); |
298 | 321 |
if (ind > 0) { |
299 | 322 |
String value = selectedItems.getItem(ind); |
300 | 323 |
selectedItems.remove(ind); |
301 |
selectedItems.add(value, ind -1); |
|
302 |
|
|
324 |
selectedItems.add(value, ind - 1);
|
|
325 |
|
|
303 | 326 |
Property prop = selectedReferenceItems.get(ind); |
304 | 327 |
selectedReferenceItems.remove(ind); |
305 |
selectedReferenceItems.add(ind-1,prop);
|
|
306 |
|
|
307 |
selectedItems.setSelection(ind -1); |
|
328 |
selectedReferenceItems.add(ind - 1, prop);
|
|
329 |
|
|
330 |
selectedItems.setSelection(ind - 1);
|
|
308 | 331 |
} |
309 | 332 |
} |
310 | 333 |
}); |
311 |
|
|
334 |
|
|
312 | 335 |
down.addSelectionListener(new SelectionAdapter() { |
336 |
|
|
313 | 337 |
@Override |
314 | 338 |
public void widgetSelected(SelectionEvent e) { |
315 | 339 |
int ind = selectedItems.getSelectionIndex(); |
... | ... | |
317 | 341 |
String value = selectedItems.getItem(ind); |
318 | 342 |
selectedItems.remove(ind); |
319 | 343 |
selectedItems.add(value, ind + 1); |
320 |
|
|
344 |
|
|
321 | 345 |
Property prop = selectedReferenceItems.get(ind); |
322 | 346 |
selectedReferenceItems.remove(ind); |
323 |
selectedReferenceItems.add(ind+1, prop);
|
|
324 |
|
|
347 |
selectedReferenceItems.add(ind + 1, prop);
|
|
348 |
|
|
325 | 349 |
selectedItems.setSelection(ind + 1); |
326 | 350 |
} |
327 | 351 |
} |
328 | 352 |
}); |
329 |
|
|
353 |
|
|
330 | 354 |
return mainArea; |
331 | 355 |
} |
332 | 356 |
} |
333 |
} |
|
357 |
} |
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/actions/DefineViewReferencePattern.java (revision 2947) | ||
---|---|---|
52 | 52 |
import org.txm.searchengine.cqp.corpus.Property; |
53 | 53 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
54 | 54 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
55 |
import org.txm.searchengine.cqp.corpus.VirtualProperty; |
|
56 |
|
|
55 | 57 |
/** |
56 | 58 |
* Action to build the reference pattern. |
57 | 59 |
* |
58 | 60 |
* @author mdecorde |
59 | 61 |
*/ |
60 | 62 |
public class DefineViewReferencePattern extends Action implements IWorkbenchAction { |
61 |
|
|
63 |
|
|
62 | 64 |
/** The Constant ID. */ |
63 | 65 |
private static final String ID = "org.txm.rcp.editors.concordances.definereferencepattern"; //$NON-NLS-1$ |
64 |
|
|
66 |
|
|
65 | 67 |
/** The window. */ |
66 | 68 |
private IWorkbenchWindow window; |
67 |
|
|
69 |
|
|
68 | 70 |
/** The concordance editor. */ |
69 | 71 |
private ConcordanceEditor concordanceEditor; |
70 |
|
|
72 |
|
|
71 | 73 |
/** |
72 | 74 |
* Instantiates a new define reference pattern. |
73 | 75 |
* |
... | ... | |
82 | 84 |
setText(TXMUIMessages.referencesAmpdisplayOptions); |
83 | 85 |
setToolTipText(TXMUIMessages.referencesDisplayOptions); |
84 | 86 |
} |
85 |
|
|
86 |
/* (non-Javadoc) |
|
87 |
|
|
88 |
/* |
|
89 |
* (non-Javadoc) |
|
87 | 90 |
* @see org.eclipse.ui.actions.ActionFactory.IWorkbenchAction#dispose() |
88 | 91 |
*/ |
89 | 92 |
@Override |
90 |
public void dispose() { } |
|
91 |
|
|
92 |
/* (non-Javadoc) |
|
93 |
public void dispose() {} |
|
94 |
|
|
95 |
/* |
|
96 |
* (non-Javadoc) |
|
93 | 97 |
* @see org.eclipse.jface.action.Action#run() |
94 | 98 |
*/ |
95 | 99 |
@Override |
96 | 100 |
public void run() { |
97 | 101 |
List<StructuralUnit> structuralUnits = null; |
98 |
List<Property> availableReferenceItems = new ArrayList<Property>();
|
|
102 |
List<Property> availableReferenceItems = new ArrayList<>(); |
|
99 | 103 |
try { |
100 | 104 |
structuralUnits = concordanceEditor.getCorpus().getOrderedStructuralUnits(); |
101 | 105 |
availableReferenceItems.addAll(concordanceEditor.getCorpus().getOrderedProperties()); |
102 |
} catch (Exception e) { |
|
106 |
} |
|
107 |
catch (Exception e) { |
|
103 | 108 |
org.txm.utils.logger.Log.printStackTrace(e); |
104 | 109 |
} |
105 |
|
|
110 |
|
|
106 | 111 |
for (StructuralUnit unit : structuralUnits) { |
107 | 112 |
availableReferenceItems.addAll(unit.getOrderedProperties()); |
108 | 113 |
} |
109 |
|
|
114 |
|
|
115 |
availableReferenceItems.addAll(concordanceEditor.getCorpus().getVirtualProperties()); |
|
116 |
|
|
110 | 117 |
// System.out.println("selected "+concordanceEditor.getSelectedReferences()); |
111 | 118 |
// System.out.println("before avail"+availableReferenceItems); |
112 | 119 |
availableReferenceItems.removeAll(concordanceEditor.getSelectedViewReferences()); |
113 |
|
|
120 |
|
|
114 | 121 |
// System.out.println("after avail"+availableReferenceItems); |
115 | 122 |
DefineReferencePatternDialog d = null; |
116 | 123 |
d = new DefineReferencePatternDialog(window.getShell(), |
117 | 124 |
availableReferenceItems, concordanceEditor |
118 |
.getSelectedViewReferences()); |
|
119 |
|
|
125 |
.getSelectedViewReferences());
|
|
126 |
|
|
120 | 127 |
if (d.open() == Window.OK) { |
121 | 128 |
concordanceEditor.setRefViewPattern(new ReferencePattern(d |
122 | 129 |
.getSelectesdReferenceItems())); |
123 |
//System.out.println(concordanceEditor.getViewReferencePattern()); |
|
124 |
|
|
130 |
// System.out.println(concordanceEditor.getViewReferencePattern());
|
|
131 |
|
|
125 | 132 |
} |
126 | 133 |
} |
127 |
|
|
134 |
|
|
128 | 135 |
/** |
129 | 136 |
* The Class DefineReferencePatternDialog. |
130 | 137 |
*/ |
131 | 138 |
private class DefineReferencePatternDialog extends Dialog { |
132 |
|
|
139 |
|
|
133 | 140 |
/** The available reference items. */ |
134 | 141 |
private List<Property> availableReferenceItems; |
135 |
|
|
142 |
|
|
136 | 143 |
/** The selected reference items. */ |
137 | 144 |
private List<Property> selectedReferenceItems; |
138 |
|
|
145 |
|
|
139 | 146 |
/** |
140 | 147 |
* Instantiates a new define reference pattern dialog. |
141 | 148 |
* |
... | ... | |
147 | 154 |
List<Property> availableReferenceItems, |
148 | 155 |
List<Property> selectedReferences) { |
149 | 156 |
super(parentShell); |
150 |
|
|
157 |
|
|
151 | 158 |
this.availableReferenceItems = availableReferenceItems; |
152 | 159 |
this.selectedReferenceItems = selectedReferences; |
153 | 160 |
this.availableReferenceItems.removeAll(selectedReferences); |
154 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE);
|
|
161 |
this.setShellStyle(this.getShellStyle() | SWT.RESIZE); |
|
155 | 162 |
} |
156 |
|
|
163 |
|
|
157 | 164 |
/** |
158 | 165 |
* Gets the selectesd reference items. |
159 | 166 |
* |
... | ... | |
162 | 169 |
public List<Property> getSelectesdReferenceItems() { |
163 | 170 |
return selectedReferenceItems; |
164 | 171 |
} |
165 |
|
|
166 |
/* (non-Javadoc) |
|
172 |
|
|
173 |
/* |
|
174 |
* (non-Javadoc) |
|
167 | 175 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell) |
168 | 176 |
*/ |
169 | 177 |
@Override |
170 | 178 |
protected void configureShell(Shell shell) { |
171 | 179 |
super.configureShell(shell); |
172 | 180 |
shell.setText(TXMUIMessages.referencesDisplayOptions); |
173 |
|
|
181 |
|
|
174 | 182 |
shell.setSize(400, 500); |
175 | 183 |
shell.setLocation(shell.getParent().getLocation()); |
176 | 184 |
} |
177 |
|
|
178 |
/* (non-Javadoc) |
|
185 |
|
|
186 |
/* |
|
187 |
* (non-Javadoc) |
|
179 | 188 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite) |
180 | 189 |
*/ |
181 | 190 |
@Override |
182 | 191 |
protected Control createDialogArea(Composite parent) { |
183 |
|
|
192 |
|
|
184 | 193 |
Composite mainArea = new Composite(parent, SWT.NONE); |
185 | 194 |
mainArea.setLayoutData(new GridData(GridData.FILL, GridData.FILL, |
186 | 195 |
true, true)); |
187 | 196 |
mainArea.setLayout(new GridLayout(4, false)); |
188 |
|
|
197 |
|
|
189 | 198 |
final org.eclipse.swt.widgets.List availbleItems = new org.eclipse.swt.widgets.List( |
190 | 199 |
mainArea, SWT.BORDER | SWT.V_SCROLL); |
191 | 200 |
for (Property property : availableReferenceItems) { |
192 |
if (property instanceof StructuralUnitProperty) { |
|
201 |
if (property instanceof VirtualProperty) { |
|
202 |
VirtualProperty sProperty = (VirtualProperty) property; |
|
203 |
availbleItems.add(sProperty.getFullName()); |
|
204 |
} |
|
205 |
else if (property instanceof StructuralUnitProperty) { |
|
193 | 206 |
StructuralUnitProperty sProperty = (StructuralUnitProperty) property; |
194 | 207 |
availbleItems.add(sProperty.getStructuralUnit().getName() |
195 | 208 |
+ ": " + property.getName()); //$NON-NLS-1$ |
196 |
} else { |
|
209 |
} |
|
210 |
else { |
|
197 | 211 |
availbleItems.add(property.getName()); |
198 | 212 |
} |
199 | 213 |
} |
200 |
|
|
214 |
|
|
201 | 215 |
GridData gridData = new GridData(GridData.FILL, GridData.FILL, |
202 | 216 |
true, true); |
203 |
//Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT); |
|
204 |
//gridData.widthHint = size.x; |
|
217 |
// Point size = availbleItems.computeSize(SWT.DEFAULT, SWT.DEFAULT);
|
|
218 |
// gridData.widthHint = size.x;
|
|
205 | 219 |
availbleItems.setLayoutData(gridData); |
206 |
|
|
220 |
|
|
207 | 221 |
Composite selectionButtons = new Composite(mainArea, SWT.NONE); |
208 | 222 |
selectionButtons.setLayout(new GridLayout(1, false)); |
209 | 223 |
Button select = new Button(selectionButtons, SWT.ARROW | SWT.RIGHT); |
210 | 224 |
Button unselect = new Button(selectionButtons, SWT.ARROW | SWT.LEFT); |
211 |
|
|
225 |
|
|
212 | 226 |
final org.eclipse.swt.widgets.List selectedItems = new org.eclipse.swt.widgets.List( |
213 | 227 |
mainArea, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL); |
214 | 228 |
selectedItems.setLayoutData(gridData); |
215 | 229 |
for (Property property : selectedReferenceItems) { |
216 |
if (property instanceof StructuralUnitProperty) { |
|
230 |
if (property instanceof VirtualProperty) { |
|
231 |
VirtualProperty sProperty = (VirtualProperty) property; |
|
232 |
selectedItems.add(sProperty.getFullName()); |
|
233 |
} |
|
234 |
else if (property instanceof StructuralUnitProperty) { |
|
217 | 235 |
StructuralUnitProperty sProperty = (StructuralUnitProperty) property; |
218 | 236 |
selectedItems.add(sProperty.getStructuralUnit().getName() |
219 | 237 |
+ ": " + property.getName()); //$NON-NLS-1$ |
220 |
} else { |
|
238 |
} |
|
239 |
else { |
|
221 | 240 |
selectedItems.add(property.getName()); |
222 | 241 |
} |
223 | 242 |
} |
224 |
|
|
225 |
//DBL CLICK Listeners |
|
243 |
|
|
244 |
// DBL CLICK Listeners
|
|
226 | 245 |
selectedItems.addMouseListener(new MouseListener() { |
246 |
|
|
227 | 247 |
@Override |
228 |
public void mouseUp(MouseEvent e) { }
|
|
229 |
|
|
248 |
public void mouseUp(MouseEvent e) {} |
|
249 |
|
|
230 | 250 |
@Override |
231 |
public void mouseDown(MouseEvent e) { }
|
|
232 |
|
|
251 |
public void mouseDown(MouseEvent e) {} |
|
252 |
|
|
233 | 253 |
@Override |
234 | 254 |
public void mouseDoubleClick(MouseEvent e) { |
235 | 255 |
int ind = selectedItems.getSelectionIndex(); |
236 | 256 |
availbleItems.add(selectedItems.getItem(ind)); |
237 | 257 |
selectedItems.remove(ind); |
238 | 258 |
availableReferenceItems |
239 |
.add(selectedReferenceItems.get(ind)); |
|
259 |
.add(selectedReferenceItems.get(ind));
|
|
240 | 260 |
selectedReferenceItems.remove(ind); |
241 |
selectedItems.setSelection(ind);
|
|
261 |
selectedItems.setSelection(ind); |
|
242 | 262 |
} |
243 | 263 |
}); |
244 | 264 |
availbleItems.addMouseListener(new MouseListener() { |
265 |
|
|
245 | 266 |
@Override |
246 |
public void mouseUp(MouseEvent e) { }
|
|
247 |
|
|
267 |
public void mouseUp(MouseEvent e) {} |
|
268 |
|
|
248 | 269 |
@Override |
249 |
public void mouseDown(MouseEvent e) { }
|
|
250 |
|
|
270 |
public void mouseDown(MouseEvent e) {} |
|
271 |
|
|
251 | 272 |
@Override |
252 | 273 |
public void mouseDoubleClick(MouseEvent e) { |
253 | 274 |
int ind = availbleItems.getSelectionIndex(); |
254 | 275 |
selectedItems.add(availbleItems.getItem(ind)); |
255 | 276 |
availbleItems.remove(ind); |
256 | 277 |
selectedReferenceItems |
257 |
.add(availableReferenceItems.get(ind)); |
|
278 |
.add(availableReferenceItems.get(ind));
|
|
258 | 279 |
availableReferenceItems.remove(ind); |
259 | 280 |
availbleItems.setSelection(ind); |
260 | 281 |
} |
261 | 282 |
}); |
262 |
|
|
283 |
|
|
263 | 284 |
Composite orderButtons = new Composite(mainArea, SWT.NONE); |
264 | 285 |
orderButtons.setLayout(new GridLayout(1, false)); |
265 | 286 |
Button up = new Button(orderButtons, SWT.ARROW | SWT.UP); |
266 | 287 |
Button down = new Button(orderButtons, SWT.ARROW | SWT.DOWN); |
267 |
|
|
288 |
|
|
268 | 289 |
select.addSelectionListener(new SelectionAdapter() { |
290 |
|
|
269 | 291 |
@Override |
270 | 292 |
public void widgetSelected(SelectionEvent e) { |
271 | 293 |
int ind = availbleItems.getSelectionIndex(); |
272 | 294 |
selectedItems.add(availbleItems.getItem(ind)); |
273 | 295 |
availbleItems.remove(ind); |
274 | 296 |
selectedReferenceItems |
275 |
.add(availableReferenceItems.get(ind)); |
|
297 |
.add(availableReferenceItems.get(ind));
|
|
276 | 298 |
availableReferenceItems.remove(ind); |
277 | 299 |
availbleItems.setSelection(ind); |
278 | 300 |
} |
279 | 301 |
}); |
280 |
|
|
302 |
|
|
281 | 303 |
unselect.addSelectionListener(new SelectionAdapter() { |
304 |
|
|
282 | 305 |
@Override |
283 | 306 |
public void widgetSelected(SelectionEvent e) { |
284 | 307 |
int ind = selectedItems.getSelectionIndex(); |
285 | 308 |
availbleItems.add(selectedItems.getItem(ind)); |
286 | 309 |
selectedItems.remove(ind); |
287 | 310 |
availableReferenceItems |
288 |
.add(selectedReferenceItems.get(ind)); |
|
311 |
.add(selectedReferenceItems.get(ind));
|
|
289 | 312 |
selectedReferenceItems.remove(ind); |
290 |
selectedItems.setSelection(ind);
|
|
313 |
selectedItems.setSelection(ind); |
|
291 | 314 |
} |
292 | 315 |
}); |
293 |
|
|
316 |
|
|
294 | 317 |
up.addSelectionListener(new SelectionAdapter() { |
318 |
|
|
295 | 319 |
@Override |
296 | 320 |
public void widgetSelected(SelectionEvent e) { |
297 | 321 |
int ind = selectedItems.getSelectionIndex(); |
298 | 322 |
if (ind > 0) { |
299 | 323 |
String value = selectedItems.getItem(ind); |
300 | 324 |
selectedItems.remove(ind); |
301 |
selectedItems.add(value, ind -1); |
|
302 |
|
|
325 |
selectedItems.add(value, ind - 1);
|
|
326 |
|
|
303 | 327 |
Property prop = selectedReferenceItems.get(ind); |
304 | 328 |
selectedReferenceItems.remove(ind); |
305 |
selectedReferenceItems.add(ind-1,prop);
|
|
306 |
|
|
307 |
selectedItems.setSelection(ind -1); |
|
329 |
selectedReferenceItems.add(ind - 1, prop);
|
|
330 |
|
|
331 |
selectedItems.setSelection(ind - 1);
|
|
308 | 332 |
} |
309 | 333 |
} |
310 | 334 |
}); |
311 |
|
|
335 |
|
|
312 | 336 |
down.addSelectionListener(new SelectionAdapter() { |
337 |
|
|
313 | 338 |
@Override |
314 | 339 |
public void widgetSelected(SelectionEvent e) { |
315 | 340 |
int ind = selectedItems.getSelectionIndex(); |
... | ... | |
317 | 342 |
String value = selectedItems.getItem(ind); |
318 | 343 |
selectedItems.remove(ind); |
319 | 344 |
selectedItems.add(value, ind + 1); |
320 |
|
|
345 |
|
|
321 | 346 |
Property prop = selectedReferenceItems.get(ind); |
322 | 347 |
selectedReferenceItems.remove(ind); |
323 |
selectedReferenceItems.add(ind+1, prop);
|
|
324 |
|
|
348 |
selectedReferenceItems.add(ind + 1, prop);
|
|
349 |
|
|
325 | 350 |
selectedItems.setSelection(ind + 1); |
326 | 351 |
} |
327 | 352 |
} |
328 | 353 |
}); |
329 |
|
|
354 |
|
|
330 | 355 |
return mainArea; |
331 | 356 |
} |
332 | 357 |
} |
333 |
} |
|
358 |
} |
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/handlers/___ReferencerToConc.java (revision 2947) | ||
---|---|---|
54 | 54 |
*/ |
55 | 55 |
@Deprecated |
56 | 56 |
public class ___ReferencerToConc extends AbstractHandler { |
57 |
|
|
58 |
/* (non-Javadoc) |
|
57 |
|
|
58 |
/* |
|
59 |
* (non-Javadoc) |
|
59 | 60 |
* @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent) |
60 | 61 |
*/ |
61 | 62 |
@Override |
62 | 63 |
public Object execute(ExecutionEvent event) throws ExecutionException { |
63 | 64 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil |
64 |
.getActiveWorkbenchWindow(event).getActivePage().getSelection(); |
|
65 |
|
|
65 |
.getActiveWorkbenchWindow(event).getActivePage().getSelection();
|
|
66 |
|
|
66 | 67 |
ReferencerEditor refeditor = (ReferencerEditor) HandlerUtil |
67 |
.getActiveWorkbenchWindow(event).getActivePage() |
|
68 |
.getActivePart(); |
|
69 |
|
|
68 |
.getActiveWorkbenchWindow(event).getActivePage()
|
|
69 |
.getActivePart();
|
|
70 |
|
|
70 | 71 |
return link(refeditor, selection); |
71 | 72 |
} |
72 |
|
|
73 |
|
|
73 | 74 |
/** |
74 | 75 |
* Link. |
75 | 76 |
* |
... | ... | |
77 | 78 |
* @param iSelection the selection |
78 | 79 |
* @return the object |
79 | 80 |
*/ |
80 |
public static Object link(ReferencerEditor refeditor, ISelection iSelection) |
|
81 |
{ |
|
81 |
public static Object link(ReferencerEditor refeditor, ISelection iSelection) { |
|
82 | 82 |
IStructuredSelection selection = (IStructuredSelection) iSelection; |
83 | 83 |
String query = getQuery(refeditor.getReferencer(), selection); |
84 |
if (query.length() == 0) |
|
84 |
if (query.length() == 0) {
|
|
85 | 85 |
return null; |
86 |
} |
|
86 | 87 |
CQPCorpus corpus = refeditor.getCorpus(); |
87 | 88 |
Concordance concordance = new Concordance(corpus); |
88 | 89 |
|
89 | 90 |
ReferencePattern rp = new ReferencePattern(); |
90 |
for (Property p : refeditor.getReferencer().getPattern()) |
|
91 |
for (Property p : refeditor.getReferencer().getPattern()) {
|
|
91 | 92 |
rp.addProperty(p); |
93 |
} |
|
92 | 94 |
|
93 | 95 |
concordance.setParameters(new CQLQuery(query), null, null, null, null, null, null, rp, rp, null, null); |
94 | 96 |
TXMResultEditorInput editorInput = new TXMResultEditorInput(concordance); |
95 |
|
|
97 |
|
|
96 | 98 |
IWorkbenchPage page = refeditor.getEditorSite().getWorkbenchWindow().getActivePage(); |
97 | 99 |
try { |
98 | 100 |
ConcordanceEditor conceditor = (ConcordanceEditor) page.openEditor(editorInput, |
99 |
ConcordanceEditor.class.getName()); //$NON-NLS-1$ |
|
100 |
} catch (PartInitException e) { |
|
101 |
System.err.println("Error: "+e.getLocalizedMessage()); |
|
101 |
ConcordanceEditor.class.getName()); |
|
102 | 102 |
} |
103 |
|
|
103 |
catch (PartInitException e) { |
|
104 |
System.err.println("Error: " + e.getLocalizedMessage()); |
|
105 |
} |
|
106 |
|
|
104 | 107 |
return null; |
105 | 108 |
} |
106 |
|
|
109 |
|
|
107 | 110 |
/** |
108 | 111 |
* Gets the query. |
109 | 112 |
* |
... | ... | |
112 | 115 |
*/ |
113 | 116 |
private static String getQuery(Referencer referencer, IStructuredSelection selection) { |
114 | 117 |
String query = ""; //$NON-NLS-1$ |
115 |
|
|
118 |
|
|
116 | 119 |
Line fline = (Line) selection.getFirstElement(); |
117 | 120 |
int nbToken = 1; |
118 |
|
|
121 |
|
|
119 | 122 |
List<Line> lines = selection.toList(); |
120 |
|
|
123 |
|
|
121 | 124 |
Property prop = referencer.getProperty(); |
122 |
for (int t = 0; t < nbToken; t++) |
|
123 |
{ |
|
124 |
query += "["+prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
125 |
|
|
125 |
for (int t = 0; t < nbToken; t++) { |
|
126 |
query += "[" + prop + "=\""; //$NON-NLS-1$ //$NON-NLS-2$ |
|
127 |
|
|
126 | 128 |
for (Line line : lines) { |
127 | 129 |
String s = line.getPropValue(); |
128 | 130 |
s = CQLQuery.addBackSlash(s); |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/VirtualProperty.java (revision 2947) | ||
---|---|---|
1 |
package org.txm.searchengine.cqp.corpus; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
import java.util.List; |
|
5 |
|
|
6 |
/** |
|
7 |
* A CQP property at token/word level |
|
8 |
* |
|
9 |
* @author mdecorde |
|
10 |
* |
|
11 |
*/ |
|
12 |
public class VirtualProperty extends Property { |
|
13 |
|
|
14 |
/** |
|
15 |
* Creates a new WordProperty. |
|
16 |
* |
|
17 |
* @param name |
|
18 |
* @param corpus |
|
19 |
*/ |
|
20 |
public VirtualProperty(String name, CQPCorpus corpus) { |
|
21 |
super(name, corpus); |
|
22 |
} |
|
23 |
|
|
24 |
@Override |
|
25 |
public String getFullName() { |
|
26 |
return "<" + getName() + ">"; |
|
27 |
} |
|
28 |
|
|
29 |
/** |
|
30 |
* Creates a readable formated string from the specified properties list. |
|
31 |
* |
|
32 |
* @param properties |
|
33 |
* @return |
|
34 |
*/ |
|
35 |
public static String asString(List<VirtualProperty> properties) { |
|
36 |
|
|
37 |
String str = ""; |
|
38 |
for (int i = 0; i < properties.size(); i++) { |
|
39 |
if (i > 0) { |
|
40 |
str += "_"; |
|
41 |
} |
|
42 |
str += properties.get(i).getFullName(); |
|
43 |
} |
|
44 |
return "@" + str; |
|
45 |
} |
|
46 |
|
|
47 |
public String getValue(int position) { |
|
48 |
return Integer.toString(position); |
|
49 |
} |
|
50 |
|
|
51 |
public List<String> getValues(int[] positions) { |
|
52 |
ArrayList<String> rez = new ArrayList<>(); |
|
53 |
for (int p : positions) { |
|
54 |
rez.add(getValue(p)); |
|
55 |
} |
|
56 |
return rez; |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
0 | 60 |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/CQPCorpus.java (revision 2947) | ||
---|---|---|
86 | 86 |
|
87 | 87 |
@Override |
88 | 88 |
public int compare(WordProperty o1, WordProperty o2) { |
89 |
if (o1.getName().equals("word")) |
|
89 |
if (o1.getName().equals("word")) {
|
|
90 | 90 |
return -1; |
91 |
if (o2.getName().equals("word")) |
|
91 |
} |
|
92 |
if (o2.getName().equals("word")) { |
|
92 | 93 |
return 1; |
94 |
} |
|
93 | 95 |
return o1.compareTo(o2); |
94 | 96 |
} |
95 | 97 |
}; |
... | ... | |
102 | 104 |
* @return |
103 | 105 |
*/ |
104 | 106 |
public static Object cache(Object toCache) { |
105 |
if (toCache == null) |
|
107 |
if (toCache == null) {
|
|
106 | 108 |
return null; |
109 |
} |
|
107 | 110 |
|
108 | 111 |
ArrayList<?> ocCache = getObjectCacheForClass(toCache.getClass()); |
109 | 112 |
if (ocCache.size() > CACHE_MAXIMUM_SIZE) { |
... | ... | |
189 | 192 |
* @return |
190 | 193 |
*/ |
191 | 194 |
public static ArrayList<?> uncache(Class classToUnCache) { |
192 |
if (classToUnCache == null) |
|
195 |
if (classToUnCache == null) {
|
|
193 | 196 |
return null; |
194 |
|
|
197 |
} |
|
195 | 198 |
return cache.remove(classToUnCache); |
196 | 199 |
} |
197 | 200 |
|
... | ... | |
203 | 206 |
* @return |
204 | 207 |
*/ |
205 | 208 |
public static boolean uncache(Object toUnCache) { |
206 |
if (toUnCache == null) |
|
209 |
if (toUnCache == null) {
|
|
207 | 210 |
return false; |
208 |
|
|
211 |
} |
|
209 | 212 |
ArrayList<?> ocCache = getObjectCacheForClass(toUnCache.getClass()); |
210 | 213 |
return ocCache.remove(toUnCache); |
211 | 214 |
} |
... | ... | |
413 | 416 |
NodeList partitionElems = preBuildElem.getElementsByTagName("partition"); //$NON-NLS-1$ |
414 | 417 |
for (int i = 0; i < partitionElems.getLength(); i++) { |
415 | 418 |
Element partitionElem = (Element) partitionElems.item(i); |
416 |
if (!partitionElem.getParentNode().equals(preBuildElem)) |
|
419 |
if (!partitionElem.getParentNode().equals(preBuildElem)) {
|
|
417 | 420 |
continue; // level 1 elements |
421 |
} |
|
418 | 422 |
String name = partitionElem.getAttribute("name"); //$NON-NLS-1$ |
419 | 423 |
List<String> names = new ArrayList<>(); |
420 | 424 |
List<String> queries = new ArrayList<>(); |
... | ... | |
482 | 486 |
if (this.pID == null) { |
483 | 487 |
return -1; |
484 | 488 |
} |
485 |
if (o.getSimpleName() == null) |
|
489 |
if (o.getSimpleName() == null) {
|
|
486 | 490 |
return 1; |
491 |
} |
|
487 | 492 |
if (output == 0) { |
488 | 493 |
output = this.getSimpleName().compareTo(o.getSimpleName()); |
489 | 494 |
} |
... | ... | |
993 | 998 |
public abstract List<WordProperty> getProperties() throws CqiClientException; |
994 | 999 |
|
995 | 1000 |
/** |
1001 |
* Gets the virtual properties of this corpus. |
|
1002 |
* |
|
1003 |
* current implementation only returns the "position" virtual property |
|
1004 |
* |
|
1005 |
* @return the properties |
|
1006 |
* |
|
1007 |
* @throws CqiClientException |
|
1008 |
* the cqi client exception |
|
1009 |
*/ |
|
1010 |
public List<VirtualProperty> getVirtualProperties() { |
|
1011 |
ArrayList<VirtualProperty> rez = new ArrayList<>(); |
|
1012 |
rez.add(new VirtualProperty("position", this)); |
|
1013 |
return rez; |
|
1014 |
} |
|
1015 |
|
|
1016 |
/** |
|
996 | 1017 |
* Gets a property from its name. |
997 | 1018 |
* |
998 | 1019 |
* @param name |
... | ... | |
1395 | 1416 |
public void setLanguage(String corpusLanguage) { |
1396 | 1417 |
this.lang = corpusLanguage; |
1397 | 1418 |
} |
1419 |
|
|
1420 |
public Property getVirtualProperty(String s) { |
|
1421 |
return new VirtualProperty(s, this); |
|
1422 |
} |
|
1398 | 1423 |
} |
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/ReferencePattern.java (revision 2947) | ||
---|---|---|
37 | 37 |
import org.txm.searchengine.cqp.corpus.Property; |
38 | 38 |
import org.txm.searchengine.cqp.corpus.StructuralUnit; |
39 | 39 |
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty; |
40 |
import org.txm.searchengine.cqp.corpus.VirtualProperty; |
|
40 | 41 |
import org.txm.utils.logger.Log; |
41 | 42 |
|
42 | 43 |
// TODO: Auto-generated Javadoc |
... | ... | |
46 | 47 |
* @author mdecorde |
47 | 48 |
*/ |
48 | 49 |
public class ReferencePattern implements Iterable<Property> { |
49 |
|
|
50 |
|
|
50 | 51 |
/** The properties. */ |
51 |
private List<Property> properties = new ArrayList<Property>();
|
|
52 |
|
|
52 |
private List<Property> properties = new ArrayList<>(); |
|
53 |
|
|
53 | 54 |
/** |
54 | 55 |
* |
55 | 56 |
* @param corpus |
... | ... | |
61 | 62 |
ReferencePattern props = new ReferencePattern(); |
62 | 63 |
if (v == null) return props; |
63 | 64 |
if (v.length() == 0) return props; |
64 |
|
|
65 |
|
|
65 | 66 |
String[] split = v.split("\t"); |
66 | 67 |
for (String s : split) { |
67 |
if (s.contains("_")) { |
|
68 |
if (s.startsWith("<") && s.endsWith(">")) { |
|
69 |
props.addProperty(corpus.getVirtualProperty(s)); |
|
70 |
} |
|
71 |
else if (s.contains("_")) { |
|
68 | 72 |
String[] split2 = s.split("_", 2); |
69 | 73 |
StructuralUnit su = corpus.getStructuralUnit(split2[0]); |
70 | 74 |
if (su != null) { |
... | ... | |
73 | 77 |
props.addProperty(prop); |
74 | 78 |
} |
75 | 79 |
} |
76 |
} else { |
|
80 |
} |
|
81 |
else { |
|
77 | 82 |
Property prop = corpus.getProperty(s); |
78 | 83 |
if (prop != null) { |
79 | 84 |
props.addProperty(prop); |
... | ... | |
81 | 86 |
} |
82 | 87 |
} |
83 | 88 |
return props; |
84 |
} catch (Exception e) { |
|
85 |
System.out.println("Error: "+v+" property not found in "+corpus); |
|
89 |
} |
|
90 |
catch (Exception e) { |
|
91 |
System.out.println("Error: " + v + " property not found in " + corpus); |
|
86 | 92 |
return null; |
87 | 93 |
} |
88 | 94 |
} |
89 |
|
|
95 |
|
|
90 | 96 |
/** |
91 | 97 |
* Instantiates a new reference pattern. |
92 | 98 |
*/ |
93 | 99 |
public ReferencePattern() { |
94 |
properties = new ArrayList<Property>();
|
|
100 |
properties = new ArrayList<>(); |
|
95 | 101 |
} |
96 |
|
|
102 |
|
|
97 | 103 |
/** |
98 | 104 |
* Instantiates a new reference pattern. |
99 | 105 |
* |
100 | 106 |
* @param parameters the properties |
101 | 107 |
*/ |
102 | 108 |
public ReferencePattern(Property prop) { |
103 |
List<Property> properties = new ArrayList<Property>();
|
|
109 |
List<Property> properties = new ArrayList<>(); |
|
104 | 110 |
properties.add(prop); |
105 | 111 |
this.properties = properties; |
106 | 112 |
} |
107 |
|
|
113 |
|
|
108 | 114 |
/** |
109 | 115 |
* Instantiates a new reference pattern. |
110 | 116 |
* |
111 | 117 |
* @param parameters the properties |
112 | 118 |
*/ |
113 | 119 |
public ReferencePattern(StructuralUnitProperty prop) { |
114 |
List<Property> properties = new ArrayList<Property>();
|
|
120 |
List<Property> properties = new ArrayList<>(); |
|
115 | 121 |
properties.add(prop); |
116 | 122 |
this.properties = properties; |
117 | 123 |
} |
118 |
|
|
124 |
|
|
119 | 125 |
/** |
120 | 126 |
* Instantiates a new reference pattern. |
121 | 127 |
* |
... | ... | |
124 | 130 |
public ReferencePattern(List<Property> properties) { |
125 | 131 |
this.properties = properties; |
126 | 132 |
} |
127 |
|
|
133 |
|
Formats disponibles : Unified diff