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.

SparkleShareInvitePanel.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. /*
  2. * Copyright 2013 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 org.apache.wicket.Component;
  18. import org.apache.wicket.Localizer;
  19. import org.apache.wicket.markup.html.basic.Label;
  20. import org.apache.wicket.markup.html.image.ContextImage;
  21. import org.apache.wicket.markup.html.link.ExternalLink;
  22. import com.gitblit.Constants.AccessPermission;
  23. import com.gitblit.wicket.WicketUtils;
  24. public class SparkleShareInvitePanel extends BasePanel {
  25. private static final long serialVersionUID = 1L;
  26. public SparkleShareInvitePanel(String wicketId, Localizer localizer, Component parent, String url, AccessPermission ap) {
  27. super(wicketId);
  28. ContextImage star = WicketUtils.newImage("sparkleshareIcon", "star_16x16.png");
  29. add(star);
  30. add(new ExternalLink("inviteUrl", url));
  31. String note = localizer.getString("gb.externalAccess", parent);
  32. String permission = "";
  33. if (ap != null) {
  34. permission = ap.toString();
  35. if (ap.atLeast(AccessPermission.PUSH)) {
  36. note = localizer.getString("gb.readWriteAccess", parent);
  37. } else if (ap.atLeast(AccessPermission.CLONE)) {
  38. note = localizer.getString("gb.readOnlyAccess", parent);
  39. } else {
  40. note = localizer.getString("gb.viewAccess", parent);
  41. }
  42. }
  43. Label label = new Label("accessPermission", permission);
  44. WicketUtils.setHtmlTooltip(label, note);
  45. add(label);
  46. }
  47. }