James Moger
2012-10-22 eba89539a29deba954035056437279088c3e047b
commit | author | age
82df52 1 /*
JM 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
18 import org.apache.wicket.markup.html.basic.Label;
19 import org.apache.wicket.markup.html.image.ContextImage;
3b6904 20 import org.apache.wicket.markup.html.panel.Fragment;
82df52 21
3b6904 22 import com.gitblit.GitBlit;
JM 23 import com.gitblit.Keys;
24 import com.gitblit.utils.StringUtils;
82df52 25 import com.gitblit.wicket.WicketUtils;
JM 26
27 public class RepositoryUrlPanel extends BasePanel {
28
29     private static final long serialVersionUID = 1L;
30
31     public RepositoryUrlPanel(String wicketId, String url) {
32         super(wicketId);
33         add(new Label("repositoryUrl", url));
3b6904 34         if (GitBlit.getBoolean(Keys.web.allowFlashCopyToClipboard, true)) {
JM 35             // clippy: flash-based copy & paste
36             Fragment fragment = new Fragment("copyFunction", "clippyPanel", this);
37             String baseUrl = WicketUtils.getGitblitURL(getRequest());
38             ShockWaveComponent clippy = new ShockWaveComponent("clippy", baseUrl + "/clippy.swf");
39             clippy.setValue("flashVars", "text=" + StringUtils.encodeURL(url));
40             fragment.add(clippy);
41             add(fragment);
42         } else {
43             // javascript: manual copy & paste with modal browser prompt dialog
44             Fragment fragment = new Fragment("copyFunction", "jsPanel", this);
13a3f5 45             ContextImage img = WicketUtils.newImage("copyIcon", "clippy.png");
3b6904 46             img.add(new JavascriptTextPrompt("onclick", "Copy to Clipboard (Ctrl+C, Enter)", url));
JM 47             fragment.add(img);
48             add(fragment);
49         }
82df52 50     }
JM 51 }