From 74c879d953f74f76586be39c9354ed342c016638 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Wed, 15 Jan 2014 11:10:33 +0000 Subject: [PATCH] Added Change Label git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@90129 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/ChangeLabelColumnDialog.java | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeLabelColumnDialog.java diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeLabelColumnDialog.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeLabelColumnDialog.java new file mode 100644 index 0000000..ed94607 --- /dev/null +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/ChangeLabelColumnDialog.java @@ -0,0 +1,91 @@ +package org.gcube.portlets.user.td.columnwidget.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.google.gwt.widget.client.TextButton; +import com.sencha.gxt.core.client.util.Margins; +import com.sencha.gxt.widget.core.client.ContentPanel; +import com.sencha.gxt.widget.core.client.FramedPanel; +import com.sencha.gxt.widget.core.client.Window; +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.TextField; + + +public class ChangeLabelColumnDialog extends Window { + protected TRId trId; + protected TextField label=null; + protected String columnName=null; + protected ColumnData column=null; + + public ChangeLabelColumnDialog(TRId trId) { + create(trId, null); + } + + public ChangeLabelColumnDialog(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(400); + setHeight(120); + setResizable(false); + + VerticalLayoutContainer basicLayout = new VerticalLayoutContainer(); + + ContentPanel panel = new ContentPanel(); + panel.setHeaderVisible(false); + + FramedPanel form = new FramedPanel(); + form.setHeaderVisible(false); + form.setBodyStyle("background: none;"); + + VerticalLayoutContainer v = new VerticalLayoutContainer(); + + label = new TextField(); + label.setAllowBlank(false); + label.setWidth(150); + v.add(new FieldLabel(label, "Column Label"), new VerticalLayoutData(1, -1)); + loadData(); + + form.add(v); + form.addButton(new TextButton("Remove")); + + + panel.add(form); + basicLayout.add(panel, new VerticalLayoutData(-1, -1, new Margins())); + + add(basicLayout); + + } + + + protected void loadData() { + TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName, new AsyncCallback(){ + + public void onFailure(Throwable caught) { + Log.error("load column data failure:"+caught.getLocalizedMessage()); + } + + public void onSuccess(ColumnData result) { + Log.trace("loaded " + result); + column=result; + label.setValue(result.getLabel()); + + } + + }); + + } + +}