remove usage of vaadin table => grid instead
This commit is contained in:
parent
e19bb642ca
commit
0c2762bc2c
4 changed files with 63 additions and 83 deletions
|
|
@ -95,6 +95,7 @@
|
|||
<artifactId>vaadin-push</artifactId>
|
||||
<version>7.7.6</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-tomcat</artifactId>
|
||||
|
|
@ -121,16 +122,6 @@
|
|||
<artifactId>jackson-annotations</artifactId>
|
||||
<version>2.9.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.vaadin.addons</groupId>
|
||||
<artifactId>exporter</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.vaadin.addons</groupId>
|
||||
<artifactId>excelimporttable</artifactId>
|
||||
<version>1.1.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.dataformat</groupId>
|
||||
<artifactId>jackson-dataformat-xml</artifactId>
|
||||
|
|
|
|||
|
|
@ -58,9 +58,9 @@ public class DroolsAdminConsoleMainView extends UI {
|
|||
MenuBar.MenuItem submenuAsset = menuBar.addItem("Asset", null);
|
||||
|
||||
|
||||
subMenuDeployment.addItem("Option 2", null);
|
||||
// subMenuDeployment.addItem("Option 2", null);
|
||||
|
||||
submenuAsset.addItem("Option 4", null);
|
||||
//submenuAsset.addItem("Option 4", null);
|
||||
|
||||
subMenuDeployment.addItem("Deploy", (MenuBar.Command) menuItem -> {
|
||||
navigator.navigateTo("Deployment");
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ import com.vaadin.data.Item;
|
|||
import com.vaadin.navigator.View;
|
||||
import com.vaadin.navigator.ViewChangeListener;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Grid;
|
||||
import com.vaadin.ui.HorizontalLayout;
|
||||
import com.vaadin.ui.Table;
|
||||
import com.vaadin.ui.VerticalLayout;
|
||||
import org.chtijbug.drools.console.AddLog;
|
||||
import org.chtijbug.drools.console.service.KieRepositoryService;
|
||||
|
|
@ -18,8 +18,6 @@ import org.chtijbug.guvnor.server.jaxrs.jaxb.Asset;
|
|||
import org.drools.workbench.models.datamodel.rule.InterpolationVariable;
|
||||
import org.drools.workbench.models.guided.template.backend.RuleTemplateModelXMLPersistenceImpl;
|
||||
import org.drools.workbench.models.guided.template.shared.TemplateModel;
|
||||
import org.vaadin.haijian.ExcelExporter;
|
||||
import org.vaadin.winnid.excelimporttable.ExcelImportTable;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.text.ParseException;
|
||||
|
|
@ -36,12 +34,11 @@ public class AssetEditView extends VerticalLayout implements AddLog, View {
|
|||
private XmlMapper mapper = new XmlMapper();
|
||||
private String spaceName;
|
||||
private String projectName;
|
||||
private Table assetTable;
|
||||
private Grid gridAssetTable;
|
||||
private Button startUpdate;
|
||||
private Button commitUpdate;
|
||||
private Button undoUpdate;
|
||||
private ExcelExporter excelExporter;
|
||||
private ExcelImportTable excelImportTable;
|
||||
|
||||
|
||||
public AssetEditView(UserConnected userConnected, String spaceName, String projectName, Asset assetToUpdate) {
|
||||
this.userConnected = userConnected;
|
||||
|
|
@ -63,9 +60,9 @@ public class AssetEditView extends VerticalLayout implements AddLog, View {
|
|||
startUpdate.setEnabled(false);
|
||||
commitUpdate.setEnabled(true);
|
||||
undoUpdate.setEnabled(true);
|
||||
assetTable.setEditable(true);
|
||||
excelExporter.setEnabled(false);
|
||||
excelImportTable.setEnabled(false);
|
||||
gridAssetTable.setEditorEnabled(true);
|
||||
gridAssetTable.setReadOnly(false);
|
||||
|
||||
});
|
||||
commitUpdate = new Button("Commit");
|
||||
commitUpdate.setEnabled(false);
|
||||
|
|
@ -73,9 +70,11 @@ public class AssetEditView extends VerticalLayout implements AddLog, View {
|
|||
startUpdate.setEnabled(true);
|
||||
commitUpdate.setEnabled(false);
|
||||
undoUpdate.setEnabled(false);
|
||||
assetTable.setEditable(false);
|
||||
excelExporter.setEnabled(true);
|
||||
excelImportTable.setEnabled(false);
|
||||
gridAssetTable.cancelEditor();
|
||||
gridAssetTable.setEditorEnabled(false);
|
||||
gridAssetTable.setReadOnly(true);
|
||||
|
||||
|
||||
});
|
||||
actionButtons.addComponent(commitUpdate);
|
||||
undoUpdate = new Button("undo");
|
||||
|
|
@ -84,54 +83,59 @@ public class AssetEditView extends VerticalLayout implements AddLog, View {
|
|||
startUpdate.setEnabled(true);
|
||||
commitUpdate.setEnabled(false);
|
||||
undoUpdate.setEnabled(false);
|
||||
assetTable.setEditable(false);
|
||||
gridAssetTable.cancelEditor();
|
||||
gridAssetTable.setEditorEnabled(false);
|
||||
gridAssetTable.cancelEditor();
|
||||
gridAssetTable.setReadOnly(true);
|
||||
fillTable(model);
|
||||
excelExporter.setEnabled(true);
|
||||
excelImportTable.setEnabled(false);
|
||||
|
||||
});
|
||||
actionButtons.addComponent(undoUpdate);
|
||||
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
|
||||
assetTable = new Table("Data");
|
||||
this.addComponent(assetTable);
|
||||
assetTable.setSelectable(true);
|
||||
assetTable.setMultiSelect(false);
|
||||
gridAssetTable = new Grid("Data");
|
||||
this.addComponent(gridAssetTable);
|
||||
gridAssetTable.setEditorEnabled(false);
|
||||
gridAssetTable.setSelectionMode(Grid.SelectionMode.SINGLE);
|
||||
gridAssetTable.setReadOnly(true);
|
||||
for (InterpolationVariable i : variablesList) {
|
||||
if (i.getDataType().equals("String")) {
|
||||
assetTable.addContainerProperty(i.getVarName(), String.class, null);
|
||||
gridAssetTable.addColumn(i.getVarName(), String.class);
|
||||
} else if (i.getDataType().equals("Date")) {
|
||||
assetTable.addContainerProperty(i.getVarName(), Date.class, null);
|
||||
gridAssetTable.addColumn(i.getVarName(), Date.class);
|
||||
} else {
|
||||
assetTable.addContainerProperty(i.getVarName(), String.class, null);
|
||||
gridAssetTable.addColumn(i.getVarName(), String.class);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fillTable(model);
|
||||
|
||||
assetTable.setSizeFull();
|
||||
|
||||
gridAssetTable.setSizeFull();
|
||||
/**
|
||||
excelExporter = new ExcelExporter();
|
||||
excelExporter.setDateFormat("dd-MM-yyyy");
|
||||
excelExporter.setLocale(Locale.FRANCE);
|
||||
excelExporter.setTableToBeExported(assetTable);
|
||||
excelExporter.setTableToBeExported(gridAssetTable);
|
||||
excelExporter.setCaption("Export to Excel");
|
||||
actionButtons.addComponent(excelExporter);
|
||||
excelExporter.setEnabled(true);
|
||||
|
||||
excelImportTable = new ExcelImportTable(assetTable);
|
||||
excelImportTable = new ExcelImportTable(gridAssetTable);
|
||||
excelImportTable.setLocale(Locale.FRANCE);
|
||||
actionButtons.addComponent(excelImportTable);
|
||||
**/
|
||||
}
|
||||
|
||||
private void fillTable(TemplateModel model) {
|
||||
InterpolationVariable[] variablesList = model.getInterpolationVariablesList();
|
||||
DateFormat format = new SimpleDateFormat("dd-MMM-yyyy", Locale.FRANCE);
|
||||
String[][] contenuTable = model.getTableAsArray();
|
||||
Container dataSource = assetTable.getContainerDataSource();
|
||||
Container dataSource = gridAssetTable.getContainerDataSource();
|
||||
dataSource.removeAllItems();
|
||||
for (int i = 0; i < model.getRowsCount(); i++) {
|
||||
String[] ligne = contenuTable[i];
|
||||
Object newItemId = assetTable.addItem();
|
||||
Item row1 = assetTable.getItem(newItemId);
|
||||
Object item = dataSource.addItem();
|
||||
Item row1 = dataSource.getItem(item);
|
||||
int k = 0;
|
||||
for (InterpolationVariable j : variablesList) {
|
||||
if (j.getDataType().equals("String")) {
|
||||
|
|
|
|||
|
|
@ -2,11 +2,8 @@ package org.chtijbug.drools.console.view;
|
|||
|
||||
import com.vaadin.data.Property;
|
||||
import com.vaadin.data.util.BeanItemContainer;
|
||||
import com.vaadin.event.Action;
|
||||
import com.vaadin.event.ItemClickEvent;
|
||||
import com.vaadin.navigator.View;
|
||||
import com.vaadin.navigator.ViewChangeListener;
|
||||
import com.vaadin.shared.ui.MultiSelectMode;
|
||||
import com.vaadin.ui.*;
|
||||
import com.vaadin.ui.themes.Runo;
|
||||
import org.chtijbug.drools.console.AddLog;
|
||||
|
|
@ -36,7 +33,14 @@ public class TableLikeArtefactView extends VerticalLayout implements AddLog, Vie
|
|||
|
||||
final private BeanItemContainer<Asset> assetBeanItemContainer = new BeanItemContainer<>(Asset.class);
|
||||
|
||||
private Table assetTable;
|
||||
private Grid assetListGrid;
|
||||
|
||||
|
||||
private Button deleteRow;
|
||||
|
||||
private Button editRow;
|
||||
|
||||
private Button duplicateRow;
|
||||
|
||||
public TableLikeArtefactView(UserConnected userConnected) {
|
||||
|
||||
|
|
@ -81,6 +85,14 @@ public class TableLikeArtefactView extends VerticalLayout implements AddLog, Vie
|
|||
}
|
||||
});
|
||||
this.addComponent(spaceSelection);
|
||||
HorizontalLayout actionButtons = new HorizontalLayout();
|
||||
this.addComponent(actionButtons);
|
||||
duplicateRow = new Button("Duplicate");
|
||||
actionButtons.addComponent(duplicateRow);
|
||||
editRow = new Button("Edit");
|
||||
actionButtons.addComponent(editRow);
|
||||
deleteRow = new Button("Delete");
|
||||
actionButtons.addComponent(deleteRow);
|
||||
assetBeanItemContainer.removeContainerProperty("author");
|
||||
assetBeanItemContainer.removeContainerProperty("binaryLink");
|
||||
assetBeanItemContainer.removeContainerProperty("sourceLink");
|
||||
|
|
@ -94,45 +106,18 @@ public class TableLikeArtefactView extends VerticalLayout implements AddLog, Vie
|
|||
assetBeanItemContainer.removeContainerProperty("metadata");
|
||||
|
||||
|
||||
assetTable = new Table("List of assets", assetBeanItemContainer);
|
||||
assetTable.setSelectable(true);
|
||||
assetTable.setSizeFull();
|
||||
assetTable.setMultiSelectMode(MultiSelectMode.SIMPLE);
|
||||
assetTable.addItemClickListener(new ItemClickEvent.ItemClickListener() {
|
||||
@Override
|
||||
public void itemClick(ItemClickEvent itemClickEvent) {
|
||||
if (itemClickEvent.isCtrlKey()) {
|
||||
Asset selected = (Asset) itemClickEvent.getItemId();
|
||||
System.out.println(itemClickEvent.getItemId().toString());
|
||||
}
|
||||
assetListGrid = new Grid("List of assets", assetBeanItemContainer);
|
||||
assetListGrid.setSelectionMode(Grid.SelectionMode.SINGLE);
|
||||
assetListGrid.setSizeFull();
|
||||
|
||||
}
|
||||
});
|
||||
this.addComponent(assetTable);
|
||||
final Action actionDuplicate = new Action("Duplicate");
|
||||
final Action actionEdit = new Action("Edit");
|
||||
final Action actionDelete = new Action("Delete");
|
||||
assetTable.addActionHandler(new Action.Handler() {
|
||||
|
||||
public void handleAction(Action action, Object sender,
|
||||
Object target) {
|
||||
if (action.equals(actionDuplicate)) {
|
||||
Notification.show("Duplicate not yet implemented");
|
||||
} else if (action.equals(actionEdit)) {
|
||||
Notification.show("Edit/modification not yet implemented");
|
||||
Asset selected = (Asset) target;
|
||||
this.addComponent(assetListGrid);
|
||||
editRow.addClickListener(clickEvent -> {
|
||||
Asset selected = (Asset) assetListGrid.getSelectedRow();
|
||||
if (selected != null) {
|
||||
ProjectResponse response = (ProjectResponse) spaceSelection.getValue();
|
||||
AssetEditView assetEditView = new AssetEditView(userConnected, response.getSpaceName(), response.getName(), selected);
|
||||
UI.getCurrent().getNavigator().addView("Asset-" + selected.getTitle(), assetEditView);
|
||||
UI.getCurrent().getNavigator().navigateTo("Asset-" + selected.getTitle());
|
||||
} else if (action.equals(actionDelete)) {
|
||||
Notification.show("Delete not yet implemented");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Action[] getActions(Object target, Object sender) {
|
||||
return new Action[]{actionDuplicate, actionEdit, actionDelete};
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
editor.link_modal.header
Reference in a new issue