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.views.main;
|
|
20 |
|
|
21 |
import java.util.ArrayList;
|
|
22 |
|
|
23 |
import org.eclipse.jface.action.Action;
|
|
24 |
import org.eclipse.jface.action.IMenuListener;
|
|
25 |
import org.eclipse.jface.action.IMenuManager;
|
|
26 |
import org.eclipse.jface.action.IToolBarManager;
|
|
27 |
import org.eclipse.jface.action.MenuManager;
|
|
28 |
import org.eclipse.jface.action.Separator;
|
|
29 |
import org.eclipse.jface.viewers.ISelection;
|
|
30 |
import org.eclipse.jface.viewers.ISelectionChangedListener;
|
|
31 |
import org.eclipse.jface.viewers.IStructuredSelection;
|
|
32 |
import org.eclipse.jface.viewers.TableViewer;
|
|
33 |
import org.eclipse.jface.viewers.TreeViewer;
|
|
34 |
import org.eclipse.swt.SWT;
|
|
35 |
import org.eclipse.swt.custom.CTabFolder;
|
|
36 |
import org.eclipse.swt.custom.CTabItem;
|
|
37 |
import org.eclipse.swt.custom.SashForm;
|
|
38 |
import org.eclipse.swt.events.KeyEvent;
|
|
39 |
import org.eclipse.swt.events.KeyListener;
|
|
40 |
import org.eclipse.swt.widgets.Composite;
|
|
41 |
import org.eclipse.swt.widgets.Event;
|
|
42 |
import org.eclipse.swt.widgets.Menu;
|
|
43 |
import org.eclipse.swt.widgets.Table;
|
|
44 |
import org.eclipse.swt.widgets.TableColumn;
|
|
45 |
import org.eclipse.ui.IActionBars;
|
|
46 |
import org.eclipse.ui.IMemento;
|
|
47 |
import org.eclipse.ui.IViewPart;
|
|
48 |
import org.eclipse.ui.IViewReference;
|
|
49 |
import org.eclipse.ui.IViewSite;
|
|
50 |
import org.eclipse.ui.IWorkbenchActionConstants;
|
|
51 |
import org.eclipse.ui.IWorkbenchPage;
|
|
52 |
import org.eclipse.ui.PartInitException;
|
|
53 |
import org.eclipse.ui.part.DrillDownAdapter;
|
|
54 |
import org.eclipse.ui.part.ViewPart;
|
|
55 |
|
|
56 |
import com.nokia.s60tools.appdep.AppDepHelpContextIDs;
|
|
57 |
import com.nokia.s60tools.appdep.common.ProductInfoRegistry;
|
|
58 |
import com.nokia.s60tools.appdep.core.AppDepSettings;
|
|
59 |
import com.nokia.s60tools.appdep.core.data.ComponentLinkLeafNode;
|
|
60 |
import com.nokia.s60tools.appdep.core.data.ComponentNode;
|
|
61 |
import com.nokia.s60tools.appdep.core.data.ComponentParentNode;
|
|
62 |
import com.nokia.s60tools.appdep.core.model.ComponentPropertiesData;
|
|
63 |
import com.nokia.s60tools.appdep.core.model.ExportFunctionData;
|
|
64 |
import com.nokia.s60tools.appdep.core.model.ImportFunctionData;
|
|
65 |
import com.nokia.s60tools.appdep.plugin.AppDepPlugin;
|
|
66 |
import com.nokia.s60tools.appdep.resources.Messages;
|
|
67 |
import com.nokia.s60tools.appdep.search.SearchConstants;
|
|
68 |
import com.nokia.s60tools.appdep.ui.actions.AbstractShowSourceFileAction;
|
|
69 |
import com.nokia.s60tools.appdep.ui.actions.AddSisAndUpdateCacheMainViewAction;
|
|
70 |
import com.nokia.s60tools.appdep.ui.actions.CacheUpdateMainViewAction;
|
|
71 |
import com.nokia.s60tools.appdep.ui.actions.CollapseAllMainViewAction;
|
|
72 |
import com.nokia.s60tools.appdep.ui.actions.ComponentIsUsedByMainViewAction;
|
|
73 |
import com.nokia.s60tools.appdep.ui.actions.ComponentPropertiesMainViewAction;
|
|
74 |
import com.nokia.s60tools.appdep.ui.actions.ExpandAllMainViewAction;
|
|
75 |
import com.nokia.s60tools.appdep.ui.actions.ExpandSubtreeMainViewAction;
|
|
76 |
import com.nokia.s60tools.appdep.ui.actions.ExportReportMainViewAction;
|
|
77 |
import com.nokia.s60tools.appdep.ui.actions.FindMainViewAction;
|
|
78 |
import com.nokia.s60tools.appdep.ui.actions.FunctionIsUsedByExportFunctionMainViewAction;
|
|
79 |
import com.nokia.s60tools.appdep.ui.actions.FunctionIsUsedByImportFunctionMainViewAction;
|
|
80 |
import com.nokia.s60tools.appdep.ui.actions.LocateComponentMainViewAction;
|
|
81 |
import com.nokia.s60tools.appdep.ui.actions.SearchMainViewAction;
|
|
82 |
import com.nokia.s60tools.appdep.ui.actions.SelectAllFromTableViewerMainViewAction;
|
|
83 |
import com.nokia.s60tools.appdep.ui.actions.SelectNewRootComponentMainViewAction;
|
|
84 |
import com.nokia.s60tools.appdep.ui.actions.SelectNewSDKMainViewAction;
|
|
85 |
import com.nokia.s60tools.appdep.ui.actions.SetNewRootMainViewAction;
|
|
86 |
import com.nokia.s60tools.appdep.ui.actions.ShowMethodCallLocationsImportFunctionMainViewAction;
|
|
87 |
import com.nokia.s60tools.appdep.ui.actions.ShowSourceFileAndCreateProjectExportFunctionMainViewAction;
|
|
88 |
import com.nokia.s60tools.appdep.ui.actions.ShowSourceFileAndCreateProjectImportFunctionMainViewAction;
|
|
89 |
import com.nokia.s60tools.appdep.ui.actions.ShowSourceFileExportFunctionMainViewAction;
|
|
90 |
import com.nokia.s60tools.appdep.ui.actions.ShowSourceFileImportFunctionMainViewAction;
|
|
91 |
import com.nokia.s60tools.appdep.ui.dialogs.AppDepMessageBox;
|
|
92 |
import com.nokia.s60tools.ui.ICopyActionHandler;
|
|
93 |
import com.nokia.s60tools.ui.ProgrammaticSelection;
|
|
94 |
import com.nokia.s60tools.ui.S60ToolsTable;
|
|
95 |
import com.nokia.s60tools.ui.S60ToolsTableColumnData;
|
|
96 |
import com.nokia.s60tools.ui.S60ToolsTableFactory;
|
|
97 |
import com.nokia.s60tools.ui.actions.CopyFromTableViewerAction;
|
|
98 |
|
|
99 |
/**
|
|
100 |
* This class comprises the Main View of the AppDep
|
|
101 |
* application.
|
|
102 |
*/
|
|
103 |
public class MainView extends ViewPart implements KeyListener {
|
|
104 |
|
|
105 |
/**
|
|
106 |
* We can get view ID at runtime once the view is instantiated, but we
|
|
107 |
* also need static access to ID in order to be able to invoke the view.
|
|
108 |
*/
|
|
109 |
public static final String ID = "com.nokia.s60tools.appdep.ui.views.main.MainView"; //$NON-NLS-1$
|
|
110 |
|
|
111 |
/**
|
|
112 |
* We will disable show source functionality for some "method" names,
|
|
113 |
* which are no real method names. List for prefixes is stored in here and
|
|
114 |
* all clients of {@link MainView} can be used them.
|
|
115 |
*/
|
|
116 |
private static final String [] DISABLE_SHOW_SOURCE_PREFIXES = {
|
|
117 |
"BC break", //$NON-NLS-1$
|
|
118 |
"vtable for", //$NON-NLS-1$
|
|
119 |
"typeinfo", //$NON-NLS-1$
|
|
120 |
"\"_._.absent_export_"}; //$NON-NLS-1$
|
|
121 |
|
|
122 |
//
|
|
123 |
// Actions
|
|
124 |
//
|
|
125 |
|
|
126 |
private Action actionSetAsNewRoot;
|
|
127 |
private Action actionComponentIsUsedBy;
|
|
128 |
|
|
129 |
private Action actionImportFunctionIsUsedBy;
|
|
130 |
private Action actionImportFunctionDataCopy;
|
|
131 |
private Action actionSelectAllImportFunctions;
|
|
132 |
|
|
133 |
private Action actionExportFunctionIsUsedBy;
|
|
134 |
private Action actionExportFunctionDataCopy;
|
|
135 |
private Action actionSelectAllExportFunctions;
|
|
136 |
|
|
137 |
private Action actionCompPropertyDataCopy;
|
|
138 |
private Action actionSelectAllComponentProperties;
|
|
139 |
private Action actionExpandAll = null;
|
|
140 |
private Action actionCollapseAll = null;
|
|
141 |
private Action actionExpandSubtree = null;
|
|
142 |
private Action actionSelectNewRootComponent = null;
|
|
143 |
private Action actionComponentProperties;
|
|
144 |
private Action actionSelectNewSDK;
|
|
145 |
private Action actionExportReport;
|
|
146 |
private Action actionComponentFind;
|
|
147 |
private Action actionLocateComponent;
|
|
148 |
|
|
149 |
private Action actionCacheUpdate;
|
|
150 |
private Action addSisFilesAndUpdateCache;
|
|
151 |
private Action actionComponentSearch;
|
|
152 |
private Action actionImportFunctionSearch;
|
|
153 |
private Action actionExportFunctionSearch;
|
|
154 |
|
|
155 |
private AbstractShowSourceFileAction actionImportShowSource;
|
|
156 |
private AbstractShowSourceFileAction actionExportShowSource;
|
|
157 |
|
|
158 |
private ShowMethodCallLocationsImportFunctionMainViewAction actionImportShowMethodLoc;
|
|
159 |
|
|
160 |
private ShowSourceFileAndCreateProjectExportFunctionMainViewAction actionExportShowSourceInProject;
|
|
161 |
private ShowSourceFileAndCreateProjectImportFunctionMainViewAction actionImportShowSourceInProject;
|
|
162 |
|
|
163 |
/**
|
|
164 |
* This flag is updated when the view is fully populated
|
|
165 |
* i.e. all the indirect dependencies are searched.
|
|
166 |
* This flag is set to <code>true</code> by population
|
|
167 |
* progress listener when population has either finished
|
|
168 |
* or aborted by the user. The value of this flag is used,
|
|
169 |
* for instance, by selection listener.
|
|
170 |
*/
|
|
171 |
static private boolean isDependencySearchOngoing = false;
|
|
172 |
|
|
173 |
//
|
|
174 |
// Controls and related classes (providers etc.)
|
|
175 |
//
|
|
176 |
|
|
177 |
private TreeViewer componentTreeViewer;
|
|
178 |
private DrillDownAdapter drillDownAdapter;
|
|
179 |
private MainViewComponentTreeContentProvider compTreeViewerContentProv = null;
|
|
180 |
|
|
181 |
private CTabItem importFunctionsTab;
|
|
182 |
|
|
183 |
private S60ToolsTable importFunctionsViewer;
|
|
184 |
|
|
185 |
private MainViewImportFunctionsTabContentProvider importFunctionsTabContentProvider;
|
|
186 |
|
|
187 |
private CTabItem componentPropertiesTab;
|
|
188 |
|
|
189 |
private SashForm componentPropertiesSashForm;
|
|
190 |
|
|
191 |
private TableViewer componentPropertiesViewer;
|
|
192 |
|
|
193 |
private MainViewComponentPropertiesTabContentProvider componentPropertiesTabContentProvider;
|
|
194 |
|
|
195 |
private ArrayList<ImportFunctionData> importFunctionsArrayList;
|
|
196 |
|
|
197 |
private ComponentPropertiesData selectedComponentPropertiesData = null;
|
|
198 |
|
|
199 |
private CTabItem exportFunctionsTab;
|
|
200 |
|
|
201 |
private S60ToolsTable exportFunctionsViewer;
|
|
202 |
|
|
203 |
private MainViewExportFunctionsTabContentProvider exportFunctionsTabContentProvider;
|
|
204 |
|
|
205 |
private ArrayList<ExportFunctionData> exportFunctionsArrayList;
|
|
206 |
|
|
207 |
/**
|
|
208 |
* 'Go Into' actions looses the selection from the tree view, and there is
|
|
209 |
* no way to hook the action, therefore we store the recently selected
|
|
210 |
* component in order to know for which the selected function is bound to.
|
|
211 |
*
|
|
212 |
* This is used for "Is Used By..."-actions and also
|
|
213 |
* for "Show Source.."- and "Show Method.."-actions.
|
|
214 |
*/
|
|
215 |
private Object mostRecentlySelectedComponentNode = null;
|
|
216 |
|
|
217 |
|
|
218 |
/**
|
|
219 |
* The constructor.
|
|
220 |
*/
|
|
221 |
public MainView() {
|
|
222 |
setTitleToolTip(ProductInfoRegistry.getProductName());
|
|
223 |
}
|
|
224 |
|
|
225 |
/**
|
|
226 |
* This is a callback that will allow us
|
|
227 |
* to create the componentTreeViewer and initialize it.
|
|
228 |
*/
|
|
229 |
public void createPartControl(Composite parent) {
|
|
230 |
|
|
231 |
// Creating commonly used data structures
|
|
232 |
importFunctionsArrayList = new ArrayList<ImportFunctionData>();
|
|
233 |
exportFunctionsArrayList = new ArrayList<ExportFunctionData>();
|
|
234 |
|
|
235 |
//
|
|
236 |
// Actions invoked by content providers may set enable/disable
|
|
237 |
// states for the actions, therefore all the action has to be
|
|
238 |
// created before creating the controls. This makes sure that
|
|
239 |
// it is safe to refer to all the actions after this point.
|
|
240 |
//
|
|
241 |
createOnlyMainViewDependentActions();
|
|
242 |
|
|
243 |
//
|
|
244 |
// Creating controls
|
|
245 |
//
|
|
246 |
|
|
247 |
// The left side contains component hierarchy tree view
|
|
248 |
SashForm componentHierarchySashForm = new SashForm(parent, SWT.HORIZONTAL);
|
|
249 |
createComponentTreeViewControl(componentHierarchySashForm);
|
|
250 |
|
|
251 |
// The right side contains tabbed panes for showing...
|
|
252 |
CTabFolder sidePaneTabFolder = new CTabFolder(componentHierarchySashForm, SWT.BOTTOM);
|
|
253 |
//... parent imported functions
|
|
254 |
createImportFunctionsTabControl(sidePaneTabFolder);
|
|
255 |
// ...exported functions for the selected module
|
|
256 |
createExportFunctionsTabControl(sidePaneTabFolder);
|
|
257 |
//...component properties
|
|
258 |
createComponentPropertiesTabControl(sidePaneTabFolder);
|
|
259 |
|
|
260 |
// Default selection for tab folder
|
|
261 |
sidePaneTabFolder.setSelection(importFunctionsTab);
|
|
262 |
|
|
263 |
//
|
|
264 |
// Doing other initializations that may refer to the component
|
|
265 |
// that has been created above.
|
|
266 |
//
|
|
267 |
hookContextMenu();
|
|
268 |
contributeToActionBars();
|
|
269 |
|
|
270 |
// Adding listeners
|
|
271 |
componentTreeViewer.getControl().addKeyListener(this);
|
|
272 |
|
|
273 |
// Setting context help IDs
|
|
274 |
AppDepPlugin.setContextSensitiveHelpID(componentTreeViewer.getControl(),
|
|
275 |
AppDepHelpContextIDs.APPDEP_MAIN_VIEW);
|
|
276 |
|
|
277 |
AppDepPlugin.setContextSensitiveHelpID(importFunctionsViewer.getTableInstance(),
|
|
278 |
AppDepHelpContextIDs.APPDEP_IMPORTED_FUNCTIONS);
|
|
279 |
|
|
280 |
AppDepPlugin.setContextSensitiveHelpID(exportFunctionsViewer.getTableInstance(),
|
|
281 |
AppDepHelpContextIDs.APPDEP_EXPORTED_FUNCTIONS);
|
|
282 |
|
|
283 |
AppDepPlugin.setContextSensitiveHelpID(componentPropertiesViewer.getTable(),
|
|
284 |
AppDepHelpContextIDs.APPDEP_PROPERTIES);
|
|
285 |
}
|
|
286 |
|
|
287 |
/**
|
|
288 |
* Creates component properties tab.
|
|
289 |
* @param sidePaneTabFolder Parent tab folder.
|
|
290 |
*/
|
|
291 |
private void createComponentPropertiesTabControl(CTabFolder sidePaneTabFolder) {
|
|
292 |
componentPropertiesSashForm = new SashForm(sidePaneTabFolder, SWT.VERTICAL);
|
|
293 |
componentPropertiesTab = new CTabItem(sidePaneTabFolder, SWT.NONE);
|
|
294 |
componentPropertiesTab.setControl(componentPropertiesSashForm);
|
|
295 |
componentPropertiesTab.setText(Messages.getString("MainView.ComponentProperties_TabTitle")); //$NON-NLS-1$
|
|
296 |
// and viewer for those
|
|
297 |
componentPropertiesViewer = createComponentPropertiesTableViewer(componentPropertiesSashForm);
|
|
298 |
// Creating pop-up menu actions that require the existence of componentPropertiesViewer
|
|
299 |
createComponentPropertiesTabPopUpMenuActions();
|
|
300 |
componentPropertiesTabContentProvider = new MainViewComponentPropertiesTabContentProvider(this);
|
|
301 |
componentPropertiesViewer.setContentProvider(componentPropertiesTabContentProvider);
|
|
302 |
componentPropertiesViewer.setLabelProvider(new MainViewComponentPropertiesTabLabelProvider());
|
|
303 |
componentPropertiesViewer.setInput(componentPropertiesTabContentProvider);
|
|
304 |
componentPropertiesViewer.setSorter(new PropertyDataSorter());
|
|
305 |
}
|
|
306 |
|
|
307 |
/**
|
|
308 |
* Creates export functions tab.
|
|
309 |
* @param sidePaneTabFolder Parent tab folder.
|
|
310 |
*/
|
|
311 |
private void createExportFunctionsTabControl(CTabFolder sidePaneTabFolder) {
|
|
312 |
SashForm exportFunctionsSashForm = new SashForm(sidePaneTabFolder, SWT.VERTICAL);
|
|
313 |
exportFunctionsTab = new CTabItem(sidePaneTabFolder, SWT.NONE);
|
|
314 |
exportFunctionsTab.setControl(exportFunctionsSashForm);
|
|
315 |
exportFunctionsTab.setText(Messages.getString("MainView.ExportedFunctions_TabTitle")); //$NON-NLS-1$
|
|
316 |
// and viewer for those
|
|
317 |
exportFunctionsViewer = createExportFunctionsTableViewer(exportFunctionsSashForm);
|
|
318 |
// Creating pop-up menu actions that require the existence of exportFunctionsViewer
|
|
319 |
createExportFunctionsTabPopUpMenuActions();
|
|
320 |
exportFunctionsTabContentProvider = new MainViewExportFunctionsTabContentProvider(exportFunctionsArrayList);
|
|
321 |
exportFunctionsViewer.getHostingViewer().setContentProvider(exportFunctionsTabContentProvider);
|
|
322 |
exportFunctionsViewer.getHostingViewer().setLabelProvider(new MainViewExportFunctionsTabLabelProvider());
|
|
323 |
exportFunctionsViewer.getHostingViewer().setInput(exportFunctionsTabContentProvider);
|
|
324 |
exportFunctionsViewer.getHostingViewer().setSorter(new ExportFunctionDataSorter());
|
|
325 |
ExportedFunctionsTabSelectionChangedListener selListener = new ExportedFunctionsTabSelectionChangedListener(this);
|
|
326 |
exportFunctionsViewer.getHostingViewer().addSelectionChangedListener(selListener);
|
|
327 |
}
|
|
328 |
|
|
329 |
|
|
330 |
/**
|
|
331 |
* Creates import functions tab.
|
|
332 |
* @param sidePaneTabFolder Parent tab folder.
|
|
333 |
*/
|
|
334 |
private void createImportFunctionsTabControl(CTabFolder sidePaneTabFolder) {
|
|
335 |
SashForm importFunctionsSashForm = new SashForm(sidePaneTabFolder, SWT.VERTICAL);
|
|
336 |
importFunctionsTab = new CTabItem(sidePaneTabFolder, SWT.NONE);
|
|
337 |
importFunctionsTab.setControl(importFunctionsSashForm);
|
|
338 |
importFunctionsTab.setText(Messages.getString("MainView.ImportedFunctions_TabTitle")); //$NON-NLS-1$
|
|
339 |
// and viewer for those
|
|
340 |
importFunctionsViewer = createImportFunctionsTableViewer(importFunctionsSashForm);
|
|
341 |
// Creating pop-up menu actions that require the existence of importFunctionsViewer
|
|
342 |
createImportFunctionsTabPopUpMenuActions();
|
|
343 |
importFunctionsTabContentProvider = new MainViewImportFunctionsTabContentProvider(importFunctionsArrayList);
|
|
344 |
importFunctionsViewer.getHostingViewer().setContentProvider(importFunctionsTabContentProvider);
|
|
345 |
importFunctionsViewer.getHostingViewer().setLabelProvider(new MainViewImportFunctionsTabLabelProvider());
|
|
346 |
importFunctionsViewer.getHostingViewer().setInput(importFunctionsTabContentProvider);
|
|
347 |
importFunctionsViewer.getHostingViewer().setSorter(new ImportFunctionDataSorter());
|
|
348 |
ImportedFunctionsTabSelectionChangedListener selListener = new ImportedFunctionsTabSelectionChangedListener(this);
|
|
349 |
importFunctionsViewer.getHostingViewer().addSelectionChangedListener(selListener);
|
|
350 |
}
|
|
351 |
|
|
352 |
/**
|
|
353 |
* Creates component tree view control.
|
|
354 |
* @param componentHierarchySashForm Parent SashForm for the tree view control.
|
|
355 |
*/
|
|
356 |
private void createComponentTreeViewControl(SashForm componentHierarchySashForm) {
|
|
357 |
componentTreeViewer = new TreeViewer(componentHierarchySashForm, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
|
358 |
drillDownAdapter = new DrillDownAdapter(componentTreeViewer);
|
|
359 |
compTreeViewerContentProv = new MainViewComponentTreeContentProvider(this);
|
|
360 |
componentTreeViewer.setContentProvider(compTreeViewerContentProv);
|
|
361 |
componentTreeViewer.setLabelProvider(new MainViewComponentTreeLabelProvider());
|
|
362 |
componentTreeViewer.setInput(compTreeViewerContentProv.getInput());
|
|
363 |
componentTreeViewer.addDoubleClickListener(new MainViewDoubleClickListener(this,
|
|
364 |
drillDownAdapter));
|
|
365 |
ISelectionChangedListener selChangedListener
|
|
366 |
= new MainViewSelectionChangedListener(this,
|
|
367 |
importFunctionsArrayList,
|
|
368 |
exportFunctionsArrayList);
|
|
369 |
componentTreeViewer.addSelectionChangedListener(selChangedListener);
|
|
370 |
}
|
|
371 |
|
|
372 |
/**
|
|
373 |
* Creates table viewer for import functions tab item.
|
|
374 |
* @return New <code>S60ToolsTable</code> object instance.
|
|
375 |
*/
|
|
376 |
private S60ToolsTable createImportFunctionsTableViewer(Composite parent) {
|
|
377 |
|
|
378 |
ArrayList<S60ToolsTableColumnData> columnDataArr = new ArrayList<S60ToolsTableColumnData>();
|
|
379 |
|
|
380 |
//
|
|
381 |
// NOTE: Column indices must start from zero (0) and
|
|
382 |
// the columns must be added in ascending numeric
|
|
383 |
// order.
|
|
384 |
//
|
|
385 |
|
|
386 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Ordinal_TableColumnTitle"), //$NON-NLS-1$
|
|
387 |
60,
|
|
388 |
ImportFunctionData.ORDINAL_COLUMN_INDEX,
|
|
389 |
ImportFunctionDataSorter.CRITERIA_ORDINAL));
|
|
390 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Name_TableColumnTitle"), //$NON-NLS-1$
|
|
391 |
340,
|
|
392 |
ImportFunctionData.NAME_COLUMN_INDEX,
|
|
393 |
ImportFunctionDataSorter.CRITERIA_NAME, true));
|
|
394 |
|
|
395 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Offset_TableColumnTitle"), //$NON-NLS-1$
|
|
396 |
60,
|
|
397 |
ImportFunctionData.OFFSET_COLUMN_INDEX,
|
|
398 |
ImportFunctionDataSorter.CRITERIA_OFFSET));
|
|
399 |
|
|
400 |
S60ToolsTableColumnData[] arr
|
|
401 |
= columnDataArr.toArray(
|
|
402 |
new S60ToolsTableColumnData[0]);
|
|
403 |
|
|
404 |
S60ToolsTable tbl = S60ToolsTableFactory.create(parent, arr, 1);
|
|
405 |
|
|
406 |
TableViewer tblViewer = new TableViewer(tbl.getTableInstance());
|
|
407 |
tbl.setHostingViewer(tblViewer);
|
|
408 |
|
|
409 |
return tbl;
|
|
410 |
}
|
|
411 |
|
|
412 |
/**
|
|
413 |
* Creates table viewer for export functions tab item.
|
|
414 |
* @return New <code>S60ToolsTable</code> object instance.
|
|
415 |
*/
|
|
416 |
private S60ToolsTable createExportFunctionsTableViewer(Composite parent) {
|
|
417 |
|
|
418 |
ArrayList<S60ToolsTableColumnData> columnDataArr = new ArrayList<S60ToolsTableColumnData>();
|
|
419 |
|
|
420 |
//
|
|
421 |
// NOTE: Column indices must start from zero (0) and
|
|
422 |
// the columns must be added in ascending numeric
|
|
423 |
// order.
|
|
424 |
//
|
|
425 |
|
|
426 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Ordinal_TableColumnTitle"), //$NON-NLS-1$
|
|
427 |
60,
|
|
428 |
ExportFunctionData.ORDINAL_COLUMN_INDEX,
|
|
429 |
ExportFunctionDataSorter.CRITERIA_ORDINAL));
|
|
430 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Name_TableColumnTitle"), //$NON-NLS-1$
|
|
431 |
340,
|
|
432 |
ExportFunctionData.NAME_COLUMN_INDEX,
|
|
433 |
ExportFunctionDataSorter.CRITERIA_NAME, true));
|
|
434 |
|
|
435 |
S60ToolsTableColumnData[] arr
|
|
436 |
= columnDataArr.toArray(
|
|
437 |
new S60ToolsTableColumnData[0]);
|
|
438 |
|
|
439 |
S60ToolsTable tbl = S60ToolsTableFactory.create(parent, arr, 1);
|
|
440 |
|
|
441 |
TableViewer tblViewer = new TableViewer(tbl.getTableInstance());
|
|
442 |
tbl.setHostingViewer(tblViewer);
|
|
443 |
|
|
444 |
return tbl;
|
|
445 |
}
|
|
446 |
|
|
447 |
|
|
448 |
/**
|
|
449 |
* Creates table viewer for component properties tab item.
|
|
450 |
* @return New <code>TableViewer</code> object instance.
|
|
451 |
*/
|
|
452 |
private TableViewer createComponentPropertiesTableViewer(Composite parent) {
|
|
453 |
|
|
454 |
ArrayList<S60ToolsTableColumnData> columnDataArr = new ArrayList<S60ToolsTableColumnData>();
|
|
455 |
|
|
456 |
//
|
|
457 |
// NOTE: Column indices must start from zero (0) and
|
|
458 |
// the columns must be added in ascending numeric
|
|
459 |
// order.
|
|
460 |
//
|
|
461 |
|
|
462 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Property_TableColumnTitle"), //$NON-NLS-1$
|
|
463 |
80,
|
|
464 |
ComponentPropertiesData.PROPERTY_COLUMN_INDEX,
|
|
465 |
PropertyDataSorter.CRITERIA_PROPERTY));
|
|
466 |
columnDataArr.add(new S60ToolsTableColumnData(Messages.getString("MainView.Value_TableColumnTitle"), //$NON-NLS-1$
|
|
467 |
380,
|
|
468 |
ComponentPropertiesData.VALUE_COLUMN_INDEX,
|
|
469 |
PropertyDataSorter.CRITERIA_VALUE));
|
|
470 |
|
|
471 |
S60ToolsTableColumnData[] arr
|
|
472 |
= columnDataArr.toArray(
|
|
473 |
new S60ToolsTableColumnData[0]);
|
|
474 |
|
|
475 |
S60ToolsTable tbl = S60ToolsTableFactory.create(parent, arr);
|
|
476 |
|
|
477 |
TableViewer tblViewer = new TableViewer(tbl.getTableInstance());
|
|
478 |
tbl.setHostingViewer(tblViewer);
|
|
479 |
|
|
480 |
return tblViewer;
|
|
481 |
}
|
|
482 |
|
|
483 |
|
|
484 |
/**
|
|
485 |
* Hooks view's context menu.
|
|
486 |
*/
|
|
487 |
private void hookContextMenu() {
|
|
488 |
//
|
|
489 |
// Context menu for tree viewer
|
|
490 |
//
|
|
491 |
MenuManager menuMgr = new MenuManager("#TreeViewPopupMenu"); //$NON-NLS-1$
|
|
492 |
menuMgr.setRemoveAllWhenShown(true);
|
|
493 |
menuMgr.addMenuListener(new IMenuListener() {
|
|
494 |
public void menuAboutToShow(IMenuManager manager) {
|
|
495 |
MainView.this.fillTreeViewContextMenu(manager);
|
|
496 |
}
|
|
497 |
});
|
|
498 |
Menu menu = menuMgr.createContextMenu(componentTreeViewer.getControl());
|
|
499 |
componentTreeViewer.getControl().setMenu(menu);
|
|
500 |
getSite().registerContextMenu(menuMgr, componentTreeViewer);
|
|
501 |
|
|
502 |
//
|
|
503 |
// Context menu for import functions pane
|
|
504 |
//
|
|
505 |
MenuManager menuMgr2 = new MenuManager("#ImportFunctionsPopupMenu"); //$NON-NLS-1$
|
|
506 |
menuMgr2.setRemoveAllWhenShown(true);
|
|
507 |
menuMgr2.addMenuListener(new IMenuListener() {
|
|
508 |
public void menuAboutToShow(IMenuManager manager) {
|
|
509 |
MainView.this.fillImportFunctionsTabContextMenu(manager);
|
|
510 |
}
|
|
511 |
});
|
|
512 |
|
|
513 |
Menu menu2 = menuMgr2.createContextMenu(importFunctionsViewer.getHostingViewer().getControl());
|
|
514 |
importFunctionsViewer.getHostingViewer().getControl().setMenu(menu2);
|
|
515 |
getSite().registerContextMenu(menuMgr2, importFunctionsViewer.getHostingViewer());
|
|
516 |
|
|
517 |
//
|
|
518 |
// Context menu for export functions pane
|
|
519 |
//
|
|
520 |
MenuManager menuMgr3 = new MenuManager("#ExportFunctionsPopupMenu"); //$NON-NLS-1$
|
|
521 |
menuMgr3.setRemoveAllWhenShown(true);
|
|
522 |
menuMgr3.addMenuListener(new IMenuListener() {
|
|
523 |
public void menuAboutToShow(IMenuManager manager) {
|
|
524 |
MainView.this.fillExportFunctionsTabContextMenu(manager);
|
|
525 |
}
|
|
526 |
});
|
|
527 |
|
|
528 |
Menu menu3 = menuMgr3.createContextMenu(exportFunctionsViewer.getHostingViewer().getControl());
|
|
529 |
exportFunctionsViewer.getHostingViewer().getControl().setMenu(menu3);
|
|
530 |
getSite().registerContextMenu(menuMgr3, exportFunctionsViewer.getHostingViewer());
|
|
531 |
|
|
532 |
//
|
|
533 |
// Context menu for component properties pane
|
|
534 |
//
|
|
535 |
MenuManager menuMgr4 = new MenuManager("#ComponentPropertiesPopupMenu"); //$NON-NLS-1$
|
|
536 |
menuMgr4.setRemoveAllWhenShown(true);
|
|
537 |
menuMgr4.addMenuListener(new IMenuListener() {
|
|
538 |
public void menuAboutToShow(IMenuManager manager) {
|
|
539 |
MainView.this.fillComponentPropertiesTabContextMenu(manager);
|
|
540 |
}
|
|
541 |
});
|
|
542 |
|
|
543 |
Menu menu4 = menuMgr4.createContextMenu(componentPropertiesViewer.getControl());
|
|
544 |
componentPropertiesViewer.getControl().setMenu(menu4);
|
|
545 |
getSite().registerContextMenu(menuMgr4, componentPropertiesViewer);
|
|
546 |
|
|
547 |
}
|
|
548 |
|
|
549 |
/**
|
|
550 |
* Contributes to view's main menu and toolbar.
|
|
551 |
*/
|
|
552 |
private void contributeToActionBars() {
|
|
553 |
IActionBars bars = getViewSite().getActionBars();
|
|
554 |
fillViewPullDownMenu(bars.getMenuManager());
|
|
555 |
fillViewToolBar(bars.getToolBarManager());
|
|
556 |
}
|
|
557 |
|
|
558 |
/**
|
|
559 |
* Fills view's main menu.
|
|
560 |
* @param manager Menu manager.
|
|
561 |
*/
|
|
562 |
private void fillViewPullDownMenu(IMenuManager manager) {
|
|
563 |
manager.add(actionSelectNewSDK);
|
|
564 |
manager.add(actionSelectNewRootComponent);
|
|
565 |
manager.add(actionCacheUpdate);
|
|
566 |
manager.add(addSisFilesAndUpdateCache);
|
|
567 |
manager.add(new Separator());
|
|
568 |
manager.add(actionExpandAll);
|
|
569 |
manager.add(actionCollapseAll);
|
|
570 |
|
|
571 |
// Finally updating action states
|
|
572 |
updateViewActionEnabledStates();
|
|
573 |
}
|
|
574 |
|
|
575 |
/**
|
|
576 |
* Checks if given node is parent node.
|
|
577 |
* @return <code>true</code> if parent node, otherwise <code>false</code>.
|
|
578 |
*/
|
|
579 |
private boolean isParentNode(){
|
|
580 |
Object obj = getComponentTreeSelectedElement();
|
|
581 |
if(obj != null && obj instanceof ComponentParentNode){
|
|
582 |
return true;
|
|
583 |
}else{
|
|
584 |
return false;
|
|
585 |
}
|
|
586 |
}
|
|
587 |
|
|
588 |
/**
|
|
589 |
* Fills tree view's context menu.
|
|
590 |
* @param manager Menu manager.
|
|
591 |
*/
|
|
592 |
private void fillTreeViewContextMenu(IMenuManager manager) {
|
|
593 |
manager.add(actionSetAsNewRoot);
|
|
594 |
manager.add(actionComponentIsUsedBy);
|
|
595 |
manager.add(actionComponentSearch);
|
|
596 |
manager.add(actionComponentFind);
|
|
597 |
manager.add(actionLocateComponent);
|
|
598 |
//Can't export only LeafNode
|
|
599 |
if(isParentNode()){
|
|
600 |
manager.add(actionExportReport);
|
|
601 |
}
|
|
602 |
manager.add(new Separator());
|
|
603 |
manager.add(actionExpandSubtree);
|
|
604 |
manager.add(actionExpandAll);
|
|
605 |
manager.add(actionCollapseAll);
|
|
606 |
manager.add(new Separator());
|
|
607 |
manager.add(actionComponentProperties);
|
|
608 |
manager.add(new Separator());
|
|
609 |
drillDownAdapter.addNavigationActions(manager);
|
|
610 |
// Other plug-ins can contribute there actions here
|
|
611 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
612 |
|
|
613 |
// Finally updating action states
|
|
614 |
updateViewActionEnabledStates();
|
|
615 |
}
|
|
616 |
|
|
617 |
/**
|
|
618 |
* Fills context menu for import functions tab.
|
|
619 |
* @param manager
|
|
620 |
*/
|
|
621 |
private void fillImportFunctionsTabContextMenu(IMenuManager manager) {
|
|
622 |
manager.add(actionImportFunctionIsUsedBy);
|
|
623 |
manager.add(actionImportShowSource);
|
|
624 |
manager.add(actionImportShowSourceInProject);
|
|
625 |
manager.add(actionImportShowMethodLoc);
|
|
626 |
manager.add(actionImportFunctionSearch);
|
|
627 |
manager.add(actionImportFunctionDataCopy);
|
|
628 |
manager.add(actionSelectAllImportFunctions);
|
|
629 |
// Other plug-ins can contribute there actions here
|
|
630 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
631 |
|
|
632 |
// Finally updating action states
|
|
633 |
updateViewActionEnabledStates();
|
|
634 |
}
|
|
635 |
|
|
636 |
/**
|
|
637 |
* Fills context menu for export functions tab.
|
|
638 |
* @param manager Menu manager.
|
|
639 |
*/
|
|
640 |
private void fillExportFunctionsTabContextMenu(IMenuManager manager) {
|
|
641 |
manager.add(actionExportFunctionIsUsedBy);
|
|
642 |
manager.add(actionExportShowSource);
|
|
643 |
manager.add(actionExportShowSourceInProject);
|
|
644 |
manager.add(actionExportFunctionSearch);
|
|
645 |
manager.add(actionExportFunctionDataCopy);
|
|
646 |
manager.add(actionSelectAllExportFunctions);
|
|
647 |
// Other plug-ins can contribute there actions here
|
|
648 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
649 |
|
|
650 |
// Finally updating action states
|
|
651 |
updateViewActionEnabledStates();
|
|
652 |
}
|
|
653 |
|
|
654 |
/**
|
|
655 |
* Fills context menu for component properties tab.
|
|
656 |
* @param manager Menu manager.
|
|
657 |
*/
|
|
658 |
private void fillComponentPropertiesTabContextMenu(IMenuManager manager) {
|
|
659 |
manager.add(actionCompPropertyDataCopy);
|
|
660 |
manager.add(actionSelectAllComponentProperties);
|
|
661 |
// Other plug-ins can contribute there actions here
|
|
662 |
manager.add(new Separator(IWorkbenchActionConstants.MB_ADDITIONS));
|
|
663 |
|
|
664 |
// Finally updating action states
|
|
665 |
updateViewActionEnabledStates();
|
|
666 |
}
|
|
667 |
|
|
668 |
/**
|
|
669 |
* Fills toolbar.
|
|
670 |
* @param manager Toolbar manager.
|
|
671 |
*/
|
|
672 |
private void fillViewToolBar(IToolBarManager manager) {
|
|
673 |
|
|
674 |
manager.add(actionSelectNewSDK);
|
|
675 |
manager.add(actionSelectNewRootComponent);
|
|
676 |
manager.add(actionCacheUpdate);
|
|
677 |
manager.add(addSisFilesAndUpdateCache);
|
|
678 |
manager.add(actionComponentFind);
|
|
679 |
manager.add(actionComponentSearch);
|
|
680 |
manager.add(new Separator());
|
|
681 |
manager.add(actionExpandAll);
|
|
682 |
manager.add(actionCollapseAll);
|
|
683 |
manager.add(new Separator());
|
|
684 |
drillDownAdapter.addNavigationActions(manager);
|
|
685 |
|
|
686 |
// Finally updating action states
|
|
687 |
updateViewActionEnabledStates();
|
|
688 |
}
|
|
689 |
|
|
690 |
/**
|
|
691 |
* Creates context menu actions for import functions tab.
|
|
692 |
*/
|
|
693 |
private void createImportFunctionsTabPopUpMenuActions(){
|
|
694 |
actionImportFunctionIsUsedBy = new FunctionIsUsedByImportFunctionMainViewAction(this);
|
|
695 |
actionImportShowSource = new ShowSourceFileImportFunctionMainViewAction(this);
|
|
696 |
actionImportShowSourceInProject = new ShowSourceFileAndCreateProjectImportFunctionMainViewAction(this);
|
|
697 |
actionImportShowMethodLoc = new ShowMethodCallLocationsImportFunctionMainViewAction(this);
|
|
698 |
ImportFunctionsClipboardCopyHandler funcCopyHandler = new ImportFunctionsClipboardCopyHandler();
|
|
699 |
actionImportFunctionDataCopy = new CopyFromTableViewerAction(importFunctionsViewer.getHostingViewer(),
|
|
700 |
new ICopyActionHandler[]{ funcCopyHandler }
|
|
701 |
);
|
|
702 |
actionSelectAllImportFunctions = new SelectAllFromTableViewerMainViewAction(this, importFunctionsViewer.getHostingViewer());
|
|
703 |
}
|
|
704 |
|
|
705 |
/**
|
|
706 |
* Creates context menu actions for export functions tab.
|
|
707 |
*/
|
|
708 |
private void createExportFunctionsTabPopUpMenuActions(){
|
|
709 |
|
|
710 |
actionExportFunctionIsUsedBy = new FunctionIsUsedByExportFunctionMainViewAction(this);
|
|
711 |
actionExportShowSource = new ShowSourceFileExportFunctionMainViewAction(this);
|
|
712 |
actionExportShowSourceInProject = new ShowSourceFileAndCreateProjectExportFunctionMainViewAction(this);
|
|
713 |
ExportFunctionsClipboardCopyHandler funcCopyHandler = new ExportFunctionsClipboardCopyHandler();
|
|
714 |
actionExportFunctionDataCopy = new CopyFromTableViewerAction(exportFunctionsViewer.getHostingViewer(),
|
|
715 |
new ICopyActionHandler[]{ funcCopyHandler }
|
|
716 |
);
|
|
717 |
actionSelectAllExportFunctions = new SelectAllFromTableViewerMainViewAction(this, exportFunctionsViewer.getHostingViewer());
|
|
718 |
}
|
|
719 |
|
|
720 |
/**
|
|
721 |
* Creates context menu actions for component properties tab.
|
|
722 |
*/
|
|
723 |
private void createComponentPropertiesTabPopUpMenuActions(){
|
|
724 |
ComponentPropertyTabClipboardCopyHandler propCopyHandler = new ComponentPropertyTabClipboardCopyHandler();
|
|
725 |
actionCompPropertyDataCopy = new CopyFromTableViewerAction(componentPropertiesViewer,
|
|
726 |
new ICopyActionHandler[]{ propCopyHandler }
|
|
727 |
);
|
|
728 |
actionSelectAllComponentProperties = new SelectAllFromTableViewerMainViewAction(this, componentPropertiesViewer);
|
|
729 |
}
|
|
730 |
|
|
731 |
/**
|
|
732 |
* Creates those actions that should be created very early in view creation
|
|
733 |
* in order to be able to set their enable/disable states.
|
|
734 |
*/
|
|
735 |
private void createOnlyMainViewDependentActions() {
|
|
736 |
actionSetAsNewRoot = new SetNewRootMainViewAction(this);
|
|
737 |
actionComponentIsUsedBy = new ComponentIsUsedByMainViewAction(this);
|
|
738 |
actionComponentSearch = new SearchMainViewAction(this, SearchConstants.SearchType.SEARCH_COMPONENTS);
|
|
739 |
actionImportFunctionSearch = new SearchMainViewAction(this, SearchConstants.SearchType.SEARCH_IMPORTED_FUNCTIONS);
|
|
740 |
actionExportFunctionSearch = new SearchMainViewAction(this, SearchConstants.SearchType.SEARCH_EXPORTED_FUNCTION);
|
|
741 |
actionComponentFind = new FindMainViewAction(this);
|
|
742 |
actionLocateComponent = new LocateComponentMainViewAction(this);
|
|
743 |
actionExpandAll = new ExpandAllMainViewAction(this);
|
|
744 |
actionCollapseAll = new CollapseAllMainViewAction(this);
|
|
745 |
actionExpandSubtree = new ExpandSubtreeMainViewAction(this);
|
|
746 |
actionSelectNewRootComponent = new SelectNewRootComponentMainViewAction(this);
|
|
747 |
actionSelectNewSDK = new SelectNewSDKMainViewAction(this);
|
|
748 |
actionCacheUpdate = new CacheUpdateMainViewAction(this);
|
|
749 |
addSisFilesAndUpdateCache = new AddSisAndUpdateCacheMainViewAction(this);
|
|
750 |
actionComponentProperties = new ComponentPropertiesMainViewAction(this);
|
|
751 |
actionExportReport = new ExportReportMainViewAction(this);
|
|
752 |
}
|
|
753 |
|
|
754 |
/**
|
|
755 |
* Passing the focus request to the componentTreeViewer's control.
|
|
756 |
*/
|
|
757 |
public void setFocus() {
|
|
758 |
componentTreeViewer.getControl().setFocus();
|
|
759 |
}
|
|
760 |
|
|
761 |
/**
|
|
762 |
* @return Returns the componentTreeViewer.
|
|
763 |
*/
|
|
764 |
public TreeViewer getComponentTreeViewer() {
|
|
765 |
return componentTreeViewer;
|
|
766 |
}
|
|
767 |
|
|
768 |
/**
|
|
769 |
* Allows other classes to update content description.
|
|
770 |
* @param newContentDescription New description.
|
|
771 |
*/
|
|
772 |
public void updateDescription(String newContentDescription){
|
|
773 |
setContentDescription(newContentDescription);
|
|
774 |
IToolBarManager tbManager = getViewSite().getActionBars().getToolBarManager();
|
|
775 |
tbManager.update(true);
|
|
776 |
}
|
|
777 |
|
|
778 |
/**
|
|
779 |
* Refereshes view contents.
|
|
780 |
*/
|
|
781 |
public void refresh(){
|
|
782 |
componentTreeViewer.refresh();
|
|
783 |
importFunctionsViewer.refreshHostingViewer(importFunctionsArrayList.size());
|
|
784 |
exportFunctionsViewer.refreshHostingViewer(exportFunctionsArrayList.size());
|
|
785 |
componentPropertiesViewer.refresh();
|
|
786 |
}
|
|
787 |
|
|
788 |
/**
|
|
789 |
* @return Returns the isDependencySearchOngoing.
|
|
790 |
*/
|
|
791 |
static public boolean isDependencySearchOngoing() {
|
|
792 |
return isDependencySearchOngoing;
|
|
793 |
}
|
|
794 |
|
|
795 |
/**
|
|
796 |
* Informs to main view that search was started.
|
|
797 |
* Toolbar is updated accordingly.
|
|
798 |
*/
|
|
799 |
public void searchStarted() {
|
|
800 |
isDependencySearchOngoing = true;
|
|
801 |
|
|
802 |
// Updating action states
|
|
803 |
updateViewActionEnabledStates();
|
|
804 |
}
|
|
805 |
|
|
806 |
/**
|
|
807 |
* Informs to main view that search was ended.
|
|
808 |
* Toolbar is updated accordingly.
|
|
809 |
*/
|
|
810 |
public void searchCompleted() {
|
|
811 |
|
|
812 |
isDependencySearchOngoing = false;
|
|
813 |
|
|
814 |
// Updating action states
|
|
815 |
updateViewActionEnabledStates();
|
|
816 |
}
|
|
817 |
|
|
818 |
/**
|
|
819 |
* Can be used to notify view that it's input data have changed.
|
|
820 |
* Triggers actions for refreshing view contents properly.
|
|
821 |
*/
|
|
822 |
public void inputUpdated() {
|
|
823 |
if(isDependencySearchOngoing){
|
|
824 |
// Aborting possible ongoing background searches
|
|
825 |
MainViewDataPopulator.abortCurrentSearch();
|
|
826 |
}
|
|
827 |
componentTreeViewer.setInput(compTreeViewerContentProv.getInput());
|
|
828 |
// The previously shown function lists are no more valid
|
|
829 |
importFunctionsArrayList.clear();
|
|
830 |
exportFunctionsArrayList.clear();
|
|
831 |
refresh();
|
|
832 |
// Expanding tree view enabling the showing of 1st level of the
|
|
833 |
// used components (that is actually 2nd level in the tree).
|
|
834 |
componentTreeViewer.expandToLevel(2);
|
|
835 |
componentTreeViewer.getTree().notifyListeners(SWT.Selection, new Event());
|
|
836 |
}
|
|
837 |
|
|
838 |
|
|
839 |
/**
|
|
840 |
* Checks if the root node is selected.
|
|
841 |
* @return Returns <code>true</code> if root node is selected
|
|
842 |
* otherwise <code>false</code>.
|
|
843 |
*/
|
|
844 |
public boolean isRootNodeSelected(){
|
|
845 |
Object obj = getComponentTreeSelectedElement();
|
|
846 |
if(obj != null){
|
|
847 |
if(obj instanceof ComponentParentNode){
|
|
848 |
ComponentParentNode parentNode = (ComponentParentNode) obj;
|
|
849 |
if(parentNode.isRootComponent()){
|
|
850 |
return true;
|
|
851 |
}
|
|
852 |
}
|
|
853 |
}
|
|
854 |
return false;
|
|
855 |
}
|
|
856 |
|
|
857 |
/**
|
|
858 |
* Checks if the selected component has subtree.
|
|
859 |
* @return Returns <code>true</code> if selected component has subtree,
|
|
860 |
* otherwise <code>false</code> (also false returned in error situations).
|
|
861 |
*/
|
|
862 |
public boolean hasSelectedComponentSubtree(){
|
|
863 |
Object obj = getComponentTreeSelectedElement();
|
|
864 |
if(obj != null){
|
|
865 |
if(obj instanceof ComponentParentNode){
|
|
866 |
return componentTreeViewer.isExpandable(obj);
|
|
867 |
}
|
|
868 |
}
|
|
869 |
return false;
|
|
870 |
}
|
|
871 |
|
|
872 |
/**
|
|
873 |
* Checks if the selected component exists.
|
|
874 |
* @return Returns <code>true</code> if selected component exists,
|
|
875 |
* otherwise <code>false</code> (also false returned in error situations).
|
|
876 |
*/
|
|
877 |
public boolean selectedComponentExist(){
|
|
878 |
Object obj = getComponentTreeSelectedElement();
|
|
879 |
ComponentParentNode nodeToBeChecked;
|
|
880 |
if(obj != null){
|
|
881 |
if(obj instanceof ComponentParentNode){
|
|
882 |
nodeToBeChecked = (ComponentParentNode) obj;
|
|
883 |
}
|
|
884 |
else if(obj instanceof ComponentLinkLeafNode){
|
|
885 |
ComponentLinkLeafNode link = (ComponentLinkLeafNode) obj;
|
|
886 |
nodeToBeChecked = link.getReferredComponent();
|
|
887 |
}
|
|
888 |
else{
|
|
889 |
return false;
|
|
890 |
}
|
|
891 |
// Checking if component exists in cache
|
|
892 |
if(!nodeToBeChecked.isMissing()){
|
|
893 |
return true;
|
|
894 |
}
|
|
895 |
}
|
|
896 |
return false;
|
|
897 |
}
|
|
898 |
|
|
899 |
/**
|
|
900 |
* Returns currently selected element from
|
|
901 |
* component tree
|
|
902 |
* @return Returns currently selected element or <code>null</code>
|
|
903 |
* if there are no selection made.
|
|
904 |
*/
|
|
905 |
public Object getComponentTreeSelectedElement() {
|
|
906 |
ISelection selection = componentTreeViewer.getSelection();
|
|
907 |
Object obj = ((IStructuredSelection)selection).getFirstElement();
|
|
908 |
return obj;
|
|
909 |
}
|
|
910 |
|
|
911 |
/**
|
|
912 |
* Returns currently selected element among
|
|
913 |
* the imported functions.
|
|
914 |
* @return Returns currently selected element or <code>null</code>
|
|
915 |
* if there are no selection made.
|
|
916 |
*/
|
|
917 |
public Object getSelectedImportFunction() {
|
|
918 |
ISelection selection = importFunctionsViewer.getHostingViewer().getSelection();
|
|
919 |
Object obj = ((IStructuredSelection)selection).getFirstElement();
|
|
920 |
return obj;
|
|
921 |
}
|
|
922 |
|
|
923 |
/* (non-Javadoc)
|
|
924 |
* @see org.eclipse.ui.part.ViewPart#init(org.eclipse.ui.IViewSite, org.eclipse.ui.IMemento)
|
|
925 |
*/
|
|
926 |
@Override
|
|
927 |
public void init(IViewSite site, IMemento memento) throws PartInitException {
|
|
928 |
super.init(site, memento);
|
|
929 |
}
|
|
930 |
|
|
931 |
/* (non-Javadoc)
|
|
932 |
* @see org.eclipse.ui.part.WorkbenchPart#dispose()
|
|
933 |
*/
|
|
934 |
public void dispose() {
|
|
935 |
if(isDependencySearchOngoing){
|
|
936 |
// Aborting possible ongoing background searches
|
|
937 |
MainViewDataPopulator.abortCurrentSearch();
|
|
938 |
}
|
|
939 |
|
|
940 |
super.dispose();
|
|
941 |
}
|
|
942 |
|
|
943 |
/**
|
|
944 |
* @return Returns the selectedComponentPropertiesData.
|
|
945 |
*/
|
|
946 |
public ComponentPropertiesData getSelectedComponentPropertiesData() {
|
|
947 |
return selectedComponentPropertiesData;
|
|
948 |
}
|
|
949 |
|
|
950 |
/**
|
|
951 |
* @param selectedComponentPropertiesData The selectedComponentPropertiesData to set.
|
|
952 |
*/
|
|
953 |
public void setSelectedComponentPropertiesData(
|
|
954 |
ComponentPropertiesData selectedComponentPropertiesData) {
|
|
955 |
this.selectedComponentPropertiesData = selectedComponentPropertiesData;
|
|
956 |
}
|
|
957 |
|
|
958 |
/**
|
|
959 |
* @return Returns the importFunctionsViewer.
|
|
960 |
*/
|
|
961 |
public TableViewer getImportFunctionsViewer() {
|
|
962 |
return importFunctionsViewer.getHostingViewer();
|
|
963 |
}
|
|
964 |
|
|
965 |
/**
|
|
966 |
* Updates context menu for import functions tab.
|
|
967 |
* @param isMultipleSelection <code>true</code> in case of multiple selection
|
|
968 |
* otherwise <code>false</code>.
|
|
969 |
*/
|
|
970 |
public void updateImportFunctionsContextMenuStates(boolean isMultipleSelection) {
|
|
971 |
if(isMultipleSelection){
|
|
972 |
actionImportFunctionIsUsedBy.setEnabled(false);
|
|
973 |
enableImportShowSourceAction();
|
|
974 |
}
|
|
975 |
else{
|
|
976 |
actionImportFunctionIsUsedBy.setEnabled(true);
|
|
977 |
disableImportShowSourceAction();
|
|
978 |
}
|
|
979 |
}
|
|
980 |
|
|
981 |
/**
|
|
982 |
* Enables show source functionality
|
|
983 |
*/
|
|
984 |
public void enableImportShowSourceAction() {
|
|
985 |
actionImportShowSource.setEnabled(true);
|
|
986 |
actionImportShowMethodLoc.setEnabled(true);
|
|
987 |
actionImportShowSourceInProject.setEnabled(true);
|
|
988 |
}
|
|
989 |
|
|
990 |
/**
|
|
991 |
* Disables show source functionality
|
|
992 |
*/
|
|
993 |
public void disableImportShowSourceAction() {
|
|
994 |
actionImportShowSource.setEnabled(false);
|
|
995 |
actionImportShowMethodLoc.setEnabled(false);
|
|
996 |
actionImportShowSourceInProject.setEnabled(false);
|
|
997 |
}
|
|
998 |
|
|
999 |
/**
|
|
1000 |
* Disables Locate source action.
|
|
1001 |
*/
|
|
1002 |
public void disableLocateComponentAction(){
|
|
1003 |
actionLocateComponent.setEnabled(false);
|
|
1004 |
}
|
|
1005 |
|
|
1006 |
/**
|
|
1007 |
* Enables Locate source action.
|
|
1008 |
*/
|
|
1009 |
public void enableLocateComponentAction(){
|
|
1010 |
actionLocateComponent.setEnabled(true);
|
|
1011 |
}
|
|
1012 |
|
|
1013 |
/**
|
|
1014 |
* Disables actionSetAsNewRoot action.
|
|
1015 |
*/
|
|
1016 |
public void disableSetAsNewRootAction(){
|
|
1017 |
actionSetAsNewRoot.setEnabled(false);
|
|
1018 |
}
|
|
1019 |
|
|
1020 |
/**
|
|
1021 |
* Enables actionSetAsNewRoot action.
|
|
1022 |
*/
|
|
1023 |
public void enableSetAsNewRootAction(){
|
|
1024 |
actionSetAsNewRoot.setEnabled(true);
|
|
1025 |
}
|
|
1026 |
|
|
1027 |
/**
|
|
1028 |
* Enables to get reference of the main view
|
|
1029 |
* from the classes that do not actually
|
|
1030 |
* have reference to the main view instance.
|
|
1031 |
* This method opens activates/opens up the
|
|
1032 |
* view if it was not visible.
|
|
1033 |
* @throws PartInitException
|
|
1034 |
*/
|
|
1035 |
public static MainView getViewInstance() throws PartInitException{
|
|
1036 |
|
|
1037 |
IWorkbenchPage page = AppDepPlugin.getCurrentlyActivePage();
|
|
1038 |
|
|
1039 |
boolean viewAlreadyVisible = false;
|
|
1040 |
IViewPart viewPart = null;
|
|
1041 |
|
|
1042 |
// Checking if view is already open
|
|
1043 |
IViewReference[] viewRefs = page.getViewReferences();
|
|
1044 |
for (int i = 0; i < viewRefs.length; i++) {
|
|
1045 |
IViewReference reference = viewRefs[i];
|
|
1046 |
String id = reference.getId();
|
|
1047 |
if(id.equalsIgnoreCase(MainView.ID)){
|
|
1048 |
viewAlreadyVisible = true;
|
|
1049 |
// Found, restoring the view
|
|
1050 |
viewPart = reference.getView(true);
|
|
1051 |
page.activate(viewPart);
|
|
1052 |
}
|
|
1053 |
}
|
|
1054 |
// View was not opened
|
|
1055 |
if(! viewAlreadyVisible){
|
|
1056 |
viewPart = page.showView(MainView.ID);
|
|
1057 |
}
|
|
1058 |
return ((MainView) viewPart);
|
|
1059 |
}
|
|
1060 |
|
|
1061 |
/**
|
|
1062 |
* Enables update request for the main view
|
|
1063 |
* also from the classes that do not actually
|
|
1064 |
* have reference to the main view instance.
|
|
1065 |
*/
|
|
1066 |
public static void update(){
|
|
1067 |
try {
|
|
1068 |
|
|
1069 |
getViewInstance().inputUpdated();
|
|
1070 |
|
|
1071 |
} catch (PartInitException e) {
|
|
1072 |
e.printStackTrace();
|
|
1073 |
}
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
/**
|
|
1077 |
* Aborts currently ongoing search (if dependency search is ongoing).
|
|
1078 |
*/
|
|
1079 |
public static void abortCurrentlyOngoingSearches(){
|
|
1080 |
if(isDependencySearchOngoing){
|
|
1081 |
MainViewDataPopulator.abortCurrentSearch();
|
|
1082 |
}
|
|
1083 |
}
|
|
1084 |
|
|
1085 |
/**
|
|
1086 |
* Because Window's native table component does not support
|
|
1087 |
* text wrapping, this method offers possibility to resize
|
|
1088 |
* Value column according to data. Resizing brings about
|
|
1089 |
* scroll bars that enable seeing of all the data.
|
|
1090 |
*/
|
|
1091 |
public void performValueColumnPackToPropertiesTab(){
|
|
1092 |
Table table = componentPropertiesViewer.getTable();
|
|
1093 |
TableColumn column = table.getColumn(ComponentPropertiesData.VALUE_COLUMN_INDEX);
|
|
1094 |
column.pack();
|
|
1095 |
}
|
|
1096 |
|
|
1097 |
/**
|
|
1098 |
* Updates context menu for export functions tab.
|
|
1099 |
* @param isMultipleSelection <code>true</code> in case of multiple selection
|
|
1100 |
* otherwise <code>false</code>.
|
|
1101 |
*/
|
|
1102 |
public void updateExportFunctionsContextMenuStates(boolean isMultipleSelection) {
|
|
1103 |
if(isMultipleSelection){
|
|
1104 |
actionExportFunctionIsUsedBy.setEnabled(false);
|
|
1105 |
disableExportShowSourceAction();
|
|
1106 |
}
|
|
1107 |
else{
|
|
1108 |
actionExportFunctionIsUsedBy.setEnabled(true);
|
|
1109 |
enableExportShowSourceAction();
|
|
1110 |
}
|
|
1111 |
}
|
|
1112 |
|
|
1113 |
/**
|
|
1114 |
* Enables show source functionality
|
|
1115 |
*/
|
|
1116 |
public void enableExportShowSourceAction() {
|
|
1117 |
actionExportShowSource.setEnabled(true);
|
|
1118 |
actionExportShowSourceInProject.setEnabled(true);
|
|
1119 |
}
|
|
1120 |
|
|
1121 |
/**
|
|
1122 |
* Disables show source functionality
|
|
1123 |
*/
|
|
1124 |
public void disableExportShowSourceAction() {
|
|
1125 |
actionExportShowSource.setEnabled(false);
|
|
1126 |
actionExportShowSourceInProject.setEnabled(false);
|
|
1127 |
}
|
|
1128 |
|
|
1129 |
/**
|
|
1130 |
* @return Returns the exportFunctionsViewer.
|
|
1131 |
*/
|
|
1132 |
public TableViewer getExportFunctionsViewer() {
|
|
1133 |
return exportFunctionsViewer.getHostingViewer();
|
|
1134 |
}
|
|
1135 |
|
|
1136 |
/**
|
|
1137 |
* Gets currently selected export function.
|
|
1138 |
* @return currently selected export function.
|
|
1139 |
*/
|
|
1140 |
public Object getSelectedExportFunction() {
|
|
1141 |
ISelection selection = getExportFunctionsViewer().getSelection();
|
|
1142 |
Object obj = ((IStructuredSelection)selection).getFirstElement();
|
|
1143 |
return obj;
|
|
1144 |
}
|
|
1145 |
|
|
1146 |
/**
|
|
1147 |
* Gets the most recently selected component from tree view.
|
|
1148 |
* @return Returns the mostRecentlySelectedComponentNode.
|
|
1149 |
*/
|
|
1150 |
public Object getMostRecentlySelectedComponentNode() {
|
|
1151 |
return mostRecentlySelectedComponentNode;
|
|
1152 |
}
|
|
1153 |
|
|
1154 |
/**
|
|
1155 |
* Sets the most recently selected component from tree view.
|
|
1156 |
* @param mostRecentlySelectedComponentNode The mostRecentlySelectedComponentNode to set.
|
|
1157 |
*/
|
|
1158 |
public void setMostRecentlySelectedComponentNode(
|
|
1159 |
Object mostRecentlySelectedComponentNode) {
|
|
1160 |
this.mostRecentlySelectedComponentNode = mostRecentlySelectedComponentNode;
|
|
1161 |
}
|
|
1162 |
|
|
1163 |
/**
|
|
1164 |
* Gets current root component node.
|
|
1165 |
* @return Current root component node.
|
|
1166 |
*/
|
|
1167 |
public ComponentParentNode getRootComponentNode() {
|
|
1168 |
return (ComponentParentNode) compTreeViewerContentProv.getRootComponentNode();
|
|
1169 |
}
|
|
1170 |
|
|
1171 |
/* (non-Javadoc)
|
|
1172 |
* @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
|
|
1173 |
*/
|
|
1174 |
public void keyPressed(KeyEvent e) {
|
|
1175 |
// Key presses are only enabled when there is no dependency search ongoing
|
|
1176 |
if(isDependencySearchOngoing){
|
|
1177 |
String infoMsg = Messages.getString("MainView.KeyPresses_Disabled_While_Search_Is_Ongoing_InfoMsg"); //$NON-NLS-1$
|
|
1178 |
new AppDepMessageBox(infoMsg, SWT.OK | SWT.ICON_INFORMATION).open();
|
|
1179 |
}
|
|
1180 |
else{
|
|
1181 |
//
|
|
1182 |
// Checking if Ctrl+F was pressed and triggering find action, if pressed
|
|
1183 |
//
|
|
1184 |
final int CTRL_F = 0x6;
|
|
1185 |
int charValue = e.character;
|
|
1186 |
boolean ctrlFPressed = charValue == CTRL_F; // This should be enough
|
|
1187 |
boolean ctrlPressed = (e.stateMask & SWT.CTRL) != 0; // But still checking that Ctrl is also pressed
|
|
1188 |
if(ctrlPressed & ctrlFPressed){
|
|
1189 |
// Triggering find action
|
|
1190 |
actionComponentFind.run();
|
|
1191 |
}
|
|
1192 |
}
|
|
1193 |
}
|
|
1194 |
|
|
1195 |
/* (non-Javadoc)
|
|
1196 |
* @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
|
|
1197 |
*/
|
|
1198 |
public void keyReleased(KeyEvent e) {
|
|
1199 |
// Not needed, but has to be implemented
|
|
1200 |
}
|
|
1201 |
|
|
1202 |
/**
|
|
1203 |
* Activates the given node in Main view's component tree.
|
|
1204 |
* The given node is set as current selection.
|
|
1205 |
* @param node Component node to be activated.
|
|
1206 |
*/
|
|
1207 |
public void activateTreeViewComponent(ComponentNode node) {
|
|
1208 |
|
|
1209 |
// Making sure that referred component can be found
|
|
1210 |
if(drillDownAdapter.canGoHome()){
|
|
1211 |
drillDownAdapter.goHome();
|
|
1212 |
}
|
|
1213 |
|
|
1214 |
ProgrammaticSelection newSelection = null;
|
|
1215 |
newSelection = new ProgrammaticSelection(
|
|
1216 |
new ComponentNode[]{
|
|
1217 |
node
|
|
1218 |
}
|
|
1219 |
);
|
|
1220 |
getComponentTreeViewer().setSelection(newSelection, true);
|
|
1221 |
refresh();
|
|
1222 |
}
|
|
1223 |
|
|
1224 |
/**
|
|
1225 |
* We will disable show source functionality for some "method" names,
|
|
1226 |
* which are no real method names. List for prefixes is stored in here and
|
|
1227 |
* all clients of {@link MainView} can be used them.
|
|
1228 |
*
|
|
1229 |
* @return the DISABLE_SHOW_SOURCE_PREFIXES
|
|
1230 |
*/
|
|
1231 |
public String[] getDisableShowSourcePrefixes() {
|
|
1232 |
return DISABLE_SHOW_SOURCE_PREFIXES;
|
|
1233 |
}
|
|
1234 |
|
|
1235 |
/**
|
|
1236 |
* Checks if the imported functions tab has currently any imported functions.
|
|
1237 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1238 |
*/
|
|
1239 |
private boolean hasImportFunctions() {
|
|
1240 |
return (importFunctionsArrayList.size() > 0);
|
|
1241 |
}
|
|
1242 |
|
|
1243 |
/**
|
|
1244 |
* Checks if the imported functions tab has currently any selections.
|
|
1245 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1246 |
*/
|
|
1247 |
private boolean hasImportFunctionSelection() {
|
|
1248 |
int selectionCount = importFunctionsSelectionCount();
|
|
1249 |
return (selectionCount > 0);
|
|
1250 |
}
|
|
1251 |
|
|
1252 |
/**
|
|
1253 |
* Checks if only single imported functions is selected.
|
|
1254 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1255 |
*/
|
|
1256 |
private boolean hasImportFunctionSingleSelection() {
|
|
1257 |
int selectionCount = importFunctionsSelectionCount();
|
|
1258 |
return (selectionCount == 1);
|
|
1259 |
}
|
|
1260 |
|
|
1261 |
/**
|
|
1262 |
* Gets import functions viewer selection count.
|
|
1263 |
* @return import functions viewer selection count.
|
|
1264 |
*/
|
|
1265 |
private int importFunctionsSelectionCount() {
|
|
1266 |
return importFunctionsViewer.getSelectionCount();
|
|
1267 |
}
|
|
1268 |
|
|
1269 |
/**
|
|
1270 |
* Checks if all import functions has been selected.
|
|
1271 |
* @return <code>true</code> if all selected, otherwise <code>false</code>.
|
|
1272 |
*/
|
|
1273 |
private boolean isAllImportFunctionsSelected() {
|
|
1274 |
return (importFunctionsArrayList.size() == importFunctionsSelectionCount());
|
|
1275 |
}
|
|
1276 |
|
|
1277 |
/**
|
|
1278 |
* Checks if the exported functions tab has currently any exported functions.
|
|
1279 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1280 |
*/
|
|
1281 |
private boolean hasExportFunctions() {
|
|
1282 |
return (exportFunctionsArrayList.size() > 0);
|
|
1283 |
}
|
|
1284 |
|
|
1285 |
/**
|
|
1286 |
* Checks if the exported functions tab has currently any selections.
|
|
1287 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1288 |
*/
|
|
1289 |
private boolean hasExportFunctionSelection() {
|
|
1290 |
int selectionCount = exportFunctionsSelectionCount();
|
|
1291 |
return (selectionCount > 0);
|
|
1292 |
}
|
|
1293 |
|
|
1294 |
/**
|
|
1295 |
* Checks if only single exported functions is selected.
|
|
1296 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1297 |
*/
|
|
1298 |
private boolean hasExportFunctionSingleSelection() {
|
|
1299 |
int selectionCount = exportFunctionsSelectionCount();
|
|
1300 |
return (selectionCount == 1);
|
|
1301 |
}
|
|
1302 |
|
|
1303 |
/**
|
|
1304 |
* Gets export functions viewer selection count.
|
|
1305 |
* @return export functions viewer selection count.
|
|
1306 |
*/
|
|
1307 |
private int exportFunctionsSelectionCount() {
|
|
1308 |
return exportFunctionsViewer.getSelectionCount();
|
|
1309 |
}
|
|
1310 |
|
|
1311 |
/**
|
|
1312 |
* Checks if all export functions has been selected.
|
|
1313 |
* @return <code>true</code> if all selected, otherwise <code>false</code>.
|
|
1314 |
*/
|
|
1315 |
private boolean isAllExportFunctionsSelected() {
|
|
1316 |
return (exportFunctionsArrayList.size() == exportFunctionsSelectionCount());
|
|
1317 |
}
|
|
1318 |
|
|
1319 |
/**
|
|
1320 |
* Checks if the component properties tab has currently any selections.
|
|
1321 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1322 |
*/
|
|
1323 |
private boolean hasCompPropertiesSelection() {
|
|
1324 |
int selectionCount = componentPropertiesSelectionCount();
|
|
1325 |
return (selectionCount > 0);
|
|
1326 |
}
|
|
1327 |
|
|
1328 |
/**
|
|
1329 |
* Gets component properties viewer selection count.
|
|
1330 |
* @return component properties viewer selection count.
|
|
1331 |
*/
|
|
1332 |
private int componentPropertiesSelectionCount() {
|
|
1333 |
return componentPropertiesViewer.getTable().getSelectionCount();
|
|
1334 |
}
|
|
1335 |
|
|
1336 |
/**
|
|
1337 |
* Checks if all component properties has been selected.
|
|
1338 |
* @return <code>true</code> if all selected, otherwise <code>false</code>.
|
|
1339 |
*/
|
|
1340 |
private boolean isAllCompPropertiesSelected() {
|
|
1341 |
return (ComponentPropertiesData.DESCRIPT_ARR.length == componentPropertiesSelectionCount());
|
|
1342 |
}
|
|
1343 |
|
|
1344 |
/**
|
|
1345 |
* Checks if the component properties tab has currently any properties.
|
|
1346 |
* @return <code>true</code> if has, otherwise <code>false</code>.
|
|
1347 |
*/
|
|
1348 |
private boolean hasCompProperties() {
|
|
1349 |
return (componentPropertiesViewer.getTable().getItemCount() > 0);
|
|
1350 |
}
|
|
1351 |
|
|
1352 |
/**
|
|
1353 |
* Sets enabled/disabled states for actions commands
|
|
1354 |
* on this view, based on the current application state.
|
|
1355 |
* This method should be called whenever an operation is
|
|
1356 |
* started or stopped that might have effect on action
|
|
1357 |
* button states.
|
|
1358 |
*/
|
|
1359 |
public void updateViewActionEnabledStates(){
|
|
1360 |
|
|
1361 |
// Resolving current state
|
|
1362 |
boolean isRootComponentSelectedForAnalysis = AppDepSettings.isRootComponentSelectedForAnalysis();
|
|
1363 |
boolean isValidComponentSelection = isRootComponentSelectedForAnalysis && (getComponentTreeSelectedElement() != null);
|
|
1364 |
boolean isCurrentSelectionRootComponent = isRootNodeSelected();
|
|
1365 |
|
|
1366 |
// Main menu & toolbar & common actions
|
|
1367 |
setEnableState(actionSelectNewSDK, !isDependencySearchOngoing());
|
|
1368 |
setEnableState(actionSelectNewRootComponent, !isDependencySearchOngoing() && isRootComponentSelectedForAnalysis);
|
|
1369 |
setEnableState(actionCacheUpdate, isRootComponentSelectedForAnalysis);
|
|
1370 |
setEnableState(addSisFilesAndUpdateCache, isRootComponentSelectedForAnalysis);
|
|
1371 |
setEnableState(actionComponentFind, isRootComponentSelectedForAnalysis);
|
|
1372 |
setEnableState(actionComponentSearch, isRootComponentSelectedForAnalysis);
|
|
1373 |
setEnableState(actionExpandAll, isRootComponentSelectedForAnalysis);
|
|
1374 |
setEnableState(actionCollapseAll, isRootComponentSelectedForAnalysis);
|
|
1375 |
|
|
1376 |
// Tree view
|
|
1377 |
boolean selectedComponentExist = selectedComponentExist();
|
|
1378 |
setEnableState(actionSetAsNewRoot, isValidComponentSelection && !isCurrentSelectionRootComponent && selectedComponentExist);
|
|
1379 |
setEnableState(actionComponentIsUsedBy, isValidComponentSelection);
|
|
1380 |
setEnableState(actionLocateComponent, isValidComponentSelection && !selectedComponentExist);
|
|
1381 |
setEnableState(actionExportReport, isValidComponentSelection);
|
|
1382 |
setEnableState(actionExpandSubtree, isValidComponentSelection && hasSelectedComponentSubtree());
|
|
1383 |
setEnableState(actionComponentProperties, isValidComponentSelection && selectedComponentExist);
|
|
1384 |
|
|
1385 |
// Import function
|
|
1386 |
boolean isImportActionsEnabled = isValidComponentSelection && hasImportFunctions();
|
|
1387 |
boolean hasImportFunctionSelection = isImportActionsEnabled && hasImportFunctionSelection();
|
|
1388 |
boolean hasImportFunctionSingleSelection = isImportActionsEnabled && hasImportFunctionSingleSelection();
|
|
1389 |
boolean isAllImportFunctionsSelected = isImportActionsEnabled && isAllImportFunctionsSelected();
|
|
1390 |
setEnableState(actionImportFunctionIsUsedBy, hasImportFunctionSingleSelection);
|
|
1391 |
setEnableState(actionImportShowSource, hasImportFunctionSingleSelection);
|
|
1392 |
setEnableState(actionImportShowSourceInProject, hasImportFunctionSingleSelection);
|
|
1393 |
setEnableState(actionImportShowMethodLoc, hasImportFunctionSingleSelection);
|
|
1394 |
setEnableState(actionImportFunctionSearch, isImportActionsEnabled);
|
|
1395 |
setEnableState(actionImportFunctionDataCopy, hasImportFunctionSelection);
|
|
1396 |
setEnableState(actionSelectAllImportFunctions, isImportActionsEnabled && !isAllImportFunctionsSelected);
|
|
1397 |
|
|
1398 |
// Export functions
|
|
1399 |
boolean isExportActionsEnabled = isValidComponentSelection && hasExportFunctions();
|
|
1400 |
boolean hasExportFunctionSelection = isExportActionsEnabled && hasExportFunctionSelection();
|
|
1401 |
boolean hasExportFunctionSingleSelection = isExportActionsEnabled && hasExportFunctionSingleSelection();
|
|
1402 |
boolean isAllExportFunctionsSelected = isExportActionsEnabled && isAllExportFunctionsSelected();
|
|
1403 |
setEnableState(actionExportFunctionIsUsedBy, hasExportFunctionSingleSelection);
|
|
1404 |
setEnableState(actionExportShowSource, hasExportFunctionSingleSelection);
|
|
1405 |
setEnableState(actionExportShowSourceInProject, hasExportFunctionSingleSelection);
|
|
1406 |
setEnableState(actionExportFunctionSearch, isExportActionsEnabled);
|
|
1407 |
setEnableState(actionExportFunctionDataCopy, hasExportFunctionSelection);
|
|
1408 |
setEnableState(actionSelectAllExportFunctions, isExportActionsEnabled && !isAllExportFunctionsSelected);
|
|
1409 |
|
|
1410 |
// Component properties
|
|
1411 |
boolean isCompPropActionsEnabled = isValidComponentSelection && hasCompProperties();
|
|
1412 |
boolean hasCompPropertiesSelection = isCompPropActionsEnabled && hasCompPropertiesSelection();
|
|
1413 |
boolean isAllCompPropertiesSelected = isCompPropActionsEnabled && isAllCompPropertiesSelected();
|
|
1414 |
setEnableState(actionCompPropertyDataCopy, hasCompPropertiesSelection);
|
|
1415 |
setEnableState(actionSelectAllComponentProperties, isCompPropActionsEnabled && !isAllCompPropertiesSelected);
|
|
1416 |
|
|
1417 |
}
|
|
1418 |
|
|
1419 |
/**
|
|
1420 |
* Sets given enable state for an action if it is non <code>null</code>.
|
|
1421 |
* @param action Action to set enable status for.
|
|
1422 |
* @param enableStatus <code>true</code> if enabled, otherwise <code>false</code>.
|
|
1423 |
*/
|
|
1424 |
private void setEnableState(Action action, boolean enableStatus) {
|
|
1425 |
if(action != null){
|
|
1426 |
action.setEnabled(enableStatus);
|
|
1427 |
}
|
|
1428 |
}
|
|
1429 |
|
|
1430 |
}
|