Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 176219 Details for
Bug 273450
Wrong dialogs when closing Compare With Each Other... editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v05
wrongDialogs3.txt (text/plain), 33.82 KB, created by
Tomasz Zarna
on 2010-08-10 06:21:39 EDT
(
hide
)
Description:
Patch v05
Filename:
MIME Type:
Creator:
Tomasz Zarna
Created:
2010-08-10 06:21:39 EDT
Size:
33.82 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/CompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java,v >retrieving revision 1.117 >diff -u -r1.117 CompareEditorInput.java >--- compare/org/eclipse/compare/CompareEditorInput.java 9 Apr 2010 13:06:32 -0000 1.117 >+++ compare/org/eclipse/compare/CompareEditorInput.java 10 Aug 2010 10:07:29 -0000 >@@ -11,9 +11,9 @@ > package org.eclipse.compare; > > import java.lang.reflect.InvocationTargetException; >-import java.util.ArrayList; > import java.util.ResourceBundle; > >+import org.eclipse.compare.contentmergeviewer.ContentMergeViewer; > import org.eclipse.compare.contentmergeviewer.IFlushable; > import org.eclipse.compare.internal.BinaryCompareViewer; > import org.eclipse.compare.internal.ChangePropertyAction; >@@ -24,6 +24,7 @@ > import org.eclipse.compare.internal.CompareStructureViewerSwitchingPane; > import org.eclipse.compare.internal.CompareUIPlugin; > import org.eclipse.compare.internal.ICompareUIConstants; >+import org.eclipse.compare.internal.IFlushable2; > import org.eclipse.compare.internal.OutlineViewerCreator; > import org.eclipse.compare.internal.Utilities; > import org.eclipse.compare.internal.ViewerDescriptor; >@@ -177,7 +178,7 @@ > * @since 3.3 > */ > public static final String PROP_SELECTED_EDITION= ICompareUIConstants.PROP_SELECTED_EDITION; >- >+ > private static final String COMPARE_EDITOR_IMAGE_NAME= "eview16/compare_view.gif"; //$NON-NLS-1$ > private static Image fgTitleImage; > >@@ -193,8 +194,8 @@ > private String fTitle; > private ListenerList fListenerList= new ListenerList(); > private CompareNavigator fNavigator; >- private boolean fDirty= false; >- private ArrayList fDirtyViewers= new ArrayList(); >+ private ContentMergeViewer fLeftDirtyViewer = null; >+ private ContentMergeViewer fRightDirtyViewer = null; > private IPropertyChangeListener fDirtyStateListener; > > boolean fStructureCompareOnSingleClick= true; >@@ -1016,18 +1017,38 @@ > } > > /** >- * Returns <code>true</code> if there are unsaved changes. >- * The value returned is the value of the <code>DIRTY_STATE</code> property of this input object. >- >- * Returns <code>true</code> if this input has unsaved changes, >- * that is if <code>setDirty(true)</code> has been called. >- * Subclasses don't have to override if the functionality provided by <code>setDirty</code> >- * is sufficient. >- * >+ * Returns <code>true</code> if there are unsaved changes in either left or >+ * right side. The value returned is the value of the >+ * <code>DIRTY_STATE</code> property of this input object. >+ * >+ * Returns <code>true</code> if left or right side has unsaved changes >+ * Subclasses don't have to override if the functionality provided by >+ * <code>setDirty</code> is sufficient. >+ * > * @return <code>true</code> if there are changes that need to be saved > */ > public boolean isSaveNeeded() { >- return fDirty || fDirtyViewers.size() > 0; >+ return isLeftSaveNeeded() || isRightSaveNeeded(); >+ } >+ >+ /** >+ * Returns <code>true</code> if there are unsaved changes for left side. >+ * >+ * @return <code>true</code> if there are changes that need to be saved >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ protected boolean isLeftSaveNeeded() { >+ return fLeftDirtyViewer != null; >+ } >+ >+ /** >+ * Returns <code>true</code> if there are unsaved changes for right side. >+ * >+ * @return <code>true</code> if there are changes that need to be saved >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ protected boolean isRightSaveNeeded() { >+ return fRightDirtyViewer != null; > } > > /** >@@ -1044,31 +1065,70 @@ > } > > /** >- * Sets the dirty state of this input to the given >- * value and sends out a <code>PropertyChangeEvent</code> if the new value differs from the old value. >- * >- * @param dirty the dirty state for this compare input >+ * Sets the dirty state of this input to the given value and sends out a >+ * <code>PropertyChangeEvent</code> if the new value differs from the old >+ * value. Direct calling this method with parameter dirty equal to >+ * <code>false</code> when there are unsaved changes in viewers, results in >+ * inconsistent state. The dirty state of compare input should be based only >+ * on the information if there are changes in viewers for left or right >+ * side. >+ * >+ * @param dirty >+ * the dirty state for this compare input > */ > public void setDirty(boolean dirty) { >- boolean oldDirty = fDirty || fDirtyViewers.size() > 0; >- fDirty= dirty; >- if (!fDirty) >- fDirtyViewers.clear(); >- if (oldDirty != dirty) >- Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty), Boolean.valueOf(dirty)); >+ boolean oldDirty = isSaveNeeded(); >+ boolean newDirty = dirty || isSaveNeeded(); >+ if (!newDirty) { >+ fLeftDirtyViewer = null; >+ fRightDirtyViewer = null; >+ } >+ if (oldDirty != isSaveNeeded()) { >+ Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty), Boolean.valueOf(isSaveNeeded())); >+ } > } > >+ /** >+ * Method adds or removes viewers that changed left or right side of this >+ * compare input. Any modification of any of the list of viewers may result >+ * in dirty state change. >+ * >+ * @param source >+ * the object that fired <code>PropertyChangeEvent</code> >+ * modifying the dirty state >+ * @param dirty >+ * value that describes if the changes were added or removed >+ */ > private void setDirty(Object source, boolean dirty) { > Assert.isNotNull(source); >- boolean oldDirty= fDirty || fDirtyViewers.size() > 0; >- if (dirty) >- fDirtyViewers.add(source); >- else >- fDirtyViewers.remove(source); >- boolean newDirty= fDirty || fDirtyViewers.size() > 0; >- if (DEBUG) System.out.println("setDirty("+source+", "+dirty+"): " + newDirty); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >- if (oldDirty != newDirty) >+ boolean oldDirty = isSaveNeeded(); >+ ContentMergeViewer cmv = (ContentMergeViewer) source; >+ if (dirty) { >+ if (cmv.internalIsLeftDirty()) { >+ if (fLeftDirtyViewer == null) { >+ fLeftDirtyViewer = cmv; >+ } >+ } >+ if (cmv.internalIsRightDirty()) { >+ if (fRightDirtyViewer == null) { >+ fRightDirtyViewer = cmv; >+ } >+ } >+ } else { >+ if (!cmv.internalIsLeftDirty()) { >+ fLeftDirtyViewer = null; >+ } >+ if (!cmv.internalIsRightDirty()) { >+ fRightDirtyViewer = null; >+ } >+ } >+ boolean newDirty = isSaveNeeded(); >+ if (DEBUG) { >+ System.out.println("setDirty(" + source + ", " + dirty + "): " + newDirty); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ >+ } >+ if (oldDirty != newDirty) { > Utilities.firePropertyChange(fListenerList, this, DIRTY_STATE, Boolean.valueOf(oldDirty), Boolean.valueOf(newDirty)); >+ } > } > > /* (non Javadoc) >@@ -1129,7 +1189,31 @@ > flushViewer(fStructurePane2, monitor); > flushViewer(fContentInputPane, monitor); > } >- >+ >+ /** >+ * @param monitor >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ protected void flushLeftViewers(IProgressMonitor monitor) { >+ // flush changes in left dirty viewer >+ flushViewer(fStructureInputPane, monitor); >+ flushViewer(fStructurePane1, monitor); >+ flushViewer(fStructurePane2, monitor); >+ flushLeftViewer(fContentInputPane, monitor); >+ } >+ >+ /** >+ * @param monitor >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ protected void flushRightViewers(IProgressMonitor monitor) { >+ // flush changes in right dirty viewer >+ flushViewer(fStructureInputPane, monitor); >+ flushViewer(fStructurePane1, monitor); >+ flushViewer(fStructurePane2, monitor); >+ flushRightViewer(fContentInputPane, monitor); >+ } >+ > private static void flushViewer(CompareViewerPane pane, IProgressMonitor pm) { > if (pane != null) { > IFlushable flushable = (IFlushable)Utilities.getAdapter(pane, IFlushable.class); >@@ -1138,6 +1222,22 @@ > } > } > >+ private static void flushLeftViewer(CompareViewerPane pane, IProgressMonitor pm) { >+ if (pane != null) { >+ IFlushable2 flushable = (IFlushable2)Utilities.getAdapter(pane, IFlushable2.class); >+ if (flushable != null) >+ flushable.flushLeft(pm); >+ } >+ } >+ >+ private static void flushRightViewer(CompareViewerPane pane, IProgressMonitor pm) { >+ if (pane != null) { >+ IFlushable2 flushable = (IFlushable2)Utilities.getAdapter(pane, IFlushable2.class); >+ if (flushable != null) >+ flushable.flushRight(pm); >+ } >+ } >+ > /* (non-Javadoc) > * @see org.eclipse.compare.ICompareContainer#addCompareInputChangeListener(org.eclipse.compare.structuremergeviewer.ICompareInput, org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener) > */ >Index: compare/org/eclipse/compare/CompareViewerSwitchingPane.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/CompareViewerSwitchingPane.java,v >retrieving revision 1.35 >diff -u -r1.35 CompareViewerSwitchingPane.java >--- compare/org/eclipse/compare/CompareViewerSwitchingPane.java 4 Mar 2010 16:26:05 -0000 1.35 >+++ compare/org/eclipse/compare/CompareViewerSwitchingPane.java 10 Aug 2010 10:07:32 -0000 >@@ -12,6 +12,7 @@ > > import org.eclipse.compare.contentmergeviewer.IFlushable; > import org.eclipse.compare.internal.CompareMessages; >+import org.eclipse.compare.internal.IFlushable2; > import org.eclipse.compare.internal.NullViewer; > import org.eclipse.compare.internal.Utilities; > import org.eclipse.compare.structuremergeviewer.ICompareInput; >@@ -354,6 +355,14 @@ > return flushable; > } > } >+ if (adapter == IFlushable2.class) { >+ Viewer v= getViewer(); >+ if (v != null) { >+ IFlushable2 flushable = (IFlushable2)Utilities.getAdapter(v, IFlushable2.class); >+ if (flushable != null) >+ return flushable; >+ } >+ } > return super.getAdapter(adapter); > } > >Index: compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java,v >retrieving revision 1.79 >diff -u -r1.79 ContentMergeViewer.java >--- compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java 28 Apr 2010 13:46:45 -0000 1.79 >+++ compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java 10 Aug 2010 10:07:34 -0000 >@@ -25,16 +25,14 @@ > import org.eclipse.compare.internal.CompareHandlerService; > import org.eclipse.compare.internal.CompareMessages; > import org.eclipse.compare.internal.ICompareUIConstants; >+import org.eclipse.compare.internal.IFlushable2; >+import org.eclipse.compare.internal.ISavingSaveable; > import org.eclipse.compare.internal.MergeViewerContentProvider; > import org.eclipse.compare.internal.Utilities; > import org.eclipse.compare.internal.ViewerSwitchingCancelled; > import org.eclipse.compare.structuremergeviewer.Differencer; > import org.eclipse.compare.structuremergeviewer.ICompareInput; > import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener; >-import org.eclipse.core.commands.ExecutionEvent; >-import org.eclipse.core.commands.ExecutionException; >-import org.eclipse.core.commands.IExecutionListener; >-import org.eclipse.core.commands.NotHandledException; > import org.eclipse.core.runtime.Assert; > import org.eclipse.core.runtime.CoreException; > import org.eclipse.core.runtime.IProgressMonitor; >@@ -71,9 +69,9 @@ > import org.eclipse.swt.widgets.Layout; > import org.eclipse.swt.widgets.Sash; > import org.eclipse.swt.widgets.Shell; >-import org.eclipse.ui.IWorkbenchCommandConstants; >-import org.eclipse.ui.PlatformUI; >-import org.eclipse.ui.commands.ICommandService; >+import org.eclipse.ui.ISaveablesSource; >+import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.Saveable; > > /** > * An abstract compare and merge viewer with two side-by-side content areas >@@ -102,7 +100,7 @@ > * @see TextMergeViewer > */ > public abstract class ContentMergeViewer extends ContentViewer >- implements IPropertyChangeNotifier, IFlushable { >+ implements IPropertyChangeNotifier, IFlushable, IFlushable2 { > > /* package */ static final int HORIZONTAL= 1; > /* package */ static final int VERTICAL= 2; >@@ -295,10 +293,6 @@ > private boolean fIsLeftDirty; > private boolean fIsRightDirty; > >- private boolean fIsSaving; >- private ICommandService fCommandService; >- private IExecutionListener fExecutionListener; >- > private CompareHandlerService fHandlerService; > > // SWT widgets >@@ -371,43 +365,8 @@ > > fIsLeftDirty = false; > fIsRightDirty = false; >- >- fIsSaving = false; >- fCommandService = (ICommandService)PlatformUI.getWorkbench().getAdapter(ICommandService.class); >- if (fCommandService != null) { >- fCommandService.addExecutionListener(getExecutionListener()); >- } > } > >- private IExecutionListener getExecutionListener() { >- if (fExecutionListener == null) { >- fExecutionListener = new IExecutionListener() { >- public void preExecute(String commandId, ExecutionEvent event) { >- if (IWorkbenchCommandConstants.FILE_SAVE.equals(commandId) >- || IWorkbenchCommandConstants.FILE_SAVE_ALL.equals(commandId)) >- fIsSaving = true; >- } >- >- public void postExecuteSuccess(String commandId, Object returnValue) { >- if (IWorkbenchCommandConstants.FILE_SAVE.equals(commandId) >- || IWorkbenchCommandConstants.FILE_SAVE_ALL.equals(commandId)) >- fIsSaving= false; >- } >- >- public void postExecuteFailure(String commandId, ExecutionException exception) { >- if (IWorkbenchCommandConstants.FILE_SAVE.equals(commandId) >- || IWorkbenchCommandConstants.FILE_SAVE_ALL.equals(commandId)) >- fIsSaving= false; >- } >- >- public void notHandled(String commandId, NotHandledException exception) { >- // not needed >- } >- }; >- } >- return fExecutionListener; >- } >- > //---- hooks --------------------- > > /** >@@ -1037,12 +996,6 @@ > fHVSashCursor= null; > } > >- if (fCommandService != null) { >- fCommandService.removeExecutionListener(fExecutionListener); >- fCommandService = null; >- fExecutionListener = null; >- } >- > super.handleDispose(event); > } > >@@ -1168,9 +1121,8 @@ > protected void setLeftDirty(boolean dirty) { > if (isLeftDirty() != dirty) { > fIsLeftDirty = dirty; >- // Only fire the event if the combined dirty state has changed >- if (!isRightDirty()) >- fireDirtyState(dirty); >+ // Always fire the event if the dirty state has changed >+ fireDirtyState(dirty); > } > } > >@@ -1186,9 +1138,8 @@ > protected void setRightDirty(boolean dirty) { > if (isRightDirty() != dirty) { > fIsRightDirty = dirty; >- // Only fire the event if the combined dirty state has changed >- if (!isLeftDirty()) >- fireDirtyState(dirty); >+ // Always fire the event if the dirty state has changed >+ fireDirtyState(dirty); > } > } > >@@ -1215,7 +1166,7 @@ > public final void flush(IProgressMonitor monitor) { > flushContent(getInput(), monitor); > } >- >+ > /** > * Flush the modified content back to input elements via the content provider. > * The provided input may be the current input of the viewer or it may be >@@ -1227,31 +1178,56 @@ > * @since 3.3 > */ > protected void flushContent(Object input, IProgressMonitor monitor) { >- >- // write back modified contents >- IMergeViewerContentProvider content= (IMergeViewerContentProvider) getContentProvider(); >- >- boolean leftEmpty= content.getLeftContent(input) == null; >- boolean rightEmpty= content.getRightContent(input) == null; >+ flushLeftSide(input, monitor); >+ flushRightSide(input, monitor); >+ } >+ >+ >+ void flushLeftSide(Object input, IProgressMonitor monitor) { >+ IMergeViewerContentProvider content = (IMergeViewerContentProvider) getContentProvider(); >+ >+ boolean rightEmpty = content.getRightContent(input) == null; > > if (getCompareConfiguration().isLeftEditable() && isLeftDirty()) { >- byte[] bytes= getContents(true); >+ byte[] bytes = getContents(true); > if (rightEmpty && bytes != null && bytes.length == 0) >- bytes= null; >+ bytes = null; > setLeftDirty(false); > content.saveLeftContent(input, bytes); > } >- >+ } >+ >+ void flushRightSide(Object input, IProgressMonitor monitor) { >+ IMergeViewerContentProvider content = (IMergeViewerContentProvider) getContentProvider(); >+ >+ boolean leftEmpty = content.getLeftContent(input) == null; >+ > if (getCompareConfiguration().isRightEditable() && isRightDirty()) { >- byte[] bytes= getContents(false); >+ byte[] bytes = getContents(false); > if (leftEmpty && bytes != null && bytes.length == 0) >- bytes= null; >+ bytes = null; > setRightDirty(false); > content.saveRightContent(input, bytes); > } > } > > /** >+ * @param monitor >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ public void flushLeft(IProgressMonitor monitor) { >+ flushLeftSide(getInput(), monitor); >+ } >+ >+ /** >+ * @param monitor >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ public void flushRight(IProgressMonitor monitor) { >+ flushRightSide(getInput(), monitor); >+ } >+ >+ /** > * Return the dirty state of the right side of this viewer. > * @return the dirty state of the right side of this viewer > * @since 3.3 >@@ -1261,6 +1237,15 @@ > } > > /** >+ * @return the dirty state of the right side of this viewer >+ * @since 3.7 >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ public boolean internalIsRightDirty() { >+ return isRightDirty(); >+ } >+ >+ /** > * Return the dirty state of the left side of this viewer. > * @return the dirty state of the left side of this viewer > * @since 3.3 >@@ -1270,6 +1255,15 @@ > } > > /** >+ * @return the dirty state of the left side of this viewer >+ * @since 3.7 >+ * @noreference This method is not intended to be referenced by clients. >+ */ >+ public boolean internalIsLeftDirty() { >+ return isLeftDirty(); >+ } >+ >+ /** > * Handle a change to the given input reported from an {@link org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener}. > * This class registers a listener with its input and reports any change events through > * this method. By default, this method prompts for any unsaved changes and then refreshes >@@ -1279,7 +1273,7 @@ > protected void handleCompareInputChange() { > // before setting the new input we have to save the old > Object input = getInput(); >- if (!fIsSaving && (isLeftDirty() || isRightDirty())) { >+ if (!isSaving() && (isLeftDirty() || isRightDirty())) { > > if (Utilities.RUNNING_TESTS) { > if (Utilities.TESTING_FLUSH_ON_COMPARE_INPUT_CHANGE) { >@@ -1310,11 +1304,39 @@ > break; > } > } >+ refresh(); > } >- refresh(); > } > > CompareHandlerService getCompareHandlerService() { > return fHandlerService; > } >+ >+ /** >+ * @return true if any of the Saveables is being saved >+ */ >+ private boolean isSaving() { >+ ICompareContainer container = fCompareConfiguration.getContainer(); >+ ISaveablesSource source = null; >+ if (container instanceof ISaveablesSource) { >+ source = (ISaveablesSource) container; >+ } else { >+ IWorkbenchPart part = container.getWorkbenchPart(); >+ if (part instanceof ISaveablesSource) { >+ source = (ISaveablesSource) part; >+ } >+ } >+ if (source != null) { >+ Saveable[] saveables = source.getSaveables(); >+ for (int i = 0; i < saveables.length; i++) { >+ if (saveables[i] instanceof ISavingSaveable) { >+ ISavingSaveable saveable = (ISavingSaveable) saveables[i]; >+ if (saveable.isSaving()) >+ return true; >+ } >+ } >+ } >+ return false; >+ } >+ > } >Index: compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java,v >retrieving revision 1.270 >diff -u -r1.270 TextMergeViewer.java >--- compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 22 Mar 2010 12:43:53 -0000 1.270 >+++ compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 10 Aug 2010 10:07:38 -0000 >@@ -4838,15 +4838,9 @@ > return fMerger.virtualToRealPosition(contributor, v); > } > >- /* (non-Javadoc) >- * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#flushContent(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) >- */ >- protected void flushContent(Object oldInput, IProgressMonitor monitor) { >- >- // check and handle any shared buffers >+ void flushLeftSide(Object oldInput, IProgressMonitor monitor){ > IMergeViewerContentProvider content= getMergeContentProvider(); > Object leftContent = content.getLeftContent(oldInput); >- Object rightContent = content.getRightContent(oldInput); > > if (leftContent != null && getCompareConfiguration().isLeftEditable() && isLeftDirty()) { > if (fLeftContributor.hasSharedDocument(leftContent)) { >@@ -4855,13 +4849,36 @@ > } > } > >+ if (!(content instanceof MergeViewerContentProvider) || isLeftDirty()) { >+ super.flushLeftSide(oldInput, monitor); >+ } >+ } >+ >+ void flushRightSide(Object oldInput, IProgressMonitor monitor){ >+ IMergeViewerContentProvider content= getMergeContentProvider(); >+ Object rightContent = content.getRightContent(oldInput); >+ > if (rightContent != null && getCompareConfiguration().isRightEditable() && isRightDirty()) { > if (fRightContributor.hasSharedDocument(rightContent)) { > if (flush(fRightContributor)) > setRightDirty(false); > } > } >- >+ >+ if (!(content instanceof MergeViewerContentProvider) || isRightDirty()) { >+ super.flushRightSide(oldInput, monitor); >+ } >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.compare.contentmergeviewer.ContentMergeViewer#flushContent(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ protected void flushContent(Object oldInput, IProgressMonitor monitor) { >+ flushLeftSide(oldInput, monitor); >+ flushRightSide(oldInput, monitor); >+ >+ IMergeViewerContentProvider content = getMergeContentProvider(); >+ > if (!(content instanceof MergeViewerContentProvider) || isLeftDirty() || isRightDirty()) { > super.flushContent(oldInput, monitor); > } >Index: compare/org/eclipse/compare/internal/IFlushable2.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/IFlushable2.java >diff -N compare/org/eclipse/compare/internal/IFlushable2.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/internal/IFlushable2.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,28 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.compare.internal; >+ >+import org.eclipse.compare.contentmergeviewer.IFlushable; >+import org.eclipse.core.runtime.IProgressMonitor; >+ >+/** >+ * Interface which provides the ability to flush the contents from the specified >+ * side of the viewer. >+ * >+ * @see IFlushable >+ * >+ * @since 3.7 >+ */ >+public interface IFlushable2 { >+ void flushLeft(IProgressMonitor monitor); >+ >+ void flushRight(IProgressMonitor monitor); >+} >Index: compare/org/eclipse/compare/internal/ISavingSaveable.java >=================================================================== >RCS file: compare/org/eclipse/compare/internal/ISavingSaveable.java >diff -N compare/org/eclipse/compare/internal/ISavingSaveable.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ compare/org/eclipse/compare/internal/ISavingSaveable.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,23 @@ >+/******************************************************************************* >+ * Copyright (c) 2010 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.compare.internal; >+ >+import org.eclipse.ui.Saveable; >+ >+/** >+ * Interface defines API for checking if an object, preferably an instance of >+ * {@link Saveable}, is being saved. >+ * >+ * @since 3.7 >+ */ >+public interface ISavingSaveable { >+ public boolean isSaving(); >+} >#P org.eclipse.compare.tests >Index: src/org/eclipse/compare/tests/ContentMergeViewerTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare.tests/src/org/eclipse/compare/tests/ContentMergeViewerTest.java,v >retrieving revision 1.1 >diff -u -r1.1 ContentMergeViewerTest.java >--- src/org/eclipse/compare/tests/ContentMergeViewerTest.java 16 Apr 2008 14:32:29 -0000 1.1 >+++ src/org/eclipse/compare/tests/ContentMergeViewerTest.java 10 Aug 2010 10:07:44 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2008 IBM Corporation and others. >+ * Copyright (c) 2008, 2010 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 >@@ -21,6 +21,9 @@ > public class ContentMergeViewerTest extends TestCase { > > private MyContentMergeViewer myContentMergeViewer; >+ /** >+ * result[0]-event occurred or not; result[1]-new state that was set >+ */ > boolean[] result = new boolean[] { false, false }; > > public ContentMergeViewerTest() { >@@ -109,7 +112,8 @@ > myContentMergeViewer.rightDirty = true; > myContentMergeViewer.setLeftDirty(true); > >- Assert.assertEquals(false, result[0]); >+ Assert.assertEquals(true, result[0]); >+ Assert.assertEquals(true, result[1]); > } > > public void testTFTX() { >@@ -160,7 +164,8 @@ > myContentMergeViewer.rightDirty = true; > myContentMergeViewer.setLeftDirty(false); > >- Assert.assertEquals(false, result[0]); >+ Assert.assertEquals(true, result[0]); >+ Assert.assertEquals(false, result[1]); > } > > // set right to true >@@ -187,7 +192,8 @@ > myContentMergeViewer.rightDirty = false; > myContentMergeViewer.setRightDirty(true); > >- Assert.assertEquals(false, result[0]); >+ Assert.assertEquals(true, result[0]); >+ Assert.assertEquals(true, result[1]); > } > > public void testTTXT() { >@@ -230,6 +236,7 @@ > myContentMergeViewer.rightDirty = true; > myContentMergeViewer.setRightDirty(false); > >- Assert.assertEquals(false, result[0]); >+ Assert.assertEquals(true, result[0]); >+ Assert.assertEquals(false, result[1]); > } > } >#P org.eclipse.team.ui >Index: src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java,v >retrieving revision 1.9 >diff -u -r1.9 LocalResourceSaveableComparison.java >--- src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java 12 Sep 2007 19:40:21 -0000 1.9 >+++ src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java 10 Aug 2010 10:07:48 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2006, 2007 IBM Corporation and others. >+ * Copyright (c) 2006, 2010 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,6 +11,7 @@ > package org.eclipse.team.internal.ui.synchronize; > > import org.eclipse.compare.*; >+import org.eclipse.compare.internal.ISavingSaveable; > import org.eclipse.compare.structuremergeviewer.ICompareInput; > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.*; >@@ -35,7 +36,7 @@ > * @see LocalResourceTypedElement > * @since 3.3 > */ >-public abstract class LocalResourceSaveableComparison extends SaveableComparison implements IPropertyChangeListener { >+public abstract class LocalResourceSaveableComparison extends SaveableComparison implements IPropertyChangeListener, ISavingSaveable { > > private final ICompareInput input; > private final CompareEditorInput editorInput; >@@ -130,10 +131,10 @@ > flushViewers(Policy.subMonitorFor(monitor, 40)); > // Then we tell the input to commit its changes > // Only the left is ever saveable >- ITypedElement left = getFileElement(); >- if (left instanceof LocalResourceTypedElement) { >- LocalResourceTypedElement te = (LocalResourceTypedElement) left; >- te.commit(Policy.subMonitorFor(monitor, 60)); >+ ITypedElement te = getFileElement(); >+ if (te instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) te; >+ lrte.commit(Policy.subMonitorFor(monitor, 60)); > } > } finally { > // Make sure we fire a change for the compare input to update the viewers >@@ -150,7 +151,11 @@ > * @throws CoreException > */ > protected void flushViewers(IProgressMonitor monitor) throws CoreException { >- editorInput.saveChanges(monitor); >+ if (editorInput instanceof SaveablesCompareEditorInput) { >+ ((SaveablesCompareEditorInput) editorInput).saveChanges(monitor, this); >+ } else { >+ editorInput.saveChanges(monitor); >+ } > } > > /** >@@ -206,6 +211,9 @@ > public boolean isDirty() { > // We need to get the dirty state from the compare editor input > // since it is our only connection to the merge viewer >+ if (editorInput instanceof SaveablesCompareEditorInput) { >+ return ((SaveablesCompareEditorInput) editorInput).isSaveNeeded(this); >+ } > return editorInput.isSaveNeeded(); > } > >@@ -232,6 +240,15 @@ > * @see org.eclipse.ui.Saveable#getName() > */ > public String getName() { >+ // Return the name of the file element as held in the compare input >+ if (fileElement.equals(input.getLeft())) { >+ return input.getLeft().getName(); >+ } >+ if (fileElement.equals(input.getRight())) { >+ return input.getRight().getName(); >+ } >+ // Fallback call returning name of the main non-null element of the input >+ // see org.eclipse.team.internal.ui.mapping.AbstractCompareInput#getMainElement() > return input.getName(); > } > >@@ -345,4 +362,8 @@ > } > return false; > } >+ >+ public boolean isSaving() { >+ return isSaving; >+ } > } >Index: src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java,v >retrieving revision 1.5 >diff -u -r1.5 SaveablesCompareEditorInput.java >--- src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java 20 Apr 2010 14:55:14 -0000 1.5 >+++ src/org/eclipse/team/internal/ui/synchronize/SaveablesCompareEditorInput.java 10 Aug 2010 10:07:48 -0000 >@@ -126,10 +126,9 @@ > closed = closeEditor(true); > } > if (!closed) { >- // The editor was closed either because the compare >- // input still has changes >- // or because the editor input is dirty. In either case, >- // fire the changes >+ // The editor was not closed either because the compare >+ // input still has changes or because the editor input >+ // is dirty. In either case, fire the changes > // to the registered listeners > propogateInputChange(); > } >@@ -360,6 +359,45 @@ > } > > /** >+ * Returns <code>true</code> if the given saveable contains any unsaved >+ * changes. If the saveable doesn't match either left nor right side of the >+ * current editor input {@link CompareEditorInput#isSaveNeeded()} is called. >+ * <p> >+ * This method is preferred to {@link CompareEditorInput#isSaveNeeded()}. >+ * >+ * @param the >+ * the saveable to check >+ * @return <code>true</code> if there are changes that need to be saved >+ * @since 3.7 >+ */ >+ boolean isSaveNeeded(Saveable saveable) { >+ if (saveable == null) { >+ return isSaveNeeded(); >+ } >+ if (saveable.equals(fLeftSaveable)) { >+ return isLeftSaveNeeded(); >+ } >+ if (saveable.equals(fRightSaveable)) { >+ return isRightSaveNeeded(); >+ } >+ // Fallback call returning true if there are unsaved changes in either >+ // left or right side >+ return isSaveNeeded(); >+ } >+ >+ void saveChanges(IProgressMonitor monitor, Saveable saveable) >+ throws CoreException { >+ if (saveable.equals(fLeftSaveable)) { >+ flushLeftViewers(monitor); >+ return; >+ } else if (saveable.equals(fRightSaveable)) { >+ flushRightViewers(monitor); >+ return; >+ } >+ Assert.isTrue(false, "invalid saveable parameter"); //$NON-NLS-1$ >+ } >+ >+ /** > * Close the editor if it is not dirty. If it is still dirty, let the > * content merge viewer handle the compare input change. > *
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 273450
:
161445
|
161585
|
168134
|
168536
|
168537
|
168897
| 176219