Plugin and dialog together - plugins

If I use a dialog to create an instance of an entity, will it fire the plugin registered to that message (i.e. Create on EntityA)?
If not, how can I link that plugin to that message?

Yes, the plugin will always fire regardless of the source of the message.

You're safe to use the plugin. It will catch the dispatched message as long as you've registered it correctly.
The plugin will, in fact, react to the following events.
Creation of an instance (a record) by the user from the GUI.
Creation of an instance by a workflow.
Creation of an instance by a dialog.
Creation of an instance by a code from an extern program.
Creation of an instance by... anything.

Related

Attachments are not updated asynchronously in Fiori MyInbox app?

I use SAP standard library: Inbox.
in library class S3.controller by tap on attachments icon is onTabSelect event executed, witch makes
this.fnDelegateAttachmentsCreation();
this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
break;
fnFetchDataOnTabSelect makes an asynchronous call. During this call is fnHandleAttachmentsCountText already executed, so the update of attachments count occurs before the request for attachments is ready. As far the request for attachments is ready, there is no update for title executed.
On screenshot is AttachmentCountText „Attachnents (1/1)“, that comes from previously selected item.
It should be „Attachements (2/2)".
Also if response comes too quick, then view changes to loading view after it received the answer from request.
If list of attachments was updated from request callback, then it should not be updated second time.
Here it seems, that there is something on loading, but request is already finished.
How could be Inbox extended, to update the attachment header and content after request is ready?
used SAPUI5-Version: 1.71.4
You are using the standard bsp-application ca_fiori_inbox?
You didn't create an extension project of the application ca_fiori_inbox with custom coding?
If that's the case, it's a bug in an standard application delivered by the SAP. SAP releases so called notes to fix bugs in their standard applications.
You can import notes in your system via the transaction SNOTE. May ask a SAP Basis Administrator from your company for help.
The following notes exactly describe your problem
2873960
2823664
2916255
2901520
If you already extended the SAP standard application(MyInbox) without using ExtensionPoints codechanges in the standard application will not affect your custom extension.
When overriding a controller method, any functionality that was previously provided by it is no longer available. Likewise, any future changes made to the original controller method implementation will not be reflected in the custom controller.
In this case you could still implement the note and check the changes in the standard controller vs. your custom controller on your system and change the respective lines in your custom coding.
Don't fix SAP coding. Report it and get a fix.
The Note 2873960 corrects coding in an abap class, not in the bsp-application(ca_fiori_inbox). So definitly import the note and check if it's fixing your problem.
I actually do not know, how the app works, but I want to give it a try.
Since it is an asynchronous function, you can always also wait for the function until it is done. So in your case, you could try to set an await keyword in front of the function.
await fnFetchDataOnTabSelect("Attachments");
This will now wait on this position until it has finished the function call before it will call the next functions. In addition to that you also need to set the upper function onTabSelect to async. So in the end it should look something like this.
onTabSelect: async function() {
// ...
this.fnDelegateAttachmentsCreation();
await this.fnFetchDataOnTabSelect("Attachments");
this.fnHandleAttachmentsCountText("Attachments");
this.fnHandleNoTextCreation("Attachments");
// ...
}
Although the Web IDE maybe shows you errors, it does work, since it is an official JavaScript API.

Listening to SWT.OpenDocument event from within a plugin

I have read lots of differemt documentation about the launcher.openFile feature of eclipse. They contain information about how to add a listener for the SWT.OpenDocument event to react on files that were opened from outside. This always includes adding the listener inside the Application class of the eclipse product.
What i want to do is to add such a listener from within my plugin where i don't have an Application class at all. Is this possible?

Instance lifetime management

I am using Caliburn.Micro v2 along with Autofac and I am having some issues with the WindowManager.ShowDialog function.
I have the following which successfully displays a dialog:
windowManager.ShowDialog(dialogViewModel.Show(typeToShow));
If after closing the newly shown window via the cross button I recall the above expecting to see the dialog once again, I encounter the following exception:
Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.
It is my understanding that the error is due to ShowDialog only being usable once and that if I want to call ShowDialog again, I need to provide a new instance. I have proven this to some degree by using:
windowManager.ShowDialog(new DialogViewModel().Show(typeToShow));
This successfully results in a new dialog each time, however, I do not wish to call new here each time. How do I therefore tell Autofac to give me a new instance of DialogViewModel each time, rather than reusing the same instance?
EDIT 1 - DialogViewModel registration
var buider = new ContainerBuilder();
builder.Register(e => new DialogViewModel())
.AsSelf()
.InstancePerDependency();
I have previously been using .SingleInstance() and thought using .InstancePerDependency() might be what I was looking for, it appears not though.
Autofac has built-in factory support via Func<T> class. You just need to resolve Func<DialogViewModel> instead of DialogViewModel which means a factory that returns DialogViewModel. You don't need to change your existing registration. More info on wiki page.

How do NPAPI Plug-in accept command+o event?

I got into a trouble, because my plug-in want to open file dialog when using command+o,but the safari holded on this event.Anyone has a solution?
I strongly suspect there is nothing you can do about this; as a plugin you are a second class citizen, a guest in the process.
You can accept the command event, you have to listen to set a callback for the event member of NPPluginFuncs struct in NP_GetEntryPoints method.
In that method you'll receive all mouse and keyboard events, as well as window focus events. You can cast the second argument from void* to NPCocoaEvent where you will find all necessary parameters suchs as event type, mouse state, keys and focus data.
Please check which event type you're handling before digging into the 'data' union of NPCocoaEvent, otherwise you can get an EXC_BAD_ACCESS.
I'm having trouble with sharing commands with the browser, in my case Command+O should fire the plugin's file open dialog only, but it's also firing the browser open file dialog. Supposedly, returning TRUE for event handling method should report the browser that the plugin handled the event, but I'm having no luck yet.

Intercept Build Request in Eclipse - Before Compilation

I was wondering in Eclipse if it's possible to intercept when a user hits save or 'ctrl + s' via some sort of listener. What I want to do is determine when a file in a project changes and receive this notification before the file is actually compiled, so that I can update a property in the class. Afterwards, I would like the file to be compiled as per normal. Is this at all possible? Similar to the idea of a database trigger I suppose.
I would look at org.eclipse.jdt.core.compilationParticipant. From the description:
This extension point allows clients to participate in the compilation process by receiving notifications at various stages of build and reconcile, via a org.eclipse.jdt.core.compiler.CompilationParticipant.