Updated Rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114301 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-21 14:54:58 +00:00
parent 12619508bf
commit b7ab7cc8fb
7 changed files with 131 additions and 34 deletions

View File

@ -906,6 +906,9 @@ public class TabularDataController {
case RULE_APPLY:
openApplyRule();
break;
case RULES_APPLIED_ON_TABULAR_RESOURCE:
openRulesAppliedOnTabularResource();
break;
case RULE_SHARE:
openShareRule();
break;
@ -1752,6 +1755,22 @@ public class TabularDataController {
}
private void openRulesAppliedOnTabularResource() {
Log.debug("Request Open Rules Applied on TabularResource Dialog");
if (trId != null) {
RuleApplyDialog raDialog = new RuleApplyDialog(
trId, eventBus);
raDialog.show();
} else {
Log.error("TRId is null");
UtilsGXT3.alert("Error",
"No current tabular resource present");
}
}
private void callDiscard() {
HistoryDiscard historyDiscard = new HistoryDiscard(eventBus);

View File

@ -41,6 +41,7 @@ public class RuleToolBar {
private TextButton ruleOpenButton;
private TextButton ruleDeleteButton;
private TextButton ruleApplyButton;
private TextButton ruleTabularResourceButton;
// private TextButton ruleShareButton;
@ -105,6 +106,22 @@ public class RuleToolBar {
ruleLayout.setWidget(0, 1, ruleDeleteButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleTabularResourceButton = new TextButton(msgs.ruleTabularResourceButton(),
TabularDataResources.INSTANCE.ruleTabularResource32());
ruleTabularResourceButton.disable();
ruleTabularResourceButton.setScale(ButtonScale.LARGE);
ruleTabularResourceButton.setIconAlign(IconAlign.TOP);
ruleTabularResourceButton.setToolTip(msgs.ruleTabularResourceButtonToolTip());
ruleTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleTabularResourceButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(RibbonType.RULES_APPLIED_ON_TABULAR_RESOURCE));
}
});
ruleLayout.setWidget(0, 2, ruleTabularResourceButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
/*
@ -204,6 +221,7 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.enable();
break;
case TR_CLOSE:
@ -212,6 +230,7 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.enable();
break;
case TR_OPEN:
@ -221,6 +240,7 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.enable();
ruleTabularResourceButton.enable();
// ruleShareButton.enable();
break;
case WIZARD_OPEN:
@ -228,6 +248,7 @@ public class RuleToolBar {
ruleNewButton.disable();
ruleDeleteButton.disable();
ruleApplyButton.disable();
ruleTabularResourceButton.disable();
// ruleShareButton.disable();
break;
default:

View File

@ -31,6 +31,12 @@ public interface RuleToolBarMessages extends Messages {
@DefaultMessage("Share")
String ruleShareButtonToolTip();
@DefaultMessage("Applied")
String ruleTabularResourceButton();
@DefaultMessage("Applied")
String ruleTabularResourceButtonToolTip();
@DefaultMessage("On Column")
String ruleOnColumnGroupHeadingText();
@ -49,5 +55,7 @@ public interface RuleToolBarMessages extends Messages {
}

View File

@ -1,6 +1,7 @@
package org.gcube.portlets.user.td.client.rule;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
@ -11,6 +12,7 @@ import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
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.ApplyColumnRulesSession;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
@ -87,8 +89,9 @@ public class RuleApplyPanel extends FramedPanel {
private TRId trId;
private ArrayList<ColumnData> columns;
private ColumnData column;
private AppliedRulesResponseData appliedRuleResponseData;
private ArrayList<RuleDescriptionData> applicableRules;
private ArrayList<RuleDescriptionData> appliesRules;
private ArrayList<RuleDescriptionData> appliedRules;
private TextButton btnApply;
private TextButton btnClose;
@ -103,7 +106,6 @@ public class RuleApplyPanel extends FramedPanel {
this.parent = parent;
this.trId = trId;
applicableRules = new ArrayList<RuleDescriptionData>();
appliesRules = new ArrayList<RuleDescriptionData>();
Log.debug("RuleApplyPanel");
setWidth(WIDTH);
@ -154,7 +156,8 @@ public class RuleApplyPanel extends FramedPanel {
"The requested columns is null");
}
columns = result;
create();
getAppliedBaseColumnRules();
}
});
@ -212,8 +215,6 @@ public class RuleApplyPanel extends FramedPanel {
sb.append(ruleApplyTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.description(), 120, "Description");
@ -400,6 +401,21 @@ public class RuleApplyPanel extends FramedPanel {
protected void updateRulesInGrids(ColumnData columnData) {
column = columnData;
HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
.getColumnRuleMapping();
if (columnRuleMapping != null) {
ArrayList<RuleDescriptionData> applied = columnRuleMapping
.get(columnData.getColumnId());
if (applied != null) {
appliedRules = applied;
appliesRulesStore.clear();
appliesRulesStore.addAll(new ArrayList<RuleDescriptionData>(
applied));
}
}
getApplicableBaseColumnRules();
}
@ -414,10 +430,10 @@ public class RuleApplyPanel extends FramedPanel {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving applicable rules:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving applicable rules");
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert(
"Error retrieving applicable rules",
caught.getLocalizedMessage());
}
}
@ -425,18 +441,40 @@ public class RuleApplyPanel extends FramedPanel {
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
if (appliedRules != null && appliedRules.size() > 0) {
ArrayList<RuleDescriptionData> removableRules = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData ruleApplied : appliedRules) {
for (RuleDescriptionData ruleApplicable : result) {
if (ruleApplicable.equals(ruleApplied)) {
removableRules.add(ruleApplicable);
break;
}
}
}
result.removeAll(removableRules);
}
applicableRules = result;
getAppliesBaseColumnRules();
applicableRulesStore.clear();
applicableRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
applicableRules));
forceLayout();
}
});
}
protected void getAppliesBaseColumnRules() {
protected void getAppliedBaseColumnRules() {
ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
ExpressionServiceAsync.INSTANCE.getAppliedRulesByTabularResourceId(
trId, new AsyncCallback<AppliedRulesResponseData>() {
@Override
public void onFailure(Throwable caught) {
@ -444,28 +482,18 @@ public class RuleApplyPanel extends FramedPanel {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Error retrieving applicable rules:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving applicable rules");
Log.error(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving applied rules",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
appliesRules = result;
applicableRulesStore.clear();
applicableRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
applicableRules));
appliesRulesStore.clear();
appliesRulesStore
.addAll(new ArrayList<RuleDescriptionData>(
appliesRules));
forceLayout();
public void onSuccess(AppliedRulesResponseData result) {
Log.trace("AppliedRuleResponseData: " + result);
appliedRuleResponseData = result;
create();
}
});
@ -485,12 +513,27 @@ public class RuleApplyPanel extends FramedPanel {
ArrayList<RuleDescriptionData> rulesToBeApplied = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData ruleSelected : selectedRules) {
boolean ruleApplied = false;
for (RuleDescriptionData ruleAlreadyApplied : appliesRules) {
if (ruleSelected.getId() == ruleAlreadyApplied.getId()) {
ruleApplied = true;
break;
HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
.getColumnRuleMapping();
if (columnRuleMapping != null) {
ArrayList<RuleDescriptionData> applied = columnRuleMapping
.get(column.getColumnId());
if (applied != null) {
for (RuleDescriptionData ruleAlreadyApplied : applied) {
if (ruleSelected.getId() == ruleAlreadyApplied
.getId()) {
ruleApplied = true;
break;
}
}
} else {
}
} else {
}
if (ruleApplied == false) {
rulesToBeApplied.add(ruleSelected);
}

View File

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

View File

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

View File

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