• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2008 The Android Open Source Project
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/org/documents/epl-v10.php
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ide.eclipse.adt.internal.editors.layout.parts;
18 
19 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiDocumentNode;
20 import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
21 
22 import org.eclipse.gef.EditPart;
23 import org.eclipse.gef.EditPartFactory;
24 import org.eclipse.gef.editparts.AbstractTreeEditPart;
25 import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
26 
27 /**
28  * {@link EditPartFactory} to create {@link AbstractTreeEditPart} for {@link UiElementNode} objects.
29  * These objects are used in the {@link IContentOutlinePage} linked to the layout editor.
30  *
31  * @since GLE1
32  */
33 public class UiElementTreeEditPartFactory implements EditPartFactory {
34 
createEditPart(EditPart context, Object model)35     public EditPart createEditPart(EditPart context, Object model) {
36         if (model instanceof UiDocumentNode) {
37             return new UiDocumentTreeEditPart((UiDocumentNode) model);
38         } else if (model instanceof UiElementNode) {
39             UiElementNode node = (UiElementNode) model;
40             if (node.getDescriptor().hasChildren()) {
41                 return new UiLayoutTreeEditPart(node);
42             } else {
43                 return new UiViewTreeEditPart(node);
44             }
45         }
46         return null;
47     }
48 
49 }
50