See: Description
Package | Description |
---|---|
org.netbeans.api.intent |
API for working with
Intent s, abstract descriptions of intended
operations. |
org.netbeans.spi.intent |
SPI for Intent handlers.
|
Intent is an description of some intended operation. It is specified by action type (String) and a URI. When some Intent is executed, proper handler is chosen and it performs the actual operation.
Intents provide loose coupling between modules that may request an operation and modules that can perform it. They can be easily serialized, so they are suitable for distributed heterogenous systems.
IntentAPIAPI for describing and executing intended operations.
IntentHandlerSPISPI for handlers that are able to invoke proper operation for specified intents.
Future<Object> result = new Intent(Intent.ACTION_VIEW, new URI("scheme://path/")).execute(); Object value = result.get();
new Intent(Intent.ACTION_VIEW, new URI("scheme://path/")).execute(new Callback() { void success(Object result) { // use the result somehow } void failure(Exception exception) { // report the failure somehow } });
@IntentHandlerRegistration( displayName = "Show my item in MyEditor", position = 800, uriPattern = "myscheme://.*", actions = {Intent.ACTION_VIEW, Intent.ACTION_EDIT} ) public static Object handleIntent(Intent intent) { SomeType result = parseAndPerformIntentSomehow(intent); return result; }
@IntentHandlerRegistration( displayName = "Show my item in MyEditor", position = 800, uriPattern = "myscheme://.*", actions = "*" ) public static void handleIntent(final Intent intent, final Result result) { // Move the execution to another thread. Do not wait for the result // here, just pass the result object. EventQueue.invokeLater(new Runnable() { public void run() { try { Object result = doSomethingInEDT(intent); result.setResult(e); } catch (Exception e) { result.setException(e); } } }); }
|
The sources for the module are in the Apache Git repositories or in the GitHub repositories.
Standard module dependency is sufficient.
Read more about the implementation in the answers to architecture questions.