Updated Rule

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114022 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-14 12:46:34 +00:00
parent a0891c2e3b
commit cf12254a96
9 changed files with 219 additions and 295 deletions

View File

@ -54,7 +54,7 @@ public class RuleApplyDialog extends Window implements
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(TabularDataResources.INSTANCE.templateApply());
getHeader().setIcon(TabularDataResources.INSTANCE.ruleApply());
}

View File

@ -4,10 +4,12 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
@ -71,12 +73,11 @@ public class RuleApplyPanel extends FramedPanel {
private TextButton btnApply;
private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
private Grid<TemplateData> grid;
private ExtendedListStore<TemplateData> store;
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<RuleDescriptionData> grid;
private ExtendedListStore<RuleDescriptionData> store;
public RuleApplyPanel(RuleApplyDialog parent, TRId trId,
EventBus eventBus) {
public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
this.parent = parent;
this.trId = trId;
Log.debug("TemplateApplyPanel");
@ -102,36 +103,31 @@ public class RuleApplyPanel extends FramedPanel {
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity);
RuleDataProperties props = GWT.create(RuleDataProperties.class);
RuleDescriptionDataProperties props = GWT
.create(RuleDescriptionDataProperties.class);
ColumnConfig<TemplateData, String> nameCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>(
props.ownerLogin(), 70, "Owner");
ColumnConfig<TemplateData, String> agencyCol = new ColumnConfig<TemplateData, String>(
props.agency(), 100, "Agency");
ColumnConfig<TemplateData, String> descriptionCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
List<ColumnConfig<TemplateData, ?>> l = new ArrayList<ColumnConfig<TemplateData, ?>>();
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol);
l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
store = new ExtendedListStore<TemplateData>(props.id());
store = new ExtendedListStore<RuleDescriptionData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
@ -141,11 +137,11 @@ public class RuleApplyPanel extends FramedPanel {
}
});
store.addFilter(new StoreFilter<TemplateData>() {
store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
public boolean select(Store<RuleDescriptionData> store,
RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null)
return true;
@ -155,18 +151,19 @@ public class RuleApplyPanel extends FramedPanel {
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
public void load(
ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback);
}
};
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>(
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>(
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) {
});
@ -178,7 +175,7 @@ public class RuleApplyPanel extends FramedPanel {
btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) {
grid = new Grid<RuleDescriptionData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
@ -210,7 +207,7 @@ public class RuleApplyPanel extends FramedPanel {
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnApply = new TextButton("Apply");
btnApply.setIcon(TabularDataResources.INSTANCE.templateApply());
btnApply.setIcon(TabularDataResources.INSTANCE.ruleApply());
btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setToolTip("Apply Template");
btnApply.addSelectHandler(new SelectHandler() {
@ -252,47 +249,48 @@ public class RuleApplyPanel extends FramedPanel {
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
TDGWTServiceAsync.INSTANCE
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() {
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Load templates failure:"
Log.error("Load rules failure:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates",
"Error retrieving templates");
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving rules");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<TemplateData> result) {
Log.trace("loaded " + result.size() + " Occurences");
callback.onSuccess(new ListLoadResultBean<TemplateData>(
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result));
}
});
}
protected TemplateData getSelectedItem() {
protected RuleDescriptionData getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();
}
protected void apply() {
templateApplySession = new TemplateApplySession();
TemplateData template = getSelectedItem();
RuleDescriptionData template = getSelectedItem();
if (template == null) {
UtilsGXT3.info("Attention", "Select the template to apply");
} else {
templateApplySession.setTemplateData(getSelectedItem());
//templateApplySession.setRuleDescriptionData(getSelectedItem());
templateApplySession.setTrId(trId);
Log.debug("applyTemplateSession: " + templateApplySession);
parent.applyTemplate(templateApplySession);
@ -319,19 +317,11 @@ public class RuleApplyPanel extends FramedPanel {
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null
&& item.getName().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getCategory() != null
&& item.getCategory().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getAgency() != null
&& item.getAgency().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getDescription() != null
&& item.getDescription().toLowerCase()
.contains(searchTerm.toLowerCase()))

View File

@ -1,32 +0,0 @@
package org.gcube.portlets.user.td.client.rule;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import com.google.gwt.editor.client.Editor.Path;
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 RuleDataProperties extends PropertyAccess<TemplateData> {
@Path("id")
ModelKeyProvider<TemplateData> id();
ValueProvider<TemplateData, String> name();
ValueProvider<TemplateData, String> category();
ValueProvider<TemplateData, String> ownerLogin();
ValueProvider<TemplateData, String> agency();
ValueProvider<TemplateData, String> description();
}

View File

@ -41,11 +41,11 @@ public class RuleDeleteDialog extends Window {
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Delete Template");
setHeadingText("Delete Rule");
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(TabularDataResources.INSTANCE.templateDelete());
getHeader().setIcon(TabularDataResources.INSTANCE.ruleDelete());
}

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
@ -63,13 +65,13 @@ public class RuleDeletePanel extends FramedPanel {
private TextButton btnDelete;
private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
private Grid<TemplateData> grid;
private ExtendedListStore<TemplateData> store;
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<RuleDescriptionData> grid;
private ExtendedListStore<RuleDescriptionData> store;
public RuleDeletePanel(RuleDeleteDialog parent, EventBus eventBus) {
this.parent = parent;
Log.debug("TemplateDeletePanel");
Log.debug("RuleDeletePanel");
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
@ -92,36 +94,31 @@ public class RuleDeletePanel extends FramedPanel {
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity);
RuleDataProperties props = GWT.create(RuleDataProperties.class);
RuleDescriptionDataProperties props = GWT
.create(RuleDescriptionDataProperties.class);
ColumnConfig<TemplateData, String> nameCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>(
props.ownerLogin(), 70, "Owner");
ColumnConfig<TemplateData, String> agencyCol = new ColumnConfig<TemplateData, String>(
props.agency(), 100, "Agency");
ColumnConfig<TemplateData, String> descriptionCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
List<ColumnConfig<TemplateData, ?>> l = new ArrayList<ColumnConfig<TemplateData, ?>>();
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol);
l.add(readableExpressionCol);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l);
store = new ExtendedListStore<TemplateData>(props.id());
store = new ExtendedListStore<RuleDescriptionData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
@ -131,11 +128,11 @@ public class RuleDeletePanel extends FramedPanel {
}
});
store.addFilter(new StoreFilter<TemplateData>() {
store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
public boolean select(Store<RuleDescriptionData> store,
RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null)
return true;
@ -145,18 +142,19 @@ public class RuleDeletePanel extends FramedPanel {
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
public void load(
ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback);
}
};
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>(
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>(
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) {
});
@ -168,7 +166,7 @@ public class RuleDeletePanel extends FramedPanel {
btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) {
grid = new Grid<RuleDescriptionData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
@ -200,7 +198,7 @@ public class RuleDeletePanel extends FramedPanel {
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnDelete = new TextButton("Delete");
btnDelete.setIcon(TabularDataResources.INSTANCE.templateDelete());
btnDelete.setIcon(TabularDataResources.INSTANCE.ruleDelete());
btnDelete.setIconAlign(IconAlign.RIGHT);
btnDelete.setToolTip("Delete Template");
btnDelete.addSelectHandler(new SelectHandler() {
@ -243,33 +241,34 @@ public class RuleDeletePanel extends FramedPanel {
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
TDGWTServiceAsync.INSTANCE
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() {
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Load templates failure:"
Log.error("Load rules failure:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates",
"Error retrieving templates");
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving rules");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<TemplateData> result) {
Log.trace("loaded " + result.size() + " Occurences");
callback.onSuccess(new ListLoadResultBean<TemplateData>(
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result));
}
});
}
/*
@ -281,7 +280,7 @@ public class RuleDeletePanel extends FramedPanel {
* deleteTemplateItem.addSelectionHandler(new SelectionHandler<Item>() {
*
* @Override public void onSelection(SelectionEvent<Item> event) {
* Log.debug("Delete Template"); TemplateData templateDesc =
* Log.debug("Delete Template"); RuleDescriptionData templateDesc =
* getSelectedItem();
*
* } });
@ -289,9 +288,9 @@ public class RuleDeletePanel extends FramedPanel {
* grid.setContextMenu(contextMenu); }
*/
protected ArrayList<TemplateData> getSelectedItem() {
ArrayList<TemplateData> templates = new ArrayList<TemplateData>();
for (TemplateData template : grid.getSelectionModel()
protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData template : grid.getSelectionModel()
.getSelectedItems()) {
templates.add(template);
}
@ -300,11 +299,11 @@ public class RuleDeletePanel extends FramedPanel {
protected void delete() {
templateDeleteSession = new TemplateDeleteSession();
ArrayList<TemplateData> templates = getSelectedItem();
ArrayList<RuleDescriptionData> templates = getSelectedItem();
if (templates == null || templates.size() == 0) {
UtilsGXT3.info("Attention", "Select the template to be deleted");
} else {
templateDeleteSession.setTemplates(getSelectedItem());
// templateDeleteSession.setTemplates(getSelectedItem());
Log.debug("templateDeleteSession: " + templateDeleteSession);
parent.templatesDelete(templateDeleteSession);
@ -332,19 +331,11 @@ public class RuleDeletePanel extends FramedPanel {
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null
&& item.getName().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getCategory() != null
&& item.getCategory().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getAgency() != null
&& item.getAgency().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getDescription() != null
&& item.getDescription().toLowerCase()
.contains(searchTerm.toLowerCase()))

View File

@ -1,9 +1,7 @@
package org.gcube.portlets.user.td.client.rule;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.tdtemplate.client.TdTemplateController;
import org.gcube.portlets.user.tdtemplate.client.TdTemplateControllerUpdater;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
@ -19,10 +17,8 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
public class RuleOpenDialog extends Window {
private static final String WIDTH = "720px";
private static final String HEIGHT = "530px";
private EventBus eventBus;
public RuleOpenDialog(EventBus eventBus) {
this.eventBus = eventBus;
initWindow();
RuleOpenPanel templateOpenPanel = new RuleOpenPanel(this,
@ -35,11 +31,11 @@ public class RuleOpenDialog extends Window {
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Open Template");
setHeadingText("Open Rule");
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(TabularDataResources.INSTANCE.templateEdit());
getHeader().setIcon(TabularDataResources.INSTANCE.ruleEdit());
}
@ -63,11 +59,8 @@ public class RuleOpenDialog extends Window {
hide();
}
public void templateOpen(TemplateData template) {
TdTemplateControllerUpdater controller = new TdTemplateControllerUpdater(
template.getId());
TdTemplateController.bindCommonBus(eventBus);
controller.getWindowTemplatePanel().show();
public void ruleOpen(RuleDescriptionData ruleDescriptionData) {
close();
}

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
@ -68,13 +70,13 @@ public class RuleOpenPanel extends FramedPanel {
private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
private Grid<TemplateData> grid;
private ExtendedListStore<TemplateData> store;
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<RuleDescriptionData> grid;
private ExtendedListStore<RuleDescriptionData> store;
public RuleOpenPanel(RuleOpenDialog parent, EventBus eventBus) {
this.parent = parent;
Log.debug("TemplateEditPanel");
Log.debug("RuleOpenPanel");
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
@ -97,36 +99,31 @@ public class RuleOpenPanel extends FramedPanel {
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity);
RuleDataProperties props = GWT.create(RuleDataProperties.class);
RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class);
ColumnConfig<TemplateData, String> nameCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>(
props.ownerLogin(), 70, "Owner");
ColumnConfig<TemplateData, String> agencyCol = new ColumnConfig<TemplateData, String>(
props.agency(), 100, "Agency");
ColumnConfig<TemplateData, String> descriptionCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
List<ColumnConfig<TemplateData, ?>> l = new ArrayList<ColumnConfig<TemplateData, ?>>();
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol);
l.add(readableExpressionCol);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l);
store = new ExtendedListStore<TemplateData>(props.id());
store = new ExtendedListStore<RuleDescriptionData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
@ -136,11 +133,11 @@ public class RuleOpenPanel extends FramedPanel {
}
});
store.addFilter(new StoreFilter<TemplateData>() {
store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
public boolean select(Store<RuleDescriptionData> store,
RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null)
return true;
@ -150,18 +147,18 @@ public class RuleOpenPanel extends FramedPanel {
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback);
}
};
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>(
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>(
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) {
});
@ -173,7 +170,7 @@ public class RuleOpenPanel extends FramedPanel {
btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) {
grid = new Grid<RuleDescriptionData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
@ -205,7 +202,7 @@ public class RuleOpenPanel extends FramedPanel {
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnOpen = new TextButton("Open");
btnOpen.setIcon(TabularDataResources.INSTANCE.templateEdit());
btnOpen.setIcon(TabularDataResources.INSTANCE.ruleEdit());
btnOpen.setIconAlign(IconAlign.RIGHT);
btnOpen.setToolTip("Open");
btnOpen.addSelectHandler(new SelectHandler() {
@ -251,38 +248,41 @@ public class RuleOpenPanel extends FramedPanel {
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
TDGWTServiceAsync.INSTANCE
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Load templates failure:"
Log.error("Load rules failure:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates",
"Error retrieving templates");
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving rules");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<TemplateData> result) {
Log.trace("loaded " + result.size() + " Occurences");
callback.onSuccess(new ListLoadResultBean<TemplateData>(
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result));
}
});
}
protected ArrayList<TemplateData> getSelectedItem() {
ArrayList<TemplateData> templates = new ArrayList<TemplateData>();
for (TemplateData template : grid.getSelectionModel()
protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData template : grid.getSelectionModel()
.getSelectedItems()) {
templates.add(template);
}
@ -291,13 +291,13 @@ public class RuleOpenPanel extends FramedPanel {
protected void open() {
ArrayList<TemplateData> templates = getSelectedItem();
ArrayList<RuleDescriptionData> templates = getSelectedItem();
if (templates == null || templates.size() == 0) {
UtilsGXT3.info("Attention", "Select the template");
} else {
TemplateData template = templates.get(0);
RuleDescriptionData template = templates.get(0);
Log.debug("templateOpenSession: " + template);
parent.templateOpen(template);
parent.ruleOpen(template);
}
@ -325,19 +325,11 @@ public class RuleOpenPanel extends FramedPanel {
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null
&& item.getName().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getCategory() != null
&& item.getCategory().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getAgency() != null
&& item.getAgency().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getDescription() != null
&& item.getDescription().toLowerCase()
.contains(searchTerm.toLowerCase()))

View File

@ -36,11 +36,11 @@ public class RuleShareDialog extends Window {
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setHeadingText("Share Template");
setHeadingText("Share Rule");
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(TabularDataResources.INSTANCE.templateShare());
getHeader().setIcon(TabularDataResources.INSTANCE.ruleShare());
}

View File

@ -4,9 +4,11 @@ import java.util.ArrayList;
import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
@ -20,7 +22,7 @@ import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
@ -67,13 +69,13 @@ public class RuleSharePanel extends FramedPanel {
private TextButton btnClose;
private TextButton btnShare;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
private Grid<TemplateData> grid;
private ExtendedListStore<TemplateData> store;
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<RuleDescriptionData> grid;
private ExtendedListStore<RuleDescriptionData> store;
public RuleSharePanel(RuleShareDialog parent, EventBus eventBus) {
this.parent = parent;
Log.debug("TemplateSharePanel");
Log.debug("RuleSharePanel");
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
@ -96,36 +98,30 @@ public class RuleSharePanel extends FramedPanel {
btnReload.setToolTip("Reload");
toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>(
IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity);
RuleDataProperties props = GWT.create(RuleDataProperties.class);
RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class);
ColumnConfig<TemplateData, String> nameCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>(
props.ownerLogin(), 70, "Owner");
ColumnConfig<TemplateData, String> agencyCol = new ColumnConfig<TemplateData, String>(
props.agency(), 100, "Agency");
ColumnConfig<TemplateData, String> descriptionCol = new ColumnConfig<TemplateData, String>(
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
List<ColumnConfig<TemplateData, ?>> l = new ArrayList<ColumnConfig<TemplateData, ?>>();
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol);
l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
store = new ExtendedListStore<TemplateData>(props.id());
store = new ExtendedListStore<RuleDescriptionData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() {
@ -135,11 +131,11 @@ public class RuleSharePanel extends FramedPanel {
}
});
store.addFilter(new StoreFilter<TemplateData>() {
store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override
public boolean select(Store<TemplateData> store,
TemplateData parent, TemplateData item) {
public boolean select(Store<RuleDescriptionData> store,
RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue();
if (searchTerm == null)
return true;
@ -149,18 +145,18 @@ public class RuleSharePanel extends FramedPanel {
store.setEnableFilters(true);
RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<TemplateData>>() {
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
public void load(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback);
}
};
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>(
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy);
loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>(
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) {
});
@ -172,7 +168,7 @@ public class RuleSharePanel extends FramedPanel {
btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) {
grid = new Grid<RuleDescriptionData>(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
@ -218,7 +214,7 @@ public class RuleSharePanel extends FramedPanel {
});
btnShare = new TextButton("Share");
btnShare.setIcon(TabularDataResources.INSTANCE.share());
btnShare.setIcon(TabularDataResources.INSTANCE.ruleShare());
btnShare.setIconAlign(IconAlign.RIGHT);
btnShare.setToolTip("Share");
btnShare.addSelectHandler(new SelectHandler() {
@ -248,40 +244,42 @@ public class RuleSharePanel extends FramedPanel {
}
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) {
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
TDGWTServiceAsync.INSTANCE
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() {
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.error("Load templates failure:"
Log.error("Load rules failure:"
+ caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates",
"Error retrieving templates");
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving rules");
}
callback.onFailure(caught);
}
public void onSuccess(ArrayList<TemplateData> result) {
Log.trace("loaded " + result.size() + " Occurences");
callback.onSuccess(new ListLoadResultBean<TemplateData>(
@Override
public void onSuccess(ArrayList<RuleDescriptionData> result) {
Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result));
}
});
}
protected ArrayList<TemplateData> getSelectedItem() {
ArrayList<TemplateData> templates = new ArrayList<TemplateData>();
for (TemplateData template : grid.getSelectionModel()
protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData template : grid.getSelectionModel()
.getSelectedItems()) {
templates.add(template);
}
@ -291,13 +289,13 @@ public class RuleSharePanel extends FramedPanel {
protected void share() {
ArrayList<TemplateData> templates = getSelectedItem();
ArrayList<RuleDescriptionData> templates = getSelectedItem();
if (templates == null || templates.size() == 0) {
UtilsGXT3.info("Attention", "Select the template");
} else {
TemplateData template = templates.get(0);
RuleDescriptionData template = templates.get(0);
Log.debug("templateShare: " + template);
parent.templateShare(template);
//parent.templateShare(template);
}
@ -323,19 +321,11 @@ public class RuleSharePanel extends FramedPanel {
grid.getLoader().load();
}
protected boolean select(TemplateData item, String searchTerm) {
protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null
&& item.getName().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getCategory() != null
&& item.getCategory().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getAgency() != null
&& item.getAgency().toLowerCase()
.contains(searchTerm.toLowerCase()))
return true;
if (item.getDescription() != null
&& item.getDescription().toLowerCase()
.contains(searchTerm.toLowerCase()))