Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 87f933b3d3d8faf7dcc47c3dab10575e4f4eb4b9 (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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
/*****************************************************************************
 * Copyright (c) 2010 ATOS ORIGIN.
 *
 * 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:
 *  Tristan Faure (ATOS ORIGIN INTEGRATION) tristan.faure@atosorigin.com - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.infra.widgets.toolbox.notification.builders;

import java.util.Collection;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.papyrus.infra.widgets.toolbox.notification.ICompositeCreator;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.NotificationRunnable;
import org.eclipse.papyrus.infra.widgets.toolbox.notification.Type;
import org.eclipse.swt.graphics.Image;


/**
 * This class provides a more comfortable usage
 * to access to properties from NotificationBuilder map
 *
 * @author tristan faure
 *
 */
public class PropertyWrapper {

	private boolean asynchronous = false;

	private String message = null;

	private ICompositeCreator composite = null;

	private Collection<NotificationRunnable> actions = null;

	private Long delay = null;

	private boolean temporary = false;

	private String title = null;

	private boolean html = false;

	private Type type = null;

	private Image image = null;

	private Map<String, Object> others = new HashMap<String, Object>();

	/**
	 * The class analyses the map and set the fields of the objects according to the values of the map.
	 *
	 * @param properties
	 *            the map from Notification Builder
	 */
	@SuppressWarnings("unchecked")
	public PropertyWrapper(Map<String, Object> properties) {
		for (String s : properties.keySet()) {
			if (NotificationBuilder.ASYNCHRONOUS.equals(s)) {
				asynchronous = (Boolean) properties.get(s);
			} else if (NotificationBuilder.COMPOSITE.equals(s)) {
				composite = (ICompositeCreator) properties.get(s);
			} else if (NotificationBuilder.MESSAGE.equals(s)) {
				message = (String) properties.get(s);
			} else if (NotificationBuilder.ACTION.equals(s)) {
				actions = (Collection<NotificationRunnable>) properties.get(s);
			} else if (NotificationBuilder.DELAY.equals(s)) {
				delay = (Long) properties.get(s);
			} else if (NotificationBuilder.HTML.equals(s)) {
				html = (Boolean) properties.get(s);
			} else if (NotificationBuilder.TEMPORARY.equals(s)) {
				temporary = (Boolean) properties.get(s);
			} else if (NotificationBuilder.TITLE.equals(s)) {
				title = (String) properties.get(s);
			} else if (NotificationBuilder.TYPE.equals(s)) {
				type = (Type) properties.get(s);
			} else if (NotificationBuilder.IMAGE.equals(s)) {
				image = (Image) properties.get(s);
			} else {
				others.put(s, properties.get(s));
			}
		}
	}

	/**
	 * Checks if is asynchronous.
	 *
	 * @return true, if is asynchronous
	 */
	public boolean isAsynchronous() {
		return asynchronous;
	}

	/**
	 * Gets the message.
	 *
	 * @return the message
	 */
	public String getMessage() {
		return message;
	}

	/**
	 * Gets the composite.
	 *
	 * @return the composite
	 */
	public ICompositeCreator getComposite() {
		return composite;
	}

	/**
	 * Gets the actions.
	 *
	 * @return the actions
	 */
	public Collection<NotificationRunnable> getActions() {
		return actions;
	}

	/**
	 * Gets the delay.
	 *
	 * @return the delay
	 */
	public Long getDelay() {
		return delay;
	}

	/**
	 * Checks if is temporary.
	 *
	 * @return true, if is temporary
	 */
	public boolean isTemporary() {
		return temporary;
	}

	/**
	 * Gets the title.
	 *
	 * @return the title
	 */
	public String getTitle() {
		return title;
	}

	/**
	 * Checks if is html.
	 *
	 * @return true, if is html
	 */
	public boolean isHtml() {
		return html;
	}

	/**
	 * Gets the type.
	 *
	 * @return the type
	 */
	public Type getType() {
		return type;
	}

	/**
	 * Gets the image.
	 *
	 * @return the image
	 */
	public Image getImage() {
		return image;
	}

	/**
	 * Get the map containing parameters not predefined
	 *
	 * @return the map
	 */
	public Map<String, Object> getCustomParameters() {
		return others;
	}

}

Back to the top