Does TreeEditor support multiple selection? - enthought

I am using a TreeEditor to represent model objects in my traitsui application. I would like the ability select multiple objects in the tree editor by holding down Shift or Ctrl and performing selections. My ultimate goal is to provide a quick way for the user to delete multiple objects in one go rather than right-clicking each item individually.
From reading the source code for tree editor I noticed,
selection_mode = Enum('single', 'extended')
which appears to define an extended selection mode. But I cannot find any example code which uses nor is it mentioned in the documentation of TreeEditor.
Is this supported by traitsui?

FWIW, here's some relevant code snipped from a working application and sanitized. I have not tried to run it, so there could be some copy/paste/sanitize typos.
def default_traits_view(self):
return View(
UItem(
'my_run_tree',
editor=TreeEditor(
nodes=[
TestRunTreeNode(
node_for=[Node0],
children='children',
label='label',
),
TestRunTreeNode(
node_for=[Node1],
children='',
label='mylabel',
),
],
editable=False,
selected='selected_nodes',
selection_mode='extended',
)
),
resizable=True,
)

Here is an example demonstrating multiple selection. As Jonathan says,
Set selection_mode='extended'
Set selected attribute to a List(Any)
https://gist.github.com/danieljfarrell/24f838085172de9d20a4d3daa9f813b3

Related

Is it possible to change Flutter's AutoComplete order in VS code?

I have a question.
Is it possible to change Flutter's AutoComplete order in VS code?
If I try to put an IconButton,
IconButton Snippet is recommended, and autocomplete is as follows.
for example
IconButton(onPressed: onPressed, icon: icon),
But I want the order to be like this.
IconButton(icon: icon, onPressed: onPressed),
How can I change this?
If you have not typed any prefix and are seeing the "full list" of code completion, then the ordering is determined by the Dart analysis server. They should be sorted with "relevant" items at the top (where "relevant" is a computed score that takes into account a number of things).
However, if you have typed any characters (such as "icon") so that the list has been filtered, then VS Code is handling the ranking. VS Code's ranking is based only on the text of the completion and the text you've typed and does not have any additional context (such as which types are most likely there), which can sometimes result in sub-optimal ranking.
It's not clear which of these is the case here, but a screenshot would help understand.
There are some related issues in the VS Code issue tracker relating to the second point above:
https://github.com/microsoft/vscode/issues/79516 - a report of VS Code ignoring server-provided ranking - considered by design
https://github.com/microsoft/vscode/issues/127516 - a feature request for a way for VS Code to use type information to provide better completions/ranking

Autodesk forge highlight child object

Recently i've been working on this repository https://github.com/xiaodongliang/forgeviewer_embed_in_powerbi_report to build a custom visual in Power BI to visualize the issues extracted from Bim track'S API.
The idea was visualizing them in associaton to the model's ROOMS.
In order to do that I worked with a NWC file, so i cuold export rooms as a geometry.
What i would like to do now is to highligt the rooms if a connected issue is selected from a table.
The problem is When i select an issue from a table, in the selection tree i can see highlighted the parent object name (ROOM) instead of the child (solid), and i think that is why i can't achieve my purpose (if not please correct me).
what i have
what i wold like to do
Does anyone know a way to do that?
If you would like to change your selection between (FIRST_OBJECT, LAST_OBJECT, LEAF_OBJECT) you can change viewer selection settings in order to test:
If you would like to achieve this programmatically :
Viewer.setSelectionMode();
could help you as well.
If I well understood, you want to highlight the child (which contain the mesh) instead of the parent.
The object highlight (isolate) is done in /forgePowerbiView/src/visual.ts with this code:
const dbIds = options.dataViews[0].table.rows.map(r =>
<number>r[0].valueOf());
console.log('dbIds: ' +dbIds)
this.forge_viewer.showAll();
this.forge_viewer.impl.setGhostingBrightness(true); //for isolate effect
this.forge_viewer.isolate(dbIds);
Take a look at this link Enumerating leaf nodes on Viewer. This will help you to get the dbIds you want to isolate.

Is there a way to avoid holding the ALT key when cycling through input fields within a SAPUI5 table?

I have a SAPUI5 table which contains input fields. I have prepared an example at http://jsfiddle.net/bgerth/x8h92mz8/.
When you press ALT+TAB you can cycle through the input fields within the table (I only found that out by looking at sap.m.ListBase.prototype._startItemNavigation).
Only pressing TAB focuses the first element outside the table.
I consider that rather non-intuitive. Is there a way to make TAB alone work the same way?
Update:
Alt+Tab works in Chrome and Safari, but not Firefox (45.0.2) on my Mac. It doesn't work at all on Windows, as that combination is reserved to toggle through open application windows.
There are two solutions I discovered so far to address this problem
Proposal 1: Adapt tab key handling
I have found the blog SAPUI5 Table Navigation with Tab Key by Klaus Kronawetter which adds extra keyboard handling to a sap.ui.table.Table. I adapted his code for a sap.m.Table which you can find at http://jsfiddle.net/bgerth/os6r096y.
Unfortunately, the code is rather lenghty.
Proposal 2: Enable up/down arrow keys
After further investigation, I decided that the solution from proposal 1 above is too much hassle.
Instead, I adapted the class sap.ui.core.delegate.ItemNavigationmentioned above, which is internally employed by sap.m.ListBase. In essence, you can cycle through the input fields with up and down arrow keys.
I have prepared an example at http://jsfiddle.net/bgerth/0r9L30wd. The relevant code is
var fnPatchedItemNavigationsetItemDomRefs = sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs;
sap.ui.core.delegate.ItemNavigation.prototype.setItemDomRefs = function setItemDomRefsPatched(aItemDomRefs) {
// 'this' is now the instance of sap.ui.core.delegate.ItemNavigation
jQuery.sap.log.debug("Patched version of sap.ui.core.delegate.ItemNavigation.setItemDomRefs");
var aInputFields = $(aItemDomRefs).find("input:enabled").get();
if (aInputFields[0]) {
// There is at least one enabled input field in this table
return fnPatchedItemNavigationsetItemDomRefs.call(this, aInputFields);
} else {
return fnPatchedItemNavigationsetItemDomRefs.call(this, aItemDomRefs);
}
}

Custom content assist for default java editor in Eclipse

I'm currently trying to develop an Eclipse Plugin to support code replacement, like what the default content assist in Eclipse do. What I want to implement is something like "insert argument names automatically on method completion with visualized box around the argument" and I can "use the Tab key to navigate between the inserted names" and "while navigating, list of optional variables for current argument can be displayed and be chosen".
In short, it comes to two questions:
How to add the visualized box around the already existed variable or even Java keywords that need replacement? And at the meanwhile I can use Tab key to switch between these boxes.
How to display a list of candidates to select from when I trigger on the box?
By now I only figure out the extension point : org.eclipse.jdt.ui.javaCompletionProposalComputer may be useful, but I have no idea where to start at? Thanks in advance.
Oh, finally I've solved it myself...
For the 'box', it should be the LinkedModeModel, this class should work with LinkedPositionGroup and LinkedPosition to add mutiple boxes. And we should use LinkedModeUI to set it up.
For the content assistant, there's no need to use the extension point. There is a ProposalPosition class which extends LinkedPosition for you to add your proposals for the 'box' in its constructor. And we can simply use the CompletionProposal to construct a ICompletionProposal array as the argument of ProposalPosition's constructor.

Grab focus to embedded window inside Gtk::Socket

I have embedded gvim inside a Gtk::Socket which is placed in a Gtk::Box, how can I grab focus to the embedded gvim window so that I achieve the same as actually pointing and clicking in the embedded window?
Using ->grab_focus() on the Gtk::Socket widget does not have any effect.
According to the XEMBED spec (http://standards.freedesktop.org/xembed-spec/xembed-spec-latest.html#idm139742761059984) it seems that the embedder (Gtk::Socket) should send either a XEMBED_FOCUS_IN or a XEMBED_WINDOW_ACTIVATE signal to the child, but there does not seem to be an interface for this in Gtk::Socket.
An simple example of what I am trying to do based on the Gtk::Plug and Gtk::Socket example can be found here: https://github.com/gauteh/plug-socket-grab-focus .
In case this is a bug, it has been reported here: https://bugzilla.gnome.org/show_bug.cgi?id=729248
There are now two ways to achieve this, one is by using the patch as provided in: https://bugzilla.gnome.org/show_bug.cgi?id=729248 which adds an gtk_socket_focus_forward () method to GtkSocket. Calling this will focus the first widget inside the Gtk::Plug window.
An example of using gtk_socket_focus_forward can be found in the focus_forward branch of an example adapted from the standard example.
The second way to achieve this is to send the Gtk::DIR_TAB_FORWARD signal as described on the mailing list, a similar example can be found in the tab_forward branch.
This involves the following:
socket->set_can_focus (true);
socket->child_focus (Gtk::DIR_TAB_FORWARD);
The method does diverge slightly from what is possible with gtk_socket_focus_forward, but appears to do the trick.