Nebula Grid Show Item and centre it - java

Can I get a Nebula Grid to show an item and centre it in the available space?
I'm using the showItem() function in the grid, and it just seems to scroll the table by the shortest possible amount to show the row.
I tried adding a few rows on to lessen the annoyance of it sitting right at the top but of course you can't predict whether it will be at the top or the bottom after the call to showItem so this doesn't work.
Glen x

The showItem(Item) API is from AbstractTreeViewer in JFace, and is not Nebula-specific.
There is no API for what you need. You could work around it by adding extra items, showing a "further" item (to simulate the centering), then show your initial item again.
Sorry. :-(

Related

Is there a way to have a GridView with dynamic cell size?

In android, the gridview provides an excellent way to arrange items neatly. However, the cell size for a grid is fixed. That is, in a 3 column by 4 rows grid, if the very first item is 10 dp in height and the second and third items are 20 dp in height, then all the cells in first row will be of 20 dp height.
I want to find a way where in, the view will automatically adjust the cell size for the first cell, so that items below the first item of 10dp height are displayed immediately below it, instead of leaving that extra 10dp gap.
This is the sort of behaviour we can see in Windows live tiles. The items below small tiles move up to fill the gap. I want to implement a similar functionality.
Is there a way to do that?
So turns out, there was already a way to do this. I just didn't know the right term for it.
Android provides a StaggeredGridLayout Layout Manager that does just what I need.
You can take a look at this page
Also, visit this page to see it in action.

Expandable grid Vaadin UI

I have a simple grid. Two columns with a variable amount of rows. I want to make it so i have a header row with an arrow that can collapse and show the whole grid. So when I bring up the app, only the header row is visible with an arrow, and I can click to expand/collapse to show the rest of the grid.
A TreeGrid seems like overkill since I don’t need any hierarchical structure, just the ability to collapse/expand one row. I exclusively use IE and I’ve read that Drawyer doesnt work with IE 8 and above. I return a list of the objects and the object just has two string variables.
Any help with this? I am new to Vaadin 8.
Set grid height (workaround)
As a workaround, you could set the height to be approximately the number of pixels you expect to be the height of the header.
See the Sampler demo. Click the gear icon at top to expose properties of the example Grid object. The last property shown is "Size (W x H)". Change 100% to 100px to see the effect.
Grid height set to 100%
Grid height set to 100px
You can also hide the footer (see checkbox in that property list).
I don't think this can be done with plain Vaadin. But I recommend the following simpler approach:
Initially call grid.setHeightByRows(1.5) (javadoc). This will show exactly one row and a half to indicate more data is available. A scrollbar will appear, too.
Make a new column within the grid that has a button or add a button below the grid that - when clicked - calls setHeightByRows with the number of elements in the grid and hides the button. This will show all rows.

RecyclerView - how to stack items instead of scroll off screen?

I noticed a cool effect in a game I've been playing and was wondering how to accomplish it in an android application using the RecyclerView (or any other kind of list object in android).
What I'm trying to accomplish: when you scroll the items in the recyclerview, instead of having those items scroll off the screen, I'd like those items to start stacking on top of each other near the edge of the screen. So when you scroll towards the edge, the items start stacking on top of each other. And when you scroll away from the edge towards the middle of the screen, the items start unstacking off of each other.
I'd post an image, but I currently don't have enough reputation, so here is a link to what I'm trying to accomplish:
http://i66.tinypic.com/1z3uubm.gif
Another link in case other one is not available:
http://imgur.com/8GkWKdQ
Any code examples or a general direction would be greatly appreciated! Thanks.

SWT Label Drag'n'Drop

I'm surprised to see that this hasn't been done, or at least my research says so.
I have a Canvas with RowLayout and a bunch of Labels.
The title is pretty straight forward: I want to reorder my labels using DND.
Please don't tell me I have to engineer my own algorithm for calculating bounds and sizes and stuff like that.
Later edit:
I'm considering using Zest, but again, I can't find any example where graph nodes are snapped to eachother.
I did something like this about a year ago.
My method of solving this problem was to use a data model to hold the label information. Use the canvas.getChildren() and search for a separator composite between each object or the label that you dropped on top of. When a drag and drop operation was completed you would search for the item that you dropped on and move the reference to the appropriate position in the model. Then reset the information on each label. Only requirement to do this is to keep a data structure with the label info and a reference to the canvas.

How to determine how far a scrollbar has moved in SWT?

Before Scroll
After Scroll
I am working on creating an Eclipse plugin for tracking of collections (Arrays, Array List, etc.). And I was in need of an SWT Table with expandable columns. In order to implement this, I created several SWT buttons, and generated them before I created the table, and I linked them to the columns that need to be expanded. What I'm having a problem with now is that I need a way to determine how much a user scrolled the scroll bar in order to determine what the new location of the buttons should be. For instance, if the user scrolls 10 pixels to the left, I need to move the buttons 10 pixels to the left, etc.
Is there an easy way to accomplish this within the SWT ScrollBar framework?
Actually, I was able to solve the problem by using Scrollbars "getSelection" method. Turns out, the value that this method represents is the offset from 0 of the scrollbar. In order to solve the problem, I just subtracted the getSelection value from the X position of the buttons

Categories

Resources