]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.ui/src/org/simantics/ui/workbench/editor/input/ResourceEditorInputMatchingStrategy.java
Fixed all line endings of the repository
[simantics/platform.git] / bundles / org.simantics.ui / src / org / simantics / ui / workbench / editor / input / ResourceEditorInputMatchingStrategy.java
1 /*******************************************************************************
2  * Copyright (c) 2012 Association for Decentralized Information Management in
3  * Industry THTH ry.
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License v1.0
6  * which accompanies this distribution, and is available at
7  * http://www.eclipse.org/legal/epl-v10.html
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.ui.workbench.editor.input;
13
14 import org.eclipse.ui.IEditorInput;
15 import org.eclipse.ui.IEditorMatchingStrategy;
16 import org.eclipse.ui.IEditorReference;
17 import org.eclipse.ui.PartInitException;
18 import org.simantics.ui.workbench.IResourceEditorInput;
19 import org.simantics.ui.workbench.IResourceEditorInput2;
20 import org.simantics.ui.workbench.ResourceEditorInput;
21 import org.simantics.ui.workbench.ResourceEditorInput2;
22
23 /**
24  * An editor input matching strategy that does not take into account the name in
25  * the editor input. This is because in {@link ResourceEditorInput} and
26  * {@link ResourceEditorInput2} the name is not important, only
27  * <code>equals</code> is.
28  * 
29  * @author Tuukka Lehtonen
30  * 
31  * @see IResourceEditorInput
32  * @see IResourceEditorInput2
33  * @see ResourceEditorInput
34  * @see ResourceEditorInput2
35  */
36 public class ResourceEditorInputMatchingStrategy implements IEditorMatchingStrategy {
37
38     @Override
39     public boolean matches(IEditorReference editorRef, IEditorInput input) {
40         if (!(input instanceof IResourceEditorInput))
41             return false;
42
43         try {
44             IEditorInput editorInput = editorRef.getEditorInput();
45             return input.equals(editorInput);
46         } catch (PartInitException e) {
47             return false;
48         }
49     }
50
51 }