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); setClosable(true);
setModal(true); setModal(true);
forceLayoutOnResize = 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 java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; 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.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession; 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.tablewidget.client.util.UtilsGXT3;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
@ -71,12 +73,11 @@ public class RuleApplyPanel extends FramedPanel {
private TextButton btnApply; private TextButton btnApply;
private TextButton btnClose; private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader; private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<TemplateData> grid; private Grid<RuleDescriptionData> grid;
private ExtendedListStore<TemplateData> store; private ExtendedListStore<RuleDescriptionData> store;
public RuleApplyPanel(RuleApplyDialog parent, TRId trId, public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
EventBus eventBus) {
this.parent = parent; this.parent = parent;
this.trId = trId; this.trId = trId;
Log.debug("TemplateApplyPanel"); Log.debug("TemplateApplyPanel");
@ -102,36 +103,31 @@ public class RuleApplyPanel extends FramedPanel {
btnReload.setToolTip("Reload"); btnReload.setToolTip("Reload");
toolBarHead.add(btnReload); toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>(); IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>( CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity); 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"); props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>( ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, 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>(
props.description(), 120, "Description"); 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(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l); store = new ExtendedListStore<RuleDescriptionData>(props.id());
store = new ExtendedListStore<TemplateData>(props.id());
searchField.addKeyUpHandler(new KeyUpHandler() { searchField.addKeyUpHandler(new KeyUpHandler() {
@ -141,11 +137,11 @@ public class RuleApplyPanel extends FramedPanel {
} }
}); });
store.addFilter(new StoreFilter<TemplateData>() { store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override @Override
public boolean select(Store<TemplateData> store, public boolean select(Store<RuleDescriptionData> store,
TemplateData parent, TemplateData item) { RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue(); String searchTerm = searchField.getCurrentValue();
if (searchTerm == null) if (searchTerm == null)
return true; return true;
@ -155,18 +151,19 @@ public class RuleApplyPanel extends FramedPanel {
store.setEnableFilters(true); 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, public void load(
final AsyncCallback<ListLoadResult<TemplateData>> callback) { ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback); loadData(loadConfig, callback);
} }
}; };
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>( loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy); proxy);
loader.setRemoteSort(false); loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>( loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) { store) {
}); });
@ -178,7 +175,7 @@ public class RuleApplyPanel extends FramedPanel {
btnReload.addSelectHandler(sh); btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) { grid = new Grid<RuleDescriptionData>(store, cm) {
@Override @Override
protected void onAfterFirstAttach() { protected void onAfterFirstAttach() {
super.onAfterFirstAttach(); super.onAfterFirstAttach();
@ -210,7 +207,7 @@ public class RuleApplyPanel extends FramedPanel {
toolBar.getElement().getStyle().setProperty("borderBottom", "none"); toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnApply = new TextButton("Apply"); btnApply = new TextButton("Apply");
btnApply.setIcon(TabularDataResources.INSTANCE.templateApply()); btnApply.setIcon(TabularDataResources.INSTANCE.ruleApply());
btnApply.setIconAlign(IconAlign.RIGHT); btnApply.setIconAlign(IconAlign.RIGHT);
btnApply.setToolTip("Apply Template"); btnApply.setToolTip("Apply Template");
btnApply.addSelectHandler(new SelectHandler() { btnApply.addSelectHandler(new SelectHandler() {
@ -252,47 +249,48 @@ public class RuleApplyPanel extends FramedPanel {
} }
protected void loadData(ListLoadConfig loadConfig, protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) { final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
TDGWTServiceAsync.INSTANCE ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() { new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) { if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Load templates failure:" Log.error("Load rules failure:"
+ caught.getLocalizedMessage()); + caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates", UtilsGXT3.alert("Error retrieving rules",
"Error retrieving templates"); "Error retrieving rules");
} }
callback.onFailure(caught); callback.onFailure(caught);
} }
public void onSuccess(ArrayList<TemplateData> result) { @Override
Log.trace("loaded " + result.size() + " Occurences"); public void onSuccess(ArrayList<RuleDescriptionData> result) {
callback.onSuccess(new ListLoadResultBean<TemplateData>( Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result)); result));
} }
}); });
} }
protected RuleDescriptionData getSelectedItem() {
protected TemplateData getSelectedItem() {
return grid.getSelectionModel().getSelectedItem(); return grid.getSelectionModel().getSelectedItem();
} }
protected void apply() { protected void apply() {
templateApplySession = new TemplateApplySession(); templateApplySession = new TemplateApplySession();
TemplateData template = getSelectedItem(); RuleDescriptionData template = getSelectedItem();
if (template == null) { if (template == null) {
UtilsGXT3.info("Attention", "Select the template to apply"); UtilsGXT3.info("Attention", "Select the template to apply");
} else { } else {
templateApplySession.setTemplateData(getSelectedItem()); //templateApplySession.setRuleDescriptionData(getSelectedItem());
templateApplySession.setTrId(trId); templateApplySession.setTrId(trId);
Log.debug("applyTemplateSession: " + templateApplySession); Log.debug("applyTemplateSession: " + templateApplySession);
parent.applyTemplate(templateApplySession); parent.applyTemplate(templateApplySession);
@ -319,19 +317,11 @@ public class RuleApplyPanel extends FramedPanel {
grid.getLoader().load(); grid.getLoader().load();
} }
protected boolean select(TemplateData item, String searchTerm) { protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null if (item.getName() != null
&& item.getName().toLowerCase() && item.getName().toLowerCase()
.contains(searchTerm.toLowerCase())) .contains(searchTerm.toLowerCase()))
return true; 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 if (item.getDescription() != null
&& item.getDescription().toLowerCase() && item.getDescription().toLowerCase()
.contains(searchTerm.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); setHeight(HEIGHT);
setBodyBorder(false); setBodyBorder(false);
setResizable(false); setResizable(false);
setHeadingText("Delete Template"); setHeadingText("Delete Rule");
setClosable(true); setClosable(true);
setModal(true); setModal(true);
forceLayoutOnResize = 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 java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; 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.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.gwtservice.shared.template.TemplateDeleteSession;
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; 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.event.SessionExpiredEvent;
@ -63,13 +65,13 @@ public class RuleDeletePanel extends FramedPanel {
private TextButton btnDelete; private TextButton btnDelete;
private TextButton btnClose; private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader; private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<TemplateData> grid; private Grid<RuleDescriptionData> grid;
private ExtendedListStore<TemplateData> store; private ExtendedListStore<RuleDescriptionData> store;
public RuleDeletePanel(RuleDeleteDialog parent, EventBus eventBus) { public RuleDeletePanel(RuleDeleteDialog parent, EventBus eventBus) {
this.parent = parent; this.parent = parent;
Log.debug("TemplateDeletePanel"); Log.debug("RuleDeletePanel");
setWidth(WIDTH); setWidth(WIDTH);
setHeight(HEIGHT); setHeight(HEIGHT);
setHeaderVisible(false); setHeaderVisible(false);
@ -92,36 +94,31 @@ public class RuleDeletePanel extends FramedPanel {
btnReload.setToolTip("Reload"); btnReload.setToolTip("Reload");
toolBarHead.add(btnReload); toolBarHead.add(btnReload);
IdentityValueProvider<TemplateData> identity = new IdentityValueProvider<TemplateData>(); IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
CheckBoxSelectionModel<TemplateData> sm = new CheckBoxSelectionModel<TemplateData>( CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity); 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"); props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
ColumnConfig<TemplateData, String> ownerCol = new ColumnConfig<TemplateData, String>( ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, 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>(
props.description(), 120, "Description"); 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(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(descriptionCol); 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() { searchField.addKeyUpHandler(new KeyUpHandler() {
@ -131,11 +128,11 @@ public class RuleDeletePanel extends FramedPanel {
} }
}); });
store.addFilter(new StoreFilter<TemplateData>() { store.addFilter(new StoreFilter<RuleDescriptionData>() {
@Override @Override
public boolean select(Store<TemplateData> store, public boolean select(Store<RuleDescriptionData> store,
TemplateData parent, TemplateData item) { RuleDescriptionData parent, RuleDescriptionData item) {
String searchTerm = searchField.getCurrentValue(); String searchTerm = searchField.getCurrentValue();
if (searchTerm == null) if (searchTerm == null)
return true; return true;
@ -145,18 +142,19 @@ public class RuleDeletePanel extends FramedPanel {
store.setEnableFilters(true); 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, public void load(
final AsyncCallback<ListLoadResult<TemplateData>> callback) { ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback); loadData(loadConfig, callback);
} }
}; };
loader = new ListLoader<ListLoadConfig, ListLoadResult<TemplateData>>( loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
proxy); proxy);
loader.setRemoteSort(false); loader.setRemoteSort(false);
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, TemplateData, ListLoadResult<TemplateData>>( loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
store) { store) {
}); });
@ -168,7 +166,7 @@ public class RuleDeletePanel extends FramedPanel {
btnReload.addSelectHandler(sh); btnReload.addSelectHandler(sh);
grid = new Grid<TemplateData>(store, cm) { grid = new Grid<RuleDescriptionData>(store, cm) {
@Override @Override
protected void onAfterFirstAttach() { protected void onAfterFirstAttach() {
super.onAfterFirstAttach(); super.onAfterFirstAttach();
@ -200,7 +198,7 @@ public class RuleDeletePanel extends FramedPanel {
toolBar.getElement().getStyle().setProperty("borderBottom", "none"); toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnDelete = new TextButton("Delete"); btnDelete = new TextButton("Delete");
btnDelete.setIcon(TabularDataResources.INSTANCE.templateDelete()); btnDelete.setIcon(TabularDataResources.INSTANCE.ruleDelete());
btnDelete.setIconAlign(IconAlign.RIGHT); btnDelete.setIconAlign(IconAlign.RIGHT);
btnDelete.setToolTip("Delete Template"); btnDelete.setToolTip("Delete Template");
btnDelete.addSelectHandler(new SelectHandler() { btnDelete.addSelectHandler(new SelectHandler() {
@ -243,33 +241,34 @@ public class RuleDeletePanel extends FramedPanel {
} }
protected void loadData(ListLoadConfig loadConfig, protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<TemplateData>> callback) { final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
TDGWTServiceAsync.INSTANCE ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
.getTemplates(new AsyncCallback<ArrayList<TemplateData>>() { new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) { if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent( eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER)); SessionExpiredType.EXPIREDONSERVER));
} else { } else {
Log.error("Load templates failure:" Log.error("Load rules failure:"
+ caught.getLocalizedMessage()); + caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving templates", UtilsGXT3.alert("Error retrieving rules",
"Error retrieving templates"); "Error retrieving rules");
} }
callback.onFailure(caught); callback.onFailure(caught);
} }
public void onSuccess(ArrayList<TemplateData> result) { @Override
Log.trace("loaded " + result.size() + " Occurences"); public void onSuccess(ArrayList<RuleDescriptionData> result) {
callback.onSuccess(new ListLoadResultBean<TemplateData>( Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result)); result));
} }
}); });
} }
/* /*
@ -281,7 +280,7 @@ public class RuleDeletePanel extends FramedPanel {
* deleteTemplateItem.addSelectionHandler(new SelectionHandler<Item>() { * deleteTemplateItem.addSelectionHandler(new SelectionHandler<Item>() {
* *
* @Override public void onSelection(SelectionEvent<Item> event) { * @Override public void onSelection(SelectionEvent<Item> event) {
* Log.debug("Delete Template"); TemplateData templateDesc = * Log.debug("Delete Template"); RuleDescriptionData templateDesc =
* getSelectedItem(); * getSelectedItem();
* *
* } }); * } });
@ -289,9 +288,9 @@ public class RuleDeletePanel extends FramedPanel {
* grid.setContextMenu(contextMenu); } * grid.setContextMenu(contextMenu); }
*/ */
protected ArrayList<TemplateData> getSelectedItem() { protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<TemplateData> templates = new ArrayList<TemplateData>(); ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
for (TemplateData template : grid.getSelectionModel() for (RuleDescriptionData template : grid.getSelectionModel()
.getSelectedItems()) { .getSelectedItems()) {
templates.add(template); templates.add(template);
} }
@ -300,11 +299,11 @@ public class RuleDeletePanel extends FramedPanel {
protected void delete() { protected void delete() {
templateDeleteSession = new TemplateDeleteSession(); templateDeleteSession = new TemplateDeleteSession();
ArrayList<TemplateData> templates = getSelectedItem(); ArrayList<RuleDescriptionData> templates = getSelectedItem();
if (templates == null || templates.size() == 0) { if (templates == null || templates.size() == 0) {
UtilsGXT3.info("Attention", "Select the template to be deleted"); UtilsGXT3.info("Attention", "Select the template to be deleted");
} else { } else {
templateDeleteSession.setTemplates(getSelectedItem()); // templateDeleteSession.setTemplates(getSelectedItem());
Log.debug("templateDeleteSession: " + templateDeleteSession); Log.debug("templateDeleteSession: " + templateDeleteSession);
parent.templatesDelete(templateDeleteSession); parent.templatesDelete(templateDeleteSession);
@ -332,19 +331,11 @@ public class RuleDeletePanel extends FramedPanel {
grid.getLoader().load(); grid.getLoader().load();
} }
protected boolean select(TemplateData item, String searchTerm) { protected boolean select(RuleDescriptionData item, String searchTerm) {
if (item.getName() != null if (item.getName() != null
&& item.getName().toLowerCase() && item.getName().toLowerCase()
.contains(searchTerm.toLowerCase())) .contains(searchTerm.toLowerCase()))
return true; 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 if (item.getDescription() != null
&& item.getDescription().toLowerCase() && item.getDescription().toLowerCase()
.contains(searchTerm.toLowerCase())) .contains(searchTerm.toLowerCase()))

View File

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

View File

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

View File

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