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