1452: Implement a GUI for StatMan Algorithms Importer

Task-Url: https://support.d4science.org/issues/1452

Added DND on tables

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@122493 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2016-01-25 16:02:23 +00:00
parent 6bf37916c9
commit 84e0f110ed
5 changed files with 192 additions and 96 deletions

View File

@ -25,7 +25,12 @@ import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.dnd.core.client.DND.Feedback;
import com.sencha.gxt.dnd.core.client.DndDragStartEvent;
import com.sencha.gxt.dnd.core.client.GridDragSource;
import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
@ -33,11 +38,13 @@ import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent;
import com.sencha.gxt.widget.core.client.event.DialogHideEvent;
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent.BeforeStartEditHandler;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent;
import com.sencha.gxt.widget.core.client.event.CancelEditEvent.CancelEditHandler;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
import com.sencha.gxt.widget.core.client.event.DialogHideEvent.DialogHideHandler;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
@ -69,7 +76,6 @@ public class GlobalVariablesPanel extends ContentPanel {
private int seq = 0;
private ListStore<DataType> storeComboInputType;
private ComboBox<DataType> comboInputType;
interface InputTypeTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
@ -135,7 +141,8 @@ public class GlobalVariablesPanel extends ContentPanel {
l.add(inputTypeColumn);
l.add(defaultValueColumn);
ColumnModel<GlobalVariables> columns = new ColumnModel<GlobalVariables>(l);
ColumnModel<GlobalVariables> columns = new ColumnModel<GlobalVariables>(
l);
storeGlobalVariable = new ListStore<GlobalVariables>(props.id());
@ -149,8 +156,8 @@ public class GlobalVariablesPanel extends ContentPanel {
final GridSelectionModel<GlobalVariables> sm = new GridSelectionModel<GlobalVariables>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridGlobalVariable = new Grid<GlobalVariables>(
storeGlobalVariable, columns);
gridGlobalVariable = new Grid<GlobalVariables>(storeGlobalVariable,
columns);
gridGlobalVariable.setSelectionModel(sm);
gridGlobalVariable.getView().setStripeRows(true);
gridGlobalVariable.getView().setColumnLines(true);
@ -159,21 +166,25 @@ public class GlobalVariablesPanel extends ContentPanel {
gridGlobalVariable.setBorders(false);
gridGlobalVariable.setColumnReordering(false);
/*
* GridDragSource<GlobalVariables> ds = new
* GridDragSource<GlobalVariables>( gridGlobalVariable);
* ds.addDragStartHandler(new DndDragStartHandler() {
*
* @Override public void onDragStart(DndDragStartEvent event) {
*
* @SuppressWarnings("unchecked") ArrayList<GlobalVariables>
* draggingSelection = (ArrayList<GlobalVariables>) event
* .getData(); Log.debug("Start Drag: " + draggingSelection);
*
* } }); GridDropTarget<GlobalVariables> dt = new
* GridDropTarget<GlobalVariables>( gridGlobalVariable);
* dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true);
*/
// DND
GridDragSource<GlobalVariables> ds = new GridDragSource<GlobalVariables>(
gridGlobalVariable);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override
public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked")
ArrayList<GlobalVariables> draggingSelection = (ArrayList<GlobalVariables>) event
.getData();
Log.debug("Start Drag: " + draggingSelection);
}
});
GridDropTarget<GlobalVariables> dt = new GridDropTarget<GlobalVariables>(
gridGlobalVariable);
dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true);
// EDITING //
// Key
@ -191,7 +202,7 @@ public class GlobalVariablesPanel extends ContentPanel {
comboInputType.setTriggerAction(TriggerAction.ALL);
addHandlersForComboInputType(inputTypePropertiesCombo.label());
//
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
@ -202,14 +213,13 @@ public class GlobalVariablesPanel extends ContentPanel {
TextField defaultValueColumnEditing = new TextField();
defaultValueColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridGlobalVariableEditing = new GridRowEditing<GlobalVariables>(
gridGlobalVariable);
gridGlobalVariableEditing.addEditor(nameColumn, nameColumnEditing);
gridGlobalVariableEditing.addEditor(descriptionColumn,
descriptionColumnEditing);
gridGlobalVariableEditing.addEditor(inputTypeColumn,
comboInputType);
gridGlobalVariableEditing.addEditor(inputTypeColumn, comboInputType);
gridGlobalVariableEditing.addEditor(defaultValueColumn,
defaultValueColumnEditing);
@ -227,6 +237,20 @@ public class GlobalVariablesPanel extends ContentPanel {
});
TextButton btnTest = new TextButton("Test");
btnTest.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnTest.setScale(ButtonScale.SMALL);
btnTest.setIconAlign(IconAlign.LEFT);
btnTest.setToolTip("Test");
btnTest.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
testGrid(event);
}
});
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
@ -238,28 +262,28 @@ public class GlobalVariablesPanel extends ContentPanel {
storeGlobalVariable.remove(rowIndex);
storeGlobalVariable.commitChanges();
gridGlobalVariableEditing.getCancelButton().setVisible(
true);
gridGlobalVariableEditing.getCancelButton().setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
List<GlobalVariables> listSelected=storeGlobalVariable.getAll();
List<GlobalVariables> listNewSelected= new ArrayList<GlobalVariables>();
for(int i=0; i<listSelected.size(); i++){
GlobalVariables var=listSelected.get(i);
List<GlobalVariables> listSelected = storeGlobalVariable
.getAll();
List<GlobalVariables> listNewSelected = new ArrayList<GlobalVariables>();
for (int i = 0; i < listSelected.size(); i++) {
GlobalVariables var = listSelected.get(i);
var.setId(i);
listNewSelected.add(var);
}
storeGlobalVariable.clear();
storeGlobalVariable.addAll(listNewSelected);
storeGlobalVariable.commitChanges();
seq=listNewSelected.size();
Log.debug("Current Seq: "+seq);
seq = listNewSelected.size();
Log.debug("Current Seq: " + seq);
}
});
ButtonBar buttonBar = gridGlobalVariableEditing.getButtonBar();
@ -306,8 +330,7 @@ public class GlobalVariablesPanel extends ContentPanel {
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error: "
+ e.getLocalizedMessage());
Log.error("Error: " + e.getLocalizedMessage());
e.printStackTrace();
}
}
@ -321,13 +344,36 @@ public class GlobalVariablesPanel extends ContentPanel {
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridGlobalVariable, new VerticalLayoutData(1, 1,
new Margins(0)));
vlc.add(gridGlobalVariable,
new VerticalLayoutData(1, 1, new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
private void testGrid(SelectEvent event) {
final ConfirmMessageBox mb = new ConfirmMessageBox("Attention", ""
+ getGlobalVariables());
mb.addDialogHideHandler(new DialogHideHandler() {
@Override
public void onDialogHide(DialogHideEvent event) {
switch (event.getHideButton()) {
case NO:
break;
case YES:
break;
default:
break;
}
}
});
mb.setWidth(300);
mb.show();
}
private void editingBeforeStart(BeforeStartEditEvent<GlobalVariables> event) {
// TODO Auto-generated method stub
@ -364,14 +410,15 @@ public class GlobalVariablesPanel extends ContentPanel {
if (project != null && project.getInputData() != null
&& project.getInputData().getListGlobalVariables() != null) {
storeGlobalVariable.clear();
storeGlobalVariable.addAll(project.getInputData().getListGlobalVariables());
storeGlobalVariable.addAll(project.getInputData()
.getListGlobalVariables());
storeGlobalVariable.commitChanges();
seq = project.getInputData().getListGlobalVariables().size();
} else {
storeGlobalVariable.clear();
storeGlobalVariable.commitChanges();
seq=0;
seq = 0;
}
}
@ -386,7 +433,7 @@ public class GlobalVariablesPanel extends ContentPanel {
storeGlobalVariable.commitChanges();
seq = 0;
forceLayout();
}
}

View File

@ -25,6 +25,10 @@ import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.dnd.core.client.DND.Feedback;
import com.sencha.gxt.dnd.core.client.DndDragStartEvent;
import com.sencha.gxt.dnd.core.client.GridDragSource;
import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
@ -195,24 +199,25 @@ public class InputOutputVariablesPanel extends ContentPanel {
gridInputOutputVariables.setBorders(false);
gridInputOutputVariables.setColumnReordering(false);
/*
* GridDragSource<InputOutputVariablesVariables> ds = new
* GridDragSource<InputOutputVariablesVariables>(
* gridEnvironmentVariable); ds.addDragStartHandler(new
* DndDragStartHandler() {
*
* @Override public void onDragStart(DndDragStartEvent event) {
*
* @SuppressWarnings("unchecked")
* ArrayList<InputOutputVariablesVariables> draggingSelection =
* (ArrayList<InputOutputVariablesVariables>) event .getData();
* Log.debug("Start Drag: " + draggingSelection);
*
* } }); GridDropTarget<InputOutputVariablesVariables> dt = new
* GridDropTarget<InputOutputVariablesVariables>(
* gridEnvironmentVariable); dt.setFeedback(Feedback.BOTH);
* dt.setAllowSelfAsSource(true);
*/
// DND
GridDragSource<InputOutputVariables> ds = new GridDragSource<InputOutputVariables>(
gridInputOutputVariables);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override
public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked")
ArrayList<InputOutputVariables> draggingSelection = (ArrayList<InputOutputVariables>) event
.getData();
Log.debug("Start Drag: " + draggingSelection);
}
});
GridDropTarget<InputOutputVariables> dt = new GridDropTarget<InputOutputVariables>(
gridInputOutputVariables);
dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true);
// EDITING //

View File

@ -16,6 +16,10 @@ import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.dnd.core.client.DND.Feedback;
import com.sencha.gxt.dnd.core.client.DndDragStartEvent;
import com.sencha.gxt.dnd.core.client.GridDragSource;
import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
@ -83,7 +87,7 @@ public class InterpreterInfoPanel extends ContentPanel {
}
private void create(Project project) {
// Grid
InterpreterPackageInfoProperties props = GWT
.create(InterpreterPackageInfoProperties.class);
@ -140,18 +144,38 @@ public class InterpreterInfoPanel extends ContentPanel {
gridInterpreterPackageInfo.setBorders(false);
gridInterpreterPackageInfo.setColumnReordering(false);
// DND
GridDragSource<InterpreterPackageInfo> ds = new GridDragSource<InterpreterPackageInfo>(
gridInterpreterPackageInfo);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override
public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked")
ArrayList<InterpreterPackageInfo> draggingSelection = (ArrayList<InterpreterPackageInfo>) event
.getData();
Log.debug("Start Drag: " + draggingSelection);
}
});
GridDropTarget<InterpreterPackageInfo> dt = new GridDropTarget<InterpreterPackageInfo>(
gridInterpreterPackageInfo);
dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true);
// EDITING //
TextField nameColumnEditing=new TextField();
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField versionColumnEditing=new TextField();
TextField versionColumnEditing = new TextField();
versionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridInterpreterPackageInfoEditing = new GridRowEditing<InterpreterPackageInfo>(
gridInterpreterPackageInfo);
gridInterpreterPackageInfoEditing
.addEditor(nameColumn, nameColumnEditing);
gridInterpreterPackageInfoEditing.addEditor(nameColumn,
nameColumnEditing);
gridInterpreterPackageInfoEditing.addEditor(versionColumn,
versionColumnEditing);
@ -364,7 +388,8 @@ public class InterpreterInfoPanel extends ContentPanel {
storeInterpreterPackageInfo.addAll(project.getInputData()
.getInterpreterInfo().getInterpreterPackagesInfo());
storeInterpreterPackageInfo.commitChanges();
seq = project.getInputData().getInterpreterInfo().getInterpreterPackagesInfo().size();
seq = project.getInputData().getInterpreterInfo()
.getInterpreterPackagesInfo().size();
} else {
seq = 0;
}

View File

@ -20,6 +20,10 @@ import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.dnd.core.client.DND.Feedback;
import com.sencha.gxt.dnd.core.client.DndDragStartEvent;
import com.sencha.gxt.dnd.core.client.GridDragSource;
import com.sencha.gxt.dnd.core.client.GridDropTarget;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.button.ButtonBar;
import com.sencha.gxt.widget.core.client.button.TextButton;
@ -106,24 +110,22 @@ public class ProjectInfoPanel extends ContentPanel {
FieldLabel nameLabel = new FieldLabel(algorithmName, "Name");
nameLabel.setLabelWidth(LABAEL_WIDTH);
algorithmDescription = new TextField();
algorithmDescription.setAllowBlank(false);
algorithmDescription.setEmptyText("Enter description...");
algorithmDescription.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
FieldLabel descriptionLabel = new FieldLabel(
algorithmDescription, "Description");
FieldLabel descriptionLabel = new FieldLabel(algorithmDescription,
"Description");
descriptionLabel.setLabelWidth(LABAEL_WIDTH);
// Grid
RequestedVREProperties props = GWT
.create(RequestedVREProperties.class);
RequestedVREProperties props = GWT.create(RequestedVREProperties.class);
ColumnConfig<RequestedVRE, String> nameColumn = new ColumnConfig<RequestedVRE, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<RequestedVRE, String> descriptionColumn = new ColumnConfig<RequestedVRE, String>(
props.description(), 100, "Description");
@ -171,19 +173,39 @@ public class ProjectInfoPanel extends ContentPanel {
gridRequestedVRE.setBorders(false);
gridRequestedVRE.setColumnReordering(false);
// DND
GridDragSource<RequestedVRE> ds = new GridDragSource<RequestedVRE>(
gridRequestedVRE);
ds.addDragStartHandler(new DndDragStartEvent.DndDragStartHandler() {
@Override
public void onDragStart(DndDragStartEvent event) {
@SuppressWarnings("unchecked")
ArrayList<RequestedVRE> draggingSelection = (ArrayList<RequestedVRE>) event
.getData();
Log.debug("Start Drag: " + draggingSelection);
}
});
GridDropTarget<RequestedVRE> dt = new GridDropTarget<RequestedVRE>(
gridRequestedVRE);
dt.setFeedback(Feedback.BOTH);
dt.setAllowSelfAsSource(true);
// EDITING //
TextField nameColumnEditing=new TextField();
TextField nameColumnEditing = new TextField();
nameColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
TextField descriptionColumnEditing=new TextField();
TextField descriptionColumnEditing = new TextField();
descriptionColumnEditing.addValidator(new RegExValidator("^[^\"]*$",
"Attention character \" is not allowed"));
gridRequestedVREEditing = new GridRowEditing<RequestedVRE>(
gridRequestedVRE);
gridRequestedVREEditing.addEditor(nameColumn, nameColumnEditing);
gridRequestedVREEditing.addEditor(descriptionColumn, descriptionColumnEditing);
gridRequestedVREEditing.addEditor(descriptionColumn,
descriptionColumnEditing);
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
@ -251,8 +273,7 @@ public class ProjectInfoPanel extends ContentPanel {
.addCancelEditHandler(new CancelEditHandler<RequestedVRE>() {
@Override
public void onCancelEdit(
CancelEditEvent<RequestedVRE> event) {
public void onCancelEdit(CancelEditEvent<RequestedVRE> event) {
storeRequestedVRE.rejectChanges();
btnAdd.setEnabled(true);
@ -286,7 +307,7 @@ public class ProjectInfoPanel extends ContentPanel {
// /
FieldLabel requestedVRELabel = new FieldLabel(null, "Requested VREs");
requestedVRELabel.setLabelWidth(LABAEL_WIDTH);
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
@ -295,10 +316,9 @@ public class ProjectInfoPanel extends ContentPanel {
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(descriptionLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
vlc.add(requestedVRELabel, new VerticalLayoutData(1, -1,
new Margins(0)));
vlc.add(descriptionLabel, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(requestedVRELabel,
new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridRequestedVRE, new VerticalLayoutData(1, 1, new Margins(0)));
@ -356,8 +376,7 @@ public class ProjectInfoPanel extends ContentPanel {
private void addRequestedVRE(SelectEvent event) {
try {
seq++;
RequestedVRE newRequestedVRE = new RequestedVRE(seq, "",
"");
RequestedVRE newRequestedVRE = new RequestedVRE(seq, "", "");
Log.debug("New RequestedVRE: " + newRequestedVRE);
gridRequestedVREEditing.cancelEditing();
addStatus = true;

View File

@ -25,7 +25,6 @@ import org.gcube.common.homelibrary.home.workspace.exceptions.WrongItemTypeExcep
import org.gcube.common.homelibrary.home.workspace.folder.FolderItem;
import org.gcube.common.homelibrary.home.workspace.folder.items.ExternalFile;
import org.gcube.common.homelibrary.util.zip.ZipUtil;
import org.gcube.contentmanager.storageclient.model.protocol.smp.SMPUrl;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.exception.StatAlgoImporterServiceException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -397,8 +396,7 @@ public class FilesStorage {
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
/**
*
* @param user
@ -406,8 +404,8 @@ public class FilesStorage {
* @return
* @throws StatAlgoImporterServiceException
*/
public boolean existProjectItemOnWorkspace(String user,
String folderId) throws StatAlgoImporterServiceException {
public boolean existProjectItemOnWorkspace(String user, String folderId)
throws StatAlgoImporterServiceException {
Workspace ws;
try {
ws = HomeLibrary.getUserWorkspace(user);
@ -434,7 +432,6 @@ public class FilesStorage {
throw new StatAlgoImporterServiceException(e.getLocalizedMessage());
}
}
/**
*
@ -504,6 +501,9 @@ public class FilesStorage {
try {
org.gcube.common.homelibrary.home.workspace.folder.items.File gcubeItem = ((org.gcube.common.homelibrary.home.workspace.folder.items.File) wi);
is=gcubeItem.getData();
/*
SMPUrl smsHome = new SMPUrl(gcubeItem.getPublicLink());
logger.debug("smsHome: [host:" + smsHome.getHost() + " path:"
@ -512,7 +512,7 @@ public class FilesStorage {
URLConnection uc = null;
uc = (URLConnection) smsHome.openConnection();
is = uc.getInputStream();
*/
} catch (Exception e) {
logger.error("Error retrieving file from storage", e);
e.printStackTrace();