Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 782162330ad18e396e0a7a54bb29896ae4b37061 (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
52
53
54
55
/*******************************************************************************
 * Copyright (c) 2007, 2012 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.structure;

import org.eclipse.jpt.common.ui.internal.jface.AbstractItemTreeContentProvider;
import org.eclipse.jpt.common.utility.internal.model.value.ListAspectAdapter;
import org.eclipse.jpt.common.utility.internal.model.value.ListCollectionValueModelAdapter;
import org.eclipse.jpt.common.utility.iterable.ListIterable;
import org.eclipse.jpt.common.utility.model.value.CollectionValueModel;
import org.eclipse.jpt.jpa.core.context.orm.EntityMappings;
import org.eclipse.jpt.jpa.core.context.orm.OrmPersistentType;

public class EntityMappingsItemContentProvider
	extends AbstractItemTreeContentProvider<EntityMappings, OrmPersistentType>
{
	public EntityMappingsItemContentProvider(EntityMappings entityMappings, Manager manager) {
		super(entityMappings, manager);
	}
	
	public Object getParent() {
		// I'd like to return the resource model here, but that involves a hefty 
		// API change - we'll see what happens with this code first
		return null;
	}

	@Override
	protected CollectionValueModel<OrmPersistentType> buildChildrenModel() {
		return new ListCollectionValueModelAdapter<OrmPersistentType>(new ChildrenModel(this.item));
	}

	protected static class ChildrenModel
		extends ListAspectAdapter<EntityMappings, OrmPersistentType>
	{
		ChildrenModel(EntityMappings entityMappings) {
			super(EntityMappings.PERSISTENT_TYPES_LIST, entityMappings);
		}

		@Override
		protected ListIterable<OrmPersistentType> getListIterable() {
			return this.subject.getPersistentTypes();
		}

		@Override
		public int size_() {
			return this.subject.getPersistentTypesSize();
		}
	}
}

Back to the top