Skip to main content
summaryrefslogtreecommitdiffstats
blob: ef6525528955178f5eebe588381ab8362aa3957a (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
41
42
43
44
45
46
47
48
49
50
51
/*******************************************************************************
 * Copyright (c) 2008, 2009 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.jpa.ui.internal.platform.generic;

import org.eclipse.core.resources.IProject;
import org.eclipse.jpt.common.ui.internal.jface.AbstractTreeItemContentProvider;
import org.eclipse.jpt.common.ui.internal.jface.DelegatingTreeContentAndLabelProvider;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.PropertyCollectionValueModelAdapter;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.jpa.core.context.JpaRootContextNode;
import org.eclipse.jpt.jpa.core.context.persistence.PersistenceXml;

public class RootContextItemContentProvider
	extends AbstractTreeItemContentProvider<PersistenceXml>
{
	public RootContextItemContentProvider(
			JpaRootContextNode rootContext, DelegatingTreeContentAndLabelProvider contentProvider) {
		super(rootContext, contentProvider);
	}
	
	@Override
	public JpaRootContextNode getModel() {
		return (JpaRootContextNode) super.getModel();
	}
	
	@Override
	public IProject getParent() {
		return getModel().getJpaProject().getProject();
	}
	
	@Override
	protected CollectionValueModel<PersistenceXml> buildChildrenModel() {
		return new PropertyCollectionValueModelAdapter<PersistenceXml>(
				new PropertyAspectAdapter<JpaRootContextNode, PersistenceXml>(
						JpaRootContextNode.PERSISTENCE_XML_PROPERTY,
						getModel()) {
					 @Override
					protected PersistenceXml buildValue_() {
						return subject.getPersistenceXml();
					}
				});
	}
}

Back to the top