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 34039 Details for
Bug 126230
CompareEditor and ISaveableModelSource
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch to add saveable model support to compare editor
patch126230.txt (text/plain), 4.64 KB, created by
Michael Valenta
on 2006-02-02 13:48:12 EST
(
hide
)
Description:
Patch to add saveable model support to compare editor
Filename:
MIME Type:
Creator:
Michael Valenta
Created:
2006-02-02 13:48:12 EST
Size:
4.64 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/CompareEditor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareEditor.java,v >retrieving revision 1.29 >diff -u -r1.29 CompareEditor.java >--- compare/org/eclipse/compare/internal/CompareEditor.java 14 Nov 2005 20:30:16 -0000 1.29 >+++ compare/org/eclipse/compare/internal/CompareEditor.java 2 Feb 2006 18:49:01 -0000 >@@ -17,6 +17,7 @@ > > import org.eclipse.jface.dialogs.ErrorDialog; > import org.eclipse.jface.dialogs.MessageDialog; >+import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.util.*; > import org.eclipse.jface.util.Assert; > >@@ -35,7 +36,7 @@ > * A CompareEditor takes a ICompareEditorInput as input. > * Most functionality is delegated to the ICompareEditorInput. > */ >-public class CompareEditor extends EditorPart implements IReusableEditor { >+public class CompareEditor extends EditorPart implements IReusableEditor, ISaveableModelSource, ISaveableModel { > > /** > * Internal property change listener for handling changes in the editor's input. >@@ -257,6 +258,15 @@ > */ > public boolean isDirty() { > IEditorInput input= getEditorInput(); >+ if (input instanceof ISaveableModelSource) { >+ ISaveableModelSource sms = (ISaveableModelSource) input; >+ ISaveableModel[] models = sms.getModels(); >+ for (int i = 0; i < models.length; i++) { >+ ISaveableModel model = models[i]; >+ if (model.isDirty()) >+ return true; >+ } >+ } > if (input instanceof CompareEditorInput) > return ((CompareEditorInput)input).isSaveNeeded(); > return false; >@@ -268,5 +278,50 @@ > if (old_value == null || new_value == null || !old_value.equals(new_value)) > firePropertyChange(PROP_DIRTY); > } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISaveableModelSource#getModels() >+ */ >+ public ISaveableModel[] getModels() { >+ IEditorInput input= getEditorInput(); >+ if (input instanceof ISaveableModelSource) { >+ ISaveableModelSource source = (ISaveableModelSource) input; >+ return source.getModels(); >+ } >+ return new ISaveableModel[] { this }; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISaveableModelSource#getActiveModels() >+ */ >+ public ISaveableModel[] getActiveModels() { >+ IEditorInput input= getEditorInput(); >+ if (input instanceof ISaveableModelSource) { >+ ISaveableModelSource source = (ISaveableModelSource) input; >+ return source.getActiveModels(); >+ } >+ return new ISaveableModel[] { this }; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISaveableModel#getName() >+ */ >+ public String getName() { >+ return getPartName(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISaveableModel#getToolTipText() >+ */ >+ public String getToolTipText() { >+ return getTitleToolTip(); >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.ISaveableModel#getImageDescriptor() >+ */ >+ public ImageDescriptor getImageDescriptor() { >+ return ImageDescriptor.createFromImage(getTitleImage()); >+ } > } > >Index: compare/org/eclipse/compare/CompareEditorInput.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/compare/org/eclipse/compare/CompareEditorInput.java,v >retrieving revision 1.56 >diff -u -r1.56 CompareEditorInput.java >--- compare/org/eclipse/compare/CompareEditorInput.java 11 Jan 2006 10:47:53 -0000 1.56 >+++ compare/org/eclipse/compare/CompareEditorInput.java 2 Feb 2006 18:49:01 -0000 >@@ -23,8 +23,7 @@ > > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.*; >-import org.eclipse.ui.IPersistableElement; >-import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.*; > > import org.eclipse.jface.util.*; > import org.eclipse.jface.util.Assert; >@@ -88,6 +87,12 @@ > * by passing a subclass of <code>CompareConfiguration</code> and by implementing the <code>prepareInput</code> method. > * If a subclass cannot use the <code>DiffTreeViewer</code> which is installed by default in the > * top left pane, method <code>createDiffViewer</code> can be overridden. >+ * <p> >+ * If subclasses of this class implement {@link ISaveableModelSource}, the compare editor will >+ * pass these models through to the workbench. The editor will still show the dirty indicator >+ * if one of these underlying models is dirty. It is the reponsibility of subclasses that >+ * implement this interface to call {@link #setDirty(boolean)} when the dirty state of >+ * any of the models managed by the sublcass change dirty state. > * > * @see CompareUI > * @see CompareEditorInput
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 126230
: 34039