diff options
author | Michael Valenta | 2006-12-15 14:01:37 +0000 |
---|---|---|
committer | Michael Valenta | 2006-12-15 14:01:37 +0000 |
commit | 46cd3c0a4467bb8c7aa9b13b7982a38a25fac32f (patch) | |
tree | 02eda6df78d6f58f0a74d6751f6de210b115587a /bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs | |
parent | 70a03f90603fd37eb32b287decc7a3a5c2e136a6 (diff) | |
download | eclipse.platform.team-46cd3c0a4467bb8c7aa9b13b7982a38a25fac32f.tar.gz eclipse.platform.team-46cd3c0a4467bb8c7aa9b13b7982a38a25fac32f.tar.xz eclipse.platform.team-46cd3c0a4467bb8c7aa9b13b7982a38a25fac32f.zip |
Bug 60586 [Sync View] SaveablePartDialog uses internal compare class
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs')
2 files changed, 33 insertions, 83 deletions
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 index 79a48816f..3293cb2be 100644 --- 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 @@ -425,7 +425,7 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC if(confirmOverwrite() && validateChange()) { CVSTag revisionTag = new CVSTag(remoteFile.getRevision(), CVSTag.VERSION); - if(CVSAction.checkForMixingTags(getSite().getShell(), new IResource[] {file.getIResource()}, revisionTag)) { + if(CVSAction.checkForMixingTags(getHistoryPageSite().getShell(), new IResource[] {file.getIResource()}, revisionTag)) { new UpdateOperation( null, new IResource[] {file.getIResource()}, @@ -1498,6 +1498,8 @@ public class CVSHistoryPage extends HistoryPage implements IAdaptable, IHistoryC final boolean hasRevision = cvsFileHistory.getFileRevision(revision) != null; Display.getDefault().asyncExec(new Runnable() { public void run() { + if (treeViewer.getControl().isDisposed()) + return; if (treeViewer.getControl().isVisible()) { if (hasRevision) refresh(CVSFileHistory.REFRESH_LOCAL); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java index 69c4be5ac..15f77e55d 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRevisionAction.java @@ -10,20 +10,17 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; -import java.lang.reflect.InvocationTargetException; - import org.eclipse.compare.CompareConfiguration; -import org.eclipse.compare.IEditableContent; +import org.eclipse.compare.CompareUI; import org.eclipse.compare.structuremergeviewer.ICompareInput; +import org.eclipse.core.resources.IFile; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.viewers.*; -import org.eclipse.swt.widgets.*; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.team.internal.ccvs.ui.CVSHistoryPage; import org.eclipse.team.internal.ccvs.ui.CVSUIMessages; import org.eclipse.team.internal.ui.Utils; import org.eclipse.team.internal.ui.history.FileRevisionTypedElement; -import org.eclipse.team.ui.SaveablePartDialog; import org.eclipse.team.ui.history.*; /** @@ -35,87 +32,38 @@ import org.eclipse.team.ui.history.*; */ public class ReplaceWithRevisionAction extends CompareWithRevisionAction { - protected static final int REPLACE_ID = 10; - - protected class ReplaceSaveablePart extends HistoryPageSaveablePart { - ICompareInput compareInput; - - public ReplaceSaveablePart(Shell shell, CompareConfiguration configuration, IHistoryPageSource pageSource, Object object) { - super(shell, configuration, pageSource, object); - } - - protected void prepareInput(ICompareInput input, CompareConfiguration configuration, IProgressMonitor monitor) throws InvocationTargetException { - super.prepareInput(input, configuration, monitor); - compareInput = input; - configuration.setLeftEditable(false); - } - - public void replaceLocalWithCurrentlySelectedRevision() throws CoreException{ - FileRevisionTypedElement right = (FileRevisionTypedElement) compareInput.getRight(); - IEditableContent left = (IEditableContent)compareInput.getLeft(); - left.setContent(Utils.readBytes(right.getContents())); - } - - - public ISelectionProvider getReplaceSelectionProvider(){ - return getSelectionProvider(); - } - } - protected class ReplaceCompareDialog extends SaveablePartDialog { - private Button replaceButton; - - public ReplaceCompareDialog(Shell shell, ReplaceSaveablePart input) { - super(shell, input); - } - - /** - * Add the replace button to the dialog. - */ - protected void createButtonsForButtonBar(Composite parent) { - replaceButton = createButton(parent, REPLACE_ID, CVSUIMessages.ReplaceWithRevisionAction_0, true); - replaceButton.setEnabled(false); - ((ReplaceSaveablePart) getInput()).getReplaceSelectionProvider().addSelectionChangedListener( - new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent e) { - IStructuredSelection s= (StructuredSelection) e.getSelection(); - replaceButton.setEnabled(s != null && ! s.isEmpty() && s.size() == 1); - } - } - ); - createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false); - // Don't call super because we don't want the OK button to appear - } - - /** - * If the replace button was pressed. - */ - protected void buttonPressed(int buttonId) { - if(buttonId == REPLACE_ID) { - try { - ((ReplaceSaveablePart) getInput()).replaceLocalWithCurrentlySelectedRevision(); - } catch (CoreException e) { - Utils.handle(e); - } - buttonId = IDialogConstants.OK_ID; - } - super.buttonPressed(buttonId); - } - } - protected void showCompareInDialog(Shell shell, Object object){ IHistoryPageSource pageSource = HistoryPageSource.getHistoryPageSource(object); if (pageSource != null && pageSource.canShowHistoryFor(object)) { CompareConfiguration cc = new CompareConfiguration(); cc.setLeftEditable(false); cc.setRightEditable(false); - ReplaceSaveablePart input = new ReplaceSaveablePart(shell, cc, pageSource, object); - try { - SaveablePartDialog cd = new ReplaceCompareDialog(shell, input); - cd.setBlockOnOpen(true); - cd.open(); - } finally { - input.dispose(); - } + HistoryPageCompareEditorInput input = new HistoryPageCompareEditorInput(cc, pageSource, object) { + public void saveChanges(IProgressMonitor monitor) throws CoreException { + super.saveChanges(monitor); + ((CVSHistoryPage)getHistoryPage()).saveChanges(monitor); + setDirty(false); + } + public boolean isEditionSelectionDialog() { + return true; + } + public String getOKButtonLabel() { + return CVSUIMessages.ReplaceWithRevisionAction_0; + } + public boolean okPressed() { + try { + Object o = getSelectedEdition(); + FileRevisionTypedElement right = (FileRevisionTypedElement) ((ICompareInput)o).getRight(); + IFile file = (IFile)getCompareResult(); + file.setContents(right.getContents(), false, true, null); + } catch (CoreException e) { + Utils.handle(e); + return false; + } + return true; + } + }; + CompareUI.openCompareDialog(input); } } /* (non-Javadoc) |