Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 5d71b90e9957cb3e094589c13d8aee2543e3f102 (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
/*****************************************************************************
 * 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
 *  Thibault Le Ouay t.leouay@sherpa-eng.com - Strategy improvement of generated files
 *  Christian W. Damus (CEA) - bug 422257
 *
 *****************************************************************************/
package org.eclipse.papyrus.customization.properties.generation.generators;

import java.util.List;

import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.views.properties.contexts.Context;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.contexts.Property;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Listener;

/**
 * A Generator is intended to output a partial Context model.
 * This context model should only contain DataContextElements and Properties
 * (i.e. it should not contain any View or Tabs)
 * The Generator should also implement an heuristic, which will determine
 * for each Property if it should be displayed in the Property view or not,
 * for both Single and Multiple selection
 *
 * @author Camille Letavernier
 *
 */
public interface IGenerator {

	/**
	 * Generates the partial context, and persists it to the given target URI
	 *
	 * @param targetURI
	 * @return The generated Context
	 */
	public List<Context> generate(List<URI> targetURI);

	/**
	 * Creates the controls for this Generator. The generator is responsible
	 * for displaying any Control useful for editing its options, and listening
	 * for changes on them.
	 *
	 * @param parent
	 *            The Composite in which the controls will be displayed
	 */
	public void createControls(Composite parent);

	/**
	 * Gets the description for this Generator
	 *
	 * @return The description
	 */
	public String getDescription();

	/**
	 * Tests if this Generator's settings are all set and valid
	 *
	 * @return true if all options are set and valid
	 */
	public boolean isReady();

	/**
	 * Gets the name for this Generator
	 *
	 * @return The name
	 */
	public String getName();

	/**
	 * Tests if a field should be displayed for this Property when
	 * exactly one instance of this property's parent element is selected.
	 *
	 * @param property
	 * @return
	 */
	public boolean isSelectedSingle(Property property);

	/**
	 * Tests if a field should be displayed for this Property when
	 * at least two instances of this property's parent element are selected.
	 *
	 * @param property
	 * @return
	 */
	public boolean isSelectedMultiple(Property property);

	/**
	 * Tests if a field should be displayed for this Property when
	 * exactly one instance of the given element is selected. The difference
	 * with {@link #isSelectedSingle(Property)} is that this method takes the inheritance
	 * into account, i.e. the property belongs to a Superclass of the given DataContextElement
	 *
	 * @param property
	 * @param element
	 * @return
	 */
	public boolean isSelectedSingle(Property property, DataContextElement element);

	/**
	 * Tests if a field should be displayed for this Property when
	 * at least two instances of the given element are selected. The difference
	 * with {@link #isSelectedMultiple(Property)} is that this method takes the inheritance
	 * into account, i.e. the property belongs to a Superclass of the given DataContextElement
	 *
	 * @param property
	 * @param element
	 * @return
	 */
	public boolean isSelectedMultiple(Property property, DataContextElement element);

	/**
	 * Adds a Change Listener to this generator. The Listener should be notified
	 * each time the generator's {@link #isReady()} value changes
	 *
	 * @param listener
	 */
	public void addListener(Listener listener);

	/**
	 * Removes a Change Listener from this generator.
	 *
	 * @param listener
	 */
	public void removeListener(Listener listener);

	public List<Object> getExternalReference();

	public IObservableValue getObservableValue();

	public void setStrategy(int strategy);

	public void addCheckElement(Object obj);

	/**
	 * Disposes of any resources allocated by me when I am no longer needed.
	 */
	public void dispose();

}

Back to the top