How can I style a cell or row/column of cells in NatTable programatically? - nattable

I'm having a hard time figuring out how to individually style a cell or group of cells when a certain thing happens. For instance I would like to be able to right-click on a cell and hit something like "tag" and it would change the background color of the cell to something different. I would like to do the same thing with rows, columns, or any random group of selected cells. I also need this change in style to persist even if the cell(s) are moved beyond the viewport layer's view.

If you have a hard time with NatTable, maybe it is worth reading some of our tutorials and documents.
https://www.eclipse.org/nattable/documentation.php?page=styling
http://www.vogella.com/tutorials/NatTable/article.html
In short related to your question. Individual styling is done via config labels on a cell and styles that are registered in the ConfigRegistry for that label. So what you need to do is to implement some sort of label registry based on cell indeces. That label registry then needs to be used by a custom ConfigLabelAccumulator so the labels are attached to the cells with the corresponding indeces.
We have a basic implementation on a column base via the ColumnStyleEditorDialog. This can be seen in the _000_Styled_grid example by clicking on the column header and call "Format cells". Personally I think that feature is not complete, but it should help you in seeing how it works in principle.

Related

NSTableView / Cocoa - Multi-column table with table-wide section row

I'm working on an MacOS/Cocoa app where an NSTableView contains information on multiple items where information on each item is displayed on multiple rows in a multi-column table with a table-wide "title" row displayed above the information for each item's data.
Here I have three columns: "Page", "Term" and "Popularity". I've implemented code that sets the formatting of the cells in the title row to black with white text via tableView(:viewFor:row:) and have also created a custom row object (the light blue) via custom NSTableRowView::draw( dirtyRect: NSRect).
However, I also need to have the title (truncated to "Her" in this case) span the entire table width and have not found any solutions posted for something like this. Basically I just need the view for the black row w/white text go all the way across all three columns.
Researching the problem I've found a number of potential leads for possible solutions but none seem like a clear winner:
Use of the custom NSTableViewRow and a hand-added NSTextField that floats above the cells in the table, though I've not tried it yet and no idea if the scrolling/stacking will be a headache. Not even sure how to implement something like that but I imagine I could figure it out.
Apple documentation refers to NSTableViewRow::var isGroupRowStyle but I cannot find for the life of me any documentation that actually explains what that's for / how it's used so no idea if that would be of help.
The use of NSTableView "Sections" was also recommended and looks very promising. However it looks to be iOS specific (could be wrong here) and I've not found anything like an example that shows it working w/multiple columns.
Basically what I'm needing is something simple like the HTML RowSpan feature but that's probably expecting too much. Any suggestions for best solutions for this and/or coding examples I could look at?

How to edit rowSpan of cell of report in BIRT?

I created a report (.rptdesign) in eclipse/BIRT and added a Grid and some rows in it. I want to change the rowSpan of 1st cell in 1st row to 3. But in properties window, the property is 1:inherited and won't allow me to edit the value. I tried different combinations of width and height (in, %..) and other properties but can't figure out this behavior.
I spent hours and there is barely any resource available online or on official site. Any help is appreciated. Thanks.
when you create a grid with rows- all cells are equal in width. Now what you can do is merge the cells together that will create the rowspan/colspan like this -
Please click on image to see steps
After merging it will look like this -
You can get more information here : eclipse help
You just mark several cells in the layout editor, then "merge cells" in the context menu. To split a block of merged cells again, use "split cells" in the context menu.

NSTableView with custom cell view and NSArrayController bindings drawing a blank string

It took me forever to figure out how to set up editing on a custom cell view for an NSTableView. Thanks to StackOverflow I figured that much out. P.S. I was doing all of this in Interface Builder.
I have a single column table in which the cell is a custom multi-control NSTableCellView, with:
name (in bold)
description
detail
It's all text. Set up editability on the name only. The table is sorted by the name.
When I edit the name, it has the effect on the bound model that I expect. The table even re-sorts correctly. However, it's displaying incorrectly. The description and detail (not editable) still show up correctly, but the name (which was edited) is a blank. When I inspect the model, it has the correct updated value. But the cell view itself is incorrect.
This doesn't happen all the time--it typically happens if the cell is re-sorted to the top or bottom of the table, but that may be a red herring and may instead have to do with NSTableView cell caching or something.
I hacked up a workaround in which I assign a delegate to the NSTextField (automatically generated for the NSTableCellView) and intercept the textShouldEndEditing event. For some reason this event is getting triggered twice for a given edit (after I press "enter" in the text field)--once for the actual edit where fieldEditor.string is different from the model name, followed by another event where fieldEditor.string is the same as the model name. If I return false for my textShouldEndEditing handler in the latter case, then the cell contents end up being drawn correctly. That's the hack.
I feel like I'm doing something wrong here though, and that shouldn't be necessary.
Is the textShouldEndEditing event supposed to be fired twice?

Creating Form Control at Cell Location with VBA in Excel

Reference
I am using ActiveSheet.Buttons.Add() to add format control buttons to a worksheet. This method suffers when I have to add several buttons with a certain horizontal distance between them and column widths change, causing a slight drift between buttons.
I would like to instead use a cell reference which would prevent this drifting caused by column width changes.
The syntax is
ActiveSheet.Buttons.Add BUTTON_LEFT, BUTTON_TOP, _
BUTTON_WIDTH, BUTTON_HEIGHT
This will create a button at the active cell. Change as possible.
ActiveSheet.Buttons.Add ActiveCell.Left, ActiveCell.Top, _
ActiveCell.Width, ActiveCell.Height
EDIT: Beaten by Tim!

UITableView: moving a row into an empty section

I have a UITableView with some empty sections. I'd like the user to be able to move a row into them using the standard edit mode controls. The only way I can do it so far is to have a dummy row in my "empty" sections and try to hide it by using tableView:heightForRowAtIndexPath: to give the dummy row a height of zero. This seems to leave it as a 1-pixel row. I can probably hide this by making a special type of cell that's just filled with [UIColor groupTableViewBackgroundColor], but is there a better way?
This is all in the grouped mode of UITableView.
UPDATE: Looks like moving rows into empty sections is possible without any tricks, but the "sensitivity" is bad enough that you DO need tricks in order to make it usable for general users (who won't be patient enough to slowly hover the row around the empty section until things click).
I found that in iOS 4.3, the dummy row needs to have a height of at least 1 pixel in order to give the desired effect of allowing a row to be moved into that section.
I also found that the dummy row is only needed in the first and last section; any sections in between don't have this problem.
And it looks like in iOS 5.0, no dummy rows or special tricks are needed at all.
While managing the edit, you can monitor if the table view is in Edit Mode. Use that flag inside of cellForRowAtIndexPath to decide weather or not to display the 'blank' row. While in 'regular' mode, the row will not display, but when the user taps 'edit' cellForRowAtIndexPath should get called again and this time decide to display the row. The details of how to do that depend on your data source and how you are gluing it to the display. If you aren't getting the call again, you can manually inject rows with insertRowsAtIndexPaths / deleteRowsAtIndexPaths and/or call reloadData to force a refresh.
I found that if you return -1.0 from the heightForRowAtIndexPath method it will remove the 1 pixel line.