remove usage of vaadin table => grid instead

This commit is contained in:
Nicolas Héron 2018-12-14 11:25:29 +01:00
commit 724d0f8e11

View file

@ -1,6 +1,5 @@
package org.chtijbug.drools.console.view; package org.chtijbug.drools.console.view;
import com.vaadin.data.Container;
import com.vaadin.data.Item; import com.vaadin.data.Item;
import com.vaadin.data.Property; import com.vaadin.data.Property;
import com.vaadin.data.util.BeanItemContainer; import com.vaadin.data.util.BeanItemContainer;
@ -22,7 +21,7 @@ import java.util.List;
public class DeploymentView extends VerticalLayout implements AddLog, View { public class DeploymentView extends VerticalLayout implements AddLog, View {
final private Table table = new Table(); final private Grid gridLogging = new Grid();
final private Button buttonDeployProject = new Button("Deploy project"); final private Button buttonDeployProject = new Button("Deploy project");
final private KieConfigurationData config; final private KieConfigurationData config;
final private BeanItemContainer<ProjectResponse> spaceContainer; final private BeanItemContainer<ProjectResponse> spaceContainer;
@ -97,7 +96,7 @@ public class DeploymentView extends VerticalLayout implements AddLog, View {
buttonDeployProject.addClickListener((Button.ClickListener) event -> { buttonDeployProject.addClickListener((Button.ClickListener) event -> {
// if (containerIdTextField.getValue() != null // if (containerIdTextField.getValue() != null
// && containerIdTextField.getValue().length() > 0) { // && containerIdTextField.getValue().length() > 0) {
table.removeAllItems();
ProjectResponse response = (ProjectResponse) spaceSelection.getValue(); ProjectResponse response = (ProjectResponse) spaceSelection.getValue();
@ -131,19 +130,18 @@ public class DeploymentView extends VerticalLayout implements AddLog, View {
}); });
buttonDeployProject.setEnabled(false); buttonDeployProject.setEnabled(false);
table.setCaption("Logging"); gridLogging.setCaption("Logging");
table.setSizeFull(); gridLogging.setSizeFull();
table.setPageLength(0);
table.setSelectable(false); gridLogging.setColumnReorderingAllowed(false);
table.setColumnCollapsingAllowed(false); gridLogging.setImmediate(true);
table.setColumnReorderingAllowed(false);
table.setImmediate(true);
table.setNullSelectionAllowed(false); IndexedContainer container = new IndexedContainer();
table.setColumnHeaderMode(Table.ColumnHeaderMode.ID);
Container container = new IndexedContainer();
container.addContainerProperty("Message", String.class, "none"); container.addContainerProperty("Message", String.class, "none");
table.setContainerDataSource(container);
this.addComponent(table); gridLogging.setContainerDataSource(container);
this.addComponent(gridLogging);
} }
@ -171,14 +169,14 @@ public class DeploymentView extends VerticalLayout implements AddLog, View {
} }
public void addRow(String textToAdd) { public void addRow(String textToAdd) {
int nbRows = table.getContainerDataSource().getItemIds().size() + 1; int nbRows = gridLogging.getContainerDataSource().getItemIds().size() + 1;
Item item = table.getContainerDataSource().addItem(nbRows); Item item = gridLogging.getContainerDataSource().addItem(nbRows);
if (item != null) { if (item != null) {
Property<String> nameProperty = Property<String> nameProperty =
item.getItemProperty("Message"); item.getItemProperty("Message");
nameProperty.setValue(textToAdd); nameProperty.setValue(textToAdd);
table.setContainerDataSource(table.getContainerDataSource()); gridLogging.setContainerDataSource(gridLogging.getContainerDataSource());
} else { } else {
System.out.println("null"); System.out.println("null");
} }