Skip to main content
summaryrefslogtreecommitdiffstats
blob: 17236d7b805bfc9b79dbdb71fd7ce38c35da38a4 (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
/*******************************************************************************
 * Copyright (c) 2008 Oracle. 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
 * 
 * Contributors: Oracle. - initial API and implementation
 ******************************************************************************/        
package org.eclipse.jpt.core.internal;

import org.eclipse.core.expressions.PropertyTester;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jpt.core.JptCorePlugin;

public class JpaPlatformTester extends PropertyTester {
	
	public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
		if (! property.equals("jpaPlatform")) { //$NON-NLS-1$
			return false;
		}
		IProject project = null;
		if (receiver instanceof IResource) {
			project = ((IResource) receiver).getProject();
		}
		else if (receiver instanceof IJavaElement) {
	        project = ((IJavaElement) receiver).getResource().getProject();
		}
		
		if (project == null) {
			return false;
		}

		String platformId = JptCorePlugin.getJpaPlatformId(project);
		
		return platformId == null ? false : platformId.equals(expectedValue);
	}		
}

Back to the top