Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 8d53d15eee5ca9dc596d8a0d93859ffe3354988e (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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
/*****************************************************************************
 * Copyright (c) 2010 CEA LIST.
 *    
 * 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:
 *  Florian Noyrit (CEA LIST) florian.noyrit@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.properties.tabbed.core.view;

import java.util.List;
import java.util.Vector;

import org.eclipse.papyrus.properties.tabbed.core.Activator;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor;

/**
 * This class stores the states: sectionSets and tabs
 * It provides corresponding retrieve and store methods
 */
public class StatesStore {

	/** available tab states for this wizard page */
	protected static Vector<TabDescriptorState> tabDescriptorStates;

	/** available section states for this wizard page */
	protected static List<SectionSetDescriptorState> sectionSetDescriptorStates;

	/**
	 * Get the tab descriptor states.
	 * 
	 * @return the list of descriptor states
	 */
	public static List<TabDescriptorState> getTabDescriptorStates() {
		return tabDescriptorStates;
	}

	/**
	 * Set the tab descriptor states.
	 * 
	 * @param tabDescriptorStates2
	 *        the list to set
	 */
	public static void setTabDescriptorStates(List<TabDescriptorState> tabDescriptorStates2) {
		tabDescriptorStates = new Vector<TabDescriptorState>(tabDescriptorStates2);
	}

	/**
	 * Get the sectionSet descriptor states.
	 * 
	 * @return the list of section descriptor states
	 */
	public static List<SectionSetDescriptorState> getSectionSetDescriptorStates() {
		return sectionSetDescriptorStates;
	}

	/**
	 * Set the tab sectionSet states.
	 * 
	 * @param sectionSeDescriptorStates2
	 *        the list to set
	 */
	public static void setSectionSetDescriptorStates(List<SectionSetDescriptorState> sectionSeDescriptorStates2) {
		sectionSetDescriptorStates = new Vector<SectionSetDescriptorState>(sectionSeDescriptorStates2);
	}

	/**
	 * Get the text for the tab mentioned TargetTab of a section.
	 * 
	 * @param id
	 *        the id of the tab to get the text from
	 * @return the text corresponding to the tab
	 */
	public static String getTextSectionDescriptorStateTargetTab(String id) {
		for(TabDescriptorState tabDescriptorState : tabDescriptorStates) {
			if(tabDescriptorState.getId().compareTo(id) == 0) {
				return tabDescriptorState.getText();
			}

		}
		return null;
	}

	/**
	 * Get the text for the section mentioned in AfterSection of a section.
	 * 
	 * @param id
	 *        the id of the section to get the text from
	 * @return the text corresponding to the section
	 */
	public static String getTextSectionDescriptorStateAfterSection(String id) {

		if(id.equals(ISectionDescriptor.TOP)) {
			return id;
		}

		for(SectionSetDescriptorState sectionSetDescriptorState : sectionSetDescriptorStates) {
			for(SectionDescriptorState sectionDescriptorState : sectionSetDescriptorState.getSectionDescriptorStates()) {
				if(sectionDescriptorState.getId().compareTo(id) == 0) {
					return sectionDescriptorState.getText();
				}
			}
		}
		return null;
	}

	/**
	 * Get the text for the section mentioned in id of a replacedSection.
	 * 
	 * @param id
	 *        the id of the section to get the text from
	 * @return the text corresponding to the section
	 */
	public static String getTextReplacedSectionStateId(String id) {
		for(SectionSetDescriptorState sectionSetDescriptorState : sectionSetDescriptorStates) {
			for(SectionDescriptorState sectionDescriptorState : sectionSetDescriptorState.getSectionDescriptorStates()) {
				if(sectionDescriptorState.getId().compareTo(id) == 0) {
					return sectionDescriptorState.getText();
				}
			}
		}
		return null;
	}

	/**
	 * Get the image for the tab (corresponding to TargetTab of a section).
	 * 
	 * @return the image for a tab
	 */
	public static Image getImageSectionDescriptorStateTargetTab() {
		return Activator.getImage("/icons/Tab.gif");
	}

	/**
	 * Get the image for the section (corresponding to AfterSection of a section).
	 * 
	 * @return the image for a section
	 */
	public static Image getImageSectionDescriptorStateAfterSection() {
		return Activator.getImage("/icons/Section.gif");
	}

	/**
	 * Get the image for the section (corresponding to Id of a replacedSection).
	 * 
	 * @return the image for a section
	 */
	public static Image getImageReplacedSectionStateId() {
		return Activator.getImage("/icons/Section.gif");
	}

}

Back to the top