blob: 3cb6e9bbf01e92b3f9ad08ac4e9f3dd9227e6e1a (
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
|
/*******************************************************************************
* Copyright (c) 2006 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.team.examples.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
public abstract class ModelContainer extends ModelResource {
protected ModelContainer(IContainer container) {
super(container);
}
protected IContainer getContainer() {
return (IContainer)getResource();
}
public ModelObject[] getChildren() throws CoreException {
IResource[] members = getContainer().members();
List result = new ArrayList();
for (int i = 0; i < members.length; i++) {
IResource resource = members[i];
if (resource instanceof IFolder) {
result.add(new ModelFolder((IFolder) resource));
} else if (ModelObjectDefinitionFile.isModFile(resource)) {
result.add(new ModelObjectDefinitionFile((IFile)resource));
} else if (resource instanceof IProject && ModelProject.isModProject((IProject) resource)) {
result.add(new ModelProject((IProject) resource));
}
}
return (ModelObject[]) result.toArray(new ModelObject[result.size()]);
}
}
|