View Javadoc

1   /**
2    * Copyright (C) 2008 Atlassian
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  
17  package com.atlassian.theplugin.idea.config;
18  
19  import com.atlassian.theplugin.idea.Constants;
20  import com.atlassian.theplugin.idea.HelpUrl;
21  import com.atlassian.theplugin.idea.BugReporting;
22  import com.intellij.ide.BrowserUtil;
23  import com.intellij.ui.HyperlinkLabel;
24  import com.intellij.openapi.application.ApplicationInfo;
25  
26  import javax.swing.*;
27  import javax.swing.event.HyperlinkEvent;
28  import javax.swing.event.HyperlinkListener;
29  import java.awt.*;
30  
31  public class FooterPanel extends JPanel {
32  
33  
34  	public FooterPanel() {
35  		initLayout();
36      }
37  
38  	private void initLayout() {
39  
40  		GridBagLayout gb = new GridBagLayout();
41  		setLayout(gb);
42  
43  
44  		final String helpUrl = HelpUrl.getHelpUrl(Constants.HELP_CONFIG_PANEL);
45  
46  		JPanel linkPanel = new JPanel();
47  
48  		final HyperlinkLabel openJiraHyperlinkBugLabel = new HyperlinkLabel("Report Bug");
49  		openJiraHyperlinkBugLabel.addHyperlinkListener(new HyperlinkListener() {
50  			public void hyperlinkUpdate(HyperlinkEvent e) {
51  				BrowserUtil.launchBrowser(BugReporting.getBugUrl(ApplicationInfo.getInstance().getBuildNumber()));
52  			}
53  		});
54  
55  		final HyperlinkLabel openJiraHyperlinkStoryLabel = new HyperlinkLabel("Request Feature");
56  		openJiraHyperlinkStoryLabel.addHyperlinkListener(new HyperlinkListener() {
57  			public void hyperlinkUpdate(HyperlinkEvent e) {
58  				BrowserUtil.launchBrowser(BugReporting.getStoryUrl());
59  			}
60  		});
61  
62  		// jgorycki: in my and Marek's opinion, text-based link looks marginally less bad than an icon
63  		final HyperlinkLabel openConfigHelpLabel = new HyperlinkLabel("Help");
64  //		openConfigHelpLabel.setIcon(Constants.HELP_ICON);
65  //		openConfigHelpLabel.setToolTipText(helpUrl);
66  
67  		openConfigHelpLabel.addHyperlinkListener(new HyperlinkListener() {
68  			public void hyperlinkUpdate(HyperlinkEvent e) {
69  				BrowserUtil.launchBrowser(helpUrl);
70  			}
71  		});
72  
73  		linkPanel.add(openJiraHyperlinkBugLabel);
74  		linkPanel.add(new JLabel("|"));
75  		linkPanel.add(openJiraHyperlinkStoryLabel);
76  		linkPanel.add(new JLabel(BugReporting.getVersionString()));
77  		
78  		GridBagConstraints c = new GridBagConstraints();
79  
80  		c.gridx = 0;
81  		c.fill = GridBagConstraints.NONE;
82  		add(linkPanel, c);
83  		c.gridx = 1;
84  		c.weightx = 1;
85  		c.fill = GridBagConstraints.HORIZONTAL;
86  		add(new JPanel(), c);
87  		c.gridx = 2;
88  		c.weightx = 0;
89  		c.anchor = GridBagConstraints.LINE_END;
90  		c.insets = new Insets(0, 0, 0, Constants.DIALOG_MARGIN);
91  		add(openConfigHelpLabel, c);
92  	}
93  }