1 11 12 package org.eclipse.pde.internal.ui.editor.plugin; 13 14 import org.eclipse.core.resources.IFile; 15 import org.eclipse.ui.IEditorInput; 16 import org.eclipse.ui.IEditorMatchingStrategy; 17 import org.eclipse.ui.IEditorReference; 18 import org.eclipse.ui.IFileEditorInput; 19 import org.eclipse.ui.IStorageEditorInput; 20 import org.eclipse.ui.PartInitException; 21 import org.eclipse.ui.ide.ResourceUtil; 22 23 24 public class ManifestEditorMatchingStrategy implements IEditorMatchingStrategy { 25 26 public boolean matches(IEditorReference editorRef, IEditorInput input) { 27 IFile inputFile = ResourceUtil.getFile(input); 28 if (input instanceof IFileEditorInput) { 29 try { 30 if (input.equals(editorRef.getEditorInput())) 31 return true; 32 String path = inputFile.getProjectRelativePath().toString(); 33 if (path.equals("build.properties")) { IFile editorFile = ResourceUtil.getFile(editorRef.getEditorInput()); 35 return editorFile != null && inputFile.getProject().equals(editorFile.getProject()); 36 } 37 } catch (PartInitException e) { 38 return false; 39 } 40 } else if (input instanceof IStorageEditorInput) { 41 try { 42 IEditorInput existing = editorRef.getEditorInput(); 43 return input.equals(existing); 44 } catch (PartInitException e1) { 45 } 46 } 47 return false; 48 } 49 50 51 } 52 53 | Popular Tags |