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 214210 Details for
Bug 377129
Backport to 3.2.x RSE does not respect editor overrides
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]
backport patch
patch.txt (text/plain), 12.07 KB, created by
David McKnight
on 2012-04-18 18:33:20 EDT
(
hide
)
Description:
backport patch
Filename:
MIME Type:
Creator:
David McKnight
Created:
2012-04-18 18:33:20 EDT
Size:
12.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.rse.files.ui >Index: src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java,v >retrieving revision 1.70.2.4 >diff -u -r1.70.2.4 SystemEditableRemoteFile.java >--- src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java 16 Jan 2012 15:59:55 -0000 1.70.2.4 >+++ src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java 18 Apr 2012 22:33:06 -0000 >@@ -43,6 +43,7 @@ > * David McKnight (IBM) - [334839] File Content Conflict is not handled properly > * David McKnight (IBM) - [359704] SystemEditableRemoteFile does not release reference to editor > * David McKnight (IBM) - [249031] Last used editor should be set to SystemEditableRemoteFile >+ * Rick Sawyer (IBM) - [376535] RSE does not respect editor overrides > *******************************************************************************/ > > package org.eclipse.rse.files.ui.resources; >@@ -131,6 +132,7 @@ > private IEditorPart editor; > private IFile localFile; > private IWorkbenchPage page; >+ private boolean _usingDefaultDescriptor = false; > > /** > * Internal class for downloading file >@@ -275,6 +277,10 @@ > IEditorDescriptor descriptor = null; > try { > descriptor = IDE.getEditorDescriptor(localResource); >+ >+ if (!localResource.exists()){ >+ _usingDefaultDescriptor = true; >+ } > } catch (PartInitException e) { > } > >@@ -1645,8 +1651,15 @@ > > // set editor as preferred editor for this file > String editorId = null; >- if (_editorDescriptor != null) >- editorId = _editorDescriptor.getId(); >+ if (_editorDescriptor != null){ >+ if (_usingDefaultDescriptor){ >+ _editorDescriptor = IDE.getEditorDescriptor(file); >+ editorId = _editorDescriptor.getId(); >+ } >+ else { >+ editorId = _editorDescriptor.getId(); >+ } >+ } > > IDE.setDefaultEditor(file, editorId); > >@@ -1763,13 +1776,11 @@ > { > if (editor == part){ > //delete(); >- >+ > SystemUniversalTempFileListener.getListener().unregisterEditedFile(this); > >- IWorkbenchPage page = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage(); >- >- if (page != null) >- { >+ IWorkbenchPage page = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage(); >+ if (page != null){ > page.removePartListener(this); > editor = null; > } >@@ -2020,7 +2031,7 @@ > } > } > } >- } >+ } > } > > >Index: src/org/eclipse/rse/internal/files/ui/actions/SystemRemoteFileOpenWithMenu.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions/SystemRemoteFileOpenWithMenu.java,v >retrieving revision 1.16 >diff -u -r1.16 SystemRemoteFileOpenWithMenu.java >--- src/org/eclipse/rse/internal/files/ui/actions/SystemRemoteFileOpenWithMenu.java 11 May 2010 18:44:15 -0000 1.16 >+++ src/org/eclipse/rse/internal/files/ui/actions/SystemRemoteFileOpenWithMenu.java 18 Apr 2012 22:33:06 -0000 >@@ -20,8 +20,10 @@ > * David McKnight (IBM) - [284596] [regression] Open with-> problem when descriptor doesn't match previous > * David McKnight (IBM) - [309755] SystemRemoteFileOpenWithMenu.getPreferredEditor(), the listed default editor is not always correct > * David McKnight (IBM) - [312362] Editing Unix file after it changes on host edits old data >+ * Rick Sawyer (IBM) - [376535] RSE does not respect editor overrides > *******************************************************************************/ > package org.eclipse.rse.internal.files.ui.actions; >+import java.lang.reflect.Method; > import java.text.Collator; > import java.util.ArrayList; > import java.util.Arrays; >@@ -32,6 +34,7 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.resources.ResourceAttributes; > import org.eclipse.core.runtime.NullProgressMonitor; >+import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.jface.action.ContributionItem; > import org.eclipse.jface.resource.ImageDescriptor; > import org.eclipse.jface.viewers.IStructuredSelection; >@@ -56,6 +59,7 @@ > import org.eclipse.swt.widgets.Menu; > import org.eclipse.swt.widgets.MenuItem; > import org.eclipse.ui.IEditorDescriptor; >+import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IEditorRegistry; > import org.eclipse.ui.IWorkbench; >@@ -408,7 +412,22 @@ > IFile localFile = getLocalResource(remoteFile); > > if (localFile == null || !localFile.exists()){ >- return registry.getDefaultEditor(remoteFile.getName()); >+ // bug #376535 - need to respect editor overrides >+ IEditorDescriptor desc = registry.getDefaultEditor(remoteFile.getName(), IDE.guessContentType(localFile)); >+ // Using reflection in case IDE is older version, without this method >+ //desc = IDE.overrideDefaultEditorAssociation(new FileEditorInput(localFile), IDE.guessContentType(localFile), desc); >+ Class clazz = IDE.class; >+ try { >+ Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor.class}; >+ Method method = clazz.getMethod("overrideDefaultEditorAssociation", parmtypes); //$NON-NLS-1$ >+ if (method != null) { >+ Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), desc}; >+ desc = (IEditorDescriptor) method.invoke(null, args); >+ } >+ } catch (Exception e) { >+ } >+ >+ return desc; > } > else { > return IDE.getDefaultEditor(localFile); >@@ -470,7 +489,23 @@ > IEditorDescriptor defaultEditor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); // may be null //$NON-NLS-1$ > IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null > >- Object[] editors = registry.getEditors(getFileName()); >+ IFile localFile = getLocalResource(_remoteFile); >+ IEditorDescriptor[] editors = registry.getEditors(getFileName()); >+ if (localFile != null) { >+ // bug #376535 - need to respect editor overrides >+ // Using reflection in case IDE is older version, without this method >+ //editors = IDE.overrideEditorAssociations(new FileEditorInput(localFile), IDE.guessContentType(localFile), editors); >+ Class clazz = IDE.class; >+ try { >+ Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor[].class}; >+ Method method = clazz.getMethod("overrideEditorAssociations", parmtypes); //$NON-NLS-1$ >+ if (method != null) { >+ Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), editors}; >+ editors = (IEditorDescriptor[]) method.invoke(null, args); >+ } >+ } catch (Exception e) { >+ } >+ } > Collections.sort(Arrays.asList(editors), comparer); > > boolean defaultFound = false; >Index: src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java,v >retrieving revision 1.99.2.2 >diff -u -r1.99.2.2 SystemViewRemoteFileAdapter.java >--- src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java 30 Mar 2011 15:53:54 -0000 1.99.2.2 >+++ src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java 18 Apr 2012 22:33:06 -0000 >@@ -70,10 +70,12 @@ > * David McKnight (IBM) - [323299] [files] remote file view adapter needs to use the latest version of IRemoteFile > * David McKnight (IBM) - [324192] Cannot open a renamed file > * David McKnight (IBM) - [341244] folder selection input to unlocked Remote Systems Details view sometimes fails >+ * Rick Sawyer (IBM) - [376535] RSE does not respect editor overrides > *******************************************************************************/ > > package org.eclipse.rse.internal.files.ui.view; > import java.io.File; >+import java.lang.reflect.Method; > import java.text.MessageFormat; > import java.util.ArrayList; > import java.util.Date; >@@ -93,6 +95,7 @@ > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.Status; > import org.eclipse.core.runtime.SubProgressMonitor; >+import org.eclipse.core.runtime.content.IContentType; > import org.eclipse.core.runtime.jobs.Job; > import org.eclipse.jface.action.MenuManager; > import org.eclipse.jface.action.Separator; >@@ -196,11 +199,15 @@ > import org.eclipse.swt.dnd.Clipboard; > import org.eclipse.swt.widgets.Display; > import org.eclipse.swt.widgets.Shell; >+import org.eclipse.ui.IEditorDescriptor; >+import org.eclipse.ui.IEditorInput; > import org.eclipse.ui.IEditorPart; > import org.eclipse.ui.IEditorRegistry; > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.IWorkbench; > import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.ide.IDE; >+import org.eclipse.ui.part.FileEditorInput; > import org.eclipse.ui.progress.IElementCollector; > import org.eclipse.ui.views.properties.IPropertyDescriptor; > import org.eclipse.ui.views.properties.PropertyDescriptor; >@@ -505,6 +512,31 @@ > IRemoteFile file = (IRemoteFile) element; > if (file.isFile() || file.isArchive()) // hack to show zips without folder icons > { >+ // bug #376535 - need to respect editor overrides >+ IFile localFile = getLocalResource(file); >+ if (localFile != null) { >+ IEditorDescriptor editorDesc = getEditorRegistry().getDefaultEditor(file.getName(), IDE.guessContentType(localFile)); >+ // Using reflection in case IDE is older version, without this method >+ //editorDesc = IDE.overrideDefaultEditorAssociation(new FileEditorInput(localFile), IDE.guessContentType(localFile), editorDesc); >+ Class clazz = IDE.class; >+ try { >+ Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor.class}; >+ Method method = clazz.getMethod("overrideDefaultEditorAssociation", parmtypes); //$NON-NLS-1$ >+ if (method != null) { >+ Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), editorDesc}; >+ editorDesc = (IEditorDescriptor) method.invoke(null, args); >+ } >+ } catch (Exception e) { >+ } >+ >+ if (editorDesc != null) { >+ ImageDescriptor image = editorDesc.getImageDescriptor(); >+ if (image != null) { >+ return image; >+ } >+ } >+ } >+ > return getEditorRegistry().getImageDescriptor(file.getName()); > } > else >@@ -533,6 +565,16 @@ > } > > /** >+ * Get the local cache of the remote file, or <code>null</code> if none. >+ * @param remoteFile the remote file. >+ * @return the local cached resource, or <code>null</code> if none. >+ */ >+ private IFile getLocalResource(IRemoteFile remoteFile) >+ { >+ return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile); >+ } >+ >+ /** > * Return the label for this object. Uses getName() on the remote file object. > */ > public String getText(Object element) >@@ -3359,7 +3401,30 @@ > > // open new editor for correct replica > editable = getEditableRemoteObject(remoteFile); >- } >+ } >+ >+ /* Commenting out - no longer needed with fix to bug #376535 >+ if (editable instanceof SystemEditableRemoteFile){ >+ SystemEditableRemoteFile edit = (SystemEditableRemoteFile)editable; >+ IEditorDescriptor oldDescriptor = edit.getEditorDescriptor(); >+ IEditorDescriptor curDescriptor = null; >+ IFile file = editable.getLocalResource(); >+ >+ if (file == null || !file.exists()){ >+ curDescriptor = registry.getDefaultEditor(remoteFile.getName()); >+ } >+ if (curDescriptor == null){ >+ try { >+ curDescriptor = IDE.getEditorDescriptor(file); >+ } catch (PartInitException e) { >+ curDescriptor = IDE.getDefaultEditor(file); >+ } >+ } >+ if (oldDescriptor != curDescriptor){ >+ edit.setEditorDescriptor(curDescriptor); >+ } >+ } >+ */ > > try > {
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 377129
: 214210