Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114347 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-22 17:08:32 +00:00
parent c7bd80cf99
commit ddd2be5167
14 changed files with 188 additions and 78 deletions

View File

@ -8,7 +8,7 @@ import java.util.HashMap;
import org.gcube.portlets.user.td.chartswidget.client.ChartsWidgetTD;
import org.gcube.portlets.user.td.client.logs.TDMLogs;
import org.gcube.portlets.user.td.client.rstudio.RStudio;
import org.gcube.portlets.user.td.client.rule.RuleAppliedDialog;
import org.gcube.portlets.user.td.client.rule.RuleActiveDialog;
import org.gcube.portlets.user.td.client.rule.RuleApplyDialog;
import org.gcube.portlets.user.td.client.rule.RuleDeleteDialog;
import org.gcube.portlets.user.td.client.rule.RuleOpenDialog;
@ -907,7 +907,7 @@ public class TabularDataController {
case RULE_APPLY:
openApplyRule();
break;
case RULES_APPLIED_ON_TABULAR_RESOURCE:
case RULES_ACTIVE:
openRulesAppliedOnTabularResource();
break;
case RULE_SHARE:
@ -1759,7 +1759,7 @@ public class TabularDataController {
private void openRulesAppliedOnTabularResource() {
Log.debug("Request Open Rules Applied on TabularResource Dialog");
if (trId != null) {
RuleAppliedDialog raDialog = new RuleAppliedDialog(
RuleActiveDialog raDialog = new RuleActiveDialog(
trId, eventBus);
raDialog.show();
} else {

View File

@ -171,11 +171,17 @@ public interface TabularDataResources extends ClientBundle {
@Source("rule-column-apply_32.png")
ImageResource ruleColumnApply32();
@Source("rule-column-detach.png")
ImageResource ruleColumnDetach();
@Source("rule-column-detach_32.png")
ImageResource ruleColumnDetach32();
@Source("rule-tabularresource.png")
ImageResource ruleTabularResource();
@Source("rule-tabularresource_32.png")
ImageResource ruleTabularResource32();
ImageResource ruleActive32();
@Source("table-filter_32.png")

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -39,7 +39,7 @@ public class RuleToolBar {
// Rules
private TextButton ruleOpenButton;
private TextButton ruleDeleteButton;
private TextButton ruleOnTabularResourceButton;
private TextButton ruleActiveButton;
private TextButton ruleShareButton;
// On Column
@ -107,24 +107,24 @@ public class RuleToolBar {
ruleLayout.setWidget(0, 1, ruleDeleteButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleOnTabularResourceButton = new TextButton(
msgs.ruleTabularResourceButton(),
TabularDataResources.INSTANCE.ruleTabularResource32());
ruleOnTabularResourceButton.disable();
ruleOnTabularResourceButton.setScale(ButtonScale.LARGE);
ruleOnTabularResourceButton.setIconAlign(IconAlign.TOP);
ruleOnTabularResourceButton.setToolTip(msgs
.ruleTabularResourceButtonToolTip());
ruleOnTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleOnTabularResourceButton.addSelectHandler(new SelectHandler() {
ruleActiveButton = new TextButton(
msgs.ruleActiveButton(),
TabularDataResources.INSTANCE.ruleActive32());
ruleActiveButton.disable();
ruleActiveButton.setScale(ButtonScale.LARGE);
ruleActiveButton.setIconAlign(IconAlign.TOP);
ruleActiveButton.setToolTip(msgs
.ruleActiveButtonToolTip());
ruleActiveButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleActiveButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(
RibbonType.RULES_APPLIED_ON_TABULAR_RESOURCE));
RibbonType.RULES_ACTIVE));
}
});
ruleLayout.setWidget(0, 2, ruleOnTabularResourceButton);
ruleLayout.setWidget(0, 2, ruleActiveButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
ruleShareButton = new TextButton(msgs.ruleShareButton(),
@ -222,7 +222,7 @@ public class RuleToolBar {
case START:
ruleOpenButton.enable();
ruleDeleteButton.enable();
ruleOnTabularResourceButton.disable();
ruleActiveButton.disable();
ruleShareButton.enable();
ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.disable();
@ -231,7 +231,7 @@ public class RuleToolBar {
case TR_READONLY:
ruleOpenButton.enable();
ruleDeleteButton.enable();
ruleOnTabularResourceButton.disable();
ruleActiveButton.disable();
ruleShareButton.enable();
ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.disable();
@ -242,7 +242,7 @@ public class RuleToolBar {
case TABLECURATION:
ruleOpenButton.enable();
ruleDeleteButton.enable();
ruleOnTabularResourceButton.enable();
ruleActiveButton.enable();
ruleShareButton.enable();
ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.enable();
@ -251,7 +251,7 @@ public class RuleToolBar {
case WIZARD_OPEN:
ruleOpenButton.disable();
ruleDeleteButton.disable();
ruleOnTabularResourceButton.disable();
ruleActiveButton.disable();
ruleShareButton.disable();
ruleOnColumnNewButton.disable();
ruleOnColumnApplyButton.disable();

View File

@ -32,10 +32,10 @@ public interface RuleToolBarMessages extends Messages {
String ruleShareButtonToolTip();
@DefaultMessage("Applied")
String ruleTabularResourceButton();
String ruleActiveButton();
@DefaultMessage("Applied")
String ruleTabularResourceButtonToolTip();
String ruleActiveButtonToolTip();
@DefaultMessage("On Column")

View File

@ -14,15 +14,15 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleAppliedDialog extends Window {
public class RuleActiveDialog extends Window {
private static final String WIDTH = "720px";
private static final String HEIGHT = "428px";
public RuleAppliedDialog(TRId trId, EventBus eventBus) {
public RuleActiveDialog(TRId trId, EventBus eventBus) {
initWindow();
RuleAppliedPanel ruleApplyPanel = new RuleAppliedPanel(this,
RuleActivePanel ruleActivePanel = new RuleActivePanel(this,
trId, eventBus);
add(ruleApplyPanel);
add(ruleActivePanel);
}
protected void initWindow() {
@ -30,7 +30,7 @@ public class RuleAppliedDialog extends Window {
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Rules Applied On TabularResource");
setHeadingText("Active Rules On TabularResource");
setClosable(true);
setModal(true);
forceLayoutOnResize = true;

View File

@ -12,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalExcept
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData;
import org.gcube.portlets.user.td.gwtservice.shared.rule.DetachColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
@ -65,7 +66,7 @@ import com.sencha.gxt.widget.core.client.menu.MenuItem;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public class RuleAppliedPanel extends FramedPanel {
public class RuleActivePanel extends FramedPanel {
private static final int RULE_ON_COLUMN_FIELDSET_HEIGHT = 348;
private static final String RULES_GRID_HEIGHT = "102px";
private static final String WIDTH = "630px";
@ -77,20 +78,21 @@ public class RuleAppliedPanel extends FramedPanel {
}
private EventBus eventBus;
private RuleAppliedDialog parent;
private RuleActiveDialog parent;
private TRId trId;
private ArrayList<ColumnData> columns;
private AppliedRulesResponseData appliedRuleResponseData;
private TextButton btnClose;
private VerticalLayoutContainer mainLayoutContainer;
public RuleAppliedPanel(RuleAppliedDialog parent, TRId trId,
public RuleActivePanel(RuleActiveDialog parent, TRId trId,
EventBus eventBus) {
this.parent = parent;
this.trId = trId;
Log.debug("RuleAppliedPanel");
Log.debug("RuleActivePanel");
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
@ -140,7 +142,7 @@ public class RuleAppliedPanel extends FramedPanel {
}
columns = result;
getAppliedBaseColumnRules();
getActiveRulesOnColumn();
}
});
@ -148,7 +150,7 @@ public class RuleAppliedPanel extends FramedPanel {
protected void create() {
Log.debug("Create RuleAppliedPanel(): " + trId);
Log.debug("Create RuleActivePanel(): " + trId);
// SimpleContainer rulesOnColumnContainer=new SimpleContainer();
FieldSet columnRulesFieldSet = new FieldSet();
@ -200,12 +202,12 @@ public class RuleAppliedPanel extends FramedPanel {
flowButton.setPack(BoxLayoutPack.CENTER);
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(columnRulesFieldSet, new VerticalLayoutData(-1,
mainLayoutContainer = new VerticalLayoutContainer();
mainLayoutContainer.add(columnRulesFieldSet, new VerticalLayoutData(-1,
RULE_ON_COLUMN_FIELDSET_HEIGHT, new Margins(0)));
v.add(flowButton,
mainLayoutContainer.add(flowButton,
new VerticalLayoutData(1, 36, new Margins(5, 2, 5, 2)));
add(v);
add(mainLayoutContainer);
}
@ -292,6 +294,7 @@ public class RuleAppliedPanel extends FramedPanel {
final Grid<RuleDescriptionData> gridAppliedRules = new Grid<RuleDescriptionData>(
appliedRulesStore, cm);
gridAppliedRules.setItemId(column.getColumnId());
gridAppliedRules.setHeight(RULES_GRID_HEIGHT);
gridAppliedRules.getView().setStripeRows(true);
gridAppliedRules.getView().setColumnLines(true);
@ -316,9 +319,38 @@ public class RuleAppliedPanel extends FramedPanel {
return rulesAppliedLabel;
}
protected void getAppliedBaseColumnRules() {
protected void getActiveRulesOnColumn() {
ExpressionServiceAsync.INSTANCE.getAppliedRulesByTabularResourceId(
ExpressionServiceAsync.INSTANCE.getActiveRulesByTabularResourceId(
trId, new AsyncCallback<AppliedRulesResponseData>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving active rules",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(AppliedRulesResponseData result) {
Log.trace("AppliedRuleResponseData: " + result);
appliedRuleResponseData = result;
create();
}
});
}
protected void updateActiveRulesOnColumn() {
ExpressionServiceAsync.INSTANCE.getActiveRulesByTabularResourceId(
trId, new AsyncCallback<AppliedRulesResponseData>() {
@Override
@ -338,15 +370,19 @@ public class RuleAppliedPanel extends FramedPanel {
public void onSuccess(AppliedRulesResponseData result) {
Log.trace("AppliedRuleResponseData: " + result);
appliedRuleResponseData = result;
create();
recreate();
}
});
}
protected void close() {
parent.close();
}
protected void requestInfo(RuleDescriptionData rule) {
@ -422,6 +458,7 @@ public class RuleAppliedPanel extends FramedPanel {
MenuItem infoItem = new MenuItem();
infoItem.setText("Info");
infoItem.setToolTip("Info");
infoItem.setIcon(TabularDataResources.INSTANCE.information());
infoItem.addSelectionHandler(new SelectionHandler<Item>() {
@ -433,6 +470,24 @@ public class RuleAppliedPanel extends FramedPanel {
requestInfo(selected);
}
});
MenuItem detachItem = new MenuItem();
detachItem.setText("Detach");
detachItem.setToolTip("Detach rule");
detachItem.setIcon(TabularDataResources.INSTANCE.ruleColumnDetach());
detachItem.addSelectionHandler(new SelectionHandler<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
RuleDescriptionData selected = grid.getSelectionModel()
.getSelectedItem();
Log.debug(selected.toString());
requestDetach(selected, grid);
}
});
contextMenu.add(infoItem);
@ -440,4 +495,53 @@ public class RuleAppliedPanel extends FramedPanel {
}
protected void requestDetach(RuleDescriptionData selected,
final Grid<RuleDescriptionData> grid) {
String columnLocalId=grid.getItemId();
ColumnData columnData=new ColumnData();
columnData.setColumnId(columnLocalId);
ArrayList<RuleDescriptionData> detachRules=new ArrayList<RuleDescriptionData>();
detachRules.add(selected);
DetachColumnRulesSession detachColumnRulesSession=new DetachColumnRulesSession(trId, columnData, detachRules);
ExpressionServiceAsync.INSTANCE.setDetachColumnRules(detachColumnRulesSession,
new AsyncCallback<Void>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error in detach rules",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(Void result) {
updateActiveRulesOnColumn();
Log.debug("The rule is detached!");
UtilsGXT3.info("Detach Rule",
"The rule is detached!");
}
});
}
protected void recreate(){
remove(mainLayoutContainer);
create();
forceLayout();
}
}

View File

@ -99,8 +99,8 @@ public class RuleApplyPanel extends FramedPanel {
private ComboBox<ColumnData> comboColumns;
private ListStore<RuleDescriptionData> applicableRulesStore;
private Grid<RuleDescriptionData> gridApplicableRules;
private ListStore<RuleDescriptionData> appliesRulesStore;
private Grid<RuleDescriptionData> gridAppliesRules;
private ListStore<RuleDescriptionData> selectedRulesStore;
private Grid<RuleDescriptionData> gridSelectedRules;
public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
this.parent = parent;
@ -292,38 +292,38 @@ public class RuleApplyPanel extends FramedPanel {
createContextMenu(gridApplicableRules);
// Applies Rules
appliesRulesStore = new ListStore<RuleDescriptionData>(propsRules.id());
// Selected Rules
selectedRulesStore = new ListStore<RuleDescriptionData>(propsRules.id());
gridAppliesRules = new Grid<RuleDescriptionData>(appliesRulesStore, cm);
gridAppliesRules.setHeight(RULES_GRID_HEIGHT);
gridAppliesRules.getView().setStripeRows(true);
gridAppliesRules.getView().setColumnLines(true);
gridAppliesRules.getView().setAutoFill(true);
gridAppliesRules.setBorders(false);
gridAppliesRules.setLoadMask(true);
gridAppliesRules.setColumnReordering(true);
gridAppliesRules.setColumnResize(true);
gridAppliesRules.getView().setAutoExpandColumn(descriptionCol);
gridSelectedRules = new Grid<RuleDescriptionData>(selectedRulesStore, cm);
gridSelectedRules.setHeight(RULES_GRID_HEIGHT);
gridSelectedRules.getView().setStripeRows(true);
gridSelectedRules.getView().setColumnLines(true);
gridSelectedRules.getView().setAutoFill(true);
gridSelectedRules.setBorders(false);
gridSelectedRules.setLoadMask(true);
gridSelectedRules.setColumnReordering(true);
gridSelectedRules.setColumnResize(true);
gridSelectedRules.getView().setAutoExpandColumn(descriptionCol);
GridFilters<RuleDescriptionData> filtersAppliesRules = new GridFilters<RuleDescriptionData>();
filtersAppliesRules.initPlugin(gridAppliesRules);
filtersAppliesRules.setLocal(true);
filtersAppliesRules.addFilter(nameFilter);
filtersAppliesRules.addFilter(descriptionFilter);
GridFilters<RuleDescriptionData> filtersSelectedRules = new GridFilters<RuleDescriptionData>();
filtersSelectedRules.initPlugin(gridSelectedRules);
filtersSelectedRules.setLocal(true);
filtersSelectedRules.addFilter(nameFilter);
filtersSelectedRules.addFilter(descriptionFilter);
createContextMenu(gridAppliesRules);
createContextMenu(gridSelectedRules);
//
new GridDragSource<RuleDescriptionData>(gridApplicableRules)
.setGroup(SET_RULES);
new GridDragSource<RuleDescriptionData>(gridAppliesRules)
new GridDragSource<RuleDescriptionData>(gridSelectedRules)
.setGroup(SET_RULES);
new GridDropTarget<RuleDescriptionData>(gridApplicableRules)
.setGroup(SET_RULES);
new GridDropTarget<RuleDescriptionData>(gridAppliesRules)
new GridDropTarget<RuleDescriptionData>(gridSelectedRules)
.setGroup(SET_RULES);
//
@ -333,17 +333,17 @@ public class RuleApplyPanel extends FramedPanel {
configurationFieldSetLayout.add(rulesApplicableLabel,
new VerticalLayoutData(1, -1, new Margins(0)));
FieldLabel rulesAppliesLabel = new FieldLabel(gridAppliesRules,
"Applies Rules");
FieldLabel rulesSelectedLabel = new FieldLabel(gridSelectedRules,
"Selected Rules");
configurationFieldSetLayout.add(rulesAppliesLabel,
configurationFieldSetLayout.add(rulesSelectedLabel,
new VerticalLayoutData(1, -1, new Margins(0)));
// Button
btnApply = new TextButton("Apply");
btnApply.setIcon(TabularDataResources.INSTANCE.ruleColumnApply());
btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setToolTip("Apply Template");
btnApply.setToolTip("Apply Rule");
btnApply.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
@ -403,7 +403,7 @@ public class RuleApplyPanel extends FramedPanel {
protected void updateRulesInGrids(ColumnData columnData) {
column = columnData;
applicableRulesStore.clear();
appliesRulesStore.clear();
selectedRulesStore.clear();
HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
.getColumnRuleMapping();
@ -413,7 +413,7 @@ public class RuleApplyPanel extends FramedPanel {
if (applied != null) {
appliedRules = applied;
appliesRulesStore.addAll(new ArrayList<RuleDescriptionData>(
selectedRulesStore.addAll(new ArrayList<RuleDescriptionData>(
applied));
}
@ -472,7 +472,7 @@ public class RuleApplyPanel extends FramedPanel {
protected void getAppliedBaseColumnRules() {
ExpressionServiceAsync.INSTANCE.getAppliedRulesByTabularResourceId(
ExpressionServiceAsync.INSTANCE.getActiveRulesByTabularResourceId(
trId, new AsyncCallback<AppliedRulesResponseData>() {
@Override
@ -482,7 +482,7 @@ public class RuleApplyPanel extends FramedPanel {
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving applied rules",
UtilsGXT3.alert("Error retrieving selected rules",
caught.getLocalizedMessage());
}
@ -499,7 +499,7 @@ public class RuleApplyPanel extends FramedPanel {
}
protected ArrayList<RuleDescriptionData> getSelectedItems() {
List<RuleDescriptionData> selectedItems = appliesRulesStore.getAll();
List<RuleDescriptionData> selectedItems = selectedRulesStore.getAll();
ArrayList<RuleDescriptionData> rulesSelected = new ArrayList<RuleDescriptionData>(
selectedItems);
return rulesSelected;

Binary file not shown.

After

Width:  |  Height:  |  Size: 862 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -5,8 +5,8 @@ ruleDeleteButton = Delete
ruleDeleteButtonToolTip = Delete
ruleShareButton = Share
ruleShareButtonToolTip = Share
ruleTabularResourceButton = Applied
ruleTabularResourceButtonToolTip = Applied
ruleActiveButton = Active
ruleActiveButtonToolTip = Active
ruleOnColumnGroupHeadingText = On Column
ruleNewButton = New
ruleNewButtonToolTip = New

View File

@ -5,8 +5,8 @@ ruleDeleteButton = Borrar
ruleDeleteButtonToolTip = Borrar
ruleShareButton = Cuota
ruleShareButtonToolTip = Cuota
ruleTabularResourceButton = Aplicado
ruleTabularResourceButtonToolTip = Aplicado
ruleActiveButton = Activo
ruleActiveToolTip = Activo
ruleOnColumnGroupHeadingText = On Columna
ruleNewButton = Nuevo
ruleNewButtonToolTip = Nuevo

View File

@ -5,8 +5,8 @@ ruleDeleteButton = Elimina
ruleDeleteButtonToolTip = Elimina
ruleShareButton = Condividi
ruleShareButtonToolTip = Condividi
ruleTabularResourceButton = Applicate
ruleTabularResourceButtonToolTip = Applicate
ruleActiveButton = Attive
ruleActiveButtonToolTip = Attive
ruleOnColumnGroupHeadingText = Su Colonna
ruleNewButton = Nuova
ruleNewButtonToolTip = Nuova