|
Lines 11-48
Link Here
|
| 11 |
package org.eclipse.team.internal.ccvs.ui; |
11 |
package org.eclipse.team.internal.ccvs.ui; |
| 12 |
|
12 |
|
| 13 |
|
13 |
|
|
|
14 |
import java.io.IOException; |
| 14 |
import java.io.InputStream; |
15 |
import java.io.InputStream; |
| 15 |
import java.lang.reflect.InvocationTargetException; |
16 |
import java.lang.reflect.InvocationTargetException; |
|
|
17 |
import java.net.MalformedURLException; |
| 18 |
import java.net.URL; |
| 19 |
import java.net.URLConnection; |
| 16 |
import java.util.ArrayList; |
20 |
import java.util.ArrayList; |
|
|
21 |
import java.util.HashMap; |
| 17 |
import java.util.Iterator; |
22 |
import java.util.Iterator; |
| 18 |
|
23 |
import java.util.Set; |
| 19 |
import org.eclipse.core.resources.*; |
24 |
import java.util.regex.Matcher; |
| 20 |
import org.eclipse.core.runtime.*; |
25 |
import java.util.regex.Pattern; |
|
|
26 |
import org.eclipse.core.resources.IFile; |
| 27 |
import org.eclipse.core.resources.IResource; |
| 28 |
import org.eclipse.core.resources.IWorkspaceRunnable; |
| 29 |
import org.eclipse.core.runtime.CoreException; |
| 30 |
import org.eclipse.core.runtime.IAdaptable; |
| 31 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 32 |
import org.eclipse.core.runtime.IStatus; |
| 33 |
import org.eclipse.core.runtime.QualifiedName; |
| 34 |
import org.eclipse.core.runtime.Status; |
| 35 |
import org.eclipse.core.runtime.SubProgressMonitor; |
| 21 |
import org.eclipse.core.runtime.jobs.Job; |
36 |
import org.eclipse.core.runtime.jobs.Job; |
| 22 |
import org.eclipse.jface.action.*; |
37 |
import org.eclipse.jface.action.Action; |
| 23 |
import org.eclipse.jface.dialogs.*; |
38 |
import org.eclipse.jface.action.IAction; |
|
|
39 |
import org.eclipse.jface.action.IMenuListener; |
| 40 |
import org.eclipse.jface.action.IMenuManager; |
| 41 |
import org.eclipse.jface.action.IToolBarManager; |
| 42 |
import org.eclipse.jface.action.MenuManager; |
| 43 |
import org.eclipse.jface.action.Separator; |
| 44 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 45 |
import org.eclipse.jface.dialogs.MessageDialog; |
| 46 |
import org.eclipse.jface.dialogs.ProgressMonitorDialog; |
| 24 |
import org.eclipse.jface.preference.IPreferenceStore; |
47 |
import org.eclipse.jface.preference.IPreferenceStore; |
| 25 |
import org.eclipse.jface.text.*; |
48 |
import org.eclipse.jface.text.Document; |
| 26 |
import org.eclipse.jface.viewers.*; |
49 |
import org.eclipse.jface.text.ITextOperationTarget; |
|
|
50 |
import org.eclipse.jface.text.TextViewer; |
| 51 |
import org.eclipse.jface.viewers.ColumnWeightData; |
| 52 |
import org.eclipse.jface.viewers.ISelection; |
| 53 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
| 54 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
| 55 |
import org.eclipse.jface.viewers.IStructuredSelection; |
| 56 |
import org.eclipse.jface.viewers.LabelProvider; |
| 57 |
import org.eclipse.jface.viewers.SelectionChangedEvent; |
| 58 |
import org.eclipse.jface.viewers.StructuredSelection; |
| 59 |
import org.eclipse.jface.viewers.TableLayout; |
| 60 |
import org.eclipse.jface.viewers.TableViewer; |
| 61 |
import org.eclipse.jface.viewers.Viewer; |
| 62 |
import org.eclipse.jface.viewers.ViewerSorter; |
| 27 |
import org.eclipse.swt.SWT; |
63 |
import org.eclipse.swt.SWT; |
| 28 |
import org.eclipse.swt.custom.*; |
64 |
import org.eclipse.swt.custom.BusyIndicator; |
|
|
65 |
import org.eclipse.swt.custom.SashForm; |
| 66 |
import org.eclipse.swt.custom.StyledText; |
| 29 |
import org.eclipse.swt.dnd.DND; |
67 |
import org.eclipse.swt.dnd.DND; |
| 30 |
import org.eclipse.swt.dnd.Transfer; |
68 |
import org.eclipse.swt.dnd.Transfer; |
|
|
69 |
import org.eclipse.swt.events.ControlEvent; |
| 70 |
import org.eclipse.swt.events.ControlListener; |
| 71 |
import org.eclipse.swt.events.MouseEvent; |
| 72 |
import org.eclipse.swt.events.MouseListener; |
| 73 |
import org.eclipse.swt.events.MouseMoveListener; |
| 74 |
import org.eclipse.swt.events.PaintEvent; |
| 75 |
import org.eclipse.swt.events.PaintListener; |
| 76 |
import org.eclipse.swt.graphics.Color; |
| 77 |
import org.eclipse.swt.graphics.Cursor; |
| 78 |
import org.eclipse.swt.graphics.GC; |
| 31 |
import org.eclipse.swt.graphics.Image; |
79 |
import org.eclipse.swt.graphics.Image; |
|
|
80 |
import org.eclipse.swt.graphics.Point; |
| 81 |
import org.eclipse.swt.graphics.Rectangle; |
| 32 |
import org.eclipse.swt.layout.GridData; |
82 |
import org.eclipse.swt.layout.GridData; |
| 33 |
import org.eclipse.swt.widgets.*; |
83 |
import org.eclipse.swt.widgets.Composite; |
|
|
84 |
import org.eclipse.swt.widgets.Display; |
| 85 |
import org.eclipse.swt.widgets.Event; |
| 86 |
import org.eclipse.swt.widgets.Listener; |
| 87 |
import org.eclipse.swt.widgets.Menu; |
| 88 |
import org.eclipse.swt.widgets.Table; |
| 34 |
import org.eclipse.team.core.RepositoryProvider; |
89 |
import org.eclipse.team.core.RepositoryProvider; |
| 35 |
import org.eclipse.team.core.TeamException; |
90 |
import org.eclipse.team.core.TeamException; |
| 36 |
import org.eclipse.team.core.synchronize.SyncInfo; |
91 |
import org.eclipse.team.core.synchronize.SyncInfo; |
| 37 |
import org.eclipse.team.internal.ccvs.core.*; |
92 |
import org.eclipse.team.internal.ccvs.core.CVSException; |
|
|
93 |
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; |
| 94 |
import org.eclipse.team.internal.ccvs.core.CVSSyncInfo; |
| 95 |
import org.eclipse.team.internal.ccvs.core.CVSTag; |
| 96 |
import org.eclipse.team.internal.ccvs.core.ICVSFile; |
| 97 |
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile; |
| 98 |
import org.eclipse.team.internal.ccvs.core.ICVSResource; |
| 99 |
import org.eclipse.team.internal.ccvs.core.ILogEntry; |
| 38 |
import org.eclipse.team.internal.ccvs.core.client.Command; |
100 |
import org.eclipse.team.internal.ccvs.core.client.Command; |
| 39 |
import org.eclipse.team.internal.ccvs.core.client.Update; |
101 |
import org.eclipse.team.internal.ccvs.core.client.Update; |
| 40 |
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; |
102 |
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; |
| 41 |
import org.eclipse.team.internal.ccvs.ui.actions.*; |
103 |
import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; |
|
|
104 |
import org.eclipse.team.internal.ccvs.ui.actions.MoveRemoteTagAction; |
| 105 |
import org.eclipse.team.internal.ccvs.ui.actions.OpenLogEntryAction; |
| 42 |
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; |
106 |
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation; |
| 43 |
import org.eclipse.team.internal.ui.Utils; |
107 |
import org.eclipse.team.internal.ui.Utils; |
| 44 |
import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; |
108 |
import org.eclipse.team.ui.synchronize.SyncInfoCompareInput; |
| 45 |
import org.eclipse.ui.*; |
109 |
import org.eclipse.ui.IActionBars; |
|
|
110 |
import org.eclipse.ui.IActionDelegate; |
| 111 |
import org.eclipse.ui.IEditorInput; |
| 112 |
import org.eclipse.ui.IEditorPart; |
| 113 |
import org.eclipse.ui.IFileEditorInput; |
| 114 |
import org.eclipse.ui.IPartListener; |
| 115 |
import org.eclipse.ui.IPartListener2; |
| 116 |
import org.eclipse.ui.IReusableEditor; |
| 117 |
import org.eclipse.ui.IWorkbenchActionConstants; |
| 118 |
import org.eclipse.ui.IWorkbenchPage; |
| 119 |
import org.eclipse.ui.IWorkbenchPart; |
| 120 |
import org.eclipse.ui.IWorkbenchPartReference; |
| 121 |
import org.eclipse.ui.PartInitException; |
| 122 |
import org.eclipse.ui.PlatformUI; |
| 46 |
import org.eclipse.ui.actions.WorkspaceModifyOperation; |
123 |
import org.eclipse.ui.actions.WorkspaceModifyOperation; |
| 47 |
import org.eclipse.ui.help.WorkbenchHelp; |
124 |
import org.eclipse.ui.help.WorkbenchHelp; |
| 48 |
import org.eclipse.ui.part.ResourceTransfer; |
125 |
import org.eclipse.ui.part.ResourceTransfer; |
|
Lines 62-68
Link Here
|
| 62 |
private TableViewer tableViewer; |
139 |
private TableViewer tableViewer; |
| 63 |
private TextViewer textViewer; |
140 |
private TextViewer textViewer; |
| 64 |
private TableViewer tagViewer; |
141 |
private TableViewer tagViewer; |
| 65 |
|
142 |
private StyledText text; |
|
|
143 |
private HashMap map = new HashMap(); |
| 144 |
private int cursorStatus = 0; |
| 145 |
private String bugNum; |
| 66 |
private OpenLogEntryAction openAction; |
146 |
private OpenLogEntryAction openAction; |
| 67 |
private IAction toggleTextAction; |
147 |
private IAction toggleTextAction; |
| 68 |
private IAction toggleListAction; |
148 |
private IAction toggleListAction; |
|
Lines 89-95
Link Here
|
| 89 |
|
169 |
|
| 90 |
private boolean shutdown = false; |
170 |
private boolean shutdown = false; |
| 91 |
|
171 |
|
|
|
172 |
private static final String bugPattern = "[bB]ug [0-9]+"; |
| 92 |
public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.HistoryView"; //$NON-NLS-1$ |
173 |
public static final String VIEW_ID = "org.eclipse.team.ccvs.ui.HistoryView"; //$NON-NLS-1$ |
|
|
174 |
private String link = "https://bugs.eclipse.org/bugs/show_bug.cgi?id="; |
| 93 |
|
175 |
|
| 94 |
private IPartListener partListener = new IPartListener() { |
176 |
private IPartListener partListener = new IPartListener() { |
| 95 |
public void partActivated(IWorkbenchPart part) { |
177 |
public void partActivated(IWorkbenchPart part) { |
|
Lines 160-166
Link Here
|
| 160 |
return e.getStatus(); |
242 |
return e.getStatus(); |
| 161 |
} |
243 |
} |
| 162 |
} |
244 |
} |
| 163 |
}; |
245 |
} |
| 164 |
|
246 |
|
| 165 |
/** |
247 |
/** |
| 166 |
* Adds the action contributions for this view. |
248 |
* Adds the action contributions for this view. |
|
Lines 346-354
Link Here
|
| 346 |
fillTextMenu(menuMgr); |
428 |
fillTextMenu(menuMgr); |
| 347 |
} |
429 |
} |
| 348 |
}); |
430 |
}); |
| 349 |
StyledText text = textViewer.getTextWidget(); |
431 |
text = textViewer.getTextWidget(); |
| 350 |
menu = menuMgr.createContextMenu(text); |
432 |
menu = menuMgr.createContextMenu(text); |
| 351 |
text.setMenu(menu); |
433 |
text.setMenu(menu); |
|
|
434 |
text.addControlListener( new ControlListener(){ |
| 435 |
public void controlMoved(ControlEvent e) { |
| 436 |
// text.setWordWrap(true); |
| 437 |
// extractBugPatterns(text.getText()); |
| 438 |
} |
| 439 |
|
| 440 |
public void controlResized(ControlEvent e) { |
| 441 |
boolean b = text.getWordWrap(); |
| 442 |
text.setWordWrap(true); |
| 443 |
extractBugPatterns(text.getText()); |
| 444 |
} |
| 445 |
|
| 446 |
}); |
| 447 |
text.addPaintListener(new PaintListener() { |
| 448 |
public void paintControl(PaintEvent e) { |
| 449 |
for (Iterator it = map.keySet().iterator(); it.hasNext();) { |
| 450 |
Rectangle rect = (Rectangle) it.next(); |
| 451 |
GC gc = new GC(text); |
| 452 |
Color preClick = text.getDisplay().getSystemColor(SWT.COLOR_BLUE); |
| 453 |
gc.setForeground(preClick); |
| 454 |
int lineHeight = text.getLineHeight(); |
| 455 |
gc.drawLine(rect.x, rect.y + lineHeight, rect.x + rect.width, rect.y + lineHeight); |
| 456 |
gc.dispose(); |
| 457 |
} |
| 458 |
} |
| 459 |
}); |
| 460 |
text.addMouseMoveListener(new MouseMoveListener(){ |
| 461 |
public void mouseMove(MouseEvent e){ |
| 462 |
handleMouseMove(e); |
| 463 |
} |
| 464 |
}); |
| 465 |
text.addMouseListener(new MouseListener(){ |
| 466 |
public void mouseDoubleClick(MouseEvent e) { |
| 467 |
} |
| 468 |
|
| 469 |
public void mouseDown(MouseEvent e) { |
| 470 |
|
| 471 |
} |
| 472 |
|
| 473 |
public void mouseUp(MouseEvent e) { |
| 474 |
if(cursorStatus == 1){ |
| 475 |
final String url = link + bugNum; |
| 476 |
IWorkbenchPage page = CVSUIPlugin.getPlugin().getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
| 477 |
URL address = null; |
| 478 |
InputStream input = null; |
| 479 |
try { |
| 480 |
address = new URL(url); |
| 481 |
} catch (MalformedURLException e1) { |
| 482 |
//TODO:CVSUIPlugin.log(new CoreException(e1)); |
| 483 |
} |
| 484 |
if(address != null){ |
| 485 |
try { |
| 486 |
URLConnection connection = address.openConnection(); |
| 487 |
input = connection.getInputStream(); |
| 488 |
} catch (IOException e2) { |
| 489 |
//TODO: CVSUIPlugin.log(e2); |
| 490 |
} |
| 491 |
} |
| 492 |
|
| 493 |
BrowserEditorInput ip = new BrowserEditorInput(url); |
| 494 |
try { |
| 495 |
IEditorPart editor = getSite().getPage().findEditor(ip); |
| 496 |
if(editor != null && editor instanceof IReusableEditor) { |
| 497 |
((IReusableEditor)editor).setInput(ip); |
| 498 |
} else { |
| 499 |
getSite().getPage().openEditor(ip, "org.eclipse.team.ccvs.ui.BrowserEditor"); |
| 500 |
} |
| 501 |
} catch (PartInitException e2) { |
| 502 |
Utils.handle(e2); |
| 503 |
} |
| 504 |
} |
| 505 |
} |
| 506 |
}); |
| 507 |
} |
| 508 |
|
| 509 |
private void handleMouseMove(MouseEvent e){ |
| 510 |
Point p = new Point(e.x, e.y); |
| 511 |
String bugNumber = getHighlightedBugNum(p); |
| 512 |
if(bugNumber != null){ |
| 513 |
text.setCursor(new Cursor(Display.getCurrent(), SWT.CURSOR_HAND)); |
| 514 |
text.setToolTipText("Open the bug URL"); |
| 515 |
cursorStatus = 1; |
| 516 |
bugNum = bugNumber; |
| 517 |
}else{ |
| 518 |
text.setCursor(new Cursor(Display.getCurrent(), SWT.CURSOR_IBEAM)); |
| 519 |
text.setToolTipText(null); |
| 520 |
cursorStatus = 0; |
| 521 |
} |
| 522 |
} |
| 523 |
private String getHighlightedBugNum(Point p){ |
| 524 |
Set squares = map.keySet(); |
| 525 |
Iterator iter = squares.iterator(); |
| 526 |
while(iter.hasNext()){ |
| 527 |
Rectangle rect = (Rectangle)iter.next(); |
| 528 |
if(rect.contains(p)){ |
| 529 |
return (String)map.get(rect); |
| 530 |
} |
| 531 |
} |
| 532 |
return null; |
| 352 |
} |
533 |
} |
| 353 |
private void setViewerVisibility() { |
534 |
private void setViewerVisibility() { |
| 354 |
boolean showText = toggleTextAction.isChecked(); |
535 |
boolean showText = toggleTextAction.isChecked(); |
|
Lines 459-472
Link Here
|
| 459 |
return; |
640 |
return; |
| 460 |
} |
641 |
} |
| 461 |
ILogEntry entry = (ILogEntry)ss.getFirstElement(); |
642 |
ILogEntry entry = (ILogEntry)ss.getFirstElement(); |
| 462 |
textViewer.setDocument(new Document(entry.getComment())); |
643 |
String comment = entry.getComment(); |
|
|
644 |
textViewer.setDocument(new Document(comment)); |
| 645 |
extractBugPatterns(comment); |
| 463 |
tagViewer.setInput(entry.getTags()); |
646 |
tagViewer.setInput(entry.getTags()); |
| 464 |
} |
647 |
} |
|
|
648 |
|
| 465 |
}); |
649 |
}); |
| 466 |
|
|
|
| 467 |
return viewer; |
650 |
return viewer; |
| 468 |
} |
651 |
} |
| 469 |
|
652 |
//highlight the bug patterns and save them to a hash map |
|
|
653 |
private void extractBugPatterns(String comment) { |
| 654 |
Rectangle bounds = text.getBounds(); |
| 655 |
int bx1 = bounds.x; |
| 656 |
int by1 = bounds.y; |
| 657 |
int bx2 = bx1 + bounds.width; |
| 658 |
int by2 = by1 + bounds.height; |
| 659 |
map = new HashMap(); |
| 660 |
Pattern pattern = Pattern.compile(bugPattern); |
| 661 |
Matcher matcher = pattern.matcher(comment); |
| 662 |
while(matcher.find()){ |
| 663 |
String match = matcher.group(); |
| 664 |
bugNum = match.substring(4); |
| 665 |
int start = matcher.start(); |
| 666 |
int end = matcher.end(); |
| 667 |
Color preClick = text.getDisplay().getSystemColor(SWT.COLOR_BLUE); |
| 668 |
textViewer.setTextColor(preClick, start, end-start, false); |
| 669 |
Point ul = text.getLocationAtOffset(start); |
| 670 |
Point ur = text.getLocationAtOffset(end); |
| 671 |
int lineHeight = text.getLineHeight(); |
| 672 |
int x1 = ul.x; |
| 673 |
int y1 = ul.y; |
| 674 |
int x2 = ur.x; |
| 675 |
int y2 = ur.y; |
| 676 |
Rectangle rect; |
| 677 |
//Case 1: Bug pattern is not wrapped by new line |
| 678 |
if(y1 == y2 && x2 > x1){ |
| 679 |
rect = new Rectangle(x1,y1,ur.x - x1,lineHeight); |
| 680 |
map.put(rect, bugNum); |
| 681 |
} |
| 682 |
//Case 2: A bug pattern is wrapped into multiple lines, maybe more than 2 lines |
| 683 |
if(y1 < y2){ |
| 684 |
int n = (y2 - y1)/lineHeight; |
| 685 |
//the first line |
| 686 |
rect = new Rectangle(x1, y1, bx2 - x1,lineHeight); |
| 687 |
map.put(rect, bugNum); |
| 688 |
//the middle lines |
| 689 |
for(int i = 2; i < n; i++){ |
| 690 |
rect = new Rectangle(bx1, y1 + (i-1) * lineHeight, bx2 - bx1, lineHeight); |
| 691 |
map.put(rect, bugNum); |
| 692 |
} |
| 693 |
//the last line |
| 694 |
rect = new Rectangle(bx1, y1 + n * lineHeight, x2 - bx1, lineHeight); |
| 695 |
map.put(rect, bugNum); |
| 696 |
} |
| 697 |
|
| 698 |
} |
| 699 |
} |
| 470 |
private TableViewer createTagTable(Composite parent) { |
700 |
private TableViewer createTagTable(Composite parent) { |
| 471 |
Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); |
701 |
Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER); |
| 472 |
TableViewer result = new TableViewer(table); |
702 |
TableViewer result = new TableViewer(table); |