Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-09 22:19:47 +0000
committerMichael Valenta2006-01-09 22:19:47 +0000
commit5511570cc419e795f4be8bb22df33ef9536098b5 (patch)
treebc7994c0e5c2f1079cb7b379645e954d8068ba71
parentdadf9bc2204d67fe0e35bfe2aa5e93f480aa7283 (diff)
downloadeclipse.platform.team-5511570cc419e795f4be8bb22df33ef9536098b5.tar.gz
eclipse.platform.team-5511570cc419e795f4be8bb22df33ef9536098b5.tar.xz
eclipse.platform.team-5511570cc419e795f4be8bb22df33ef9536098b5.zip
Bug 120151 [History View] Generic History View needs to allow page contributions
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFileHistoryProviderParticipant.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java510
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java374
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRevisionAction.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/CompareRevisionAction.java)31
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRevisionAction.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/OpenRevisionAction.java)82
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java13
-rw-r--r--bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF2
-rw-r--r--bundles/org.eclipse.team.ui/plugin.xml15
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ITeamUIImages.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java3
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java47
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java841
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java62
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IFileHistoryProviderParticipant.java40
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IHistoryPage.java54
17 files changed, 1566 insertions, 574 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 5ed54d6e9..dc5c34a5a 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -609,6 +609,20 @@
id="org.eclipse.team.ccvs.ui.tagInRepository">
</action>
</objectContribution>
+ <objectContribution
+ adaptable="false"
+ id="org.eclipse.team.ui.FileRevisionsContribution"
+ objectClass="org.eclipse.team.core.history.IFileRevision">
+ <action
+ class="org.eclipse.team.internal.ccvs.ui.actions.CompareRevisionAction"
+ enablesFor="2"
+ id="org.eclipse.team.ui.CompareRevisionAction"
+ label="&amp;Compare"/>
+ <action
+ class="org.eclipse.team.internal.ccvs.ui.actions.OpenRevisionAction"
+ id="org.eclipse.team.ui.FileRevisionsContribution"
+ label="&amp;Open Revision"/>
+ </objectContribution>
</extension>
<!-- ************** Model Element Contributions ********************** -->
@@ -1375,5 +1389,23 @@
</description>
</transfer>
</extension>
+ <extension
+ point="org.eclipse.ui.preferencePages">
+ <page
+ category="org.eclipse.team.cvs.ui.CVSPreferences"
+ class="org.eclipse.team.internal.ccvs.ui.WorkInProgressPage"
+ id="org.eclipse.team.cvs.ui.WorkInProgressPreferences"
+ name="%WorkInProgressPreferencePage.name">
+ <keywordReference id="org.eclipse.team.cvs.ui.cvs"/>
+ </page>
+ </extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.team.internal.ccvs.core.filehistory.CVSFileHistoryProvider"
+ class="org.eclipse.team.internal.ccvs.ui.model.CVSAdapterFactory">
+ <adapter type="org.eclipse.team.ui.history.IFileHistoryProviderParticipant"/>
+ </factory>
+ </extension>
</plugin>
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFileHistoryProviderParticipant.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFileHistoryProviderParticipant.java
new file mode 100644
index 000000000..14c595393
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSFileHistoryProviderParticipant.java
@@ -0,0 +1,24 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui;
+
+import org.eclipse.team.ui.history.IFileHistoryProviderParticipant;
+import org.eclipse.ui.part.Page;
+
+public class CVSFileHistoryProviderParticipant implements IFileHistoryProviderParticipant {
+
+ public Page createPage() {
+ CVSHistoryPage page = new CVSHistoryPage();
+ return page;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java
new file mode 100644
index 000000000..de1d862e7
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryPage.java
@@ -0,0 +1,510 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.custom.SashForm;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.history.IFileHistory;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.history.ITag;
+import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
+import org.eclipse.team.internal.ccvs.ui.actions.OpenRevisionAction;
+import org.eclipse.team.internal.ui.ITeamUIImages;
+import org.eclipse.team.internal.ui.TeamUIMessages;
+import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.ui.Utils;
+import org.eclipse.team.ui.history.IHistoryPage;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.part.Page;
+
+public class CVSHistoryPage extends Page implements IHistoryPage {
+ private IFile file;
+
+ // cached for efficiency
+ /* private */IFileRevision[] entries;
+
+ protected CVSHistoryTableProvider historyTableProvider;
+
+ /* private */TableViewer tableViewer;
+ protected TextViewer textViewer;
+ protected TableViewer tagViewer;
+
+ /* private */OpenRevisionAction openAction;
+ private IAction toggleTextAction;
+ private IAction toggleTextWrapAction;
+ private IAction toggleListAction;
+ private Action refreshAction;
+
+ private SashForm sashForm;
+ private SashForm innerSashForm;
+
+ protected IFileRevision currentSelection;
+
+ protected FetchLogEntriesJob fetchLogEntriesJob;
+
+ private IViewSite parentSite;
+
+ /* private */boolean shutdown = false;
+
+ // preferences
+ public final static String PREF_GENERIC_HISTORYVIEW_SHOW_COMMENTS = "pref_generichistory_show_comments"; //$NON-NLS-1$
+
+ public final static String PREF_GENERIC_HISTORYVIEW_WRAP_COMMENTS = "pref_generichistory_wrap_comments"; //$NON-NLS-1$
+
+ public final static String PREF_GENERIC_HISTORYVIEW_SHOW_TAGS = "pref_generichistory_show_tags"; //$NON-NLS-1$
+
+ public void createControl(Composite parent) {
+ sashForm = new SashForm(parent, SWT.VERTICAL);
+ sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+
+ tableViewer = createTable(sashForm);
+ innerSashForm = new SashForm(sashForm, SWT.HORIZONTAL);
+ tagViewer = createTagTable(innerSashForm);
+ textViewer = createText(innerSashForm);
+ sashForm.setWeights(new int[] {70, 30});
+ innerSashForm.setWeights(new int[] {50, 50});
+
+ contributeActions();
+
+ setViewerVisibility();
+ }
+
+ private TextViewer createText(SashForm parent) {
+ TextViewer result = new TextViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY);
+ result.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ //copyAction.update();
+ }
+ });
+ return result;
+ }
+
+ private TableViewer createTagTable(SashForm parent) {
+ Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
+ TableViewer result = new TableViewer(table);
+ TableLayout layout = new TableLayout();
+ layout.addColumnData(new ColumnWeightData(100));
+ table.setLayout(layout);
+ result.setContentProvider(new SimpleContentProvider() {
+ public Object[] getElements(Object inputElement) {
+ if (inputElement == null)
+ return new Object[0];
+ ITag[] tags = (ITag[]) inputElement;
+ return tags;
+ }
+ });
+ result.setLabelProvider(new LabelProvider() {
+ public Image getImage(Object element) {
+ if (element == null)
+ return null;
+ ITag tag = (ITag) element;
+ //Need an image
+ return null;
+ }
+
+ public String getText(Object element) {
+ return ((ITag) element).getName();
+ }
+ });
+ result.setSorter(new ViewerSorter() {
+ public int compare(Viewer viewer, Object e1, Object e2) {
+ if (!(e1 instanceof ITag) || !(e2 instanceof ITag))
+ return super.compare(viewer, e1, e2);
+ ITag tag1 = (ITag) e1;
+ ITag tag2 = (ITag) e2;
+ /*int type1 = tag1.getType();
+ int type2 = tag2.getType();
+ if (type1 != type2) {
+ return type2 - type1;
+ }*/
+ return super.compare(viewer, tag1, tag2);
+ }
+ });
+ return result;
+ }
+
+ public void setFocus() {
+ sashForm.setFocus();
+ }
+
+ protected void contributeActions() {
+ TeamUIPlugin plugin = TeamUIPlugin.getPlugin();
+
+ refreshAction = new Action(TeamUIMessages.GenericHistoryView_Refresh, plugin.getImageDescriptor(ITeamUIImages.IMG_REFRESH)) {
+ public void run() {
+ refresh();
+ }
+ };
+
+ // Double click open action
+ openAction = new OpenRevisionAction();
+ tableViewer.getTable().addListener(SWT.DefaultSelection, new Listener() {
+ public void handleEvent(Event e) {
+ openAction.selectionChanged(null, tableViewer.getSelection());
+ openAction.run(null);
+ }
+ });
+
+ // Toggle text visible action
+ final IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
+ toggleTextAction = new Action(TeamUIMessages.GenericHistoryView_ShowCommentViewer) {
+ public void run() {
+ setViewerVisibility();
+ store.setValue(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_SHOW_COMMENTS, toggleTextAction.isChecked());
+ }
+ };
+ toggleTextAction.setChecked(store.getBoolean(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_SHOW_COMMENTS));
+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextAction, IHelpContextIds.SHOW_COMMENT_IN_HISTORY_ACTION);
+
+ // Toggle wrap comments action
+ toggleTextWrapAction = new Action(TeamUIMessages.GenericHistoryView_WrapComments) {
+ public void run() {
+ setViewerVisibility();
+ store.setValue(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_WRAP_COMMENTS, toggleTextWrapAction.isChecked());
+ }
+ };
+ toggleTextWrapAction.setChecked(store.getBoolean(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_WRAP_COMMENTS));
+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextWrapAction, IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);
+
+ // Toggle list visible action
+ toggleListAction = new Action(TeamUIMessages.GenericHistoryView_ShowTagViewer) {
+ public void run() {
+ setViewerVisibility();
+ store.setValue(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_SHOW_TAGS, toggleListAction.isChecked());
+ }
+ };
+ toggleListAction.setChecked(store.getBoolean(CVSHistoryPage.PREF_GENERIC_HISTORYVIEW_SHOW_TAGS));
+ //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleListAction, IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);
+
+ //Contribute actions to popup menu
+ MenuManager menuMgr = new MenuManager();
+ Menu menu = menuMgr.createContextMenu(tableViewer.getTable());
+ menuMgr.addMenuListener(new IMenuListener() {
+ public void menuAboutToShow(IMenuManager menuMgr) {
+ fillTableMenu(menuMgr);
+ }
+ });
+ menuMgr.setRemoveAllWhenShown(true);
+ tableViewer.getTable().setMenu(menu);
+ parentSite.registerContextMenu(menuMgr, tableViewer);
+
+ // Contribute toggle text visible to the toolbar drop-down
+ IActionBars actionBars = getSite().getActionBars();
+ IMenuManager actionBarsMenu = actionBars.getMenuManager();
+ actionBarsMenu.add(toggleTextWrapAction);
+ actionBarsMenu.add(new Separator());
+ actionBarsMenu.add(toggleTextAction);
+ actionBarsMenu.add(toggleListAction);
+
+ }
+
+ /* private */ void fillTableMenu(IMenuManager manager) {
+ // file actions go first (view file)
+ manager.add(new Separator("additions")); //$NON-NLS-1$
+ manager.add(refreshAction);
+ manager.add(new Separator("additions-end")); //$NON-NLS-1$
+ }
+
+ /**
+ * Creates the group that displays lists of the available repositories and
+ * team streams.
+ *
+ * @param the
+ * parent composite to contain the group
+ * @return the group control
+ */
+ protected TableViewer createTable(Composite parent) {
+
+ historyTableProvider = new CVSHistoryTableProvider();
+ TableViewer viewer = historyTableProvider.createTable(parent);
+
+ viewer.setContentProvider(new IStructuredContentProvider() {
+ public Object[] getElements(Object inputElement) {
+
+ // The entries of already been fetch so return them
+ if (entries != null)
+ return entries;
+
+ // The entries need to be fetch (or are being fetched)
+ if (!(inputElement instanceof IFileHistory))
+ return null;
+
+ final IFileHistory remoteFile = (IFileHistory) inputElement;
+ if (fetchLogEntriesJob == null) {
+ fetchLogEntriesJob = new FetchLogEntriesJob();
+ }
+
+ IFileHistory file = fetchLogEntriesJob.getRemoteFile();
+
+ if (file == null || !file.equals(remoteFile)) { // The resource
+ // has changed
+ // so stop the
+ // currently
+ // running job
+ if (fetchLogEntriesJob.getState() != Job.NONE) {
+ fetchLogEntriesJob.cancel();
+ try {
+ fetchLogEntriesJob.join();
+ } catch (InterruptedException e) {
+ TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] {""}), e)); //$NON-NLS-1$
+ }
+ }
+ fetchLogEntriesJob.setRemoteFile(remoteFile);
+ } // Schedule the job even if it is already running
+ Utils.schedule(fetchLogEntriesJob, /*getSite()*/parentSite);
+
+ return new Object[0];
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ entries = null;
+ }
+ });
+
+ viewer.addSelectionChangedListener(new ISelectionChangedListener() {
+ public void selectionChanged(SelectionChangedEvent event) {
+ ISelection selection = event.getSelection();
+
+ if (selection != null && selection instanceof IStructuredSelection) {
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ currentSelection = (IFileRevision) ss.getFirstElement();
+ }
+
+ if (selection == null || !(selection instanceof IStructuredSelection)) {
+ textViewer.setDocument(new Document("")); //$NON-NLS-1$
+ tagViewer.setInput(null);
+ return;
+ }
+
+ IStructuredSelection ss = (IStructuredSelection) selection;
+ if (ss.size() != 1) {
+ textViewer.setDocument(new Document("")); //$NON-NLS-1$
+ tagViewer.setInput(null);
+ return;
+ }
+
+ IFileRevision entry = (IFileRevision) ss.getFirstElement();
+ textViewer.setDocument(new Document(entry.getComment()));
+ tagViewer.setInput(entry.getTags());
+
+ }
+ });
+
+ return viewer;
+ }
+
+ /*
+ * Refresh the view by refetching the log entries for the remote file
+ */
+ public void refresh() {
+ entries = null;
+ BusyIndicator.showWhile(tableViewer.getTable().getDisplay(), new Runnable() {
+ public void run() {
+ // if a local file was fed to the history view then we
+ // will have to refetch the handle
+ // to properly display the current revision marker.
+ tableViewer.refresh();
+ }
+ });
+ }
+
+ /**
+ * Shows the history for the given IResource in the view.
+ *
+ * Only files are supported for now.
+ */
+ public void showHistory(IResource resource, boolean refetch) {
+ if (resource instanceof IFile) {
+ IFile newfile = (IFile) resource;
+ if (!refetch && this.file != null && newfile.equals(this.file)) {
+ return;
+ }
+ this.file = newfile;
+ RepositoryProvider teamProvider = RepositoryProvider.getProvider(file.getProject());
+ IFileHistory fileHistory = teamProvider.getFileHistoryProvider().getFileHistoryFor(resource, new NullProgressMonitor());
+
+ historyTableProvider.setFile(fileHistory, file);
+ tableViewer.setInput(fileHistory);
+ } else {
+ this.file = null;
+ tableViewer.setInput(null);
+ }
+
+ return;
+ }
+
+ /* private */void setViewerVisibility() {
+ boolean showText = toggleTextAction.isChecked();
+ boolean showList = toggleListAction.isChecked();
+ if (showText && showList) {
+ sashForm.setMaximizedControl(null);
+ innerSashForm.setMaximizedControl(null);
+ } else if (showText) {
+ sashForm.setMaximizedControl(null);
+ innerSashForm.setMaximizedControl(textViewer.getTextWidget());
+ } else if (showList) {
+ sashForm.setMaximizedControl(null);
+ innerSashForm.setMaximizedControl(tagViewer.getTable());
+ } else {
+ sashForm.setMaximizedControl(tableViewer.getControl());
+ }
+
+ boolean wrapText = toggleTextWrapAction.isChecked();
+ textViewer.getTextWidget().setWordWrap(wrapText);
+ }
+
+ public void dispose() {
+ shutdown = true;
+
+ if (fetchLogEntriesJob != null) {
+ if (fetchLogEntriesJob.getState() != Job.NONE) {
+ fetchLogEntriesJob.cancel();
+ try {
+ fetchLogEntriesJob.join();
+ } catch (InterruptedException e) {
+ TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] {""}), e)); //$NON-NLS-1$
+ }
+ }
+ }
+ }
+
+ private class FetchLogEntriesJob extends Job {
+ public IFileHistory fileHistory;
+
+ public FetchLogEntriesJob() {
+ super(TeamUIMessages.GenericHistoryView_GenericFileHistoryFetcher);
+ }
+
+ public void setRemoteFile(IFileHistory file) {
+ this.fileHistory = file;
+ }
+
+ public IStatus run(IProgressMonitor monitor) {
+ try {
+ if (fileHistory != null && !shutdown) {
+ entries = fileHistory.getFileRevisions();
+ getSite().getShell().getDisplay().asyncExec(new Runnable() {
+ public void run() {
+ if (entries != null && tableViewer != null && !tableViewer.getTable().isDisposed()) {
+ tableViewer.refresh();
+ }
+ }
+ });
+ }
+ return Status.OK_STATUS;
+ } catch (TeamException e) {
+ return e.getStatus();
+ }
+ }
+
+ public IFileHistory getRemoteFile() {
+ return this.fileHistory;
+ }
+ }
+
+ /**
+ * A default content provider to prevent subclasses from
+ * having to implement methods they don't need.
+ */
+ private class SimpleContentProvider implements IStructuredContentProvider {
+
+ /**
+ * SimpleContentProvider constructor.
+ */
+ public SimpleContentProvider() {
+ super();
+ }
+
+ /*
+ * @see SimpleContentProvider#dispose()
+ */
+ public void dispose() {
+ }
+
+ /*
+ * @see SimpleContentProvider#getElements()
+ */
+ public Object[] getElements(Object element) {
+ return new Object[0];
+ }
+
+ /*
+ * @see SimpleContentProvider#inputChanged()
+ */
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+ }
+
+ public Control getControl() {
+ return sashForm;
+ }
+
+ public boolean canShowHistoryFor(IResource resource) {
+
+ RepositoryProvider provider = RepositoryProvider.getProvider(resource.getProject());
+ if (provider instanceof CVSTeamProvider)
+ return true;
+
+ return false;
+ }
+
+ public String getName() {
+ return file.getName();
+ }
+
+ public void setSite(IViewSite viewSite) {
+ this.parentSite = viewSite;
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java
new file mode 100644
index 000000000..29e400c2b
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSHistoryTableProvider.java
@@ -0,0 +1,374 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui;
+
+import java.text.DateFormat;
+import java.util.Date;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.team.core.RepositoryProvider;
+import org.eclipse.team.core.history.IFileHistory;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.internal.ui.TeamUIMessages;
+
+public class CVSHistoryTableProvider {
+
+ private IFileHistory currentFileHistory;
+ private IFile currentFile;
+ private String currentRevision;
+ /* private */TableViewer viewer;
+ /* private */Font currentRevisionFont;
+
+ //column constants
+ private static final int COL_REVISIONID = 0;
+ private static final int COL_DATE = 1;
+ private static final int COL_AUTHOR = 2;
+ private static final int COL_COMMENT = 3;
+
+ /**
+ * The history label provider.
+ */
+ class HistoryLabelProvider extends LabelProvider implements ITableLabelProvider, IColorProvider, IFontProvider {
+ public Image getColumnImage(Object element, int columnIndex) {
+ return null;
+ }
+
+ public String getColumnText(Object element, int columnIndex) {
+ IFileRevision entry = adaptToFileRevision(element);
+ if (entry == null)
+ return ""; //$NON-NLS-1$
+ switch (columnIndex) {
+ case COL_REVISIONID :
+ String revision = entry.getContentIdentifier();
+ return revision;
+ case COL_DATE :
+ long date = entry.getTimestamp();
+ Date dateFromLong = new Date(date);
+ return DateFormat.getInstance().format(dateFromLong);
+ case COL_AUTHOR :
+ return entry.getAuthor();
+ case COL_COMMENT :
+ String comment = entry.getComment();
+ return comment;
+ }
+ return ""; //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
+ */
+ public Color getForeground(Object element) {
+ IFileRevision entry = adaptToFileRevision(element);
+ if (!entry.exists()) {
+ return Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_NORMAL_SHADOW);
+ }
+
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
+ */
+ public Color getBackground(Object element) {
+ return null;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.jface.viewers.IFontProvider#getFont(java.lang.Object)
+ */
+ public Font getFont(Object element) {
+ IFileRevision entry = adaptToFileRevision(element);
+ if (entry == null)
+ return null;
+ String revision = entry.getContentIdentifier();
+ String tempCurrentRevision = getCurrentRevision();
+ if (tempCurrentRevision != null && tempCurrentRevision.equals(revision)) {
+ if (currentRevisionFont == null) {
+ Font defaultFont = JFaceResources.getDefaultFont();
+ FontData[] data = defaultFont.getFontData();
+ for (int i = 0; i < data.length; i++) {
+ data[i].setStyle(SWT.BOLD);
+ }
+ currentRevisionFont = new Font(viewer.getTable().getDisplay(), data);
+ }
+ return currentRevisionFont;
+ }
+ return null;
+ }
+ }
+
+ /**
+ * The history sorter
+ */
+ class HistorySorter extends ViewerSorter {
+ private boolean reversed = false;
+ private int columnNumber;
+
+ private VersionCollator versionCollator = new VersionCollator();
+
+ // column headings: "Revision" "Tags" "Date" "Author" "Comment"
+ private int[][] SORT_ORDERS_BY_COLUMN = { {COL_REVISIONID, COL_DATE, COL_AUTHOR, COL_COMMENT}, /* revision */
+ {COL_REVISIONID, COL_DATE, COL_AUTHOR, COL_COMMENT}, /* tags */
+ {COL_DATE, COL_REVISIONID, COL_AUTHOR, COL_COMMENT}, /* date */
+ {COL_AUTHOR, COL_REVISIONID, COL_DATE, COL_COMMENT}, /* author */
+ {COL_COMMENT, COL_REVISIONID, COL_DATE, COL_AUTHOR} /* comment */
+ };
+
+ /**
+ * The constructor.
+ */
+ public HistorySorter(int columnNumber) {
+ this.columnNumber = columnNumber;
+ }
+
+ /**
+ * Compares two log entries, sorting first by the main column of this sorter,
+ * then by subsequent columns, depending on the column sort order.
+ */
+ public int compare(Viewer compareViewer, Object o1, Object o2) {
+ IFileRevision e1 = adaptToFileRevision(o1);
+ IFileRevision e2 = adaptToFileRevision(o2);
+ int result = 0;
+ if (e1 == null || e2 == null) {
+ result = super.compare(compareViewer, o1, o2);
+ } else {
+ int[] columnSortOrder = SORT_ORDERS_BY_COLUMN[columnNumber];
+ for (int i = 0; i < columnSortOrder.length; ++i) {
+ result = compareColumnValue(columnSortOrder[i], e1, e2);
+ if (result != 0)
+ break;
+ }
+ }
+ if (reversed)
+ result = -result;
+ return result;
+ }
+
+ /**
+ * Compares two markers, based only on the value of the specified column.
+ */
+ int compareColumnValue(int columnNumber, IFileRevision e1, IFileRevision e2) {
+ switch (columnNumber) {
+ case 0 : /* revision */
+ return versionCollator.compare(e1.getContentIdentifier(), e2.getContentIdentifier());
+ case 1 : /* date */
+ long date1 = e1.getTimestamp();
+ long date2 = e2.getTimestamp();
+ if (date1 == date2)
+ return 0;
+
+ return date1 > date2 ? -1 : 1;
+
+ case 2 : /* author */
+ return getCollator().compare(e1.getAuthor(), e2.getAuthor());
+ case 3 : /* comment */
+ return getCollator().compare(e1.getComment(), e2.getComment());
+ default :
+ return 0;
+ }
+ }
+
+ /**
+ * Returns the number of the column by which this is sorting.
+ */
+ public int getColumnNumber() {
+ return columnNumber;
+ }
+
+ /**
+ * Returns true for descending, or false
+ * for ascending sorting order.
+ */
+ public boolean isReversed() {
+ return reversed;
+ }
+
+ /**
+ * Sets the sorting order.
+ */
+ public void setReversed(boolean newReversed) {
+ reversed = newReversed;
+ }
+ }
+
+ protected IFileRevision adaptToFileRevision(Object element) {
+ // Get the log entry for the provided object
+ IFileRevision entry = null;
+ if (element instanceof IFileRevision) {
+ entry = (IFileRevision) element;
+ } else if (element instanceof IAdaptable) {
+ entry = (IFileRevision) ((IAdaptable) element).getAdapter(IFileRevision.class);
+ }
+ return entry;
+ }
+
+ /**
+ * Create a TableViewer that can be used to display a list of IFileRevision instances.
+ * Ths method provides the labels and sorter but does not provide a content provider
+ *
+ * @param parent
+ * @return TableViewer
+ */
+ public TableViewer createTable(Composite parent) {
+ Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION);
+ table.setHeaderVisible(true);
+ table.setLinesVisible(true);
+ GridData data = new GridData(GridData.FILL_BOTH);
+ table.setLayoutData(data);
+
+ TableLayout layout = new TableLayout();
+ table.setLayout(layout);
+
+ TableViewer viewer = new TableViewer(table);
+
+ createColumns(table, layout, viewer);
+
+ viewer.setLabelProvider(new HistoryLabelProvider());
+
+ // By default, reverse sort by revision.
+ HistorySorter sorter = new HistorySorter(COL_REVISIONID);
+ sorter.setReversed(true);
+ viewer.setSorter(sorter);
+
+ table.addDisposeListener(new DisposeListener() {
+ public void widgetDisposed(DisposeEvent e) {
+ if (currentRevisionFont != null) {
+ currentRevisionFont.dispose();
+ }
+ }
+ });
+
+ this.viewer = viewer;
+ return viewer;
+ }
+
+ /**
+ * Creates the columns for the history table.
+ */
+ private void createColumns(Table table, TableLayout layout, TableViewer viewer) {
+ SelectionListener headerListener = getColumnListener(viewer);
+ // revision
+ TableColumn col = new TableColumn(table, SWT.NONE);
+ col.setResizable(true);
+ col.setText(TeamUIMessages.GenericHistoryTableProvider_Revision);
+ col.addSelectionListener(headerListener);
+ layout.addColumnData(new ColumnWeightData(20, true));
+
+ // creation date
+ col = new TableColumn(table, SWT.NONE);
+ col.setResizable(true);
+ col.setText(TeamUIMessages.GenericHistoryTableProvider_RevisionTime);
+ col.addSelectionListener(headerListener);
+ layout.addColumnData(new ColumnWeightData(20, true));
+
+ // author
+ col = new TableColumn(table, SWT.NONE);
+ col.setResizable(true);
+ col.setText(TeamUIMessages.GenericHistoryTableProvider_Author);
+ col.addSelectionListener(headerListener);
+ layout.addColumnData(new ColumnWeightData(20, true));
+
+ //comment
+ col = new TableColumn(table, SWT.NONE);
+ col.setResizable(true);
+ col.setText(TeamUIMessages.GenericHistoryTableProvider_Comment);
+ col.addSelectionListener(headerListener);
+ layout.addColumnData(new ColumnWeightData(50, true));
+ }
+
+ /**
+ * Adds the listener that sets the sorter.
+ */
+ private SelectionListener getColumnListener(final TableViewer tableViewer) {
+ /**
+ * This class handles selections of the column headers.
+ * Selection of the column header will cause resorting
+ * of the shown tasks using that column's sorter.
+ * Repeated selection of the header will toggle
+ * sorting order (ascending versus descending).
+ */
+ return new SelectionAdapter() {
+ /**
+ * Handles the case of user selecting the
+ * header area.
+ * <p>If the column has not been selected previously,
+ * it will set the sorter of that column to be
+ * the current tasklist sorter. Repeated
+ * presses on the same column header will
+ * toggle sorting order (ascending/descending).
+ */
+ public void widgetSelected(SelectionEvent e) {
+ // column selected - need to sort
+ int column = tableViewer.getTable().indexOf((TableColumn) e.widget);
+ HistorySorter oldSorter = (HistorySorter) tableViewer.getSorter();
+ if (oldSorter != null && column == oldSorter.getColumnNumber()) {
+ oldSorter.setReversed(!oldSorter.isReversed());
+ tableViewer.refresh();
+ } else {
+ tableViewer.setSorter(new HistorySorter(column));
+ }
+ }
+ };
+ }
+
+ public void setFile(IFileHistory fileHistory, IFile file) {
+ this.currentFileHistory = fileHistory;
+ this.currentFile = file;
+ this.currentRevision = findCurrentRevision();
+ }
+
+ private String findCurrentRevision() {
+
+ RepositoryProvider teamProvider = RepositoryProvider.getProvider(currentFile.getProject());
+ IFileRevision fileRevision = teamProvider.getFileHistoryProvider().getWorkspaceFileRevision(currentFile);
+
+ if (fileRevision != null)
+ return fileRevision.getContentIdentifier();
+
+ return null;
+ }
+
+ public IFileHistory getIFileHistory() {
+ return this.currentFileHistory;
+ }
+
+ public String getCurrentRevision() {
+ return currentRevision;
+ }
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/CompareRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRevisionAction.java
index 8e27059c5..1524dc898 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/CompareRevisionAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRevisionAction.java
@@ -1,4 +1,15 @@
-package org.eclipse.team.internal.ui.history.actions;
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
@@ -24,30 +35,30 @@ public class CompareRevisionAction extends TeamAction {
IStructuredSelection structSel = getSelection();
if (structSel.size() != 2)
return;
-
+
Object[] objArray = structSel.toArray();
-
+
IFileRevision file1 = (IFileRevision) objArray[0];
IFileRevision file2 = (IFileRevision) objArray[1];
-
+
RevisionEditionNode left = new RevisionEditionNode(file1);
RevisionEditionNode right = new RevisionEditionNode(file2);
- CompareUI.openCompareEditorOnPage(new CompareFileRevisionEditorInput(left, right), getTargetPage());
-
+ CompareUI.openCompareEditorOnPage(new CompareFileRevisionEditorInput(left, right), getTargetPage());
+
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
- }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
+ }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
}
-
+
protected boolean isEnabled() throws TeamException {
IResource[] res = getSelectedResources();
int sizeofSelection = getSelection().size();
-
+
if (sizeofSelection == 2)
return true;
-
+
return false;
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/OpenRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRevisionAction.java
index 9273a2cbf..fe64fa45b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/actions/OpenRevisionAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/OpenRevisionAction.java
@@ -1,4 +1,15 @@
-package org.eclipse.team.internal.ui.history.actions;
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ccvs.ui.actions;
import java.io.IOException;
import java.io.InputStream;
@@ -30,59 +41,58 @@ public class OpenRevisionAction extends TeamAction {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
IStructuredSelection structSel = getSelection();
-
+
Object[] objArray = structSel.toArray();
-
+
for (int i = 0; i < objArray.length; i++) {
IFileRevision revision = (IFileRevision) objArray[i];
if (!revision.exists()) {
- MessageDialog.openError(getShell(), TeamUIMessages.OpenRevisionAction_DeletedRevisionTitle, TeamUIMessages.OpenRevisionAction_DeletedRevisionMessage);
+ MessageDialog.openError(getShell(), TeamUIMessages.OpenRevisionAction_DeletedRevisionTitle, TeamUIMessages.OpenRevisionAction_DeletedRevisionMessage);
} else {
- IStorage file =revision.getStorage(monitor);
-
+ IStorage file = revision.getStorage(monitor);
+
String id = getEditorID(file.getName(), file.getContents());
getTargetPage().openEditor(new FileRevisionEditorInput(revision), id);
}
-
+
}
-
+
} catch (Exception e) {
throw new InvocationTargetException(e);
}
}
- }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
+ }, TeamUIMessages.ConfigureProjectAction_configureProject, PROGRESS_BUSYCURSOR);
}
-
+
protected boolean isEnabled() throws TeamException {
return true;
}
-
- private String getEditorID(String fileName, InputStream contents){
+
+ /* private */ String getEditorID(String fileName, InputStream contents) {
IWorkbench workbench = TeamUIPlugin.getPlugin().getWorkbench();
- IEditorRegistry registry = workbench.getEditorRegistry();
- IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
-
-
- IContentType type = null;
- if (contents != null) {
- try {
- type = Platform.getContentTypeManager().findContentTypeFor(contents, fileName);
- } catch (IOException e) {
-
- }
- }
- if (type == null) {
- type = Platform.getContentTypeManager().findContentTypeFor(fileName);
- }
- IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type);
- String id;
- if (descriptor == null) {
- id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
- } else {
- id = descriptor.getId();
- }
-
- return id;
+ IEditorRegistry registry = workbench.getEditorRegistry();
+ IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+
+ IContentType type = null;
+ if (contents != null) {
+ try {
+ type = Platform.getContentTypeManager().findContentTypeFor(contents, fileName);
+ } catch (IOException e) {
+
+ }
+ }
+ if (type == null) {
+ type = Platform.getContentTypeManager().findContentTypeFor(fileName);
+ }
+ IEditorDescriptor descriptor = registry.getDefaultEditor(fileName, type);
+ String id;
+ if (descriptor == null) {
+ id = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
+ } else {
+ id = descriptor.getId();
+ }
+
+ return id;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
index ee90c7f92..35121bc4f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/CVSAdapterFactory.java
@@ -12,10 +12,10 @@ package org.eclipse.team.internal.ccvs.ui.model;
import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
+import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.ui.CVSFileHistoryProviderParticipant;
import org.eclipse.team.internal.ccvs.ui.repo.RepositoryRoot;
+import org.eclipse.team.ui.history.IFileHistoryProviderParticipant;
import org.eclipse.ui.model.IWorkbenchAdapter;
import org.eclipse.ui.progress.IDeferredWorkbenchAdapter;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -25,6 +25,8 @@ public class CVSAdapterFactory implements IAdapterFactory {
private Object folderAdapter = new RemoteFolderElement();
private Object rootAdapter = new CVSRepositoryRootElement();
+ private Object historyParticipant = new CVSFileHistoryProviderParticipant();
+
// Property cache
private Object cachedPropertyObject = null;
private Object cachedPropertyValue = null;
@@ -48,6 +50,11 @@ public class CVSAdapterFactory implements IAdapterFactory {
if (IPropertySource.class == adapterType) {
return getPropertySource(adaptableObject);
}
+
+ if (IFileHistoryProviderParticipant.class == adapterType){
+ return historyParticipant;
+ }
+
return null;
}
diff --git a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
index 4b9f9d9c1..509b143d0 100644
--- a/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.team.ui/META-INF/MANIFEST.MF
@@ -9,6 +9,7 @@ Bundle-Localization: plugin
Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.actions;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.dialogs;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
+ org.eclipse.team.internal.ui.history,
org.eclipse.team.internal.ui.mapping,
org.eclipse.team.internal.ui.preferences;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.registry;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
@@ -16,6 +17,7 @@ Export-Package: org.eclipse.team.internal.ui;x-friends:="org.eclipse.team.cvs.ss
org.eclipse.team.internal.ui.synchronize.actions;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.internal.ui.wizards;x-friends:="org.eclipse.team.cvs.ssh,org.eclipse.team.cvs.ssh2,org.eclipse.team.cvs.ui",
org.eclipse.team.ui,
+ org.eclipse.team.ui.history,
org.eclipse.team.ui.mapping,
org.eclipse.team.ui.operations,
org.eclipse.team.ui.synchronize
diff --git a/bundles/org.eclipse.team.ui/plugin.xml b/bundles/org.eclipse.team.ui/plugin.xml
index 024ed8201..3d6991968 100644
--- a/bundles/org.eclipse.team.ui/plugin.xml
+++ b/bundles/org.eclipse.team.ui/plugin.xml
@@ -114,20 +114,6 @@
id="nonbound.org.eclipse.team.ui.ImportProjectSetAction">
</action>
</objectContribution>
- <objectContribution
- adaptable="false"
- id="org.eclipse.team.ui.FileRevisionsContribution"
- objectClass="org.eclipse.team.core.history.IFileRevision">
- <action
- class="org.eclipse.team.internal.ui.history.actions.OpenRevisionAction"
- id="org.eclipse.team.ui.OpenRevisionAction"
- label="%FileRevision.OpenAction.name"/>
- <action
- class="org.eclipse.team.internal.ui.history.actions.CompareRevisionAction"
- enablesFor="2"
- id="org.eclipse.team.ui.CompareRevisionAction"
- label="%FileRevision.Compare.name"/>
- </objectContribution>
</extension>
<!-- ************** Views ********************** -->
<extension
@@ -146,6 +132,7 @@
id="org.eclipse.team.sync.views.SynchronizeView">
</view>
<view
+ allowMultiple="true"
category="org.eclipse.team.ui"
class="org.eclipse.team.internal.ui.history.GenericHistoryView"
icon="icons/full/obj/changeset_obj.gif"
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ITeamUIImages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ITeamUIImages.java
index cfb82190a..cb916c555 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ITeamUIImages.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/ITeamUIImages.java
@@ -166,6 +166,15 @@ public interface ITeamUIImages {
* Icon for authentication dialogs.
*/
public final String IMG_KEY_LOCK = "wizban/keylock.gif"; //$NON-NLS-1$
+ /**
+ * Pinned icon
+ */
+ public final String IMG_PINNED = "elcl16/pin.gif"; //$NON-NLS-1$
+ /**
+ * Previous history
+ */
+ public final String IMG_PREVIOUS = "elcl16/prev_nav.gif"; //$NON-NLS-1$
+
//objects
public final String IMG_SITE_ELEMENT = "elcl16/site_element.gif"; //$NON-NLS-1$
public final String IMG_CHANGE_FILTER = "elcl16/change_filter.gif"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
index a4bf95e24..b3b6d7b77 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/TeamUIMessages.java
@@ -362,5 +362,8 @@ public class TeamUIMessages extends NLS {
public static String ResourceMappingMergeOperation_3;
public static String ResourceMappingMergeOperation_4;
+
+
+ public static String GenericHistoryView_PinCurrentHistory;
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
index 0b9584a88..5c87fc533 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryDropAdapter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -13,7 +13,6 @@ package org.eclipse.team.internal.ui.history;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.viewers.StructuredViewer;
import org.eclipse.jface.viewers.ViewerDropAdapter;
import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTargetEvent;
@@ -22,12 +21,13 @@ import org.eclipse.ui.part.ResourceTransfer;
public class GenericHistoryDropAdapter extends ViewerDropAdapter {
- GenericHistoryView view;
-
- public GenericHistoryDropAdapter(StructuredViewer viewer, GenericHistoryView view) {
- super(viewer);
+ private GenericHistoryView view;
+
+ public GenericHistoryDropAdapter(GenericHistoryView view) {
+ super(null);
this.view = view;
}
+
/*
* Override dragOver to slam the detail to DROP_LINK, as we do not
* want to really execute a DROP_MOVE, although we want to respond
@@ -39,6 +39,7 @@ public class GenericHistoryDropAdapter extends ViewerDropAdapter {
}
super.dragOver(event);
}
+
/*
* Override drop to slam the detail to DROP_LINK, as we do not
* want to really execute a DROP_MOVE, although we want to respond
@@ -48,28 +49,30 @@ public class GenericHistoryDropAdapter extends ViewerDropAdapter {
super.drop(event);
event.detail = DND.DROP_LINK;
}
+
public boolean performDrop(Object data) {
- if (data == null) return false;
- if(data instanceof IResource[]) {
- IResource[] sources = (IResource[])data;
- if (sources.length == 0) return false;
- IResource resource = sources[0];
- if (!(resource instanceof IFile)) return false;
- view.showHistory(resource, true /* fetch */);
- return true;
- }
- return false;
+ if (data == null)
+ return false;
+ if (data instanceof IResource[]) {
+ IResource[] sources = (IResource[]) data;
+ if (sources.length == 0)
+ return false;
+ IResource resource = sources[0];
+ if (!(resource instanceof IFile))
+ return false;
+
+ view.itemDropped(resource);
+
+ return true;
+ }
+ return false;
}
-
+
public boolean validateDrop(Object target, int operation, TransferData transferType) {
- if (transferType != null &&
- ResourceTransfer.getInstance().isSupportedType(transferType)) {
+ if (transferType != null && ResourceTransfer.getInstance().isSupportedType(transferType)) {
return true;
}
return false;
}
}
-
-
-
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
index 967cb9abe..e3267f9d6 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryView.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * Copyright (c) 2006 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -11,503 +11,448 @@
package org.eclipse.team.internal.ui.history;
+import java.util.*;
+
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jface.action.*;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerSorter;
-import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.SashForm;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.dnd.*;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.history.*;
-import org.eclipse.team.internal.ui.ITeamUIImages;
-import org.eclipse.team.internal.ui.TeamUIMessages;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.internal.ui.Utils;
-import org.eclipse.team.internal.ui.history.actions.OpenRevisionAction;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartListener2;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchPartReference;
+import org.eclipse.team.core.history.IFileHistoryProvider;
+import org.eclipse.team.internal.ui.*;
+import org.eclipse.team.ui.history.IFileHistoryProviderParticipant;
+import org.eclipse.team.ui.history.IHistoryPage;
+import org.eclipse.ui.*;
import org.eclipse.ui.ide.ResourceUtil;
-import org.eclipse.ui.part.ResourceTransfer;
-import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.part.*;
public class GenericHistoryView extends ViewPart {
- private IFile file;
+ class PageContainer {
+ private Page page;
+ private SubActionBars subBars;
- // cached for efficiency
- private IFileRevision[] entries;
+ public PageContainer(Page page) {
+ this.page = page;
+ }
- protected GenericHistoryTableProvider historyTableProvider;
+ public Page getPage() {
+ return page;
+ }
- private TableViewer tableViewer;
- protected TextViewer textViewer;
- protected TableViewer tagViewer;
+ public void setPage(Page page) {
+ this.page = page;
+ }
-
- protected OpenRevisionAction openAction;
- private IAction toggleTextAction;
- private IAction toggleTextWrapAction;
- private IAction toggleListAction;
- private Action refreshAction;
- private Action linkWithEditorAction;
-
- private SashForm sashForm;
- private SashForm innerSashForm;
+ public SubActionBars getSubBars() {
+ return subBars;
+ }
- protected IFileRevision currentSelection;
+ public void setSubBars(SubActionBars subBars) {
+ this.subBars = subBars;
+ }
+ }
+
+ /**
+ * The pagebook control, or <code>null</code> if not initialized.
+ */
+ private PageBook book;
- protected FetchLogEntriesJob fetchLogEntriesJob;
+ /**
+ * View actions
+ */
+ private Action refreshAction;
+ private Action linkWithEditorAction;
+ private Action pinAction;
- private boolean shutdown = false;
+ /**
+ * The page container for the default page.
+ */
+ private PageContainer defaultPageContainer;
- private boolean linkingEnabled;
-
- public static final String VIEW_ID = "org.eclipse.team.ui.GenericHistoryView"; //$NON-NLS-1$
+ /**
+ * The current page container
+ */
+ PageContainer currentPageContainer;
private IPartListener partListener = new IPartListener() {
public void partActivated(IWorkbenchPart part) {
if (part instanceof IEditorPart)
editorActivated((IEditorPart) part);
}
+
public void partBroughtToTop(IWorkbenchPart part) {
- if(part == GenericHistoryView.this)
+ if (part == GenericHistoryView.this)
editorActivated(getViewSite().getPage().getActiveEditor());
}
+
public void partOpened(IWorkbenchPart part) {
- if(part == GenericHistoryView.this)
+ if (part == GenericHistoryView.this)
editorActivated(getViewSite().getPage().getActiveEditor());
}
+
public void partClosed(IWorkbenchPart part) {
}
+
public void partDeactivated(IWorkbenchPart part) {
}
};
-
+
private IPartListener2 partListener2 = new IPartListener2() {
public void partActivated(IWorkbenchPartReference ref) {
}
+
public void partBroughtToTop(IWorkbenchPartReference ref) {
}
+
public void partClosed(IWorkbenchPartReference ref) {
}
+
public void partDeactivated(IWorkbenchPartReference ref) {
}
+
public void partOpened(IWorkbenchPartReference ref) {
}
+
public void partHidden(IWorkbenchPartReference ref) {
}
+
public void partVisible(IWorkbenchPartReference ref) {
- if(ref.getPart(true) == GenericHistoryView.this)
+ if (ref.getPart(true) == GenericHistoryView.this)
editorActivated(getViewSite().getPage().getActiveEditor());
}
+
public void partInputChanged(IWorkbenchPartReference ref) {
}
};
- public void createPartControl(Composite parent) {
- sashForm = new SashForm(parent, SWT.VERTICAL);
- sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
+ private ISelectionListener selectionListener = new ISelectionListener() {
+
+ public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+ if (!isLinkingEnabled()) {
+ return;
+ }
+
+ if (selection instanceof IStructuredSelection) {
+ IStructuredSelection structSelection = (IStructuredSelection) selection;
+ //Always take the first element - this is not intended to work with multiple selection
+ Object firstElement = structSelection.getFirstElement();
+ itemDropped(firstElement);
+ }
+ }
- tableViewer = createTable(sashForm);
- innerSashForm = new SashForm(sashForm, SWT.HORIZONTAL);
- tagViewer = createTagTable(innerSashForm);
- textViewer = createText(innerSashForm);
- sashForm.setWeights(new int[] { 70, 30 });
- innerSashForm.setWeights(new int[] { 50, 50 });
+ };
+
+ /**
+ * The action bar property listener.
+ */
+ private IPropertyChangeListener actionBarPropListener = new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ if (event.getProperty().equals(SubActionBars.P_ACTION_HANDLERS) && currentPageContainer.getPage() != null && event.getSource() == currentPageContainer.getSubBars()) {
+ refreshGlobalActionHandlers();
+ }
+ }
+ };
+
+ private boolean linkingEnabled;
+
+ private boolean viewPinned;
+
+ private static String viewId = "org.eclipse.team.ui.GenericHistoryView"; //$NON-NLS-1$
+
+ /**
+ * Refreshes the global actions for the active page.
+ */
+ void refreshGlobalActionHandlers() {
+ // Clear old actions.
+ IActionBars bars = getViewSite().getActionBars();
+ bars.clearGlobalActionHandlers();
+
+ // Set new actions.
+ Map newActionHandlers = currentPageContainer.getSubBars().getGlobalActionHandlers();
+ if (newActionHandlers != null) {
+ Set keys = newActionHandlers.entrySet();
+ Iterator iter = keys.iterator();
+ while (iter.hasNext()) {
+ Map.Entry entry = (Map.Entry) iter.next();
+ bars.setGlobalActionHandler((String) entry.getKey(), (IAction) entry.getValue());
+ }
+ }
+ }
+
+ public void createPartControl(Composite parent) {
+ // Create the page book.
+ book = new PageBook(parent, SWT.NONE);
this.linkingEnabled = TeamUIPlugin.getPlugin().getPreferenceStore().getBoolean(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_EDITOR_LINKING);
-
- contributeActions();
- setViewerVisibility();
+ // Create the default page rec.
+ defaultPageContainer = createDefaultPage(book);
+
+ //Contribute toolbars
+ configureToolbars(getViewSite().getActionBars());
- // set F1 help
- // PlatformUI.getWorkbench().getHelpSystem().setHelp(sashForm,
- // IHelpContextIds.RESOURCE_HISTORY_VIEW);
+ //initialize the drag and drop
initDragAndDrop();
+ // Show the default page
+ showPageRec(defaultPageContainer);
+
// add listener for editor page activation - this is to support editor
// linking
getSite().getPage().addPartListener(partListener);
getSite().getPage().addPartListener(partListener2);
- }
-
- private TextViewer createText(SashForm parent) {
- TextViewer result = new TextViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.READ_ONLY);
- result.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- //copyAction.update();
- }
- });
- return result;
- }
- private TableViewer createTagTable(SashForm parent) {
- Table table = new Table(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
- TableViewer result = new TableViewer(table);
- TableLayout layout = new TableLayout();
- layout.addColumnData(new ColumnWeightData(100));
- table.setLayout(layout);
- result.setContentProvider(new SimpleContentProvider() {
- public Object[] getElements(Object inputElement) {
- if (inputElement == null) return new Object[0];
- ITag[] tags = (ITag[])inputElement;
- return tags;
- }
- });
- result.setLabelProvider(new LabelProvider() {
- public Image getImage(Object element) {
- if (element == null) return null;
- ITag tag = (ITag)element;
- //Need an image
- return null;
- }
- public String getText(Object element) {
- return ((ITag)element).getName();
- }
- });
- result.setSorter(new ViewerSorter() {
- public int compare(Viewer viewer, Object e1, Object e2) {
- if (!(e1 instanceof ITag) || !(e2 instanceof ITag)) return super.compare(viewer, e1, e2);
- ITag tag1 = (ITag)e1;
- ITag tag2 = (ITag)e2;
- /*int type1 = tag1.getType();
- int type2 = tag2.getType();
- if (type1 != type2) {
- return type2 - type1;
- }*/
- return super.compare(viewer, tag1, tag2);
- }
- });
- return result;
+ // add listener for selections
+ getSite().getPage().addSelectionListener(selectionListener);
}
- public void setFocus() {
- }
+ private void configureToolbars(IActionBars actionBars) {
- /**
- * Adds drag and drop support to the history view.
- */
- void initDragAndDrop() {
- int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
- Transfer[] transfers = new Transfer[] { ResourceTransfer.getInstance(),
- ResourceTransfer.getInstance() };
- tableViewer.addDropSupport(ops, transfers,
- new GenericHistoryDropAdapter(tableViewer, this));
- }
-
- protected void contributeActions() {
- TeamUIPlugin plugin = TeamUIPlugin.getPlugin();
-
- // Double click open action
- openAction = new OpenRevisionAction();
- tableViewer.getTable().addListener(SWT.DefaultSelection, new Listener() {
- public void handleEvent(Event e) {
- openAction.selectionChanged(null, tableViewer.getSelection());
- openAction.run(null);
- }
- });
-
- refreshAction = new Action(TeamUIMessages.GenericHistoryView_Refresh, plugin.getImageDescriptor(ITeamUIImages.IMG_REFRESH)) {
+ pinAction = new Action(TeamUIMessages.GenericHistoryView_PinCurrentHistory, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_PINNED)) {
public void run() {
- refresh();
+ if (isChecked()) {
+ //uncheck editor linking and disable
+ linkWithEditorAction.setChecked(false);
+ linkWithEditorAction.setEnabled(false);
+ setLinkingEnabled(false);
+ } else {
+ //renable the linking button
+ linkWithEditorAction.setEnabled(true);
+ }
+ setViewPinned(isChecked());
}
};
-
- linkWithEditorAction = new Action(TeamUIMessages.GenericHistoryView_LinkWithEditor, plugin.getImageDescriptor(ITeamUIImages.IMG_LINK_WITH)) {
- public void run() {
- setLinkingEnabled(isChecked());
- }
- };
- linkWithEditorAction.setChecked(isLinkingEnabled());
-
- // Toggle text visible action
- final IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
- toggleTextAction = new Action(TeamUIMessages.GenericHistoryView_ShowCommentViewer) {
+ pinAction.setChecked(isViewPinned());
+ pinAction.setToolTipText("Pins this history view");
+
+ refreshAction = new Action(TeamUIMessages.GenericHistoryView_Refresh, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_REFRESH)) {
public void run() {
- setViewerVisibility();
- store.setValue(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_SHOW_COMMENTS, toggleTextAction.isChecked());
+ ((IHistoryPage) currentPageContainer.getPage()).refresh();
}
};
- toggleTextAction.setChecked(store.getBoolean(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_SHOW_COMMENTS));
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextAction, IHelpContextIds.SHOW_COMMENT_IN_HISTORY_ACTION);
-
- // Toggle wrap comments action
- toggleTextWrapAction = new Action(TeamUIMessages.GenericHistoryView_WrapComments) {
- public void run() {
- setViewerVisibility();
- store.setValue(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_WRAP_COMMENTS, toggleTextWrapAction.isChecked());
- }
- };
- toggleTextWrapAction.setChecked(store.getBoolean(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_WRAP_COMMENTS));
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleTextWrapAction, IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);
-
- // Toggle list visible action
- toggleListAction = new Action(TeamUIMessages.GenericHistoryView_ShowTagViewer) {
+
+ linkWithEditorAction = new Action(TeamUIMessages.GenericHistoryView_LinkWithEditor, TeamUIPlugin.getImageDescriptor(ITeamUIImages.IMG_LINK_WITH)) {
public void run() {
- setViewerVisibility();
- store.setValue(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_SHOW_TAGS, toggleListAction.isChecked());
+ setLinkingEnabled(isViewPinned() ? false : isChecked());
}
};
- toggleListAction.setChecked(store.getBoolean(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_SHOW_TAGS));
- //PlatformUI.getWorkbench().getHelpSystem().setHelp(toggleListAction, IHelpContextIds.SHOW_TAGS_IN_HISTORY_ACTION);
-
-
+ linkWithEditorAction.setChecked(isLinkingEnabled());
+
+ //previousHistory = new GenericHistoryDropDownAction();
+
//Create the local tool bar
- IToolBarManager tbm = getViewSite().getActionBars().getToolBarManager();
+ IToolBarManager tbm = actionBars.getToolBarManager();
+ //Take out history support for now
+ //tbm.add(previousHistory);
tbm.add(refreshAction);
tbm.add(linkWithEditorAction);
+ tbm.add(pinAction);
tbm.update(false);
-
- //Contribute actions to popup menu
- MenuManager menuMgr = new MenuManager();
- Menu menu = menuMgr.createContextMenu(tableViewer.getTable());
- menuMgr.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager menuMgr) {
- fillTableMenu(menuMgr);
- }
- });
- menuMgr.setRemoveAllWhenShown(true);
- tableViewer.getTable().setMenu(menu);
- getSite().registerContextMenu(menuMgr, tableViewer);
-
- // Contribute toggle text visible to the toolbar drop-down
- IActionBars actionBars = getViewSite().getActionBars();
- IMenuManager actionBarsMenu = actionBars.getMenuManager();
- actionBarsMenu.add(toggleTextWrapAction);
- actionBarsMenu.add(new Separator());
- actionBarsMenu.add(toggleTextAction);
- actionBarsMenu.add(toggleListAction);
-
}
- private void fillTableMenu(IMenuManager manager) {
- // file actions go first (view file)
- manager.add(new Separator("additions")); //$NON-NLS-1$
- manager.add(refreshAction);
- manager.add(new Separator("additions-end")); //$NON-NLS-1$
+ boolean isLinkingEnabled() {
+ return linkingEnabled;
}
-
+
/**
- * Creates the group that displays lists of the available repositories and
- * team streams.
- *
- * @param the
- * parent composite to contain the group
- * @return the group control
+ * Enabled linking to the active editor
*/
- protected TableViewer createTable(Composite parent) {
-
- historyTableProvider = new GenericHistoryTableProvider();
- TableViewer viewer = historyTableProvider.createTable(parent);
-
- viewer.setContentProvider(new IStructuredContentProvider() {
- public Object[] getElements(Object inputElement) {
+ public void setLinkingEnabled(boolean enabled) {
+ this.linkingEnabled = enabled;
- // The entries of already been fetch so return them
- if (entries != null)
- return entries;
+ // remember the last setting in the dialog settings
+ TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_EDITOR_LINKING, enabled);
- // The entries need to be fetch (or are being fetched)
- if (!(inputElement instanceof IFileHistory))
- return null;
+ // if turning linking on, update the selection to correspond to the active editor
+ if (enabled) {
+ editorActivated(getSite().getPage().getActiveEditor());
+ }
+ }
- final IFileHistory remoteFile = (IFileHistory) inputElement;
- if (fetchLogEntriesJob == null) {
- fetchLogEntriesJob = new FetchLogEntriesJob();
- }
+ /**
+ * Sets the current view pinned
+ * @param b
+ */
+ void setViewPinned(boolean pinned) {
+ this.viewPinned = pinned;
+ }
- IFileHistory file = fetchLogEntriesJob.getRemoteFile();
-
- if (file == null || !file.equals(remoteFile)) { // The resource
- // has changed
- // so stop the
- // currently
- // running job
- if (fetchLogEntriesJob.getState() != Job.NONE) {
- fetchLogEntriesJob.cancel();
- try {
- fetchLogEntriesJob.join();
- } catch (InterruptedException e) {
- TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] { "" }), e)); //$NON-NLS-1$
- }
- }
- fetchLogEntriesJob.setRemoteFile(remoteFile);
- } // Schedule the job even if it is already running
- Utils.schedule(fetchLogEntriesJob, getViewSite());
+ /**
+ * Adds drag and drop support to the history view.
+ */
+ void initDragAndDrop() {
+ int ops = DND.DROP_MOVE | DND.DROP_COPY | DND.DROP_LINK;
+ Transfer[] transfers = new Transfer[] {ResourceTransfer.getInstance(), ResourceTransfer.getInstance()};
- return new Object[0];
- }
+ DropTarget dropTarget = new DropTarget(book, ops);
+ dropTarget.setTransfer(transfers);
+ dropTarget.addDropListener(new GenericHistoryDropAdapter(this));
+ }
- public void dispose() {
- }
+ public void setFocus() {
+ // TODO Auto-generated method stub
- public void inputChanged(Viewer viewer, Object oldInput,
- Object newInput) {
- entries = null;
- }
- });
-
- viewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- ISelection selection = event.getSelection();
-
- if (selection != null &&
- selection instanceof IStructuredSelection){
- IStructuredSelection ss = (IStructuredSelection) selection;
- currentSelection = (IFileRevision) ss.getFirstElement();
- }
-
- if (selection == null || !(selection instanceof IStructuredSelection)) {
- textViewer.setDocument(new Document("")); //$NON-NLS-1$
- tagViewer.setInput(null);
- return; }
-
- IStructuredSelection ss =(IStructuredSelection)selection;
- if (ss.size() != 1) {
- textViewer.setDocument(new Document("")); //$NON-NLS-1$
- tagViewer.setInput(null);
- return;
- }
-
- IFileRevision entry =(IFileRevision)ss.getFirstElement();
- textViewer.setDocument(new Document(entry.getComment()));
- tagViewer.setInput(entry.getTags());
-
- }
- });
+ }
- return viewer;
+ /**
+ * Prepares the page in the given page rec for use
+ * in this view.
+ * @param rec
+ */
+ private void preparePage(PageContainer pageContainer) {
+ pageContainer.getSubBars().addPropertyChangeListener(actionBarPropListener);
+ //for backward compability with IPage
+ pageContainer.getPage().setActionBars(pageContainer.getSubBars());
}
-
- /*
- * Refresh the view by refetching the log entries for the remote file
+
+ /**
+ * Shows page contained in the given page record in this view. The page record must
+ * be one from this pagebook view.
+ * <p>
+ * The <code>PageBookView</code> implementation of this method asks the
+ * pagebook control to show the given page's control, and records that the
+ * given page is now current. Subclasses may extend.
+ * </p>
+ *
+ * @param pageRec the page record containing the page to show
*/
- private void refresh() {
- entries = null;
- BusyIndicator.showWhile(tableViewer.getTable().getDisplay(),
- new Runnable() {
- public void run() {
- // if a local file was fed to the history view then we
- // will have to refetch the handle
- // to properly display the current revision marker.
- tableViewer.refresh();
- }
- });
+ protected void showPageRec(PageContainer pageContainer) {
+ // If already showing do nothing
+ if (currentPageContainer == pageContainer)
+ return;
+ // If the page is the same, just set activeRec to pageRec
+ if (currentPageContainer != null && pageContainer != null && currentPageContainer == pageContainer) {
+ currentPageContainer = pageContainer;
+ return;
+ }
+
+ // Hide old page.
+ if (currentPageContainer != null) {
+ currentPageContainer.getSubBars().deactivate();
+ // remove our selection listener
+ /* ISelectionProvider provider = ((PageSite) mapPageToSite.get(activeRec.page)).getSelectionProvider();
+ if (provider != null)
+ provider
+ .removeSelectionChangedListener(selectionChangedListener);*/
+ }
+ // Show new page.
+ currentPageContainer = pageContainer;
+ //setContentDescription(((IHistoryPage)currentPageContainer.getPage()).getName());
+ Control pageControl = currentPageContainer.getPage().getControl();
+ if (pageControl != null && !pageControl.isDisposed()) {
+ // Verify that the page control is not disposed
+ // If we are closing, it may have already been disposed
+ book.showPage(pageControl);
+ currentPageContainer.getSubBars().activate();
+ //refreshGlobalActionHandlers();
+ // add our selection listener
+ /*ISelectionProvider provider = ((PageSite) mapPageToSite
+ .get(activeRec.page)).getSelectionProvider();
+ if (provider != null)
+ provider.addSelectionChangedListener(selectionChangedListener);*/
+ // Update action bars.
+ getViewSite().getActionBars().updateActionBars();
+ }
}
/**
- * Shows the history for the given IResource in the view.
- *
- * Only files are supported for now.
+ * Initializes the given page with a page site.
+ * <p>
+ * Subclasses should call this method after
+ * the page is created but before creating its
+ * controls.
+ * </p>
+ * <p>
+ * Subclasses may override
+ * </p>
+ * @param page The page to initialize
*/
- public void showHistory(IResource resource, boolean refetch) {
- if (resource instanceof IFile) {
- IFile newfile = (IFile) resource;
- if (!refetch && this.file != null && newfile.equals(this.file)) {
- return;
- }
- this.file = newfile;
- RepositoryProvider teamProvider = RepositoryProvider
- .getProvider(file.getProject());
- IFileHistory fileHistory = teamProvider.getFileHistoryProvider()
- .getFileHistoryFor(resource, new NullProgressMonitor());
+ protected PageSite initPage(IPageBookViewPage page) {
+ try {
+ PageSite site = new PageSite(getViewSite());
+ page.init(site);
+ return site;
+ } catch (PartInitException e) {
+ TeamUIPlugin.log(e);
+ }
+ return null;
+ }
- try {
- IFileRevision[] revisions = fileHistory
- .getFileRevisions();
+ public void itemDropped(Object object) {
- } catch (TeamException e) {
+ if (object instanceof IFile) {
+ IFile newFile = (IFile) object;
+ //check first to see if this view is pinned
+ if (isViewPinned()) {
+ try {
+ //get the file name
+ IViewPart view = getSite().getPage().showView(viewId, viewId + newFile.getName() + System.currentTimeMillis(), IWorkbenchPage.VIEW_CREATE);
+ if (view instanceof GenericHistoryView) {
+ GenericHistoryView view2 = (GenericHistoryView) view;
+ view2.itemDropped(object);
+ }
+ return;
+ } catch (PartInitException e) {
+ }
+ }
+ RepositoryProvider teamProvider = RepositoryProvider.getProvider(newFile.getProject());
+ IFileHistoryProvider fileHistory = teamProvider.getFileHistoryProvider();
+ Object tempParticipant = Platform.getAdapterManager().getAdapter(fileHistory, IFileHistoryProviderParticipant.class);
+ if (tempParticipant instanceof IFileHistoryProviderParticipant) {
+ IFileHistoryProviderParticipant participant = (IFileHistoryProviderParticipant) tempParticipant;
+
+ //If a current page exists, see if it can handle the dropped item
+ if (currentPageContainer.getPage() instanceof IHistoryPage) {
+ PageContainer tempPageContainer = currentPageContainer;
+ if (!((IHistoryPage) tempPageContainer.getPage()).canShowHistoryFor(newFile)) {
+ tempPageContainer = createPage(participant);
+ }
+ if (tempPageContainer != null) {
+ ((IHistoryPage) tempPageContainer.getPage()).showHistory(newFile, true);
+ setContentDescription(newFile.getName());
+ showPageRec(tempPageContainer);
+ } else {
+ showPageRec(defaultPageContainer);
+ }
+ }
}
- historyTableProvider.setFile(fileHistory, file);
- tableViewer.setInput(fileHistory);
- setContentDescription(newfile.getName());
- } else {
- this.file = null;
- tableViewer.setInput(null);
- setContentDescription(""); //$NON-NLS-1$
- setTitleToolTip(""); //$NON-NLS-1$
}
+
}
-
- private void setViewerVisibility() {
- boolean showText = toggleTextAction.isChecked();
- boolean showList = toggleListAction.isChecked();
- if (showText && showList) {
- sashForm.setMaximizedControl(null);
- innerSashForm.setMaximizedControl(null);
- } else if (showText) {
- sashForm.setMaximizedControl(null);
- innerSashForm.setMaximizedControl(textViewer.getTextWidget());
- } else if (showList) {
- sashForm.setMaximizedControl(null);
- innerSashForm.setMaximizedControl(tagViewer.getTable());
- } else {
- sashForm.setMaximizedControl(tableViewer.getControl());
- }
-
- boolean wrapText = toggleTextWrapAction.isChecked();
- textViewer.getTextWidget().setWordWrap(wrapText);
+
+ boolean isViewPinned() {
+ return viewPinned;
}
-
- /**
- * Enabled linking to the active editor
- */
- public void setLinkingEnabled(boolean enabled) {
- this.linkingEnabled = enabled;
- // remember the last setting in the dialog settings
- TeamUIPlugin.getPlugin().getPreferenceStore().setValue(IFileHistoryConstants.PREF_GENERIC_HISTORYVIEW_EDITOR_LINKING, enabled);
-
- // if turning linking on, update the selection to correspond to the active editor
- if (enabled) {
- editorActivated(getSite().getPage().getActiveEditor());
- }
+ private PageContainer createPage(IFileHistoryProviderParticipant participant) {
+ Page page = participant.createPage();
+ PageSite site = initPage(page);
+ ((IHistoryPage) page).setSite(getViewSite());
+ page.createControl(book);
+ PageContainer container = new PageContainer(page);
+ container.setSubBars((SubActionBars) site.getActionBars());
+ return container;
}
-
+
+ protected PageContainer createDefaultPage(PageBook book) {
+ GenericHistoryViewDefaultPage page = new GenericHistoryViewDefaultPage();
+ PageSite site = initPage(page);
+ page.createControl(book);
+ PageContainer container = new PageContainer(page);
+ container.setSubBars((SubActionBars) site.getActionBars());
+ return container;
+ }
+
/**
* An editor has been activated. Fetch the history if the file is shared and the history view
* is visible in the current page.
@@ -516,124 +461,42 @@ public class GenericHistoryView extends ViewPart {
*/
protected void editorActivated(IEditorPart editor) {
// Only fetch contents if the view is shown in the current page.
- if (editor == null || !isLinkingEnabled() || !checkIfPageIsVisible()) {
+ if (editor == null || !isLinkingEnabled() || !checkIfPageIsVisible() || isViewPinned()) {
return;
- }
+ }
IEditorInput input = editor.getEditorInput();
-
- if (input instanceof FileRevisionEditorInput){
+
+ if (input instanceof FileRevisionEditorInput) {
IFile file;
try {
file = ResourceUtil.getFile(((FileRevisionEditorInput) input).getStorage().getFullPath());
- if(file != null) {
- showHistory(file, false);
- }
- } catch (CoreException e) {}
+ if (file != null) {
+ itemDropped(file);
+ }
+ } catch (CoreException e) {
+ }
} // Handle regular file editors
else {
- IFile file = ResourceUtil.getFile(input);
- if(file != null) {
- showHistory(file, false /* don't fetch if already cached */);
- }
+ IFile file = ResourceUtil.getFile(input);
+ if (file != null) {
+ itemDropped(file);//, false /* don't fetch if already cached */);
+ }
}
}
-
+
private boolean checkIfPageIsVisible() {
return getViewSite().getPage().isPartVisible(this);
}
-
- /**
- * Returns if linking to the ative editor is enabled or disabled.
- * @return boolean indicating state of editor linking.
- */
- private boolean isLinkingEnabled() {
- return linkingEnabled;
- }
public void dispose() {
- shutdown = true;
-
- if(fetchLogEntriesJob != null) {
- if(fetchLogEntriesJob.getState() != Job.NONE) {
- fetchLogEntriesJob.cancel();
- try {
- fetchLogEntriesJob.join();
- } catch (InterruptedException e) {
- TeamUIPlugin.log(new TeamException(NLS.bind(TeamUIMessages.GenericHistoryView_ErrorFetchingEntries, new String[] { "" }), e)); //$NON-NLS-1$
- }
- }
- }
+ super.dispose();
+ //Call dispose on current and default pages
+ currentPageContainer.getPage().dispose();
+ defaultPageContainer.getPage().dispose();
+ //Remove the part listeners
getSite().getPage().removePartListener(partListener);
getSite().getPage().removePartListener(partListener2);
- }
-
- private class FetchLogEntriesJob extends Job {
- public IFileHistory fileHistory;
-
- public FetchLogEntriesJob() {
- super(TeamUIMessages.GenericHistoryView_GenericFileHistoryFetcher);
- }
-
- public void setRemoteFile(IFileHistory file) {
- this.fileHistory = file;
- }
-
- public IStatus run(IProgressMonitor monitor) {
- try {
- if (fileHistory != null && !shutdown) {
- entries = fileHistory.getFileRevisions();
- // final String revisionId = fileHistory.;
- getSite().getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (entries != null && tableViewer != null
- && !tableViewer.getTable().isDisposed()) {
- tableViewer.refresh();
- // selectRevision(revisionId);
- }
- }
- });
- }
- return Status.OK_STATUS;
- } catch (TeamException e) {
- return e.getStatus();
- }
- }
-
- public IFileHistory getRemoteFile() {
- return this.fileHistory;
- }
- }
-
- /**
- * A default content provider to prevent subclasses from
- * having to implement methods they don't need.
- */
- private class SimpleContentProvider implements IStructuredContentProvider {
-
- /**
- * SimpleContentProvider constructor.
- */
- public SimpleContentProvider() {
- super();
- }
-
- /*
- * @see SimpleContentProvider#dispose()
- */
- public void dispose() {
- }
-
- /*
- * @see SimpleContentProvider#getElements()
- */
- public Object[] getElements(Object element) {
- return new Object[0];
- }
-
- /*
- * @see SimpleContentProvider#inputChanged()
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
+ //Remove the selection listener
+ getSite().getPage().addSelectionListener(selectionListener);
}
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java
new file mode 100644
index 000000000..97ebda44e
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/history/GenericHistoryViewDefaultPage.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.internal.ui.history;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.jface.resource.JFaceColors;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.team.ui.history.IHistoryPage;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.part.Page;
+
+public class GenericHistoryViewDefaultPage extends Page implements IHistoryPage {
+
+ private Composite pgComp;
+
+ public void createControl(Composite parent) {
+ pgComp = new Composite(parent, SWT.NULL);
+ pgComp.setLayout(new FillLayout());
+ pgComp.setBackground(JFaceColors.getBannerBackground(pgComp.getDisplay()));
+ }
+
+ public Control getControl() {
+ return pgComp;
+ }
+
+ public void setFocus() {
+ pgComp.setFocus();
+ }
+
+ public void showHistory(IResource resource, boolean refetch) {
+ //no history to show
+ }
+
+ public boolean canShowHistoryFor(IResource resource) {
+ return false;
+ }
+
+ public void refresh() {
+ //nothing to refresh
+ }
+
+ public String getName() {
+ return ""; //$NON-NLS-1$
+ }
+
+ public void setSite(IViewSite viewSite) {
+ //nothing to set
+ }
+
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index c08b785b0..e96725ef4 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -339,6 +339,7 @@ TeamContentProviderDescriptor_2=Attribute {0} of extension point {1} missing for
TeamCompareEditorInput_fileProgress=Comparing file: {0}
GenericHistoryView_ShowCommentViewer=Show Comment Viewer
+GenericHistoryView_PinCurrentHistory=Pin current history view
GenericHistoryTableProvider_Revision=Revision
GenericHistoryTableProvider_Comment=Comment
GenericHistoryView_GenericFileHistoryFetcher=Fetching File History
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IFileHistoryProviderParticipant.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IFileHistoryProviderParticipant.java
new file mode 100644
index 000000000..7bb438808
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IFileHistoryProviderParticipant.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.ui.history;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.team.core.history.IFileHistoryProvider;
+import org.eclipse.ui.part.Page;
+
+/**
+ * IFileHistoryProviderParticipant is the visual component of an
+ * {@link IFileHistoryProvider}. It is used by the HistoryView to associate
+ * an IFileHistoryProvider with its corresponding Page. Clients should provide an
+ * implementation for all IFileHistory types they wish to display in the history
+ * view.
+ *
+ * An IFileHistoryProviderParticipant is associated with its IFileHistoryProvider through
+ * the {@link IAdaptable} mechanism.
+ *
+ * @see IFileHistoryProvider
+ * @since 3.2
+ */
+public interface IFileHistoryProviderParticipant {
+ /**
+ * Called by the HistoryView to create the page for this IFileHistoryProvider. The
+ * page must implement {@link IHistoryPage}.
+ *
+ * @see IHistoryPage
+ * @return a Page that implements IHistoryPage
+ */
+ public Page createPage();
+}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IHistoryPage.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IHistoryPage.java
new file mode 100644
index 000000000..766840322
--- /dev/null
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/history/IHistoryPage.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.team.ui.history;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.ui.IViewSite;
+
+public interface IHistoryPage {
+ /**
+ * Fetches and populates the history page for the given IResource. Clients
+ * should provide an implementation for their individual pages.
+ *
+ * @param resource the resource for which history is being requested for
+ * @return true if the page can show the history for the given resource, false if
+ * it can't
+ */
+ public void showHistory(IResource resource, boolean refetch);
+
+ /**
+ * Returns true if this history page can show a history for the given resource, false if it cannot
+ * @param resource the resource that is to have history shown
+ * @return boolean
+ */
+ public boolean canShowHistoryFor(IResource resource);
+
+ /**
+ * Requests a refresh of the information presented by the history page.
+ *
+ */
+ public void refresh();
+
+ /**
+ * Returns the name of the object whose history the page is showing
+ * @return String containing the name of the object
+ */
+ public String getName();
+
+ /**
+ * Set the site for the page - this needs to be replaced with a proper
+ * IHistoryPageSite in order to allow history pages to be displayed in
+ * both views and dialogs
+ * @param viewSite
+ */
+ public void setSite(IViewSite viewSite);
+}

Back to the top