191 lines
5.5 KiB
Java
191 lines
5.5 KiB
Java
package org.gcube.portlets.user.td.expressionwidget.client;
|
|
|
|
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.user.client.rpc.AsyncCallback;
|
|
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
|
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
|
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.FieldLabel;
|
|
import com.sencha.gxt.widget.core.client.form.TextArea;
|
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
|
|
|
/**
|
|
*
|
|
* @author "Giancarlo Panichi"
|
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
|
*
|
|
*/
|
|
public class ColumnExpressionPanel extends FramedPanel {
|
|
protected TRId trId;
|
|
protected String columnName=null;
|
|
protected ColumnData column;
|
|
//protected ComboBox<ColumnData> combo=null;
|
|
|
|
/**
|
|
*
|
|
* @param columnTypeCode
|
|
* @param dataTypeName
|
|
*/
|
|
public ColumnExpressionPanel(String columnId, String columnTypeCode, String dataTypeName) {
|
|
column=new ColumnData();
|
|
column.setColumnId(columnId);
|
|
column.setDataTypeName(dataTypeName);
|
|
column.setTypeCode(columnTypeCode);
|
|
create();
|
|
}
|
|
|
|
/**
|
|
*
|
|
* @param trId
|
|
* @param columnName
|
|
*/
|
|
public ColumnExpressionPanel(TRId trId, String columnName) {
|
|
this.trId=trId;
|
|
this.columnName=columnName;
|
|
load(trId, columnName);
|
|
}
|
|
|
|
protected void create() {
|
|
setBodyBorder(false);
|
|
// getHeader().setIcon(Resources.IMAGES.side_list());
|
|
setWidth(400);
|
|
setHeight(400);
|
|
setResize(true);
|
|
|
|
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
|
basicLayout.setScrollMode(ScrollMode.AUTO);
|
|
basicLayout.setAdjustForScroll(true);
|
|
|
|
|
|
TextField nome= new TextField();
|
|
basicLayout.add(new FieldLabel(nome, "Nome"), new VerticalLayoutData(1, -1));
|
|
|
|
TextArea descrizione= new TextArea();
|
|
basicLayout.add(new FieldLabel(descrizione, "Descrizione"), new VerticalLayoutData(1, -1));
|
|
|
|
|
|
ConditionWidget conditionWidget =new ConditionWidget(column.getColumnId(), column.getTypeCode(), column.getDataTypeName());
|
|
basicLayout.add(conditionWidget);
|
|
|
|
add(basicLayout);
|
|
show();
|
|
|
|
/*
|
|
ContentPanel panel = new ContentPanel();
|
|
panel.setHeaderVisible(false);
|
|
|
|
//panel.setBodyStyle("margin: 0px;");
|
|
|
|
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);
|
|
|
|
FramedPanel form = new FramedPanel();
|
|
form.setHeaderVisible(false);
|
|
//form.setWidth(350);
|
|
form.setBodyStyle("background: none;");
|
|
|
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
|
v.add(new FieldLabel(combo, "Column"), new VerticalLayoutData(1, -1));
|
|
form.add(v);
|
|
form.addButton(new TextButton("Remove"));
|
|
|
|
|
|
panel.add(form);
|
|
|
|
basicLayout.add(panel, new VerticalLayoutData(-1, -1, new Margins()));
|
|
*/
|
|
|
|
}
|
|
|
|
/*
|
|
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 load(TRId trId, String columnName) {
|
|
TDGWTServiceAsync.INSTANCE.getColumn(trId,columnName, new AsyncCallback<ColumnData>(){
|
|
|
|
public void onFailure(Throwable caught) {
|
|
Log.error("Error retrieving column: "+caught.getMessage());
|
|
|
|
}
|
|
|
|
public void onSuccess(ColumnData result) {
|
|
Log.debug("Retrived column: "+result);
|
|
column=result;
|
|
create();
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
}
|