Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 0384cde276aa3db03f73323444358eec40ad20aa (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
/*****************************************************************************
 * 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:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.properties.generation.generators;

import org.eclipse.emf.common.util.URI;
import org.eclipse.papyrus.properties.contexts.Context;
import org.eclipse.papyrus.properties.contexts.DataContextElement;
import org.eclipse.papyrus.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 Context generate(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);
}

Back to the top