0
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description:
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
package com.nokia.s60tools.appdep.ui.dialogs;
|
|
20 |
|
|
21 |
import java.io.IOException;
|
|
22 |
import java.util.HashMap;
|
|
23 |
import java.util.Map;
|
|
24 |
import java.util.Set;
|
|
25 |
|
|
26 |
import org.eclipse.jface.action.Action;
|
|
27 |
import org.eclipse.jface.action.IMenuListener;
|
|
28 |
import org.eclipse.jface.action.IMenuManager;
|
|
29 |
import org.eclipse.jface.action.MenuManager;
|
|
30 |
import org.eclipse.jface.action.Separator;
|
|
31 |
import org.eclipse.jface.dialogs.IDialogConstants;
|
|
32 |
import org.eclipse.jface.dialogs.TrayDialog;
|
|
33 |
import org.eclipse.swt.SWT;
|
|
34 |
import org.eclipse.swt.custom.BusyIndicator;
|
|
35 |
import org.eclipse.swt.events.ModifyEvent;
|
|
36 |
import org.eclipse.swt.events.ModifyListener;
|
|
37 |
import org.eclipse.swt.events.MouseEvent;
|
|
38 |
import org.eclipse.swt.events.MouseListener;
|
|
39 |
import org.eclipse.swt.events.SelectionEvent;
|
|
40 |
import org.eclipse.swt.events.SelectionListener;
|
|
41 |
import org.eclipse.swt.graphics.Color;
|
|
42 |
import org.eclipse.swt.layout.GridData;
|
|
43 |
import org.eclipse.swt.layout.GridLayout;
|
|
44 |
import org.eclipse.swt.widgets.Button;
|
|
45 |
import org.eclipse.swt.widgets.Combo;
|
|
46 |
import org.eclipse.swt.widgets.Composite;
|
|
47 |
import org.eclipse.swt.widgets.Control;
|
|
48 |
import org.eclipse.swt.widgets.Display;
|
|
49 |
import org.eclipse.swt.widgets.Group;
|
|
50 |
import org.eclipse.swt.widgets.Label;
|
|
51 |
import org.eclipse.swt.widgets.List;
|
|
52 |
import org.eclipse.swt.widgets.Menu;
|
|
53 |
import org.eclipse.swt.widgets.Shell;
|
|
54 |
import org.eclipse.swt.widgets.Text;
|
|
55 |
import org.eclipse.swt.widgets.Widget;
|
|
56 |
import org.eclipse.ui.IWorkbenchActionConstants;
|
|
57 |
|
|
58 |
import com.nokia.s60tools.appdep.AppDepHelpContextIDs;
|
|
59 |
import com.nokia.s60tools.appdep.core.AppDepSettings;
|
|
60 |
import com.nokia.s60tools.appdep.core.data.CacheDataManager;
|
|
61 |
import com.nokia.s60tools.appdep.core.data.ComponentParentNode;
|
|
62 |
import com.nokia.s60tools.appdep.core.data.ICacheDataManager;
|
|
63 |
import com.nokia.s60tools.appdep.core.model.AbstractFunctionData;
|
|
64 |
import com.nokia.s60tools.appdep.exceptions.CacheFileDoesNotExistException;
|
|
65 |
import com.nokia.s60tools.appdep.locatecomponent.SeekParentNodesService;
|
|
66 |
import com.nokia.s60tools.appdep.plugin.AppDepPlugin;
|
|
67 |
import com.nokia.s60tools.appdep.resources.Messages;
|
|
68 |
import com.nokia.s60tools.appdep.search.MatchType;
|
|
69 |
import com.nokia.s60tools.appdep.search.SearchConstants;
|
|
70 |
import com.nokia.s60tools.appdep.search.MatchType.MatchTypes;
|
|
71 |
import com.nokia.s60tools.appdep.search.SearchConstants.SearchType;
|
|
72 |
import com.nokia.s60tools.appdep.ui.actions.SelectAllFromListAction;
|
|
73 |
import com.nokia.s60tools.appdep.ui.actions.ShowMethodCallLocationsSearchDialogAction;
|
|
74 |
import com.nokia.s60tools.appdep.ui.utils.UiUtils;
|
|
75 |
import com.nokia.s60tools.appdep.ui.views.main.MainView;
|
|
76 |
import com.nokia.s60tools.appdep.util.AppDepConsole;
|
|
77 |
import com.nokia.s60tools.ui.ICopyActionHandler;
|
|
78 |
import com.nokia.s60tools.ui.IStringProvider;
|
|
79 |
import com.nokia.s60tools.ui.StringArrayClipboardCopyHandler;
|
|
80 |
import com.nokia.s60tools.ui.actions.CopyFromStringProviderToClipboardAction;
|
|
81 |
import com.nokia.s60tools.util.debug.DbgUtility;
|
|
82 |
|
|
83 |
/**
|
|
84 |
*
|
|
85 |
* Implements search dialog for fetching components or
|
|
86 |
* imported/exported functions.
|
|
87 |
*
|
|
88 |
* Usage example:
|
|
89 |
*
|
|
90 |
* <code>
|
|
91 |
* <pre>
|
|
92 |
*
|
|
93 |
* // Parent shell
|
|
94 |
* Shell sh = Display.getCurrent().getActiveShell()
|
|
95 |
*
|
|
96 |
* ComponentParentNode rootNode = view.getRootComponentNode();
|
|
97 |
* AppDepSearchDialog dlg = new AppDepSearchDialog(sh, SearchType.SEARCH_COMPONENTS, rootNode);
|
|
98 |
* dlg.create();
|
|
99 |
* dlg.open();
|
|
100 |
*
|
|
101 |
* </pre>
|
|
102 |
* </code>
|
|
103 |
*
|
|
104 |
* @see org.eclipse.jface.dialogs.Dialog
|
|
105 |
*/
|
|
106 |
public class AppDepSearchDialog extends TrayDialog implements SelectionListener,
|
|
107 |
ModifyListener,
|
|
108 |
IStringProvider{
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Tooltip shown to user when searching components. This is default message at start up when default values are selected from dialog.
|
|
112 |
*/
|
|
113 |
private static final String TOOLTIP_MSG_COMPONENT_QUERY = Messages.getString("AppDepSearchDialog.Tooltip_Msg_MatchTypeCombo_ComponentQuery"); //$NON-NLS-1$
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Tooltip shown to user when searching functions and 'StartsWith', 'EndsWith', or 'ExactMatch' is selected from math type selection combo box.
|
|
117 |
*/
|
|
118 |
private static final String TOOLTIP_MSG_USE_FUNC_BASE_NAME = Messages.getString("AppDepSearchDialog.Tooltip_Msg_MatchTypeCombo_FunctionQuery_UsingBaseName"); //$NON-NLS-1$
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Tooltip shown to user when searching functions and 'Contains', or 'RegularExpression' is selected from math type selection combo box.
|
|
122 |
*/
|
|
123 |
private static final String TOOLTIP_MSG_USE_COMPLETE_FUNC_NAME = Messages.getString("AppDepSearchDialog.Tooltip_Msg_MatchTypeCombo_FunctionQuery_UsingLongName"); //$NON-NLS-1$
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Maximum amount of data items that are reasonable to show in search result list without making user wait for too long time.
|
|
127 |
* In case maximum result size is exceeded, an informative message is shown for a user.
|
|
128 |
*/
|
|
129 |
private static final int MAX_RESULTS_SIZE = 30000;
|
|
130 |
|
|
131 |
//
|
|
132 |
// Private types
|
|
133 |
//
|
|
134 |
private Action actionCompPropertiesDataCopy;
|
|
135 |
private Action actionSelectAllFromList;
|
|
136 |
private Action actionImportShowMethodLoc;
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Match type is attached with description shown in the UI
|
|
140 |
*/
|
|
141 |
private class MatchTypeItem{
|
|
142 |
|
|
143 |
private final MatchTypes matchType;
|
|
144 |
private final String matchTypeDescription;
|
|
145 |
|
|
146 |
public MatchTypeItem(MatchTypes matchType, String matchTypeDescription){
|
|
147 |
this.matchType = matchType;
|
|
148 |
this.matchTypeDescription = matchTypeDescription;
|
|
149 |
|
|
150 |
}
|
|
151 |
|
|
152 |
/**
|
|
153 |
* @return the matchType
|
|
154 |
*/
|
|
155 |
public MatchTypes getMatchType() {
|
|
156 |
return matchType;
|
|
157 |
}
|
|
158 |
|
|
159 |
/**
|
|
160 |
* @return the matchTypeDescription
|
|
161 |
*/
|
|
162 |
public String getMatchTypeDescription() {
|
|
163 |
return matchTypeDescription;
|
|
164 |
}
|
|
165 |
|
|
166 |
}
|
|
167 |
|
|
168 |
/**
|
|
169 |
* Single result item object in search result list box.
|
|
170 |
*/
|
|
171 |
private class SearchResultItem{
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Component name
|
|
175 |
*/
|
|
176 |
private String componentName = null;
|
|
177 |
/**
|
|
178 |
* Function name
|
|
179 |
*/
|
|
180 |
private String functionName = null;
|
|
181 |
/**
|
|
182 |
* Function ordinal
|
|
183 |
*/
|
|
184 |
private String functionOrdinal = null;
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Constructor.
|
|
188 |
*/
|
|
189 |
public SearchResultItem(){
|
|
190 |
}
|
|
191 |
|
|
192 |
/**
|
|
193 |
* Gets component name.
|
|
194 |
* @return component name
|
|
195 |
*/
|
|
196 |
public String getComponentName() {
|
|
197 |
return componentName;
|
|
198 |
}
|
|
199 |
|
|
200 |
/**
|
|
201 |
* Sets component name
|
|
202 |
* @param componentName component name
|
|
203 |
*/
|
|
204 |
public void setComponentName(String componentName) {
|
|
205 |
this.componentName = componentName;
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Gets function name
|
|
210 |
* @return function name
|
|
211 |
*/
|
|
212 |
public String getFunctionName() {
|
|
213 |
return functionName;
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Sets function name
|
|
218 |
* @param functionName function name
|
|
219 |
*/
|
|
220 |
public void setFunctionName(String functionName) {
|
|
221 |
this.functionName = functionName;
|
|
222 |
}
|
|
223 |
|
|
224 |
/**
|
|
225 |
* Gets function ordinal.
|
|
226 |
* @return function ordinal
|
|
227 |
*/
|
|
228 |
public String getFunctionOrdinal() {
|
|
229 |
return functionOrdinal;
|
|
230 |
}
|
|
231 |
|
|
232 |
/**
|
|
233 |
* Sets function ordinal
|
|
234 |
* @param functionOrdinal function ordinal
|
|
235 |
*/
|
|
236 |
public void setFunctionOrdinal(String functionOrdinal) {
|
|
237 |
this.functionOrdinal = functionOrdinal;
|
|
238 |
}
|
|
239 |
|
|
240 |
}
|
|
241 |
|
|
242 |
//
|
|
243 |
// Constants
|
|
244 |
//
|
|
245 |
|
|
246 |
/**
|
|
247 |
* Default width.
|
|
248 |
*/
|
|
249 |
private static final int DEFAULT_WIDTH = 500;
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Default height.
|
|
253 |
*/
|
|
254 |
private static final int DEFAULT_HEIGHT = 350;
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Default column count for grid layouts.
|
|
258 |
*/
|
|
259 |
private final int DEFAULT_COLUMN_COUNT = 1;
|
|
260 |
|
|
261 |
/**
|
|
262 |
* Search button ID
|
|
263 |
*/
|
|
264 |
private static final int SEARCH_BUTTON_ID = IDialogConstants.CLIENT_ID + 1;
|
|
265 |
|
|
266 |
//
|
|
267 |
// Members
|
|
268 |
//
|
|
269 |
|
|
270 |
/**
|
|
271 |
* Possible match types available in search dialog.
|
|
272 |
*/
|
|
273 |
MatchTypeItem[] matchTypeItemArr = {
|
|
274 |
new MatchTypeItem(MatchTypes.CONTAINS, Messages.getString("AppDepSearchDialog.Contains_Msg")), //$NON-NLS-1$
|
|
275 |
new MatchTypeItem(MatchTypes.STARTS_WITH, Messages.getString("AppDepSearchDialog.Starts_With_Msg")), //$NON-NLS-1$
|
|
276 |
new MatchTypeItem(MatchTypes.ENDS_WITH, Messages.getString("AppDepSearchDialog.Ends_With_Msg")), //$NON-NLS-1$
|
|
277 |
new MatchTypeItem(MatchTypes.EXACT_MATCH, Messages.getString("AppDepSearchDialog.Exact_Match_Msg")), //$NON-NLS-1$
|
|
278 |
new MatchTypeItem(MatchTypes.REGULAR_EXPRESSION, Messages.getString("AppDepSearchDialog.Regular_Expression_Msg")) //$NON-NLS-1$
|
|
279 |
};
|
|
280 |
|
|
281 |
/**
|
|
282 |
* Search button starts the search.
|
|
283 |
*/
|
|
284 |
private Button searchButton;
|
|
285 |
|
|
286 |
/**
|
|
287 |
* Close button closes the dialog.
|
|
288 |
*/
|
|
289 |
private Button closeButton;
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Radio button for components search type
|
|
293 |
*/
|
|
294 |
Button searchForComponentsRadioBtn;
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Radio button for imported functions search type
|
|
298 |
*/
|
|
299 |
Button searchForImportedFunctionsRadioBtn;
|
|
300 |
|
|
301 |
/**
|
|
302 |
* Radio button for exported functions search type
|
|
303 |
*/
|
|
304 |
Button searchForExportedFunctionsRadioBtn;
|
|
305 |
|
|
306 |
/**
|
|
307 |
* Combobox for selecting the used match criterion.
|
|
308 |
*/
|
|
309 |
private Combo matchTypeSelCombo;
|
|
310 |
|
|
311 |
/**
|
|
312 |
* Background color for non-editable widgets.
|
|
313 |
*/
|
|
314 |
Color nonEditableFieldBkgColor;
|
|
315 |
|
|
316 |
/**
|
|
317 |
* Case sensitivity selection checkbox
|
|
318 |
*/
|
|
319 |
Button caseSensitivityOptionCheckbox;
|
|
320 |
/**
|
|
321 |
* Search string entering field.
|
|
322 |
*/
|
|
323 |
private Text searchStringTxtField;
|
|
324 |
|
|
325 |
/**
|
|
326 |
* List item for showing list of APIs
|
|
327 |
*/
|
|
328 |
private List searchResultList;
|
|
329 |
|
|
330 |
/**
|
|
331 |
* Search type used for actual search.
|
|
332 |
*/
|
|
333 |
private SearchType selectedSearchType;
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Reference to main view showing the actual data to search for.
|
|
337 |
*/
|
|
338 |
private final MainView view;
|
|
339 |
|
|
340 |
/**
|
|
341 |
* Map where is results in list as keys and component name, where result belongs as value.
|
|
342 |
* Really needed when results are exported or imported functions, and item in list is not really
|
|
343 |
* component name, but "<function name> [<component name>]". We need to know component name
|
|
344 |
* when double click is performed. Also we need to .
|
|
345 |
*/
|
|
346 |
private Map<String, SearchResultItem> resultsMap;
|
|
347 |
|
|
348 |
/**
|
|
349 |
* Keeps track if searchResultList contains data of imported functions.
|
|
350 |
*/
|
|
351 |
private boolean isImportedFunctionsSearched = false;
|
|
352 |
|
|
353 |
/**
|
|
354 |
* Constructor.
|
|
355 |
* @param parentShell Parent shell.
|
|
356 |
* @param searchType Default search type for this dialog instance at start-up.
|
|
357 |
* @param view Reference to main view.
|
|
358 |
*/
|
|
359 |
public AppDepSearchDialog(Shell parentShell, SearchConstants.SearchType searchType,
|
|
360 |
MainView view) {
|
|
361 |
super(parentShell);
|
|
362 |
int shellStyle = getShellStyle() | SWT.RESIZE;
|
|
363 |
setShellStyle(shellStyle);
|
|
364 |
this.selectedSearchType = searchType;
|
|
365 |
this.view = view;
|
|
366 |
}
|
|
367 |
|
|
368 |
/* (non-Javadoc)
|
|
369 |
* @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
|
|
370 |
*/
|
|
371 |
protected Control createDialogArea(Composite parent) {
|
|
372 |
|
|
373 |
// Creating dialog area composite
|
|
374 |
Composite dialogAreaComposite = (Composite) super.createDialogArea(parent);
|
|
375 |
//
|
|
376 |
// Defining dialog area layout
|
|
377 |
//
|
|
378 |
GridLayout gdl = new GridLayout(DEFAULT_COLUMN_COUNT, false);
|
|
379 |
GridData gd = new GridData(GridData.FILL_BOTH);
|
|
380 |
gd.widthHint = DEFAULT_WIDTH;
|
|
381 |
gd.heightHint = DEFAULT_HEIGHT;
|
|
382 |
gd.horizontalIndent = IDialogConstants.HORIZONTAL_MARGIN;
|
|
383 |
gd.verticalIndent = IDialogConstants.VERTICAL_MARGIN;
|
|
384 |
dialogAreaComposite.setLayout(gdl);
|
|
385 |
dialogAreaComposite.setLayoutData(gd);
|
|
386 |
// Allocating new color => should be dispose at close
|
|
387 |
nonEditableFieldBkgColor = getShell().getDisplay().getSystemColor(SWT.COLOR_WIDGET_LIGHT_SHADOW);
|
|
388 |
|
|
389 |
//
|
|
390 |
// Adding search label and search text box
|
|
391 |
//
|
|
392 |
Composite searchFieldsComposite = new Composite(dialogAreaComposite, SWT.NONE);
|
|
393 |
final int searchFieldsColumnCount = 2;
|
|
394 |
GridLayout gdlComposite = new GridLayout(searchFieldsColumnCount, false);
|
|
395 |
GridData gdComposite = new GridData(GridData.FILL_HORIZONTAL);
|
|
396 |
searchFieldsComposite.setLayout(gdlComposite);
|
|
397 |
searchFieldsComposite.setLayoutData(gdComposite);
|
|
398 |
|
|
399 |
// Search string label
|
|
400 |
Label searchStringTxtFieldLabel = new Label(searchFieldsComposite, SWT.HORIZONTAL);
|
|
401 |
searchStringTxtFieldLabel.setText(Messages.getString("AppDepSearchDialog.Search_String_Msg")); //$NON-NLS-1$
|
|
402 |
|
|
403 |
// Search string input fields
|
|
404 |
final int textFieldStyleBits = SWT.LEFT | SWT.SINGLE | SWT.BACKGROUND | SWT.BORDER;
|
|
405 |
searchStringTxtField = new Text(searchFieldsComposite, textFieldStyleBits);
|
|
406 |
searchStringTxtField.setLayoutData((new GridData(GridData.FILL_HORIZONTAL)));
|
|
407 |
searchStringTxtField.setEditable(true);
|
|
408 |
searchStringTxtField.addModifyListener(this);
|
|
409 |
searchStringTxtField.addSelectionListener(this);
|
|
410 |
|
|
411 |
//
|
|
412 |
// Search type
|
|
413 |
//
|
|
414 |
Group searchTypeGroup = new Group(dialogAreaComposite, SWT.SHADOW_NONE);
|
|
415 |
searchTypeGroup.setText(Messages.getString("AppDepSearchDialog.Search_For_Msg")); //$NON-NLS-1$
|
|
416 |
GridLayout gdl2 = new GridLayout(DEFAULT_COLUMN_COUNT , false);
|
|
417 |
GridData gd2 = new GridData(GridData.FILL_HORIZONTAL);
|
|
418 |
searchTypeGroup.setLayout(gdl2);
|
|
419 |
searchTypeGroup.setLayoutData(gd2);
|
|
420 |
|
|
421 |
// Component search radio button
|
|
422 |
searchForComponentsRadioBtn = new Button(searchTypeGroup, SWT.RADIO);
|
|
423 |
searchForComponentsRadioBtn.setText(Messages.getString("AppDepSearchDialog.Components_Msg")); //$NON-NLS-1$
|
|
424 |
searchForComponentsRadioBtn.addSelectionListener(this);
|
|
425 |
|
|
426 |
// Imported functions search radio button
|
|
427 |
searchForImportedFunctionsRadioBtn = new Button(searchTypeGroup, SWT.RADIO);
|
|
428 |
searchForImportedFunctionsRadioBtn.setText(Messages.getString("AppDepSearchDialog.Imported_Functions_Msg")); //$NON-NLS-1$
|
|
429 |
searchForImportedFunctionsRadioBtn.addSelectionListener(this);
|
|
430 |
|
|
431 |
// Exported functions search radio button
|
|
432 |
searchForExportedFunctionsRadioBtn = new Button(searchTypeGroup, SWT.RADIO);
|
|
433 |
searchForExportedFunctionsRadioBtn.setText(Messages.getString("AppDepSearchDialog.Exported_Functions_Msg")); //$NON-NLS-1$
|
|
434 |
searchForExportedFunctionsRadioBtn.addSelectionListener(this);
|
|
435 |
|
|
436 |
// Updating radio button selection states accoring currenlty selected search type
|
|
437 |
updateSearchTypeSelectionBtns();
|
|
438 |
|
|
439 |
//
|
|
440 |
// Options group
|
|
441 |
//
|
|
442 |
Group searchOptionsGroup = new Group(dialogAreaComposite, SWT.SHADOW_NONE);
|
|
443 |
searchOptionsGroup.setText(Messages.getString("AppDepSearchDialog.Options_Msg")); //$NON-NLS-1$
|
|
444 |
final int optionsGroupColumnCount = 3;
|
|
445 |
GridLayout gdl3 = new GridLayout(optionsGroupColumnCount, false);
|
|
446 |
GridData gd3 = new GridData(GridData.FILL_HORIZONTAL);
|
|
447 |
searchOptionsGroup.setLayout(gdl3);
|
|
448 |
searchOptionsGroup.setLayoutData(gd3);
|
|
449 |
|
|
450 |
// Match type combo label
|
|
451 |
Label matchTypeLabel = new Label(searchOptionsGroup, SWT.HORIZONTAL | SWT.LEFT);
|
|
452 |
matchTypeLabel.setText(Messages.getString("AppDepSearchDialog.Match_Type_Msg")); //$NON-NLS-1$
|
|
453 |
|
|
454 |
// Match type combo
|
|
455 |
matchTypeSelCombo = new Combo(searchOptionsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
|
|
456 |
matchTypeSelCombo.setText(Messages.getString("CacheGenerationOptionsWizardPage.ToolchainSelCombo_Text")); //$NON-NLS-1$
|
|
457 |
matchTypeSelCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
|
|
458 |
matchTypeSelCombo.setBackground(nonEditableFieldBkgColor);
|
|
459 |
|
|
460 |
for (int i = 0; i < matchTypeItemArr.length; i++) {
|
|
461 |
MatchTypeItem matchType = matchTypeItemArr[i];
|
|
462 |
matchTypeSelCombo.add(matchType.getMatchTypeDescription());
|
|
463 |
}
|
|
464 |
matchTypeSelCombo.select(0); // Selecting first match type by default
|
|
465 |
matchTypeSelCombo.addSelectionListener(this);
|
|
466 |
|
|
467 |
// Case sensitivity selection checbox
|
|
468 |
caseSensitivityOptionCheckbox = new Button(searchOptionsGroup, SWT.CHECK);
|
|
469 |
caseSensitivityOptionCheckbox.setText(Messages.getString("AppDepSearchDialog.Case_Sensitive_Msg")); //$NON-NLS-1$
|
|
470 |
caseSensitivityOptionCheckbox.setSelection(false);
|
|
471 |
caseSensitivityOptionCheckbox.addSelectionListener(this);
|
|
472 |
|
|
473 |
//
|
|
474 |
// Search Results
|
|
475 |
//
|
|
476 |
Label searchResultsLabel = new Label(dialogAreaComposite, SWT.HORIZONTAL);
|
|
477 |
searchResultsLabel.setText(Messages.getString("AppDepSearchDialog.Search_Results_Msg")); //$NON-NLS-1$
|
|
478 |
|
|
479 |
// List box for results
|
|
480 |
final int listBoxStyleBits = SWT.MULTI | SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL;
|
|
481 |
searchResultList = new List(dialogAreaComposite, listBoxStyleBits);
|
|
482 |
GridData listData1 = new GridData(GridData.FILL_BOTH);
|
|
483 |
searchResultList.setLayoutData(listData1);
|
|
484 |
searchResultList.setBackground(nonEditableFieldBkgColor);
|
|
485 |
|
|
486 |
// Listening for user selections
|
|
487 |
MouseListener searchResultListSelListener = new MouseListener(){
|
|
488 |
public void mouseDoubleClick(MouseEvent e) {
|
|
489 |
searchListObjectDoubleClicked();
|
|
490 |
}
|
|
491 |
public void mouseDown(MouseEvent e) {
|
|
492 |
// No action
|
|
493 |
}
|
|
494 |
public void mouseUp(MouseEvent e) {
|
|
495 |
// No action
|
|
496 |
}
|
|
497 |
};
|
|
498 |
searchResultList.addMouseListener(searchResultListSelListener);
|
|
499 |
|
|
500 |
// Listening for list selections to prevent using Show Method Call Location with multiple selections.
|
|
501 |
SelectionListener searchResultListSelectionListener = new SelectionListener(){
|
|
502 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
503 |
// No action
|
|
504 |
}
|
|
505 |
|
|
506 |
public void widgetSelected(SelectionEvent e) {
|
|
507 |
// Enabling action if needed.
|
|
508 |
boolean enableMethodCallLocationsAction = (searchResultList.getSelectionCount() == 1) && isImportedFunctionsSearched;
|
|
509 |
actionImportShowMethodLoc.setEnabled(enableMethodCallLocationsAction);
|
|
510 |
}
|
|
511 |
};
|
|
512 |
searchResultList.addSelectionListener(searchResultListSelectionListener);
|
|
513 |
|
|
514 |
//Adding context menu to list.
|
|
515 |
createActionMenu();
|
|
516 |
|
|
517 |
// Updating tooltip texts according the current selection status
|
|
518 |
updateToolTipTexts();
|
|
519 |
|
|
520 |
//
|
|
521 |
// And finally adding separator above the dialog button array
|
|
522 |
//
|
|
523 |
Label separatorLine = new Label(dialogAreaComposite, SWT.HORIZONTAL | SWT.SEPARATOR);
|
|
524 |
separatorLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
|
|
525 |
|
|
526 |
// Setting context help IDs
|
|
527 |
AppDepPlugin.setContextSensitiveHelpID(dialogAreaComposite, AppDepHelpContextIDs.APPDEP_SEARCH_DIALOG);
|
|
528 |
|
|
529 |
return dialogAreaComposite;
|
|
530 |
}
|
|
531 |
|
|
532 |
|
|
533 |
/**
|
|
534 |
* Creating context menu
|
|
535 |
*/
|
|
536 |
private void createActionMenu(){
|
|
537 |
|
|
538 |
createActions();
|
|
539 |
|
|
540 |
MenuManager menuMgr = new MenuManager("#PopupCopyMenu"); //$NON-NLS-1$
|
|
541 |
menuMgr.setRemoveAllWhenShown(true);
|
|
542 |
menuMgr.addMenuListener(new IMenuListener() {
|
|
543 |
public void menuAboutToShow(IMenuManager manager) {
|
|
544 |
AppDepSearchDialog.this.fillViewContextMenu(manager);
|
|
545 |
}
|
|
546 |
});
|
|
547 |
Menu menu = menuMgr.createContextMenu(searchResultList);
|
|
548 |
searchResultList.setMenu(menu);
|
|
549 |
|
|
550 |
}
|
|
551 |
|
|
552 |
/**
|
|
553 |
* Adds items to context menu.
|
|
554 |
* @param manager Menu manager
|
|
555 |
*/
|
|
556 |
private void fillViewContextMenu(IMenuManager manager) {
|
|
557 |
manager.add(actionCompPropertiesDataCopy);
|
|
558 |
manager.add(actionSelectAllFromList);
|
|
559 |
manager.add(actionImportShowMethodLoc);
|
|
560 |
// Other plug-ins can contribute there actions here
|
|
561 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
562 |
}
|
|
563 |
|
|
564 |
/**
|
|
565 |
* Creates actions for context menu
|
|
566 |
*/
|
|
567 |
private void createActions() {
|
|
568 |
|
|
569 |
StringArrayClipboardCopyHandler copyHandler = new StringArrayClipboardCopyHandler();
|
|
570 |
actionCompPropertiesDataCopy = new CopyFromStringProviderToClipboardAction(this /* listItemsViewer*/,
|
|
571 |
new ICopyActionHandler[]{ copyHandler }
|
|
572 |
);
|
|
573 |
actionSelectAllFromList = new SelectAllFromListAction(searchResultList);
|
|
574 |
actionImportShowMethodLoc = new ShowMethodCallLocationsSearchDialogAction(this, view);
|
|
575 |
}
|
|
576 |
|
|
577 |
/**
|
|
578 |
* Updates radio buttons states insided search type group
|
|
579 |
* according the current selection.
|
|
580 |
*/
|
|
581 |
private void updateSearchTypeSelectionBtns() {
|
|
582 |
if(selectedSearchType.equals(SearchType.SEARCH_COMPONENTS)){
|
|
583 |
searchForComponentsRadioBtn.setSelection(true);
|
|
584 |
}
|
|
585 |
else{
|
|
586 |
searchForComponentsRadioBtn.setSelection(false);
|
|
587 |
}
|
|
588 |
if(selectedSearchType.equals(SearchType.SEARCH_IMPORTED_FUNCTIONS)){
|
|
589 |
searchForImportedFunctionsRadioBtn.setSelection(true);
|
|
590 |
}
|
|
591 |
else{
|
|
592 |
searchForImportedFunctionsRadioBtn.setSelection(false);
|
|
593 |
}
|
|
594 |
if(selectedSearchType.equals(SearchType.SEARCH_EXPORTED_FUNCTION)){
|
|
595 |
searchForExportedFunctionsRadioBtn.setSelection(true);
|
|
596 |
}
|
|
597 |
else{
|
|
598 |
searchForExportedFunctionsRadioBtn.setSelection(false);
|
|
599 |
}
|
|
600 |
}
|
|
601 |
|
|
602 |
/* (non-Javadoc)
|
|
603 |
* @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
|
|
604 |
*/
|
|
605 |
protected void configureShell(Shell shell) {
|
|
606 |
super.configureShell(shell);
|
|
607 |
String dialogTopic = getDialogName();
|
|
608 |
shell.setText(dialogTopic);
|
|
609 |
}
|
|
610 |
|
|
611 |
/**
|
|
612 |
* Gets the dialog name.
|
|
613 |
* @return dialog name
|
|
614 |
*/
|
|
615 |
private String getDialogName() {
|
|
616 |
AppDepSettings st = AppDepSettings.getActiveSettings();
|
|
617 |
|
|
618 |
String currentlyUsedSDK = st.getCurrentlyUsedSdk().getSdkId();
|
|
619 |
String variant = st.getCurrentlyUsedTargetPlatformsAsString();
|
|
620 |
String build = st.getBuildType().getBuildTypeName();
|
|
621 |
String usedSDKInfo = currentlyUsedSDK + " - " + variant + " " +build;//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
|
|
622 |
String dialogTopic = Messages.getString("AppDepSearchDialog.Search_Msg") +" " +usedSDKInfo ;//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
623 |
return dialogTopic;
|
|
624 |
}
|
|
625 |
|
|
626 |
/* (non-Javadoc)
|
|
627 |
* @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse.swt.widgets.Composite)
|
|
628 |
*/
|
|
629 |
protected void createButtonsForButtonBar(Composite parent) {
|
|
630 |
// Creating Search button
|
|
631 |
searchButton = createButton(parent, SEARCH_BUTTON_ID, Messages.getString("AppDepSearchDialog.Search_Btn_Msg"),true); //$NON-NLS-1$
|
|
632 |
searchButton.setEnabled(false); // By default disabled
|
|
633 |
searchButton.addSelectionListener(this);
|
|
634 |
//Creating Close button
|
|
635 |
closeButton = createButton(parent, IDialogConstants.CLOSE_ID, IDialogConstants.CLOSE_LABEL, false);
|
|
636 |
closeButton.addSelectionListener(this);
|
|
637 |
}
|
|
638 |
|
|
639 |
/* (non-Javadoc)
|
|
640 |
* @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
|
|
641 |
*/
|
|
642 |
public void widgetDefaultSelected(SelectionEvent e) {
|
|
643 |
if(e.widget == searchStringTxtField){
|
|
644 |
// <code>widgetDefaultSelected</code> is typically called
|
|
645 |
// when ENTER is pressed in a single-line text.
|
|
646 |
}
|
|
647 |
}
|
|
648 |
|
|
649 |
/* (non-Javadoc)
|
|
650 |
* @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
|
|
651 |
*/
|
|
652 |
public void widgetSelected(SelectionEvent e) {
|
|
653 |
Widget w = e.widget;
|
|
654 |
|
|
655 |
if(w.equals(searchButton)){
|
|
656 |
Runnable performAPIDetailsQueryRunnable = new Runnable(){
|
|
657 |
public void run(){
|
|
658 |
performSearch();
|
|
659 |
}
|
|
660 |
};
|
|
661 |
|
|
662 |
// Showing busy cursor during operation
|
|
663 |
Display d = getShell().getDisplay();
|
|
664 |
BusyIndicator.showWhile(d, performAPIDetailsQueryRunnable);
|
|
665 |
}
|
|
666 |
else if(w.equals(closeButton)){
|
|
667 |
// Otherwise it must be Close button
|
|
668 |
this.close(); // close() method is overridden in the end of the file for making clean-up
|
|
669 |
return;
|
|
670 |
}
|
|
671 |
else if(w.equals(matchTypeSelCombo)){
|
|
672 |
int selIndex = matchTypeSelCombo.getSelectionIndex();
|
|
673 |
MatchTypes selType = matchTypeItemArr[selIndex].getMatchType();
|
|
674 |
// Setting enable/disable state of case sensitivity checkbox according the selected match type
|
|
675 |
if(selType.equals(MatchTypes.REGULAR_EXPRESSION)){
|
|
676 |
caseSensitivityOptionCheckbox.setEnabled(false);
|
|
677 |
caseSensitivityOptionCheckbox.setSelection(false);
|
|
678 |
}
|
|
679 |
else{
|
|
680 |
caseSensitivityOptionCheckbox.setEnabled(true);
|
|
681 |
}
|
|
682 |
}
|
|
683 |
else if(w.equals(searchForComponentsRadioBtn)){
|
|
684 |
selectedSearchType = SearchType.SEARCH_COMPONENTS;
|
|
685 |
updateSearchTypeSelectionBtns();
|
|
686 |
}
|
|
687 |
else if(w.equals(searchForImportedFunctionsRadioBtn)){
|
|
688 |
selectedSearchType = SearchType.SEARCH_IMPORTED_FUNCTIONS;
|
|
689 |
updateSearchTypeSelectionBtns();
|
|
690 |
}
|
|
691 |
else if(w.equals(searchForExportedFunctionsRadioBtn)){
|
|
692 |
selectedSearchType = SearchType.SEARCH_EXPORTED_FUNCTION;
|
|
693 |
updateSearchTypeSelectionBtns();
|
|
694 |
}
|
|
695 |
|
|
696 |
// Updating tooltip texts according the current selection status
|
|
697 |
// This must be called here because selected search type has
|
|
698 |
// to be set before calling the method.
|
|
699 |
updateToolTipTexts();
|
|
700 |
}
|
|
701 |
|
|
702 |
/**
|
|
703 |
* Sets tooltip text according the selected match type
|
|
704 |
* and the used query type.
|
|
705 |
* Calling of this method requires that all the referenced
|
|
706 |
* widgets are created/initialized properly.
|
|
707 |
*/
|
|
708 |
private void updateToolTipTexts() {
|
|
709 |
int selIndex = matchTypeSelCombo.getSelectionIndex();
|
|
710 |
MatchTypes selType = matchTypeItemArr[selIndex].getMatchType();
|
|
711 |
// Are we querying function data?
|
|
712 |
if(selectedSearchType == SearchType.SEARCH_IMPORTED_FUNCTIONS || selectedSearchType == SearchType.SEARCH_EXPORTED_FUNCTION){
|
|
713 |
if(selType.equals(MatchTypes.REGULAR_EXPRESSION) || selType.equals(MatchTypes.CONTAINS)){
|
|
714 |
matchTypeSelCombo.setToolTipText(TOOLTIP_MSG_USE_COMPLETE_FUNC_NAME);
|
|
715 |
return;
|
|
716 |
}
|
|
717 |
else{
|
|
718 |
matchTypeSelCombo.setToolTipText(TOOLTIP_MSG_USE_FUNC_BASE_NAME);
|
|
719 |
return;
|
|
720 |
}
|
|
721 |
}
|
|
722 |
// Otherwise component data is to be queried
|
|
723 |
matchTypeSelCombo.setToolTipText(TOOLTIP_MSG_COMPONENT_QUERY);
|
|
724 |
}
|
|
725 |
|
|
726 |
/**
|
|
727 |
* Performs the search based on the current dialog parameters.
|
|
728 |
*/
|
|
729 |
private void performSearch() {
|
|
730 |
|
|
731 |
String searchString = null;
|
|
732 |
try {
|
|
733 |
// Clearing old results
|
|
734 |
searchResultList.removeAll();
|
|
735 |
|
|
736 |
// Disabling Show Method Call Locations functionality when list is cleared.
|
|
737 |
actionImportShowMethodLoc.setEnabled(false);
|
|
738 |
isImportedFunctionsSearched = false;
|
|
739 |
|
|
740 |
ICacheDataManager manager = CacheDataManager.getInstance();
|
|
741 |
|
|
742 |
searchString = searchStringTxtField.getText();
|
|
743 |
MatchType matchType = new MatchType( matchTypeItemArr[matchTypeSelCombo.getSelectionIndex()].matchType );
|
|
744 |
//Adding case sensitive parameters, only when its not regular expression
|
|
745 |
if(matchType.getMatchType() != MatchTypes.REGULAR_EXPRESSION){
|
|
746 |
boolean isCaseSensitiveSearch = caseSensitivityOptionCheckbox.getSelection();
|
|
747 |
matchType.setCaseSensitiveSearch(isCaseSensitiveSearch);
|
|
748 |
}
|
|
749 |
|
|
750 |
//Get results from manager
|
|
751 |
Map<String, java.util.List<AbstractFunctionData>> results = manager.searchCache(searchString, selectedSearchType, matchType);
|
|
752 |
|
|
753 |
if(results != null){
|
|
754 |
//Generate results map, where is list strings and component names
|
|
755 |
resultsMap = getResultMap(results, selectedSearchType);
|
|
756 |
//check if there is not too much results. Checked with imported functions search "L"
|
|
757 |
//that 200000 results takes way too long to set dialog List items, but "newL" search with 13000 result is ok.
|
|
758 |
int size = resultsMap.size();
|
|
759 |
DbgUtility.println(DbgUtility.PRIORITY_OPERATION, "Search returned " //$NON-NLS-1$
|
|
760 |
+ size + " data items as result when searching with string '" + searchString + "'."); //$NON-NLS-1$ //$NON-NLS-2$
|
|
761 |
if(size > MAX_RESULTS_SIZE){
|
|
762 |
showTooManyResultsErrorMsg(size);
|
|
763 |
}else{
|
|
764 |
Set<String> listItems = resultsMap.keySet();
|
|
765 |
String[] resultString = (String[]) listItems.toArray(new String[0]);
|
|
766 |
searchResultList.setItems(resultString);
|
|
767 |
|
|
768 |
// Enabling Show Method Call Locations functionality if imported functions were successfully searched.
|
|
769 |
if(selectedSearchType == SearchType.SEARCH_IMPORTED_FUNCTIONS){
|
|
770 |
actionImportShowMethodLoc.setEnabled(true);
|
|
771 |
isImportedFunctionsSearched = true;
|
|
772 |
}
|
|
773 |
}
|
|
774 |
}
|
|
775 |
|
|
776 |
} catch (CacheFileDoesNotExistException e) {
|
|
777 |
// write to console, show error
|
|
778 |
e.printStackTrace();
|
|
779 |
String msg = Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part1") //$NON-NLS-1$
|
|
780 |
+ searchString //$NON-NLS-1$
|
|
781 |
+Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part2") //$NON-NLS-1$
|
|
782 |
+ e;
|
|
783 |
AppDepConsole.getInstance().println(
|
|
784 |
msg, AppDepConsole.MSG_ERROR);
|
|
785 |
showErrorDialog();
|
|
786 |
} catch (IOException e) {
|
|
787 |
// write to console, show error
|
|
788 |
e.printStackTrace();
|
|
789 |
String msg = Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part1") //$NON-NLS-1$
|
|
790 |
+ searchString //$NON-NLS-1$
|
|
791 |
+Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part2") //$NON-NLS-1$
|
|
792 |
+ e;
|
|
793 |
AppDepConsole.getInstance().println(msg, AppDepConsole.MSG_ERROR);
|
|
794 |
showErrorDialog();
|
|
795 |
}
|
|
796 |
catch (Exception e) {
|
|
797 |
// write to console, show error
|
|
798 |
e.printStackTrace();
|
|
799 |
String msg = Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part1") //$NON-NLS-1$
|
|
800 |
+ searchString //$NON-NLS-1$
|
|
801 |
+Messages.getString("AppDepSearchDialog.Search_Console_Err_Msg_Part2") //$NON-NLS-1$
|
|
802 |
+ e;
|
|
803 |
AppDepConsole.getInstance().println(msg, AppDepConsole.MSG_ERROR);
|
|
804 |
showErrorDialog();
|
|
805 |
}
|
|
806 |
|
|
807 |
}
|
|
808 |
|
|
809 |
/**
|
|
810 |
* This message is shown in case query returns too many data items
|
|
811 |
* that cannot be shown in dialog withouth compromising user experience.
|
|
812 |
* @param resultsSize Amount of data items returned as a results.
|
|
813 |
*/
|
|
814 |
private void showTooManyResultsErrorMsg(int resultsSize) {
|
|
815 |
String msg = Messages.getString("AppDepSearchDialog.TooManyResults_ErrMsg_Part1")//$NON-NLS-1$
|
|
816 |
+resultsSize + Messages.getString("AppDepSearchDialog.TooManyResults_ErrMsg_Part2");//$NON-NLS-1$
|
|
817 |
AppDepMessageBox msgBox = new AppDepMessageBox(msg , SWT.ICON_INFORMATION | SWT.OK );
|
|
818 |
msgBox.open();
|
|
819 |
}
|
|
820 |
|
|
821 |
/**
|
|
822 |
* Gets search results as map (converts the input data).
|
|
823 |
* @param results Original search results to be converted.
|
|
824 |
* @param searchType Type of search performed.
|
|
825 |
* @return Search results as map (converted from the input data).
|
|
826 |
*/
|
|
827 |
private Map<String, SearchResultItem> getResultMap(Map<String, java.util.List<AbstractFunctionData>> results, SearchType searchType) {
|
|
828 |
|
|
829 |
Set<String> keys = results.keySet();
|
|
830 |
Map<String, SearchResultItem> resultsArray = new HashMap<String, SearchResultItem>();
|
|
831 |
switch (searchType) {
|
|
832 |
case SEARCH_COMPONENTS:
|
|
833 |
for (String compName : keys) {
|
|
834 |
SearchResultItem compData = new SearchResultItem();
|
|
835 |
compData.setComponentName(compName);
|
|
836 |
resultsArray.put(compName, compData);
|
|
837 |
}
|
|
838 |
break;
|
|
839 |
case SEARCH_EXPORTED_FUNCTION:
|
|
840 |
case SEARCH_IMPORTED_FUNCTIONS:
|
|
841 |
for (String compName : keys) {
|
|
842 |
java.util.List<AbstractFunctionData> datas = results.get(compName);
|
|
843 |
for (AbstractFunctionData data : datas) {
|
|
844 |
String functionNameAndCompName = data.getFunctionName() + " [" + compName +"]"; //$NON-NLS-1$//$NON-NLS-2$
|
|
845 |
SearchResultItem compData = new SearchResultItem();
|
|
846 |
compData.setComponentName(compName);
|
|
847 |
compData.setFunctionName(data.getFunctionName());
|
|
848 |
compData.setFunctionOrdinal(data.getFunctionOrdinal());
|
|
849 |
resultsArray.put(functionNameAndCompName, compData);
|
|
850 |
}
|
|
851 |
}
|
|
852 |
break;
|
|
853 |
default:
|
|
854 |
break;
|
|
855 |
}
|
|
856 |
return resultsArray;
|
|
857 |
|
|
858 |
}
|
|
859 |
|
|
860 |
/**
|
|
861 |
* Shows an error dialog
|
|
862 |
*/
|
|
863 |
private void showErrorDialog() {
|
|
864 |
String msg = Messages.getString("AppDepSearchDialog.Search_User_Err_Msg"); //$NON-NLS-1$
|
|
865 |
AppDepMessageBox msgBox = new AppDepMessageBox(msg , SWT.ICON_ERROR | SWT.OK );
|
|
866 |
msgBox.open();
|
|
867 |
}
|
|
868 |
|
|
869 |
/**
|
|
870 |
* Checks what is selected object in the search results list
|
|
871 |
* and activates and selects it from the UI.
|
|
872 |
*/
|
|
873 |
private void searchListObjectDoubleClicked() {
|
|
874 |
|
|
875 |
String selectedComponentName = null;
|
|
876 |
//get selected component name
|
|
877 |
try {
|
|
878 |
|
|
879 |
String [] results = searchResultList.getItems();
|
|
880 |
//Get selected component name from List:s object data by selection index
|
|
881 |
String listItemId = results[searchResultList.getSelectionIndex()];
|
|
882 |
SearchResultItem value = resultsMap.get(listItemId);
|
|
883 |
selectedComponentName = value.getComponentName();
|
|
884 |
|
|
885 |
//get root node of tree
|
|
886 |
ComponentParentNode root = getRootNode();
|
|
887 |
|
|
888 |
//Seek all parent nodes of tree to find if we have selected component all ready in tree
|
|
889 |
Map<String, ComponentParentNode> parentNodes = SeekParentNodesService.findParentNodes(root);
|
|
890 |
|
|
891 |
//If component can be found from current component tree, activating selection
|
|
892 |
if(parentNodes.containsKey(selectedComponentName.toLowerCase())){
|
|
893 |
ComponentParentNode selectedNode = parentNodes.get(selectedComponentName.toLowerCase());
|
|
894 |
view.activateTreeViewComponent(selectedNode);
|
|
895 |
}
|
|
896 |
else{
|
|
897 |
//If component cannot be found from current component tree, setting selection as new root
|
|
898 |
UiUtils.setComponentAsNewRootInMainView(view, selectedComponentName, null);
|
|
899 |
}
|
|
900 |
} catch (Exception e) {
|
|
901 |
e.printStackTrace();
|
|
902 |
String msg = Messages.getString("AppDepSearchDialog.SetComponent_Console_Err_Msg_Part1") //$NON-NLS-1$
|
|
903 |
+ selectedComponentName //$NON-NLS-1$
|
|
904 |
+Messages.getString("AppDepSearchDialog.SetComponent_Console_Err_Msg_Part2") //$NON-NLS-1$
|
|
905 |
+ e;
|
|
906 |
AppDepConsole.getInstance().println(msg, AppDepConsole.MSG_ERROR);
|
|
907 |
showErrorDialog();
|
|
908 |
}
|
|
909 |
}
|
|
910 |
|
|
911 |
/**
|
|
912 |
* Gets current root node
|
|
913 |
* @return root node
|
|
914 |
*/
|
|
915 |
private ComponentParentNode getRootNode() {
|
|
916 |
//Getting new root node from view, not from start node!
|
|
917 |
ComponentParentNode root = view.getRootComponentNode();
|
|
918 |
return root;
|
|
919 |
}
|
|
920 |
|
|
921 |
/* (non-Javadoc)
|
|
922 |
* @see org.eclipse.swt.events.ModifyListener#modifyText(org.eclipse.swt.events.ModifyEvent)
|
|
923 |
*/
|
|
924 |
public void modifyText(ModifyEvent e) {
|
|
925 |
if(searchStringTxtField.getText().length() > 0){
|
|
926 |
searchButton.setEnabled(true);
|
|
927 |
}else{
|
|
928 |
searchButton.setEnabled(false);
|
|
929 |
}
|
|
930 |
}
|
|
931 |
|
|
932 |
/**
|
|
933 |
* Gets selected String from list.
|
|
934 |
*/
|
|
935 |
public String getString() {
|
|
936 |
String[] selectedItems = searchResultList.getSelection();
|
|
937 |
if(selectedItems.length > 0){
|
|
938 |
StringBuffer items = new StringBuffer();
|
|
939 |
|
|
940 |
// There should be at least one item.
|
|
941 |
items.append(selectedItems[0]);
|
|
942 |
// Adding rest of the strings with new line.
|
|
943 |
for(int i = 1;i < selectedItems.length;i++){
|
|
944 |
items.append("\r\n"); //$NON-NLS-1$
|
|
945 |
items.append(selectedItems[i]);
|
|
946 |
}
|
|
947 |
return items.toString();
|
|
948 |
}
|
|
949 |
return null;
|
|
950 |
}
|
|
951 |
|
|
952 |
/* (non-Javadoc)
|
|
953 |
* @see org.eclipse.jface.dialogs.TrayDialog#close()
|
|
954 |
*/
|
|
955 |
@Override
|
|
956 |
public boolean close() {
|
|
957 |
// clean-up
|
|
958 |
nonEditableFieldBkgColor.dispose();
|
|
959 |
searchStringTxtField.removeSelectionListener(this);
|
|
960 |
searchStringTxtField.removeModifyListener(this);
|
|
961 |
// Calling super close
|
|
962 |
return super.close();
|
|
963 |
}
|
|
964 |
|
|
965 |
/**
|
|
966 |
* Get currently selected function.
|
|
967 |
* @return String or <code>null</code>.
|
|
968 |
*/
|
|
969 |
public String getSelectedFunction() {
|
|
970 |
if(searchResultList.getSelectionIndex() >= 0){
|
|
971 |
//Get selected function name from list.
|
|
972 |
String listItemId = searchResultList.getItem(searchResultList.getSelectionIndex());
|
|
973 |
SearchResultItem value = resultsMap.get(listItemId);
|
|
974 |
String functionName = value.getFunctionName();
|
|
975 |
return functionName;
|
|
976 |
}
|
|
977 |
return null;
|
|
978 |
}
|
|
979 |
|
|
980 |
/**
|
|
981 |
* Get component for currently selected function.
|
|
982 |
* @return String or<code>null</code>.
|
|
983 |
*/
|
|
984 |
public String getComponentForSelectedFunction() {
|
|
985 |
if(searchResultList.getSelectionIndex() >= 0){
|
|
986 |
//Get selected component name from list.
|
|
987 |
String listItemId = searchResultList.getItem(searchResultList.getSelectionIndex());
|
|
988 |
SearchResultItem value = resultsMap.get(listItemId);
|
|
989 |
String componentName = value.getComponentName();
|
|
990 |
return componentName;
|
|
991 |
}
|
|
992 |
return null;
|
|
993 |
}
|
|
994 |
|
|
995 |
/**
|
|
996 |
* Gets the ordinal of selected function in search results list.
|
|
997 |
* @return ordinal of selected function in search results list, if
|
|
998 |
* a function is selected, otherwise <code>null</code>
|
|
999 |
* (i.e. component has been selected or there is
|
|
1000 |
* no selection made).
|
|
1001 |
*/
|
|
1002 |
public String getSelectedFunctionOrdinal() {
|
|
1003 |
if(searchResultList.getSelectionIndex() >= 0){
|
|
1004 |
//Get selected function ordinal from list.
|
|
1005 |
String listItemId = searchResultList.getItem(searchResultList.getSelectionIndex());
|
|
1006 |
SearchResultItem value = resultsMap.get(listItemId);
|
|
1007 |
String functionOrdinal = value.getFunctionOrdinal();
|
|
1008 |
return functionOrdinal;
|
|
1009 |
}
|
|
1010 |
return null;
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
}
|