2 * Copyright (C) 2006 Robin Rosenberg
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License, version 2.1, as published by the Free Software Foundation.
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, write to the Free Software
15 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
17 package org
.spearce
.egit
.ui
;
19 import java
.io
.IOException
;
20 import java
.util
.Date
;
21 import java
.util
.HashMap
;
22 import java
.util
.List
;
25 import org
.eclipse
.compare
.CompareConfiguration
;
26 import org
.eclipse
.compare
.structuremergeviewer
.ICompareInput
;
27 import org
.eclipse
.core
.resources
.IContainer
;
28 import org
.eclipse
.core
.resources
.IProject
;
29 import org
.eclipse
.core
.resources
.IResource
;
30 import org
.eclipse
.core
.resources
.IResourceChangeEvent
;
31 import org
.eclipse
.core
.resources
.IResourceChangeListener
;
32 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
33 import org
.eclipse
.core
.runtime
.IAdaptable
;
34 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
35 import org
.eclipse
.core
.runtime
.IStatus
;
36 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
37 import org
.eclipse
.core
.runtime
.Status
;
38 import org
.eclipse
.core
.runtime
.jobs
.Job
;
39 import org
.eclipse
.jface
.action
.Action
;
40 import org
.eclipse
.jface
.action
.IMenuListener
;
41 import org
.eclipse
.jface
.action
.IMenuManager
;
42 import org
.eclipse
.jface
.action
.MenuManager
;
43 import org
.eclipse
.jface
.resource
.JFaceResources
;
44 import org
.eclipse
.jface
.viewers
.ColumnWeightData
;
45 import org
.eclipse
.jface
.viewers
.ILazyContentProvider
;
46 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
47 import org
.eclipse
.jface
.viewers
.TableLayout
;
48 import org
.eclipse
.jface
.viewers
.TableViewer
;
49 import org
.eclipse
.jface
.viewers
.Viewer
;
50 import org
.eclipse
.swt
.SWT
;
51 import org
.eclipse
.swt
.events
.MouseEvent
;
52 import org
.eclipse
.swt
.events
.MouseListener
;
53 import org
.eclipse
.swt
.events
.MouseMoveListener
;
54 import org
.eclipse
.swt
.events
.SelectionAdapter
;
55 import org
.eclipse
.swt
.events
.SelectionEvent
;
56 import org
.eclipse
.swt
.graphics
.Point
;
57 import org
.eclipse
.swt
.layout
.GridData
;
58 import org
.eclipse
.swt
.layout
.GridLayout
;
59 import org
.eclipse
.swt
.widgets
.Composite
;
60 import org
.eclipse
.swt
.widgets
.Control
;
61 import org
.eclipse
.swt
.widgets
.Display
;
62 import org
.eclipse
.swt
.widgets
.Event
;
63 import org
.eclipse
.swt
.widgets
.Listener
;
64 import org
.eclipse
.swt
.widgets
.Menu
;
65 import org
.eclipse
.swt
.widgets
.Table
;
66 import org
.eclipse
.swt
.widgets
.TableColumn
;
67 import org
.eclipse
.swt
.widgets
.TableItem
;
68 import org
.eclipse
.team
.core
.RepositoryProvider
;
69 import org
.eclipse
.team
.core
.history
.IFileHistoryProvider
;
70 import org
.eclipse
.team
.core
.history
.IFileRevision
;
71 import org
.eclipse
.team
.internal
.ui
.TeamUIMessages
;
72 import org
.eclipse
.team
.internal
.ui
.history
.DialogHistoryPageSite
;
73 import org
.eclipse
.team
.ui
.history
.HistoryPage
;
74 import org
.eclipse
.team
.ui
.history
.IHistoryCompareAdapter
;
75 import org
.eclipse
.team
.ui
.history
.IHistoryPageSite
;
76 import org
.spearce
.egit
.core
.GitProvider
;
77 import org
.spearce
.egit
.core
.internal
.mapping
.GitFileHistory
;
78 import org
.spearce
.egit
.core
.internal
.mapping
.GitFileRevision
;
79 import org
.spearce
.egit
.core
.project
.RepositoryMapping
;
80 import org
.spearce
.egit
.ui
.internal
.actions
.GitCompareRevisionAction
;
81 import org
.spearce
.jgit
.lib
.ObjectId
;
82 import org
.spearce
.jgit
.lib
.Tag
;
83 import org
.spearce
.jgit
.lib
.TopologicalSorter
;
84 import org
.spearce
.jgit
.lib
.Repository
.StGitPatch
;
85 import org
.spearce
.jgit
.lib
.TopologicalSorter
.Edge
;
86 import org
.spearce
.jgit
.lib
.TopologicalSorter
.Lane
;
88 public class GitHistoryPage
extends HistoryPage
implements IAdaptable
,
89 IHistoryCompareAdapter
{
91 private static final String PREF_SHOWALLPROJECTVERSIONS
= "org.spearce.egit.ui.githistorypage.showallprojectversions";
92 private static final String PREF_SHOWALLFOLDERVERSIONS
= "org.spearce.egit.ui.githistorypage.showallfolderversions";
94 private Composite localComposite
;
96 private TableViewer viewer
;
100 private List
<IFileRevision
> fileRevisions
;
102 protected boolean hintShowDiffNow
;
104 private boolean showAllVersions
;
106 private boolean showAllFolderVersions
;
108 public GitHistoryPage(Object object
) {
110 showAllVersions
= Activator
.getDefault().getPreferenceStore()
111 .getBoolean(PREF_SHOWALLPROJECTVERSIONS
);
112 showAllFolderVersions
= Activator
.getDefault().getPreferenceStore()
113 .getBoolean(PREF_SHOWALLFOLDERVERSIONS
);
116 public boolean inputSet() {
118 viewer
.setInput(getInput());
119 // TODO Auto-generated method stub
123 public void createControl(Composite parent
) {
124 localComposite
= new Composite(parent
, SWT
.NONE
);
125 GridLayout layout
= new GridLayout();
126 layout
.marginHeight
= 0;
127 layout
.marginWidth
= 0;
128 localComposite
.setLayout(layout
);
129 GridData data
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
130 data
.grabExcessVerticalSpace
= true;
131 localComposite
.setLayoutData(data
);
133 createTable(localComposite
);
135 IHistoryPageSite parentSite
= getHistoryPageSite();
136 if (parentSite
!= null && parentSite
instanceof DialogHistoryPageSite
)
137 parentSite
.setSelectionProvider(viewer
);
139 final GitCompareRevisionAction compareAction
= new GitCompareRevisionAction(
141 final GitCompareRevisionAction compareActionPrev
= new GitCompareRevisionAction(
143 table
.addMouseListener(new MouseListener() {
145 public void mouseUp(MouseEvent e
) {
148 public void mouseDown(MouseEvent e
) {
149 hintShowDiffNow
= e
.button
==1;
152 public void mouseDoubleClick(MouseEvent e
) {
157 table
.addMouseMoveListener(new MouseMoveListener() {
159 public void mouseMove(MouseEvent e
) {
160 TableItem item
= table
.getItem(new Point(e
.x
,e
.y
));
161 if (item
!= null && item
!=lastItem
) {
162 IFileRevision rev
= (IFileRevision
) item
.getData();
165 String commitStr
=null;
166 if (appliedPatches
!=null) {
167 String id
= rev
.getContentIdentifier();
168 if (!id
.equals("Workspace")) {
169 StGitPatch patch
= (StGitPatch
) appliedPatches
.get(new ObjectId(id
));
171 commitStr
= "Patch: "+patch
.getName();
173 commitStr
= "Workspace:";
176 if (commitStr
== null)
177 commitStr
= "Commit: "+rev
.getContentIdentifier();
178 table
.setToolTipText(commitStr
+"\nAuthor: "+rev
.getAuthor()+"\nDate: "+new Date(rev
.getTimestamp())+"\n\n"+rev
.getComment());
184 table
.addSelectionListener(new SelectionAdapter() {
185 public void widgetSelected(SelectionEvent e
) {
186 // update the current
187 TableItem
[] selection
= table
.getSelection();
188 IFileRevision
[] selection2
= new IFileRevision
[selection
.length
];
189 for (int i
= 0; i
< selection
.length
; ++i
) {
190 selection2
[i
] = (IFileRevision
) selection
[i
].getData();
193 compareAction
.setCurrentFileRevision(fileRevisions
.get(0));
194 compareAction
.selectionChanged(new StructuredSelection(
196 if (selection2
.length
== 1 && hintShowDiffNow
) {
197 ObjectId
[] parentIds
= ((GitFileRevision
)selection2
[0]).getCommit().getParentIds();
198 if (parentIds
.length
> 0) {
199 ObjectId parentId
= parentIds
[0];
200 IFileRevision previous
= new GitFileRevision(parentId
,
201 ((GitFileRevision
)selection2
[0]).getResource(),
202 ((GitFileRevision
)selection2
[0]).getCount()+1);
203 compareActionPrev
.setCurrentFileRevision(null);
204 compareActionPrev
.selectionChanged(new StructuredSelection(new IFileRevision
[] {selection2
[0], previous
}));
205 System
.out
.println("detail="+e
.detail
);
206 table
.getDisplay().asyncExec(new Runnable() {
208 if (GitCompareRevisionAction
.findReusableCompareEditor(GitHistoryPage
.this.getSite().getPage()) != null)
209 compareActionPrev
.run();
214 compareActionPrev
.setCurrentFileRevision(null);
215 compareActionPrev
.selectionChanged(new StructuredSelection(new IFileRevision
[0]));
217 hintShowDiffNow
= false;
220 compareAction
.setPage(this);
221 compareActionPrev
.setPage(this);
222 MenuManager menuMgr
= new MenuManager();
223 Menu menu
= menuMgr
.createContextMenu(table
);
224 menuMgr
.addMenuListener(new IMenuListener() {
225 public void menuAboutToShow(IMenuManager menuMgr
) {
226 menuMgr
.add(compareAction
);
227 menuMgr
.add(compareActionPrev
);
230 menuMgr
.setRemoveAllWhenShown(true);
233 GitHistoryResourceListener resourceListener
= new GitHistoryResourceListener();
234 ResourcesPlugin
.getWorkspace().addResourceChangeListener(
235 resourceListener
, IResourceChangeEvent
.POST_CHANGE
);
237 Action showAllVersionsAction
= new Action("\u2200" /* unicode: FOR ALL */) {
239 setShowAllVersions(isChecked());
240 if (historyRefreshJob
.cancel()) {
241 System
.out
.println("rescheduling");
242 historyRefreshJob
.schedule();
244 System
.out
.println("failed to cancel?");
248 showAllVersionsAction
249 .setToolTipText("Show all versions for the project containing the resource");
250 showAllVersionsAction
.setChecked(isShowAllVersions());
251 getSite().getActionBars().getToolBarManager()
252 .add(showAllVersionsAction
);
254 Action showAllFolderVersionsAction
= new Action("F") {
256 setShowAllFolderVersion(isChecked());
257 if (historyRefreshJob
.cancel()) {
258 System
.out
.println("rescheduling");
259 historyRefreshJob
.schedule();
261 System
.out
.println("failed to cancel?");
265 showAllFolderVersionsAction
266 .setToolTipText("Show all versions for the folder containing the resource");
267 showAllFolderVersionsAction
.setChecked(isShowAllFolderVersions());
268 getSite().getActionBars().getToolBarManager().add(
269 showAllFolderVersionsAction
);
272 private boolean isShowAllVersions() {
273 return showAllVersions
;
276 protected void setShowAllVersions(boolean showAllVersions
) {
277 this.showAllVersions
= showAllVersions
;
278 Activator
.getDefault().getPreferenceStore().setValue(
279 PREF_SHOWALLPROJECTVERSIONS
, showAllVersions
);
282 private boolean isShowAllFolderVersions() {
283 return showAllFolderVersions
;
286 protected void setShowAllFolderVersion(boolean showAllFolderVersions
) {
287 this.showAllFolderVersions
= showAllFolderVersions
;
288 Activator
.getDefault().getPreferenceStore().setValue(
289 PREF_SHOWALLFOLDERVERSIONS
, showAllFolderVersions
);
292 class GitHistoryResourceListener
implements IResourceChangeListener
{
294 public void resourceChanged(IResourceChangeEvent event
) {
295 System
.out
.println("resourceChanged(" + event
+ ")");
300 class GitHistoryLabelProvider
{
302 public String
getColumnText(int index
, int columnIndex
) {
303 GitFileRevision element
= (GitFileRevision
) fileRevisions
.get(index
);
304 if (columnIndex
== 0) {
308 if (columnIndex
== 1) {
309 String rss
= element
.getURI().toString();
310 String rs
= rss
.substring(rss
.length()-10);
311 String id
= element
.getContentIdentifier();
312 if (appliedPatches
!=null) {
313 if (!id
.equals("Workspace")) {
314 StGitPatch patch
= (StGitPatch
) appliedPatches
.get(new ObjectId(id
));
316 return patch
.getName();
320 if (id
.length() > 9) // make sure "Workspace" is spelled out
321 return id
.substring(0, 7) + "..";
325 return id
+ "@.." + rs
;
328 if (columnIndex
== 2) {
329 String id
= element
.getContentIdentifier();
330 if (id
.equals("Workspace")) {
333 ObjectId oid
= new ObjectId(id
);
334 StringBuilder b
=new StringBuilder();
336 Tag
[] matching
= tags
.get(oid
);
337 if (matching
!= null) {
338 for (Tag t
: matching
) {
341 b
.append(t
.getTag());
345 if (branches
!= null) {
348 String
[] matching
= branches
.get(oid
);
349 if (matching
!= null) {
350 for (String t
: matching
) {
360 if (columnIndex
== 3) {
361 Date d
= new Date(element
.getTimestamp());
362 if (d
.getTime() == -1)
366 if (columnIndex
== 4)
367 return element
.getAuthor();
369 if (columnIndex
== 5) {
370 String comment
= element
.getComment();
373 int p
= comment
.indexOf('\n');
375 return comment
.substring(0, p
);
379 return Integer
.toString(columnIndex
);
383 private void createTable(Composite composite
) {
384 table
= new Table(composite
, SWT
.H_SCROLL
| SWT
.V_SCROLL
| SWT
.MULTI
385 | SWT
.FULL_SELECTION
| SWT
.VIRTUAL
);
386 table
.setHeaderVisible(true);
387 table
.setLinesVisible(true);
388 GridData data
= new GridData(SWT
.FILL
, SWT
.FILL
, true, true);
389 table
.setLayoutData(data
);
390 table
.setData("HEAD");
391 table
.addListener(SWT
.SetData
, new Listener() {
392 public void handleEvent(Event event
) {
394 // System.out.println("handleEvent "+event.type+" "+event.index + "=> "+fileRevisions.get(event.index));
395 TableItem item
= (TableItem
) event
.item
;
396 Table parent
= item
.getParent();
397 if (parent
== null) {
398 item
.setText(new String
[] { "hej", "san" });
401 for (int i
= 0; i
< 6; ++i
) {
402 String text
= lp
.getColumnText(event
.index
, i
);
404 item
.setText(i
, text
);
408 item
.setData(fileRevisions
.get(event
.index
));
410 item
.setFont(0,JFaceResources
.getBannerFont());
411 } catch (Throwable b
) {
417 table
.addListener(SWT
.PaintItem
, new Listener() {
419 final int[] colors
= {
425 SWT
.COLOR_DARK_GREEN
,
426 SWT
.COLOR_DARK_MAGENTA
,
428 SWT
.COLOR_DARK_YELLOW
,
436 public void handleEvent(Event event
) {
437 TableItem item
= (TableItem
) event
.item
;
438 if (event
.index
== 0) {
439 System
.out
.println(event
);
440 GitFileRevision element
= (GitFileRevision
)item
.getData();
441 ObjectId xx
= element
.getCommitId();
444 int h
= event
.height
;
445 event
.gc
.setLineWidth(2);
446 // RepositoryMapping rm = RepositoryMapping.getMapping(element.getResource());
447 final int DOTRADIUS
= 3;
448 final int INTERLANE
= 10;
450 Lane lane
= element
.getLane();
451 TopologicalSorter
<ObjectId
> counter
= lane
.getSorter();
452 Integer io
= counter
.getInternalPosition(xx
);
453 for (TopologicalSorter
<ObjectId
>.Lane li
: counter
.currentLanes
) {
454 Integer iost
= counter
.getInternalPosition(li
.startsAt
);
455 Integer ioen
= counter
.getInternalPosition(li
.endsAt
);
456 List
<Edge
<ObjectId
>> lif
= counter
.getEdgeFrom(li
.endsAt
);
458 for(TopologicalSorter
.Edge
<ObjectId
> ee
: lif
) {
459 Integer eio
= counter
.getInternalPosition(ee
.getTo());
460 if (eio
== null) { // not yet assigned (further down)
461 if (iost
!= null && io
.intValue() > iost
.intValue()) {
462 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
463 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_RED));
464 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
);
467 // System.out.println ("Looking at id "+li.endsAt+" at lane "+li.number+" ending on ="+ioen+" and it's parent "+ee.to+ " ends at "+eio);
468 if (io
.intValue() < eio
.intValue() && /*ECLIPSEBUG*/ iost
!=null && /*ENDBUG*/ io
.intValue() > iost
.intValue()) {
469 if (io
.intValue() >= ioen
.intValue()) {
470 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
471 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_MAGENTA));
472 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
);
475 if (io
.intValue() == eio
.intValue()) {
477 int fromn
= lane
.getNumber();
478 int ton
= li
.getNumber();
479 int x1
= x
+ fromn
* INTERLANE
;
480 int x2
= x
+ ton
* INTERLANE
;
485 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
486 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_GREEN));
489 event
.gc
.drawArc(x1
- (x2
-x1
), y
-h
/2, (x2
-x1
)*2, h
, 270, 90);
491 event
.gc
.drawArc(x2
, y
-h
/2, (x1
-x2
)*2, h
, 180, 90);
492 // event.gc.drawLine(x1, y + h/2, x2, y + h/2);
493 // event.gc.drawLine(x2, y, x2, y + h/2);
499 if (li
.startsAt
== xx
) {
501 int fromn
= lane
.getNumber();
502 int ton
= li
.getNumber();
503 int x1
= x
+ fromn
* INTERLANE
;
504 int x2
= x
+ ton
* INTERLANE
;
509 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_DARK_GREEN));
510 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
512 event
.gc
.drawArc(x1
- (x2
-x1
), y
+h
/2, (x2
-x1
)*2, h
, 0, 90);
514 event
.gc
.drawArc(x2
, y
+h
/2, (x1
-x2
)*2, h
, 180, 90);
515 // event.gc.drawLine(x1, y + h/2, x2, y + h/2);
516 // event.gc.drawLine(x2, y + h/2, x2, y + h);
519 if (iost
!=null && io
.intValue() > iost
.intValue()) {
520 if (ioen
== null || io
.intValue() < ioen
.intValue()) {
521 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
522 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
523 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
);
525 if (ioen
== null || io
.intValue() == ioen
.intValue()) {
526 // event.gc.setForeground(Display.getCurrent().getSystemColor(SWT.COLOR_BLACK));
527 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
528 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
/2);
532 event
.gc
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
533 event
.gc
.fillOval(x
+ lane
.getNumber() * INTERLANE
- DOTRADIUS
, y
+ h
/2 - DOTRADIUS
, DOTRADIUS
*2, DOTRADIUS
*2);
537 TableLayout layout
= new TableLayout();
538 table
.setLayout(layout
);
540 viewer
= new TableViewer(table
, SWT
.VIRTUAL
| SWT
.FULL_SELECTION
);
542 viewer
.setUseHashlookup(true);
546 viewer
.setContentProvider(new GitHistoryContentProvider());
548 viewer
.setInput(getInput());
551 private Map appliedPatches
;
552 private Map
<ObjectId
,Tag
[]> tags
;
553 private Map
<ObjectId
, String
[]> branches
;
554 GitHistoryLabelProvider lp
= new GitHistoryLabelProvider();
556 class HistoryRefreshJob
extends Job
{
558 public HistoryRefreshJob(String name
) {
562 protected IStatus
run(IProgressMonitor monitor
) {
563 monitor
= new NullProgressMonitor();
564 monitor
.beginTask("UpdateHistory", IProgressMonitor
.UNKNOWN
);
565 IProject project
= ((IResource
) getInput()).getProject();
566 RepositoryProvider provider
= RepositoryProvider
567 .getProvider(project
);
568 RepositoryMapping repositoryMapping
= RepositoryMapping
.getMapping(project
);
569 Map newappliedPatches
= null;
571 newappliedPatches
= repositoryMapping
.getRepository().getAppliedPatches();
572 } catch (IOException e
) {
573 // TODO Auto-generated catch block
576 Map
<ObjectId
,Tag
[]> newtags
= new HashMap
<ObjectId
,Tag
[]>();
578 for (String name
: repositoryMapping
.getRepository().getTags()) {
579 Tag t
= repositoryMapping
.getRepository().mapTag(name
);
580 Tag
[] samecommit
= newtags
.get(t
.getObjId());
581 if (samecommit
==null) {
582 samecommit
= new Tag
[] { t
};
584 Tag
[] n
=new Tag
[samecommit
.length
+1];
585 for (int j
=0; j
<samecommit
.length
; ++j
)
586 n
[j
] = samecommit
[j
];
590 newtags
.put(t
.getObjId(), samecommit
);
592 } catch (IOException e
) {
593 // TODO Auto-generated catch block
596 Map
<ObjectId
, String
[]> newBranches
= new HashMap
<ObjectId
, String
[]>();
598 for (String branch
: repositoryMapping
.getRepository().getBranches()) {
599 ObjectId id
= repositoryMapping
.getRepository().resolve("refs/heads/"+branch
);
600 String
[] samecommit
= newBranches
.get(id
);
601 if (samecommit
== null) {
602 samecommit
= new String
[] { branch
};
604 String
[] n
=new String
[samecommit
.length
+ 1];
605 for (int j
=0; j
<samecommit
.length
; ++j
)
606 n
[j
] = samecommit
[j
];
607 n
[n
.length
-1] = branch
;
610 newBranches
.put(id
, samecommit
);
612 branches
= newBranches
;
613 } catch (IOException e
) {
614 // TODO Auto-generated catch block
618 IFileHistoryProvider fileHistoryProvider
= provider
619 .getFileHistoryProvider();
620 IResource startingPoint
= (IResource
) getInput();
621 if (isShowAllFolderVersions())
622 if (!(startingPoint
instanceof IContainer
))
623 startingPoint
= startingPoint
.getParent();
624 if (isShowAllVersions())
625 startingPoint
= startingPoint
.getProject();
626 GitFileHistory fileHistoryFor
= (GitFileHistory
)fileHistoryProvider
627 .getFileHistoryFor(startingPoint
,
630 fileRevisions
= fileHistoryFor
.getFileRevisionsList();
631 final Map fnewappliedPatches
= newappliedPatches
;
632 final Map
<ObjectId
,Tag
[]> ftags
= newtags
;
634 table
.getDisplay().asyncExec(new Runnable() {
638 table
.setItemCount(fileRevisions
.size());
640 table
.setLayoutData(new GridData(SWT
.FILL
,SWT
.FILL
,true,true));
641 System
.out
.println("inputchanged, invoking refresh");
642 appliedPatches
= fnewappliedPatches
;
644 long t0
= System
.currentTimeMillis();
646 long t1
= System
.currentTimeMillis();
647 System
.out
.println("refresh in "+(t1
-t0
)/1000.0+"s");
648 done(Status
.OK_STATUS
);
652 return Status
.OK_STATUS
;
657 HistoryRefreshJob historyRefreshJob
= new HistoryRefreshJob("Git history refresh");
659 class GitHistoryContentProvider
implements ILazyContentProvider
{
661 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
662 if (newInput
== null)
664 if (newInput
== oldInput
)
666 IProject project
= ((IResource
) getInput()).getProject();
667 RepositoryProvider provider
= RepositoryProvider
.getProvider(project
);
668 if (!(provider
instanceof GitProvider
))
671 System
.out
.println(new Date()+"inputChanged(" + viewer
+ "," + oldInput
+ ","
673 if (historyRefreshJob
.cancel()) {
674 System
.out
.println("rescheduling");
675 historyRefreshJob
.schedule();
677 System
.out
.println("failed to cancel?");
681 public void dispose() {
684 public void updateElement(int index
) {
685 // viewer.update(arg0, arg1)
689 private void createColumns() {
690 // X SelectionListener headerListener = getColumnListener(viewer);
692 TableColumn col
= new TableColumn(table
, SWT
.NONE
);
693 col
.setResizable(true);
695 // X col.addSelectionListener(headerListener);
696 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
700 col
= new TableColumn(table
, SWT
.NONE
);
701 col
.setResizable(true);
702 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Revision
);
703 // X col.addSelectionListener(headerListener);
704 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
708 col
= new TableColumn(table
, SWT
.NONE
);
709 col
.setResizable(true);
711 // X col.addSelectionListener(headerListener);
712 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
715 col
= new TableColumn(table
, SWT
.NONE
);
716 col
.setResizable(true);
717 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_RevisionTime
);
718 // X col.addSelectionListener(headerListener);
719 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(30,
723 col
= new TableColumn(table
, SWT
.NONE
);
724 col
.setResizable(true);
725 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Author
);
726 // X col.addSelectionListener(headerListener);
727 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(20,
731 col
= new TableColumn(table
, SWT
.NONE
);
732 col
.setResizable(true);
733 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Comment
);
734 // X col.addSelectionListener(headerListener);
735 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(35,
739 public Control
getControl() {
740 return localComposite
;
743 public void setFocus() {
744 localComposite
.setFocus();
747 public String
getDescription() {
748 return "GIT History viewer";
751 public String
getName() {
752 return getInput().toString();
755 public boolean isValidInput(Object object
) {
756 // TODO Auto-generated method stub
760 public void refresh() {
761 // TODO Auto-generated method stub
765 public Object
getAdapter(Class adapter
) {
766 if (adapter
== IHistoryCompareAdapter
.class) {
772 public ICompareInput
getCompareInput(Object object
) {
773 // TODO Auto-generated method stub
777 public void prepareInput(ICompareInput input
,
778 CompareConfiguration configuration
, IProgressMonitor monitor
) {
779 System
.out
.println("prepareInput()");
780 // TODO Auto-generated method stub