| 1 | /********************************************************************** |
| 2 | * Copyright (c) 2005, 2013 IBM Corporation, Ericsson |
| 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 | * IBM - Initial API and implementation |
| 10 | * Bernd Hufmann - Updated for TMF |
| 11 | **********************************************************************/ |
| 12 | |
| 13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers; |
| 14 | |
| 15 | import org.eclipse.jface.action.Action; |
| 16 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView; |
| 17 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDWidget; |
| 18 | |
| 19 | /** |
| 20 | * Action class implementation to move left in the sequence diagram view within a page. |
| 21 | * |
| 22 | * @version 1.0 |
| 23 | * @author sveyrier |
| 24 | * |
| 25 | */ |
| 26 | public class MoveSDLeft extends Action { |
| 27 | |
| 28 | // ------------------------------------------------------------------------ |
| 29 | // Constants |
| 30 | // ------------------------------------------------------------------------ |
| 31 | /** |
| 32 | * The action ID. |
| 33 | */ |
| 34 | public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveSDLeft"; //$NON-NLS-1$ |
| 35 | |
| 36 | // ------------------------------------------------------------------------ |
| 37 | // Attributes |
| 38 | // ------------------------------------------------------------------------ |
| 39 | /** |
| 40 | * The sequence diagram view reference. |
| 41 | */ |
| 42 | protected SDView fView = null; |
| 43 | |
| 44 | // ------------------------------------------------------------------------ |
| 45 | // Constructors |
| 46 | // ------------------------------------------------------------------------ |
| 47 | /** |
| 48 | * Default constructor |
| 49 | */ |
| 50 | public MoveSDLeft(){ |
| 51 | this(null); |
| 52 | } |
| 53 | |
| 54 | /** |
| 55 | * Constructor |
| 56 | * |
| 57 | * @param view a sequence diagram view reference |
| 58 | */ |
| 59 | public MoveSDLeft(SDView view) { |
| 60 | super(); |
| 61 | setId(ID); |
| 62 | setActionDefinitionId(ID); |
| 63 | fView = view; |
| 64 | } |
| 65 | |
| 66 | // ------------------------------------------------------------------------ |
| 67 | // Operations |
| 68 | // ------------------------------------------------------------------------ |
| 69 | |
| 70 | @Override |
| 71 | public void run() { |
| 72 | |
| 73 | if (fView == null) { |
| 74 | return; |
| 75 | } |
| 76 | |
| 77 | SDWidget viewer = fView.getSDWidget(); |
| 78 | if (viewer != null) { |
| 79 | viewer.scrollBy(-viewer.getVisibleWidth(), 0); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | /** |
| 84 | * Sets the active SD view. |
| 85 | * |
| 86 | * @param view The SD view. |
| 87 | */ |
| 88 | public void setView(SDView view) { |
| 89 | fView = view; |
| 90 | } |
| 91 | } |