Remove all existing @since annotations
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / uml2sd / handlers / ShowNodeStart.java
CommitLineData
73005152 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
73005152
BH
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
c8422608
AM
7 *
8 * Contributors:
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
73005152 11 **********************************************************************/
c8422608 12
2bdf0193 13package org.eclipse.tracecompass.tmf.ui.views.uml2sd.handlers;
73005152
BH
14
15import java.util.Iterator;
16
73005152
BH
17import org.eclipse.jface.viewers.ISelection;
18import org.eclipse.jface.viewers.ISelectionProvider;
19import org.eclipse.jface.viewers.StructuredSelection;
2bdf0193
AM
20import org.eclipse.tracecompass.internal.tmf.ui.Activator;
21import org.eclipse.tracecompass.internal.tmf.ui.ITmfImageConstants;
22import org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDView;
23import org.eclipse.tracecompass.tmf.ui.views.uml2sd.SDWidget;
24import org.eclipse.tracecompass.tmf.ui.views.uml2sd.core.GraphNode;
73005152
BH
25
26/**
df0b8ff4 27 * Action class implementation to show end of a graph node.
c8422608 28 *
73005152
BH
29 * @author sveyrier
30 */
cab6c8ff 31public class ShowNodeStart extends BaseSDAction {
73005152
BH
32
33 // ------------------------------------------------------------------------
34 // Constructors
35 // ------------------------------------------------------------------------
11252342 36
df0b8ff4
BH
37 /**
38 * Default constructor
39 */
73005152
BH
40 public ShowNodeStart() {
41 this(null);
42 }
df0b8ff4
BH
43
44 /**
45 * Constructor
c8422608 46 *
11252342
AM
47 * @param view
48 * The sequence diagram view reference
df0b8ff4 49 */
cab6c8ff
BH
50 public ShowNodeStart(SDView view) {
51 super(view);
8fd82db5 52 setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_NODE_START));
73005152
BH
53 }
54
55 // ------------------------------------------------------------------------
df0b8ff4 56 // Methods
73005152 57 // ------------------------------------------------------------------------
11252342
AM
58
59 @Override
73005152 60 public void run() {
cab6c8ff 61 if (getView() == null) {
73005152 62 return;
df0b8ff4
BH
63 }
64
cab6c8ff 65 SDWidget sdWidget = getView().getSDWidget();
73005152
BH
66
67 if (sdWidget == null) {
68 return;
69 }
df0b8ff4 70
73005152
BH
71 ISelectionProvider selProvider = sdWidget.getSelectionProvider();
72 ISelection sel = selProvider.getSelection();
73 Object selectedNode = null;
5b5b7df5 74 Iterator<Object> it = ((StructuredSelection) sel).iterator();
df0b8ff4 75 while (it.hasNext()) {
73005152 76 selectedNode = it.next();
df0b8ff4 77 }
73005152
BH
78 if (selectedNode != null) {
79 GraphNode node = (GraphNode) selectedNode;
df0b8ff4 80 if (node.getX() * sdWidget.getZoomFactor() < sdWidget.getContentsX() + sdWidget.getVisibleWidth() / 2) {
73005152 81 sdWidget.ensureVisible(Math.round(node.getX() * sdWidget.getZoomFactor() - sdWidget.getVisibleWidth() / (float) 2), Math.round(node.getY() * sdWidget.getZoomFactor()));
df0b8ff4 82 } else {
73005152 83 sdWidget.ensureVisible(Math.round(node.getX() * sdWidget.getZoomFactor() + sdWidget.getVisibleWidth() / (float) 2), Math.round(node.getY() * sdWidget.getZoomFactor()));
df0b8ff4 84 }
73005152
BH
85 }
86 }
73005152 87}
This page took 0.086338 seconds and 5 git commands to generate.