View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: TemplateTreeEntry.java
13   * Created: Sep 17, 2009
14   * Author: Kamil
15   * $Id$
16   */
17  
18  package pl.edu.agh.cast.importer.wizard.template;
19  
20  import pl.edu.agh.cast.importer.base.template.IImportTemplate;
21  
22  /**
23   * Entry used in TreeViewer as a model. Wraps {@link IImportTemplate}.
24   * 
25   * @author AGH CAST Team
26   */
27  public class TemplateTreeEntry implements ITreeEntry {
28  
29  	private final IImportTemplate element;
30  
31  	private final TemplateGroupTreeEntry parent;
32  
33  	public TemplateTreeEntry(IImportTemplate element, TemplateGroupTreeEntry parent) {
34  		if (element == null || parent == null) {
35  			throw new IllegalArgumentException();
36  		}
37  		if (!parent.getElement().containsTemplate(element.getId())) {
38  			throw new IllegalArgumentException();
39  		}
40  		this.element = element;
41  		this.parent = parent;
42  	}
43  
44  	public IImportTemplate getElement() {
45  		return element;
46  	}
47  
48  	public TemplateGroupTreeEntry getParent() {
49  		return parent;
50  	}
51  
52  	/**
53  	 * {@inheritDoc}
54  	 * 
55  	 * @see pl.edu.agh.cast.importer.wizard.template.ITreeEntry#getText()
56  	 */
57  	@Override
58  	public String getText() {
59  		return element.getName();
60  	}
61  
62  }