You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BasePanel.java 2.3KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /*
  2. * Copyright 2011 gitblit.com.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.gitblit.wicket.panels;
  17. import java.util.TimeZone;
  18. import org.apache.wicket.AttributeModifier;
  19. import org.apache.wicket.Component;
  20. import org.apache.wicket.markup.html.panel.Panel;
  21. import org.apache.wicket.model.Model;
  22. import com.gitblit.GitBlit;
  23. import com.gitblit.Keys;
  24. import com.gitblit.utils.JGitUtils.SearchType;
  25. import com.gitblit.wicket.GitBlitWebSession;
  26. import com.gitblit.wicket.WicketUtils;
  27. public abstract class BasePanel extends Panel {
  28. private static final long serialVersionUID = 1L;
  29. public BasePanel(String wicketId) {
  30. super(wicketId);
  31. }
  32. protected TimeZone getTimeZone() {
  33. return GitBlit.self().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();
  34. }
  35. protected void setPersonSearchTooltip(Component component, String value, SearchType searchType) {
  36. if (searchType.equals(SearchType.AUTHOR)) {
  37. WicketUtils.setHtmlTooltip(component, getString("gb.searchForAuthor") + " " + value);
  38. } else if (searchType.equals(SearchType.COMMITTER)) {
  39. WicketUtils.setHtmlTooltip(component, getString("gb.searchForCommitter") + " " + value);
  40. }
  41. }
  42. public class JavascriptEventConfirmation extends AttributeModifier {
  43. private static final long serialVersionUID = 1L;
  44. public JavascriptEventConfirmation(String event, String msg) {
  45. super(event, true, new Model<String>(msg));
  46. }
  47. protected String newValue(final String currentValue, final String replacementValue) {
  48. String prefix = "var conf = confirm('" + replacementValue + "'); " + "if (!conf) return false; ";
  49. String result = prefix;
  50. if (currentValue != null) {
  51. result = prefix + currentValue;
  52. }
  53. return result;
  54. }
  55. }
  56. }