diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeToAnnotationColumnDialog.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeToAnnotationColumnDialog.java deleted file mode 100644 index 9c736de..0000000 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeToAnnotationColumnDialog.java +++ /dev/null @@ -1,179 +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; - -/** - * - * - * @author "Giancarlo Panichi" - * g.panichi@isti.cnr.it - * - */ -public class ChangeToAnnotationColumnDialog extends Window { - protected int WIDTH=400; - protected int HEIGHT=120; - protected TRId trId; - protected ComboBox combo=null; - protected String columnName=null; - - public ChangeToAnnotationColumnDialog(TRId trId) { - create(trId, null); - } - - public ChangeToAnnotationColumnDialog(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("Change To Annotation 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 store = new ListStore(props.id()); - - Log.trace("Store created"); - RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - final ListLoader> loader = new ListLoader>(proxy); - loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>(store)); - Log.trace("Loader created"); - - - combo = new ComboBox(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("Change")); - - add(panel); - - } - - private void addHandlersForEventObservation(ComboBox combo, - final LabelProvider labelProvider) { - combo.addValueChangeHandler(new ValueChangeHandler() { - - public void onValueChange(ValueChangeEvent event) { - Info.display( - "Value Changed", - "New value: " - + (event.getValue() == null ? "nothing" - : labelProvider.getLabel(event - .getValue()) + "!")); - - } - }); - combo.addSelectionHandler(new SelectionHandler() { - public void onSelection(SelectionEvent event) { - Info.display( - "State Selected", - "You selected " - + (event.getSelectedItem() == null ? "nothing" - : labelProvider.getLabel(event - .getSelectedItem()) + "!")); - } - }); - } - - - - - - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE.getColumns(trId, new AsyncCallback>(){ - - public void onFailure(Throwable caught) { - Log.error("load combo failure:"+caught.getLocalizedMessage()); - callback.onFailure(caught); - } - - public void onSuccess(ArrayList 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( - result)); - - } - - }); - - } - -}