Missing link between objectContribution and command - eclipse

When using the objectContribution-element (which is part of the org.eclipse.ui.popupMenus-extension point), I often (practically always) want to delegate to some command instead of implementing some action myself (since usually, I have the command and a handler already implemented). I'm doing this by using ICommandService and IHandlerService, but it feels there should be a way to achieve this programmatically. I could use viewerContribution instead of objectContribution, but then I would lose the easy way of showing the menu entry only when certain object types are selected. Ideally, I would like to use the enablement-checks that already exist for my handlers to apply to the menu entry defined by the objectContribution.

Ok, here's what I was missing: instead of using the org.eclipse.ui.popupMenus-extension point, I had to use the org.eclipse.ui.menus-extension point with a menuContribution that has its locationURI-attribute pointing to popup:org.eclipse.ui.popup.any?after=additions. This menuContribution can include a command-element (achieving the goal of binding directly to an existing command), and this command-element´s visibleWhen-element can be bound to the activation status of the bound command's handler via the checkEnabled-attribute (achieving the goal of having the popup-menu entry visible only when the enablement for the command handler is satisfied).
What's bad is that the documentation of the org.eclipse.ui.menus-extension point states that the org.eclipse.ui.popupMenus-extension point is to be considered deprecated, but the documentation of org.eclipse.ui.popupMenus does not mention this fact.

Related

Does UI5 Remember's previous entity

I am building simple crud for an entity. Initial state is read on particular entity(key) using view>form.bindElement('/entity(key)').
when I click on new button I clear the form and when the cancel button is clicked during the new/create process(without performing the save), how to go back to the previous entity. Is there some place ui5 stores, the previous entity or should I have some variable and assign it to the controller.previousEntity = oldsPath?
what are the different members in the oModel,it start with
a(aBindings)
b(bUseBatch)
m(mContexts)
o(oHeaders)
p(pCallAsync)
s(sPathUrl).
Is there a naming convention in these?
From what I can see, there are following things you need to notice and work upon.
Its generally not a good idea if you use the same form to display and to create/update also. A simpler approach would be to
use a new popover to show the form for create and in that case, the view binding would not be changed when you cancel the operation.
However, if you still want to use the same form, yes you would have to bind the view/form again on cancel operation. You can have a variable declared in the Component.js to store the path for you. In UI5, the model captures the current state to ensure the back the binding concept by default.
You can check all properties and their definitions here: oData Model
Yes, there is a naming convention followed here.
a - Array, s-String, b- Boolean etc.
Read more about Hungarian notations for naming conventions
The previous entity is still there in the cache (ODataModel.oData), but you'll need to re-bind it. For that purpose, as you have written, you'll need to store the path to the entity yourself. Once you bind the control, I don't think the previous binding context is stored somewhere (why should it).

exist-db restxq trigger : Services deleted but still active

I have issues with the RESTXQ implementation in exist-db.
I think it might be the RestXQTrigger which is not working correctly.
The problem: I deleted (via the Dashboard) a collection including RESTXQ services inside several .xqm files. However, the services are not unregistered and are still available, even after restarting eXist.
Is there any way to force this unregistring, I mean other than recreate the previous collections/files and delete each .xqm files one by one (this way, the trigger seems to work) ?
RESTXQ in eXist at the moment only implements the Document Trigger events and not the Collection Trigger events. This is just a limitation which needs to be resolved when there is time to implement it.
There is an XQuery module provided with eXist in the namespace: http://exquery.org/ns/restxq/exist. The functions in this module enable you to manually manipulate the RESTXQ Registry. You can enable it in $EXIST_HOME/conf.xml. If you then restart eXist and re-build the function documentation you should be able to see the documentation in the function browser app for these functions. In particular you most likely want the functions:
exrest:deregister-module(xs:anyURI("/db/my-module.xqm")) and exrest:register-module(xs:anyURI("/db/my-module.xqm")).
There are also functions for registering and deregistering individual functions from a module, which are called register-resource-function and deregister-resource-function they are similar to above but take a second argument which is a function signature (as a xs:string) in the form of qname#arity e.g. "fn:substring#2"
You can stop the database, and manually remove the registry file $EXIST_HOME/webapp/WEBINF/data/restxq.registry

Something similar to RoutedCommands, but for MVVM

I have a Command bound to my MainWindow via CommandBinding to the Delete key.
I want that, depending on the context (which element is active), the same command would be translated to different delete commands that semantically delete things.
In few words, I want that pressing the Delete key will delete things depending on where the focus is at that moment.
I have heard about CompositeCommands (PRISM), but I don't know whether that is useful an easily applicable here.
Thanks a lot!
CompositeCommand in Prism helps you register several commands in one, so that all can be called at the same time.
Since you use MVVM, you should have a ViewModel for each kind of object at least. If you have something like a ViewModelBase or an IViewModel, you could simply add a command to it, and initialize it differently in each ViewModel.

Lazarus: How do I find detailed docs (class info) of objects?

Is there a way to find complete class info of an object in Lazarus. F1 doesn't work.
For example, I want to know the methods, events and properties of TSQLQuery. More specifically, I'm trying to find what constants I can use with the state property.
The docs I've found so far aren't really much help in this context.
I've also tried the menu that says 'object browser' but it simply points to the properites window.
TSQLQuery and its unit sqldb is not documented.
The state property however is from the base tdataset ancestor of sqlquery, and that IS documented.
Try typing TDatasetstate or tdataset and press F1
The best documentation is the source code. After you dropped a TSQLQuery on the form CTRL-click on the identifier "TSQLQuery" in the source editor. Lazarus will open the corresponding source file at the position where TSQLQuery is declared. Scroll down to the public methods or published properties to see everything you need. Identifiers usually are self-explanatory - the chm file often does not contain more info. And the source is always up-to-date.
You can do the same with any identifier. Depending on the Lazarus version you may land in the implementation part of the unit. In this case, just press SHIFT-CTRL Up/Down to go to the interface.

How to change scaladoc default ordering to "by inheritance"?

I generate scaladoc by using the sbt command doc. The generated scaladoc has default ordering set to Alphabetic. I can manually change it to By inheritance, but when I visit another class documentation, the ordering reverts back to alphabetic.
Is there a way to generate scaladoc with default ordering set to By inheritanace?
At present there is no way to generate scaladoc with default ordering set to By Inheritance.
The page template hard codes the initial value and switching is handled by some jQuery event listeners.
It should be possible to write a simple script and attach it with TamperMonkey or similar that will run the equivalent to click() for you.