blob: d2e703d25a545a4363d48f38585d608c82ed8cc4 (
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
|
/*****************************************************************************
* Copyright (c) 2010, 2014 CEA LIST and others.
*
* 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:
* Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
* Christian W. Damus (CEA) - bug 417409
*
*****************************************************************************/
package org.eclipse.papyrus.infra.properties.ui.xwt;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.papyrus.infra.properties.contexts.Section;
import org.eclipse.papyrus.infra.properties.contexts.View;
import org.eclipse.papyrus.infra.properties.ui.runtime.DisplayEngine;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.views.properties.tabbed.AbstractSectionDescriptor;
import org.eclipse.ui.views.properties.tabbed.ISection;
/**
* An XWTSectionDescriptor contains Metadata for the XWTSection.
* It is similar to the {@link Section} class, but in the TabbedPropertyView context.
*
* @author Camille Letavernier
*/
public class XWTSectionDescriptor extends AbstractSectionDescriptor {
private Section section;
private View view;
private DisplayEngine display;
/**
*
* Constructs a new XWTSectionDescriptor from the given section and view.
* The XWTSections will be displayed in the given DisplayEngine.
*
* @param section
* The Section model object containing the section metadata
* @param view
* The view the section belongs to
* @param display
* The display engine that will be used to display the XWTSection
*/
public XWTSectionDescriptor(Section section, View view, DisplayEngine display) {
this.section = section;
this.view = view;
this.display = display;
}
public String getId() {
return section.getName();
}
public ISection getSectionClass() {
return new XWTSection(section, view, display);
}
public String getTargetTab() {
return section.getTab().getId();
}
@Override
public String toString() {
return "Section " + getId(); //$NON-NLS-1$
}
@Override
public boolean appliesTo(IWorkbenchPart part, ISelection selection) {
return true;
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + System.identityHashCode(display);
result = prime * result + System.identityHashCode(section);
result = prime * result + System.identityHashCode(view);
return result;
}
/**
* XWT section descriptors are equal if they have the same (identical) references to the section and view from the property-sheet model
* and are associated with the same display engine.
*/
@Override
public boolean equals(Object obj) {
boolean result;
if (this == obj) {
result = true;
} else if ((obj == null) || (obj.getClass() != this.getClass())) {
result = false;
} else {
XWTSectionDescriptor other = (XWTSectionDescriptor) obj;
result = (other.section == this.section) && (other.view == this.view) && (other.display == this.display);
}
return result;
}
}
|