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();
442 final int DOTRADIUS
= 3;
443 final int INTERLANE
= 8;
444 int x
= event
.x
+ INTERLANE
/2 + 2;
446 int h
= event
.height
;
447 event
.gc
.setLineWidth(2);
449 Lane lane
= element
.getLane();
450 TopologicalSorter
<ObjectId
> counter
= lane
.getSorter();
451 Integer io
= counter
.getInternalPosition(xx
);
452 List
<Edge
<ObjectId
>> px
= counter
.getEdgeFrom(xx
);
453 for (TopologicalSorter
<ObjectId
>.Lane li
: counter
.currentLanes
) {
454 Integer iost
= counter
.getInternalPosition(li
.startsAt
);
455 Integer ioen
= counter
.getInternalPosition(li
.endsAt
);
460 if (iost
!= null && io
> iost
&& (ioen
== null || io
< ioen
)) {
461 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
462 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
);
465 if (iost
!= null && io
> iost
&& (ioen
== null || io
<= ioen
)) {
466 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
467 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
, x
+ li
.getNumber()*INTERLANE
, y
+ h
/2);
469 if (iost
!= null && io
>= iost
&& (ioen
== null || io
< ioen
)) {
470 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[li
.getNumber()%colors
.length
]));
471 event
.gc
.drawLine(x
+ li
.getNumber()*INTERLANE
, y
+ h
/2, x
+ li
.getNumber()*INTERLANE
, y
+ h
);
474 // branch out to parent
476 // \>>>>>>>>>>o o<<<<<<<<<</
478 for (int j
=0; j
<px
.size(); ++j
) {
479 ObjectId p
= px
.get(j
).getTo();
480 Lane pl
= counter
.getLane(p
);
481 if (li
== pl
&& lane
!= li
) {
482 int fromn
= lane
.getNumber();
483 int ton
= pl
.getNumber();
484 int x1
= x
+ fromn
* INTERLANE
;
485 int x2
= x
+ ton
* INTERLANE
;
486 event
.gc
.setForeground(Display
.getCurrent().getSystemColor(colors
[pl
.getNumber()%colors
.length
]));
488 event
.gc
.drawArc(x1
- (x2
-x1
), y
+h
/2, (x2
-x1
)*2, h
, 0, 90);
490 event
.gc
.drawArc(x2
, y
+h
/2, (x1
-x2
)*2, h
, 90, 90);
494 // merge, SAME (unless we get really smart)
497 if (xx
.equals(currentHead
)) {
498 event
.gc
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_RED
));
499 event
.gc
.fillOval(x
+ lane
.getNumber() * INTERLANE
- DOTRADIUS
*2, y
+ h
/2 - DOTRADIUS
*2, DOTRADIUS
*4, DOTRADIUS
*4);
501 event
.gc
.setBackground(Display
.getCurrent().getSystemColor(SWT
.COLOR_BLACK
));
502 event
.gc
.fillOval(x
+ lane
.getNumber() * INTERLANE
- DOTRADIUS
, y
+ h
/2 - DOTRADIUS
, DOTRADIUS
*2, DOTRADIUS
*2);
506 TableLayout layout
= new TableLayout();
507 table
.setLayout(layout
);
509 viewer
= new TableViewer(table
, SWT
.VIRTUAL
| SWT
.FULL_SELECTION
);
511 viewer
.setUseHashlookup(true);
515 viewer
.setContentProvider(new GitHistoryContentProvider());
517 viewer
.setInput(getInput());
520 private Map appliedPatches
;
521 ObjectId currentHead
;
522 private Map
<ObjectId
,Tag
[]> tags
;
523 private Map
<ObjectId
, String
[]> branches
;
524 GitHistoryLabelProvider lp
= new GitHistoryLabelProvider();
526 class HistoryRefreshJob
extends Job
{
528 public HistoryRefreshJob(String name
) {
532 protected IStatus
run(IProgressMonitor monitor
) {
533 monitor
= new NullProgressMonitor();
534 monitor
.beginTask("UpdateHistory", IProgressMonitor
.UNKNOWN
);
535 IProject project
= ((IResource
) getInput()).getProject();
536 RepositoryProvider provider
= RepositoryProvider
537 .getProvider(project
);
538 RepositoryMapping repositoryMapping
= RepositoryMapping
.getMapping(project
);
539 Map newappliedPatches
= null;
541 newappliedPatches
= repositoryMapping
.getRepository().getAppliedPatches();
542 } catch (IOException e
) {
543 // TODO Auto-generated catch block
546 Map
<ObjectId
,Tag
[]> newtags
= new HashMap
<ObjectId
,Tag
[]>();
548 for (String name
: repositoryMapping
.getRepository().getTags()) {
549 Tag t
= repositoryMapping
.getRepository().mapTag(name
);
550 Tag
[] samecommit
= newtags
.get(t
.getObjId());
551 if (samecommit
==null) {
552 samecommit
= new Tag
[] { t
};
554 Tag
[] n
=new Tag
[samecommit
.length
+1];
555 for (int j
=0; j
<samecommit
.length
; ++j
)
556 n
[j
] = samecommit
[j
];
560 newtags
.put(t
.getObjId(), samecommit
);
562 } catch (IOException e
) {
563 // TODO Auto-generated catch block
567 currentHead
= repositoryMapping
.getRepository().resolve("HEAD");
568 } catch (IOException e
) {
569 // TODO Auto-generated catch block
572 Map
<ObjectId
, String
[]> newBranches
= new HashMap
<ObjectId
, String
[]>();
574 for (String branch
: repositoryMapping
.getRepository().getBranches()) {
575 ObjectId id
= repositoryMapping
.getRepository().resolve(branch
);
576 String
[] samecommit
= newBranches
.get(id
);
577 if (samecommit
== null) {
578 samecommit
= new String
[] { branch
};
580 String
[] n
=new String
[samecommit
.length
+ 1];
581 for (int j
=0; j
<samecommit
.length
; ++j
)
582 n
[j
] = samecommit
[j
];
583 n
[n
.length
-1] = branch
;
586 newBranches
.put(id
, samecommit
);
588 String
[] samecommit
= newBranches
.get(currentHead
);
589 if (samecommit
== null) {
590 samecommit
= new String
[] { "HEAD" };
592 String
[] n
=new String
[samecommit
.length
+ 1];
593 for (int j
=0; j
<samecommit
.length
; ++j
)
594 n
[j
] = samecommit
[j
];
595 n
[n
.length
-1] = "HEAD";
598 newBranches
.put(currentHead
, samecommit
);
599 branches
= newBranches
;
600 } catch (IOException e
) {
601 // TODO Auto-generated catch block
604 IFileHistoryProvider fileHistoryProvider
= provider
605 .getFileHistoryProvider();
606 IResource startingPoint
= (IResource
) getInput();
607 if (isShowAllFolderVersions())
608 if (!(startingPoint
instanceof IContainer
))
609 startingPoint
= startingPoint
.getParent();
610 if (isShowAllVersions())
611 startingPoint
= startingPoint
.getProject();
612 GitFileHistory fileHistoryFor
= (GitFileHistory
)fileHistoryProvider
613 .getFileHistoryFor(startingPoint
,
616 fileRevisions
= fileHistoryFor
.getFileRevisionsList();
617 final Map fnewappliedPatches
= newappliedPatches
;
618 final Map
<ObjectId
,Tag
[]> ftags
= newtags
;
620 table
.getDisplay().asyncExec(new Runnable() {
624 table
.setItemCount(fileRevisions
.size());
626 table
.setLayoutData(new GridData(SWT
.FILL
,SWT
.FILL
,true,true));
627 System
.out
.println("inputchanged, invoking refresh");
628 appliedPatches
= fnewappliedPatches
;
630 long t0
= System
.currentTimeMillis();
632 long t1
= System
.currentTimeMillis();
633 System
.out
.println("refresh in "+(t1
-t0
)/1000.0+"s");
634 done(Status
.OK_STATUS
);
638 return Status
.OK_STATUS
;
643 HistoryRefreshJob historyRefreshJob
= new HistoryRefreshJob("Git history refresh");
645 class GitHistoryContentProvider
implements ILazyContentProvider
{
647 public void inputChanged(Viewer viewer
, Object oldInput
, Object newInput
) {
648 if (newInput
== null)
650 if (newInput
== oldInput
)
652 IProject project
= ((IResource
) getInput()).getProject();
653 RepositoryProvider provider
= RepositoryProvider
.getProvider(project
);
654 if (!(provider
instanceof GitProvider
))
657 System
.out
.println(new Date()+"inputChanged(" + viewer
+ "," + oldInput
+ ","
659 if (historyRefreshJob
.cancel()) {
660 System
.out
.println("rescheduling");
661 historyRefreshJob
.schedule();
663 System
.out
.println("failed to cancel?");
667 public void dispose() {
670 public void updateElement(int index
) {
671 // viewer.update(arg0, arg1)
675 private void createColumns() {
676 // X SelectionListener headerListener = getColumnListener(viewer);
678 TableColumn col
= new TableColumn(table
, SWT
.NONE
);
679 col
.setResizable(true);
681 // X col.addSelectionListener(headerListener);
682 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
686 col
= new TableColumn(table
, SWT
.NONE
);
687 col
.setResizable(true);
688 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Revision
);
689 // X col.addSelectionListener(headerListener);
690 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
694 col
= new TableColumn(table
, SWT
.NONE
);
695 col
.setResizable(true);
697 // X col.addSelectionListener(headerListener);
698 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(15,
701 col
= new TableColumn(table
, SWT
.NONE
);
702 col
.setResizable(true);
703 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_RevisionTime
);
704 // X col.addSelectionListener(headerListener);
705 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(30,
709 col
= new TableColumn(table
, SWT
.NONE
);
710 col
.setResizable(true);
711 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Author
);
712 // X col.addSelectionListener(headerListener);
713 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(20,
717 col
= new TableColumn(table
, SWT
.NONE
);
718 col
.setResizable(true);
719 col
.setText(TeamUIMessages
.GenericHistoryTableProvider_Comment
);
720 // X col.addSelectionListener(headerListener);
721 ((TableLayout
) table
.getLayout()).addColumnData(new ColumnWeightData(35,
725 public Control
getControl() {
726 return localComposite
;
729 public void setFocus() {
730 localComposite
.setFocus();
733 public String
getDescription() {
734 return "GIT History viewer";
737 public String
getName() {
738 return getInput().toString();
741 public boolean isValidInput(Object object
) {
742 // TODO Auto-generated method stub
746 public void refresh() {
747 // TODO Auto-generated method stub
751 public Object
getAdapter(Class adapter
) {
752 if (adapter
== IHistoryCompareAdapter
.class) {
758 public ICompareInput
getCompareInput(Object object
) {
759 // TODO Auto-generated method stub
763 public void prepareInput(ICompareInput input
,
764 CompareConfiguration configuration
, IProgressMonitor monitor
) {
765 System
.out
.println("prepareInput()");
766 // TODO Auto-generated method stub