Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 377129
Collapse All | Expand All

(-)src/org/eclipse/rse/files/ui/resources/SystemEditableRemoteFile.java (-8 / +19 lines)
Lines 43-48 Link Here
43
 * David McKnight   (IBM)        - [334839] File Content Conflict is not handled properly
43
 * David McKnight   (IBM)        - [334839] File Content Conflict is not handled properly
44
 * David McKnight   (IBM)        - [359704] SystemEditableRemoteFile does not release reference to editor
44
 * David McKnight   (IBM)        - [359704] SystemEditableRemoteFile does not release reference to editor
45
 * David McKnight   (IBM)        - [249031] Last used editor should be set to SystemEditableRemoteFile
45
 * David McKnight   (IBM)        - [249031] Last used editor should be set to SystemEditableRemoteFile
46
 * Rick Sawyer      (IBM)        - [376535] RSE does not respect editor overrides
46
 *******************************************************************************/
47
 *******************************************************************************/
47
48
48
package org.eclipse.rse.files.ui.resources;
49
package org.eclipse.rse.files.ui.resources;
Lines 131-136 Link Here
131
	private IEditorPart editor;
132
	private IEditorPart editor;
132
	private IFile localFile;
133
	private IFile localFile;
133
	private IWorkbenchPage page;
134
	private IWorkbenchPage page;
135
	private boolean _usingDefaultDescriptor = false;
134
136
135
	/**
137
	/**
136
	 * Internal class for downloading file
138
	 * Internal class for downloading file
Lines 275-280 Link Here
275
		IEditorDescriptor descriptor = null;
277
		IEditorDescriptor descriptor = null;
276
		try {
278
		try {
277
			descriptor = IDE.getEditorDescriptor(localResource);
279
			descriptor = IDE.getEditorDescriptor(localResource);
280
			
281
			if (!localResource.exists()){
282
				_usingDefaultDescriptor = true;
283
			}
278
		} catch (PartInitException e) {	
284
		} catch (PartInitException e) {	
279
		}	
285
		}	
280
		
286
		
Lines 1645-1652 Link Here
1645
1651
1646
		// set editor as preferred editor for this file
1652
		// set editor as preferred editor for this file
1647
		String editorId = null;
1653
		String editorId = null;
1648
		if (_editorDescriptor != null)
1654
		if (_editorDescriptor != null){
1649
			editorId = _editorDescriptor.getId();
1655
			if (_usingDefaultDescriptor){
1656
				_editorDescriptor = IDE.getEditorDescriptor(file);
1657
				editorId = _editorDescriptor.getId();
1658
			}	
1659
			else {
1660
				editorId = _editorDescriptor.getId();
1661
			}
1662
		}
1650
1663
1651
		IDE.setDefaultEditor(file, editorId);
1664
		IDE.setDefaultEditor(file, editorId);
1652
1665
Lines 1763-1775 Link Here
1763
	{
1776
	{
1764
		if (editor == part){
1777
		if (editor == part){
1765
			//delete();
1778
			//delete();
1766
		      
1779
		       
1767
			SystemUniversalTempFileListener.getListener().unregisterEditedFile(this);
1780
			SystemUniversalTempFileListener.getListener().unregisterEditedFile(this);
1768
1781
1769
			IWorkbenchPage page = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage();
1782
			IWorkbenchPage page = SystemBasePlugin.getActiveWorkbenchWindow().getActivePage();			
1770
1783
			if (page != null){
1771
			if (page != null)
1772
			{
1773
				page.removePartListener(this);
1784
				page.removePartListener(this);
1774
				editor = null;
1785
				editor = null;
1775
			}
1786
			}
Lines 2020-2026 Link Here
2020
					}
2031
					}
2021
				}
2032
				}
2022
			}
2033
			}
2023
		 }
2034
		}
2024
	}
2035
	}
2025
2036
2026
2037
(-)src/org/eclipse/rse/internal/files/ui/actions/SystemRemoteFileOpenWithMenu.java (-2 / +37 lines)
Lines 20-27 Link Here
20
 * David McKnight   (IBM)        - [284596] [regression] Open with-> problem when descriptor doesn't match previous
20
 * David McKnight   (IBM)        - [284596] [regression] Open with-> problem when descriptor doesn't match previous
21
 * David McKnight   (IBM)        - [309755] SystemRemoteFileOpenWithMenu.getPreferredEditor(), the listed default editor is not always correct
21
 * David McKnight   (IBM)        - [309755] SystemRemoteFileOpenWithMenu.getPreferredEditor(), the listed default editor is not always correct
22
 * David McKnight   (IBM)        - [312362] Editing Unix file after it changes on host edits old data
22
 * David McKnight   (IBM)        - [312362] Editing Unix file after it changes on host edits old data
23
 * Rick Sawyer      (IBM)        - [376535] RSE does not respect editor overrides
23
 *******************************************************************************/
24
 *******************************************************************************/
24
package org.eclipse.rse.internal.files.ui.actions;
25
package org.eclipse.rse.internal.files.ui.actions;
26
import java.lang.reflect.Method;
25
import java.text.Collator;
27
import java.text.Collator;
26
import java.util.ArrayList;
28
import java.util.ArrayList;
27
import java.util.Arrays;
29
import java.util.Arrays;
Lines 32-37 Link Here
32
import org.eclipse.core.resources.IFile;
34
import org.eclipse.core.resources.IFile;
33
import org.eclipse.core.resources.ResourceAttributes;
35
import org.eclipse.core.resources.ResourceAttributes;
34
import org.eclipse.core.runtime.NullProgressMonitor;
36
import org.eclipse.core.runtime.NullProgressMonitor;
37
import org.eclipse.core.runtime.content.IContentType;
35
import org.eclipse.jface.action.ContributionItem;
38
import org.eclipse.jface.action.ContributionItem;
36
import org.eclipse.jface.resource.ImageDescriptor;
39
import org.eclipse.jface.resource.ImageDescriptor;
37
import org.eclipse.jface.viewers.IStructuredSelection;
40
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 56-61 Link Here
56
import org.eclipse.swt.widgets.Menu;
59
import org.eclipse.swt.widgets.Menu;
57
import org.eclipse.swt.widgets.MenuItem;
60
import org.eclipse.swt.widgets.MenuItem;
58
import org.eclipse.ui.IEditorDescriptor;
61
import org.eclipse.ui.IEditorDescriptor;
62
import org.eclipse.ui.IEditorInput;
59
import org.eclipse.ui.IEditorPart;
63
import org.eclipse.ui.IEditorPart;
60
import org.eclipse.ui.IEditorRegistry;
64
import org.eclipse.ui.IEditorRegistry;
61
import org.eclipse.ui.IWorkbench;
65
import org.eclipse.ui.IWorkbench;
Lines 408-414 Link Here
408
	IFile localFile = getLocalResource(remoteFile);
412
	IFile localFile = getLocalResource(remoteFile);
409
	
413
	
410
	if (localFile == null || !localFile.exists()){
414
	if (localFile == null || !localFile.exists()){
411
		return registry.getDefaultEditor(remoteFile.getName());
415
		// bug #376535 - need to respect editor overrides
416
		IEditorDescriptor desc = registry.getDefaultEditor(remoteFile.getName(), IDE.guessContentType(localFile));
417
		// Using reflection in case IDE is older version, without this method
418
		//desc = IDE.overrideDefaultEditorAssociation(new FileEditorInput(localFile), IDE.guessContentType(localFile), desc);
419
		Class clazz = IDE.class;
420
		try {
421
			Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor.class};
422
			Method method = clazz.getMethod("overrideDefaultEditorAssociation", parmtypes); //$NON-NLS-1$
423
			if (method != null) {
424
				Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), desc};
425
				desc = (IEditorDescriptor) method.invoke(null, args);
426
			}
427
		} catch (Exception e) {
428
		}
429
		
430
		return desc;
412
	}
431
	}
413
	else {
432
	else {
414
		return IDE.getDefaultEditor(localFile);
433
		return IDE.getDefaultEditor(localFile);
Lines 470-476 Link Here
470
	IEditorDescriptor defaultEditor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); // may be null //$NON-NLS-1$
489
	IEditorDescriptor defaultEditor = registry.findEditor("org.eclipse.ui.DefaultTextEditor"); // may be null //$NON-NLS-1$
471
	IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null
490
	IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null
472
	
491
	
473
	Object[] editors = registry.getEditors(getFileName());
492
	IFile localFile = getLocalResource(_remoteFile);
493
	IEditorDescriptor[] editors = registry.getEditors(getFileName());
494
	if (localFile != null) {
495
		// bug #376535 - need to respect editor overrides
496
		// Using reflection in case IDE is older version, without this method
497
		//editors = IDE.overrideEditorAssociations(new FileEditorInput(localFile), IDE.guessContentType(localFile), editors);
498
		Class clazz = IDE.class;
499
		try {
500
			Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor[].class};
501
			Method method = clazz.getMethod("overrideEditorAssociations", parmtypes); //$NON-NLS-1$
502
			if (method != null) {
503
				Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), editors};
504
				editors = (IEditorDescriptor[]) method.invoke(null, args);
505
			}
506
		} catch (Exception e) {
507
		}
508
	}
474
	Collections.sort(Arrays.asList(editors), comparer);
509
	Collections.sort(Arrays.asList(editors), comparer);
475
510
476
	boolean defaultFound = false;
511
	boolean defaultFound = false;
(-)src/org/eclipse/rse/internal/files/ui/view/SystemViewRemoteFileAdapter.java (-1 / +66 lines)
Lines 70-79 Link Here
70
 * David McKnight   (IBM)        - [323299] [files] remote file view adapter needs to use the latest version of IRemoteFile
70
 * David McKnight   (IBM)        - [323299] [files] remote file view adapter needs to use the latest version of IRemoteFile
71
 * David McKnight   (IBM)        - [324192] Cannot open a renamed file
71
 * David McKnight   (IBM)        - [324192] Cannot open a renamed file
72
 * David McKnight   (IBM)        - [341244] folder selection input to unlocked Remote Systems Details view sometimes fails
72
 * David McKnight   (IBM)        - [341244] folder selection input to unlocked Remote Systems Details view sometimes fails
73
 * Rick Sawyer      (IBM)        - [376535] RSE does not respect editor overrides
73
 *******************************************************************************/
74
 *******************************************************************************/
74
75
75
package org.eclipse.rse.internal.files.ui.view;
76
package org.eclipse.rse.internal.files.ui.view;
76
import java.io.File;
77
import java.io.File;
78
import java.lang.reflect.Method;
77
import java.text.MessageFormat;
79
import java.text.MessageFormat;
78
import java.util.ArrayList;
80
import java.util.ArrayList;
79
import java.util.Date;
81
import java.util.Date;
Lines 93-98 Link Here
93
import org.eclipse.core.runtime.Platform;
95
import org.eclipse.core.runtime.Platform;
94
import org.eclipse.core.runtime.Status;
96
import org.eclipse.core.runtime.Status;
95
import org.eclipse.core.runtime.SubProgressMonitor;
97
import org.eclipse.core.runtime.SubProgressMonitor;
98
import org.eclipse.core.runtime.content.IContentType;
96
import org.eclipse.core.runtime.jobs.Job;
99
import org.eclipse.core.runtime.jobs.Job;
97
import org.eclipse.jface.action.MenuManager;
100
import org.eclipse.jface.action.MenuManager;
98
import org.eclipse.jface.action.Separator;
101
import org.eclipse.jface.action.Separator;
Lines 196-206 Link Here
196
import org.eclipse.swt.dnd.Clipboard;
199
import org.eclipse.swt.dnd.Clipboard;
197
import org.eclipse.swt.widgets.Display;
200
import org.eclipse.swt.widgets.Display;
198
import org.eclipse.swt.widgets.Shell;
201
import org.eclipse.swt.widgets.Shell;
202
import org.eclipse.ui.IEditorDescriptor;
203
import org.eclipse.ui.IEditorInput;
199
import org.eclipse.ui.IEditorPart;
204
import org.eclipse.ui.IEditorPart;
200
import org.eclipse.ui.IEditorRegistry;
205
import org.eclipse.ui.IEditorRegistry;
201
import org.eclipse.ui.ISharedImages;
206
import org.eclipse.ui.ISharedImages;
202
import org.eclipse.ui.IWorkbench;
207
import org.eclipse.ui.IWorkbench;
203
import org.eclipse.ui.PlatformUI;
208
import org.eclipse.ui.PlatformUI;
209
import org.eclipse.ui.ide.IDE;
210
import org.eclipse.ui.part.FileEditorInput;
204
import org.eclipse.ui.progress.IElementCollector;
211
import org.eclipse.ui.progress.IElementCollector;
205
import org.eclipse.ui.views.properties.IPropertyDescriptor;
212
import org.eclipse.ui.views.properties.IPropertyDescriptor;
206
import org.eclipse.ui.views.properties.PropertyDescriptor;
213
import org.eclipse.ui.views.properties.PropertyDescriptor;
Lines 505-510 Link Here
505
		IRemoteFile file = (IRemoteFile) element;
512
		IRemoteFile file = (IRemoteFile) element;
506
		if (file.isFile() || file.isArchive()) // hack to show zips without folder icons
513
		if (file.isFile() || file.isArchive()) // hack to show zips without folder icons
507
		{
514
		{
515
			// bug #376535 - need to respect editor overrides
516
			IFile localFile = getLocalResource(file);
517
			if (localFile != null) {
518
				IEditorDescriptor editorDesc = getEditorRegistry().getDefaultEditor(file.getName(), IDE.guessContentType(localFile));
519
				// Using reflection in case IDE is older version, without this method
520
				//editorDesc = IDE.overrideDefaultEditorAssociation(new FileEditorInput(localFile), IDE.guessContentType(localFile), editorDesc);
521
				Class clazz = IDE.class;
522
				try {  
523
					Class parmtypes[] = {IEditorInput.class, IContentType.class, IEditorDescriptor.class};
524
					Method method = clazz.getMethod("overrideDefaultEditorAssociation", parmtypes); //$NON-NLS-1$
525
					if (method != null) {
526
						Object args[] = {new FileEditorInput(localFile), IDE.guessContentType(localFile), editorDesc};
527
						editorDesc = (IEditorDescriptor) method.invoke(null, args);
528
					}
529
				} catch (Exception e) {
530
				}
531
				
532
				if (editorDesc != null) {
533
					ImageDescriptor image = editorDesc.getImageDescriptor();
534
					if (image != null) {
535
						return image;
536
					}
537
				}
538
			}
539
			
508
			return getEditorRegistry().getImageDescriptor(file.getName());
540
			return getEditorRegistry().getImageDescriptor(file.getName());
509
		}
541
		}
510
		else
542
		else
Lines 533-538 Link Here
533
	}
565
	}
534
566
535
	/**
567
	/**
568
	 * Get the local cache of the remote file, or <code>null</code> if none.
569
	 * @param remoteFile the remote file.
570
	 * @return the local cached resource, or <code>null</code> if none.
571
	 */
572
	private IFile getLocalResource(IRemoteFile remoteFile) 
573
	{
574
	    return (IFile)UniversalFileTransferUtility.getTempFileFor(remoteFile);
575
	}
576
	
577
	/**
536
	 * Return the label for this object. Uses getName() on the remote file object.
578
	 * Return the label for this object. Uses getName() on the remote file object.
537
	 */
579
	 */
538
	public String getText(Object element)
580
	public String getText(Object element)
Lines 3359-3365 Link Here
3359
					
3401
					
3360
					// open new editor for correct replica
3402
					// open new editor for correct replica
3361
					editable = getEditableRemoteObject(remoteFile);
3403
					editable = getEditableRemoteObject(remoteFile);
3362
				}											
3404
				}
3405
				
3406
				/* Commenting out - no longer needed with fix to bug #376535
3407
				if (editable instanceof SystemEditableRemoteFile){
3408
					SystemEditableRemoteFile edit = (SystemEditableRemoteFile)editable;
3409
					IEditorDescriptor oldDescriptor = edit.getEditorDescriptor();
3410
					IEditorDescriptor curDescriptor = null;
3411
					IFile file = editable.getLocalResource();
3412
					
3413
					if (file == null || !file.exists()){
3414
						curDescriptor = registry.getDefaultEditor(remoteFile.getName());						
3415
					}
3416
					if (curDescriptor == null){
3417
						try {
3418
							curDescriptor = IDE.getEditorDescriptor(file);
3419
						} catch (PartInitException e) {
3420
							curDescriptor = IDE.getDefaultEditor(file);
3421
						}
3422
					}
3423
					if (oldDescriptor != curDescriptor){
3424
						edit.setEditorDescriptor(curDescriptor);
3425
					}								
3426
				}
3427
				*/
3363
				
3428
				
3364
				try
3429
				try
3365
				{
3430
				{

Return to bug 377129