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 121932 Details for
Bug 223857
[Viewers] Should be able to set the encoding of text pane in compare editor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
Patch_v05
223857_v05.txt (text/plain), 14.68 KB, created by
Pawel Pogorzelski
on 2009-01-08 05:52:26 EST
(
hide
)
Description:
Patch_v05
Filename:
MIME Type:
Creator:
Pawel Pogorzelski
Created:
2009-01-08 05:52:26 EST
Size:
14.68 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.compare >Index: compare/org/eclipse/compare/internal/MergeSourceViewer.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/MergeSourceViewer.java,v >retrieving revision 1.47 >diff -u -r1.47 MergeSourceViewer.java >--- compare/org/eclipse/compare/internal/MergeSourceViewer.java 7 Jan 2009 10:14:11 -0000 1.47 >+++ compare/org/eclipse/compare/internal/MergeSourceViewer.java 8 Jan 2009 10:49:04 -0000 >@@ -105,6 +105,7 @@ > public static final String SAVE_ID= "save"; //$NON-NLS-1$ > public static final String FIND_ID= "find"; //$NON-NLS-1$ > public static final String GOTO_LINE_ID= "gotoLine"; //$NON-NLS-1$ >+ public static final String CHANGE_ENCODING_ID= "changeEncoding"; //$NON-NLS-1$ > > class TextOperationAction extends MergeViewerAction { > >@@ -799,6 +800,7 @@ > addMenu(menu, SELECT_ALL_ID); > > menu.add(new Separator("edit")); //$NON-NLS-1$ >+ addMenu(menu, CHANGE_ENCODING_ID); > menu.add(new Separator("find")); //$NON-NLS-1$ > addMenu(menu, FIND_ID); > >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.239 >diff -u -r1.239 TextMergeViewer.java >--- compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 7 Jan 2009 10:14:11 -0000 1.239 >+++ compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java 8 Jan 2009 10:49:04 -0000 >@@ -74,6 +74,7 @@ > import org.eclipse.jface.action.Action; > import org.eclipse.jface.action.ActionContributionItem; > import org.eclipse.jface.action.IAction; >+import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.action.Separator; > import org.eclipse.jface.action.ToolBarManager; > import org.eclipse.jface.dialogs.ErrorDialog; >@@ -139,6 +140,7 @@ > import org.eclipse.swt.graphics.Cursor; > import org.eclipse.swt.graphics.Font; > import org.eclipse.swt.graphics.GC; >+import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.RGB; > import org.eclipse.swt.graphics.Rectangle; >@@ -152,14 +154,24 @@ > import org.eclipse.swt.widgets.ScrollBar; > import org.eclipse.swt.widgets.Shell; > import org.eclipse.ui.IEditorInput; >+import org.eclipse.ui.IEditorSite; >+import org.eclipse.ui.IKeyBindingService; >+import org.eclipse.ui.IPropertyListener; >+import org.eclipse.ui.IWorkbenchPage; > import org.eclipse.ui.IWorkbenchPart; >+import org.eclipse.ui.IWorkbenchPartSite; >+import org.eclipse.ui.IWorkbenchWindow; >+import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.actions.ActionFactory; > import org.eclipse.ui.contexts.IContextService; > import org.eclipse.ui.editors.text.EditorsUI; >+import org.eclipse.ui.editors.text.IEncodingSupport; >+import org.eclipse.ui.editors.text.IStorageDocumentProvider; > import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants; > import org.eclipse.ui.texteditor.AbstractTextEditor; > import org.eclipse.ui.texteditor.ChainedPreferenceStore; >+import org.eclipse.ui.texteditor.ChangeEncodingAction; > import org.eclipse.ui.texteditor.FindReplaceAction; > import org.eclipse.ui.texteditor.GotoLineAction; > import org.eclipse.ui.texteditor.IDocumentProvider; >@@ -497,7 +509,7 @@ > } > } > >- class ContributorInfo implements IElementStateListener, VerifyListener, IDocumentListener { >+ class ContributorInfo implements IElementStateListener, VerifyListener, IDocumentListener, IEncodingSupport { > private final TextMergeViewer fViewer; > private final Object fElement; > private char fLeg; >@@ -521,11 +533,66 @@ > } > } > } >- >+ >+ public void resetDocumentProvider() { >+ if (fDocumentProvider == null || fDocumentKey == null) { >+ return; >+ } >+ try { >+ fDocumentProvider.resetDocument(fDocumentKey); >+ } catch (CoreException e) { >+ // TODO: >+ e.printStackTrace(); >+ } >+ } >+ >+ public void setEncoding(String encoding) { >+ if (fDocumentKey == null || fDocumentProvider == null) { >+ return; >+ } >+ if (fDocumentProvider instanceof IStorageDocumentProvider) { >+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider; >+ String current = provider.getEncoding(fDocumentKey); >+ boolean dirty = fDocumentProvider.canSaveDocument(fDocumentKey); >+ if (!dirty) { >+ String internal = encoding == null ? "" : encoding; //$NON-NLS-1$ >+ if (!internal.equals(current)) { >+ provider.setEncoding(fDocumentKey, encoding); >+ try { >+ fDocumentProvider.resetDocument(fDocumentKey); >+ } catch (CoreException e) { >+ CompareUIPlugin.log(e); >+ } finally { >+ update(true); >+ } >+ } >+ } >+ } >+ } >+ > public String getEncoding() { >- if (fEncoding == null) >- return ResourcesPlugin.getEncoding(); >- return fEncoding; >+ if (fDocumentProvider != null && fDocumentKey != null >+ && fDocumentProvider instanceof IStorageDocumentProvider) { >+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider; >+ return provider.getEncoding(fDocumentKey); >+ } >+ return null; >+ } >+ >+ public String getDefaultEncoding() { >+ if (fDocumentProvider != null && fDocumentKey != null >+ && fDocumentProvider instanceof IStorageDocumentProvider) { >+ IStorageDocumentProvider provider = (IStorageDocumentProvider) fDocumentProvider; >+ return provider.getDefaultEncoding(); >+ } >+ return null; >+ } >+ >+ public String getInternalEncoding() { >+ if (fEncoding != null) { >+ return fEncoding; >+ } >+ return ResourcesPlugin.getEncoding(); > } > > public void setEncodingIfAbsent(ContributorInfo otherContributor) { >@@ -716,7 +783,7 @@ > String s= null; > > try { >- String encoding = getEncoding(); >+ String encoding = getInternalEncoding(); > s = Utilities.readString(sca, encoding); > } catch (CoreException ex) { > this.fViewer.setError(fLeg, ex.getMessage()); >@@ -836,7 +903,7 @@ > * </ol> > * @return the document key used to obtain a shared document or <code>null</code> > */ >- private IEditorInput getDocumentKey() { >+ public IEditorInput getDocumentKey() { > if (fDocumentKey != null) > return fDocumentKey; > if (isUsingDefaultContentProvider() && fElement != null && canHaveSharedDocument()) { >@@ -979,6 +1046,7 @@ > if (oldContributor != null) { > fSelection = oldContributor.fSelection; > fTopIndex = oldContributor.fTopIndex; >+ fEncoding = oldContributor.fEncoding; > } > > } >@@ -2391,6 +2459,8 @@ > > contributeGotoLineAction(viewer); > >+ contributeChangeEncodingAction(viewer); >+ > getSourceViewerDecorationSupport(viewer.getSourceViewer()).install(fPreferenceStore); > > return viewer; >@@ -2430,6 +2500,262 @@ > viewer.addAction(MergeSourceViewer.GOTO_LINE_ID, action); > } > >+ private void contributeChangeEncodingAction(MergeSourceViewer viewer) { >+ ResourceBundle bundle = ResourceBundle.getBundle("org.eclipse.ui.texteditor.ConstructedTextEditorMessages"); //$NON-NLS-1$ >+ IAction action = new ChangeEncodingAction(bundle, "Editor.ChangeEncodingAction.", getTextEditorAdapter()); //$NON-NLS-1$ >+ viewer.addAction(MergeSourceViewer.CHANGE_ENCODING_ID, action); >+ } >+ >+ private ITextEditor getTextEditorAdapter() { >+ return new ITextEditor () { >+ public void close(boolean save) { >+ // Implementing interface method >+ } >+ >+ public void doRevertToSaved() { >+ // Implementing interface method >+ } >+ >+ public IAction getAction(String actionId) { >+ // Implementing interface method >+ return null; >+ } >+ >+ public IDocumentProvider getDocumentProvider() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public IRegion getHighlightRange() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public ISelectionProvider getSelectionProvider() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public boolean isEditable() { >+ // Implementing interface method >+ return false; >+ } >+ >+ public void removeActionActivationCode(String actionId) { >+ // Implementing interface method >+ } >+ >+ public void resetHighlightRange() { >+ // Implementing interface method >+ } >+ >+ public void selectAndReveal(int offset, int length) { >+ // Implementing interface method >+ } >+ >+ public void setAction(String actionId, IAction action) { >+ // Implementing interface method >+ } >+ >+ public void setActionActivationCode(String actionId, >+ char activationCharacter, int activationKeyCode, >+ int activationStateMask) { >+ // Implementing interface method >+ } >+ >+ public void setHighlightRange(int offset, int length, >+ boolean moveCursor) { >+ // Implementing interface method >+ } >+ >+ public void showHighlightRangeOnly(boolean showHighlightRangeOnly) { >+ // Implementing interface method >+ } >+ >+ public boolean showsHighlightRangeOnly() { >+ // Implementing interface method >+ return false; >+ } >+ >+ public IEditorInput getEditorInput() { >+ if (fFocusPart == fAncestor && fAncestorContributor != null) { >+ return fAncestorContributor.getDocumentKey(); >+ } else if (fFocusPart == fLeft && fLeftContributor != null) { >+ return fLeftContributor.getDocumentKey(); >+ } else if (fFocusPart == fRight && fRightContributor != null) { >+ return fRightContributor.getDocumentKey(); >+ } else { >+ return null; >+ } >+ } >+ >+ public IEditorSite getEditorSite() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public void init(IEditorSite site, IEditorInput input) >+ throws PartInitException { >+ // Implementing interface method >+ } >+ >+ public void addPropertyListener(IPropertyListener listener) { >+ // Implementing interface method >+ } >+ >+ public void createPartControl(Composite parent) { >+ // Implementing interface method >+ } >+ >+ public void dispose() { >+ // Implementing interface method >+ } >+ >+ public IWorkbenchPartSite getSite() { >+ // Implementing interface method >+ return new IWorkbenchPartSite() { >+ >+ public String getId() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public IKeyBindingService getKeyBindingService() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public IWorkbenchPart getPart() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public String getPluginId() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public String getRegisteredName() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public void registerContextMenu(MenuManager menuManager, >+ ISelectionProvider selectionProvider) { >+ // Implementing interface method >+ } >+ >+ public void registerContextMenu(String menuId, >+ MenuManager menuManager, >+ ISelectionProvider selectionProvider) { >+ // Implementing interface method >+ } >+ >+ public IWorkbenchPage getPage() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public ISelectionProvider getSelectionProvider() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public Shell getShell() { >+ return fComposite.getShell(); >+ } >+ >+ public IWorkbenchWindow getWorkbenchWindow() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public void setSelectionProvider(ISelectionProvider provider) { >+ // Implementing interface method >+ } >+ >+ public Object getAdapter(Class adapter) { >+ // Implementing interface method >+ return null; >+ } >+ >+ public Object getService(Class api) { >+ // Implementing interface method >+ return null; >+ } >+ >+ public boolean hasService(Class api) { >+ // Implementing interface method >+ return false; >+ } >+ >+ }; >+ } >+ >+ public String getTitle() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public Image getTitleImage() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public String getTitleToolTip() { >+ // Implementing interface method >+ return null; >+ } >+ >+ public void removePropertyListener(IPropertyListener listener) { >+ // Implementing interface method >+ } >+ >+ public void setFocus() { >+ // Implementing interface method >+ } >+ >+ public Object getAdapter(Class adapter) { >+ if (adapter == IEncodingSupport.class) { >+ if (fFocusPart == fAncestor) { >+ return fAncestorContributor; >+ } else if (fFocusPart == fLeft) { >+ return fLeftContributor; >+ } else if (fFocusPart == fRight) { >+ return fRightContributor; >+ } else { >+ return null; >+ } >+ } >+ return null; >+ } >+ >+ public void doSave(IProgressMonitor monitor) { >+ // Implementing interface method >+ } >+ >+ public void doSaveAs() { >+ // Implementing interface method >+ } >+ >+ public boolean isDirty() { >+ // Implementing interface method >+ return false; >+ } >+ >+ public boolean isSaveAsAllowed() { >+ // Implementing interface method >+ return false; >+ } >+ >+ public boolean isSaveOnCloseNeeded() { >+ // Implementing interface method >+ return false; >+ } >+ >+ }; >+ } >+ > private void connectGlobalActions(final MergeSourceViewer part) { > if (fHandlerService != null) { > if (part != null) >@@ -2938,7 +3264,7 @@ > if (contents != null) { > byte[] bytes; > try { >- bytes= contents.getBytes(left ? fLeftContributor.getEncoding() : fRightContributor.getEncoding()); >+ bytes= contents.getBytes(left ? fLeftContributor.getInternalEncoding() : fRightContributor.getInternalEncoding()); > } catch(UnsupportedEncodingException ex) { > // use default encoding > bytes= contents.getBytes(); >@@ -4898,4 +5224,21 @@ > return true; > return false; > } >+ >+ protected void setLeftDirty(boolean dirty) { >+ super.setLeftDirty(dirty); >+ IAction action = fLeft.getAction(MergeSourceViewer.CHANGE_ENCODING_ID); >+ if (action != null) { >+ action.setEnabled(!dirty); >+ } >+ } >+ >+ protected void setRightDirty(boolean dirty) { >+ super.setRightDirty(dirty); >+ IAction action = fRight.getAction(MergeSourceViewer.CHANGE_ENCODING_ID); >+ if (action != null) { >+ action.setEnabled(!dirty); >+ } >+ } >+ > }
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
Flags:
pawel.pogorzelski1
:
iplog+
Actions:
View
|
Diff
Attachments on
bug 223857
:
121626
|
121790
|
121791
|
121805
|
121826
|
121932
|
122084
|
122256
|
122258
|
122528
|
122667
|
122671