Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 332010
Collapse All | Expand All

(-)src/org/eclipse/emf/facet/infra/browser/editors/EcoreBrowser.java (-10 / +9 lines)
Lines 880-890 Link Here
880
					if (externalResource != null) {
880
					if (externalResource != null) {
881
						directReferencedResources.add(externalResource);
881
						directReferencedResources.add(externalResource);
882
					} else {
882
					} else {
883
						Logger
883
						Logger.logError(
884
								.logError(
884
								"Failed to load an external element: " + external.eClass().getName() //$NON-NLS-1$
885
										"Failed to load an external element: " + external.eClass().getName() //$NON-NLS-1$
885
										+ " " + EcoreUtil.getURI(external), //$NON-NLS-1$
886
												+ " " + EcoreUtil.getURI(external), //$NON-NLS-1$
886
								BrowserPlugin.getPlugin());
887
										BrowserPlugin.getPlugin());
888
					}
887
					}
889
				}
888
				}
890
			}
889
			}
Lines 987-993 Link Here
987
		this.customTreePainter = new CustomTreePainter(this.fTree,
986
		this.customTreePainter = new CustomTreePainter(this.fTree,
988
				this.browserConfiguration.getAppearanceConfiguration());
987
				this.browserConfiguration.getAppearanceConfiguration());
989
		// create a tooltip to show facet names
988
		// create a tooltip to show facet names
990
		FacetTooltip.create(this.fTree, this.customTreePainter);
989
		FacetTooltip.create(this.fTree, this.customTreePainter,
990
				this.browserConfiguration.getAppearanceConfiguration());
991
991
992
		this.treeViewer = new TreeViewer(this.fTree);
992
		this.treeViewer = new TreeViewer(this.fTree);
993
		// speeds up all operations on a big model
993
		// speeds up all operations on a big model
Lines 2412-2420 Link Here
2412
			basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
2412
			basicDiagnostic.merge(EcoreUtil.computeDiagnostic(resource, true));
2413
			return basicDiagnostic;
2413
			return basicDiagnostic;
2414
		} else if (exception != null) {
2414
		} else if (exception != null) {
2415
			return new BasicDiagnostic(Diagnostic.ERROR, BrowserPlugin.PLUGIN_ID, 0,
2415
			return new BasicDiagnostic(Diagnostic.ERROR, BrowserPlugin.PLUGIN_ID, 0, NLS.bind(
2416
					NLS.bind(Messages.UI_ErrorFile_message, resource.getURI()),
2416
					Messages.UI_ErrorFile_message, resource.getURI()), new Object[] { exception });
2417
					new Object[] { exception });
2418
		} else {
2417
		} else {
2419
			return Diagnostic.OK_INSTANCE;
2418
			return Diagnostic.OK_INSTANCE;
2420
		}
2419
		}
Lines 2456-2462 Link Here
2456
			commandStack.addCommandStackListener(new CommandStackListener() {
2455
			commandStack.addCommandStackListener(new CommandStackListener() {
2457
				public void commandStackChanged(final EventObject event) {
2456
				public void commandStackChanged(final EventObject event) {
2458
					Composite composite = getParentComposite();
2457
					Composite composite = getParentComposite();
2459
					if(composite.isDisposed()) {
2458
					if (composite.isDisposed()) {
2460
						return;
2459
						return;
2461
					}
2460
					}
2462
					composite.getDisplay().asyncExec(new Runnable() {
2461
					composite.getDisplay().asyncExec(new Runnable() {
(-)src/org/eclipse/emf/facet/infra/browser/editors/FacetTooltip.java (-6 / +13 lines)
Lines 14-21 Link Here
14
14
15
import org.eclipse.emf.ecore.EObject;
15
import org.eclipse.emf.ecore.EObject;
16
import org.eclipse.emf.facet.infra.browser.BrowserPlugin;
16
import org.eclipse.emf.facet.infra.browser.BrowserPlugin;
17
import org.eclipse.emf.facet.infra.browser.uicore.internal.AppearanceConfiguration;
17
import org.eclipse.emf.facet.infra.browser.uicore.internal.CustomTreePainter;
18
import org.eclipse.emf.facet.infra.browser.uicore.internal.CustomTreePainter;
18
import org.eclipse.emf.facet.infra.browser.uicore.internal.CustomTreePainter.FacetToPaint;
19
import org.eclipse.emf.facet.infra.browser.uicore.internal.FacetToPaint;
19
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
20
import org.eclipse.emf.facet.infra.browser.uicore.internal.model.ModelElementItem;
20
import org.eclipse.emf.facet.infra.facet.Facet;
21
import org.eclipse.emf.facet.infra.facet.Facet;
21
import org.eclipse.swt.SWT;
22
import org.eclipse.swt.SWT;
Lines 40-51 Link Here
40
 * Windows Vista or 7
41
 * Windows Vista or 7
41
 */
42
 */
42
public final class FacetTooltip {
43
public final class FacetTooltip {
43
	
44
44
	// TODO: extend org.eclipse.emf.facet.infra.common.ui.internal.controls.Tooltip
45
	// TODO: extend
46
	// org.eclipse.emf.facet.infra.common.ui.internal.controls.Tooltip
45
47
46
	private static final String TREEITEM_DATA_KEY = "_TREEITEM"; //$NON-NLS-1$
48
	private static final String TREEITEM_DATA_KEY = "_TREEITEM"; //$NON-NLS-1$
49
	private static AppearanceConfiguration fApearanceConfiguration;
47
50
48
	public static FacetTooltip create(final Tree tree, final CustomTreePainter customTreePainter) {
51
	public static FacetTooltip create(final Tree tree, final CustomTreePainter customTreePainter,
52
			final AppearanceConfiguration appearanceConfiguration) {
53
		FacetTooltip.fApearanceConfiguration = appearanceConfiguration;
49
		return new FacetTooltip(tree, customTreePainter);
54
		return new FacetTooltip(tree, customTreePainter);
50
	}
55
	}
51
56
Lines 87-95 Link Here
87
							Rectangle bounds = item.getBounds();
92
							Rectangle bounds = item.getBounds();
88
							int maxX = tree.getClientArea().width
93
							int maxX = tree.getClientArea().width
89
									+ tree.getHorizontalBar().getSelection();
94
									+ tree.getHorizontalBar().getSelection();
90
							List<FacetToPaint> facetsToPaint = customTreePainter
95
							List<FacetToPaint> facetsToPaint = CustomTreePainter
91
									.getFacetsToPaintFor(eObject, bounds.x, bounds.width, bounds.y,
96
									.getFacetsToPaintFor(eObject, bounds.x, bounds.width, bounds.y,
92
											bounds.height, maxX);
97
											bounds.height, maxX,
98
											FacetTooltip.fApearanceConfiguration.getCustomizationEngine(),
99
											FacetTooltip.fApearanceConfiguration.getFacetContext());
93
							Facet facet = findFacetAt(event.x, event.y, facetsToPaint);
100
							Facet facet = findFacetAt(event.x, event.y, facetsToPaint);
94
101
95
							if (facet != null) {
102
							if (facet != null) {
(-)src/org/eclipse/emf/facet/widgets/nattable/painter/CustomizedCellPainter.java (-21 / +97 lines)
Lines 29-36 Link Here
29
import org.eclipse.emf.ecore.EClass;
29
import org.eclipse.emf.ecore.EClass;
30
import org.eclipse.emf.ecore.EObject;
30
import org.eclipse.emf.ecore.EObject;
31
import org.eclipse.emf.ecore.EReference;
31
import org.eclipse.emf.ecore.EReference;
32
import org.eclipse.emf.facet.infra.browser.uicore.internal.CustomTreePainter;
33
import org.eclipse.emf.facet.infra.browser.uicore.internal.FacetToPaint;
32
import org.eclipse.emf.facet.infra.browser.uicore.internal.customization.CustomizationEngine;
34
import org.eclipse.emf.facet.infra.browser.uicore.internal.customization.CustomizationEngine;
33
import org.eclipse.emf.facet.infra.common.core.logging.Logger;
35
import org.eclipse.emf.facet.infra.common.core.logging.Logger;
36
import org.eclipse.emf.facet.infra.facet.Facet;
34
import org.eclipse.emf.facet.widgets.nattable.Activator;
37
import org.eclipse.emf.facet.widgets.nattable.Activator;
35
import org.eclipse.emf.facet.widgets.nattable.ColumnDescription;
38
import org.eclipse.emf.facet.widgets.nattable.ColumnDescription;
36
import org.eclipse.emf.facet.widgets.nattable.ColumnDescription.Type;
39
import org.eclipse.emf.facet.widgets.nattable.ColumnDescription.Type;
Lines 87-92 Link Here
87
		ColumnDescription columnDescription = this.natTableWidget.getColumnDescriptions().get(
90
		ColumnDescription columnDescription = this.natTableWidget.getColumnDescriptions().get(
88
				convertedColumn);
91
				convertedColumn);
89
92
93
		// leave a 2 pixel wide margin
94
		Rectangle rectangleWithMargin = new Rectangle(rectangle.x + 2, rectangle.y + 2,
95
				rectangle.width - 2 * 2, rectangle.height - 2 * 2);
96
90
		Color backgroundColor = CellStyleUtil.getCellStyle(cell, configRegistry).getAttributeValue(
97
		Color backgroundColor = CellStyleUtil.getCellStyle(cell, configRegistry).getAttributeValue(
91
				CellStyleAttributes.BACKGROUND_COLOR);
98
				CellStyleAttributes.BACKGROUND_COLOR);
92
		Customization customization = null;
99
		Customization customization = null;
Lines 97-103 Link Here
97
			Object element = gridElement.getElement();
104
			Object element = gridElement.getElement();
98
			if (element instanceof EObject) {
105
			if (element instanceof EObject) {
99
				EObject eObject = (EObject) element;
106
				EObject eObject = (EObject) element;
100
				customization = getCustomization(eObject, columnDescription);
107
				customization = getCustomization(eObject, columnDescription, rectangleWithMargin);
101
			}
108
			}
102
		}
109
		}
103
		// }
110
		// }
Lines 119-130 Link Here
119
		gc.setBackground(originalBackground);
126
		gc.setBackground(originalBackground);
120
127
121
		Rectangle originalClipping = gc.getClipping();
128
		Rectangle originalClipping = gc.getClipping();
122
		// leave a margin
129
		gc.setClipping(rectangleWithMargin);
123
		rectangle.x += 2;
124
		rectangle.y += 2;
125
		rectangle.width -= 2 * 2;
126
		rectangle.height -= 2 * 2;
127
		gc.setClipping(rectangle.intersection(originalClipping));
128
130
129
		IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
131
		IStyle cellStyle = CellStyleUtil.getCellStyle(cell, configRegistry);
130
		setupGCFromConfig(gc, cellStyle);
132
		setupGCFromConfig(gc, cellStyle);
Lines 142-181 Link Here
142
			}
144
			}
143
		}
145
		}
144
146
147
		gc.setClipping(rectangle);
148
145
		boolean hasIcon = false;
149
		boolean hasIcon = false;
146
		if (customization != null && customization.getInstanceIcon() != null) {
150
		if (customization != null && customization.getInstanceIcon() != null) {
147
			gc.drawImage(customization.getInstanceIcon(), rectangle.x, rectangle.y);
151
			gc.drawImage(customization.getInstanceIcon(), rectangleWithMargin.x,
152
					rectangleWithMargin.y);
148
			hasIcon = true;
153
			hasIcon = true;
149
		} else {
154
		} else {
150
			Image columnImage = this.tableLabelProvider.getColumnImage(cell.getDataValue(),
155
			Image columnImage = this.tableLabelProvider.getColumnImage(cell.getDataValue(),
151
					convertedColumn);
156
					convertedColumn);
152
			if (columnImage != null) {
157
			if (columnImage != null) {
153
				gc.drawImage(columnImage, rectangle.x, rectangle.y);
158
				gc.drawImage(columnImage, rectangleWithMargin.x, rectangleWithMargin.y);
154
				hasIcon = true;
159
				hasIcon = true;
155
			}
160
			}
156
		}
161
		}
157
162
163
		boolean hasOverlay = false;
164
		if (customization != null) {
165
			int facetMinX = rectangle.width;
166
			List<FacetToPaint> facetsToMeasure = customization.getFacetsToPaint();
167
			for (FacetToPaint facetToPaint : facetsToMeasure) {
168
				if (!facetToPaint.isOverlay()) {
169
					facetMinX = Math.min(facetMinX, facetToPaint.getBounds().x);
170
				} else {
171
					hasOverlay = true;
172
				}
173
			}
174
			// reduce the clipping, so as to not draw again over stickers
175
			Rectangle textClipping = new Rectangle(rectangleWithMargin.x, rectangleWithMargin.y,
176
					facetMinX - 2, rectangleWithMargin.height);
177
			gc.setClipping(textClipping);
178
		}
179
158
		if (hasIcon) {
180
		if (hasIcon) {
181
			final int totalOffsetAfterIcon;
159
			final int offsetAfterIcon = 18;
182
			final int offsetAfterIcon = 18;
160
			gc.drawText(text, rectangle.x + offsetAfterIcon, rectangle.y, true);
183
			final int overlaySize = 8;
184
			if (hasOverlay) {
185
				totalOffsetAfterIcon = offsetAfterIcon + overlaySize;
186
			} else {
187
				totalOffsetAfterIcon = offsetAfterIcon;
188
			}
189
190
			gc.drawText(text, rectangleWithMargin.x + totalOffsetAfterIcon, rectangleWithMargin.y, true);
161
		} else {
191
		} else {
162
			gc.drawText(text, rectangle.x, rectangle.y, true);
192
			gc.drawText(text, rectangleWithMargin.x, rectangleWithMargin.y, true);
163
		}
193
		}
164
194
195
		gc.setClipping(rectangle);
196
165
		if (customization != null) {
197
		if (customization != null) {
166
			final int leftMargin = 0;
198
			final int leftMargin = 0;
167
			final int rightMargin = 0;
199
			final int rightMargin = 0;
168
200
169
			if (customization.isUnderlined()) {
201
			if (customization.isUnderlined()) {
170
				final int y = rectangle.y + rectangle.height - 1;
202
				final int y = rectangleWithMargin.y + rectangleWithMargin.height - 1;
171
				gc.drawLine(rectangle.x + leftMargin, y, rectangle.x + rectangle.width
203
				gc.drawLine(rectangleWithMargin.x + leftMargin, y, rectangleWithMargin.x
172
						- rightMargin, y);
204
						+ rectangleWithMargin.width - rightMargin, y);
173
			}
205
			}
174
206
175
			if (customization.isStruckthrough()) {
207
			if (customization.isStruckthrough()) {
176
				final int y = rectangle.y + rectangle.height / 2 + 1;
208
				final int y = rectangleWithMargin.y + rectangleWithMargin.height / 2 + 1;
177
				gc.drawLine(rectangle.x + leftMargin, y, rectangle.x + rectangle.width
209
				gc.drawLine(rectangleWithMargin.x + leftMargin, y, rectangleWithMargin.x
178
						- rightMargin, y);
210
						+ rectangleWithMargin.width - rightMargin, y);
211
			}
212
		}
213
214
		if (customization != null) {
215
			List<FacetToPaint> facetsToPaint = customization.getFacetsToPaint();
216
			final int facetStickerBackgroundOpacity = 192;
217
			for (FacetToPaint facetToPaint : facetsToPaint) {
218
				Image customizedIcon = facetToPaint.getImage();
219
				if (customizedIcon != null) {
220
					Rectangle bounds = customizedIcon.getBounds();
221
					Rectangle target = facetToPaint.getBounds();
222
					Rectangle stickerRectangle = new Rectangle(rectangle.x + target.x + 1,
223
							rectangle.y + target.y + 1, target.width, target.height);
224
					// int oldAlpha = gc.getAlpha();
225
					// gc.setAlpha(facetStickerBackgroundOpacity);
226
					// gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
227
					// gc.fillRectangle(stickerRectangle);
228
					// gc.setAlpha(oldAlpha);
229
					gc.drawImage(customizedIcon, 0, 0, bounds.width, bounds.height,
230
							stickerRectangle.x, stickerRectangle.y, stickerRectangle.width,
231
							stickerRectangle.height);
232
				}
179
			}
233
			}
180
		}
234
		}
181
235
Lines 196-205 Link Here
196
	}
250
	}
197
251
198
	private Customization getCustomization(final EObject eObject,
252
	private Customization getCustomization(final EObject eObject,
199
			final ColumnDescription columnDescription) {
253
			final ColumnDescription columnDescription, final Rectangle rectangle) {
200
		// label column : customization on the EObject, defined on the EClass
254
		// label column : customization on the EObject, defined on the EClass
201
		// unary reference : customization on the EObject, defined on the EClass
255
		// unary reference : customization on the EObject, defined on the EClass
202
		// n-ary reference with a single element: customization on the EObject, defined on the EClass
256
		// n-ary reference with a single element: customization on the EObject,
257
		// defined on the EClass
203
		// n-ary reference (!= 1): no customization
258
		// n-ary reference (!= 1): no customization
204
		// attribute : customization on the EObject, defined on the EAttribute
259
		// attribute : customization on the EObject, defined on the EAttribute
205
260
Lines 278-285 Link Here
278
					(EClass) attribute.eContainer(), attribute.getName(), customizedEObject));
333
					(EClass) attribute.eContainer(), attribute.getName(), customizedEObject));
279
		} else {
334
		} else {
280
			customization.setLabel(this.customizationEngine.getTypeLabel(customizedEObject));
335
			customization.setLabel(this.customizationEngine.getTypeLabel(customizedEObject));
281
			customization.setInstanceIcon(this.customizationEngine.getTypeIcon(customizedEObject,
336
282
					customizedEObject.eClass()));
337
			// Facet icon customization
338
			Image facetIcon = null;
339
			for (final Facet facet : this.natTableWidget.getFacetContext().getFacets(
340
					customizedEObject)) {
341
				facetIcon = this.customizationEngine.getFacetMainIcon(customizedEObject, facet);
342
				if (facetIcon != null) {
343
					// first one wins
344
					break;
345
				}
346
			}
347
			if (facetIcon != null) {
348
				customization.setInstanceIcon(facetIcon);
349
			} else {
350
				customization.setInstanceIcon(this.customizationEngine.getTypeIcon(
351
						customizedEObject, customizedEObject.eClass()));
352
			}
283
			customization.setBackground(this.customizationEngine
353
			customization.setBackground(this.customizationEngine
284
					.getTypeBackgroundColor(customizedEObject));
354
					.getTypeBackgroundColor(customizedEObject));
285
			customization.setForeground(this.customizationEngine.getTypeColor(customizedEObject));
355
			customization.setForeground(this.customizationEngine.getTypeColor(customizedEObject));
Lines 289-294 Link Here
289
					customizedEObject.eClass(), customizedEObject));
359
					customizedEObject.eClass(), customizedEObject));
290
			customization.setStruckthrough(this.customizationEngine.isTypeStruckthrough(
360
			customization.setStruckthrough(this.customizationEngine.isTypeStruckthrough(
291
					customizedEObject.eClass(), customizedEObject));
361
					customizedEObject.eClass(), customizedEObject));
362
363
			List<FacetToPaint> facetsToPaint = CustomTreePainter.getFacetsToPaintFor(
364
					customizedEObject, 0, rectangle.width, 0, rectangle.height, rectangle.width,
365
					this.customizationEngine, this.natTableWidget.getFacetContext());
366
			customization.setFacetsToPaint(facetsToPaint);
367
292
		}
368
		}
293
		return customization;
369
		return customization;
294
	}
370
	}
(-)src/org/eclipse/emf/facet/widgets/nattable/painter/Customization.java (+16 lines)
Lines 11-16 Link Here
11
 *******************************************************************************/
11
 *******************************************************************************/
12
package org.eclipse.emf.facet.widgets.nattable.painter;
12
package org.eclipse.emf.facet.widgets.nattable.painter;
13
13
14
import java.util.Collections;
15
import java.util.List;
16
17
import org.eclipse.emf.facet.infra.browser.uicore.internal.FacetToPaint;
14
import org.eclipse.swt.graphics.Color;
18
import org.eclipse.swt.graphics.Color;
15
import org.eclipse.swt.graphics.Font;
19
import org.eclipse.swt.graphics.Font;
16
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Image;
Lines 23-28 Link Here
23
	private Font font;
27
	private Font font;
24
	private boolean underlined;
28
	private boolean underlined;
25
	private boolean struckthrough;
29
	private boolean struckthrough;
30
	private List<FacetToPaint> facetsToPaint;
26
31
27
	public Customization() {
32
	public Customization() {
28
	}
33
	}
Lines 82-85 Link Here
82
	public void setLabel(final String label) {
87
	public void setLabel(final String label) {
83
		this.label = label;
88
		this.label = label;
84
	}
89
	}
90
91
	public List<FacetToPaint> getFacetsToPaint() {
92
		if (this.facetsToPaint == null) {
93
			return Collections.emptyList();
94
		}
95
		return this.facetsToPaint;
96
	}
97
98
	public void setFacetsToPaint(final List<FacetToPaint> facetsToPaint) {
99
		this.facetsToPaint = facetsToPaint;
100
	}
85
}
101
}
(-)src/org/eclipse/emf/facet/infra/browser/uicore/internal/CustomTreePainter.java (-62 / +18 lines)
Lines 26-31 Link Here
26
import org.eclipse.emf.facet.infra.browser.uicore.internal.util.ImageProvider;
26
import org.eclipse.emf.facet.infra.browser.uicore.internal.util.ImageProvider;
27
import org.eclipse.emf.facet.infra.common.core.logging.Logger;
27
import org.eclipse.emf.facet.infra.common.core.logging.Logger;
28
import org.eclipse.emf.facet.infra.facet.Facet;
28
import org.eclipse.emf.facet.infra.facet.Facet;
29
import org.eclipse.emf.facet.infra.facet.core.FacetContext;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.events.MouseEvent;
31
import org.eclipse.swt.events.MouseEvent;
31
import org.eclipse.swt.events.MouseMoveListener;
32
import org.eclipse.swt.events.MouseMoveListener;
Lines 140-146 Link Here
140
			int maxX = this.fTree.getClientArea().width
141
			int maxX = this.fTree.getClientArea().width
141
					+ this.fTree.getHorizontalBar().getSelection();
142
					+ this.fTree.getHorizontalBar().getSelection();
142
			List<FacetToPaint> facetsToPaint = getFacetsToPaintFor(eObject, event.x, event.width,
143
			List<FacetToPaint> facetsToPaint = getFacetsToPaintFor(eObject, event.x, event.width,
143
					event.y, event.height, maxX);
144
					event.y, event.height, maxX,
145
					this.appearanceConfiguration.getCustomizationEngine(),
146
					this.appearanceConfiguration.getFacetContext());
144
			if (!facetsToPaint.isEmpty()) {
147
			if (!facetsToPaint.isEmpty()) {
145
				Rectangle lastFacetBounds = facetsToPaint.get(facetsToPaint.size() - 1).getBounds();
148
				Rectangle lastFacetBounds = facetsToPaint.get(facetsToPaint.size() - 1).getBounds();
146
				event.width = lastFacetBounds.x + lastFacetBounds.width;
149
				event.width = lastFacetBounds.x + lastFacetBounds.width;
Lines 199-251 Link Here
199
				- shortcutIcon.getBounds().height - 1);
202
				- shortcutIcon.getBounds().height - 1);
200
	}
203
	}
201
204
202
	public class FacetToPaint {
203
		private static final int INITIAL_ALPHA = 255;
204
		private final Rectangle bounds;
205
		private final Facet facet;
206
		private int alpha = CustomTreePainter.FacetToPaint.INITIAL_ALPHA;
207
		private final Rectangle itemBounds;
208
		private final Image image;
209
		private final boolean overlay;
210
211
		public FacetToPaint(final Rectangle bounds, final Rectangle itemBounds, final Facet facet,
212
				final Image image, final boolean overlay) {
213
			this.bounds = bounds;
214
			this.itemBounds = itemBounds;
215
			this.facet = facet;
216
			this.image = image;
217
			this.overlay = overlay;
218
		}
219
220
		public Rectangle getBounds() {
221
			return this.bounds;
222
		}
223
224
		public Rectangle getItemBounds() {
225
			return this.itemBounds;
226
		}
227
228
		public Facet getFacet() {
229
			return this.facet;
230
		}
231
232
		public Image getImage() {
233
			return this.image;
234
		}
235
236
		public boolean isOverlay() {
237
			return this.overlay;
238
		}
239
240
		public void setAlpha(final int alpha) {
241
			this.alpha = alpha;
242
		}
243
244
		public int getAlpha() {
245
			return this.alpha;
246
		}
247
	}
248
249
	/**
205
	/**
250
	 * @param eObject
206
	 * @param eObject
251
	 *            the model element for which facets are to be painted
207
	 *            the model element for which facets are to be painted
Lines 261-268 Link Here
261
	 *            the maximum visible offset in the tree
217
	 *            the maximum visible offset in the tree
262
	 * @return a list of facets to paint
218
	 * @return a list of facets to paint
263
	 */
219
	 */
264
	public List<CustomTreePainter.FacetToPaint> getFacetsToPaintFor(final EObject eObject,
220
	public static List<FacetToPaint> getFacetsToPaintFor(final EObject eObject, final int posX,
265
			final int posX, final int width, final int posY, final int height, final int maxX) {
221
			final int width, final int posY, final int height, final int maxX,
222
			final CustomizationEngine customizationEngine, final FacetContext facetContext) {
266
		final int rightX = posX + width;
223
		final int rightX = posX + width;
267
		final int margin = 8;
224
		final int margin = 8;
268
		int offset = margin;
225
		int offset = margin;
Lines 272-285 Link Here
272
		final int overlayIconWidth = 8;
229
		final int overlayIconWidth = 8;
273
		final int overlayIconHeight = 8;
230
		final int overlayIconHeight = 8;
274
231
275
		List<CustomTreePainter.FacetToPaint> facetsToPaint = new ArrayList<CustomTreePainter.FacetToPaint>();
232
		List<FacetToPaint> facetsToPaint = new ArrayList<FacetToPaint>();
276
233
277
		int lastX = 0;
234
		int lastX = 0;
278
235
279
		final CustomizationEngine customizationEngine = this.appearanceConfiguration
280
				.getCustomizationEngine();
281
		Rectangle itemBounds = new Rectangle(posX, posY, width, height);
236
		Rectangle itemBounds = new Rectangle(posX, posY, width, height);
282
		for (final Facet facet : this.appearanceConfiguration.getFacetContext().getFacets(eObject)) {
237
		for (final Facet facet : facetContext.getFacets(eObject)) {
283
			OverlayIconImageInfo facetOverlayIcon = customizationEngine.getFacetOverlayIcon(
238
			OverlayIconImageInfo facetOverlayIcon = customizationEngine.getFacetOverlayIcon(
284
					eObject, facet);
239
					eObject, facet);
285
			if (facetOverlayIcon != null) {
240
			if (facetOverlayIcon != null) {
Lines 311-320 Link Here
311
266
312
		if (lastX > maxX) {
267
		if (lastX > maxX) {
313
			int shift = lastX - maxX;
268
			int shift = lastX - maxX;
314
			ListIterator<CustomTreePainter.FacetToPaint> facetsToPaintIterator = facetsToPaint
269
			ListIterator<FacetToPaint> facetsToPaintIterator = facetsToPaint.listIterator();
315
					.listIterator();
316
			while (facetsToPaintIterator.hasNext()) {
270
			while (facetsToPaintIterator.hasNext()) {
317
				CustomTreePainter.FacetToPaint facetToPaint = facetsToPaintIterator.next();
271
				FacetToPaint facetToPaint = facetsToPaintIterator.next();
318
				if (!facetToPaint.isOverlay()) {
272
				if (!facetToPaint.isOverlay()) {
319
					facetToPaint.getBounds().x -= shift;
273
					facetToPaint.getBounds().x -= shift;
320
					final int minVisibleText = 50;
274
					final int minVisibleText = 50;
Lines 339-346 Link Here
339
		return facetsToPaint;
293
		return facetsToPaint;
340
	}
294
	}
341
295
342
	private Point getOverlayIconOffset(final OverlayIconImageInfo facetOverlayIcon) {
296
	public static Point getOverlayIconOffset(final OverlayIconImageInfo facetOverlayIcon) {
343
		final int step = 8;
297
		final int step = 8;
298
		// with a (step×3)×(step×3) grid
344
		switch (facetOverlayIcon.getIconPosition()) {
299
		switch (facetOverlayIcon.getIconPosition()) {
345
		case TopLeft:
300
		case TopLeft:
346
			return new Point(0, 0);
301
			return new Point(0, 0);
Lines 366-373 Link Here
366
			final EObject eObject = modelElementItem.getEObject();
321
			final EObject eObject = modelElementItem.getEObject();
367
			int maxX = this.fTree.getClientArea().width
322
			int maxX = this.fTree.getClientArea().width
368
					+ this.fTree.getHorizontalBar().getSelection();
323
					+ this.fTree.getHorizontalBar().getSelection();
369
			List<CustomTreePainter.FacetToPaint> facetsToPaint = getFacetsToPaintFor(eObject,
324
			List<FacetToPaint> facetsToPaint = getFacetsToPaintFor(eObject, event.x, event.width,
370
					event.x, event.width, event.y, event.height, maxX);
325
					event.y, event.height, maxX,
326
					this.appearanceConfiguration.getCustomizationEngine(),
327
					this.appearanceConfiguration.getFacetContext());
371
328
372
			if (facetsToPaint.isEmpty()) {
329
			if (facetsToPaint.isEmpty()) {
373
				// enable default tooltip
330
				// enable default tooltip
Lines 407-414 Link Here
407
		}
364
		}
408
	}
365
	}
409
366
410
	private boolean hoveringOnTextLeftOfFacets(
367
	private boolean hoveringOnTextLeftOfFacets(final List<FacetToPaint> facetsToPaint) {
411
			final List<CustomTreePainter.FacetToPaint> facetsToPaint) {
412
		if (facetsToPaint.size() == 0) {
368
		if (facetsToPaint.size() == 0) {
413
			return false;
369
			return false;
414
		}
370
		}
(-)src/org/eclipse/emf/facet/infra/browser/uicore/internal/FacetToPaint.java (+62 lines)
Line 0 Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009, 2010 Mia-Software.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    Nicolas Bros (Mia-Software) - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.emf.facet.infra.browser.uicore.internal;
12
13
import org.eclipse.emf.facet.infra.facet.Facet;
14
import org.eclipse.swt.graphics.Image;
15
import org.eclipse.swt.graphics.Rectangle;
16
17
public class FacetToPaint {
18
	private static final int INITIAL_ALPHA = 255;
19
	private final Rectangle bounds;
20
	private final Facet facet;
21
	private int alpha = FacetToPaint.INITIAL_ALPHA;
22
	private final Rectangle itemBounds;
23
	private final Image image;
24
	private final boolean overlay;
25
26
	public FacetToPaint(final Rectangle bounds, final Rectangle itemBounds, final Facet facet,
27
			final Image image, final boolean overlay) {
28
		this.bounds = bounds;
29
		this.itemBounds = itemBounds;
30
		this.facet = facet;
31
		this.image = image;
32
		this.overlay = overlay;
33
	}
34
35
	public Rectangle getBounds() {
36
		return this.bounds;
37
	}
38
39
	public Rectangle getItemBounds() {
40
		return this.itemBounds;
41
	}
42
43
	public Facet getFacet() {
44
		return this.facet;
45
	}
46
47
	public Image getImage() {
48
		return this.image;
49
	}
50
51
	public boolean isOverlay() {
52
		return this.overlay;
53
	}
54
55
	public void setAlpha(final int alpha) {
56
		this.alpha = alpha;
57
	}
58
59
	public int getAlpha() {
60
		return this.alpha;
61
	}
62
}

Return to bug 332010