Editing SWT Table cell. Changed value jumps back immediately to old value as soon as I leave cell. Why? - eclipse-plugin

I have a Dialog and there is a Table (Tableviewer) inside it.
tableViewer = new TableViewer(composite, SWT.BORDER | SWT.MULTI);
Certain columns of my table are editable. I click on the cell, I edit the value, I leave the cell and the edited value immediately reverts back to the old one.
What should I configure/set in table/tablehelper to make the edited values last longer than the time I spend in the cell?
EDIT!-----------------------------
We have a Helper class that is responsible for creating CellEditingSupport like this:
`
if ("w".equalsIgnoreCase(hd_bean_mode)) {
CellEditingSupport editingSupport = new CellEditingSupport(viewer,pds[i]);
col.setEditingSupport(editingSupport);
}`
This class itself is quite complex and does a lot of magic through reflexion, etc... The funny thing however is that other tables use this very same Helper class, seemingly with the same configuration and they work!
One more thing: I am conviced that the columns in my table get the Editingsupport. I know it because of the debugger and because the cells are editable. The only problem is that those edits do not last long.

Related

pyqt5 automagically adds QSpinBox (?) inside a table cell

Sorry about the title but I am not even sure for the right name of this kind of "widget".
Whenever I add
if role == QtCore.Qt.EditRole:
return 42 # or any other numeric value
in data(self, index:QModelIndex, role=None) method of my model (subclass of QAbstractTableModel) a cell gets edited, the cells gets two small triangles on right, one facing up, another facing down, on which I can click so that the (integer) value in the cell is incremented or decremented
This is very annoying since I didn't ask for this behavior, and I don't know from where it comes from. This prevents me from entering non-numeric values inside the cell, and I have no other choice than deleting it, and re-enter new formula / value
How can I prevent this behavior?
Picture:

Cannot disable UltraGrid cells

I have an UltraGrid in my project. Data can be entered into each cell, which is then saved to the database. I want to be able to disable all of the cells in the current row EXCEPT for one called Product_Code. Once data has been entered into the active row column (this is entered via a ValueList), I then want all of the other cells to become available for entering data into.
So far I have tried
If Me.ugProducts.ActiveRow.Cells("Product_Code").Value.ToString = "" Then
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.Disabled
Else
Me.ugProducts.ActiveRow.Cells("Product_Volume").Activation = Activation.AllowEdit
End If
But to no success. When the project is built, all of the cells are immediately available to type into, despite no value having been entered.
Why is it not working? What is the best way to do this?
I saw a previous comment on here that has since been deleted, for some reason... However, one solve you can try is:
In the form load; add in ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.CellSelect - This will mean all of the cells are disabled, but you'll still be able to select the ValueList for Product_Code
Now, in the CellListSelect event of ugProducts, use the following code ugProducts.DisplayLayout.Override.CellClickAction = CellClickAction.Edit (After any validation checks or anything that you have in the method already, it will go in here somewhere, just keep trying things if you aren't too sure where)
Anyway, this should now let you fill them in as you wish.

Delete function first or last record

My main menu is where all records are displayed. The user can navigate between records by a list table which has all the records.
When i use the this code to delete a displayed record, allways the first record gets deleted.
BindingContext(JobsDBDataSet, "T_Jobs")
.RemoveAt(BindingContext(JobsDBDataSet, "T_Jobs").Position)
Ive added an extra line in which the position should match the ID of the record.
BindingContext(JobsDBDataSet, "T_Jobs").Position = Job_IDTextBox
BindingContext(JobsDBDataSet, "T_Jobs")
.RemoveAt(BindingContext(JobsDBDataSet, "T_Jobs").Position)
NOTE: Job_IDTextBox is directly connected to the column in the database (I dragged it from the datasource menu into the form in details form)
My goal is so that i can delete the job that has been selected (and displayed) from the list box (with all records in it)
Right so ive changed my code to
BindingContext(JobsDBDataSet, "T_Jobs").Position = Convert.ToInt32(Job_IDTextBox.Text)
BindingContext(JobsDBDataSet, "T_Jobs").RemoveAt(BindingContext(JobsDBDataSet, "T_Jobs").Position)
And the same thing still happens: last job is deleted and not the selected one (from the listbox). I have a feeling its a problem regard the listbox, and maybe I'd firstly have to tell the program to change its pointer to the job ive chosen from the list box but i have no idea how to do this - and this is just an assumption.

Programmatically set dgrid row as active

I'm trying to programmatically set a dgrid row as active, not just selected. I have a dojo dgrid OnDemandList which is using the Selection and Keyboard Mixins.
Using the select(row) method I can programmatically select a given row, but that row is not active. When a row is active, I can use the Up and Down arrow keys to navigate to the rows above and below it. When a row is just selected, the row is highlighted but the arrows keys do not work.
Clicking the row with the mouse will make it active and selected, but I'm trying to build my interface to be 100% usable with just the keyboard.
Ok, took me awhile but got it figured out. What I was really trying to do was add focus to a row. The code for doing that was in dgrid/Keyboard.js under the _focusOnNode method.
The actual code to change focus from row currentFocusedNode to row focusedNode is:
if(currentFocusedNode){
// Clean up previously-focused element
// Remove the class name and the tabIndex attribute
put(currentFocusedNode, "!dgrid-focus[!tabIndex]");
if(has("ie") < 8){
// Clean up after workaround below (for non-input cases)
currentFocusedNode.style.position = "";
}
}
if(has("ie") < 8){
// setting the position to relative magically makes the outline
// work properly for focusing later on with old IE.
// (can't be done a priori with CSS or screws up the entire table)
focusedNode.style.position = "relative";
}
focusedNode.tabIndex = grid.tabIndex;
focusedNode.focus();
put(focusedNode, ".dgrid-focus");
The code above is really just a code fragment, for it to work you will have to declare "dojo/has" and "put-selector/put" first as well as define the currentFocusedNode and focusedNode. But I'm leaving that as an exercise for the reader ;-)
Also note that this only changes the "focus", it will not select the focusedNode but that can easily be done using grid.select(focusedNode);

How can I force entry to complete in a NSTextField from a NSButton

I just noticed a problem when my user-interface is in a certain state. I have a table view with two columns both of which the user can enter data that is to be used later. There's also a button which acts upon the contents of the table view.
The problem is if the user has entered new data in the column but has not yet exited the field by using the tab key or return key (i.e. the cursor is still in the field and in editing mode) and the button is pressed the old value is used not the current value sitting in the field.
What is the best way to handle this this? I want to use whatever the user has entered thus far.
Basically, The button code needs to tell the text field to finish completion or exit the editing mode. But I can't seem to find a method that will do that.
Use bindings. In Interface Builder, select the table column and in the Inspector go to Table Column Bindings and set the Value content binding appropriately and ensure the "Continuously Updates Values" option is checked. Then changes to the table cell content will propagate immediately.
Found the answer, At least for me.
Find out if a row is selected and if so deselect it. This causes the current entry to be completed.
- (void) completeTableEntry
{
// If a column is selected ensure it is completed
NSInteger sr = [keyValueTable selectedRow];
if (sr != -1) {
[keyValueTable deselectRow:sr];
}
}
How about:
[theTargetWindowWhateverThatIs endEditingFor:nil];
theTargetWindowWhateverThatIs may be, for example, self.window if you are inside a NSWindowController.