From 1fa5a3a30d8f0ff35ac0c61cec0a95d41ffbc087 Mon Sep 17 00:00:00 2001 From: buczekp <buczekp> Date: Wed, 9 Mar 2011 13:52:47 +0000 Subject: [PATCH] minor: added flag 'reopen last tab' to display settings SVN: 20267 --- .../client/web/client/application/Client.java | 25 +++++++++++++++---- .../client/web/client/application/Dict.java | 4 +++ .../framework/DisplaySettingsManager.java | 12 +++++++++ .../framework/LastHistoryTokenUpdater.java | 1 + .../ui/user/ChangeUserSettingsDialog.java | 20 +++++++++++++++ .../shared/basic/dto/DisplaySettings.java | 22 +++++++++++++++- .../cisd/openbis/public/common-dictionary.js | 2 ++ 7 files changed, 80 insertions(+), 6 deletions(-) diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java index 4173d0c4f32..e5101b667e2 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/Client.java @@ -322,11 +322,8 @@ public class Client implements EntryPoint, ValueChangeHandler<String> GWTUtils.setConfirmExitMessage(); } - DisplaySettings displaySettings = - viewContext.getModel().getSessionContext().getDisplaySettings(); - String lastHistoryOrNull = displaySettings.getLastHistoryTokenOrNull(); - if (viewContext.isSimpleMode() == false && StringUtils.isBlank(History.getToken()) - && StringUtils.isBlank(lastHistoryOrNull) == false) + String lastHistoryOrNull = tryGetLastHistoryToken(); + if (lastHistoryOrNull != null) { History.newItem(lastHistoryOrNull); } else @@ -335,6 +332,24 @@ public class Client implements EntryPoint, ValueChangeHandler<String> } } } + + @SuppressWarnings("deprecation") + private String tryGetLastHistoryToken() + { + if (viewContext.isSimpleMode() == false && StringUtils.isBlank(History.getToken())) + { + DisplaySettings displaySettings = + viewContext.getModel().getSessionContext().getDisplaySettings(); + if (displaySettings.isIgnoreLastHistoryToken()) + { + return null; + } else + { + return displaySettings.getLastHistoryTokenOrNull(); + } + } + return null; + } } /** 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 cc95e89a676..6332612f305 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 @@ -861,6 +861,10 @@ public abstract class Dict public static final String DEBUGGING_MODE_INFO = "debugging_mode_info"; + public static final String REOPEN_LAST_TAB_ON_LOGIN_LABEL = "reopen_last_tab_on_login_label"; + + public static final String REOPEN_LAST_TAB_ON_LOGIN_INFO = "reopen_last_tab_on_login_info"; + // // Help Info // diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java index f5fb6d65f1c..f8168512503 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/DisplaySettingsManager.java @@ -492,6 +492,18 @@ public class DisplaySettingsManager displaySettings.setDebuggingModeEnabled(isDebugging); } + @SuppressWarnings("deprecation") + public final boolean isReopenLastTabOnLogin() + { + return displaySettings.isIgnoreLastHistoryToken() == false; + } + + @SuppressWarnings("deprecation") + public final void setReopenLastTabOnLogin(boolean isReopen) + { + displaySettings.setIgnoreLastHistoryToken(isReopen == false); + } + @SuppressWarnings("deprecation") public final RealNumberFormatingParameters getRealNumberFormatingParameters() { diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/LastHistoryTokenUpdater.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/LastHistoryTokenUpdater.java index 60aa1457af8..ff435302746 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/LastHistoryTokenUpdater.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/framework/LastHistoryTokenUpdater.java @@ -31,6 +31,7 @@ class LastHistoryTokenUpdater this.viewContext = viewContext; } + @SuppressWarnings("deprecation") public void update(String historyToken) { DisplaySettings displaySettings = diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/user/ChangeUserSettingsDialog.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/user/ChangeUserSettingsDialog.java index b0b4f9d32c7..16a29ac475d 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/user/ChangeUserSettingsDialog.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/client/web/client/application/ui/user/ChangeUserSettingsDialog.java @@ -66,6 +66,8 @@ public class ChangeUserSettingsDialog extends AbstractSaveDialog private final SpaceSelectionWidget homeSpaceField; + private final CheckBoxField reopenLastTabField; + private final CheckBoxField useWildcardSearchModeCheckbox; private final FieldSet formatingFields; @@ -90,6 +92,7 @@ public class ChangeUserSettingsDialog extends AbstractSaveDialog // setHeight(250); addField(homeSpaceField = createHomeGroupField()); + addField(reopenLastTabField = createReopenLastTabOnLoginField()); addField(useWildcardSearchModeCheckbox = createUseWildcardSearchModeField()); formatingFields = createRealFormatingFieldSet(); precisionField = createPrecisionField(); @@ -118,6 +121,19 @@ public class ChangeUserSettingsDialog extends AbstractSaveDialog return field; } + private CheckBoxField createReopenLastTabOnLoginField() + { + CheckBoxField field = + new CheckBoxField(viewContext.getMessage(Dict.REOPEN_LAST_TAB_ON_LOGIN_LABEL), + false); + AbstractImagePrototype infoIcon = + AbstractImagePrototype.create(viewContext.getImageBundle().getInfoIcon()); + FieldUtil.addInfoIcon(field, viewContext.getMessage(Dict.REOPEN_LAST_TAB_ON_LOGIN_INFO), + infoIcon.createImage()); + field.setValue(viewContext.getDisplaySettingsManager().isReopenLastTabOnLogin()); + return field; + } + private final CheckBoxField createUseWildcardSearchModeField() { CheckBoxField field = @@ -140,6 +156,7 @@ public class ChangeUserSettingsDialog extends AbstractSaveDialog formatingParameters.setFormatingEnabled(formatingFields.isExpanded()); formatingParameters.setPrecision(precisionField.getValue().intValue()); formatingParameters.setScientific(scientificFormatingField.getValue()); + DisplaySettingsManager displaySettingsManager = viewContext.getDisplaySettingsManager(); boolean useWildcardSearchMode = extractUseWildcardSearchMode(); displaySettingsManager.updateUseWildcardSearchMode(useWildcardSearchMode); @@ -147,6 +164,9 @@ public class ChangeUserSettingsDialog extends AbstractSaveDialog boolean debuggingModeEnabled = debuggingModeField.getValue(); displaySettingsManager.setDebuggingModeEnabled(debuggingModeEnabled); + boolean restoreLastTab = reopenLastTabField.getValue(); + displaySettingsManager.setReopenLastTabOnLogin(restoreLastTab); + displaySettingsManager.storeSettings(); } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DisplaySettings.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DisplaySettings.java index 63058789163..cd0ee1186b7 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DisplaySettings.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/DisplaySettings.java @@ -24,7 +24,7 @@ import java.util.Map; import ch.systemsx.cisd.openbis.generic.shared.basic.ISerializable; /** - * Class storing personalised display settings. This class implements {@link Serializable} not only + * Class storing personalized display settings. This class implements {@link Serializable} not only * for transferring it's content remotely but also to store it in the database. Thus, CHANGES IN * THIS CLASS MIGHT LEAD TO A LOST OF PERSONAL SETTINGS. In all cases deserialization leads to an * exception the default settings is used. @@ -60,6 +60,8 @@ public class DisplaySettings implements ISerializable private String lastHistoryTokenOrNull; + private boolean ignoreLastHistoryToken = false; + private RealNumberFormatingParameters realNumberFormatingParameters = new RealNumberFormatingParameters(); @@ -225,14 +227,32 @@ public class DisplaySettings implements ISerializable debugging = isDebugging; } + /** @deprecated Should be used only by DisplaySettingsManager. */ + @Deprecated public String getLastHistoryTokenOrNull() { return lastHistoryTokenOrNull; } + /** @deprecated Should be used only by DisplaySettingsManager. */ + @Deprecated public void setLastHistoryTokenOrNull(String lastHistoryOrNull) { this.lastHistoryTokenOrNull = lastHistoryOrNull; } + /** @deprecated Should be used only by DisplaySettingsManager. */ + @Deprecated + public boolean isIgnoreLastHistoryToken() + { + return ignoreLastHistoryToken; + } + + /** @deprecated Should be used only by DisplaySettingsManager. */ + @Deprecated + public void setIgnoreLastHistoryToken(boolean ignoreLastHistoryToken) + { + this.ignoreLastHistoryToken = ignoreLastHistoryToken; + } + } 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 fc0341024d6..d27e0acc9c5 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 @@ -487,6 +487,8 @@ var common = { real_number_formating_precision: "Precision", debugging_mode: "Enable Debugging Mode", debugging_mode_info: "This mode is for advanced users. When enabled information like detailed error messages useful e.g. when debugging scripts invoked by openbis will be shown.", + reopen_last_tab_on_login_label: "Reopen Last Tab", + reopen_last_tab_on_login_info: "Check to reopen last opened tab after login. Note, that it works only if you enter openBIS with URL to the welcome page.", // // Role View -- GitLab