diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java index 052e10df5d2e365a7eabd506fe9c49c41968049d..0e14ddb9a88573b1ebf21553d03c47a93598f882 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Dict.java @@ -162,6 +162,8 @@ public abstract class Dict public static final String BUTTON_SAVE = "button_save"; + public static final String BUTTON_UPLOAD = "button_upload"; + public static final String BUTTON_SAVE_AND_UPLOAD = "button_save_and_upload"; public static final String BUTTON_CHOOSE = "button_choose"; @@ -1297,5 +1299,11 @@ public abstract class Dict public static final String ACTIVE_USERS_DIALOG = "active_users_dialog"; + // Progress + + public static final String PROGRESS_UPLOADING = "progress_uploading"; + + public static final String PROGRESS_PROCESSING = "progress_processing"; + // ----- end generic ------------------ } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractRegistrationForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractRegistrationForm.java index 6515b55e877e7563cf10738d43f62754ce235a45..94517ac5848bd9345a1494e9029ae9d862403943 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractRegistrationForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/AbstractRegistrationForm.java @@ -88,6 +88,8 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements protected InfoBox infoBox; + protected InfoBoxResetListener infoBoxResetListener; + protected FormPanelWithSavePoint formPanel; protected final int labelWidth; @@ -108,6 +110,8 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements private Button revertButton; + private boolean dirtyCheckEnabled = true; + protected AbstractRegistrationForm(final IMessageProvider messageProvider, final String id) { this(messageProvider, id, DEFAULT_LABEL_WIDTH, DEFAULT_FIELD_WIDTH); @@ -177,7 +181,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements protected void updateDirtyCheckAfterChange(boolean isDirty) { - if (isDirty) + if (isDirtyCheckEnabled() && isDirty) { unsavedChangesInfo.setVisible(true); } else @@ -231,7 +235,8 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements private FormPanelWithSavePoint createFormPanel() { final FormPanelWithSavePoint panel = new FormPanelWithSavePoint(); - panel.addClickListener(new InfoBoxResetListener(infoBox)); + infoBoxResetListener = new InfoBoxResetListener(infoBox); + panel.addClickListener(infoBoxResetListener); panel.setHeaderVisible(false); panel.setBodyBorder(false); panel.setWidth(labelWidth + fieldWidth + PANEL_MARGIN); @@ -279,7 +284,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements @Override public final void componentSelected(final ButtonEvent ce) { - if (panel.isDirtyForSavePoint()) + if (isDirtyCheckEnabled() && panel.isDirtyForSavePoint()) { ce.setCancelled(true); new ConfirmationDialog( @@ -313,7 +318,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements @Override public final void componentSelected(final ButtonEvent ce) { - if (panel.isDirtyForSavePoint()) + if (isDirtyCheckEnabled() && panel.isDirtyForSavePoint()) { ce.setCancelled(true); new ConfirmationDialog( @@ -368,7 +373,8 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements @Override public void handleEvent(BaseEvent be) { - if (formPanel.isValid() && formPanel.isDirtyForSavePoint() == false) + if (formPanel.isValid() && isDirtyCheckEnabled() + && formPanel.isDirtyForSavePoint() == false) { be.setCancelled(true); new ConfirmationDialog(messageProvider @@ -429,7 +435,7 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements protected abstract String createSuccessfullRegistrationInfo(T result); @Override - public final void finishOnFailure(final Throwable caught) + public void finishOnFailure(final Throwable caught) { setUploadEnabled(true); } @@ -440,6 +446,8 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements { private final InfoBox infoBox; + private boolean enabled = true; + public InfoBoxResetListener(final InfoBox infoBox) { assert infoBox != null : "Unspecified info box."; @@ -448,7 +456,15 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements private void resetInfoBox() { - infoBox.reset(); + if (enabled) + { + infoBox.reset(); + } + } + + public void setEnabled(boolean enabled) + { + this.enabled = enabled; } // @@ -524,7 +540,17 @@ public abstract class AbstractRegistrationForm extends ContentPanel implements @Override public boolean shouldAskForCloseConfirmation() { - return formPanel.isDirtyForSavePoint(); + return isDirtyCheckEnabled() && formPanel.isDirtyForSavePoint(); + } + + public void setDirtyCheckEnabled(boolean dirtyCheckEnabled) + { + this.dirtyCheckEnabled = dirtyCheckEnabled; + } + + public boolean isDirtyCheckEnabled() + { + return dirtyCheckEnabled; } } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CustomImportForm.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CustomImportForm.java index 1297300979253df27350495cffe99f08746965c0..20bbe63512f882ea16a8232eb0861b5fc6037a42 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CustomImportForm.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/CustomImportForm.java @@ -20,6 +20,7 @@ import static ch.systemsx.cisd.openbis.generic.client.web.client.application.fra import com.extjs.gxt.ui.client.event.BaseEvent; import com.extjs.gxt.ui.client.event.Events; +import com.extjs.gxt.ui.client.event.FormEvent; import com.extjs.gxt.ui.client.event.Listener; import com.extjs.gxt.ui.client.widget.form.Field; import com.extjs.gxt.ui.client.widget.form.FileUploadField; @@ -67,7 +68,11 @@ public class CustomImportForm extends AbstractRegistrationForm CustomImport customImport) { super(viewContext, id); + + saveButton.setText(messageProvider.getMessage(Dict.BUTTON_UPLOAD)); setResetButtonVisible(true); + setDirtyCheckEnabled(false); + this.sessionKey = id + "-" + customImport.getCode(); this.customImport = customImport; this.viewContext = viewContext; @@ -90,6 +95,15 @@ public class CustomImportForm extends AbstractRegistrationForm } addUploadFeatures(sessionKey); + formPanel.addListener(Events.BeforeSubmit, new Listener<FormEvent>() + { + @Override + public void handleEvent(FormEvent be) + { + infoBox.displayProgress(messageProvider.getMessage(Dict.PROGRESS_UPLOADING)); + } + }); + formPanel.addListener(Events.Submit, new FormPanelListener(infoBox) { @Override @@ -101,24 +115,37 @@ public class CustomImportForm extends AbstractRegistrationForm @Override protected void onSuccessfullUpload() { + infoBox.displayProgress(messageProvider.getMessage(Dict.PROGRESS_PROCESSING)); + CustomImportForm.this.viewContext.getCommonService().performCustomImport( sessionKey, CustomImportForm.this.customImport.getCode(), new AbstractRegistrationCallback<String>( CustomImportForm.this.viewContext) { + @Override + protected void process(String result) + { + super.process(result); + resetPanel(); + } + @Override protected String createSuccessfullRegistrationInfo(String result) { return result + " succesfully uploaded to the datastore server."; } + + @Override + public void finishOnFailure(Throwable caught) + { + super.finishOnFailure(caught); + resetPanel(); + } + }); - for (FileUploadField field : fileFieldsManager.getFields()) - { - field.clear(); - } - setUploadEnabled(); + } }); } @@ -265,6 +292,13 @@ public class CustomImportForm extends AbstractRegistrationForm .getName()); } + @Override + protected void setUploadEnabled(boolean enabled) + { + super.setUploadEnabled(enabled); + infoBoxResetListener.setEnabled(enabled); + } + private void openUrl(String url) { Window.open(url, "_blank", ""); diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/IInfoHandler.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/IInfoHandler.java index 9175f744d4331e4bbf6999ac8e0e79e67c43e3e5..e8366ecf918271747c176bb9aebc7f049b6ff6ed 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/IInfoHandler.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/IInfoHandler.java @@ -18,7 +18,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget /** * Handles info and error texts. - * + * * @author Franz-Josef Elmer */ public interface IInfoHandler @@ -34,4 +34,9 @@ public interface IInfoHandler */ public abstract void displayInfo(final String text); + /** + * Display given <var>text</var> as <i>progress</i> text. + */ + public abstract void displayProgress(final String text); + } \ No newline at end of file diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/InfoBox.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/InfoBox.java index 4a78bef7e3aa2a49053f231bab67654e778a03c7..6183bc03eeb70d89f5637ff3042ab934094acc05 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/InfoBox.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/InfoBox.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.generic.client.web.client.application.ui.widget import com.extjs.gxt.ui.client.widget.Html; import com.extjs.gxt.ui.client.widget.MessageBox; +import com.google.gwt.user.client.Timer; import com.google.gwt.user.client.ui.HasHorizontalAlignment; import com.google.gwt.user.client.ui.HasHorizontalAlignment.HorizontalAlignmentConstant; @@ -42,6 +43,8 @@ public final class InfoBox extends Html implements IInfoHandler private static final String WHITE = "#ffffff"; + private Timer timer; + /** * Default constructor with {@link HasHorizontalAlignment#ALIGN_CENTER}. */ @@ -77,11 +80,44 @@ public final class InfoBox extends Html implements IInfoHandler display(text, Type.INFO); } + /** + * Display given <var>text</var> as <i>progress</i> text. + */ + @Override + public final void displayProgress(final String text) + { + display(text, Type.PROGRESS); + + timer = new Timer() + { + String dots = ""; + + @Override + public void run() + { + if (dots.length() < 5) + { + dots += "."; + } else + { + dots = ""; + } + setHtml(text + dots); + } + }; + timer.scheduleRepeating(500); + } + /** * Displays given <var>text</var> of given <var>type</var>. */ public final void display(final String text, final Type type) { + if (timer != null) + { + timer.cancel(); + timer = null; + } if (StringUtils.isBlank(text) == false) { setStyleAttribute("color", "#000000"); @@ -101,6 +137,11 @@ public final class InfoBox extends Html implements IInfoHandler */ public final void reset() { + if (timer != null) + { + timer.cancel(); + timer = null; + } setStyleAttribute("backgroundColor", WHITE); setStyleAttribute("borderColor", WHITE); // Make placeholder text invisible. @@ -115,7 +156,7 @@ public final class InfoBox extends Html implements IInfoHandler private static enum Type { - ERROR("#f6cece", "#f5a9a9"), INFO("#cef6ce", "#a9f5a9"); + ERROR("#f6cece", "#f5a9a9"), INFO("#cef6ce", "#a9f5a9"), PROGRESS("#cef6ce", "#a9f5a9"); private final String backgroundColor; diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/PopupDialogBasedInfoHandler.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/PopupDialogBasedInfoHandler.java index b371bb19f88eb83c29928a4b585e089d59e6c976..388989b8b53a84d65bc887577cf4d6d52bb571ef 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/PopupDialogBasedInfoHandler.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/widget/PopupDialogBasedInfoHandler.java @@ -20,23 +20,29 @@ import com.extjs.gxt.ui.client.widget.MessageBox; /** * Info handler which shows info in a popup dialog. - * + * * @author Franz-Josef Elmer */ public class PopupDialogBasedInfoHandler implements IInfoHandler { public static final IInfoHandler INSTANCE = new PopupDialogBasedInfoHandler(); - + @Override public void displayInfo(String text) { MessageBox.info("Info", text, null); } - + @Override public void displayError(String text) { MessageBox.alert("Error", text, null); } + @Override + public void displayProgress(String text) + { + MessageBox.alert("Progress", text, null); + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js index 2555b754104a4a83cb4c542860ecaab68e69d2fe..dd5c05b7689473c5aa160aec5a1b1f42c3650823 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js +++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/common-dictionary.js @@ -153,6 +153,7 @@ var common = { button_add: "Add {0}", button_save: "Save", + button_upload: "Upload", button_save_and_upload: "Save + Upload Data Set", button_choose: "Choose", button_cancel: "Cancel", @@ -892,7 +893,13 @@ warning_no_script_message: "No script provided", // last_visits: "Last Visited Places", clear: "Clear", - + +// +// Progress +// +progress_uploading: "Uploading", +progress_processing: "Processing", + // LAST LINE: KEEP IT AT THE END lastline: "" // we need a line without a comma };