Révision 2269
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/cmdparameters/ParametersView.java (revision 2269) | ||
|---|---|---|
| 77 | 77 |
* @author mdecorde. |
| 78 | 78 |
*/ |
| 79 | 79 |
public class ParametersView extends ViewPart implements IPartListener, IPropertyListener {
|
| 80 |
|
|
| 80 |
|
|
| 81 | 81 |
/** The ID. */ |
| 82 |
public static String ID = ParametersView.class.getName(); //$NON-NLS-1$ |
|
| 83 |
|
|
| 82 |
public static String ID = ParametersView.class.getName(); // $NON-NLS-1$
|
|
| 83 |
|
|
| 84 | 84 |
/** |
| 85 | 85 |
* Instantiates a new queries view. |
| 86 | 86 |
*/ |
| 87 | 87 |
public ParametersView() {
|
| 88 |
|
|
| 88 | 89 |
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService(); |
| 89 | 90 |
service.addPartListener(this); |
| 90 | 91 |
} |
| 91 |
|
|
| 92 |
|
|
| 92 | 93 |
@Override |
| 93 | 94 |
public void dispose() {
|
| 95 |
|
|
| 94 | 96 |
IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService(); |
| 95 | 97 |
service.removePartListener(this); |
| 96 | 98 |
} |
| 97 |
|
|
| 99 |
|
|
| 98 | 100 |
/** |
| 99 | 101 |
* Refresh. |
| 100 | 102 |
*/ |
| 101 | 103 |
public static void refresh() {
|
| 102 |
|
|
| 104 |
|
|
| 103 | 105 |
} |
| 104 |
|
|
| 106 |
|
|
| 105 | 107 |
TXMEditor<? extends TXMResult> activated; |
| 108 |
|
|
| 106 | 109 |
private Composite panel; |
| 110 |
|
|
| 107 | 111 |
private ScrolledComposite scrollC; |
| 112 |
|
|
| 108 | 113 |
private Button recompute; |
| 109 |
|
|
| 114 |
|
|
| 110 | 115 |
public void updateEditorParameters() throws Exception {
|
| 111 |
|
|
| 116 |
|
|
| 112 | 117 |
EditorPart editor = activated; |
| 113 |
|
|
| 118 |
|
|
| 114 | 119 |
for (Control c : panel.getChildren()) {
|
| 115 | 120 |
c.dispose(); |
| 116 | 121 |
} |
| 117 |
|
|
| 122 |
|
|
| 118 | 123 |
if (editor == null) {
|
| 119 | 124 |
new Label(panel, SWT.NONE).setText("No editor selected.");
|
| 120 | 125 |
recompute.setEnabled(false); |
| 121 | 126 |
return; |
| 122 | 127 |
} |
| 123 |
|
|
| 128 |
|
|
| 124 | 129 |
if (!(editor instanceof TXMEditor)) {
|
| 125 | 130 |
new Label(panel, SWT.NONE).setText("Editor is not a TXMPartEditor: " + editor);
|
| 126 | 131 |
return; |
| ... | ... | |
| 128 | 133 |
recompute.setEnabled(true); |
| 129 | 134 |
TXMEditor reditor = (TXMEditor) editor; |
| 130 | 135 |
final TXMResult result = reditor.getResult(); |
| 131 |
|
|
| 136 |
|
|
| 132 | 137 |
List<Field> allfields = result.getAllFields(); |
| 133 | 138 |
List<Field> fields = new ArrayList<Field>(); |
| 134 | 139 |
for (Field f : allfields) {
|
| ... | ... | |
| 138 | 143 |
} |
| 139 | 144 |
fields.add(f); |
| 140 | 145 |
} |
| 141 |
|
|
| 146 |
|
|
| 142 | 147 |
Collections.sort(fields, new Comparator<Field>() {
|
| 143 |
|
|
| 148 |
|
|
| 144 | 149 |
@Override |
| 145 | 150 |
public int compare(Field o1, Field o2) {
|
| 151 |
|
|
| 146 | 152 |
Parameter parameter1 = o1.getAnnotation(Parameter.class); |
| 147 | 153 |
Parameter parameter2 = o2.getAnnotation(Parameter.class); |
| 148 |
|
|
| 154 |
|
|
| 149 | 155 |
if (parameter1.type() == parameter2.type()) {
|
| 150 | 156 |
return o1.getName().compareTo(o2.getName()); |
| 151 |
} else {
|
|
| 157 |
} |
|
| 158 |
else {
|
|
| 152 | 159 |
return parameter1.type() - parameter2.type(); |
| 153 | 160 |
} |
| 154 | 161 |
} |
| 155 | 162 |
}); |
| 156 |
|
|
| 163 |
|
|
| 157 | 164 |
for (final Field f : fields) {
|
| 158 | 165 |
Parameter parameter = f.getAnnotation(Parameter.class); |
| 159 | 166 |
if (parameter == null) {
|
| 160 | 167 |
continue; |
| 161 | 168 |
} |
| 162 |
|
|
| 169 |
|
|
| 163 | 170 |
String name; |
| 164 | 171 |
if (!parameter.key().isEmpty()) {
|
| 165 | 172 |
name = parameter.key(); |
| 166 |
} else {
|
|
| 173 |
} |
|
| 174 |
else {
|
|
| 167 | 175 |
name = f.getName(); |
| 168 | 176 |
} |
| 169 | 177 |
Class<?> clazz = f.getType(); |
| 170 | 178 |
f.setAccessible(true); |
| 171 | 179 |
final Object value = f.get(result); |
| 172 |
|
|
| 180 |
|
|
| 173 | 181 |
new Label(panel, SWT.NONE).setText(name); |
| 174 | 182 |
clazz.equals(Integer.class); |
| 175 | 183 |
Control c = null; |
| ... | ... | |
| 179 | 187 |
sp.setSelection((Integer) value); |
| 180 | 188 |
} |
| 181 | 189 |
sp.addSelectionListener(new SelectionListener() {
|
| 182 |
|
|
| 190 |
|
|
| 183 | 191 |
@Override |
| 184 | 192 |
public void widgetSelected(SelectionEvent e) {
|
| 193 |
|
|
| 185 | 194 |
try {
|
| 186 | 195 |
f.set(result, sp.getSelection()); |
| 187 | 196 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 188 | 197 |
activated.compute(false); |
| 189 | 198 |
} |
| 190 |
} catch (Exception e1) {
|
|
| 199 |
} |
|
| 200 |
catch (Exception e1) {
|
|
| 191 | 201 |
// TODO Auto-generated catch block |
| 192 | 202 |
e1.printStackTrace(); |
| 193 | 203 |
} |
| 194 | 204 |
} |
| 195 |
|
|
| 205 |
|
|
| 196 | 206 |
@Override |
| 197 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 198 |
} |
|
| 207 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 199 | 208 |
}); |
| 200 | 209 |
c = sp; |
| 201 |
} else if (clazz.equals(String.class)) {
|
|
| 210 |
} |
|
| 211 |
else if (clazz.equals(String.class)) {
|
|
| 202 | 212 |
final Text t = new Text(panel, SWT.BORDER); |
| 203 | 213 |
if (value != null) {
|
| 204 | 214 |
t.setText(value.toString()); |
| 205 | 215 |
} |
| 206 | 216 |
t.addKeyListener(new org.eclipse.swt.events.KeyListener() {
|
| 207 |
|
|
| 217 |
|
|
| 208 | 218 |
@Override |
| 209 | 219 |
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
|
| 220 |
|
|
| 210 | 221 |
try {
|
| 211 | 222 |
f.set(result, t.getText()); |
| 212 | 223 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 213 | 224 |
activated.compute(false); |
| 214 | 225 |
} |
| 215 |
} catch (Exception e1) {
|
|
| 226 |
} |
|
| 227 |
catch (Exception e1) {
|
|
| 216 | 228 |
// TODO Auto-generated catch block |
| 217 | 229 |
e1.printStackTrace(); |
| 218 | 230 |
} |
| 219 | 231 |
} |
| 220 |
|
|
| 232 |
|
|
| 221 | 233 |
@Override |
| 222 | 234 |
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
|
| 223 | 235 |
// TODO Auto-generated method stub |
| 224 |
|
|
| 236 |
|
|
| 225 | 237 |
} |
| 226 | 238 |
}); |
| 227 | 239 |
c = t; |
| 228 |
} else if (clazz.equals(Float.class)) {
|
|
| 240 |
} |
|
| 241 |
else if (clazz.equals(Float.class)) {
|
|
| 229 | 242 |
final Spinner sp = new Spinner(panel, SWT.BORDER); |
| 230 | 243 |
sp.setSelection((int) ((Float) value * 2)); |
| 231 | 244 |
sp.addSelectionListener(new SelectionListener() {
|
| 232 |
|
|
| 245 |
|
|
| 233 | 246 |
@Override |
| 234 | 247 |
public void widgetSelected(SelectionEvent e) {
|
| 248 |
|
|
| 235 | 249 |
try {
|
| 236 | 250 |
f.set(result, sp.getSelection()); |
| 237 | 251 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 238 | 252 |
activated.compute(false); |
| 239 | 253 |
} |
| 240 |
} catch (Exception e1) {
|
|
| 254 |
} |
|
| 255 |
catch (Exception e1) {
|
|
| 241 | 256 |
e1.printStackTrace(); |
| 242 | 257 |
} |
| 243 | 258 |
} |
| 244 |
|
|
| 259 |
|
|
| 245 | 260 |
@Override |
| 246 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 247 |
} |
|
| 261 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 248 | 262 |
}); |
| 249 | 263 |
c = sp; |
| 250 | 264 |
((Spinner) c).setDigits(2); |
| 251 |
} else if (clazz.equals(Boolean.class)) {
|
|
| 265 |
} |
|
| 266 |
else if (clazz.equals(Boolean.class)) {
|
|
| 252 | 267 |
final Button sp = new Button(panel, SWT.CHECK); |
| 253 | 268 |
sp.addSelectionListener(new SelectionListener() {
|
| 254 |
|
|
| 269 |
|
|
| 255 | 270 |
@Override |
| 256 | 271 |
public void widgetSelected(SelectionEvent e) {
|
| 272 |
|
|
| 257 | 273 |
try {
|
| 258 | 274 |
f.set(result, sp.getSelection()); |
| 259 | 275 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 260 | 276 |
activated.compute(false); |
| 261 | 277 |
} |
| 262 |
} catch (Exception e1) {
|
|
| 278 |
} |
|
| 279 |
catch (Exception e1) {
|
|
| 263 | 280 |
e1.printStackTrace(); |
| 264 | 281 |
} |
| 265 | 282 |
} |
| 266 |
|
|
| 283 |
|
|
| 267 | 284 |
@Override |
| 268 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 269 |
} |
|
| 285 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 270 | 286 |
}); |
| 271 | 287 |
c = sp; |
| 272 |
} else if (clazz.equals(IQuery.class)) {
|
|
| 288 |
} |
|
| 289 |
else if (clazz.equals(IQuery.class)) {
|
|
| 273 | 290 |
final QueryWidget qw = new QueryWidget(panel, SWT.NONE); |
| 274 | 291 |
if (value != null) {
|
| 275 | 292 |
qw.setText(((IQuery) value).getQueryString()); |
| 276 | 293 |
} |
| 277 | 294 |
qw.addSelectionListener(new SelectionListener() {
|
| 278 |
|
|
| 295 |
|
|
| 279 | 296 |
@Override |
| 280 | 297 |
public void widgetSelected(SelectionEvent e) {
|
| 298 |
|
|
| 281 | 299 |
try {
|
| 282 | 300 |
f.set(result, qw.getQuery()); |
| 283 | 301 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 284 | 302 |
activated.compute(false); |
| 285 | 303 |
} |
| 286 |
} catch (Exception e1) {
|
|
| 304 |
} |
|
| 305 |
catch (Exception e1) {
|
|
| 287 | 306 |
// TODO Auto-generated catch block |
| 288 | 307 |
e1.printStackTrace(); |
| 289 | 308 |
} |
| 290 | 309 |
} |
| 291 |
|
|
| 310 |
|
|
| 292 | 311 |
@Override |
| 293 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 294 |
} |
|
| 312 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 295 | 313 |
}); |
| 296 | 314 |
qw.addKeyListener(new org.eclipse.swt.events.KeyListener() {
|
| 297 |
|
|
| 315 |
|
|
| 298 | 316 |
@Override |
| 299 | 317 |
public void keyReleased(org.eclipse.swt.events.KeyEvent e) {
|
| 300 |
if (e.keyCode != SWT.KEYPAD_CR && e.keyCode != SWT.CR) {
|
|
| 301 |
return; |
|
| 302 |
} |
|
| 318 |
|
|
| 319 |
if (e.keyCode != SWT.KEYPAD_CR && e.keyCode != SWT.CR) { return; }
|
|
| 303 | 320 |
try {
|
| 304 | 321 |
f.set(result, qw.getQuery()); |
| 305 | 322 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 306 | 323 |
activated.compute(false); |
| 307 | 324 |
} |
| 308 |
} catch (Exception e1) {
|
|
| 325 |
} |
|
| 326 |
catch (Exception e1) {
|
|
| 309 | 327 |
// TODO Auto-generated catch block |
| 310 | 328 |
e1.printStackTrace(); |
| 311 | 329 |
} |
| 312 | 330 |
} |
| 313 |
|
|
| 331 |
|
|
| 314 | 332 |
@Override |
| 315 |
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {
|
|
| 316 |
} |
|
| 333 |
public void keyPressed(org.eclipse.swt.events.KeyEvent e) {}
|
|
| 317 | 334 |
}); |
| 318 | 335 |
c = qw; |
| 319 |
} else if (clazz.equals(File.class)) {
|
|
| 336 |
} |
|
| 337 |
else if (clazz.equals(File.class)) {
|
|
| 320 | 338 |
final Button b = new Button(panel, SWT.PUSH); |
| 321 | 339 |
if (value != null) {
|
| 322 | 340 |
b.setText(value.toString()); |
| 323 |
|
|
| 341 |
|
|
| 324 | 342 |
} |
| 325 |
|
|
| 343 |
|
|
| 326 | 344 |
b.addSelectionListener(new SelectionListener() {
|
| 327 |
|
|
| 345 |
|
|
| 328 | 346 |
@Override |
| 329 | 347 |
public void widgetSelected(SelectionEvent e) {
|
| 348 |
|
|
| 330 | 349 |
File file = (File) value; |
| 331 | 350 |
if (file.isDirectory()) {
|
| 332 | 351 |
DirectoryDialog dialog = new DirectoryDialog(panel.getDisplay().getActiveShell()); |
| ... | ... | |
| 340 | 359 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 341 | 360 |
activated.compute(false); |
| 342 | 361 |
} |
| 343 |
} catch (IllegalArgumentException e1) {
|
|
| 362 |
} |
|
| 363 |
catch (IllegalArgumentException e1) {
|
|
| 344 | 364 |
// TODO Auto-generated catch block |
| 345 | 365 |
e1.printStackTrace(); |
| 346 |
} catch (IllegalAccessException e1) {
|
|
| 366 |
} |
|
| 367 |
catch (IllegalAccessException e1) {
|
|
| 347 | 368 |
// TODO Auto-generated catch block |
| 348 | 369 |
e1.printStackTrace(); |
| 349 | 370 |
} |
| 350 | 371 |
} |
| 351 |
} else {
|
|
| 372 |
} |
|
| 373 |
else {
|
|
| 352 | 374 |
FileDialog dialog = new FileDialog(panel.getDisplay().getActiveShell()); |
| 353 | 375 |
dialog.setText("Choose directory");
|
| 354 | 376 |
dialog.setFilterPath(file.getAbsolutePath()); |
| ... | ... | |
| 360 | 382 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 361 | 383 |
activated.compute(false); |
| 362 | 384 |
} |
| 363 |
} catch (IllegalArgumentException e1) {
|
|
| 385 |
} |
|
| 386 |
catch (IllegalArgumentException e1) {
|
|
| 364 | 387 |
// TODO Auto-generated catch block |
| 365 | 388 |
e1.printStackTrace(); |
| 366 |
} catch (IllegalAccessException e1) {
|
|
| 389 |
} |
|
| 390 |
catch (IllegalAccessException e1) {
|
|
| 367 | 391 |
// TODO Auto-generated catch block |
| 368 | 392 |
e1.printStackTrace(); |
| 369 | 393 |
} |
| 370 | 394 |
} |
| 371 | 395 |
} |
| 372 | 396 |
} |
| 373 |
|
|
| 397 |
|
|
| 374 | 398 |
@Override |
| 375 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
| 376 |
} |
|
| 399 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 377 | 400 |
}); |
| 378 |
} else if (clazz.equals(List.class)) {
|
|
| 401 |
} |
|
| 402 |
else if (clazz.equals(List.class)) {
|
|
| 379 | 403 |
List list = (List) value; |
| 380 | 404 |
if (list.isEmpty()) {
|
| 381 | 405 |
Label l3 = new Label(panel, SWT.NONE); |
| 382 | 406 |
l3.setText("no value");
|
| 383 | 407 |
c = l3; |
| 384 |
} else {
|
|
| 408 |
} |
|
| 409 |
else {
|
|
| 385 | 410 |
Object first = list.get(0); |
| 386 | 411 |
if (first instanceof WordProperty) {
|
| 387 | 412 |
c = createWordPropertyField(f, result, list); |
| 388 |
} else if (first instanceof StructuralUnitProperty) {
|
|
| 413 |
} |
|
| 414 |
else if (first instanceof StructuralUnitProperty) {
|
|
| 389 | 415 |
c = createStructuralUnitPropertyField(f, result, list); |
| 390 | 416 |
} |
| 391 | 417 |
} |
| 392 | 418 |
// } else if (value instanceof StructuralUnit) {
|
| 393 |
} else if (clazz.equals(WordProperty.class)) {
|
|
| 419 |
} |
|
| 420 |
else if (clazz.equals(WordProperty.class)) {
|
|
| 394 | 421 |
ArrayList<WordProperty> selected = new ArrayList<WordProperty>(); |
| 395 | 422 |
selected.add((WordProperty) value); |
| 396 | 423 |
c = createWordPropertyField(f, result, selected); |
| 397 | 424 |
// } else if (value instanceof StructuralUnit) {
|
| 398 | 425 |
// Label l2 = new Label(panel, |
| 399 | 426 |
// SWT.NONE).setText("="+value.toString());
|
| 400 |
} else if (clazz.equals(StructuralUnitProperty.class)) {
|
|
| 427 |
} |
|
| 428 |
else if (clazz.equals(StructuralUnitProperty.class)) {
|
|
| 401 | 429 |
ArrayList<StructuralUnitProperty> selected = new ArrayList<StructuralUnitProperty>(); |
| 402 | 430 |
selected.add((StructuralUnitProperty) value); |
| 403 | 431 |
c = createWordPropertyField(f, result, selected); |
| 404 | 432 |
// } else if (value instanceof ReferencePattern) {
|
| 405 | 433 |
// c = new Label(panel, SWT.NONE).setText("="+value.toString());
|
| 406 |
} else if (clazz.equals(ReferencePattern.class)) {
|
|
| 407 |
c = createReferencePatternField(f, result, (ReferencePattern)value); |
|
| 434 |
} |
|
| 435 |
else if (clazz.equals(ReferencePattern.class)) {
|
|
| 436 |
c = createReferencePatternField(f, result, (ReferencePattern) value); |
|
| 408 | 437 |
// } else if (value instanceof ReferencePattern) {
|
| 409 | 438 |
// c = new Label(panel, SWT.NONE).setText("="+value.toString());
|
| 410 |
} else {
|
|
| 439 |
} |
|
| 440 |
else {
|
|
| 411 | 441 |
Label l2 = new Label(panel, SWT.NONE); |
| 412 | 442 |
if (value != null) {
|
| 413 | 443 |
TypeVariable<?>[] pp = value.getClass().getTypeParameters(); |
| 414 |
l2.setText(clazz.getSimpleName()+"=" + value); |
|
| 415 |
} else {
|
|
| 416 |
l2.setText(clazz.getSimpleName()+"=" + value); |
|
| 444 |
l2.setText(clazz.getSimpleName() + "=" + value); |
|
| 417 | 445 |
} |
| 446 |
else {
|
|
| 447 |
l2.setText(clazz.getSimpleName() + "=" + value); |
|
| 448 |
} |
|
| 418 | 449 |
c = l2; |
| 419 | 450 |
} |
| 420 |
// if (c != null) |
|
| 421 |
c.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); |
|
| 451 |
|
|
| 452 |
if (c != null) {
|
|
| 453 |
c.setLayoutData(GridDataFactory.fillDefaults().grab(true, false).create()); |
|
| 454 |
} |
|
| 422 | 455 |
} |
| 423 | 456 |
scrollC.setContent(panel); |
| 424 | 457 |
scrollC.setMinSize(panel.computeSize(SWT.DEFAULT, SWT.DEFAULT)); |
| ... | ... | |
| 426 | 459 |
scrollC.setExpandVertical(true); |
| 427 | 460 |
scrollC.layout(true); |
| 428 | 461 |
} |
| 429 |
|
|
| 462 |
|
|
| 430 | 463 |
private Control createReferencePatternField(final Field f, final TXMResult result, ReferencePattern value) throws Exception {
|
| 464 |
|
|
| 431 | 465 |
final List<Property> selected = new ArrayList<Property>(); |
| 432 | 466 |
selected.addAll(value.getProperties()); |
| 433 | 467 |
CQPCorpus corpus = value.getCorpus(); |
| ... | ... | |
| 441 | 475 |
selector.setProperties(availables, selected); |
| 442 | 476 |
} |
| 443 | 477 |
selector.addSelectionListener(new SelectionListener() {
|
| 444 |
|
|
| 478 |
|
|
| 445 | 479 |
@Override |
| 446 | 480 |
public void widgetSelected(SelectionEvent e) {
|
| 481 |
|
|
| 447 | 482 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 448 | 483 |
ReferencePattern p = new ReferencePattern(selected); |
| 449 | 484 |
try {
|
| 450 | 485 |
f.set(result, p); |
| 451 |
} catch (IllegalArgumentException e1) {
|
|
| 486 |
} |
|
| 487 |
catch (IllegalArgumentException e1) {
|
|
| 452 | 488 |
// TODO Auto-generated catch block |
| 453 | 489 |
e1.printStackTrace(); |
| 454 |
} catch (IllegalAccessException e1) {
|
|
| 490 |
} |
|
| 491 |
catch (IllegalAccessException e1) {
|
|
| 455 | 492 |
// TODO Auto-generated catch block |
| 456 | 493 |
e1.printStackTrace(); |
| 457 | 494 |
} |
| 458 | 495 |
activated.compute(false); |
| 459 | 496 |
} |
| 460 | 497 |
} |
| 461 |
|
|
| 498 |
|
|
| 462 | 499 |
@Override |
| 463 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 500 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 464 | 501 |
}); |
| 465 |
// selector.setLayoutData(layoutData);
|
|
| 502 |
// selector.setLayoutData(layoutData);
|
|
| 466 | 503 |
return selector; |
| 467 | 504 |
} |
| 468 |
|
|
| 505 |
|
|
| 469 | 506 |
protected PropertiesSelector<WordProperty> createWordPropertyField(final Field f, final TXMResult result, final List selected) throws CqiClientException {
|
| 470 |
|
|
| 507 |
|
|
| 471 | 508 |
Object value = selected.get(0); |
| 472 | 509 |
CQPCorpus corpus = ((WordProperty) value).getCorpus(); |
| 473 | 510 |
List<WordProperty> availables = corpus.getOrderedProperties(); |
| ... | ... | |
| 475 | 512 |
PropertiesSelector<WordProperty> selector = new PropertiesSelector<WordProperty>(panel, SWT.NONE); |
| 476 | 513 |
selector.setProperties(availables, selected); |
| 477 | 514 |
selector.addSelectionListener(new SelectionListener() {
|
| 478 |
|
|
| 515 |
|
|
| 479 | 516 |
@Override |
| 480 | 517 |
public void widgetSelected(SelectionEvent e) {
|
| 518 |
|
|
| 481 | 519 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 482 | 520 |
try {
|
| 483 | 521 |
f.set(result, selected); |
| 484 |
} catch (Exception e1) {
|
|
| 522 |
} |
|
| 523 |
catch (Exception e1) {
|
|
| 485 | 524 |
// TODO Auto-generated catch block |
| 486 | 525 |
e1.printStackTrace(); |
| 487 | 526 |
} |
| 488 | 527 |
activated.compute(false); |
| 489 | 528 |
} |
| 490 | 529 |
} |
| 491 |
|
|
| 530 |
|
|
| 492 | 531 |
@Override |
| 493 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 532 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 494 | 533 |
}); |
| 495 |
// selector.setLayoutData(layoutData);
|
|
| 534 |
// selector.setLayoutData(layoutData);
|
|
| 496 | 535 |
return selector; |
| 497 | 536 |
} |
| 498 |
|
|
| 537 |
|
|
| 499 | 538 |
private PropertiesSelector<StructuralUnitProperty> createStructuralUnitPropertyField(final Field f, final TXMResult result, final List selected) throws CqiClientException {
|
| 539 |
|
|
| 500 | 540 |
Object value = selected.get(0); |
| 501 | 541 |
CQPCorpus corpus = ((StructuralUnitProperty) value).getCorpus(); |
| 502 | 542 |
ArrayList<StructuralUnitProperty> availables = new ArrayList<StructuralUnitProperty>(); |
| ... | ... | |
| 505 | 545 |
PropertiesSelector<StructuralUnitProperty> selector = new PropertiesSelector<StructuralUnitProperty>(panel, SWT.NONE); |
| 506 | 546 |
selector.setProperties(availables, selected); |
| 507 | 547 |
selector.addSelectionListener(new SelectionListener() {
|
| 508 |
|
|
| 548 |
|
|
| 509 | 549 |
@Override |
| 510 | 550 |
public void widgetSelected(SelectionEvent e) {
|
| 551 |
|
|
| 511 | 552 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 512 | 553 |
try {
|
| 513 | 554 |
f.set(result, selected); |
| 514 |
} catch (Exception e1) {
|
|
| 555 |
} |
|
| 556 |
catch (Exception e1) {
|
|
| 515 | 557 |
// TODO Auto-generated catch block |
| 516 | 558 |
e1.printStackTrace(); |
| 517 | 559 |
} |
| 518 | 560 |
activated.compute(false); |
| 519 | 561 |
} |
| 520 | 562 |
} |
| 521 |
|
|
| 563 |
|
|
| 522 | 564 |
@Override |
| 523 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 565 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 524 | 566 |
}); |
| 525 | 567 |
return selector; |
| 526 | 568 |
} |
| 527 |
|
|
| 569 |
|
|
| 528 | 570 |
/* |
| 529 | 571 |
* (non-Javadoc) |
| 530 |
* |
|
| 531 | 572 |
* @see |
| 532 | 573 |
* org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets |
| 533 | 574 |
* .Composite) |
| 534 | 575 |
*/ |
| 535 | 576 |
@Override |
| 536 | 577 |
public void createPartControl(Composite parent) {
|
| 537 |
|
|
| 578 |
|
|
| 538 | 579 |
parent.setLayout(new GridLayout(1, true)); |
| 539 |
|
|
| 580 |
|
|
| 540 | 581 |
recompute = new Button(parent, SWT.PUSH); |
| 541 | 582 |
recompute.setImage(IImageKeys.getImage(IImageKeys.START)); |
| 542 | 583 |
recompute.addSelectionListener(new SelectionListener() {
|
| 543 |
|
|
| 584 |
|
|
| 544 | 585 |
@Override |
| 545 | 586 |
public void widgetSelected(SelectionEvent e) {
|
| 587 |
|
|
| 546 | 588 |
if (activated != null && !activated.getParametersGroupsComposite().isDisposed()) {
|
| 547 | 589 |
activated.compute(false); |
| 548 | 590 |
} |
| 549 | 591 |
} |
| 550 |
|
|
| 592 |
|
|
| 551 | 593 |
@Override |
| 552 |
public void widgetDefaultSelected(SelectionEvent e) { }
|
|
| 594 |
public void widgetDefaultSelected(SelectionEvent e) {}
|
|
| 553 | 595 |
}); |
| 554 | 596 |
recompute.setLayoutData(GridDataFactory.fillDefaults().align(GridData.BEGINNING, GridData.BEGINNING).grab(false, false).create()); |
| 555 | 597 |
recompute.setEnabled(false); |
| 556 |
|
|
| 598 |
|
|
| 557 | 599 |
scrollC = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL); |
| 558 | 600 |
scrollC.setLayoutData(GridDataFactory.fillDefaults().grab(true, true).create()); |
| 559 |
|
|
| 601 |
|
|
| 560 | 602 |
panel = new Composite(scrollC, SWT.NONE); |
| 561 | 603 |
panel.setLayout(new GridLayout(2, true)); |
| 562 |
|
|
| 604 |
|
|
| 563 | 605 |
try {
|
| 564 | 606 |
updateEditorParameters(); |
| 565 |
} catch (Exception e) {
|
|
| 607 |
} |
|
| 608 |
catch (Exception e) {
|
|
| 566 | 609 |
// TODO Auto-generated catch block |
| 567 | 610 |
e.printStackTrace(); |
| 568 | 611 |
} |
| 569 | 612 |
} |
| 570 |
|
|
| 613 |
|
|
| 571 | 614 |
@Override |
| 572 | 615 |
public void partActivated(IWorkbenchPart part) {
|
| 616 |
|
|
| 573 | 617 |
if (part == null) |
| 574 | 618 |
return; |
| 575 | 619 |
// System.out.println("partActivated: "+part);
|
| ... | ... | |
| 582 | 626 |
// activated.addPartPropertyListener(this); |
| 583 | 627 |
try {
|
| 584 | 628 |
updateEditorParameters(); |
| 585 |
} catch (Exception e) {
|
|
| 629 |
} |
|
| 630 |
catch (Exception e) {
|
|
| 586 | 631 |
// TODO Auto-generated catch block |
| 587 | 632 |
e.printStackTrace(); |
| 588 | 633 |
} |
| 589 | 634 |
} |
| 590 |
|
|
| 635 |
|
|
| 591 | 636 |
@Override |
| 592 | 637 |
public void partBroughtToTop(IWorkbenchPart part) {
|
| 638 |
|
|
| 593 | 639 |
if (part == null) |
| 594 | 640 |
return; |
| 595 | 641 |
} |
| 596 |
|
|
| 642 |
|
|
| 597 | 643 |
@Override |
| 598 | 644 |
public void partClosed(IWorkbenchPart part) {
|
| 645 |
|
|
| 599 | 646 |
if (part == null) |
| 600 | 647 |
return; |
| 601 | 648 |
if (part == activated) {
|
| 602 | 649 |
activated = null; |
| 603 | 650 |
try {
|
| 604 | 651 |
updateEditorParameters(); |
| 605 |
} catch (Exception e) {
|
|
| 652 |
} |
|
| 653 |
catch (Exception e) {
|
|
| 606 | 654 |
// TODO Auto-generated catch block |
| 607 | 655 |
e.printStackTrace(); |
| 608 | 656 |
} |
| 609 | 657 |
} |
| 610 | 658 |
} |
| 611 |
|
|
| 659 |
|
|
| 612 | 660 |
@Override |
| 613 | 661 |
public void partDeactivated(IWorkbenchPart part) {
|
| 662 |
|
|
| 614 | 663 |
if (part == null) |
| 615 | 664 |
return; |
| 616 | 665 |
// System.out.println("partDeactivated: "+part);
|
| 617 |
// if (part instanceof TXMEditor)
|
|
| 618 |
// activated = null;
|
|
| 619 |
// try {
|
|
| 620 |
// updateEditorParameters();
|
|
| 621 |
// } catch (Exception e) {
|
|
| 622 |
// // TODO Auto-generated catch block
|
|
| 623 |
// e.printStackTrace();
|
|
| 624 |
// }
|
|
| 666 |
// if (part instanceof TXMEditor)
|
|
| 667 |
// activated = null;
|
|
| 668 |
// try {
|
|
| 669 |
// updateEditorParameters();
|
|
| 670 |
// } catch (Exception e) {
|
|
| 671 |
// // TODO Auto-generated catch block
|
|
| 672 |
// e.printStackTrace();
|
|
| 673 |
// }
|
|
| 625 | 674 |
} |
| 626 |
|
|
| 675 |
|
|
| 627 | 676 |
@Override |
| 628 | 677 |
public void propertyChanged(Object source, int propId) {
|
| 678 |
|
|
| 629 | 679 |
// System.out.println("Editor property changed: "+propId);
|
| 630 | 680 |
if (propId == EditorPart.PROP_DIRTY) {
|
| 631 | 681 |
try {
|
| 632 | 682 |
updateEditorParameters(); |
| 633 |
} catch (Exception e) {
|
|
| 683 |
} |
|
| 684 |
catch (Exception e) {
|
|
| 634 | 685 |
// TODO Auto-generated catch block |
| 635 | 686 |
e.printStackTrace(); |
| 636 | 687 |
} |
| 637 | 688 |
} |
| 638 | 689 |
} |
| 639 |
|
|
| 690 |
|
|
| 640 | 691 |
@Override |
| 641 | 692 |
public void partOpened(IWorkbenchPart part) {
|
| 693 |
|
|
| 642 | 694 |
if (part == null) |
| 643 | 695 |
return; |
| 644 | 696 |
} |
| 645 |
|
|
| 697 |
|
|
| 646 | 698 |
@Override |
| 647 | 699 |
public void setFocus() {
|
| 648 | 700 |
// TODO Auto-generated method stub |
Formats disponibles : Unified diff