Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: af7c2c3b94c5b1ab218af1a8e9adec842e3bb488 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*******************************************************************************
 * Copyright (C) 2014 Obeo and others.
 *
 * 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.eclipse.egit.core.test.models;

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ModelProvider;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;

/**
 * This model provider will make all files of a given extension to be part of
 * the same model. In this test, this will be used on files with extension
 * {@link #SAMPLE_FILE_EXTENSION}.
 */
public class SampleModelProvider extends ModelProvider {
	public static final String SAMPLE_PROVIDER_ID = "org.eclipse.egit.core.tests.sampleModelProvider";

	public static final String SAMPLE_FILE_EXTENSION = "sample";

	@Override
	public ResourceMapping[] getMappings(IResource resource,
			ResourceMappingContext context, IProgressMonitor monitor)
			throws CoreException {
		if (resource instanceof IFile
				&& SAMPLE_FILE_EXTENSION.equals(resource.getFileExtension())) {
			return new ResourceMapping[] { new SampleResourceMapping(
					(IFile) resource, SAMPLE_PROVIDER_ID), };
		}
		return super.getMappings(resource, context, monitor);
	}
}

Back to the top