Added Delete Column Dialog
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@91291 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
e5cf7429bf
commit
2c90f094f9
|
@ -0,0 +1,42 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
|
||||
/**
|
||||
* Delete Column Dialog
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DeleteColumnDialog extends Window {
|
||||
protected int WIDTH=400;
|
||||
protected int HEIGHT=120;
|
||||
protected TRId trId;
|
||||
protected ComboBox<ColumnData> combo = null;
|
||||
protected String columnName = null;
|
||||
protected EventBus eventBus;
|
||||
|
||||
public DeleteColumnDialog(TRId trId, EventBus eventBus) {
|
||||
create(trId, null, eventBus);
|
||||
}
|
||||
|
||||
public DeleteColumnDialog(TRId trId, String columnName, EventBus eventBus) {
|
||||
create(trId, columnName, eventBus);
|
||||
}
|
||||
|
||||
protected void create(TRId trId, String columnName, EventBus eventBus) {
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
this.eventBus=eventBus;
|
||||
setBodyBorder(false);
|
||||
|
||||
DeleteColumnPanel deleteColumnPanel= new DeleteColumnPanel(trId, columnName, eventBus);
|
||||
add(deleteColumnPanel);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,272 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.progress.DeleteColumnProgressDialog;
|
||||
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadConfigBean;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||
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.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
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.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.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
/**
|
||||
*
|
||||
* ChangeColumnTypePanel is the panel for change column type
|
||||
*
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DeleteColumnPanel extends FramedPanel {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected EventBus eventBus;
|
||||
protected ChangeColumnTypeDialog parent;
|
||||
protected TextField label = null;
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
protected ColumnData column;
|
||||
protected ComboBox<ColumnData> comboColumn = null;
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||
|
||||
protected TextButton delete;
|
||||
|
||||
protected DeleteColumnSession deleteColumnSession;
|
||||
protected DeleteColumnProgressDialog deleteColumnProgressDialog;
|
||||
|
||||
public DeleteColumnPanel(TRId trId, String columnName, EventBus eventBus) {
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
this.eventBus = eventBus;
|
||||
Log.debug("Create DeleteColumnPanel(): [" + trId.toString()
|
||||
+ " columnName: " + columnName + "]");
|
||||
|
||||
// Column Data
|
||||
ColumnDataProperties propsColumnData = GWT
|
||||
.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> storeCombo = new ListStore<ColumnData>(
|
||||
propsColumnData.id());
|
||||
|
||||
Log.trace("StoreCombo created");
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||
proxy) {
|
||||
@Override
|
||||
protected ListLoadConfig newLoadConfig() {
|
||||
return (ListLoadConfig) new ListLoadConfigBean();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||
storeCombo));
|
||||
Log.trace("LoaderCombo created");
|
||||
|
||||
comboColumn = new ComboBox<ColumnData>(storeCombo,
|
||||
propsColumnData.label()) {
|
||||
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
public void execute() {
|
||||
loader.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Log.trace("Combo ColumnData created");
|
||||
|
||||
addHandlersForComboColumn(propsColumnData.label());
|
||||
|
||||
comboColumn.setLoader(loader);
|
||||
comboColumn.setEmptyText("Select a column...");
|
||||
comboColumn.setWidth(150);
|
||||
comboColumn.setTypeAhead(false);
|
||||
comboColumn.setEditable(false);
|
||||
comboColumn.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
|
||||
delete=new TextButton("Delete");
|
||||
delete.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
onDeleteColumn();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
v.add(new FieldLabel(comboColumn, "Column"), new VerticalLayoutData(1,
|
||||
-1));
|
||||
v.add(delete, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0)));
|
||||
add(v, new VerticalLayoutData(-1, -1, new Margins()));
|
||||
|
||||
}
|
||||
|
||||
protected void addHandlersForComboColumn(
|
||||
final LabelProvider<ColumnData> labelProvider) {
|
||||
comboColumn.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||
Info.display(
|
||||
"Column Type Selected",
|
||||
"You selected "
|
||||
+ (event.getSelectedItem() == null ? "nothing"
|
||||
: labelProvider.getLabel(event
|
||||
.getSelectedItem()) + "!"));
|
||||
Log.debug("ComboColumn selected: " + event.getSelectedItem());
|
||||
ColumnData columnData = event.getSelectedItem();
|
||||
updateComboStatus(columnData);
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("load combo failure:"
|
||||
+ caught.getLocalizedMessage());
|
||||
AlertMessageBox d = new AlertMessageBox("Error",
|
||||
"Error retrieving columns of tabular resource:"
|
||||
+ trId.getId());
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.trace("loaded " + result.size() + " ColumnData");
|
||||
setComboStatus(result);
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||
result));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void setComboStatus(ArrayList<ColumnData> result) {
|
||||
Log.debug("ColumnName:" + columnName);
|
||||
if (columnName != null) {
|
||||
for (ColumnData cd : result) {
|
||||
Log.debug("ColumnData name:" + cd.getName());
|
||||
if (cd.getName().compareTo(columnName) == 0) {
|
||||
updateComboStatus(cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void updateComboStatus(ColumnData cd) {
|
||||
Log.debug("ColumnData: " + cd.toString());
|
||||
deleteColumnSession = new DeleteColumnSession();
|
||||
deleteColumnSession.setColumnData(cd);
|
||||
comboColumn.setValue(cd);
|
||||
}
|
||||
|
||||
public void update(TRId trId, String columnName) {
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
loader.load();
|
||||
}
|
||||
|
||||
protected void onDeleteColumn() {
|
||||
|
||||
ColumnData columnData = comboColumn.getCurrentValue();
|
||||
if(columnData!=null){
|
||||
callDeleteColumn();
|
||||
} else {
|
||||
alert("Attention", "Select a column!");
|
||||
}
|
||||
}
|
||||
|
||||
private void callDeleteColumn() {
|
||||
TDGWTServiceAsync.INSTANCE.startDeleteColumn(
|
||||
deleteColumnSession, new AsyncCallback<Void>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.debug("Delete Column Type Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
alert("Delete Column Type Error ",
|
||||
"Error in invocation of delete column operation!");
|
||||
|
||||
}
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
deleteColumnProgressDialog= new DeleteColumnProgressDialog(deleteColumnSession, eventBus);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void alert(String title, String message) {
|
||||
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,180 +0,0 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.core.client.Scheduler;
|
||||
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeEvent;
|
||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.ListLoadResult;
|
||||
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.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
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.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
|
||||
|
||||
/**
|
||||
* Remove Column Dialog
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RemoveColumnDialog extends Window {
|
||||
protected int WIDTH=400;
|
||||
protected int HEIGHT=120;
|
||||
protected TRId trId;
|
||||
protected ComboBox<ColumnData> combo = null;
|
||||
protected String columnName = null;
|
||||
|
||||
public RemoveColumnDialog(TRId trId) {
|
||||
create(trId, null);
|
||||
}
|
||||
|
||||
public RemoveColumnDialog(TRId trId, String columnName) {
|
||||
create(trId, columnName);
|
||||
}
|
||||
|
||||
protected void create(TRId trId, String columnName) {
|
||||
this.trId = trId;
|
||||
this.columnName = columnName;
|
||||
setBodyBorder(false);
|
||||
// getHeader().setIcon(Resources.IMAGES.side_list());
|
||||
setHeadingText("Remove Column");
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setResizable(false);
|
||||
|
||||
FramedPanel panel=new FramedPanel();
|
||||
panel.setHeaderVisible(false);
|
||||
panel.setBodyBorder(false);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
||||
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
||||
|
||||
Log.trace("Store created");
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
final ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||
proxy);
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||
store));
|
||||
Log.trace("Loader created");
|
||||
|
||||
combo = new ComboBox<ColumnData>(store, props.label()) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
public void execute() {
|
||||
loader.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
Log.trace("Combo created");
|
||||
|
||||
addHandlersForEventObservation(combo, props.label());
|
||||
|
||||
combo.setEmptyText("Select a column...");
|
||||
combo.setWidth(150);
|
||||
combo.setTypeAhead(true);
|
||||
combo.setTriggerAction(TriggerAction.ALL);
|
||||
combo.setLoader(loader);
|
||||
|
||||
|
||||
v.add(new FieldLabel(combo, "Column"), new VerticalLayoutData(1, -1));
|
||||
|
||||
panel.add(v);
|
||||
panel.addButton(new TextButton("Remove"));
|
||||
|
||||
add(panel);
|
||||
|
||||
}
|
||||
|
||||
private <T> void addHandlersForEventObservation(ComboBox<T> combo,
|
||||
final LabelProvider<T> labelProvider) {
|
||||
combo.addValueChangeHandler(new ValueChangeHandler<T>() {
|
||||
|
||||
public void onValueChange(ValueChangeEvent<T> event) {
|
||||
Info.display(
|
||||
"Value Changed",
|
||||
"New value: "
|
||||
+ (event.getValue() == null ? "nothing"
|
||||
: labelProvider.getLabel(event
|
||||
.getValue()) + "!"));
|
||||
|
||||
}
|
||||
});
|
||||
combo.addSelectionHandler(new SelectionHandler<T>() {
|
||||
public void onSelection(SelectionEvent<T> event) {
|
||||
Info.display(
|
||||
"State Selected",
|
||||
"You selected "
|
||||
+ (event.getSelectedItem() == null ? "nothing"
|
||||
: labelProvider.getLabel(event
|
||||
.getSelectedItem()) + "!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
Log.error("load combo failure:"
|
||||
+ caught.getLocalizedMessage());
|
||||
callback.onFailure(caught);
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.trace("loaded " + result.size() + " ColumnData");
|
||||
if (columnName != null) {
|
||||
for (ColumnData cd : result) {
|
||||
if (cd.getName().compareTo(columnName) == 0) {
|
||||
combo.setValue(cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||
result));
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -2,10 +2,12 @@ package org.gcube.portlets.user.td.columnwidget.client.dimension;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.util.OrderInfo;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -22,6 +24,8 @@ import com.sencha.gxt.core.client.Style.SelectionMode;
|
|||
import com.sencha.gxt.core.client.resources.ThemeStyles;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.SortDir;
|
||||
import com.sencha.gxt.data.shared.SortInfo;
|
||||
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadConfig;
|
||||
import com.sencha.gxt.data.shared.loader.PagingLoadResult;
|
||||
|
@ -33,6 +37,7 @@ 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.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SortChangeEvent;
|
||||
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;
|
||||
|
@ -61,7 +66,8 @@ public class DialogCodelistSelection extends Window {
|
|||
|
||||
protected Grid<TabResource> grid;
|
||||
protected ExtendedLiveGridView liveGridView;
|
||||
|
||||
protected PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>> loader;
|
||||
|
||||
protected ResourceBundle res;
|
||||
|
||||
public DialogCodelistSelection() {
|
||||
|
@ -99,22 +105,20 @@ public class DialogCodelistSelection extends Window {
|
|||
List<ColumnConfig<TabResource, ?>> columns = Arrays
|
||||
.<ColumnConfig<TabResource, ?>> asList(nameColumn,
|
||||
agencyColumn, dateColumn);
|
||||
|
||||
|
||||
ColumnModel<TabResource> cm = new ColumnModel<TabResource>(columns);
|
||||
|
||||
final ListStore<TabResource> store = new ListStore<TabResource>(
|
||||
properties.id());
|
||||
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
//store.applyFilters();
|
||||
// store.applyFilters();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
RpcProxy<PagingLoadConfig, PagingLoadResult<TabResource>> proxy = new RpcProxy<PagingLoadConfig, PagingLoadResult<TabResource>>() {
|
||||
|
||||
public void load(PagingLoadConfig loadConfig,
|
||||
|
@ -123,7 +127,7 @@ public class DialogCodelistSelection extends Window {
|
|||
|
||||
}
|
||||
};
|
||||
final PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>> loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>>(
|
||||
loader = new PagingLoader<PagingLoadConfig, PagingLoadResult<TabResource>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(true);
|
||||
|
@ -156,6 +160,7 @@ public class DialogCodelistSelection extends Window {
|
|||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(true);
|
||||
|
||||
|
||||
SelectHandler sh = new SelectHandler() {
|
||||
public void onSelect(SelectEvent event) {
|
||||
loader.load();
|
||||
|
@ -204,8 +209,27 @@ public class DialogCodelistSelection extends Window {
|
|||
*
|
||||
* });
|
||||
*/
|
||||
|
||||
|
||||
ArrayList<TabResource> trs = new ArrayList<TabResource>(1000);
|
||||
|
||||
List<? extends SortInfo> sortInfo=loadConfig.getSortInfo();
|
||||
Iterator<? extends SortInfo> iterator=sortInfo.iterator();
|
||||
ArrayList<OrderInfo> listOrderInfo=new ArrayList<OrderInfo>();
|
||||
|
||||
|
||||
while(iterator.hasNext()){
|
||||
SortInfo info=iterator.next();
|
||||
OrderInfo ord=new OrderInfo();
|
||||
SortDir sd=info.getSortDir();
|
||||
if(sd.compareTo(SortDir.ASC)==0){
|
||||
ord.setDirection("ASC");
|
||||
} else {
|
||||
ord.setDirection("DESC");
|
||||
}
|
||||
ord.setField(info.getSortField());
|
||||
listOrderInfo.add(ord);
|
||||
}
|
||||
|
||||
int totalLength = loadConfig.getOffset() + loadConfig.getLimit();
|
||||
int offset = loadConfig.getOffset();
|
||||
Log.debug("Offset: " + offset);
|
||||
|
@ -233,7 +257,6 @@ public class DialogCodelistSelection extends Window {
|
|||
offset));
|
||||
}
|
||||
|
||||
|
||||
protected HandlerRegistration addSelectionHandler(
|
||||
SelectionHandler<TabResource> handler) {
|
||||
SelectionHandler<TabResource> hand = new SelectionHandler<TabResource>() {
|
||||
|
@ -252,7 +275,6 @@ public class DialogCodelistSelection extends Window {
|
|||
return grid.getSelectionModel().getSelectedItem();
|
||||
}
|
||||
|
||||
|
||||
protected class ExtendedLiveGridView extends LiveGridView<TabResource> {
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,68 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
|
||||
/**
|
||||
* Updates a {@link ProgressBar} progress and text based on {@link DeleteColumnProgressListener} events.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DeleteColumnProgressBarUpdater implements DeleteColumnProgressListener {
|
||||
|
||||
protected ProgressBar progressBar;
|
||||
|
||||
/**
|
||||
* Creates a new {@link ProgressBar} updater.
|
||||
* @param progressBar the {@link ProgressBar} to update.
|
||||
*/
|
||||
public DeleteColumnProgressBarUpdater(ProgressBar progressBar) {
|
||||
this.progressBar = progressBar;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void operationComplete(TRId trId) {
|
||||
Log.info("Completed");
|
||||
progressBar.updateProgress(1, "Completed");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails) {
|
||||
Log.info("Failed");
|
||||
progressBar.updateText("Failed");
|
||||
}
|
||||
|
||||
public void operationInitializing() {
|
||||
Log.info("Inizializing");
|
||||
progressBar.updateProgress(0, "Initializing...");
|
||||
}
|
||||
|
||||
public void operationUpdate(float elaborated) {
|
||||
Log.info("Import elaborated: "+elaborated);
|
||||
if (elaborated == 0) progressBar.updateProgress(0, "Initializing...");
|
||||
if (elaborated>0 && elaborated<1) {
|
||||
Log.trace("progress "+elaborated);
|
||||
int elab=new Float(elaborated*100).intValue();
|
||||
progressBar.updateProgress(elaborated,elab+"% Progress...");
|
||||
}
|
||||
if (elaborated == 1) progressBar.updateProgress(1, "Completing...");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,117 @@
|
|||
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnSession;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.ProgressBar;
|
||||
import com.sencha.gxt.widget.core.client.Window;
|
||||
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.SelectEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* DeleteColumnProgressDialog is a Dialog that show delete column progress
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DeleteColumnProgressDialog extends Window implements DeleteColumnProgressListener {
|
||||
public static final int STATUS_POLLING_DELAY = 1000;
|
||||
protected String WIDTH = "400px";
|
||||
protected String HEIGHT = "120px";
|
||||
protected DeleteColumnSession deleteColumnSession;
|
||||
protected EventBus eventBus;
|
||||
protected DeleteColumnProgressUpdater progressUpdater;
|
||||
protected TextButton ok;
|
||||
protected TRId trId;
|
||||
|
||||
public DeleteColumnProgressDialog(DeleteColumnSession deleteColumnSession, EventBus eventBus) {
|
||||
this.deleteColumnSession=deleteColumnSession;
|
||||
this.eventBus=eventBus;
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setBodyBorder(false);
|
||||
setResizable(true);
|
||||
setModal(true);
|
||||
setHeadingText("Delete Column Progress");
|
||||
|
||||
trId=null;
|
||||
|
||||
FramedPanel panel=new FramedPanel();
|
||||
panel.setHeaderVisible(false);
|
||||
panel.setBodyBorder(false);
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
|
||||
|
||||
ProgressBar progressBar = new ProgressBar();
|
||||
|
||||
ok=new TextButton("OK");
|
||||
ok.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
updateInvocation();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
v.add(progressBar, new VerticalLayoutData(1,
|
||||
1, new Margins(5, 5, 5, 5)));
|
||||
|
||||
panel.add(v);
|
||||
panel.addButton(ok);
|
||||
add(panel);
|
||||
|
||||
|
||||
progressUpdater = new DeleteColumnProgressUpdater();
|
||||
progressUpdater.addListener(new DeleteColumnProgressBarUpdater(progressBar));
|
||||
|
||||
progressUpdater.addListener(this);
|
||||
progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY);
|
||||
show();
|
||||
ok.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
public void operationInitializing() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void operationUpdate(float elaborated) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
public void operationComplete(TRId trId) {
|
||||
Log.debug("Operation Complete return: "+trId.toString());
|
||||
ok.setVisible(true);
|
||||
this.trId=trId;
|
||||
}
|
||||
|
||||
public void operationFailed(Throwable caught, String reason,
|
||||
String failureDetails) {
|
||||
ok.setVisible(true);
|
||||
this.trId=null;
|
||||
}
|
||||
|
||||
public void updateInvocation(){
|
||||
if(trId!=null){
|
||||
ChangeTableRequestEvent changeTableRequestEvent=
|
||||
new ChangeTableRequestEvent(ChangeTableRequestType.DELETECOLUMN, trId);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
}
|
||||
hide();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines a listener for operation progress.
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface DeleteColumnProgressListener {
|
||||
|
||||
/**
|
||||
* Called when the operation is starting.
|
||||
*/
|
||||
public void operationInitializing();
|
||||
|
||||
/**
|
||||
* Called when there is a progress for the operation.
|
||||
* @param elaborated the elaborated part.
|
||||
*/
|
||||
public void operationUpdate(float elaborated);
|
||||
|
||||
|
||||
/**
|
||||
* Called when the operation is complete.
|
||||
*/
|
||||
public void operationComplete(TRId trId);
|
||||
|
||||
/**
|
||||
* Called when the operation is failed.
|
||||
* @param caught the failure exception.
|
||||
* @param reason the failure reason.
|
||||
*/
|
||||
public void operationFailed(Throwable caught, String reason, String failureDetails);
|
||||
}
|
|
@ -0,0 +1,172 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.columnwidget.client.progress;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.tr.column.DeleteColumnMonitor;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.user.client.Timer;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class DeleteColumnProgressUpdater extends Timer {
|
||||
|
||||
protected ArrayList<DeleteColumnProgressListener> listeners = new ArrayList<DeleteColumnProgressListener>();
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
Log.debug("requesting operation progress");
|
||||
TDGWTServiceAsync.INSTANCE
|
||||
.getDeleteColumnMonitor(new AsyncCallback<DeleteColumnMonitor>() {
|
||||
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
cancel();
|
||||
Log.error("Error retrieving the operation state",
|
||||
caught);
|
||||
String message = getStack(caught);
|
||||
fireOperationFailed(caught,
|
||||
"Failed getting operation updates", message);
|
||||
}
|
||||
|
||||
public void onSuccess(DeleteColumnMonitor result) {
|
||||
Log.info("retrieved DeleteMonitor: "
|
||||
+ result.getStatus());
|
||||
switch (result.getStatus()) {
|
||||
case INITIALIZING:
|
||||
Log.info("Delete Column Initializing...");
|
||||
fireOperationInitializing();
|
||||
break;
|
||||
case ABORTED:
|
||||
cancel();
|
||||
Log.info("Delete Column Operation Aborted");
|
||||
break;
|
||||
case IN_PROGRESS:
|
||||
fireOperationUpdate(result.getProgress());
|
||||
break;
|
||||
case VALIDATING_RULES:
|
||||
fireOperationUpdate(result.getProgress());
|
||||
break;
|
||||
case STOPPED:
|
||||
cancel();
|
||||
errorMessage(result);
|
||||
break;
|
||||
case FAILED:
|
||||
cancel();
|
||||
errorMessage(result);
|
||||
break;
|
||||
case SUCCEDED:
|
||||
cancel();
|
||||
Log.info("Import fisnish TableId :"
|
||||
+ result.getTrId());
|
||||
fireOperationComplete(result.getTrId());
|
||||
break;
|
||||
default:
|
||||
Log.info("Unknow State");
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void errorMessage(DeleteColumnMonitor result) {
|
||||
Log.info("Delete Column Failed");
|
||||
Throwable th = null;
|
||||
String failure = null;
|
||||
String details = null;
|
||||
if (result.getError() != null) {
|
||||
th = result.getError();
|
||||
failure = "Failed Client Library Delete Column";
|
||||
details = result.getError().getLocalizedMessage();
|
||||
} else {
|
||||
th = new Throwable("Failed");
|
||||
failure = "Failed Client Library Delete Column";
|
||||
details = "Error Delete Column";
|
||||
}
|
||||
fireOperationFailed(th, failure, details);
|
||||
|
||||
AlertMessageBox d = new AlertMessageBox("Error in Delete Column", details);
|
||||
d.addHideHandler(new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
d.show();
|
||||
|
||||
}
|
||||
|
||||
protected String getStack(Throwable e) {
|
||||
String message = e.getLocalizedMessage() + " -> <br>";
|
||||
Throwable c = e.getCause();
|
||||
if (c != null)
|
||||
message += getStack(c);
|
||||
return message;
|
||||
}
|
||||
|
||||
protected void fireOperationInitializing() {
|
||||
for (DeleteColumnProgressListener listener : listeners)
|
||||
listener.operationInitializing();
|
||||
}
|
||||
|
||||
protected void fireOperationUpdate(float elaborated) {
|
||||
for (DeleteColumnProgressListener listener : listeners)
|
||||
listener.operationUpdate(elaborated);
|
||||
}
|
||||
|
||||
protected void fireOperationComplete(TRId trId) {
|
||||
for (DeleteColumnProgressListener listener : listeners)
|
||||
listener.operationComplete(trId);
|
||||
}
|
||||
|
||||
protected void fireOperationFailed(Throwable caught, String failure,
|
||||
String failureDetails) {
|
||||
for (DeleteColumnProgressListener listener : listeners)
|
||||
listener.operationFailed(caught, failure, failureDetails);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new {@link DeleteColumnProgressListener} to this
|
||||
* {@link DeleteColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to add.
|
||||
*/
|
||||
public void addListener(DeleteColumnProgressListener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the specified {@link DeleteColumnProgressListener} from this
|
||||
* {@link DeleteColumnProgressUpdater}.
|
||||
*
|
||||
* @param listener
|
||||
* the listener to remove.
|
||||
*/
|
||||
public void removeListener(DeleteColumnProgressListener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue