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