Commit | Line | Data |
---|---|---|
73005152 | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2005, 2013 IBM Corporation, Ericsson |
73005152 BH |
3 | * All rights reserved. This program and the accompanying materials |
4 | * are made available under the terms of the Eclipse Public License v1.0 | |
5 | * which accompanies this distribution, and is available at | |
6 | * http://www.eclipse.org/legal/epl-v10.html | |
a55887ca AM |
7 | * |
8 | * Contributors: | |
c8422608 AM |
9 | * IBM - Initial API and implementation |
10 | * Bernd Hufmann - Updated for TMF | |
73005152 | 11 | **********************************************************************/ |
c8422608 | 12 | |
73005152 BH |
13 | package org.eclipse.linuxtools.tmf.ui.views.uml2sd; |
14 | ||
15 | import java.util.Iterator; | |
16 | ||
17 | import org.eclipse.jface.action.Action; | |
18 | import org.eclipse.jface.action.ActionContributionItem; | |
19 | import org.eclipse.jface.action.IAction; | |
20 | import org.eclipse.jface.action.IContributionItem; | |
21 | import org.eclipse.jface.action.IMenuListener; | |
22 | import org.eclipse.jface.action.IMenuManager; | |
23 | import org.eclipse.jface.action.IToolBarManager; | |
24 | import org.eclipse.jface.action.MenuManager; | |
25 | import org.eclipse.jface.action.Separator; | |
26 | import org.eclipse.jface.viewers.ISelection; | |
27 | import org.eclipse.jface.viewers.ISelectionProvider; | |
28 | import org.eclipse.jface.viewers.StructuredSelection; | |
8fd82db5 | 29 | import org.eclipse.linuxtools.internal.tmf.ui.Activator; |
a55887ca | 30 | import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants; |
73005152 BH |
31 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage; |
32 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame; | |
33 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode; | |
34 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessage; | |
35 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.SyncMessageReturn; | |
36 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax; | |
37 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.FirstPage; | |
38 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.KeyBindingsManager; | |
39 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.LastPage; | |
40 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.MoveToMessage; | |
41 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.NextPage; | |
42 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.OpenSDFiltersDialog; | |
43 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.OpenSDFindDialog; | |
44 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.OpenSDPagesDialog; | |
45 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.PrevPage; | |
46 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.Print; | |
47 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd; | |
48 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart; | |
49 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.Zoom; | |
50 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.Zoom.ZoomType; | |
51 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.IExtendedFilterProvider; | |
52 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.IExtendedFindProvider; | |
73005152 BH |
53 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDAdvancedPagingProvider; |
54 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDCollapseProvider; | |
55 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDExtendedActionBarProvider; | |
56 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider; | |
57 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider; | |
8a95ce5a | 58 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter; |
73005152 BH |
59 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider; |
60 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPropertiesProvider; | |
61 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader; | |
62 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.LoadersManager; | |
63 | import org.eclipse.linuxtools.tmf.ui.views.uml2sd.util.SDMessages; | |
64 | import org.eclipse.swt.SWT; | |
65 | import org.eclipse.swt.graphics.Cursor; | |
66 | import org.eclipse.swt.layout.GridData; | |
67 | import org.eclipse.swt.layout.GridLayout; | |
68 | import org.eclipse.swt.widgets.Composite; | |
69 | import org.eclipse.swt.widgets.Menu; | |
70 | import org.eclipse.ui.IActionBars; | |
71 | import org.eclipse.ui.IViewReference; | |
72 | import org.eclipse.ui.IWorkbenchPage; | |
73 | import org.eclipse.ui.PlatformUI; | |
74 | import org.eclipse.ui.actions.ActionFactory; | |
75 | import org.eclipse.ui.part.ViewPart; | |
ebf38fcc | 76 | import org.eclipse.ui.views.properties.IPropertySheetPage; |
73005152 BH |
77 | |
78 | /** | |
df0b8ff4 BH |
79 | * <p> |
80 | * This class is a generic sequence diagram view implementation. | |
81 | * </p> | |
82 | ||
a55887ca | 83 | * @version 1.0 |
73005152 | 84 | * @author sveyrier |
73005152 BH |
85 | */ |
86 | public class SDView extends ViewPart { | |
87 | ||
df0b8ff4 BH |
88 | // ------------------------------------------------------------------------ |
89 | // Attributes | |
90 | // ------------------------------------------------------------------------ | |
91 | /** | |
92 | * The sequence diagram widget. | |
93 | */ | |
eb63f5ff | 94 | protected SDWidget fSdWidget = null; |
df0b8ff4 BH |
95 | /** |
96 | * The time compression bar. | |
97 | */ | |
eb63f5ff | 98 | protected TimeCompressionBar fTimeCompressionBar = null; |
df0b8ff4 BH |
99 | /** |
100 | * The sequence diagram find provider implementation. | |
101 | */ | |
eb63f5ff | 102 | protected ISDFindProvider fSdFindProvider = null; |
df0b8ff4 BH |
103 | /** |
104 | * The sequence diagram paging provider implementation. | |
105 | */ | |
eb63f5ff | 106 | protected ISDPagingProvider fSdPagingProvider = null; |
df0b8ff4 BH |
107 | /** |
108 | * The sequence diagram filter provider implementation. | |
109 | */ | |
eb63f5ff | 110 | protected ISDFilterProvider fSdFilterProvider = null; |
df0b8ff4 BH |
111 | /** |
112 | * The extended sequence diagram filter provider implementation. | |
113 | */ | |
eb63f5ff | 114 | protected IExtendedFilterProvider fSdExFilterProvider = null; |
df0b8ff4 BH |
115 | /** |
116 | * The extended sequence diagram find provider implementation. | |
117 | */ | |
eb63f5ff | 118 | protected IExtendedFindProvider fSdExFindProvider = null; |
df0b8ff4 BH |
119 | /** |
120 | * The extended sequence diagram action bar provider implementation. | |
121 | */ | |
eb63f5ff | 122 | protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider = null; |
df0b8ff4 BH |
123 | /** |
124 | * The sequence diagram property provider implementation. | |
125 | */ | |
eb63f5ff | 126 | protected ISDPropertiesProvider fSdPropertiesProvider = null; |
df0b8ff4 | 127 | /** |
a55887ca | 128 | * Button for executing the next page action. |
df0b8ff4 | 129 | */ |
eb63f5ff | 130 | protected NextPage fNextPageButton = null; |
df0b8ff4 | 131 | /** |
a55887ca | 132 | * Button for executing the previous page action. |
df0b8ff4 | 133 | */ |
eb63f5ff | 134 | protected PrevPage fPrevPageButton = null; |
df0b8ff4 | 135 | /** |
a55887ca | 136 | * Button for executing the first page page action. |
df0b8ff4 | 137 | */ |
eb63f5ff | 138 | protected FirstPage fFirstPageButton = null; |
df0b8ff4 | 139 | /** |
a55887ca | 140 | * Button for executing the last page action. |
df0b8ff4 | 141 | */ |
eb63f5ff | 142 | protected LastPage fLastPageButton = null; |
df0b8ff4 BH |
143 | /** |
144 | * The menu manager reference. | |
145 | */ | |
eb63f5ff | 146 | protected MenuManager fMenuMgr = null; |
df0b8ff4 | 147 | /** |
a55887ca | 148 | * Flag to indicate whether view needs initialization or not. |
df0b8ff4 | 149 | */ |
eb63f5ff | 150 | protected boolean fNeedInit = true; |
df0b8ff4 BH |
151 | /** |
152 | * WaitCursor is the cursor to be displayed when long tasks are running | |
153 | */ | |
eb63f5ff | 154 | protected Cursor fWaitCursor; |
df0b8ff4 BH |
155 | |
156 | // ------------------------------------------------------------------------ | |
157 | // Methods | |
158 | // ------------------------------------------------------------------------ | |
73005152 | 159 | |
73005152 BH |
160 | @Override |
161 | public void createPartControl(Composite c) { | |
162 | Composite parent = new Composite(c, SWT.NONE); | |
163 | GridLayout parentLayout = new GridLayout(); | |
164 | parentLayout.numColumns = 2; | |
165 | parentLayout.marginWidth = 0; | |
166 | parentLayout.marginHeight = 0; | |
167 | parent.setLayout(parentLayout); | |
168 | ||
169 | GridData timeLayoutdata = new GridData(GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL); | |
170 | timeLayoutdata.widthHint = 10; | |
171 | GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL); | |
eb63f5ff BH |
172 | fTimeCompressionBar = new TimeCompressionBar(parent, SWT.NONE); |
173 | fTimeCompressionBar.setLayoutData(timeLayoutdata); | |
174 | fSdWidget = new SDWidget(parent, SWT.NONE);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); | |
175 | fSdWidget.setLayoutData(seqDiagLayoutData); | |
176 | fSdWidget.setSite(this); | |
177 | fSdWidget.setTimeBar(fTimeCompressionBar); | |
73005152 BH |
178 | |
179 | // Add this view to the key bindings manager | |
180 | KeyBindingsManager.getInstance().add(this.getSite().getId()); | |
a55887ca | 181 | |
73005152 BH |
182 | createCoolbarContent(); |
183 | ||
184 | hookContextMenu(); | |
185 | ||
eb63f5ff | 186 | fTimeCompressionBar.setVisible(false); |
73005152 BH |
187 | parent.layout(true); |
188 | ||
189 | Print print = new Print(this); | |
190 | getViewSite().getActionBars().setGlobalActionHandler(ActionFactory.PRINT.getId(), print); | |
191 | ||
eb63f5ff | 192 | fNeedInit = restoreLoader(); |
73005152 BH |
193 | } |
194 | ||
195 | /** | |
df0b8ff4 | 196 | * Load a blank page that is supposed to explain that a kind of interaction must be chosen. |
73005152 BH |
197 | */ |
198 | protected void loadBlank() { | |
a55887ca | 199 | IUml2SDLoader loader = new BlankUml2SdLoader(); |
df0b8ff4 BH |
200 | loader.setViewer(this); |
201 | setContentDescription(loader.getTitleString()); | |
73005152 BH |
202 | } |
203 | ||
73005152 BH |
204 | @Override |
205 | public void setFocus() { | |
eb63f5ff | 206 | if (fSdWidget != null) { |
73005152 BH |
207 | // update actions for key bindings |
208 | KeyBindingsManager.getInstance().setSdView(this); | |
eb63f5ff | 209 | fSdWidget.setFocus(); |
73005152 | 210 | } |
eb63f5ff BH |
211 | if (isViewReady() && fNeedInit) { |
212 | fNeedInit = restoreLoader(); | |
73005152 BH |
213 | } |
214 | } | |
215 | ||
73005152 BH |
216 | @Override |
217 | public void dispose() { | |
218 | KeyBindingsManager.getInstance().remove(this.getSite().getId()); | |
219 | super.dispose(); | |
220 | } | |
221 | ||
222 | /** | |
df0b8ff4 | 223 | * Returns the SD widget. |
a55887ca | 224 | * |
73005152 BH |
225 | * @return The SD widget. |
226 | */ | |
227 | public SDWidget getSDWidget() { | |
eb63f5ff | 228 | return fSdWidget; |
73005152 | 229 | } |
df0b8ff4 | 230 | |
73005152 BH |
231 | /** |
232 | * Set the find provider for the opened sequence diagram viewer<br> | |
233 | * If the provider is not set, the find menu item will not be available in the viewer<br> | |
234 | * A find provider is called back when the user perform a find action<br> | |
a55887ca | 235 | * The find provider is responsible to move the sequence diagram to the GraphNode which match the |
73005152 | 236 | * find criteria as well as to highlight the GraphNode |
a55887ca | 237 | * |
73005152 BH |
238 | * @param provider the search provider |
239 | */ | |
240 | public void setSDFindProvider(ISDFindProvider provider) { | |
eb63f5ff BH |
241 | fSdFindProvider = provider; |
242 | fSdExFindProvider = null; | |
73005152 BH |
243 | createCoolbarContent(); |
244 | if (provider != null) { | |
245 | KeyBindingsManager.getInstance().setFindEnabled(true); | |
246 | } | |
247 | else { | |
248 | KeyBindingsManager.getInstance().setFindEnabled(false); | |
249 | } | |
250 | } | |
a55887ca | 251 | |
73005152 BH |
252 | /** |
253 | * Set the find provider for the opened sequence diagram viewer<br> | |
a55887ca AM |
254 | * If the provider is not set, the find menu item will not be available in |
255 | * the viewer<br> | |
73005152 | 256 | * A find provider is called back when the user perform a find action<br> |
a55887ca AM |
257 | * If the extended find provider is set, it replaces the regular find |
258 | * provider (sdFindProvider).<br> | |
259 | * | |
73005152 | 260 | * @param provider |
a55887ca | 261 | * The provider to set |
73005152 BH |
262 | */ |
263 | public void setExtendedFindProvider(IExtendedFindProvider provider) { | |
eb63f5ff BH |
264 | fSdExFindProvider = provider; |
265 | fSdFindProvider = null; | |
73005152 BH |
266 | createCoolbarContent(); |
267 | if (provider != null) { | |
268 | KeyBindingsManager.getInstance().setFindEnabled(true); | |
269 | } | |
270 | else { | |
271 | KeyBindingsManager.getInstance().setFindEnabled(false); | |
272 | } | |
273 | } | |
274 | ||
275 | /** | |
276 | * Returns the extended find provider | |
a55887ca | 277 | * |
73005152 BH |
278 | * @return extended find provider. |
279 | */ | |
280 | public IExtendedFindProvider getExtendedFindProvider() { | |
eb63f5ff | 281 | return fSdExFindProvider; |
73005152 BH |
282 | } |
283 | ||
284 | /** | |
285 | * Resets all providers. | |
286 | */ | |
287 | public void resetProviders() { | |
288 | KeyBindingsManager.getInstance().setFindEnabled(false); | |
eb63f5ff BH |
289 | fSdFindProvider = null; |
290 | fSdExFindProvider = null; | |
291 | fSdFilterProvider = null; | |
292 | fSdExFilterProvider = null; | |
293 | fSdPagingProvider = null; | |
294 | fSdExtendedActionBarProvider = null; | |
295 | fSdPropertiesProvider = null; | |
296 | if ((fSdWidget != null) && (!fSdWidget.isDisposed())) { | |
297 | fSdWidget.setCollapseProvider(null); | |
73005152 BH |
298 | } |
299 | } | |
300 | ||
301 | /** | |
302 | * Set the filter provider for the opened sequence diagram viewer<br> | |
303 | * If the provider is not set, the filter menu item will not be available in the viewer<br> | |
304 | * A filter provider is called back when the user perform a filter action<br> | |
a55887ca | 305 | * |
73005152 BH |
306 | * @param provider the filter provider |
307 | */ | |
308 | public void setSDFilterProvider(ISDFilterProvider provider) { | |
eb63f5ff | 309 | fSdFilterProvider = provider; |
73005152 BH |
310 | // Both systems can be used now, commenting out next statement |
311 | // sdExFilterProvider = null; | |
312 | createCoolbarContent(); | |
313 | } | |
a55887ca | 314 | |
73005152 | 315 | /** |
a55887ca AM |
316 | * Sets the extended filter provider for the opened sequence diagram viewer. |
317 | * | |
73005152 | 318 | * @param provider |
a55887ca | 319 | * The provider to set |
73005152 BH |
320 | */ |
321 | public void setExtendedFilterProvider(IExtendedFilterProvider provider) { | |
eb63f5ff | 322 | fSdExFilterProvider = provider; |
73005152 BH |
323 | // Both systems can be used now, commenting out next statement |
324 | // sdFilterProvider = null; | |
325 | createCoolbarContent(); | |
326 | } | |
327 | ||
328 | /** | |
329 | * Returns the extended find provider. | |
a55887ca | 330 | * |
73005152 BH |
331 | * @return The extended find provider. |
332 | */ | |
333 | public IExtendedFilterProvider getExtendedFilterProvider() { | |
eb63f5ff | 334 | return fSdExFilterProvider; |
73005152 BH |
335 | } |
336 | ||
337 | /** | |
a55887ca | 338 | * Register the given provider to support Drag and Drop collapsing. This provider is |
73005152 | 339 | * responsible of updating the Frame. |
a55887ca | 340 | * |
73005152 BH |
341 | * @param provider - the provider to register |
342 | */ | |
343 | public void setCollapsingProvider(ISDCollapseProvider provider) { | |
eb63f5ff BH |
344 | if ((fSdWidget != null) && (!fSdWidget.isDisposed())) { |
345 | fSdWidget.setCollapseProvider(provider); | |
73005152 BH |
346 | } |
347 | } | |
348 | ||
349 | /** | |
350 | * Set the page provider for the opened sequence diagram viewer<br> | |
351 | * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be | |
352 | * provided in order to handle page change requested by the user<br> | |
353 | * Set a page provider will create the next and previous page buttons in the viewer coolBar | |
a55887ca | 354 | * |
73005152 BH |
355 | * @param provider the paging provider |
356 | */ | |
357 | public void setSDPagingProvider(ISDPagingProvider provider) { | |
eb63f5ff | 358 | fSdPagingProvider = provider; |
73005152 BH |
359 | createCoolbarContent(); |
360 | } | |
361 | ||
362 | /** | |
363 | * Returns the current page provider for the view | |
a55887ca | 364 | * |
73005152 BH |
365 | * @return the paging provider |
366 | */ | |
367 | public ISDPagingProvider getSDPagingProvider() { | |
eb63f5ff | 368 | return fSdPagingProvider; |
73005152 BH |
369 | } |
370 | ||
371 | /** | |
372 | * Returns the current find provider for the view | |
a55887ca | 373 | * |
73005152 BH |
374 | * @return the find provider |
375 | */ | |
376 | public ISDFindProvider getSDFindProvider() { | |
eb63f5ff | 377 | return fSdFindProvider; |
73005152 BH |
378 | } |
379 | ||
380 | /** | |
381 | * Returns the current filter provider for the view | |
a55887ca | 382 | * |
73005152 BH |
383 | * @return the filter provider |
384 | */ | |
385 | public ISDFilterProvider getSDFilterProvider() { | |
eb63f5ff | 386 | return fSdFilterProvider; |
73005152 BH |
387 | } |
388 | ||
389 | /** | |
390 | * Set the extended action bar provider for the opened sequence diagram viewer<br> | |
391 | * This allow to add programmatically actions in the coolbar and/or in the drop-down menu | |
a55887ca | 392 | * |
73005152 BH |
393 | * @param provider the search provider |
394 | */ | |
395 | public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider) { | |
eb63f5ff | 396 | fSdExtendedActionBarProvider = provider; |
73005152 BH |
397 | createCoolbarContent(); |
398 | } | |
399 | ||
400 | /** | |
401 | * Returns the current extended action bar provider for the view | |
a55887ca | 402 | * |
73005152 BH |
403 | * @return the extended action bar provider |
404 | */ | |
405 | public ISDExtendedActionBarProvider getSDExtendedActionBarProvider() { | |
eb63f5ff | 406 | return fSdExtendedActionBarProvider; |
73005152 BH |
407 | } |
408 | ||
409 | /** | |
df0b8ff4 | 410 | * Set the properties view provider for the opened sequence diagram viewer |
a55887ca | 411 | * |
73005152 BH |
412 | * @param provider the properties provider |
413 | */ | |
414 | public void setSDPropertiesProvider(ISDPropertiesProvider provider) { | |
eb63f5ff | 415 | fSdPropertiesProvider = provider; |
73005152 BH |
416 | } |
417 | ||
418 | /** | |
df0b8ff4 | 419 | * Returns the current extended action bar provider for the view. |
a55887ca | 420 | * |
73005152 BH |
421 | * @return the extended action bar provider |
422 | */ | |
423 | public ISDPropertiesProvider getSDPropertiesProvider() { | |
eb63f5ff | 424 | return fSdPropertiesProvider; |
73005152 BH |
425 | } |
426 | ||
427 | /** | |
428 | * Creates the basic sequence diagram menu | |
429 | */ | |
430 | protected void hookContextMenu() { | |
eb63f5ff BH |
431 | fMenuMgr = new MenuManager("#PopupMenu"); //$NON-NLS-1$ |
432 | fMenuMgr.setRemoveAllWhenShown(true); | |
433 | fMenuMgr.addMenuListener(new IMenuListener() { | |
73005152 BH |
434 | @Override |
435 | public void menuAboutToShow(IMenuManager manager) { | |
436 | fillContextMenu(manager); | |
437 | } | |
438 | }); | |
eb63f5ff BH |
439 | Menu menu = fMenuMgr.createContextMenu(fSdWidget.getViewControl()); |
440 | fSdWidget.getViewControl().setMenu(menu); | |
441 | getSite().registerContextMenu(fMenuMgr, fSdWidget.getSelectionProvider()); | |
73005152 BH |
442 | } |
443 | ||
444 | /** | |
445 | * Returns the context menu manager | |
a55887ca | 446 | * |
73005152 BH |
447 | * @return the menu manager |
448 | */ | |
449 | public MenuManager getMenuManager() { | |
eb63f5ff | 450 | return fMenuMgr; |
73005152 BH |
451 | } |
452 | ||
453 | /** | |
454 | * Fills the basic sequence diagram menu and define the dynamic menu item insertion point | |
a55887ca | 455 | * |
73005152 BH |
456 | * @param manager the menu manager |
457 | */ | |
458 | protected void fillContextMenu(IMenuManager manager) { | |
459 | manager.add(new Separator("Additions")); //$NON-NLS-1$ | |
eb63f5ff BH |
460 | if (getSDWidget() != null && getSDWidget().fCurrentGraphNode != null) { |
461 | ISelectionProvider selProvider = fSdWidget.getSelectionProvider(); | |
73005152 BH |
462 | ISelection sel = selProvider.getSelection(); |
463 | int nbMessage = 0; | |
464 | Iterator<?> it = ((StructuredSelection) sel).iterator(); | |
465 | while (it.hasNext()) { | |
466 | Object node = it.next(); | |
467 | if (node instanceof BaseMessage) { | |
468 | nbMessage++; | |
469 | } | |
470 | } | |
471 | if (nbMessage != 1) { | |
472 | return; | |
473 | } | |
eb63f5ff BH |
474 | GraphNode node = getSDWidget().fCurrentGraphNode; |
475 | if ((node instanceof SyncMessageReturn) && (((SyncMessageReturn) node).getMessage() != null)) { | |
476 | Action goToMessage = new MoveToMessage(this); | |
477 | goToMessage.setText(SDMessages._39); | |
478 | manager.add(goToMessage); | |
73005152 | 479 | } |
eb63f5ff BH |
480 | if ((node instanceof SyncMessage) && (((SyncMessage) node).getMessageReturn() != null)) { |
481 | Action goToMessage = new MoveToMessage(this); | |
482 | goToMessage.setText(SDMessages._40); | |
483 | manager.add(goToMessage); | |
73005152 BH |
484 | } |
485 | } | |
486 | manager.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$ | |
487 | } | |
488 | ||
489 | /** | |
490 | * Enables/Disables an action with given name. | |
a55887ca | 491 | * |
73005152 BH |
492 | * @param actionName The action name |
493 | * @param state true or false | |
494 | */ | |
495 | public void setEnableAction(String actionName, boolean state) { | |
496 | IActionBars bar = getViewSite().getActionBars(); | |
497 | if (bar != null) { | |
498 | IContributionItem item = bar.getMenuManager().find(actionName); | |
499 | if ((item != null) && (item instanceof ActionContributionItem)) { | |
500 | IAction action = ((ActionContributionItem) item).getAction(); | |
501 | if (action != null) { | |
502 | action.setEnabled(state); | |
503 | } | |
504 | item.setVisible(state); | |
505 | bar.updateActionBars(); | |
506 | } | |
507 | } | |
508 | } | |
509 | ||
510 | /** | |
511 | * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br> | |
512 | * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br> | |
513 | * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br> | |
a55887ca | 514 | * |
73005152 BH |
515 | * @see ISDGraphNodeSupporter Action support definition |
516 | * @see SDView#setSDFilterProvider(ISDFilterProvider) | |
517 | * @see SDView#setSDFindProvider(ISDFindProvider) | |
518 | * @see SDView#setSDPagingProvider(ISDPagingProvider) | |
519 | */ | |
520 | protected void createCoolbarContent() { | |
521 | IActionBars bar = getViewSite().getActionBars(); | |
522 | ||
523 | bar.getMenuManager().removeAll(); | |
524 | bar.getToolBarManager().removeAll(); | |
525 | ||
526 | createMenuGroup(); | |
527 | ||
528 | Zoom resetZoom = new Zoom(this, ZoomType.ZOOM_RESET); | |
529 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom);//$NON-NLS-1$ | |
530 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom); //$NON-NLS-1$ | |
531 | ||
532 | Zoom noZoom = new Zoom(this, ZoomType.ZOOM_NONE); | |
533 | noZoom.setChecked(true); | |
534 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom);//$NON-NLS-1$ | |
535 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom); //$NON-NLS-1$ | |
536 | ||
537 | Zoom zoomIn = new Zoom(this, ZoomType.ZOOM_IN); | |
538 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn);//$NON-NLS-1$ | |
539 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn); //$NON-NLS-1$ | |
540 | ||
541 | Zoom zoomOut = new Zoom(this, ZoomType.ZOOM_OUT); | |
542 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut);//$NON-NLS-1$ | |
543 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut); //$NON-NLS-1$ | |
544 | ||
545 | MenuManager navigation = new MenuManager(SDMessages._77); | |
546 | ||
547 | ShowNodeStart showNodeStart = new ShowNodeStart(this); | |
548 | showNodeStart.setText(SDMessages.uml_25); | |
549 | ||
550 | showNodeStart.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ | |
551 | showNodeStart.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$ | |
552 | navigation.add(showNodeStart); | |
553 | ||
554 | ShowNodeEnd showNodeEnd = new ShowNodeEnd(this); | |
555 | showNodeEnd.setText(SDMessages.uml_23); | |
556 | ||
557 | showNodeEnd.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ | |
558 | showNodeEnd.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$ | |
559 | navigation.add(showNodeEnd); | |
560 | ||
561 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation); //$NON-NLS-1$ | |
562 | ||
563 | ConfigureMinMax minMax = new ConfigureMinMax(this); | |
564 | minMax.setText(SDMessages.uml_45); | |
565 | minMax.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$ | |
566 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax); //$NON-NLS-1$ | |
567 | ||
eb63f5ff | 568 | if ((fSdWidget.getFrame() != null) && (fSdWidget.getFrame().hasTimeInfo())) { |
73005152 | 569 | minMax.setEnabled(true); |
df0b8ff4 | 570 | } else { |
73005152 | 571 | minMax.setEnabled(false); |
df0b8ff4 | 572 | } |
73005152 BH |
573 | |
574 | // Do we need to display a paging item | |
eb63f5ff BH |
575 | if (fSdPagingProvider != null) { |
576 | fNextPageButton = new NextPage(this); | |
577 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$ | |
578 | fNextPageButton.setEnabled(fSdPagingProvider.hasNextPage()); | |
579 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$ | |
580 | ||
581 | fPrevPageButton = new PrevPage(this); | |
582 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$ | |
583 | fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage()); | |
584 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$ | |
a55887ca | 585 | |
eb63f5ff BH |
586 | fFirstPageButton = new FirstPage(this); |
587 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$ | |
588 | fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage()); | |
589 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$ | |
590 | ||
591 | fLastPageButton = new LastPage(this); | |
592 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$ | |
593 | fLastPageButton.setEnabled(fSdPagingProvider.hasNextPage()); | |
594 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$ | |
73005152 BH |
595 | } |
596 | ||
eb63f5ff BH |
597 | if (fSdExFilterProvider != null) { |
598 | Action action = fSdExFilterProvider.getFilterAction(); | |
73005152 BH |
599 | if (action != null) { |
600 | if (action.getId() == null) | |
a55887ca | 601 | { |
73005152 | 602 | action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$ |
a55887ca AM |
603 | } |
604 | if (action.getImageDescriptor() == null) { | |
8fd82db5 | 605 | action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS)); |
a55887ca AM |
606 | } |
607 | if (action.getText() == null || action.getText().length() == 0) { | |
73005152 | 608 | action.setText(SDMessages._42); |
a55887ca | 609 | } |
73005152 BH |
610 | bar.getMenuManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$ |
611 | bar.getToolBarManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$ | |
612 | } | |
613 | } | |
614 | // Both systems can be used now: commenting out else keyword | |
eb63f5ff | 615 | /* else */if (fSdFilterProvider != null) { |
a55887ca | 616 | bar.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider)); //$NON-NLS-1$ |
73005152 | 617 | // No longer in the coolbar: commenting out next statement |
a55887ca | 618 | //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$ |
73005152 | 619 | } |
eb63f5ff | 620 | if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) { |
73005152 BH |
621 | IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID); |
622 | if (sdPaging != null) { | |
623 | bar.getMenuManager().remove(sdPaging); | |
624 | sdPaging = null; | |
625 | } | |
eb63f5ff | 626 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider)); //$NON-NLS-1$ |
73005152 BH |
627 | updatePagesMenuItem(bar); |
628 | } | |
629 | ||
eb63f5ff BH |
630 | if (fSdExFindProvider != null) { |
631 | Action action = fSdExFindProvider.getFindAction(); | |
73005152 | 632 | if (action != null) { |
df0b8ff4 | 633 | if (action.getId() == null) { |
73005152 | 634 | action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$ |
df0b8ff4 BH |
635 | } |
636 | if (action.getImageDescriptor() == null) { | |
8fd82db5 | 637 | action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ)); |
df0b8ff4 BH |
638 | } |
639 | if (action.getText() == null) { | |
73005152 | 640 | action.setText(SDMessages._41); |
df0b8ff4 | 641 | } |
73005152 BH |
642 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$ |
643 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$ | |
644 | } | |
eb63f5ff | 645 | } else if (fSdFindProvider != null) { |
73005152 BH |
646 | bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$ |
647 | bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$ | |
648 | } | |
649 | ||
eb63f5ff BH |
650 | if (fSdExtendedActionBarProvider != null) { |
651 | fSdExtendedActionBarProvider.supplementCoolbarContent(bar); | |
73005152 BH |
652 | } |
653 | ||
654 | bar.updateActionBars(); | |
655 | } | |
656 | ||
657 | /** | |
658 | * Updates the view coolbar buttons state according to the value return by: - | |
659 | * ISDExtendedActionBarProvider.hasNextPage()<br> | |
660 | * - ISDExtendedActionBarProvider.hasPrevPage()<br> | |
a55887ca | 661 | * |
73005152 BH |
662 | */ |
663 | public void updateCoolBar() { | |
eb63f5ff | 664 | if (fSdPagingProvider != null) { |
73005152 | 665 | IActionBars bar = getViewSite().getActionBars(); |
df0b8ff4 | 666 | if (bar == null) { |
73005152 | 667 | return; |
df0b8ff4 | 668 | } |
73005152 | 669 | IToolBarManager barManager = bar.getToolBarManager(); |
df0b8ff4 | 670 | if (barManager == null) { |
73005152 | 671 | return; |
df0b8ff4 | 672 | } |
73005152 | 673 | IContributionItem nextPage = barManager.find(NextPage.ID); |
eb63f5ff | 674 | if (nextPage instanceof ActionContributionItem) { |
73005152 | 675 | IAction nextPageAction = ((ActionContributionItem) nextPage).getAction(); |
eb63f5ff BH |
676 | if (nextPageAction instanceof NextPage) { |
677 | ((NextPage) nextPageAction).setEnabled(fSdPagingProvider.hasNextPage()); | |
73005152 BH |
678 | } |
679 | } | |
680 | ||
681 | IContributionItem prevPage = barManager.find(PrevPage.ID); | |
eb63f5ff | 682 | if (prevPage instanceof ActionContributionItem) { |
73005152 | 683 | IAction prevPageAction = ((ActionContributionItem) prevPage).getAction(); |
eb63f5ff BH |
684 | if (prevPageAction instanceof PrevPage) { |
685 | ((PrevPage) prevPageAction).setEnabled(fSdPagingProvider.hasPrevPage()); | |
73005152 BH |
686 | } |
687 | } | |
688 | ||
689 | IContributionItem firstPage = barManager.find(FirstPage.ID); | |
eb63f5ff | 690 | if (firstPage instanceof ActionContributionItem) { |
73005152 | 691 | IAction firstPageAction = ((ActionContributionItem) firstPage).getAction(); |
eb63f5ff BH |
692 | if (firstPageAction instanceof FirstPage) { |
693 | ((FirstPage) firstPageAction).setEnabled(fSdPagingProvider.hasPrevPage()); | |
73005152 BH |
694 | } |
695 | } | |
696 | ||
697 | IContributionItem lastPage = barManager.find(LastPage.ID); | |
eb63f5ff | 698 | if (lastPage instanceof ActionContributionItem) { |
73005152 | 699 | IAction lastPageAction = ((ActionContributionItem) lastPage).getAction(); |
eb63f5ff BH |
700 | if (lastPageAction instanceof LastPage) { |
701 | ((LastPage) lastPageAction).setEnabled(fSdPagingProvider.hasNextPage()); | |
73005152 BH |
702 | } |
703 | } | |
a55887ca | 704 | |
73005152 BH |
705 | updatePagesMenuItem(bar); |
706 | } | |
707 | } | |
708 | ||
709 | /** | |
710 | * Enables or disables the Pages... menu item, depending on the number of pages | |
a55887ca | 711 | * |
73005152 BH |
712 | * @param bar the bar containing the action |
713 | */ | |
714 | protected void updatePagesMenuItem(IActionBars bar) { | |
eb63f5ff | 715 | if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) { |
73005152 BH |
716 | IMenuManager menuManager = bar.getMenuManager(); |
717 | ActionContributionItem contributionItem = (ActionContributionItem) menuManager.find(OpenSDPagesDialog.ID); | |
718 | IAction openSDPagesDialog = null; | |
719 | if (contributionItem != null) { | |
720 | openSDPagesDialog = contributionItem.getAction(); | |
721 | } | |
722 | ||
eb63f5ff BH |
723 | if (openSDPagesDialog instanceof OpenSDPagesDialog) { |
724 | openSDPagesDialog.setEnabled(((ISDAdvancedPagingProvider) fSdPagingProvider).pagesCount() > 1); | |
73005152 BH |
725 | } |
726 | } | |
727 | } | |
728 | ||
729 | /** | |
730 | * The frame to render (the sequence diagram) | |
a55887ca | 731 | * |
73005152 BH |
732 | * @param frame the frame to display |
733 | */ | |
734 | public void setFrame(Frame frame) { | |
735 | setFrame(frame, true); | |
736 | } | |
737 | ||
738 | /** | |
739 | * The frame to render (the sequence diagram) | |
a55887ca | 740 | * |
73005152 | 741 | * @param frame the frame to display |
df0b8ff4 | 742 | * @param resetPosition boolean Flag whether to reset the position or not. |
73005152 BH |
743 | */ |
744 | protected void setFrame(Frame frame, boolean resetPosition) { | |
8a95ce5a | 745 | if (getSDWidget() == null) { |
73005152 | 746 | return; |
a55887ca | 747 | } |
73005152 BH |
748 | |
749 | if (frame == null) { | |
750 | loadBlank(); | |
751 | return; | |
752 | } | |
753 | ||
df0b8ff4 | 754 | IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this); |
4b4a1525 BH |
755 | if (loader == null) { |
756 | return; | |
757 | } | |
73005152 | 758 | |
4b4a1525 | 759 | if (loader.getTitleString() != null) { |
df0b8ff4 | 760 | setContentDescription(loader.getTitleString()); |
73005152 BH |
761 | } |
762 | ||
8a95ce5a | 763 | getSDWidget().setFrame(frame, resetPosition); |
73005152 | 764 | |
eb63f5ff BH |
765 | if (fTimeCompressionBar != null) { |
766 | fTimeCompressionBar.setFrame(frame); | |
df0b8ff4 | 767 | } |
73005152 | 768 | updateCoolBar(); |
8a95ce5a BH |
769 | if (fTimeCompressionBar != null) { |
770 | if (!frame.hasTimeInfo()) { | |
771 | Composite parent = fTimeCompressionBar.getParent(); | |
772 | fTimeCompressionBar.setVisible(false); | |
773 | parent.layout(true); | |
774 | } else { | |
775 | Composite parent = fTimeCompressionBar.getParent(); | |
776 | fTimeCompressionBar.setVisible(true); | |
777 | parent.layout(true); | |
778 | } | |
73005152 BH |
779 | } |
780 | IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$ | |
781 | MenuManager shortKeys = (MenuManager) shortKeysMenu; | |
782 | if (shortKeys != null) { | |
783 | IContributionItem[] items = shortKeys.getItems(); | |
784 | for (int i = 0; i < items.length; i++) { | |
785 | if (items[i] instanceof ActionContributionItem) { | |
786 | IAction action = ((ActionContributionItem) items[i]).getAction(); | |
df0b8ff4 | 787 | if (action != null) { |
73005152 | 788 | action.setEnabled(true); |
df0b8ff4 | 789 | } |
73005152 BH |
790 | } |
791 | } | |
792 | } | |
793 | createCoolbarContent(); | |
794 | } | |
795 | ||
796 | /** | |
797 | * Activate or deactivate the short key command given in parameter (see plugin.xml) | |
a55887ca | 798 | * |
73005152 BH |
799 | * @param id the command id defined in the plugin.xml |
800 | * @param value the state value | |
801 | */ | |
802 | public void setEnableCommand(String id, boolean value) { | |
803 | IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$ | |
804 | MenuManager shortKeys = (MenuManager) shortKeysMenu; | |
df0b8ff4 | 805 | if (shortKeys == null) { |
73005152 | 806 | return; |
df0b8ff4 | 807 | } |
73005152 BH |
808 | IContributionItem item = shortKeys.find(id); |
809 | if ((item != null) && (item instanceof ActionContributionItem)) { | |
810 | IAction action = ((ActionContributionItem) item).getAction(); | |
df0b8ff4 | 811 | if (action != null) { |
73005152 | 812 | action.setEnabled(value); |
df0b8ff4 | 813 | } |
73005152 BH |
814 | } |
815 | } | |
816 | ||
817 | /** | |
818 | * Set the frame from an other thread than the one executing the main loop | |
a55887ca | 819 | * |
df0b8ff4 | 820 | * @param frame The frame to set (and display) |
73005152 BH |
821 | */ |
822 | public void setFrameSync(final Frame frame) { | |
823 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
824 | return; | |
825 | } | |
826 | getSDWidget().getDisplay().syncExec(new Runnable() { | |
827 | @Override | |
828 | public void run() { | |
8a95ce5a BH |
829 | if (getSDWidget() == null || getSDWidget().isDisposed() || |
830 | ((fTimeCompressionBar != null) && fTimeCompressionBar.isDisposed())) { | |
73005152 BH |
831 | return; |
832 | } | |
833 | setFrame(frame); | |
834 | } | |
835 | }); | |
836 | ||
837 | } | |
838 | ||
839 | /** | |
840 | * Ensure an object is visible from an other thread than the one executing the main loop | |
a55887ca | 841 | * |
df0b8ff4 | 842 | * @param sm The node to make visible in view |
73005152 BH |
843 | */ |
844 | public void ensureVisibleSync(final GraphNode sm) { | |
845 | getSDWidget().getDisplay().syncExec(new Runnable() { | |
846 | @Override | |
847 | public void run() { | |
848 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
849 | return; | |
850 | } | |
851 | getSDWidget().ensureVisible(sm); | |
852 | } | |
853 | }); | |
854 | } | |
855 | ||
856 | /** | |
857 | * Set the frame and ensure an object is visible from an other thread than the one executing the main loop | |
a55887ca | 858 | * |
df0b8ff4 BH |
859 | * @param sm The node to make visible in view |
860 | * @param frame Frame The frame to set | |
73005152 BH |
861 | */ |
862 | public void setFrameAndEnsureVisibleSync(final Frame frame, final GraphNode sm) { | |
863 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
864 | return; | |
865 | } | |
866 | getSDWidget().getDisplay().syncExec(new Runnable() { | |
867 | @Override | |
868 | public void run() { | |
869 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
870 | return; | |
871 | } | |
872 | setFrameAndEnsureVisible(frame, sm); | |
873 | } | |
874 | }); | |
875 | } | |
876 | ||
877 | /** | |
878 | * Set the frame and ensure an object is visible | |
a55887ca | 879 | * |
df0b8ff4 BH |
880 | * @param sm The node to make visible in view |
881 | * @param frame Frame The frame to set | |
73005152 BH |
882 | */ |
883 | public void setFrameAndEnsureVisible(Frame frame, GraphNode sm) { | |
884 | getSDWidget().clearSelection(); | |
885 | setFrame(frame, false); | |
886 | getSDWidget().ensureVisible(sm); | |
887 | } | |
888 | ||
889 | /** | |
890 | * Set the frame and ensure an object is visible from an other thread than the one executing the main loop | |
a55887ca | 891 | * |
df0b8ff4 BH |
892 | * @param frame The frame to set. |
893 | * @param x The x coordinate to make visible. | |
894 | * @param y The y coordinate to make visible. | |
73005152 BH |
895 | */ |
896 | public void setFrameAndEnsureVisibleSync(final Frame frame, final int x, final int y) { | |
897 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
898 | return; | |
899 | } | |
a55887ca | 900 | |
73005152 BH |
901 | getSDWidget().getDisplay().syncExec(new Runnable() { |
902 | @Override | |
903 | public void run() { | |
904 | setFrameAndEnsureVisible(frame, x, y); | |
905 | } | |
906 | }); | |
907 | } | |
908 | ||
909 | /** | |
910 | * Set the frame and ensure an object is visible | |
a55887ca | 911 | * |
df0b8ff4 BH |
912 | * @param frame The frame to set. |
913 | * @param x The x coordinate to make visible. | |
914 | * @param y The y coordinate to make visible. | |
73005152 BH |
915 | */ |
916 | public void setFrameAndEnsureVisible(Frame frame, int x, int y) { | |
917 | getSDWidget().clearSelection(); | |
918 | setFrame(frame, false); | |
919 | getSDWidget().ensureVisible(x, y); | |
920 | getSDWidget().redraw(); | |
921 | } | |
922 | ||
73005152 BH |
923 | /** |
924 | * Toggle between default and wait cursors from an other thread than the one executing the main loop | |
a55887ca AM |
925 | * |
926 | * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor. | |
73005152 | 927 | */ |
eb63f5ff | 928 | public void toggleWaitCursorAsync(final boolean wait) { |
73005152 BH |
929 | if (getSDWidget() == null || getSDWidget().isDisposed()) { |
930 | return; | |
931 | } | |
932 | ||
933 | getSDWidget().getDisplay().asyncExec(new Runnable() { | |
934 | @Override | |
935 | public void run() { | |
936 | if (getSDWidget() == null || getSDWidget().isDisposed()) { | |
937 | return; | |
938 | } | |
eb63f5ff BH |
939 | if (wait) { |
940 | if (fWaitCursor != null && !fWaitCursor.isDisposed()) { | |
941 | fWaitCursor.dispose(); | |
73005152 | 942 | } |
eb63f5ff BH |
943 | fWaitCursor = new Cursor(getSDWidget().getDisplay(), SWT.CURSOR_WAIT); |
944 | getSDWidget().setCursor(fWaitCursor); | |
73005152 BH |
945 | getSDWidget().getDisplay().update(); |
946 | } else { | |
eb63f5ff BH |
947 | if (fWaitCursor != null && !fWaitCursor.isDisposed()) { |
948 | fWaitCursor.dispose(); | |
73005152 | 949 | } |
eb63f5ff | 950 | fWaitCursor = null; |
73005152 BH |
951 | getSDWidget().setCursor(null); |
952 | getSDWidget().getDisplay().update(); | |
953 | } | |
954 | } | |
955 | }); | |
956 | } | |
957 | ||
958 | /** | |
959 | * Return the time compression bar widget | |
a55887ca AM |
960 | * |
961 | * @return the time compression bar | |
73005152 BH |
962 | */ |
963 | public TimeCompressionBar getTimeCompressionBar() { | |
eb63f5ff | 964 | return fTimeCompressionBar; |
73005152 BH |
965 | } |
966 | ||
967 | /** | |
968 | * Returns the current Frame (the sequence diagram container) | |
a55887ca AM |
969 | * |
970 | * @return the current frame | |
73005152 BH |
971 | */ |
972 | public Frame getFrame() { | |
973 | if (getSDWidget() != null) { | |
974 | return getSDWidget().getFrame(); | |
975 | } | |
abbdd66a | 976 | return null; |
73005152 BH |
977 | } |
978 | ||
df0b8ff4 BH |
979 | /** |
980 | * Restores the loader for the view based on the view ID. | |
a55887ca | 981 | * |
df0b8ff4 BH |
982 | * @return boolean <code>true</code> if initialization is needed else <code>false</code>. |
983 | */ | |
73005152 BH |
984 | protected boolean restoreLoader() { |
985 | String id = getViewSite().getId(); | |
986 | // System.err.println("restoreLoader() id="+id); | |
987 | if (id == null) { | |
988 | return true; | |
989 | } | |
df0b8ff4 | 990 | IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(id, this); |
73005152 | 991 | // System.err.println("restoreLoader() l="+l); |
df0b8ff4 BH |
992 | if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){ |
993 | loader.setViewer(this); | |
73005152 | 994 | return false; |
73005152 | 995 | } |
abbdd66a AM |
996 | loadBlank(); |
997 | return true; | |
73005152 BH |
998 | } |
999 | ||
df0b8ff4 BH |
1000 | /** |
1001 | * Checks if current view is ready to be used. | |
a55887ca | 1002 | * |
df0b8ff4 BH |
1003 | * @return boolean <code>true</code> if view is ready else <code>false</code>. |
1004 | */ | |
73005152 | 1005 | protected boolean isViewReady() { |
df0b8ff4 BH |
1006 | IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
1007 | if (page == null) { | |
73005152 | 1008 | return false; |
df0b8ff4 | 1009 | } |
73005152 | 1010 | |
df0b8ff4 | 1011 | IViewReference[] ref = page.getViewReferences(); |
73005152 BH |
1012 | for (int i = 0; i < ref.length; i++) { |
1013 | if (ref[i].getView(false) == this) { | |
1014 | return true; | |
1015 | } | |
1016 | } | |
1017 | return false; | |
1018 | } | |
1019 | ||
df0b8ff4 BH |
1020 | /** |
1021 | * Creates the menu group. | |
1022 | */ | |
73005152 BH |
1023 | protected void createMenuGroup() { |
1024 | IActionBars bar = getViewSite().getActionBars(); | |
1025 | if (bar == null) { | |
1026 | return; | |
1027 | } | |
1028 | bar.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$ | |
1029 | bar.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$ | |
1030 | bar.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$ | |
1031 | bar.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$ | |
1032 | bar.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$ | |
1033 | bar.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$ | |
1034 | bar.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$ | |
1035 | bar.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$ | |
1036 | bar.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$ | |
1037 | bar.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$ | |
1038 | bar.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$ | |
1039 | bar.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$ | |
1040 | bar.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$ | |
1041 | bar.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$ | |
1042 | bar.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$ | |
1043 | bar.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$ | |
1044 | } | |
1045 | ||
73005152 | 1046 | @Override |
eb63f5ff BH |
1047 | public Object getAdapter(Class adapter) { |
1048 | Object obj = super.getAdapter(adapter); | |
1049 | if (fSdPropertiesProvider != null && adapter.equals(IPropertySheetPage.class)) { | |
1050 | return fSdPropertiesProvider.getPropertySheetEntry(); | |
73005152 BH |
1051 | } |
1052 | ||
1053 | return obj; | |
1054 | } | |
a55887ca | 1055 | |
3145ec83 | 1056 | /** |
3145ec83 | 1057 | * Loader for a blank sequence diagram. |
a55887ca | 1058 | * |
dbd4432d | 1059 | * @version 1.0 |
3145ec83 BH |
1060 | */ |
1061 | public static class BlankUml2SdLoader implements IUml2SDLoader { | |
3145ec83 BH |
1062 | @Override |
1063 | public void setViewer(SDView viewer) { | |
1064 | // Nothing to do | |
1065 | Frame f = new Frame(); | |
1066 | f.setName(""); //$NON-NLS-1$ | |
1067 | viewer.setFrame(f); | |
1068 | } | |
1069 | ||
3145ec83 BH |
1070 | @Override |
1071 | public String getTitleString() { | |
1072 | return ""; //$NON-NLS-1$ | |
1073 | } | |
1074 | ||
3145ec83 BH |
1075 | @Override |
1076 | public void dispose() { | |
1077 | } | |
a55887ca | 1078 | } |
73005152 | 1079 | } |