Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: a3718d020d0049ee83c5012224092d8815c5f074 (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
/*****************************************************************************
 * 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:
 *   Atos Origin - Initial API and implementation
 *   Arthur Daussy - Bug 354622 - [ActivityDiagram] Object Flows selection prevent selecting other close elements.
 *   Céline Janssens (ALL4TEC) celine.janssens@all4tec.net - Bug 440230 - Margin Label
 *
 *****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.common.figure.node;

import org.eclipse.draw2d.MarginBorder;
import org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel;
import org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel;
import org.eclipse.swt.graphics.Image;

/**
 * This correct the bug where invisible label can be selected
 *
 * @author arthur daussy
 */
public class PapyrusWrappingLabel extends WrappingLabel implements IPapyrusWrappingLabel{

	/**
	 * Constructor.
	 *
	 * @param image
	 */
	public PapyrusWrappingLabel(Image image) {
		super(image);
	}

	/**
	 * Constructor.
	 *
	 * @param text
	 */
	public PapyrusWrappingLabel(String text) {
		super(text);
	}

	/**
	 * Constructor.
	 *
	 */
	public PapyrusWrappingLabel() {
		super();
	}

	/**
	 * Constructor.
	 *
	 * @param text
	 * @param image
	 */
	public PapyrusWrappingLabel(String text, Image image) {
		super(text, image);
	}

	/**
	 * Bug 354622 - [ActivityDiagram] Object Flows selection prevent selecting other close elements.
	 * On this bug bug come from that invisible label return true containsPoint(int, int) even if there invisible
	 *
	 * This is a temporary fix until the real issue described in Bug 363362
	 * (https://bugs.eclipse.org/bugs/show_bug.cgi?id=363362) is fixed by GMF.
	 *
	 * @see org.eclipse.draw2d.Figure#containsPoint(int, int)
	 *
	 * @param x
	 * @param y
	 * @return
	 */
	@Override
	public boolean containsPoint(int x, int y) {
		if (isVisible()) {
			return super.containsPoint(x, y);
		}
		return false;
	}

	/**
	 * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel#setMarginLabel(int, int)
	 *
	 * @param xMargin Vertical margin
	 * @param yMargin Horizontal margin
	 */
	@Override
	public void setMarginLabel(int xMargin, int yMargin) {

		this.setMarginLabel(xMargin, yMargin , xMargin, yMargin);
		
	}

	/**
	 * @see org.eclipse.papyrus.infra.gmfdiag.common.figure.IPapyrusWrappingLabel#setMarginLabel(int, int, int, int)
	 *
	 * @param leftMargin
	 * @param topMargin
	 * @param rightMargin
	 * @param bottomMargin
	 */
	@Override
	public void setMarginLabel(int leftMargin, int topMargin, int rightMargin, int bottomMargin) {
		MarginBorder mb = new MarginBorder(topMargin, leftMargin, bottomMargin, rightMargin);
		this.setBorder(mb);
		repaint();
		revalidate();
		
	}
	
}

Back to the top