Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
df0b8ff4 BH |
2 | * Copyright (c) 2005, 2008 IBM Corporation and others. |
3 | * Copyright (c) 2011, 2012 Ericsson. | |
4 | * | |
73005152 BH |
5 | * All rights reserved. This program and the accompanying materials |
6 | * are made available under the terms of the Eclipse Public License v1.0 | |
7 | * which accompanies this distribution, and is available at | |
8 | * http://www.eclipse.org/legal/epl-v10.html | |
73005152 BH |
9 | * |
10 | * Contributors: | |
11 | * IBM - Initial API and implementation | |
12 | * Bernd Hufmann - Updated for TMF | |
13 | **********************************************************************/ | |
14 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers; | |
15 | ||
16 | import org.eclipse.jface.action.Action; | |
d34665f9 FC |
17 | import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants; |
18 | import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin; | |
73005152 | 19 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView; |
df0b8ff4 | 20 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.dialogs.SearchFilterDialog; |
73005152 BH |
21 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages; |
22 | import org.eclipse.swt.SWT; | |
23 | ||
24 | /** | |
df0b8ff4 BH |
25 | * Action class implementation for 'Finding' of messages/lifelines. |
26 | * | |
27 | * @version 1.0 | |
73005152 BH |
28 | * @author sveyrier |
29 | * | |
30 | */ | |
31 | public class OpenSDFindDialog extends Action { | |
df0b8ff4 | 32 | |
73005152 | 33 | // ------------------------------------------------------------------------ |
df0b8ff4 | 34 | // Constants |
73005152 | 35 | // ------------------------------------------------------------------------ |
df0b8ff4 BH |
36 | /** |
37 | * The action ID. | |
38 | */ | |
73005152 | 39 | public final static String ID = "org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.sdFind"; //$NON-NLS-1$ |
df0b8ff4 BH |
40 | /** |
41 | * The action definition ID. | |
42 | */ | |
73005152 | 43 | public final static String ACTION_DEFINITION_ID = "org.eclipse.ui.edit.findReplace"; //$NON-NLS-1$ |
df0b8ff4 BH |
44 | |
45 | // ------------------------------------------------------------------------ | |
46 | // Attributes | |
47 | // ------------------------------------------------------------------------ | |
48 | /** | |
49 | * The sequence diagram view reference | |
50 | */ | |
51 | protected SDView fView; | |
73005152 BH |
52 | |
53 | // ------------------------------------------------------------------------ | |
54 | // Constructors | |
55 | // ------------------------------------------------------------------------ | |
df0b8ff4 BH |
56 | /** |
57 | * Default constructor | |
58 | */ | |
73005152 BH |
59 | public OpenSDFindDialog() { |
60 | this(null); | |
61 | } | |
df0b8ff4 BH |
62 | |
63 | /** | |
64 | * Constructor | |
65 | * | |
66 | * @param theView The view reference | |
67 | */ | |
73005152 BH |
68 | public OpenSDFindDialog(SDView theView) { |
69 | super(SDMessages._41); | |
70 | setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ)); | |
71 | setId(ID); | |
72 | setActionDefinitionId(ACTION_DEFINITION_ID); | |
73 | setToolTipText(SDMessages._41); | |
74 | fView = theView; | |
75 | } | |
76 | ||
77 | // ------------------------------------------------------------------------ | |
df0b8ff4 | 78 | // Methods |
73005152 BH |
79 | // ------------------------------------------------------------------------ |
80 | /* | |
81 | * (non-Javadoc) | |
82 | * @see org.eclipse.jface.action.Action#run() | |
83 | */ | |
84 | @Override | |
85 | public void run() { | |
86 | if (fView == null) { | |
87 | return; | |
88 | } | |
89 | ||
90 | // Disable action while search is ongoing | |
91 | this.setEnabled(false); | |
92 | ||
93 | try { | |
94 | if ((fView.getExtendedFindProvider() != null) && (fView.getExtendedFindProvider().getFindAction() != null)) { | |
95 | fView.getExtendedFindProvider().getFindAction().run(); | |
96 | } else if (fView.getSDFindProvider() != null) { | |
97 | SearchFilterDialog dialog = new SearchFilterDialog(fView, fView.getSDFindProvider(), false, SWT.NORMAL); | |
98 | dialog.open(); | |
99 | } | |
df0b8ff4 | 100 | } finally { |
73005152 BH |
101 | // Enable action after finishing the search |
102 | this.setEnabled(true); | |
103 | } | |
104 | } | |
105 | ||
106 | /** | |
107 | * Sets the active SD view. | |
df0b8ff4 | 108 | * |
73005152 BH |
109 | * @param view The SD view. |
110 | */ | |
111 | public void setView(SDView view) { | |
112 | fView = view; | |
113 | } | |
114 | } |