Minor Updated

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@92360 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-02-26 18:03:05 +00:00
parent 9c52d1c901
commit fee49c8272
3 changed files with 148 additions and 46 deletions

View File

@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.columnwidget.client;
import java.util.ArrayList; import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.dimension.CodelistSelectionListener;
import org.gcube.portlets.user.td.columnwidget.client.dimension.DialogCodelistSelection; import org.gcube.portlets.user.td.columnwidget.client.dimension.DialogCodelistSelection;
import org.gcube.portlets.user.td.columnwidget.client.progress.ChangeColumnTypeProgressDialog; import org.gcube.portlets.user.td.columnwidget.client.progress.ChangeColumnTypeProgressDialog;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties; import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataProperties;
@ -24,8 +25,6 @@ import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT; import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.BeforeSelectionEvent;
import com.google.gwt.event.logical.shared.BeforeSelectionHandler;
import com.google.gwt.event.logical.shared.SelectionEvent; import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
@ -46,13 +45,11 @@ 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.button.TextButton;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; 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.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent;
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
import com.sencha.gxt.widget.core.client.event.BeforeShowContextMenuEvent.BeforeShowContextMenuHandler;
import com.sencha.gxt.widget.core.client.event.HideEvent; 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.HideEvent.HideHandler;
import com.sencha.gxt.widget.core.client.event.SelectEvent; 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.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent;
import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler; import com.sencha.gxt.widget.core.client.event.TriggerClickEvent.TriggerClickHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox; 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.FieldLabel;
@ -68,7 +65,7 @@ import com.sencha.gxt.widget.core.client.info.Info;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a> * href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
* *
*/ */
public class ChangeColumnTypePanel extends FramedPanel { public class ChangeColumnTypePanel extends FramedPanel implements CodelistSelectionListener {
protected String WIDTH = "640px"; protected String WIDTH = "640px";
protected String HEIGHT = "520px"; protected String HEIGHT = "520px";
protected EventBus eventBus; protected EventBus eventBus;
@ -613,7 +610,26 @@ public class ChangeColumnTypePanel extends FramedPanel {
protected void callDialogCodelistSelection() { protected void callDialogCodelistSelection() {
DialogCodelistSelection dialogCodelistSelection = new DialogCodelistSelection( DialogCodelistSelection dialogCodelistSelection = new DialogCodelistSelection(
eventBus); eventBus);
dialogCodelistSelection.addListener(this);
dialogCodelistSelection.show(); dialogCodelistSelection.show();
} }
@Override
public void selected(TabResource tabResource) {
Log.debug("Selected Codelist: "+tabResource);
}
@Override
public void aborted() {
Log.debug("Select Codelist Aborted");
}
@Override
public void failed(String reason, String detail) {
Log.error("Select Codelist Failed[reason: "+reason+" , detail:"+detail+"]");
}
} }

View File

@ -0,0 +1,32 @@
package org.gcube.portlets.user.td.columnwidget.client.dimension;
import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource;
/**
*
* @author "Giancarlo Panichi"
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
*
*/
public interface CodelistSelectionListener {
/**
* Called when selected codelist without errors
*/
public void selected(TabResource tabResource);
/**
* Called when the select operation is aborted by the user.
*/
public void aborted();
/**
* Called when the something in the wizard is failed.
*
* @param reason
* @param detail
*/
public void failed(String reason, String detail);
}

View File

@ -23,6 +23,7 @@ import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler; import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.event.shared.HandlerRegistration; import com.google.gwt.event.shared.HandlerRegistration;
import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.core.client.IdentityValueProvider; import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.resources.ThemeStyles; import com.sencha.gxt.core.client.resources.ThemeStyles;
@ -54,13 +55,13 @@ import com.sencha.gxt.widget.core.client.grid.LiveGridView;
import com.sencha.gxt.widget.core.client.grid.LiveToolItem; import com.sencha.gxt.widget.core.client.grid.LiveToolItem;
import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar; import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
import com.google.web.bindery.event.shared.EventBus;
public class DialogCodelistSelection extends Window { public class DialogCodelistSelection extends Window {
protected static final int WIDTH = 550; protected static final int WIDTH = 550;
protected static final int HEIGHT = 520; protected static final int HEIGHT = 520;
protected static final int CACHE_SIZE = 200; protected static final int CACHE_SIZE = 200;
protected ArrayList<CodelistSelectionListener> listeners;
private static final TabResourcesProperties properties = GWT private static final TabResourcesProperties properties = GWT
.create(TabResourcesProperties.class); .create(TabResourcesProperties.class);
@ -79,6 +80,7 @@ public class DialogCodelistSelection extends Window {
protected String filter; protected String filter;
protected ResourceBundle res; protected ResourceBundle res;
private TextButton select;
public DialogCodelistSelection(EventBus eventBus) { public DialogCodelistSelection(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
@ -89,6 +91,7 @@ public class DialogCodelistSelection extends Window {
setBodyBorder(false); setBodyBorder(false);
setResizable(true); setResizable(true);
setHeadingText("Select Codelist"); setHeadingText("Select Codelist");
listeners = new ArrayList<CodelistSelectionListener>();
initLoad(); initLoad();
} }
@ -196,7 +199,19 @@ public class DialogCodelistSelection extends Window {
v.add(baseToolBar, new VerticalLayoutData(1, 25)); v.add(baseToolBar, new VerticalLayoutData(1, 25));
panel.add(v); panel.add(v);
panel.addButton(new TextButton("Select"));
select = new TextButton("Select");
select.disable();
select.addSelectHandler(new SelectHandler() {
@Override
public void onSelect(SelectEvent event) {
fireCompleted(getSelected());
}
});
panel.addButton(select);
add(panel); add(panel);
forceLayout(); forceLayout();
@ -249,11 +264,11 @@ public class DialogCodelistSelection extends Window {
} }
}); });
} }
protected void initLoad() { protected void initLoad() {
TDGWTServiceAsync.INSTANCE.setCodelistsPagingLoader(new AsyncCallback<Void>(){ TDGWTServiceAsync.INSTANCE
.setCodelistsPagingLoader(new AsyncCallback<Void>() {
@Override @Override
public void onFailure(Throwable caught) { public void onFailure(Throwable caught) {
@ -280,16 +295,14 @@ public class DialogCodelistSelection extends Window {
SelectionHandler<TabResource> hand = new SelectionHandler<TabResource>() { SelectionHandler<TabResource> hand = new SelectionHandler<TabResource>() {
public void onSelection(SelectionEvent<TabResource> event) { public void onSelection(SelectionEvent<TabResource> event) {
// tabResourcesSelectionPanel.getSelectedItem(); select.enable();
// getWizardWindow().setEnableNextButton(true);
} }
}; };
return grid.getSelectionModel().addSelectionHandler(hand); return grid.getSelectionModel().addSelectionHandler(hand);
} }
public TabResource getSelectedItem() { protected TabResource getSelected() {
return grid.getSelectionModel().getSelectedItem(); return grid.getSelectionModel().getSelectedItem();
} }
@ -314,4 +327,45 @@ public class DialogCodelistSelection extends Window {
} }
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
fireAborted();
hide();
}
});
}
public void addListener(CodelistSelectionListener listener) {
listeners.add(listener);
}
public void removeListener(CodelistSelectionListener listener) {
listeners.remove(listener);
}
public void fireCompleted(TabResource tabResource) {
for (CodelistSelectionListener listener : listeners)
listener.selected(tabResource);
}
public void fireAborted() {
for (CodelistSelectionListener listener : listeners)
listener.aborted();
}
public void fireFailed(String reason, String details) {
for (CodelistSelectionListener listener : listeners)
listener.failed(reason, details);
}
} }