Paul Martin
2016-04-30 a502d96a860456ec5e8c96761db70f7cabb74751
src/main/java/com/gitblit/wicket/panels/BasePanel.java
@@ -22,54 +22,59 @@
import org.apache.wicket.Component;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.Model;
import org.apache.wicket.protocol.http.request.WebClientInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.gitblit.Constants;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.utils.TimeUtils;
import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.GitBlitWebSession;
import com.gitblit.wicket.WicketUtils;
public abstract class BasePanel extends Panel {
   private static final long serialVersionUID = 1L;
   private transient TimeUtils timeUtils;
   private transient Logger logger;
   public BasePanel(String wicketId) {
      super(wicketId);
   }
   protected TimeZone getTimeZone() {
      return GitBlit.getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
            .getTimezone() : GitBlit.getTimezone();
   protected GitBlitWebApp app() {
      return GitBlitWebApp.get();
   }
   protected Logger logger() {
      if (logger == null) {
         logger = LoggerFactory.getLogger(getClass());
      }
      return logger;
   }
   protected String getContextUrl() {
      return getRequest().getRelativePathPrefixToContextRoot();
   }
   protected TimeZone getTimeZone() {
      return app().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get()
            .getTimezone() : app().getTimezone();
   }
   protected TimeUtils getTimeUtils() {
      if (timeUtils == null) {
         ResourceBundle bundle;
         ResourceBundle bundle;
         try {
            bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", GitBlitWebSession.get().getLocale());
         } catch (Throwable t) {
            bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp");
         }
         timeUtils = new TimeUtils(bundle);
         timeUtils = new TimeUtils(bundle, getTimeZone());
      }
      return timeUtils;
   }
   protected boolean isWindows() {
      return isPlatform("windows");
   }
   protected boolean isMac() {
      return isPlatform("macintosh");
   }
   protected boolean isPlatform(String platform) {
      String ua = ((WebClientInfo) GitBlitWebSession.get().getClientInfo()).getUserAgent();
      return ua.toLowerCase().contains(platform);
   }
   protected void setPersonSearchTooltip(Component component, String value, Constants.SearchType searchType) {
@@ -88,6 +93,7 @@
         super(event, true, new Model<String>(msg));
      }
      @Override
      protected String newValue(final String currentValue, final String replacementValue) {
         String prefix = "var conf = confirm('" + replacementValue + "'); "
               + "if (!conf) return false; ";
@@ -104,12 +110,13 @@
      private static final long serialVersionUID = 1L;
      private String initialValue = "";
      public JavascriptTextPrompt(String event, String msg, String value) {
         super(event, true, new Model<String>(msg));
         initialValue = value;
      }
      @Override
      protected String newValue(final String currentValue, final String message) {
         String result = "var userText = prompt('" + message + "','"
               + (initialValue == null ? "" : initialValue) + "'); " + "return userText; ";