1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
16 import java
.util
.Iterator
;
18 import org
.eclipse
.jface
.action
.Action
;
19 import org
.eclipse
.jface
.action
.ActionContributionItem
;
20 import org
.eclipse
.jface
.action
.IAction
;
21 import org
.eclipse
.jface
.action
.IContributionItem
;
22 import org
.eclipse
.jface
.action
.IMenuListener
;
23 import org
.eclipse
.jface
.action
.IMenuManager
;
24 import org
.eclipse
.jface
.action
.IToolBarManager
;
25 import org
.eclipse
.jface
.action
.MenuManager
;
26 import org
.eclipse
.jface
.action
.Separator
;
27 import org
.eclipse
.jface
.viewers
.ISelection
;
28 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
29 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
30 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
31 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.TmfUiPlugin
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessage
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessageReturn
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ConfigureMinMax
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.FirstPage
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.KeyBindingsManager
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.LastPage
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.MoveToMessage
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.NextPage
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFiltersDialog
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFindDialog
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDPagesDialog
;
46 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.PrevPage
;
47 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Print
;
48 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeEnd
;
49 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeStart
;
50 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
;
51 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
.ZoomType
;
52 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFilterProvider
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFindProvider
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDAdvancedPagingProvider
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDExtendedActionBarProvider
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFilterProvider
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFindProvider
;
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
;
76 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
80 * This class is a generic sequence diagram view implementation.
86 public class SDView
extends ViewPart
{
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
92 * The sequence diagram widget.
94 protected SDWidget fSdWidget
= null;
96 * The time compression bar.
98 protected TimeCompressionBar fTimeCompressionBar
= null;
100 * The sequence diagram find provider implementation.
102 protected ISDFindProvider fSdFindProvider
= null;
104 * The sequence diagram paging provider implementation.
106 protected ISDPagingProvider fSdPagingProvider
= null;
108 * The sequence diagram filter provider implementation.
110 protected ISDFilterProvider fSdFilterProvider
= null;
112 * The extended sequence diagram filter provider implementation.
114 protected IExtendedFilterProvider fSdExFilterProvider
= null;
116 * The extended sequence diagram find provider implementation.
118 protected IExtendedFindProvider fSdExFindProvider
= null;
120 * The extended sequence diagram action bar provider implementation.
122 protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider
= null;
124 * The sequence diagram property provider implementation.
126 protected ISDPropertiesProvider fSdPropertiesProvider
= null;
128 * Button for executing the next page action.
130 protected NextPage fNextPageButton
= null;
132 * Button for executing the previous page action.
134 protected PrevPage fPrevPageButton
= null;
136 * Button for executing the first page page action.
138 protected FirstPage fFirstPageButton
= null;
140 * Button for executing the last page action.
142 protected LastPage fLastPageButton
= null;
144 * The menu manager reference.
146 protected MenuManager fMenuMgr
= null;
148 * Flag to indicate whether view needs initialization or not.
150 protected boolean fNeedInit
= true;
152 * WaitCursor is the cursor to be displayed when long tasks are running
154 protected Cursor fWaitCursor
;
156 // ------------------------------------------------------------------------
158 // ------------------------------------------------------------------------
162 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
165 public void createPartControl(Composite c
) {
166 Composite parent
= new Composite(c
, SWT
.NONE
);
167 GridLayout parentLayout
= new GridLayout();
168 parentLayout
.numColumns
= 2;
169 parentLayout
.marginWidth
= 0;
170 parentLayout
.marginHeight
= 0;
171 parent
.setLayout(parentLayout
);
173 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
174 timeLayoutdata
.widthHint
= 10;
175 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
176 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
177 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
178 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
179 fSdWidget
.setLayoutData(seqDiagLayoutData
);
180 fSdWidget
.setSite(this);
181 fSdWidget
.setTimeBar(fTimeCompressionBar
);
183 // Add this view to the key bindings manager
184 KeyBindingsManager
.getInstance().add(this.getSite().getId());
186 createCoolbarContent();
190 fTimeCompressionBar
.setVisible(false);
193 Print print
= new Print(this);
194 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
196 fNeedInit
= restoreLoader();
200 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
202 protected void loadBlank() {
203 IUml2SDLoader loader
= new IUml2SDLoader() {
206 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
209 public void setViewer(SDView viewer
) {
211 Frame f
= new Frame();
212 f
.setName(""); //$NON-NLS-1$
218 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
221 public String
getTitleString() {
222 return ""; //$NON-NLS-1$
227 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
230 public void dispose() {
233 loader
.setViewer(this);
234 setContentDescription(loader
.getTitleString());
239 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
242 public void setFocus() {
243 if (fSdWidget
!= null) {
244 // update actions for key bindings
245 KeyBindingsManager
.getInstance().setSdView(this);
246 fSdWidget
.setFocus();
248 if (isViewReady() && fNeedInit
) {
249 fNeedInit
= restoreLoader();
255 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
258 public void dispose() {
259 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
264 * Returns the SD widget.
266 * @return The SD widget.
268 public SDWidget
getSDWidget() {
273 * Set the find provider for the opened sequence diagram viewer<br>
274 * If the provider is not set, the find menu item will not be available in the viewer<br>
275 * A find provider is called back when the user perform a find action<br>
276 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
277 * find criteria as well as to highlight the GraphNode
279 * @param provider the search provider
281 public void setSDFindProvider(ISDFindProvider provider
) {
282 fSdFindProvider
= provider
;
283 fSdExFindProvider
= null;
284 createCoolbarContent();
285 if (provider
!= null) {
286 KeyBindingsManager
.getInstance().setFindEnabled(true);
289 KeyBindingsManager
.getInstance().setFindEnabled(false);
294 * Set the find provider for the opened sequence diagram viewer<br>
295 * If the provider is not set, the find menu item will not be available in the viewer<br>
296 * A find provider is called back when the user perform a find action<br>
297 * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
300 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
301 fSdExFindProvider
= provider
;
302 fSdFindProvider
= null;
303 createCoolbarContent();
304 if (provider
!= null) {
305 KeyBindingsManager
.getInstance().setFindEnabled(true);
308 KeyBindingsManager
.getInstance().setFindEnabled(false);
313 * Returns the extended find provider
315 * @return extended find provider.
317 public IExtendedFindProvider
getExtendedFindProvider() {
318 return fSdExFindProvider
;
322 * Resets all providers.
324 public void resetProviders() {
325 KeyBindingsManager
.getInstance().setFindEnabled(false);
326 fSdFindProvider
= null;
327 fSdExFindProvider
= null;
328 fSdFilterProvider
= null;
329 fSdExFilterProvider
= null;
330 fSdPagingProvider
= null;
331 fSdExtendedActionBarProvider
= null;
332 fSdPropertiesProvider
= null;
333 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
334 fSdWidget
.setCollapseProvider(null);
339 * Set the filter provider for the opened sequence diagram viewer<br>
340 * If the provider is not set, the filter menu item will not be available in the viewer<br>
341 * A filter provider is called back when the user perform a filter action<br>
343 * @param provider the filter provider
345 public void setSDFilterProvider(ISDFilterProvider provider
) {
346 fSdFilterProvider
= provider
;
347 // Both systems can be used now, commenting out next statement
348 // sdExFilterProvider = null;
349 createCoolbarContent();
353 * Sets the extended filter provider for the opend sequence diagram viewer.
356 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
357 fSdExFilterProvider
= provider
;
358 // Both systems can be used now, commenting out next statement
359 // sdFilterProvider = null;
360 createCoolbarContent();
364 * Returns the extended find provider.
366 * @return The extended find provider.
368 public IExtendedFilterProvider
getExtendedFilterProvider() {
369 return fSdExFilterProvider
;
373 * Register the given provider to support Drag and Drop collapsing. This provider is
374 * responsible of updating the Frame.
376 * @param provider - the provider to register
378 public void setCollapsingProvider(ISDCollapseProvider provider
) {
379 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
380 fSdWidget
.setCollapseProvider(provider
);
385 * Set the page provider for the opened sequence diagram viewer<br>
386 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
387 * provided in order to handle page change requested by the user<br>
388 * Set a page provider will create the next and previous page buttons in the viewer coolBar
390 * @param provider the paging provider
392 public void setSDPagingProvider(ISDPagingProvider provider
) {
393 fSdPagingProvider
= provider
;
394 createCoolbarContent();
398 * Returns the current page provider for the view
400 * @return the paging provider
402 public ISDPagingProvider
getSDPagingProvider() {
403 return fSdPagingProvider
;
407 * Returns the current find provider for the view
409 * @return the find provider
411 public ISDFindProvider
getSDFindProvider() {
412 return fSdFindProvider
;
416 * Returns the current filter provider for the view
418 * @return the filter provider
420 public ISDFilterProvider
getSDFilterProvider() {
421 return fSdFilterProvider
;
425 * Set the extended action bar provider for the opened sequence diagram viewer<br>
426 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
428 * @param provider the search provider
430 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
431 fSdExtendedActionBarProvider
= provider
;
432 createCoolbarContent();
436 * Returns the current extended action bar provider for the view
438 * @return the extended action bar provider
440 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
441 return fSdExtendedActionBarProvider
;
445 * Set the properties view provider for the opened sequence diagram viewer
447 * @param provider the properties provider
449 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
450 fSdPropertiesProvider
= provider
;
454 * Returns the current extended action bar provider for the view.
456 * @return the extended action bar provider
458 public ISDPropertiesProvider
getSDPropertiesProvider() {
459 return fSdPropertiesProvider
;
463 * Creates the basic sequence diagram menu
465 protected void hookContextMenu() {
466 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
467 fMenuMgr
.setRemoveAllWhenShown(true);
468 fMenuMgr
.addMenuListener(new IMenuListener() {
470 public void menuAboutToShow(IMenuManager manager
) {
471 fillContextMenu(manager
);
474 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
475 fSdWidget
.getViewControl().setMenu(menu
);
476 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
480 * Returns the context menu manager
482 * @return the menu manager
484 public MenuManager
getMenuManager() {
489 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
491 * @param manager the menu manager
493 protected void fillContextMenu(IMenuManager manager
) {
494 manager
.add(new Separator("Additions")); //$NON-NLS-1$
495 if (getSDWidget() != null && getSDWidget().fCurrentGraphNode
!= null) {
496 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
497 ISelection sel
= selProvider
.getSelection();
499 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
500 while (it
.hasNext()) {
501 Object node
= it
.next();
502 if (node
instanceof BaseMessage
) {
506 if (nbMessage
!= 1) {
509 GraphNode node
= getSDWidget().fCurrentGraphNode
;
510 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
511 Action goToMessage
= new MoveToMessage(this);
512 goToMessage
.setText(SDMessages
._39
);
513 manager
.add(goToMessage
);
515 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
516 Action goToMessage
= new MoveToMessage(this);
517 goToMessage
.setText(SDMessages
._40
);
518 manager
.add(goToMessage
);
521 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
525 * Enables/Disables an action with given name.
527 * @param actionName The action name
528 * @param state true or false
530 public void setEnableAction(String actionName
, boolean state
) {
531 IActionBars bar
= getViewSite().getActionBars();
533 IContributionItem item
= bar
.getMenuManager().find(actionName
);
534 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
535 IAction action
= ((ActionContributionItem
) item
).getAction();
536 if (action
!= null) {
537 action
.setEnabled(state
);
539 item
.setVisible(state
);
540 bar
.updateActionBars();
546 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
547 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
548 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
550 * @see ISDGraphNodeSupporter Action support definition
551 * @see SDView#setSDFilterProvider(ISDFilterProvider)
552 * @see SDView#setSDFindProvider(ISDFindProvider)
553 * @see SDView#setSDPagingProvider(ISDPagingProvider)
555 protected void createCoolbarContent() {
556 IActionBars bar
= getViewSite().getActionBars();
558 bar
.getMenuManager().removeAll();
559 bar
.getToolBarManager().removeAll();
563 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
564 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
565 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
567 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
568 noZoom
.setChecked(true);
569 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
570 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
572 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
573 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
574 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
576 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
577 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
578 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
580 MenuManager navigation
= new MenuManager(SDMessages
._77
);
582 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
583 showNodeStart
.setText(SDMessages
.uml_25
);
585 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
586 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
587 navigation
.add(showNodeStart
);
589 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
590 showNodeEnd
.setText(SDMessages
.uml_23
);
592 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
593 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
594 navigation
.add(showNodeEnd
);
596 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
598 ConfigureMinMax minMax
= new ConfigureMinMax(this);
599 minMax
.setText(SDMessages
.uml_45
);
600 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
601 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
603 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
604 minMax
.setEnabled(true);
606 minMax
.setEnabled(false);
609 // Do we need to display a paging item
610 if (fSdPagingProvider
!= null) {
611 fNextPageButton
= new NextPage(this);
612 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
613 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
614 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
616 fPrevPageButton
= new PrevPage(this);
617 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
618 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
619 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
621 fFirstPageButton
= new FirstPage(this);
622 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
623 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
624 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
626 fLastPageButton
= new LastPage(this);
627 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
628 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
629 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
632 if (fSdExFilterProvider
!= null) {
633 Action action
= fSdExFilterProvider
.getFilterAction();
634 if (action
!= null) {
635 if (action
.getId() == null)
636 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
637 if (action
.getImageDescriptor() == null)
638 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
639 if (action
.getText() == null || action
.getText().length() == 0)
640 action
.setText(SDMessages
._42
);
641 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
642 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
645 // Both systems can be used now: commenting out else keyword
646 /* else */if (fSdFilterProvider
!= null) {
647 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider
)); //$NON-NLS-1$
648 // No longer in the coolbar: commenting out next statement
649 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
651 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
652 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
653 if (sdPaging
!= null) {
654 bar
.getMenuManager().remove(sdPaging
);
657 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
)); //$NON-NLS-1$
658 updatePagesMenuItem(bar
);
661 if (fSdExFindProvider
!= null) {
662 Action action
= fSdExFindProvider
.getFindAction();
663 if (action
!= null) {
664 if (action
.getId() == null) {
665 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
667 if (action
.getImageDescriptor() == null) {
668 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
670 if (action
.getText() == null) {
671 action
.setText(SDMessages
._41
);
673 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
674 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
676 } else if (fSdFindProvider
!= null) {
677 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
678 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
681 if (fSdExtendedActionBarProvider
!= null) {
682 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
685 bar
.updateActionBars();
689 * Updates the view coolbar buttons state according to the value return by: -
690 * ISDExtendedActionBarProvider.hasNextPage()<br>
691 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
694 public void updateCoolBar() {
695 if (fSdPagingProvider
!= null) {
696 IActionBars bar
= getViewSite().getActionBars();
700 IToolBarManager barManager
= bar
.getToolBarManager();
701 if (barManager
== null) {
704 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
705 if (nextPage
instanceof ActionContributionItem
) {
706 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
707 if (nextPageAction
instanceof NextPage
) {
708 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
712 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
713 if (prevPage
instanceof ActionContributionItem
) {
714 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
715 if (prevPageAction
instanceof PrevPage
) {
716 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
720 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
721 if (firstPage
instanceof ActionContributionItem
) {
722 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
723 if (firstPageAction
instanceof FirstPage
) {
724 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
728 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
729 if (lastPage
instanceof ActionContributionItem
) {
730 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
731 if (lastPageAction
instanceof LastPage
) {
732 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
736 updatePagesMenuItem(bar
);
741 * Enables or disables the Pages... menu item, depending on the number of pages
743 * @param bar the bar containing the action
745 protected void updatePagesMenuItem(IActionBars bar
) {
746 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
747 IMenuManager menuManager
= bar
.getMenuManager();
748 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
749 IAction openSDPagesDialog
= null;
750 if (contributionItem
!= null) {
751 openSDPagesDialog
= contributionItem
.getAction();
754 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
755 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
761 * The frame to render (the sequence diagram)
763 * @param frame the frame to display
765 public void setFrame(Frame frame
) {
766 setFrame(frame
, true);
770 * The frame to render (the sequence diagram)
772 * @param frame the frame to display
773 * @param resetPosition boolean Flag whether to reset the position or not.
775 protected void setFrame(Frame frame
, boolean resetPosition
) {
776 if (fSdWidget
== null)
784 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
786 if ((loader
!= null) && (loader
.getTitleString() != null)) {
787 setContentDescription(loader
.getTitleString());
790 if (getSDWidget() != null) {
791 getSDWidget().setFrame(frame
, resetPosition
);
794 if (fTimeCompressionBar
!= null) {
795 fTimeCompressionBar
.setFrame(frame
);
798 if (!frame
.hasTimeInfo()) {
799 Composite parent
= fTimeCompressionBar
.getParent();
800 fTimeCompressionBar
.setVisible(false);
803 Composite parent
= fTimeCompressionBar
.getParent();
804 fTimeCompressionBar
.setVisible(true);
807 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
808 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
809 if (shortKeys
!= null) {
810 IContributionItem
[] items
= shortKeys
.getItems();
811 for (int i
= 0; i
< items
.length
; i
++) {
812 if (items
[i
] instanceof ActionContributionItem
) {
813 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
814 if (action
!= null) {
815 action
.setEnabled(true);
820 createCoolbarContent();
824 * Activate or deactivate the short key command given in parameter (see plugin.xml)
826 * @param id the command id defined in the plugin.xml
827 * @param value the state value
829 public void setEnableCommand(String id
, boolean value
) {
830 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
831 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
832 if (shortKeys
== null) {
835 IContributionItem item
= shortKeys
.find(id
);
836 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
837 IAction action
= ((ActionContributionItem
) item
).getAction();
838 if (action
!= null) {
839 action
.setEnabled(value
);
845 * Set the frame from an other thread than the one executing the main loop
847 * @param frame The frame to set (and display)
849 public void setFrameSync(final Frame frame
) {
850 if (getSDWidget() == null || getSDWidget().isDisposed()) {
853 getSDWidget().getDisplay().syncExec(new Runnable() {
856 if (getSDWidget() == null || getSDWidget().isDisposed()) {
866 * Ensure an object is visible from an other thread than the one executing the main loop
868 * @param sm The node to make visible in view
870 public void ensureVisibleSync(final GraphNode sm
) {
871 getSDWidget().getDisplay().syncExec(new Runnable() {
874 if (getSDWidget() == null || getSDWidget().isDisposed()) {
877 getSDWidget().ensureVisible(sm
);
883 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
885 * @param sm The node to make visible in view
886 * @param frame Frame The frame to set
888 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
889 if (getSDWidget() == null || getSDWidget().isDisposed()) {
892 getSDWidget().getDisplay().syncExec(new Runnable() {
895 if (getSDWidget() == null || getSDWidget().isDisposed()) {
898 setFrameAndEnsureVisible(frame
, sm
);
904 * Set the frame and ensure an object is visible
906 * @param sm The node to make visible in view
907 * @param frame Frame The frame to set
909 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
910 getSDWidget().clearSelection();
911 setFrame(frame
, false);
912 getSDWidget().ensureVisible(sm
);
916 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
918 * @param frame The frame to set.
919 * @param x The x coordinate to make visible.
920 * @param y The y coordinate to make visible.
922 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
923 if (getSDWidget() == null || getSDWidget().isDisposed()) {
927 getSDWidget().getDisplay().syncExec(new Runnable() {
930 setFrameAndEnsureVisible(frame
, x
, y
);
936 * Set the frame and ensure an object is visible
938 * @param frame The frame to set.
939 * @param x The x coordinate to make visible.
940 * @param y The y coordinate to make visible.
942 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
943 getSDWidget().clearSelection();
944 setFrame(frame
, false);
945 getSDWidget().ensureVisible(x
, y
);
946 getSDWidget().redraw();
950 * Toggle between default and wait cursors from an other thread than the one executing the main loop
952 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
954 public void toggleWaitCursorAsync(final boolean wait
) {
955 if (getSDWidget() == null || getSDWidget().isDisposed()) {
959 getSDWidget().getDisplay().asyncExec(new Runnable() {
962 if (getSDWidget() == null || getSDWidget().isDisposed()) {
966 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
967 fWaitCursor
.dispose();
969 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
970 getSDWidget().setCursor(fWaitCursor
);
971 getSDWidget().getDisplay().update();
973 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
974 fWaitCursor
.dispose();
977 getSDWidget().setCursor(null);
978 getSDWidget().getDisplay().update();
985 * Return the time compression bar widget
987 * @return the time compression bar
989 public TimeCompressionBar
getTimeCompressionBar() {
990 return fTimeCompressionBar
;
994 * Returns the current Frame (the sequence diagram container)
996 * @return the current frame
998 public Frame
getFrame() {
999 if (getSDWidget() != null) {
1000 return getSDWidget().getFrame();
1008 * Restores the loader for the view based on the view ID.
1010 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
1012 protected boolean restoreLoader() {
1013 String id
= getViewSite().getId();
1014 // System.err.println("restoreLoader() id="+id);
1018 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1019 // System.err.println("restoreLoader() l="+l);
1020 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
1021 loader
.setViewer(this);
1030 * Checks if current view is ready to be used.
1032 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1034 protected boolean isViewReady() {
1035 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1040 IViewReference
[] ref
= page
.getViewReferences();
1041 for (int i
= 0; i
< ref
.length
; i
++) {
1042 if (ref
[i
].getView(false) == this) {
1050 * Creates the menu group.
1052 protected void createMenuGroup() {
1053 IActionBars bar
= getViewSite().getActionBars();
1057 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1058 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1059 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1060 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1061 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1062 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1063 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1064 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1065 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1066 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1067 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1068 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1069 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1070 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1071 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1072 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1076 * Gets adapter for this view for properties.
1078 * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
1080 @SuppressWarnings("rawtypes")
1082 public Object
getAdapter(Class adapter
) {
1083 Object obj
= super.getAdapter(adapter
);
1084 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1085 return fSdPropertiesProvider
.getPropertySheetEntry();