Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
c8422608 | 2 | * Copyright (c) 2005, 2012 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 | |
73005152 BH |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers; |
14 | ||
15 | import org.eclipse.jface.action.Action; | |
d34665f9 | 16 | import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants; |
8fd82db5 | 17 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
73005152 | 18 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView; |
df0b8ff4 | 19 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.SearchFilterDialog; |
73005152 BH |
20 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages; |
21 | import org.eclipse.swt.SWT; | |
22 | ||
23 | /** | |
df0b8ff4 | 24 | * Action class implementation for 'Finding' of messages/lifelines. |
c8422608 | 25 | * |
df0b8ff4 | 26 | * @version 1.0 |
73005152 | 27 | * @author sveyrier |
c8422608 | 28 | * |
73005152 BH |
29 | */ |
30 | public class OpenSDFindDialog extends Action { | |
c8422608 | 31 | |
73005152 | 32 | // ------------------------------------------------------------------------ |
df0b8ff4 | 33 | // Constants |
73005152 | 34 | // ------------------------------------------------------------------------ |
df0b8ff4 BH |
35 | /** |
36 | * The action ID. | |
37 | */ | |
73005152 | 38 | public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.sdFind"; //$NON-NLS-1$ |
df0b8ff4 BH |
39 | /** |
40 | * The action definition ID. | |
41 | */ | |
73005152 | 42 | public final static String ACTION_DEFINITION_ID = "org.eclipse.ui.edit.findReplace"; //$NON-NLS-1$ |
df0b8ff4 BH |
43 | |
44 | // ------------------------------------------------------------------------ | |
45 | // Attributes | |
46 | // ------------------------------------------------------------------------ | |
47 | /** | |
48 | * The sequence diagram view reference | |
49 | */ | |
50 | protected SDView fView; | |
73005152 BH |
51 | |
52 | // ------------------------------------------------------------------------ | |
53 | // Constructors | |
54 | // ------------------------------------------------------------------------ | |
df0b8ff4 BH |
55 | /** |
56 | * Default constructor | |
57 | */ | |
73005152 BH |
58 | public OpenSDFindDialog() { |
59 | this(null); | |
60 | } | |
df0b8ff4 BH |
61 | |
62 | /** | |
c8422608 AM |
63 | * Constructor |
64 | * | |
eb63f5ff | 65 | * @param view The view reference |
df0b8ff4 | 66 | */ |
eb63f5ff | 67 | public OpenSDFindDialog(SDView view) { |
73005152 | 68 | super(SDMessages._41); |
8fd82db5 | 69 | setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ)); |
73005152 BH |
70 | setId(ID); |
71 | setActionDefinitionId(ACTION_DEFINITION_ID); | |
72 | setToolTipText(SDMessages._41); | |
eb63f5ff | 73 | fView = view; |
73005152 BH |
74 | } |
75 | ||
76 | // ------------------------------------------------------------------------ | |
df0b8ff4 | 77 | // Methods |
73005152 BH |
78 | // ------------------------------------------------------------------------ |
79 | /* | |
80 | * (non-Javadoc) | |
81 | * @see org.eclipse.jface.action.Action#run() | |
82 | */ | |
83 | @Override | |
84 | public void run() { | |
85 | if (fView == null) { | |
86 | return; | |
87 | } | |
c8422608 | 88 | |
73005152 BH |
89 | // Disable action while search is ongoing |
90 | this.setEnabled(false); | |
c8422608 | 91 | |
73005152 BH |
92 | try { |
93 | if ((fView.getExtendedFindProvider() != null) && (fView.getExtendedFindProvider().getFindAction() != null)) { | |
94 | fView.getExtendedFindProvider().getFindAction().run(); | |
95 | } else if (fView.getSDFindProvider() != null) { | |
96 | SearchFilterDialog dialog = new SearchFilterDialog(fView, fView.getSDFindProvider(), false, SWT.NORMAL); | |
97 | dialog.open(); | |
98 | } | |
df0b8ff4 | 99 | } finally { |
73005152 BH |
100 | // Enable action after finishing the search |
101 | this.setEnabled(true); | |
102 | } | |
103 | } | |
c8422608 | 104 | |
73005152 BH |
105 | /** |
106 | * Sets the active SD view. | |
c8422608 | 107 | * |
73005152 BH |
108 | * @param view The SD view. |
109 | */ | |
110 | public void setView(SDView view) { | |
111 | fView = view; | |
112 | } | |
113 | } |