blob: ff65de98af62a9026824e3c108e508125c2cc088 (
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
|
/*****************************************************************************
* 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:
* Remi Schnekenburger (CEA LIST) remi.schnekenburger@cea.fr - Initial API and implementation
*****************************************************************************/
package org.eclipse.papyrus.properties.tabbed.customization.state;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.TreeSet;
import org.eclipse.papyrus.properties.runtime.view.DialogDescriptor;
import org.eclipse.papyrus.properties.runtime.view.FragmentDescriptor;
import org.eclipse.papyrus.properties.runtime.view.XMLParseException;
import org.eclipse.papyrus.properties.tabbed.core.view.PropertyTabViewProviderParser;
import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptor;
import org.eclipse.papyrus.properties.tabbed.core.view.SectionSetDescriptorState;
import org.eclipse.papyrus.properties.tabbed.core.view.TabDescriptorState;
import org.eclipse.ui.views.properties.tabbed.ITabDescriptor;
import org.w3c.dom.Document;
/**
* Parser that stores a list of state on configuration elements instead of contributing to property view
*/
public class StatePropertyTabViewProviderParser extends PropertyTabViewProviderParser {
/** states of section set descriptors in the xml file */
protected List<SectionSetDescriptorState> sectionSetDescriptorStates = new ArrayList<SectionSetDescriptorState>();
/** states of tab descriptors in the xml file */
protected TreeSet<TabDescriptorState> tabDescriptorStates = new TreeSet<TabDescriptorState>(new Comparator<TabDescriptorState>() {
/**
* {@inheritDoc}
*/
public int compare(TabDescriptorState o1, TabDescriptorState o2) {
if(o1.getAfterTab().compareTo((o2.getId())) == 0) {
return -1;
} else if(o1.getId().compareTo((o2.getId())) == 0) {
return 0;
} else {
return 1;
}
}
});
/**
* Creates a new StatePropertyTabViewProviderParser.
*
* @param tabDescriptors
* list of already available tab descriptors
*/
public StatePropertyTabViewProviderParser(List<ITabDescriptor> tabDescriptors) {
super(tabDescriptors);
}
/**
* {@inheritDoc}
*/
@Override
public void parseXMLfile(Document document, Map<String, FragmentDescriptor> predefinedFragments, Map<String, DialogDescriptor> predefinedDialogs) throws XMLParseException {
super.parseXMLfile(document, predefinedFragments, predefinedDialogs);
// from the list of created tab descriptors and section sets descriptors, creates the state
for(SectionSetDescriptor sectionSetDescriptor : getProvidedSectionSets()) {
SectionSetDescriptorState descriptorState = new SectionSetDescriptorState(sectionSetDescriptor, false);
sectionSetDescriptorStates.add(descriptorState);
}
for(ITabDescriptor tabDescriptor : getProvidedTabDescriptors()) {
TabDescriptorState descriptorState = new TabDescriptorState(tabDescriptor, false);
tabDescriptorStates.add(descriptorState);
}
}
/**
* Returns the sectionSetDescriptorStates
*
* @return the sectionSetDescriptorStates
*/
public List<SectionSetDescriptorState> getSectionSetDescriptorStates() {
return sectionSetDescriptorStates;
}
/**
* Returns the sectionSetDescriptorStates
*
* @return the sectionSetDescriptorStates
*/
public List<TabDescriptorState> getTabDescriptorStates() {
return new ArrayList<TabDescriptorState>(tabDescriptorStates);
}
}
|