|
Lines 1-7
Link Here
|
| 1 |
/** |
1 |
/** |
| 2 |
* <copyright> |
2 |
* <copyright> |
| 3 |
* |
3 |
* |
| 4 |
* Copyright (c) 2005, 2007 IBM Corporation and others. |
4 |
* Copyright (c) 2005, 2008 IBM Corporation, Zeligsoft Inc., and others. |
| 5 |
* All rights reserved. This program and the accompanying materials |
5 |
* All rights reserved. This program and the accompanying materials |
| 6 |
* are made available under the terms of the Eclipse Public License v1.0 |
6 |
* are made available under the terms of the Eclipse Public License v1.0 |
| 7 |
* which accompanies this distribution, and is available at |
7 |
* which accompanies this distribution, and is available at |
|
Lines 9-14
Link Here
|
| 9 |
* |
9 |
* |
| 10 |
* Contributors: |
10 |
* Contributors: |
| 11 |
* IBM - Initial API and implementation |
11 |
* IBM - Initial API and implementation |
|
|
12 |
* Zeligsoft - Bug 245446 |
| 12 |
* |
13 |
* |
| 13 |
* </copyright> |
14 |
* </copyright> |
| 14 |
* |
15 |
* |
|
Lines 19-24
Link Here
|
| 19 |
import java.util.Map; |
20 |
import java.util.Map; |
| 20 |
|
21 |
|
| 21 |
import org.eclipse.core.runtime.IStatus; |
22 |
import org.eclipse.core.runtime.IStatus; |
|
|
23 |
import org.eclipse.emf.transaction.impl.TransactionImpl; |
| 24 |
import org.eclipse.emf.transaction.internal.AllowChangePropagationBlockingOption; |
| 25 |
import org.eclipse.emf.transaction.internal.BlockChangePropagationOption; |
| 26 |
import org.eclipse.emf.transaction.internal.ValidateEditOption; |
| 27 |
import org.eclipse.emf.transaction.util.BasicTransactionOptionMetadata; |
| 28 |
import org.eclipse.emf.transaction.util.BasicTransactionOptionMetadataRegistry; |
| 22 |
import org.eclipse.emf.transaction.util.ValidateEditSupport; |
29 |
import org.eclipse.emf.transaction.util.ValidateEditSupport; |
| 23 |
|
30 |
|
| 24 |
|
31 |
|
|
Lines 187-193
Link Here
|
| 187 |
|
194 |
|
| 188 |
/** |
195 |
/** |
| 189 |
* Obtains the special options with which I was created. The options |
196 |
* Obtains the special options with which I was created. The options |
| 190 |
* (map keys) are defined by the {@link TransactionalEditingDomain} interface. |
197 |
* (map keys) are defined by the {@link #OPTION_NO_NOTIFICATIONS Transaction} |
|
|
198 |
* interface. |
| 191 |
* |
199 |
* |
| 192 |
* @return an unmodifiable view of my options |
200 |
* @return an unmodifiable view of my options |
| 193 |
*/ |
201 |
*/ |
|
Lines 310-313
Link Here
|
| 310 |
* @return my status, most interesting after I have closed |
318 |
* @return my status, most interesting after I have closed |
| 311 |
*/ |
319 |
*/ |
| 312 |
public IStatus getStatus(); |
320 |
public IStatus getStatus(); |
|
|
321 |
|
| 322 |
// |
| 323 |
// Nested types |
| 324 |
// |
| 325 |
|
| 326 |
/** |
| 327 |
* <p> |
| 328 |
* An optional interface that allows clients to query certain meta-data |
| 329 |
* about transaction options. |
| 330 |
* </p> |
| 331 |
* <p> |
| 332 |
* This interface is not intended to be implemented by clients. Extend the |
| 333 |
* {@link BasicTransactionOptionMetadata} class, instead. |
| 334 |
* </p> |
| 335 |
* |
| 336 |
* @noimplement This interface is not intended to be implemented by clients. |
| 337 |
* |
| 338 |
* @author Christian W. Damus (cdamus) |
| 339 |
* |
| 340 |
* @since 1.3 |
| 341 |
* |
| 342 |
* @see BasicTransactionOptionMetadata |
| 343 |
*/ |
| 344 |
interface OptionMetadata { |
| 345 |
|
| 346 |
/** |
| 347 |
* Obtains the key of the option that I describe. This is the key that |
| 348 |
* would be used in the options map of a transaction. |
| 349 |
* |
| 350 |
* @return my option |
| 351 |
*/ |
| 352 |
Object getOption(); |
| 353 |
|
| 354 |
/** |
| 355 |
* <p> |
| 356 |
* Queries whether the specified option is a tag, meaning that it adorns |
| 357 |
* a transaction with client-specific information but that it does not |
| 358 |
* otherwise affect the semantics (or behaviour) of the transaction. |
| 359 |
* </p> |
| 360 |
* <p> |
| 361 |
* Unrecognized options are assumed to be tags, because a transaction |
| 362 |
* would not be able to interpret their meaning. |
| 363 |
* </p> |
| 364 |
* |
| 365 |
* @return <code>true</code> if the option key is a tag option or if it |
| 366 |
* is not recognized by this meta-data instance; |
| 367 |
* <code>false</code> if it is recognized and is known not to be |
| 368 |
* a tag |
| 369 |
*/ |
| 370 |
boolean isTag(); |
| 371 |
|
| 372 |
/** |
| 373 |
* <p> |
| 374 |
* Queries whether the specified option is inherited by nested |
| 375 |
* transactions. |
| 376 |
* </p> |
| 377 |
* <p> |
| 378 |
* Unrecognized options are assumed to be inherited. |
| 379 |
* </p> |
| 380 |
* |
| 381 |
* @return <code>true</code> if the option is inherited or if it is not |
| 382 |
* recognized; <code>false</code> if it is not inherited |
| 383 |
*/ |
| 384 |
boolean isHereditary(); |
| 385 |
|
| 386 |
/** |
| 387 |
* <p> |
| 388 |
* Obtains the type value of an option. |
| 389 |
* </p> |
| 390 |
* <p> |
| 391 |
* The type of an unrecognized option is assumed to be {@link Object}. |
| 392 |
* </p> |
| 393 |
* |
| 394 |
* @return the default value of the option, or <code>Object</code> if it |
| 395 |
* is not known |
| 396 |
*/ |
| 397 |
Class<?> getType(); |
| 398 |
|
| 399 |
/** |
| 400 |
* <p> |
| 401 |
* Obtains the default value of an option. |
| 402 |
* </p> |
| 403 |
* <p> |
| 404 |
* The default value of an unrecognized option is assumed to be |
| 405 |
* <code>null</code>. |
| 406 |
* </p> |
| 407 |
* |
| 408 |
* @return the default value of the option, or <code>null</code> if it |
| 409 |
* is not known |
| 410 |
*/ |
| 411 |
Object getDefaultValue(); |
| 412 |
|
| 413 |
/** |
| 414 |
* Gets the value (implicit/default or explicit) of my option in the |
| 415 |
* specified map. |
| 416 |
* |
| 417 |
* @param options |
| 418 |
* an options map |
| 419 |
* |
| 420 |
* @return my value in the map |
| 421 |
*/ |
| 422 |
Object getValue(Map<?, ?> options); |
| 423 |
|
| 424 |
/** |
| 425 |
* Queries whether the specified map has a setting for my option. |
| 426 |
* |
| 427 |
* @param options |
| 428 |
* an options map |
| 429 |
* @return whether it has a setting for my option |
| 430 |
*/ |
| 431 |
boolean isSet(Map<?, ?> options); |
| 432 |
|
| 433 |
/** |
| 434 |
* Queries whether the specified options maps have the same value of my |
| 435 |
* option, whether that be implicit or explicit. That is, this method |
| 436 |
* accounts for default values and such complex cases as the |
| 437 |
* {@link Transaction#OPTION_VALIDATE_EDIT} in which values of two |
| 438 |
* different types may mean the same thing. |
| 439 |
* |
| 440 |
* @param options1 |
| 441 |
* an options map |
| 442 |
* @param options2 |
| 443 |
* another options map |
| 444 |
* |
| 445 |
* @return whether the two maps have the same setting of my option |
| 446 |
*/ |
| 447 |
boolean sameSetting(Map<?, ?> options1, Map<?, ?> options2); |
| 448 |
|
| 449 |
/** |
| 450 |
* Updates the options map of a child transaction to inherit the setting |
| 451 |
* in a parent transaction, if it is a hereditary option and the child |
| 452 |
* does not already have a setting for it. |
| 453 |
* |
| 454 |
* @param parentOptions |
| 455 |
* the options map to inherit a value from. It is conceivable |
| 456 |
* that inheritance of an option may depend on more than one |
| 457 |
* option in this parent map |
| 458 |
* @param childOptions |
| 459 |
* the map that is to inherit the option setting |
| 460 |
* @param force |
| 461 |
* whether to inherit the option anyway despite that it is |
| 462 |
* not hereditary. This is used for application of default |
| 463 |
* options, and can be ignored by the implementor if |
| 464 |
* necessary. Also, clients must not use this parameter to |
| 465 |
* attempt to override an existing child setting; a |
| 466 |
* well-behaved option will not do that |
| 467 |
*/ |
| 468 |
void inherit(Map<?, ?> parentOptions, Map<Object, Object> childOptions, |
| 469 |
boolean force); |
| 470 |
|
| 471 |
/** |
| 472 |
* <p> |
| 473 |
* A registry of metadata describing transaction options. The default |
| 474 |
* implementation of the {@link TransactionalEditingDomain} interface |
| 475 |
* provides a transaction option registry as an adapter. |
| 476 |
* </p> |
| 477 |
* <p> |
| 478 |
* This interface is not intended to be implemented by clients. |
| 479 |
* </p> |
| 480 |
* |
| 481 |
* @noimplement This interface is not intended to be implemented by |
| 482 |
* clients. |
| 483 |
* @author Christian W. Damus (cdamus) |
| 484 |
* |
| 485 |
* @since 1.3 |
| 486 |
*/ |
| 487 |
interface Registry { |
| 488 |
|
| 489 |
/** |
| 490 |
* The shared transaction option metadata registry. |
| 491 |
*/ |
| 492 |
Registry INSTANCE = new BasicTransactionOptionMetadataRegistry(null) { |
| 493 |
|
| 494 |
private static final long serialVersionUID = 1L; |
| 495 |
|
| 496 |
{ |
| 497 |
// the options that we know |
| 498 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 499 |
Transaction.OPTION_NO_NOTIFICATIONS, false)); |
| 500 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 501 |
Transaction.OPTION_NO_TRIGGERS, false)); |
| 502 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 503 |
Transaction.OPTION_NO_VALIDATION, false)); |
| 504 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 505 |
Transaction.OPTION_NO_UNDO, false)); |
| 506 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 507 |
Transaction.OPTION_UNPROTECTED, false)); |
| 508 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 509 |
Transaction.OPTION_IS_UNDO_REDO_TRANSACTION, false)); |
| 510 |
|
| 511 |
register(new ValidateEditOption()); |
| 512 |
register(new BasicTransactionOptionMetadata( |
| 513 |
Transaction.OPTION_VALIDATE_EDIT_CONTEXT)); |
| 514 |
|
| 515 |
register(BasicTransactionOptionMetadata.newBoolean( |
| 516 |
TransactionImpl.OPTION_IS_TRIGGER_TRANSACTION, false)); |
| 517 |
register(new AllowChangePropagationBlockingOption()); |
| 518 |
register(new BlockChangePropagationOption()); |
| 519 |
} |
| 520 |
}; |
| 521 |
|
| 522 |
/** |
| 523 |
* Obtains a metadata object describing the specified transaction |
| 524 |
* option. For unrecognized options, a default meta-data is provided |
| 525 |
* that gives reasonable answers. |
| 526 |
* |
| 527 |
* @param option |
| 528 |
* an option key |
| 529 |
* @return the option meta-data (never <code>null</code>) |
| 530 |
*/ |
| 531 |
Transaction.OptionMetadata getOptionMetadata(Object option); |
| 532 |
} |
| 533 |
|
| 534 |
} |
| 313 |
} |
535 |
} |