Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ef42cec14d7c8f04f89954af27359243f833a612 (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
/*****************************************************************************
 * Copyright (c) 2018 Christian W. Damus, CEA LIST, and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *   Christian W. Damus - Initial API and implementation
 *
 *****************************************************************************/

package org.eclipse.papyrus.uml.diagram.sequence.edit.parts;

import java.util.Optional;

import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.uml2.uml.MessageEnd;
import org.eclipse.uml2.uml.TimeObservation;

/**
 * Custom edit-part for {@code TimeObservation} as a border node.
 */
public class CustomTimeObservationBorderNodeEditPart extends TimeObservationBorderNodeEditPart implements ITimeElementBorderNodeEditPart {

	private final TimeElementEditPartHelper helper;

	/**
	 * Initializes me with my view model.
	 *
	 * @param view
	 *            my view model
	 */
	public CustomTimeObservationBorderNodeEditPart(View view) {
		super(view);

		helper = new TimeElementEditPartHelper(this, this::getMessageEnd);
	}

	@Override
	protected void refreshBounds() {
		if (!helper.refreshBounds(getBorderItemLocator())) {
			super.refreshBounds();
		}
	}

	@Override
	public Optional<MessageEnd> getMessageEnd() {
		return Optional.of(resolveSemanticElement())
				.filter(TimeObservation.class::isInstance)
				.map(TimeObservation.class::cast)
				.map(TimeObservation::getEvent)
				.filter(MessageEnd.class::isInstance)
				.map(MessageEnd.class::cast);
	}

}

Back to the top