Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 51325de63ad037ed92bb761f62aff0fdf1f85568 (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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*****************************************************************************
 * Copyright (c) 2009 CEA LIST & LIFL
 *
 *
 * 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:
 *  Cedric Dumoulin  Cedric.dumoulin@lifl.fr - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.internal;

import java.util.List;

import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.IAbstractPanelModel;
import org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel;
import org.eclipse.papyrus.infra.core.sasheditor.di.contentprovider.IPageModelFactory;
import org.eclipse.papyrus.infra.core.sashwindows.di.SashPanel;
import org.eclipse.papyrus.infra.core.sashwindows.di.TabFolder;


/**
 * @author cedric dumoulin
 */
public class SashPanelModel implements IAbstractPanelModel, ISashPanelModel {

	/**
	 * Factory used to create PageModel.
	 */
	private IPageModelFactory pageModelFactory;

	/**
	 * The underlying di node.
	 */
	private SashPanel sashPanel;

	/**
	 *
	 * @param sashPanel
	 */
	public SashPanelModel(SashPanel sashPanel, IPageModelFactory pageModelFactory) {
		this.sashPanel = sashPanel;
		this.pageModelFactory = pageModelFactory;
	}

	/**
	 * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getChildren()
	 *
	 * @return
	 */
	@Override
	public List<?> getChildren() {
		return sashPanel.getChildren();
	}

	/**
	 * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#createChildSashModel(java.lang.Object)
	 *
	 * @param child
	 * @return
	 */
	@Override
	public IAbstractPanelModel createChildSashModel(Object child) {
		if (child instanceof SashPanel) {
			return new SashPanelModel((SashPanel) child, pageModelFactory);
		} else if (child instanceof TabFolder) {
			return new TabFolderModel((TabFolder) child, pageModelFactory);
		} else {
			throw new IllegalArgumentException("Can't create IPanelModel from raw model '" + child + "'.");
		}
	}

	/**
	 * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getSashDirection()
	 *
	 * @return
	 */
	@Override
	public int getSashDirection() {
		return sashPanel.getDirection();
	}

	/**
	 * @see org.eclipse.papyrus.infra.core.sasheditor.contentprovider.ISashPanelModel#getSashDirection()
	 *
	 * @return
	 */
	public float getSashPosition() {
		return sashPanel.getSashPosition();
	}

}

Back to the top