1452: Implement a GUI for StatMan Algorithms Importer

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

Updated GUI

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/statistical-algorithms-importer@120542 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-12-01 17:35:46 +00:00
parent 65b1c0f9aa
commit 8dc3149234
34 changed files with 918 additions and 59 deletions

View File

@ -30,7 +30,7 @@ public class StatAlgoImporter implements EntryPoint {
private static final String JSP_TAG_ID = "StatAlgoImporterPortlet";
private static final int RIBBON_HEIGHT = 120;
private static final int RIBBON_HEIGHT = 110;
@SuppressWarnings("unused")
private final StatAlgoImporterServiceAsync statAlgoImporterService = GWT
@ -72,6 +72,7 @@ public class StatAlgoImporter implements EntryPoint {
mainPanelLayout.setId("mainPanelLayout");
mainPanelLayout.setBorders(false);
mainPanelLayout.setResize(true);
// mainPanelLayout.getElement().getStyle().setBackgroundColor("rgb(3, 126, 207)");
// Main
@ -93,19 +94,22 @@ public class StatAlgoImporter implements EntryPoint {
// Right
ToolsPanel toolsPanel = new ToolsPanel(eventBus);
BorderLayoutData eastData = new BorderLayoutData(310);
eastData.setCollapsible(false);
BorderLayoutData eastData = new BorderLayoutData(400);
eastData.setCollapsible(true);
eastData.setSplit(false);
eastData.setFloatable(false);
eastData.setCollapseMini(false);
eastData.setMargins(new Margins(2, 7, 2, 7));
eastData.setCollapseHidden(true);
eastData.setCollapseMini(true);
eastData.setMargins(new Margins(0, 5, 0, 5));
eastData.setCollapseHidden(false);
// estData.setMaxSize(510);
// estData.setMinSize(310);
mainPanelLayout.setEastWidget(toolsPanel, eastData);
// codeUploadPanel.expand();
toolsPanel.enable();
bind(mainPanelLayout);
controller.setMainPanelLayout(mainPanelLayout);
controller.restoreUISession();

View File

@ -84,7 +84,7 @@ public class CodeEditPanel extends ContentPanel {
Log.debug("loaded " + result.size() + " code lines");
String text = new String();
for (CodeData codeData : result) {
Log.debug("Read: " + codeData);
//Log.debug("Read: " + codeData);
text+=codeData.getCodeLine()+"\r\n";
}

View File

@ -0,0 +1,28 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputType;
import com.sencha.gxt.core.client.ValueProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface EnvironmentVariablesProperties extends
PropertyAccess<EnvironmentVariables> {
ModelKeyProvider<EnvironmentVariables> id();
ValueProvider<EnvironmentVariables, String> name();
ValueProvider<EnvironmentVariables, String> description();
ValueProvider<EnvironmentVariables, InputType> inputType();
ValueProvider<EnvironmentVariables, String> defaultValue();
}

View File

@ -0,0 +1,24 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputType;
import com.google.gwt.editor.client.Editor.Path;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ModelKeyProvider;
import com.sencha.gxt.data.shared.PropertyAccess;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface InputTypePropertiesCombo extends PropertyAccess<InputType> {
@Path("id")
ModelKeyProvider<InputType> id();
LabelProvider<InputType> label();
}

View File

@ -24,12 +24,18 @@ public interface StatAlgoImporterResources extends ClientBundle {
@Source("help_32.png")
ImageResource help32();
@Source("help_24.png")
ImageResource help24();
@Source("download_32.png")
ImageResource download32();
@Source("upload_32.png")
ImageResource upload32();
@Source("upload_24.png")
ImageResource upload24();
@Source("job_32.png")
ImageResource job32();
@ -48,12 +54,38 @@ public interface StatAlgoImporterResources extends ClientBundle {
@Source("cancel_32.png")
ImageResource cancel32();
@Source("cancel_24.png")
ImageResource cancel24();
@Source("algorithm_32.png")
ImageResource algorithm32();
@Source("algorithm_24.png")
ImageResource algorithm24();
@Source("project-create_32.png")
ImageResource projectCreate32();
@Source("project-create_24.png")
ImageResource projectCreate24();
@Source("project-open_32.png")
ImageResource projectOpen32();
@Source("project-open_24.png")
ImageResource projectOpen24();
@Source("add_24.png")
ImageResource add24();
@Source("add_16.png")
ImageResource add16();
@Source("delete_24.png")
ImageResource delete24();
@Source("delete_16.png")
ImageResource delete16();
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B

View File

@ -33,7 +33,7 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
*
*/
public class HomeToolBar {
private static final String GROUP_HEIGHT = "80px";
private static final String GROUP_HEIGHT = "72px";
private HomeToolBarMessages msgs;
private EventBus eventBus;
private ToolBar toolBar;
@ -87,9 +87,9 @@ public class HomeToolBar {
projectGroup.add(homeLayout);
btnCreateProject = new TextButton(msgs.btnCreateProject(),
StatAlgoImporterResources.INSTANCE.projectCreate32());
StatAlgoImporterResources.INSTANCE.projectCreate24());
btnCreateProject.setId("btnCreateProject");
btnCreateProject.setScale(ButtonScale.MEDIUM);
btnCreateProject.setScale(ButtonScale.SMALL);
btnCreateProject.setIconAlign(IconAlign.LEFT);
btnCreateProject.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnCreateProject.setToolTip(msgs.btnCreateProjectToolTip());
@ -106,9 +106,9 @@ public class HomeToolBar {
homeLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
btnOpenProject = new TextButton(msgs.btnOpenProject(),
StatAlgoImporterResources.INSTANCE.projectOpen32());
StatAlgoImporterResources.INSTANCE.projectOpen24());
btnOpenProject.setId("btnOpenProject");
btnOpenProject.setScale(ButtonScale.MEDIUM);
btnOpenProject.setScale(ButtonScale.SMALL);
btnOpenProject.setIconAlign(IconAlign.LEFT);
btnOpenProject.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnOpenProject.setToolTip(msgs.btnOpenProjectToolTip());
@ -136,9 +136,9 @@ public class HomeToolBar {
algorithmGroup.add(algorithmLayout);
btnImportAlgorithm = new TextButton(msgs.importButton(),
StatAlgoImporterResources.INSTANCE.upload32());
StatAlgoImporterResources.INSTANCE.upload24());
btnImportAlgorithm.setId("importButton");
btnImportAlgorithm.setScale(ButtonScale.MEDIUM);
btnImportAlgorithm.setScale(ButtonScale.SMALL);
btnImportAlgorithm.setIconAlign(IconAlign.LEFT);
btnImportAlgorithm.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnImportAlgorithm.setToolTip(msgs.importButtonToolTip());
@ -156,9 +156,9 @@ public class HomeToolBar {
btnCreateAlgorithm = new TextButton(msgs.createAlgorithmButton(),
StatAlgoImporterResources.INSTANCE.algorithm32());
StatAlgoImporterResources.INSTANCE.algorithm24());
btnCreateAlgorithm.setId("createAlgorithmButton");
btnCreateAlgorithm.setScale(ButtonScale.MEDIUM);
btnCreateAlgorithm.setScale(ButtonScale.SMALL);
btnCreateAlgorithm.setIconAlign(IconAlign.LEFT);
btnCreateAlgorithm.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnCreateAlgorithm.setToolTip(msgs.createAlgorithmButtonToolTip());
@ -198,10 +198,10 @@ public class HomeToolBar {
*/
btnHelp = new TextButton(msgs.helpButton(),
StatAlgoImporterResources.INSTANCE.help32());
StatAlgoImporterResources.INSTANCE.help24());
btnHelp.enable();
btnHelp.setToolTip(msgs.helpButtonToolTip());
btnHelp.setScale(ButtonScale.MEDIUM);
btnHelp.setScale(ButtonScale.SMALL);
btnHelp.setIconAlign(IconAlign.LEFT);
btnHelp.setArrowAlign(ButtonArrowAlign.BOTTOM);
btnHelp.addSelectHandler(new SelectHandler() {

View File

@ -19,7 +19,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
*/
public class StatAlgoImporterRibbon {
private static final String RIBBON_HEIGHT = "90px";
private static final String RIBBON_HEIGHT = "76px";
private TabPanel ribbon;

View File

@ -6,8 +6,8 @@ import org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input.
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.event.shared.EventBus;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.widget.core.client.ContentPanel;
import com.sencha.gxt.widget.core.client.container.MarginData;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
@ -17,7 +17,7 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class ToolsPanel extends SimpleContainer {
public class ToolsPanel extends ContentPanel {
private EventBus eventBus;
private InputVariablePanel inputVariablePanel;
@ -34,9 +34,12 @@ public class ToolsPanel extends SimpleContainer {
protected void init() {
forceLayoutOnResize = true;
// setBodyBorder(false);
setHeaderVisible(false);
setResize(true);
setBodyBorder(false);
setBorders(false);
// setHeaderVisible(false);
setHideCollapseTool(true);
}
@ -71,8 +74,8 @@ public class ToolsPanel extends SimpleContainer {
inputVariablePanel = new InputVariablePanel(eventBus);
explorerProjectPanel = new ExplorerProjectPanel(eventBus);
v.add(inputVariablePanel, new VerticalLayoutData(1, -1, new Margins(0)));
v.add(explorerProjectPanel, new VerticalLayoutData(1, -1,
//v.add(inputVariablePanel, new VerticalLayoutData(1, 1, new Margins(0)));
v.add(inputVariablePanel, new VerticalLayoutData(1, 1,
new Margins(0)));
add(v, new MarginData(new Margins(0)));
forceLayout();

View File

@ -1,19 +1,76 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
import java.util.ArrayList;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.EnvironmentVariablesProperties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.InputTypePropertiesCombo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.dom.client.Style.Unit;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.cell.core.client.ButtonCell.ButtonScale;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates;
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.widget.core.client.ContentPanel;
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;
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.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.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class EnvironmentVariablesPanel extends ContentPanel {
private EventBus eventBus;
private ListStore<EnvironmentVariables> storeEnvironmentVariable;
private Grid<EnvironmentVariables> gridEnvironmentVariable;
private ListStore<InputType> storeComboInputType;
private ComboBox<InputType> comboInputType;
private GridRowEditing<EnvironmentVariables> gridEnvironmentVariableEditing;
private TextButton btnAdd;
private boolean addStatus;
private int seq = 0;
interface InputTypeTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
SafeHtml format(String value);
}
public EnvironmentVariablesPanel(EventBus eventBus) {
super();
@ -21,26 +78,263 @@ public class EnvironmentVariablesPanel extends ContentPanel {
this.eventBus = eventBus;
// msgs = GWT.create(ServiceCategoryMessages.class);
init();
create();
try {
init();
create();
} catch (Throwable e) {
e.printStackTrace();
}
}
private void init() {
forceLayoutOnResize = true;
setBodyBorder(false);
setBorders(false);
setHeaderVisible(false);
setResize(true);
setBodyBorder(false);
setBorders(false);
forceLayoutOnResize = true;
}
private void create() {
// Grid
EnvironmentVariablesProperties props = GWT
.create(EnvironmentVariablesProperties.class);
ColumnConfig<EnvironmentVariables, String> nameColumn = new ColumnConfig<EnvironmentVariables, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, String> descriptionColumn = new ColumnConfig<EnvironmentVariables, String>(
props.name(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, InputType> inputTypeColumn = new ColumnConfig<EnvironmentVariables, InputType>(
props.inputType(), 100, "Type");
// inputTypeColumn.setMenuDisabled(true);
inputTypeColumn.setCell(new AbstractCell<InputType>() {
@Override
public void render(Context context, InputType inputType,
SafeHtmlBuilder sb) {
InputTypeTemplates inputTypeTemplates = GWT
.create(InputTypeTemplates.class);
sb.append(inputTypeTemplates.format(inputType.getLabel()));
}
});
ColumnConfig<EnvironmentVariables, String> defaultValueColumn = new ColumnConfig<EnvironmentVariables, String>(
props.defaultValue(), 100, "Default");
// defaColumn.setMenuDisabled(true);
ArrayList<ColumnConfig<EnvironmentVariables, ?>> l = new ArrayList<ColumnConfig<EnvironmentVariables, ?>>();
l.add(nameColumn);
l.add(descriptionColumn);
l.add(inputTypeColumn);
l.add(defaultValueColumn);
ColumnModel<EnvironmentVariables> columns = new ColumnModel<EnvironmentVariables>(
l);
storeEnvironmentVariable = new ListStore<EnvironmentVariables>(
props.id());
/*ArrayList<EnvironmentVariables> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(new EnvironmentVariables(i, "Test" + i, "Desc",
"defaultValue", InputType.STRING));
}
storeEnvironmentVariable.addAll(list);*/
final GridSelectionModel<EnvironmentVariables> sm = new GridSelectionModel<EnvironmentVariables>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridEnvironmentVariable = new Grid<EnvironmentVariables>(
storeEnvironmentVariable, columns);
gridEnvironmentVariable.setSelectionModel(sm);
gridEnvironmentVariable.getView().setStripeRows(true);
gridEnvironmentVariable.getView().setColumnLines(true);
gridEnvironmentVariable.getView().setAutoExpandColumn(nameColumn);
gridEnvironmentVariable.getView().setAutoFill(true);
gridEnvironmentVariable.setBorders(false);
gridEnvironmentVariable.setColumnReordering(false);
/*
* GridDragSource<EnvironmentVariables> ds = new
* GridDragSource<EnvironmentVariables>( gridEnvironmentVariable);
* ds.addDragStartHandler(new DndDragStartHandler() {
*
* @Override public void onDragStart(DndDragStartEvent event) {
*
* @SuppressWarnings("unchecked") ArrayList<EnvironmentVariables>
* draggingSelection = (ArrayList<EnvironmentVariables>) event
* .getData(); Log.debug("Start Drag: " + draggingSelection);
*
* } }); GridDropTarget<EnvironmentVariables> dt = new
* GridDropTarget<EnvironmentVariables>( gridEnvironmentVariable);
* dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true);
*/
// EDITING //
// Key
InputTypePropertiesCombo inputTypePropertiesCombo = GWT
.create(InputTypePropertiesCombo.class);
storeComboInputType = new ListStore<InputType>(
inputTypePropertiesCombo.id());
comboInputType = new ComboBox<InputType>(storeComboInputType,
inputTypePropertiesCombo.label());
comboInputType.setClearValueOnParseError(false);
comboInputType.setEditable(false);
comboInputType.setTriggerAction(TriggerAction.ALL);
addHandlersForComboInputType(inputTypePropertiesCombo.label());
gridEnvironmentVariableEditing = new GridRowEditing<EnvironmentVariables>(
gridEnvironmentVariable);
gridEnvironmentVariableEditing.addEditor(nameColumn, new TextField());
gridEnvironmentVariableEditing.addEditor(descriptionColumn,
new TextField());
gridEnvironmentVariableEditing
.addEditor(inputTypeColumn, comboInputType);
gridEnvironmentVariableEditing.addEditor(defaultValueColumn,
new TextField());
btnAdd = new TextButton("Add");
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
btnAdd.setScale(ButtonScale.SMALL);
btnAdd.setIconAlign(IconAlign.LEFT);
btnAdd.setToolTip("Add Environment Variable");
btnAdd.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
addEnvironmentVariable(event);
}
});
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
GridCell cell = gridEnvironmentVariableEditing.getActiveCell();
int rowIndex = cell.getRow();
gridEnvironmentVariableEditing.cancelEditing();
storeEnvironmentVariable.remove(rowIndex);
storeEnvironmentVariable.commitChanges();
gridEnvironmentVariableEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
}
});
ButtonBar buttonBar = gridEnvironmentVariableEditing.getButtonBar();
buttonBar.add(btnDelete);
gridEnvironmentVariableEditing
.addBeforeStartEditHandler(new BeforeStartEditHandler<EnvironmentVariables>() {
@Override
public void onBeforeStartEdit(
BeforeStartEditEvent<EnvironmentVariables> event) {
editingBeforeStart(event);
}
});
gridEnvironmentVariableEditing
.addCancelEditHandler(new CancelEditHandler<EnvironmentVariables>() {
@Override
public void onCancelEdit(
CancelEditEvent<EnvironmentVariables> event) {
storeEnvironmentVariable.rejectChanges();
btnAdd.setEnabled(true);
}
});
gridEnvironmentVariableEditing
.addCompleteEditHandler(new CompleteEditHandler<EnvironmentVariables>() {
@Override
public void onCompleteEdit(
CompleteEditEvent<EnvironmentVariables> event) {
try {
if (addStatus) {
addStatus = false;
}
storeEnvironmentVariable.commitChanges();
gridEnvironmentVariableEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error in RuleOnTableNewDefinitionCard: "
+ e.getLocalizedMessage());
e.printStackTrace();
}
}
});
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridEnvironmentVariable, new VerticalLayoutData(1, 1,
new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
public void update(){
private void editingBeforeStart(
BeforeStartEditEvent<EnvironmentVariables> event) {
// TODO Auto-generated method stub
}
private void addHandlersForComboInputType(LabelProvider<InputType> idI18N) {
// TODO Auto-generated method stub
}
private void addEnvironmentVariable(SelectEvent event) {
try {
seq++;
EnvironmentVariables newEnvironmentVariable = new EnvironmentVariables(
seq, "", "", "", InputType.STRING);
Log.debug("New Environment Variable: " + newEnvironmentVariable);
gridEnvironmentVariableEditing.cancelEditing();
addStatus = true;
gridEnvironmentVariableEditing.getCancelButton().setVisible(false);
storeEnvironmentVariable.add(newEnvironmentVariable);
int row = storeEnvironmentVariable.indexOf(newEnvironmentVariable);
storeComboInputType.clear();
storeComboInputType.addAll(InputType.asList());
storeComboInputType.commitChanges();
gridEnvironmentVariableEditing.startEditing(new GridCell(row, 0));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void update() {
}

View File

@ -0,0 +1,28 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputType;
import com.google.gwt.i18n.client.Messages;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface InputTypeMessages extends Messages {
@DefaultMessage("")
@AlternateMessage({ "STRING", "String",
"NUMBER", "Number",
"ENUMERATED", "Enumerated",
"CONSTANT", "Constant",
"RANDOM", "Random",
"FILE", "File",
"MAP", "Map",
"BOOLEAN", "Boolean",
"IMAGES", "Images" })
String inputType(@Select InputType inputType);
}

View File

@ -1,19 +1,74 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.client.tools.input;
import java.util.ArrayList;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.EnvironmentVariablesProperties;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.properties.InputTypePropertiesCombo;
import org.gcube.portlets.user.statisticalalgorithmsimporter.client.resource.StatAlgoImporterResources;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.EnvironmentVariables;
import org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input.InputType;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.cell.client.AbstractCell;
import com.google.gwt.core.client.GWT;
import com.google.gwt.event.shared.EventBus;
import com.google.gwt.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates;
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.widget.core.client.ContentPanel;
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;
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.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.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
import com.sencha.gxt.widget.core.client.grid.Grid.GridCell;
import com.sencha.gxt.widget.core.client.grid.GridSelectionModel;
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
*
* @author giancarlo
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class SelectedRowsPanel extends ContentPanel {
private EventBus eventBus;
private ListStore<EnvironmentVariables> storeEnvironmentVariable;
private Grid<EnvironmentVariables> gridEnvironmentVariable;
private ListStore<InputType> storeComboInputType;
private ComboBox<InputType> comboInputType;
private GridRowEditing<EnvironmentVariables> gridEnvironmentVariableEditing;
private TextButton btnAdd;
private boolean addStatus;
private int seq = 0;
interface InputTypeTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
SafeHtml format(String value);
}
public SelectedRowsPanel(EventBus eventBus) {
super();
@ -21,26 +76,262 @@ public class SelectedRowsPanel extends ContentPanel {
this.eventBus = eventBus;
// msgs = GWT.create(ServiceCategoryMessages.class);
init();
create();
try {
init();
create();
} catch (Throwable e) {
e.printStackTrace();
}
}
private void init() {
forceLayoutOnResize = true;
setBodyBorder(false);
setBorders(false);
setHeaderVisible(false);
setResize(true);
setBodyBorder(false);
setBorders(false);
forceLayoutOnResize = true;
}
private void create() {
// Grid
EnvironmentVariablesProperties props = GWT
.create(EnvironmentVariablesProperties.class);
ColumnConfig<EnvironmentVariables, String> nameColumn = new ColumnConfig<EnvironmentVariables, String>(
props.name(), 100, "Name");
// nameColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, String> descriptionColumn = new ColumnConfig<EnvironmentVariables, String>(
props.name(), 100, "Description");
// descriptionColumn.setMenuDisabled(true);
ColumnConfig<EnvironmentVariables, InputType> inputTypeColumn = new ColumnConfig<EnvironmentVariables, InputType>(
props.inputType(), 100, "Type");
// inputTypeColumn.setMenuDisabled(true);
inputTypeColumn.setCell(new AbstractCell<InputType>() {
@Override
public void render(Context context, InputType inputType,
SafeHtmlBuilder sb) {
InputTypeTemplates inputTypeTemplates = GWT
.create(InputTypeTemplates.class);
sb.append(inputTypeTemplates.format(inputType.getLabel()));
}
});
ColumnConfig<EnvironmentVariables, String> defaultValueColumn = new ColumnConfig<EnvironmentVariables, String>(
props.defaultValue(), 100, "Default");
// defaColumn.setMenuDisabled(true);
ArrayList<ColumnConfig<EnvironmentVariables, ?>> l = new ArrayList<ColumnConfig<EnvironmentVariables, ?>>();
l.add(nameColumn);
l.add(descriptionColumn);
l.add(inputTypeColumn);
l.add(defaultValueColumn);
ColumnModel<EnvironmentVariables> columns = new ColumnModel<EnvironmentVariables>(
l);
storeEnvironmentVariable = new ListStore<EnvironmentVariables>(
props.id());
/*ArrayList<EnvironmentVariables> list = new ArrayList<>();
for (int i = 0; i < 10; i++) {
list.add(new EnvironmentVariables(i, "Test" + i, "Desc",
"defaultValue", InputType.STRING));
}
storeEnvironmentVariable.addAll(list);*/
final GridSelectionModel<EnvironmentVariables> sm = new GridSelectionModel<EnvironmentVariables>();
sm.setSelectionMode(SelectionMode.SINGLE);
gridEnvironmentVariable = new Grid<EnvironmentVariables>(
storeEnvironmentVariable, columns);
gridEnvironmentVariable.setSelectionModel(sm);
gridEnvironmentVariable.getView().setStripeRows(true);
gridEnvironmentVariable.getView().setColumnLines(true);
gridEnvironmentVariable.getView().setAutoExpandColumn(nameColumn);
gridEnvironmentVariable.getView().setAutoFill(true);
gridEnvironmentVariable.setBorders(false);
gridEnvironmentVariable.setColumnReordering(false);
/*
* GridDragSource<EnvironmentVariables> ds = new
* GridDragSource<EnvironmentVariables>( gridEnvironmentVariable);
* ds.addDragStartHandler(new DndDragStartHandler() {
*
* @Override public void onDragStart(DndDragStartEvent event) {
*
* @SuppressWarnings("unchecked") ArrayList<EnvironmentVariables>
* draggingSelection = (ArrayList<EnvironmentVariables>) event
* .getData(); Log.debug("Start Drag: " + draggingSelection);
*
* } }); GridDropTarget<EnvironmentVariables> dt = new
* GridDropTarget<EnvironmentVariables>( gridEnvironmentVariable);
* dt.setFeedback(Feedback.BOTH); dt.setAllowSelfAsSource(true);
*/
// EDITING //
// Key
InputTypePropertiesCombo inputTypePropertiesCombo = GWT
.create(InputTypePropertiesCombo.class);
storeComboInputType = new ListStore<InputType>(
inputTypePropertiesCombo.id());
comboInputType = new ComboBox<InputType>(storeComboInputType,
inputTypePropertiesCombo.label());
comboInputType.setClearValueOnParseError(false);
comboInputType.setEditable(false);
comboInputType.setTriggerAction(TriggerAction.ALL);
addHandlersForComboInputType(inputTypePropertiesCombo.label());
gridEnvironmentVariableEditing = new GridRowEditing<EnvironmentVariables>(
gridEnvironmentVariable);
gridEnvironmentVariableEditing.addEditor(nameColumn, new TextField());
gridEnvironmentVariableEditing.addEditor(descriptionColumn,
new TextField());
gridEnvironmentVariableEditing
.addEditor(inputTypeColumn, comboInputType);
gridEnvironmentVariableEditing.addEditor(defaultValueColumn,
new TextField());
btnAdd = new TextButton();
btnAdd.setIcon(StatAlgoImporterResources.INSTANCE.add16());
//btnAdd.setIconAlign(IconAlign.);
btnAdd.setToolTip("Add Environment Variable");
btnAdd.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
addEnvironmentVariable(event);
}
});
TextButton btnDelete = new TextButton("Delete");
btnDelete.addSelectHandler(new SelectEvent.SelectHandler() {
public void onSelect(SelectEvent event) {
GridCell cell = gridEnvironmentVariableEditing.getActiveCell();
int rowIndex = cell.getRow();
gridEnvironmentVariableEditing.cancelEditing();
storeEnvironmentVariable.remove(rowIndex);
storeEnvironmentVariable.commitChanges();
gridEnvironmentVariableEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
if (addStatus) {
addStatus = false;
}
}
});
ButtonBar buttonBar = gridEnvironmentVariableEditing.getButtonBar();
buttonBar.add(btnDelete);
gridEnvironmentVariableEditing
.addBeforeStartEditHandler(new BeforeStartEditHandler<EnvironmentVariables>() {
@Override
public void onBeforeStartEdit(
BeforeStartEditEvent<EnvironmentVariables> event) {
editingBeforeStart(event);
}
});
gridEnvironmentVariableEditing
.addCancelEditHandler(new CancelEditHandler<EnvironmentVariables>() {
@Override
public void onCancelEdit(
CancelEditEvent<EnvironmentVariables> event) {
storeEnvironmentVariable.rejectChanges();
btnAdd.setEnabled(true);
}
});
gridEnvironmentVariableEditing
.addCompleteEditHandler(new CompleteEditHandler<EnvironmentVariables>() {
@Override
public void onCompleteEdit(
CompleteEditEvent<EnvironmentVariables> event) {
try {
if (addStatus) {
addStatus = false;
}
storeEnvironmentVariable.commitChanges();
gridEnvironmentVariableEditing.getCancelButton()
.setVisible(true);
btnAdd.setEnabled(true);
} catch (Throwable e) {
Log.error("Error in RuleOnTableNewDefinitionCard: "
+ e.getLocalizedMessage());
e.printStackTrace();
}
}
});
ToolBar toolBar = new ToolBar();
toolBar.add(btnAdd, new BoxLayoutData(new Margins(0)));
VerticalLayoutContainer vlc = new VerticalLayoutContainer();
vlc.setAdjustForScroll(false);
vlc.setScrollMode(ScrollMode.NONE);
vlc.add(toolBar, new VerticalLayoutData(1, -1, new Margins(0)));
vlc.add(gridEnvironmentVariable, new VerticalLayoutData(1, 1,
new Margins(0)));
add(vlc, new MarginData(new Margins(0)));
}
public void update(){
private void editingBeforeStart(
BeforeStartEditEvent<EnvironmentVariables> event) {
// TODO Auto-generated method stub
}
private void addHandlersForComboInputType(LabelProvider<InputType> idI18N) {
// TODO Auto-generated method stub
}
private void addEnvironmentVariable(SelectEvent event) {
try {
seq++;
EnvironmentVariables newEnvironmentVariable = new EnvironmentVariables(
seq, "", "", "", InputType.STRING);
Log.debug("New Environment Variable: " + newEnvironmentVariable);
gridEnvironmentVariableEditing.cancelEditing();
addStatus = true;
gridEnvironmentVariableEditing.getCancelButton().setVisible(false);
storeEnvironmentVariable.add(newEnvironmentVariable);
int row = storeEnvironmentVariable.indexOf(newEnvironmentVariable);
storeComboInputType.clear();
storeComboInputType.addAll(InputType.asList());
storeComboInputType.commitChanges();
gridEnvironmentVariableEditing.startEditing(new GridCell(row, 0));
} catch (Throwable e) {
e.printStackTrace();
}
}
public void update() {
}

View File

@ -80,7 +80,7 @@ public class CodeUploadPanel extends FormPanel {
setMethod(Method.POST);
uploadCodeBtn = new TextButton("Upload");
uploadCodeBtn.setIcon(StatAlgoImporterResources.INSTANCE.upload32());
uploadCodeBtn.setIcon(StatAlgoImporterResources.INSTANCE.upload24());
uploadCodeBtn.setIconAlign(IconAlign.RIGHT);
uploadCodeBtn.setToolTip("Upload Code");
@ -106,7 +106,7 @@ public class CodeUploadPanel extends FormPanel {
});
cancelBtn = new TextButton("Cancel");
cancelBtn.setIcon(StatAlgoImporterResources.INSTANCE.cancel32());
cancelBtn.setIcon(StatAlgoImporterResources.INSTANCE.cancel24());
cancelBtn.setIconAlign(IconAlign.RIGHT);
cancelBtn.setEnabled(false);
@ -194,7 +194,7 @@ public class CodeUploadPanel extends FormPanel {
fieldSet.add(vlc);
add(fieldSet, new MarginData(new Margins(5, 0, 0, 7)));
add(fieldSet, new MarginData(new Margins(5, 7, 2, 7)));
}

View File

@ -0,0 +1,91 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input;
import java.io.Serializable;
/**
*
* @author giancarlo email: <a
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class EnvironmentVariables implements Serializable {
private static final long serialVersionUID = -2519686355634242523L;
private int id;
private String name;
private String description;
private String defaultValue;
private InputType inputType;
public EnvironmentVariables() {
super();
}
/**
*
* @param id
* @param name
* @param description
* @param defaultValue
* @param inputType
*/
public EnvironmentVariables(int id, String name, String description,
String defaultValue, InputType inputType) {
super();
this.id = id;
this.name = name;
this.description = description;
this.defaultValue = defaultValue;
this.inputType = inputType;
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getDefaultValue() {
return defaultValue;
}
public void setDefaultValue(String defaultValue) {
this.defaultValue = defaultValue;
}
public InputType getInputType() {
return inputType;
}
public void setInputType(InputType inputType) {
this.inputType = inputType;
}
@Override
public String toString() {
return "EnvironmentVariables [id=" + id + ", name=" + name
+ ", description=" + description + ", defaultValue="
+ defaultValue + ", inputType=" + inputType + "]";
}
}

View File

@ -0,0 +1,64 @@
package org.gcube.portlets.user.statisticalalgorithmsimporter.shared.input;
import java.util.Arrays;
import java.util.List;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public enum InputType {
STRING("String"),
NUMBER("Number"),
ENUMERATED("Enumerated"),
CONSTANT("Constant"),
RANDOM("Random"),
FILE("File"),
MAP("Map"),
BOOLEAN("Boolean"),
IMAGES("Images");
//private static InputTypeMessages msgs=GWT.create(InputTypeMessages.class);
private String id;
//private static List<String> inputTypeI18NList;
/*static {
inputTypeI18NList = new ArrayList<String>();
for (InputType itype : values()) {
inputTypeI18NList.add(msgs.inputType(itype));
}
}*/
private InputType(String id) {
this.id = id;
}
public String getId() {
return id;
}
public String toString() {
return id;
}
public String getLabel(){
//return msgs.inputType(this);
return id;
}
public static List<InputType> asList() {
List<InputType> list = Arrays.asList(values());
return list;
}
/*public static List<String> asI18NList() {
return inputTypeI18NList;
}*/
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 520 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 803 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1014 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 587 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 928 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 917 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 848 B