[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[tm-cvs-commit] dmcknight org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions SystemRemoteFileOpenWithMenu.java

Update of /cvsroot/tools/org.eclipse.tm.rse/plugins/org.eclipse.rse.files.ui/src/org/eclipse/rse/internal/files/ui/actions
In directory dev2:/tmp/cvs-serv3678/src/org/eclipse/rse/internal/files/ui/actions

Modified Files:
      Tag: R3_2_maintenance
	SystemRemoteFileOpenWithMenu.java 
Log Message:
[376535] RSE does not respect editor overrides


Index: 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
retrieving revision 1.16.2.1
diff -C2 -d -r1.16 -r1.16.2.1
*** SystemRemoteFileOpenWithMenu.java	11 May 2010 18:44:15 -0000	1.16
--- SystemRemoteFileOpenWithMenu.java	19 Apr 2012 13:44:54 -0000	1.16.2.1
***************
*** 21,26 ****
--- 21,28 ----
   * 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;
***************
*** 33,36 ****
--- 35,39 ----
  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;
***************
*** 57,60 ****
--- 60,64 ----
  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;
***************
*** 409,413 ****
  	
  	if (localFile == null || !localFile.exists()){
! 		return registry.getDefaultEditor(remoteFile.getName());
  	}
  	else {
--- 413,432 ----
  	
  	if (localFile == null || !localFile.exists()){
! 		// 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 {
***************
*** 471,475 ****
  	IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null
  	
! 	Object[] editors = registry.getEditors(getFileName());
  	Collections.sort(Arrays.asList(editors), comparer);
  
--- 490,510 ----
  	IEditorDescriptor preferredEditor = getPreferredEditor(_remoteFile); // may be null
  	
! 	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);