1 11 12 package org.eclipse.pde.internal.ui.editor.feature; 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.PartInitException; 20 import org.eclipse.ui.ide.ResourceUtil; 21 22 23 public class FeatureEditorMatchingStrategy implements IEditorMatchingStrategy { 24 25 private static final String BP = "build.properties"; private static final String FX = "feature.xml"; 28 public boolean matches(IEditorReference editorRef, IEditorInput input) { 29 if (!(input instanceof IFileEditorInput)) 30 return false; 31 IFile inputFile = ResourceUtil.getFile(input); 32 if (inputFile == null) 33 return false; 34 try { 35 IFile currInputFile = ResourceUtil.getFile(editorRef.getEditorInput()); 36 if (currInputFile == null) 37 return false; 38 if (!inputFile.getProject().equals(currInputFile.getProject())) 39 return false; 40 if (inputFile.getName().equals(FX)) { 43 if (currInputFile.getName().equals(BP)) 44 return inputFile.getProjectRelativePath().toString().equals(FX); 45 return inputFile.equals(currInputFile); 46 } else if (inputFile.getName().equals(BP)) { 47 if (currInputFile.getName().equals(FX)) 48 return currInputFile.getProjectRelativePath().toString().equals(FX); 49 return inputFile.equals(currInputFile); 50 } 51 return false; 52 } catch (PartInitException e) { 53 return false; 54 } 55 } 56 57 } 58 59 | Popular Tags |