Fixed Package with name empty

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@153012 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2017-09-12 16:37:54 +00:00
parent c01c13c2aa
commit 41f39ad8be
1 changed files with 66 additions and 108 deletions

View File

@ -89,8 +89,7 @@ public class InterpreterInfoPanel extends ContentPanel {
private void create(Project project) {
// Grid
InterpreterPackageInfoProperties props = GWT
.create(InterpreterPackageInfoProperties.class);
InterpreterPackageInfoProperties props = GWT.create(InterpreterPackageInfoProperties.class);
ColumnConfig<InterpreterPackageInfo, String> nameColumn = new ColumnConfig<InterpreterPackageInfo, String>(
props.name(), 100, "Name");
@ -104,11 +103,9 @@ public class InterpreterInfoPanel extends ContentPanel {
l.add(nameColumn);
l.add(detailsColumn);
ColumnModel<InterpreterPackageInfo> columns = new ColumnModel<InterpreterPackageInfo>(
l);
ColumnModel<InterpreterPackageInfo> columns = new ColumnModel<InterpreterPackageInfo>(l);
storeInterpreterPackageInfo = new ListStore<InterpreterPackageInfo>(
props.id());
storeInterpreterPackageInfo = new ListStore<InterpreterPackageInfo>(props.id());
/*
* ArrayList<InterpreterPackageInfo> list = new ArrayList<>(); for (int
@ -118,15 +115,11 @@ public class InterpreterInfoPanel extends ContentPanel {
* storeEnvironmentVariable.addAll(list);
*/
if (project != null
&& project.getInputData() != null
&& project.getInputData().getInterpreterInfo() != null
&& project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo() != null) {
storeInterpreterPackageInfo.addAll(project.getInputData()
.getInterpreterInfo().getInterpreterPackagesInfo());
seq = project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size();
if (project != null && project.getInputData() != null && project.getInputData().getInterpreterInfo() != null
&& project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo() != null) {
storeInterpreterPackageInfo
.addAll(project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo());
seq = project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size();
} else {
seq = 0;
}
@ -134,8 +127,7 @@ public class InterpreterInfoPanel extends ContentPanel {
final GridSelectionModel<InterpreterPackageInfo> sm = new GridSelectionModel<InterpreterPackageInfo>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridInterpreterPackageInfo = new Grid<InterpreterPackageInfo>(
storeInterpreterPackageInfo, columns);
gridInterpreterPackageInfo = new Grid<InterpreterPackageInfo>(storeInterpreterPackageInfo, columns);
gridInterpreterPackageInfo.setSelectionModel(sm);
gridInterpreterPackageInfo.getView().setStripeRows(true);
gridInterpreterPackageInfo.getView().setColumnLines(true);
@ -166,18 +158,14 @@ public class InterpreterInfoPanel extends ContentPanel {
// EDITING //
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
nameColumnEditing.setAllowBlank(false);
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
TextField versionColumnEditing = new TextField();
versionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
versionColumnEditing.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
gridInterpreterPackageInfoEditing = new GridRowEditing<InterpreterPackageInfo>(
gridInterpreterPackageInfo);
gridInterpreterPackageInfoEditing.addEditor(nameColumn,
nameColumnEditing);
gridInterpreterPackageInfoEditing.addEditor(detailsColumn,
versionColumnEditing);
gridInterpreterPackageInfoEditing = new GridRowEditing<InterpreterPackageInfo>(gridInterpreterPackageInfo);
gridInterpreterPackageInfoEditing.addEditor(nameColumn, nameColumnEditing);
gridInterpreterPackageInfoEditing.addEditor(detailsColumn, versionColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
@ -195,8 +183,7 @@ public class InterpreterInfoPanel extends ContentPanel {
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
GridCell cell = gridInterpreterPackageInfoEditing
.getActiveCell();
GridCell cell = gridInterpreterPackageInfoEditing.getActiveCell();
int rowIndex = cell.getRow();
gridInterpreterPackageInfoEditing.cancelEditing();
@ -204,15 +191,13 @@ public class InterpreterInfoPanel extends ContentPanel {
storeInterpreterPackageInfo.remove(rowIndex);
storeInterpreterPackageInfo.commitChanges();
gridInterpreterPackageInfoEditing.getCancelButton().setVisible(
true);
gridInterpreterPackageInfoEditing.getCancelButton().setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
List<InterpreterPackageInfo> listPackages = storeInterpreterPackageInfo
.getAll();
List<InterpreterPackageInfo> listPackages = storeInterpreterPackageInfo.getAll();
List<InterpreterPackageInfo> listNewPackages = new ArrayList<InterpreterPackageInfo>();
for (int i = 0; i < listPackages.size(); i++) {
InterpreterPackageInfo var = listPackages.get(i);
@ -236,68 +221,55 @@ public class InterpreterInfoPanel extends ContentPanel {
.addBeforeStartEditHandler(new BeforeStartEditHandler<InterpreterPackageInfo>() {
@Override
public void onBeforeStartEdit(
BeforeStartEditEvent<InterpreterPackageInfo> event) {
public void onBeforeStartEdit(BeforeStartEditEvent<InterpreterPackageInfo> event) {
editingBeforeStart(event);
}
});
gridInterpreterPackageInfoEditing
.addCancelEditHandler(new CancelEditHandler<InterpreterPackageInfo>() {
gridInterpreterPackageInfoEditing.addCancelEditHandler(new CancelEditHandler<InterpreterPackageInfo>() {
@Override
public void onCancelEdit(
CancelEditEvent<InterpreterPackageInfo> event) {
storeInterpreterPackageInfo.rejectChanges();
btnAdd.setEnabled(true);
@Override
public void onCancelEdit(CancelEditEvent<InterpreterPackageInfo> event) {
storeInterpreterPackageInfo.rejectChanges();
btnAdd.setEnabled(true);
}
});
gridInterpreterPackageInfoEditing.addCompleteEditHandler(new CompleteEditHandler<InterpreterPackageInfo>() {
@Override
public void onCompleteEdit(CompleteEditEvent<InterpreterPackageInfo> event) {
try {
if (addStatus) {
addStatus = false;
}
storeInterpreterPackageInfo.commitChanges();
});
gridInterpreterPackageInfoEditing.getCancelButton().setVisible(true);
btnAdd.setEnabled(true);
gridInterpreterPackageInfoEditing
.addCompleteEditHandler(new CompleteEditHandler<InterpreterPackageInfo>() {
@Override
public void onCompleteEdit(
CompleteEditEvent<InterpreterPackageInfo> event) {
try {
if (addStatus) {
addStatus = false;
}
storeInterpreterPackageInfo.commitChanges();
gridInterpreterPackageInfoEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
});
} catch (Throwable e) {
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
});
interpreterVersion = new TextField();
interpreterVersion.setAllowBlank(false);
interpreterVersion.setEmptyText("Enter version...");
interpreterVersion.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
FieldLabel interpreterVersionLabel = new FieldLabel(interpreterVersion,
"Version");
interpreterVersion.addValidator(new RegExValidator("^[^\"]*$", "Attention character \" is not allowed"));
FieldLabel interpreterVersionLabel = new FieldLabel(interpreterVersion, "Version");
if (project != null
&& project.getInputData() != null
&& project.getInputData().getInterpreterInfo() != null
if (project != null && project.getInputData() != null && project.getInputData().getInterpreterInfo() != null
&& project.getInputData().getInterpreterInfo().getVersion() != null) {
interpreterVersion.setValue(project.getInputData()
.getInterpreterInfo().getVersion());
interpreterVersion.setValue(project.getInputData().getInterpreterInfo().getVersion());
}
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
@ -307,28 +279,23 @@ public class InterpreterInfoPanel extends ContentPanel {
vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(interpreterVersionLabel, new VerticalLayoutData(1, -1,
new Margins(5, 0, 5, 0)));
vlc.add(interpreterVersionLabel, new VerticalLayoutData(1, -1, new Margins(5, 0, 5, 0)));
vlc.add(interpreterPackagesLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
vlc.add(interpreterPackagesLabel, new VerticalLayoutData(1, -1, new Margins(0)));
//vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridInterpreterPackageInfo, new VerticalLayoutData(1, 1,
new Margins(0)));
// vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridInterpreterPackageInfo, new VerticalLayoutData(1, 1, new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
private void editingBeforeStart(
BeforeStartEditEvent<InterpreterPackageInfo> event) {
private void editingBeforeStart(BeforeStartEditEvent<InterpreterPackageInfo> event) {
// TODO Auto-generated method stub
}
public void addNewInterpreterPackageInfo(
InterpreterPackageInfo interpreterPackageInfo) {
public void addNewInterpreterPackageInfo(InterpreterPackageInfo interpreterPackageInfo) {
try {
Log.debug("Current Seq: " + seq);
seq++;
@ -351,20 +318,15 @@ public class InterpreterInfoPanel extends ContentPanel {
try {
Log.debug("Current Seq: " + seq);
seq++;
InterpreterPackageInfo newInterpreterPackageInfo = new InterpreterPackageInfo(
seq, "", "", "");
Log.debug("New Interpreter Package Info: "
+ newInterpreterPackageInfo);
InterpreterPackageInfo newInterpreterPackageInfo = new InterpreterPackageInfo(seq, "", "", "");
Log.debug("New Interpreter Package Info: " + newInterpreterPackageInfo);
gridInterpreterPackageInfoEditing.cancelEditing();
addStatus = true;
gridInterpreterPackageInfoEditing.getCancelButton().setVisible(
false);
gridInterpreterPackageInfoEditing.getCancelButton().setVisible(false);
storeInterpreterPackageInfo.add(newInterpreterPackageInfo);
int row = storeInterpreterPackageInfo
.indexOf(newInterpreterPackageInfo);
int row = storeInterpreterPackageInfo.indexOf(newInterpreterPackageInfo);
gridInterpreterPackageInfoEditing
.startEditing(new GridCell(row, 0));
gridInterpreterPackageInfoEditing.startEditing(new GridCell(row, 0));
} catch (Throwable e) {
e.printStackTrace();
}
@ -372,26 +334,22 @@ public class InterpreterInfoPanel extends ContentPanel {
public void update(Project project) {
Log.debug("Update Interpreter Package Info: " + project);
if (project != null && project.getInputData() != null
&& project.getInputData().getInterpreterInfo() != null) {
if (project != null && project.getInputData() != null && project.getInputData().getInterpreterInfo() != null) {
if (project.getInputData().getInterpreterInfo().getVersion() != null) {
interpreterVersion.setValue(project.getInputData()
.getInterpreterInfo().getVersion());
interpreterVersion.setValue(project.getInputData().getInterpreterInfo().getVersion());
} else {
interpreterVersion.clear();
}
if (project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo() != null) {
if (project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo() != null) {
storeInterpreterPackageInfo.clear();
storeInterpreterPackageInfo.addAll(project.getInputData()
.getInterpreterInfo().getInterpreterPackagesInfo());
storeInterpreterPackageInfo
.addAll(project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo());
storeInterpreterPackageInfo.commitChanges();
seq = project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size();
seq = project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size();
} else {
storeInterpreterPackageInfo.clear();
storeInterpreterPackageInfo.commitChanges();