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 56473 Details for
Bug 167607
[EditorMgmt] Closing compare editor asks to save editor - Saveable should implement IAdaptable
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]
Updated patch
patch167607.txt (text/plain), 8.73 KB, created by
Michael Valenta
on 2007-01-05 13:11:56 EST
(
hide
)
Description:
Updated patch
Filename:
MIME Type:
Creator:
Michael Valenta
Created:
2007-01-05 13:11:56 EST
Size:
8.73 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.team.ui >Index: src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.team.ui/src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java,v >retrieving revision 1.5 >diff -u -r1.5 SaveableCompareEditorInput.java >--- src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java 22 Dec 2006 17:23:35 -0000 1.5 >+++ src/org/eclipse/team/ui/synchronize/SaveableCompareEditorInput.java 5 Jan 2007 18:04:28 -0000 >@@ -83,8 +83,8 @@ > > private class InternalResourceSaveableComparison extends LocalResourceSaveableComparison { > public InternalResourceSaveableComparison( >- ICompareInput input, CompareEditorInput editorInput) { >- super(input, editorInput, SaveableCompareEditorInput.getFileElement(input, editorInput)); >+ ICompareInput input, CompareEditorInput editorInput, boolean connected) { >+ super(input, editorInput, SaveableCompareEditorInput.getFileElement(input, editorInput), connected); > } > > protected void fireInputChange() { >@@ -127,6 +127,28 @@ > } > }; > getCompareInput().addCompareInputChangeListener(compareInputChangeListener); >+ >+ if (getSaveable() instanceof LocalResourceSaveableComparison) { >+ LocalResourceSaveableComparison lrsc = (LocalResourceSaveableComparison) saveable; >+ if (lrsc.isConnectedToSharedDocument()) { >+ ICompareContainer container = getContainer(); >+ IWorkbenchPart part = container.getWorkbenchPart(); >+ if (part != null) { >+ ISaveablesLifecycleListener lifecycleListener= (ISaveablesLifecycleListener) part.getSite().getService(ISaveablesLifecycleListener.class); >+ lifecycleListener.handleLifecycleEvent( >+ new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_CLOSE, getSaveables(), false)); >+ if (saveable instanceof LocalResourceSaveableComparison) { >+ LocalResourceSaveableComparison rsc = (LocalResourceSaveableComparison) saveable; >+ rsc.dispose(); >+ } >+ saveable = createConnectedSaveable(); >+ lifecycleListener.handleLifecycleEvent( >+ new SaveablesLifecycleEvent(part, SaveablesLifecycleEvent.POST_OPEN, getSaveables(), false)); >+ >+ } >+ } >+ } >+ > if (getSaveable() instanceof SaveableComparison) { > SaveableComparison scm = (SaveableComparison) saveable; > propertyListener = new IPropertyListener() { >@@ -272,7 +294,11 @@ > protected Saveable createSaveable() { > Object compareResult = getCompareResult(); > Assert.isNotNull(compareResult, "This method cannot be called until after prepareInput is called"); //$NON-NLS-1$ >- return new InternalResourceSaveableComparison((ICompareInput)compareResult, this); >+ return new InternalResourceSaveableComparison((ICompareInput)compareResult, this, false); >+ } >+ >+ private Saveable createConnectedSaveable() { >+ return new InternalResourceSaveableComparison((ICompareInput)getCompareResult(), this, true); > } > > /* (non-Javadoc) >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.5 >diff -u -r1.5 LocalResourceSaveableComparison.java >--- src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java 3 Jan 2007 21:52:25 -0000 1.5 >+++ src/org/eclipse/team/internal/ui/synchronize/LocalResourceSaveableComparison.java 5 Jan 2007 18:04:28 -0000 >@@ -13,15 +13,21 @@ > import org.eclipse.compare.*; > import org.eclipse.compare.internal.Utilities; > import org.eclipse.compare.structuremergeviewer.ICompareInput; >+import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.*; > import org.eclipse.jface.dialogs.IDialogConstants; > import org.eclipse.jface.dialogs.MessageDialog; > import org.eclipse.jface.resource.ImageDescriptor; >+import org.eclipse.jface.text.IDocument; > import org.eclipse.jface.util.IPropertyChangeListener; > import org.eclipse.jface.util.PropertyChangeEvent; > import org.eclipse.swt.graphics.Image; > import org.eclipse.team.internal.ui.*; > import org.eclipse.team.ui.mapping.SaveableComparison; >+import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.Saveable; >+import org.eclipse.ui.part.FileEditorInput; >+import org.eclipse.ui.texteditor.IDocumentProvider; > > /** > * A saveable that wraps a compare input in which the left side is a {@link LocalResourceTypedElement} >@@ -37,6 +43,7 @@ > private boolean isSaving; > private IContentChangeListener contentChangeListener; > private ITypedElement fileElement; >+ private IDocument document; > > /** > * Create the resource-based saveable comparison. >@@ -44,7 +51,7 @@ > * @param editorInput the editor input containing the comparison > */ > public LocalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput) { >- this(input, editorInput, input.getLeft()); >+ this(input, editorInput, input.getLeft(), false); > } > > /** >@@ -52,14 +59,25 @@ > * @param input the compare input to be save > * @param editorInput the editor input containing the comparison > * @param fileElement the file element that handles the saving and change notification >+ * @param connected > */ >- public LocalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput, ITypedElement fileElement) { >+ public LocalResourceSaveableComparison(ICompareInput input, CompareEditorInput editorInput, ITypedElement fileElement, boolean connected) { > this.input = input; > this.editorInput = editorInput; > this.fileElement = fileElement; > initializeContentChangeListeners(); >+ if (connected) { >+ initializeHashing(); >+ } > } > >+ private void initializeHashing() { >+ Object document= getAdapter(IDocument.class); >+ if (document != null) { >+ this.document = (IDocument)document; >+ } >+ } >+ > private void initializeContentChangeListeners() { > // We need to listen to saves to the input to catch the case > // where Save was picked from the context menu >@@ -252,23 +270,69 @@ > setDirty(changed); > } > } >+ >+ /* >+ * @see org.eclipse.ui.Saveable#hashCode() >+ */ >+ public int hashCode() { >+ if (document != null) { >+ return document.hashCode(); >+ } >+ return input.hashCode(); >+ } > >- /* (non-Javadoc) >+ /* > * @see org.eclipse.ui.Saveable#equals(java.lang.Object) > */ >- public boolean equals(Object object) { >- if (object instanceof LocalResourceSaveableComparison) { >- LocalResourceSaveableComparison rscm = (LocalResourceSaveableComparison) object; >+ public boolean equals(Object obj) { >+ if (this == obj) >+ return true; >+ >+ if (!(obj instanceof Saveable)) >+ return false; >+ >+ if (document != null) { >+ Object otherDocument= ((Saveable)obj).getAdapter(IDocument.class); >+ >+ if (document == null && otherDocument == null) >+ return false; >+ >+ return document != null && document.equals(otherDocument); >+ } >+ >+ if (obj instanceof LocalResourceSaveableComparison) { >+ LocalResourceSaveableComparison rscm = (LocalResourceSaveableComparison) obj; > return rscm.input.equals(input); > } > return false; > } >- >- /* (non-Javadoc) >- * @see org.eclipse.ui.Saveable#hashCode() >- */ >- public int hashCode() { >- return input.hashCode(); >+ >+ public Object getAdapter(Class adapter) { >+ if (adapter == IDocument.class) { >+ if (document != null) >+ return document; >+ if (fileElement instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) fileElement; >+ if (lrte.isConnected()) { >+ ISharedDocumentAdapter sda = (ISharedDocumentAdapter)Utils.getAdapter(lrte, ISharedDocumentAdapter.class); >+ if (sda != null) { >+ IEditorInput input = sda.getDocumentKey(lrte); >+ if (input != null) { >+ IDocumentProvider provider = SharedDocumentAdapter.getDocumentProvider(input); >+ if (provider != null) >+ return provider.getDocument(input); >+ } >+ } >+ } >+ } >+ } >+ if (adapter == IEditorInput.class) { >+ if (fileElement instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) fileElement; >+ return new FileEditorInput((IFile)lrte.getResource()); >+ } >+ } >+ return super.getAdapter(adapter); > } > > /** >@@ -278,4 +342,12 @@ > public ICompareInput getInput() { > return input; > } >+ >+ public boolean isConnectedToSharedDocument() { >+ if (fileElement instanceof LocalResourceTypedElement) { >+ LocalResourceTypedElement lrte = (LocalResourceTypedElement) fileElement; >+ return lrte.isConnected(); >+ } >+ return false; >+ } > }
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 167607
:
56409
| 56473