Drag and drop between two grids in Vaadin 14 - java

I want to run the example from the official Vaadin vendor site:
https://vaadin.com/components/vaadin-grid/java-examples/drag-and-drop
Of course, I have some other objects to drag, but i am happy when the example is working. At the minute, I don't know how it is meant to be used, or I am getting dumb, because I am living in germany.
I wonder why the example is not running out of the box.
When i use this code, there are several errors in the code. What is dragItems? And how to calculate the index of the drop position? Any help is appreciated. I just want to use this framework, but the demos are not compiling.
I want to drag an item from a grid on another grid. How to do that?

These fields are missing in the code:
private Collection<Person> draggedItems;
private Person draggedItem;
private Grid<Person> dragSource;
You can check the full code here for Vaadin 14: https://github.com/vaadin/vaadin-grid-flow/blob/4.3/vaadin-grid-flow-demo/src/main/java/com/vaadin/flow/component/grid/demo/GridDemo.java#L2375
draggedItems is the list of items that you started to drag (they are set on GridDragStartEvent and cleaned on GridDragEndEvent)
You are dropping the items on an item (before or after). The index of the position has to be calculated. It depends if you are using a listDataProvider or something else.

Related

Trying to Change Dojogrid Rowcolor based on Content

I have a function that generates a Dgrid and fills it with content which it receives from Javaside.
I tried to do dojo-css to handle this like here:
Style Dojox Grid Row depending on data
After this didn´t work I tried to work with Dojo.connect to change the color of the row when the grid is being built and filled.
After that didn´t work I tried to use dojo.on or dojo.aspect.after but since I am a total Newbie in Dojo I have no clue where you can intersect in the code and do theses things.
with a code like so :
require(["dojo/request/xhr","dojo/dom-form", "dojo/dom", "dojo/_base/array", "dojo/json",'dgrid/Grid','dgrid/Selection',"dijit/registry","dojo/_base/declare","dojo/domReady!"],
function(xhr,domForm,dom, array, json, grid, selection,registry, declare){
..... Here the grid and data is declared java function called
}.then(function(data, array, grid, selection,registry, declare){
.....Here the dgrid is filled
}
Where/when should i use Dojo.Connect , Dojo.on or Dojo.after?
I´ve spent mutiple days trying to figure this out but the program either stops working or ignores my changes.
The link you mention above is for dojox grid, which is different to dgrid. Here is the link to css styling for dgrid.
It won't answer your question though which is about changing a row color based on content. The way I do this is cell by cell, using a custom renderCell function.
Documentation on renderCell can be found here, and an example can be found here.
ps: a bit of caution. The learning curve for dojo 1.x is quite steep. When looking for documentation, make sure you get the latest possible (1.10). If you find a link which is about version 1.6 or less, be careful: many 1.6 and before features have been deprecated in version 1.7.

In Eclipse Debugger, getting the index location of a variable in an embeded list hierachy

Is anyone familiar with a debugging option that has the feature? I have a list of items in a JComboBox deeply embedded in a swing app that is buried withing multiple lists. Is there is away to find the index of these items in the Eclipse Debugger without writing code? I could manually write down the index of every list, but I'm looking for an easier way to tell me that this location is at parent[2].layer[0].child[3].layer[1].child[0].combobox[4].item[5]
without looking scrolling through the variable list.
Thanks!
When debugging, in the variables/Expressions pane, at the top right there should be a button with an arrow going to the right called "Show Logical Structure".
If you tick/untick that it should change the display of list structures. It might help you out.

Dynamically changing the shown form on tree selection

I'm currently learning the adf framework, and while doing this I found myself in a situation I am not able to solve.
I have a tree component that works fine. I also have different forms, corresponding to different levels of the tree. Rather than having all of the forms visible at one time, I would like to only show the one that corresponds to the selected item in the tree.
To solve this, I created af:switcher, created facets and moved the forms there. Here is where I am lost, how do I tell the switcher to change the form? I tried to link them together using the facetName on the switcher, but no success. I suspect I did not link the right thing there, but I could not find anything helpful from the tree either! I assume it has something to do with the selectionListener and a bean, but I could not figure out a way to do this. Any clues?
See Sample #50 of http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html#CodeCornerSamples
Frank

JTable with jgoodies sorting trouble

I've got a blocking problem with the sorting functionality of a JTable; this made stall the development of the spare time open source project for 4 months now. Hope to be pointed into the right direction here.
Context: I'm working on extending the functionality of the ps3mediaserver to add a media library with pms-mlx. The UI of the media server has been done using swing.
Problem: When clicking on a column header in the JTable, a seemingly random column gets sorted instead of the one having been clicked.
Current implementation: Here's the description of the different components and classes being used for the implementation:
ETable: As alternate row colours aren't supported by default in the JTable, I've switched to the ETable extending the JTable. Source comes from here
FileDisplayTable: This is the class creating the table. In the init() method, the sorting is being enabled with 'table.setAutoCreateRowSorter(true);'
FileDisplayTableCellRenderer: Exists to always align cell content on the left
FileDisplayTableColumnModel: Does some mapping between internal types and column names
FileDisplayTableAdapter: This class implements com.jgoodies.binding.adapter.AbstractTableAdapter to map the objects with the table columns.
Possible solutions:
Preferably, I'd like to keep the current implementation and figure out how to correct the sorting, but I doubt someone can help me out with that!? Additionally their are some bits of code I had to add because of strange behaviours; they're commented in the code
The alternate option would be to change the JTable for another control altogether. I've made some research but didn't find the solution I was hoping for. The constraints are that
it must be embeddable in a swing UI
preferably it should support data bindings
support alternate row colours
row sorting
At some point it will be possible to open an editing dialogue, where the content of the row has to be retrieved, can be edited and when saved the row has to be updated.
Before reworking the entire thing I'd like to be sure the component will be able to handle all I want to do with it.
I'm more used to create GUIs using .NET in Visual Studio. It's quite different and a lot more difficult to do the same with swing. Please show me I'm wrong :)
[edit] If someone is willing to reproduce the problem, either get the source or the binaries, launch the application, navigate to the media library tab. In the Genral section import some videos by adding some video files. Go to the library section, click on apply to refresh the list and try to sort the table.
It may be useful to know that JTable columns can be dragged by the user. As a result, the view (JTable or a subclass) and model (an implementation of TableModel) may have different column numbers. Similarly, a RowSorter may affect the order or number of rows in the view as compared to the model. The related conversion methods are mentioned in How to Use Tables: Sorting and Filtering. In particular: "When using a sorter, always remember to translate cell coordinates."
Addendum: As an alternative, consider org.netbeans.swing.etable.ETable or it's subclass org.netbeans.swing.outline.Outline, depicted here.

Scrolling down an awt.List

As from subject, I have an awt.List object. When I add something to the list I would like to scroll it down to show the last inserted object.
For instance:
myList.add("sometext");
myList.select(myList.getItemCount()-1);
myList.showSelectedItem(); // Or something like that
The documentation does not seem to list any method that does something like that, can anybody help please?
I am not sure that this is possible (explicitly). In my experience I have written an app for a Windows Mobile device using AWT and when I used one JVM calling myList.select(myList.getItemCount()-1); was enough to get it to scroll to that item, but as soon as I switched to another JVM it did not do it. So it is implementation dependent but I think there is no requirement in the specification that says that a List field should do this.
My workaround was simply to reverse the List, so that new items were added at the top. Understandably this is not ideal for all situtations, but in my case it was fine.
I use the makeVisible(index) call where index is the index of the item that is selected. This scrolls the listbox down until the selected item is visible. I'm using JDK 1.6.0_65 on Mac OSX 10.8.

Categories