diff --git a/src/main/java/org/gcube/portlets/user/td/extractcodelistwidget/client/ExtractCodelistDetailsCard.java b/src/main/java/org/gcube/portlets/user/td/extractcodelistwidget/client/ExtractCodelistDetailsCard.java index 59d82e1..ffd4b84 100644 --- a/src/main/java/org/gcube/portlets/user/td/extractcodelistwidget/client/ExtractCodelistDetailsCard.java +++ b/src/main/java/org/gcube/portlets/user/td/extractcodelistwidget/client/ExtractCodelistDetailsCard.java @@ -5,9 +5,10 @@ import org.gcube.portlets.user.td.gwtservice.shared.tr.TabResource; import org.gcube.portlets.user.td.wizardwidget.client.WizardCard; import com.allen_sauer.gwt.log.client.Log; -import com.google.gwt.i18n.client.DateTimeFormat; import com.google.gwt.user.client.Command; +import com.google.gwt.user.client.ui.HorizontalPanel; import com.google.gwt.user.client.ui.VerticalPanel; +import com.sencha.gxt.core.client.util.ToggleGroup; import com.sencha.gxt.widget.core.client.FramedPanel; import com.sencha.gxt.widget.core.client.box.AlertMessageBox; import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer; @@ -16,7 +17,10 @@ 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.form.FieldLabel; import com.sencha.gxt.widget.core.client.form.FieldSet; +import com.sencha.gxt.widget.core.client.form.Radio; import com.sencha.gxt.widget.core.client.form.TextField; +import com.sencha.gxt.widget.core.client.tips.ToolTip; +import com.sencha.gxt.widget.core.client.tips.ToolTipConfig; /** * @@ -25,31 +29,30 @@ import com.sencha.gxt.widget.core.client.form.TextField; * */ public class ExtractCodelistDetailsCard extends WizardCard { - protected DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); + //private static DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd"); - protected final String TABLEDETAILPANELWIDTH = "100%"; - protected final String TABLEDETAILPANELHEIGHT = "100%"; - protected final String FORMWIDTH = "538px"; + private static final String TABLEDETAILPANELWIDTH = "100%"; + private static final String TABLEDETAILPANELHEIGHT = "100%"; + private static final String FORMWIDTH = "538px"; - protected ExtractCodelistSession extractCodelistSession; - protected ExtractCodelistDetailsCard thisCard; - protected VerticalLayoutContainer p; - protected VerticalPanel tableDetailPanel; + private static final int LABEL_WIDTH = 0; - protected TextField name; - /*protected TextArea description; - protected TextArea rights; - protected DateField validFrom; - protected DateField validUntilTo; + private static final int LABEL_PAD_WIDTH = 0; + + private ExtractCodelistSession extractCodelistSession; + private ExtractCodelistDetailsCard thisCard; + + private VerticalLayoutContainer p; + private VerticalPanel tableDetailPanel; + + private TextField name; + private Radio automaticallyAttachTrue; + private Radio automaticallyAttachFalse; - protected ListLoader> loader; - protected ComboBox comboLicences;*/ - - protected TabResource detail; - + private TabResource detail; public ExtractCodelistDetailsCard(final ExtractCodelistSession extractCodelistSession) { super("Codelist Detail", ""); @@ -80,118 +83,39 @@ public class ExtractCodelistDetailsCard extends WizardCard { name.setEmptyText("Enter a name..."); name.setAllowBlank(false); p.add(new FieldLabel(name, "Name"), new VerticalLayoutData(1, -1)); - - /* - description = new TextArea(); - description.setAllowBlank(false); - description.setEmptyText("Enter a description..."); - description.setValue("File CSV"); - description.setAllowBlank(false); - p.add(new FieldLabel(description, "Description"), - new VerticalLayoutData(1, -1)); - - rights = new TextArea(); - rights.setEmptyText("Enter rights..."); - rights.setAllowBlank(false); - p.add(new FieldLabel(rights, "Rights"), new VerticalLayoutData(1, -1)); - validFrom = new DateField(); - validFrom.setValue(new Date()); - p.add(new FieldLabel(validFrom, "Valid From"), new VerticalLayoutData( - 1, -1)); - - validUntilTo = new DateField(); - p.add(new FieldLabel(validUntilTo, "Valid Until To"), - new VerticalLayoutData(1, -1)); - - // Combo Licences - LicenceDataPropertiesCombo propsLicenceData = GWT - .create(LicenceDataPropertiesCombo.class); - ListStore storeCombo = new ListStore( - propsLicenceData.id()); - - Log.debug("StoreCombo created"); - - RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - - loader = new ListLoader>( - proxy) { - @Override - protected ListLoadConfig newLoadConfig() { - return (ListLoadConfig) new ListLoadConfigBean(); - } - - }; - loader.addLoadHandler(new LoadResultListStoreBinding>( - storeCombo)); - Log.trace("LoaderCombo created"); + /// + automaticallyAttachTrue = new Radio(); + automaticallyAttachTrue.setBoxLabel("True"); + automaticallyAttachTrue.setValue(true); - comboLicences = new ComboBox(storeCombo, - propsLicenceData.licence()) { + automaticallyAttachFalse = new Radio(); + automaticallyAttachFalse.setBoxLabel("False"); - protected void onAfterFirstAttach() { - super.onAfterFirstAttach(); - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - public void execute() { - loader.load(); - } - }); - } - }; - comboLicences.setEditable(false); - comboLicences.setTypeAhead(false); - comboLicences.setTriggerAction(TriggerAction.ALL); - Log.trace("Combo Licence created"); - - // / - p.add(new FieldLabel(comboLicences, "Licence"), - new VerticalLayoutData(1, -1)); - */ + ToggleGroup automticallyAttachGroup = new ToggleGroup(); + automticallyAttachGroup.add(automaticallyAttachTrue); + automticallyAttachGroup.add(automaticallyAttachFalse); + + HorizontalPanel automaticallyAttachPanel = new HorizontalPanel(); + automaticallyAttachPanel.add(automaticallyAttachTrue); + automaticallyAttachPanel.add(automaticallyAttachFalse); + + new ToolTip(automaticallyAttachPanel, new ToolTipConfig( + "Automatically attach the generated codelist")); + FieldLabel fieldViewColumns=new FieldLabel(automaticallyAttachPanel, "Automatically Attach"); + fieldViewColumns.setLabelWidth(LABEL_WIDTH); + fieldViewColumns.setLabelPad(LABEL_PAD_WIDTH); + p.add(fieldViewColumns, new VerticalLayoutData(1, -1)); + + tableDetailPanel.add(form); setContent(tableDetailPanel); } - /* - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE - .getLicences(new AsyncCallback>() { - - public void onFailure(Throwable caught) { - if (caught instanceof TDGWTSessionExpiredException) { - getEventBus() - .fireEvent( - new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); - } else { - Log.error("load combo failure:" - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error", - "Error retrieving licences."); - } - callback.onFailure(caught); - } - - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " ColumnData"); - callback.onSuccess(new ListLoadResultBean( - result)); - - } - - }); - - } - */ + @Override public void setup() { @@ -255,45 +179,22 @@ public class ExtractCodelistDetailsCard extends WizardCard { } } + protected boolean getAutomaticallyAttach() { + if(automaticallyAttachTrue.getValue()){ + return true; + } else { + return false; + } + } + + protected void goNext() { try { detail= new TabResource(); detail.setName(name.getCurrentValue()); - /*detail.setDescription(description.getCurrentValue()); - detail.setRight(rights.getCurrentValue()); - - Date vFrom = validFrom.getCurrentValue(); - if (vFrom == null) { - Log.debug("Valid From is null"); - } else { - try { - detail.setValidFrom(sdf.format(vFrom)); - } catch (Throwable e) { - Log.error("Error parsing Valid From " - + e.getLocalizedMessage()); - } - } - - Date vUntilTo = validUntilTo.getCurrentValue(); - if (vUntilTo == null) { - Log.debug("Valid Until To is null"); - } else { - try { - detail.setValidUntilTo(sdf.format(vUntilTo)); - } catch (Throwable e) { - Log.error("Error parsing Valid Until To " - + e.getLocalizedMessage()); - } - } - - if(comboLicences.getCurrentValue()!=null&& comboLicences.getCurrentValue().getLicence()!=null - && !comboLicences.getCurrentValue().getLicence().isEmpty()){ - detail.setLicence(comboLicences.getCurrentValue().getLicence()); - } - */ extractCodelistSession.setTabResource(detail); - + extractCodelistSession.setAutomaticallyAttach(getAutomaticallyAttach()); ExtractCodelistOperationInProgressCard extractCodelistOperationInProgressCard = new ExtractCodelistOperationInProgressCard( extractCodelistSession); getWizardWindow().addCard(extractCodelistOperationInProgressCard);