| /* |
| ----------------------------------------------------------------------- |
| -- CHESS editor plugin -- |
| -- -- |
| -- Copyright (C) 2011-2012 -- |
| -- University of Padova, ITALY -- |
| -- -- |
| -- Author: Alessandro Zovi azovi@math.unipd.it -- |
| -- -- |
| -- All rights reserved. This program and the accompanying materials -- |
| -- are made available under the terms of the Eclipse Public License -- |
| -- v1.0 which accompanies this distribution, and is available at -- |
| -- http://www.eclipse.org/legal/epl-v10.html -- |
| ----------------------------------------------------------------------- |
| */ |
| |
| package org.polarsys.chess.service.internal; |
| import org.eclipse.core.resources.IFile; |
| import org.eclipse.core.runtime.CoreException; |
| import org.eclipse.ui.IEditorInput; |
| import org.eclipse.ui.IEditorMatchingStrategy; |
| import org.eclipse.ui.IEditorReference; |
| import org.eclipse.ui.IFileEditorInput; |
| import org.polarsys.chess.core.natures.CHESSNature; |
| |
| |
| public class MatchingStrategy implements IEditorMatchingStrategy { |
| |
| public boolean matches(IEditorReference editorRef, IEditorInput input) { |
| boolean match = false; |
| |
| IFile file = ((IFileEditorInput)input).getFile(); |
| |
| try { |
| if(file.getProject().hasNature(CHESSNature.NATURE_ID)){ |
| match = true; |
| } |
| } catch (CoreException e) { |
| Activator.error("Errors in MatchingStrategy", e); |
| } |
| return match; |
| } |
| } |