Lines 41-47
Link Here
|
41 |
* Version 2 license, then the option applies only if the new code is |
41 |
* Version 2 license, then the option applies only if the new code is |
42 |
* made subject to such option by the copyright holder. |
42 |
* made subject to such option by the copyright holder. |
43 |
*/ |
43 |
*/ |
44 |
package org.netbeans.modules.git.ui.blame; |
44 |
package org.netbeans.modules.versioning.system.cvss.ui.actions.annotate; |
45 |
|
45 |
|
46 |
import java.awt.AWTEvent; |
46 |
import java.awt.AWTEvent; |
47 |
import java.awt.BorderLayout; |
47 |
import java.awt.BorderLayout; |
Lines 64-71
Link Here
|
64 |
import java.awt.event.WindowEvent; |
64 |
import java.awt.event.WindowEvent; |
65 |
import java.awt.event.WindowFocusListener; |
65 |
import java.awt.event.WindowFocusListener; |
66 |
import java.text.DateFormat; |
66 |
import java.text.DateFormat; |
67 |
import java.util.Date; |
|
|
68 |
import java.util.List; |
69 |
import javax.swing.BorderFactory; |
67 |
import javax.swing.BorderFactory; |
70 |
import javax.swing.JComponent; |
68 |
import javax.swing.JComponent; |
71 |
import javax.swing.JScrollPane; |
69 |
import javax.swing.JScrollPane; |
Lines 78-90
Link Here
|
78 |
import javax.swing.text.Style; |
76 |
import javax.swing.text.Style; |
79 |
import javax.swing.text.StyleConstants; |
77 |
import javax.swing.text.StyleConstants; |
80 |
import javax.swing.text.StyledDocument; |
78 |
import javax.swing.text.StyledDocument; |
81 |
import org.netbeans.modules.git.Git; |
79 |
import org.netbeans.lib.cvsclient.command.annotate.AnnotateLine; |
82 |
import org.netbeans.modules.versioning.util.VCSHyperlinkSupport; |
|
|
83 |
import org.netbeans.modules.versioning.util.VCSHyperlinkSupport.AuthorLinker; |
84 |
import org.netbeans.modules.versioning.util.VCSHyperlinkSupport.IssueLinker; |
85 |
import org.netbeans.modules.versioning.util.VCSHyperlinkSupport.StyledDocumentHyperlink; |
86 |
import org.netbeans.modules.versioning.util.VCSHyperlinkProvider; |
87 |
import org.netbeans.modules.versioning.util.VCSKenaiAccessor.KenaiUser; |
88 |
|
80 |
|
89 |
/** |
81 |
/** |
90 |
* Window displaying the line annotation with links to bugtracking in the commit message. |
82 |
* Window displaying the line annotation with links to bugtracking in the commit message. |
Lines 100-121
Link Here
|
100 |
private final AnnotationBar master; |
92 |
private final AnnotationBar master; |
101 |
private JTextPane textPane; |
93 |
private JTextPane textPane; |
102 |
private final AnnotateLine annotateLine; |
94 |
private final AnnotateLine annotateLine; |
103 |
/** |
|
|
104 |
* Start of the commit message inside the full displayed message |
105 |
*/ |
106 |
private int messageOffset; |
107 |
|
108 |
private VCSHyperlinkSupport linkerSupport = new VCSHyperlinkSupport(); |
109 |
|
95 |
|
110 |
/** |
96 |
/** |
111 |
* Currently showing popup |
97 |
* Currently showing popup |
112 |
*/ |
98 |
*/ |
113 |
private JWindow contentWindow; |
99 |
private JWindow contentWindow; |
114 |
private TooltipContentPanel cp; |
100 |
private TooltipContentPanel cp; |
|
|
101 |
private final String commitMessage; |
115 |
|
102 |
|
116 |
public TooltipWindow(AnnotationBar master, final AnnotateLine al) { |
103 |
public TooltipWindow(AnnotationBar master, final AnnotateLine al, String commitMessage) { |
117 |
this.annotateLine = al; |
104 |
this.annotateLine = al; |
118 |
this.master = master; |
105 |
this.master = master; |
|
|
106 |
this.commitMessage = commitMessage; |
119 |
} |
107 |
} |
120 |
|
108 |
|
121 |
public void show(Point location) { |
109 |
public void show(Point location) { |
Lines 131-137
Link Here
|
131 |
} |
119 |
} |
132 |
|
120 |
|
133 |
// showing the popup tooltip |
121 |
// showing the popup tooltip |
134 |
cp = new TooltipContentPanel(master.getTextComponent()); |
122 |
cp = new TooltipContentPanel(master.getTextComponent(), this.commitMessage); |
135 |
|
123 |
|
136 |
Window w = SwingUtilities.windowForComponent(master.getTextComponent()); |
124 |
Window w = SwingUtilities.windowForComponent(master.getTextComponent()); |
137 |
contentWindow = new JWindow(w); |
125 |
contentWindow = new JWindow(w); |
Lines 210-217
Link Here
|
210 |
public void mouseMoved(MouseEvent e) { |
198 |
public void mouseMoved(MouseEvent e) { |
211 |
if (e.getSource().equals(textPane)) { |
199 |
if (e.getSource().equals(textPane)) { |
212 |
textPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
200 |
textPane.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
213 |
linkerSupport.computeBounds(textPane, 0); |
201 |
// NOTE: hyperlinking not supported for CVS? |
214 |
linkerSupport.mouseMoved(e.getPoint(), textPane, messageOffset); |
|
|
215 |
} |
202 |
} |
216 |
textPane.setToolTipText(""); // NOI18N |
203 |
textPane.setToolTipText(""); // NOI18N |
217 |
} |
204 |
} |
Lines 219-228
Link Here
|
219 |
@Override |
206 |
@Override |
220 |
public void mouseClicked(MouseEvent e) { |
207 |
public void mouseClicked(MouseEvent e) { |
221 |
if (e.getSource().equals(textPane)) { |
208 |
if (e.getSource().equals(textPane)) { |
222 |
linkerSupport.computeBounds(textPane, 0); |
209 |
// NOTE: hyperlinking not supported for CVS? |
223 |
if(linkerSupport.mouseClicked(e.getPoint(), 0)) { |
|
|
224 |
shutdown(); // close this window |
225 |
} |
226 |
} |
210 |
} |
227 |
} |
211 |
} |
228 |
|
212 |
|
Lines 260-266
Link Here
|
260 |
|
244 |
|
261 |
private class TooltipContentPanel extends JComponent { |
245 |
private class TooltipContentPanel extends JComponent { |
262 |
|
246 |
|
263 |
public TooltipContentPanel(JTextComponent parentPane) { |
247 |
public TooltipContentPanel(JTextComponent parentPane, String commitMessage) { |
264 |
try { |
248 |
try { |
265 |
textPane = new JTextPane(); |
249 |
textPane = new JTextPane(); |
266 |
StyledDocument doc = (StyledDocument) textPane.getDocument(); |
250 |
StyledDocument doc = (StyledDocument) textPane.getDocument(); |
Lines 276-330
Link Here
|
276 |
// revision |
260 |
// revision |
277 |
doc.insertString( |
261 |
doc.insertString( |
278 |
doc.getLength(), |
262 |
doc.getLength(), |
279 |
annotateLine.getRevisionInfo().getRevision().substring(0, 7) + " - ", |
263 |
annotateLine.getRevision() + " - ", |
280 |
normalStyle); |
264 |
normalStyle); |
281 |
|
265 |
|
282 |
// author |
266 |
// author |
283 |
{ |
267 |
{ |
284 |
String author = annotateLine.getAuthor().toString(); |
268 |
String author = annotateLine.getAuthor().toString(); |
285 |
StyledDocumentHyperlink l = linkerSupport.getLinker(AuthorLinker.class, 0); |
269 |
//NOTE kenai is not supported for CVS? |
286 |
if (master.isKenai()) { |
270 |
doc.insertString(doc.getLength(), author, normalStyle); |
287 |
KenaiUser kenaiUser = master.getKenaiUser(author); |
|
|
288 |
if (kenaiUser != null) { |
289 |
l = new AuthorLinker( |
290 |
kenaiUser, |
291 |
authorStyle, |
292 |
doc, |
293 |
author, |
294 |
KenaiUser.getChatLink( |
295 |
master.getCurrentFileObject(), |
296 |
annotateLine.getLineNum())); |
297 |
linkerSupport.add(l, 0); |
298 |
} |
299 |
} |
300 |
if (l != null) { |
301 |
l.insertString(doc, authorStyle); |
302 |
} else { |
303 |
doc.insertString(doc.getLength(), author, normalStyle); |
304 |
} |
305 |
} |
271 |
} |
306 |
// date |
272 |
// date |
307 |
doc.insertString(doc.getLength(), " ", normalStyle); |
273 |
doc.insertString(doc.getLength(), " ", normalStyle); |
308 |
doc.insertString(doc.getLength(), DateFormat.getDateInstance().format(new Date(annotateLine.getRevisionInfo().getCommitTime())), normalStyle); |
274 |
doc.insertString(doc.getLength(), DateFormat.getDateInstance().format(annotateLine.getDate()), normalStyle); |
309 |
doc.insertString(doc.getLength(), "\n", normalStyle); |
275 |
doc.insertString(doc.getLength(), "\n", normalStyle); |
310 |
|
276 |
|
311 |
// commit msg |
277 |
// commit msg |
312 |
{ |
278 |
{ |
313 |
StyledDocumentHyperlink l = null; |
279 |
//NOTE: hyperlinks are not supported for CVS? |
314 |
String commitMessage = annotateLine.getRevisionInfo().getFullMessage(); |
280 |
doc.insertString(doc.getLength(), commitMessage, normalStyle); |
315 |
List<VCSHyperlinkProvider> providers = Git.getInstance().getHyperlinkProviders(); |
|
|
316 |
for (VCSHyperlinkProvider hp : providers) { |
317 |
l = IssueLinker.create(hp, hyperlinkStyle, master.getRepositoryRoot(), doc, commitMessage); |
318 |
if (l != null) { |
319 |
linkerSupport.add(l, 0); |
320 |
break; |
321 |
} |
322 |
} |
323 |
if (l != null) { |
324 |
l.insertString(doc, normalStyle); |
325 |
} else { |
326 |
doc.insertString(doc.getLength(), commitMessage, normalStyle); |
327 |
} |
328 |
} |
281 |
} |
329 |
textPane.setDocument(doc); |
282 |
textPane.setDocument(doc); |
330 |
textPane.setEditable(false); |
283 |
textPane.setEditable(false); |