diff --git a/.classpath b/.classpath
index 3ca16a7..643df01 100644
--- a/.classpath
+++ b/.classpath
@@ -1,12 +1,12 @@
-
+
-
+
@@ -33,5 +33,5 @@
-
+
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
index 8677dd4..197bdb5 100644
--- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
+++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionCard.java
@@ -91,7 +91,7 @@ public class TabResourcesSelectionCard extends WizardCard {
d.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
- removeTRWithLastTableNull();
+ deleteTRWithLastTableNull();
}
});
@@ -109,14 +109,14 @@ public class TabResourcesSelectionCard extends WizardCard {
}
- protected void removeTRWithLastTableNull() {
- final ConfirmMessageBox mb = new ConfirmMessageBox("Remove",
- "Would you like to remove this tabular resource without table?");
+ protected void deleteTRWithLastTableNull() {
+ final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
+ "Would you like to delete this tabular resource without table?");
mb.addHideHandler(new HideHandler() {
public void onHide(HideEvent event) {
if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
.name())) {
- callRemoveLastTable();
+ callDeleteLastTable();
} else if (mb.getHideButton() == mb
.getButtonById(PredefinedButton.NO.name())) {
// perform NO action
@@ -128,8 +128,8 @@ public class TabResourcesSelectionCard extends WizardCard {
}
- protected void callRemoveLastTable(){
- Log.debug("Remove TR:" + tdOpenSession
+ protected void callDeleteLastTable(){
+ Log.debug("Delete TR:" + tdOpenSession
.getSelectedTabResource().getTrId());
TDGWTServiceAsync.INSTANCE.removeTabularResource(tdOpenSession
.getSelectedTabResource().getTrId(),
@@ -137,7 +137,7 @@ public class TabResourcesSelectionCard extends WizardCard {
public void onFailure(Throwable caught) {
AlertMessageBox d = new AlertMessageBox("Error",
- "Error on remove TabResource: "
+ "Error on delete TabResource: "
+ caught.getLocalizedMessage());
d.addHideHandler(new HideHandler() {
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
index ffefd21..d1f0537 100644
--- a/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
+++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/TabResourcesSelectionPanel.java
@@ -7,9 +7,10 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
-import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
+import org.gcube.portlets.user.td.openwidget.client.resources.ResourceBundleTDOpen;
+import org.gcube.portlets.user.td.wizardwidget.client.dataresource.ResourceBundle;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
@@ -18,6 +19,7 @@ import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler;
import com.google.gwt.event.logical.shared.HasSelectionHandlers;
+import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -34,110 +36,131 @@ import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
import com.sencha.gxt.widget.core.client.ContentPanel;
+import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
import com.sencha.gxt.widget.core.client.Resizable;
import com.sencha.gxt.widget.core.client.Resizable.Dir;
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
+import com.sencha.gxt.widget.core.client.box.ConfirmMessageBox;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.HideEvent;
-import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
+import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
import com.sencha.gxt.widget.core.client.grid.Grid;
+import com.sencha.gxt.widget.core.client.menu.Item;
+import com.sencha.gxt.widget.core.client.menu.Menu;
+import com.sencha.gxt.widget.core.client.menu.MenuItem;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
/**
*
- * @author "Giancarlo Panichi"
- * g.panichi@isti.cnr.it
- *
+ * @author "Giancarlo Panichi" g.panichi@isti.cnr.it
+ *
*/
-public class TabResourcesSelectionPanel extends ContentPanel implements HasSelectionHandlers {
+public class TabResourcesSelectionPanel extends ContentPanel implements
+ HasSelectionHandlers {
+
+ private static final TabResourcesProperties properties = GWT
+ .create(TabResourcesProperties.class);
+
+ protected static final ColumnConfig nameColumn = new ColumnConfig(
+ properties.name(), 90, "Name");
+ protected static final ColumnConfig typeColumn = new ColumnConfig(
+ properties.tabularResourceType(), 30, "Type");
+ protected static final ColumnConfig agencyColumn = new ColumnConfig(
+ properties.agency(), 60, "Agency");
+ protected static final ColumnConfig dateColumn = new ColumnConfig(
+ properties.date(), 40, "Date");
-
- private static final TabResourcesProperties properties = GWT.create(TabResourcesProperties.class);
-
- protected static final ColumnConfig nameColumn = new ColumnConfig(properties.name(), 90, "Name");
- protected static final ColumnConfig typeColumn = new ColumnConfig(properties.tabularResourceType(), 30, "Type");
- protected static final ColumnConfig agencyColumn = new ColumnConfig(properties.agency(), 60, "Agency");
- protected static final ColumnConfig dateColumn = new ColumnConfig(properties.date(), 40, "Date");
-
-
-
protected Grid grid;
protected ResourceBundle res;
-
-
-
- public TabResourcesSelectionPanel(ResourceBundle res)
- {
- this.res=res;
- setHeaderVisible(false);
- new Resizable(this, Dir.E, Dir.SE, Dir.S);
- buildPanel(properties.id(), Arrays.>asList(nameColumn, typeColumn, agencyColumn, dateColumn), nameColumn);
+ protected Menu contextMenu;
+
+ private TabResource removableTR;
+
+ public TabResourcesSelectionPanel(ResourceBundle res) {
+ this.res = res;
+ init();
+ createContextMenu();
+ buildPanel(properties.id(),
+ Arrays.> asList(nameColumn,
+ typeColumn, agencyColumn, dateColumn), nameColumn);
}
-
- protected void buildPanel(ModelKeyProvider keyProvider, List> columns, ColumnConfig autoexpandColumn)
- {
+ protected void init(){
+ setHeaderVisible(false);
+ new Resizable(this, Dir.E, Dir.SE, Dir.S);
+
+ }
+
+ protected void buildPanel(ModelKeyProvider keyProvider,
+ List> columns,
+ ColumnConfig autoexpandColumn) {
ToolBar toolBar = new ToolBar();
toolBar.add(new LabelToolItem("Search: "));
final TextField searchField = new TextField();
toolBar.add(searchField);
-
+
TextButton btnReload = new TextButton();
- //btnReload.setText("Reload");
+ // btnReload.setText("Reload");
btnReload.setIcon(res.refresh16());
btnReload.setToolTip("Reload");
toolBar.add(btnReload);
-
-
+
IdentityValueProvider identity = new IdentityValueProvider();
- final CheckBoxSelectionModel sm = new CheckBoxSelectionModel(identity);
-
+ final CheckBoxSelectionModel sm = new CheckBoxSelectionModel(
+ identity);
+
ColumnModel cm = new ColumnModel(columns);
- final ExtendedListStore store = new ExtendedListStore(keyProvider);
+ final ExtendedListStore store = new ExtendedListStore(
+ keyProvider);
searchField.addKeyUpHandler(new KeyUpHandler() {
public void onKeyUp(KeyUpEvent event) {
- Log.trace("searchTerm: "+searchField.getCurrentValue());
- store.applyFilters();
+ Log.trace("searchTerm: " + searchField.getCurrentValue());
+ store.applyFilters();
}
});
-
+
store.addFilter(new StoreFilter() {
- public boolean select(Store store, TabResource parent, TabResource item) {
+ public boolean select(Store store, TabResource parent,
+ TabResource item) {
String searchTerm = searchField.getCurrentValue();
- if (searchTerm == null) return true;
+ if (searchTerm == null)
+ return true;
return TabResourcesSelectionPanel.this.select(item, searchTerm);
}
});
store.setEnableFilters(true);
- RpcProxy> proxy = new RpcProxy>() {
+ RpcProxy> proxy = new RpcProxy>() {
-
- public void load(ListLoadConfig loadConfig, final AsyncCallback> callback) {
+ public void load(ListLoadConfig loadConfig,
+ final AsyncCallback> callback) {
loadData(loadConfig, callback);
- }
+ }
};
- final ListLoader> loader = new ListLoader>(proxy);
+ final ListLoader> loader = new ListLoader>(
+ proxy);
loader.setRemoteSort(false);
- loader.addLoadHandler(new LoadResultListStoreBinding>(store));
+ loader.addLoadHandler(new LoadResultListStoreBinding>(
+ store));
- grid = new Grid(store, cm){
+ grid = new Grid(store, cm) {
@Override
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
@@ -148,8 +171,8 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
});
}
};
-
- sm.setSelectionMode(SelectionMode.SINGLE);
+
+ sm.setSelectionMode(SelectionMode.SINGLE);
grid.setLoader(loader);
grid.setSelectionModel(sm);
grid.getView().setAutoExpandColumn(autoexpandColumn);
@@ -159,87 +182,170 @@ public class TabResourcesSelectionPanel extends ContentPanel implements HasSelec
grid.setBorders(false);
grid.setLoadMask(true);
grid.setColumnReordering(true);
-
-
+
SelectHandler sh = new SelectHandler() {
public void onSelect(SelectEvent event) {
loader.load();
}
};
-
+
btnReload.addSelectHandler(sh);
+ if (contextMenu != null) {
+ grid.setContextMenu(contextMenu);
+ } else
+ grid.setContextMenu(null);
+
+
VerticalLayoutContainer con = new VerticalLayoutContainer();
con.add(toolBar, new VerticalLayoutData(1, -1));
con.add(grid, new VerticalLayoutData(1, 1));
setWidget(con);
}
-
-
-
+
+ protected void createContextMenu() {
+ MenuItem deleteTRItem = new MenuItem("Delete");
+ deleteTRItem.setId("DeleteTR");
+ deleteTRItem.setIcon(ResourceBundleTDOpen.INSTANCE.delete());
+ deleteTRItem.addSelectionHandler(new SelectionHandler- () {
+
+ @Override
+ public void onSelection(SelectionEvent
- event) {
+ if (grid != null) {
+ TabResource tabResource= getSelectedItem();
+ deleteTR(tabResource);
+ }
+
+ }
+ });
+ contextMenu.add(deleteTRItem);
+
+ }
+
protected boolean select(TabResource item, String searchTerm) {
- if (item.getName()!=null && item.getName().toLowerCase().contains(searchTerm.toLowerCase())) return true;
- if (item.getTabularResourceType()!=null &&item.getTabularResourceType().toLowerCase().contains(searchTerm.toLowerCase())) return true;
- if (item.getAgency()!=null &&item.getAgency().toLowerCase().contains(searchTerm.toLowerCase())) return true;
- if (item.getDate()!=null && item.getDate().toLowerCase().contains(searchTerm.toLowerCase())) return true;
+ if (item.getName() != null
+ && item.getName().toLowerCase()
+ .contains(searchTerm.toLowerCase()))
+ return true;
+ if (item.getTabularResourceType() != null
+ && item.getTabularResourceType().toLowerCase()
+ .contains(searchTerm.toLowerCase()))
+ return true;
+ if (item.getAgency() != null
+ && item.getAgency().toLowerCase()
+ .contains(searchTerm.toLowerCase()))
+ return true;
+ if (item.getDate() != null
+ && item.getDate().toLowerCase()
+ .contains(searchTerm.toLowerCase()))
+ return true;
return false;
}
-
- protected void loadData(ListLoadConfig loadConfig, final AsyncCallback> callback) {
- TDGWTServiceAsync.INSTANCE.getTabularResources(new AsyncCallback>() {
+ protected void loadData(ListLoadConfig loadConfig,
+ final AsyncCallback> callback) {
+ TDGWTServiceAsync.INSTANCE
+ .getTabularResources(new AsyncCallback>() {
- public void onFailure(Throwable caught) {
- Log.debug("Error retriving tabular resource: "+caught.getLocalizedMessage());
- callback.onFailure(caught);
- AlertMessageBox d = new AlertMessageBox("Error!",
- "Error retrieving tabular resources on server!");
- d.addHideHandler(new HideHandler() {
+ public void onFailure(Throwable caught) {
+ Log.debug("Error retrieving tabular resource: "
+ + caught.getLocalizedMessage());
+ callback.onFailure(caught);
+ AlertMessageBox d = new AlertMessageBox("Error!",
+ "Error retrieving tabular resources on server!");
+ d.addHideHandler(new HideHandler() {
- public void onHide(HideEvent event) {
- //
+ public void onHide(HideEvent event) {
+ //
+ }
+
+ });
+ d.show();
}
+ public void onSuccess(ArrayList result) {
+ Log.debug("loaded " + result.size()
+ + " TabularResources");
+ /*
+ * for(TabResource tr:result){ Log.debug("TR:"+tr); }
+ */
+ callback.onSuccess(new ListLoadResultBean(
+ result));
+ }
});
- d.show();
- }
-
- public void onSuccess(ArrayList result) {
- Log.debug("loaded "+result.size()+" TabularResources");
- /*for(TabResource tr:result){
- Log.debug("TR:"+tr);
- }*/
- callback.onSuccess(new ListLoadResultBean(result));
- }
- });
}
-
- public HandlerRegistration addSelectionHandler(SelectionHandler handler) {
+ public HandlerRegistration addSelectionHandler(
+ SelectionHandler handler) {
return grid.getSelectionModel().addSelectionHandler(handler);
}
-
+
public TabResource getSelectedItem() {
return grid.getSelectionModel().getSelectedItem();
}
-
+
protected class ExtendedListStore extends ListStore {
public ExtendedListStore(ModelKeyProvider super M> keyProvider) {
super(keyProvider);
}
- public void applyFilters()
- {
+ public void applyFilters() {
super.applyFilters();
}
}
-
- public void gridReload(){
+
+ public void gridReload() {
grid.getLoader().load();
}
+
+ protected void deleteTR(TabResource tabResource) {
+ removableTR=tabResource;
+ final ConfirmMessageBox mb = new ConfirmMessageBox("Delete",
+ "Would you like to delete this tabular resource?");
+ mb.addHideHandler(new HideHandler() {
+ public void onHide(HideEvent event) {
+ if (mb.getHideButton() == mb.getButtonById(PredefinedButton.YES
+ .name())) {
+ callDeleteTabularResource();
+ } else if (mb.getHideButton() == mb
+ .getButtonById(PredefinedButton.NO.name())) {
+ // perform NO action
+ }
+ }
+ });
+ mb.setWidth(300);
+ mb.show();
+
+ }
+ protected void callDeleteTabularResource() {
+ Log.debug("Delete TR:" + removableTR);
+ TDGWTServiceAsync.INSTANCE.removeTabularResource(removableTR.getTrId(),
+ new AsyncCallback() {
+
+ public void onFailure(Throwable caught) {
+ AlertMessageBox d = new AlertMessageBox("Error",
+ "Error on delete TabResource: "
+ + caught.getLocalizedMessage());
+ d.addHideHandler(new HideHandler() {
+
+ public void onHide(HideEvent event) {
+ // TODO Auto-generated method stub
+
+ }
+ });
+ d.show();
+
+ }
+
+ public void onSuccess(Void result) {
+ gridReload();
+ }
+
+ });
+ }
}
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java
new file mode 100644
index 0000000..a2e13b4
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/ResourceBundleTDOpen.java
@@ -0,0 +1,24 @@
+package org.gcube.portlets.user.td.openwidget.client.resources;
+
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.resources.client.ClientBundle;
+import com.google.gwt.resources.client.ImageResource;
+
+/**
+ *
+ * @author "Giancarlo Panichi"
+ * g.panichi@isti.cnr.it
+ *
+ */
+public interface ResourceBundleTDOpen extends ClientBundle {
+
+ public static final ResourceBundleTDOpen INSTANCE=GWT.create(ResourceBundleTDOpen.class);
+
+
+ @Source("delete.png")
+ ImageResource delete();
+
+ @Source("delete32.png")
+ ImageResource delete32();
+
+}
\ No newline at end of file
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete.png b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete.png
new file mode 100644
index 0000000..b639afd
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete.png differ
diff --git a/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png
new file mode 100644
index 0000000..020b555
Binary files /dev/null and b/src/main/java/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png differ
diff --git a/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete.png b/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete.png
new file mode 100644
index 0000000..b639afd
Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete.png differ
diff --git a/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png b/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png
new file mode 100644
index 0000000..020b555
Binary files /dev/null and b/src/main/resources/org/gcube/portlets/user/td/openwidget/client/resources/delete_32.png differ