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
.Activator
;
31 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
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
.ISDGraphNodeSupporter
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPagingProvider
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPropertiesProvider
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.IUml2SDLoader
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
64 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
65 import org
.eclipse
.swt
.SWT
;
66 import org
.eclipse
.swt
.graphics
.Cursor
;
67 import org
.eclipse
.swt
.layout
.GridData
;
68 import org
.eclipse
.swt
.layout
.GridLayout
;
69 import org
.eclipse
.swt
.widgets
.Composite
;
70 import org
.eclipse
.swt
.widgets
.Menu
;
71 import org
.eclipse
.ui
.IActionBars
;
72 import org
.eclipse
.ui
.IViewReference
;
73 import org
.eclipse
.ui
.IWorkbenchPage
;
74 import org
.eclipse
.ui
.PlatformUI
;
75 import org
.eclipse
.ui
.actions
.ActionFactory
;
76 import org
.eclipse
.ui
.part
.ViewPart
;
77 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
81 * This class is a generic sequence diagram view implementation.
87 public class SDView
extends ViewPart
{
89 // ------------------------------------------------------------------------
91 // ------------------------------------------------------------------------
93 * The sequence diagram widget.
95 protected SDWidget fSdWidget
= null;
97 * The time compression bar.
99 protected TimeCompressionBar fTimeCompressionBar
= null;
101 * The sequence diagram find provider implementation.
103 protected ISDFindProvider fSdFindProvider
= null;
105 * The sequence diagram paging provider implementation.
107 protected ISDPagingProvider fSdPagingProvider
= null;
109 * The sequence diagram filter provider implementation.
111 protected ISDFilterProvider fSdFilterProvider
= null;
113 * The extended sequence diagram filter provider implementation.
115 protected IExtendedFilterProvider fSdExFilterProvider
= null;
117 * The extended sequence diagram find provider implementation.
119 protected IExtendedFindProvider fSdExFindProvider
= null;
121 * The extended sequence diagram action bar provider implementation.
123 protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider
= null;
125 * The sequence diagram property provider implementation.
127 protected ISDPropertiesProvider fSdPropertiesProvider
= null;
129 * Button for executing the next page action.
131 protected NextPage fNextPageButton
= null;
133 * Button for executing the previous page action.
135 protected PrevPage fPrevPageButton
= null;
137 * Button for executing the first page page action.
139 protected FirstPage fFirstPageButton
= null;
141 * Button for executing the last page action.
143 protected LastPage fLastPageButton
= null;
145 * The menu manager reference.
147 protected MenuManager fMenuMgr
= null;
149 * Flag to indicate whether view needs initialization or not.
151 protected boolean fNeedInit
= true;
153 * WaitCursor is the cursor to be displayed when long tasks are running
155 protected Cursor fWaitCursor
;
157 // ------------------------------------------------------------------------
159 // ------------------------------------------------------------------------
163 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
166 public void createPartControl(Composite c
) {
167 Composite parent
= new Composite(c
, SWT
.NONE
);
168 GridLayout parentLayout
= new GridLayout();
169 parentLayout
.numColumns
= 2;
170 parentLayout
.marginWidth
= 0;
171 parentLayout
.marginHeight
= 0;
172 parent
.setLayout(parentLayout
);
174 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
175 timeLayoutdata
.widthHint
= 10;
176 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
177 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
178 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
179 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
180 fSdWidget
.setLayoutData(seqDiagLayoutData
);
181 fSdWidget
.setSite(this);
182 fSdWidget
.setTimeBar(fTimeCompressionBar
);
184 // Add this view to the key bindings manager
185 KeyBindingsManager
.getInstance().add(this.getSite().getId());
187 createCoolbarContent();
191 fTimeCompressionBar
.setVisible(false);
194 Print print
= new Print(this);
195 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
197 fNeedInit
= restoreLoader();
201 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
203 protected void loadBlank() {
204 IUml2SDLoader loader
= new BlankUml2SdLoader();
205 loader
.setViewer(this);
206 setContentDescription(loader
.getTitleString());
211 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
214 public void setFocus() {
215 if (fSdWidget
!= null) {
216 // update actions for key bindings
217 KeyBindingsManager
.getInstance().setSdView(this);
218 fSdWidget
.setFocus();
220 if (isViewReady() && fNeedInit
) {
221 fNeedInit
= restoreLoader();
227 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
230 public void dispose() {
231 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
236 * Returns the SD widget.
238 * @return The SD widget.
240 public SDWidget
getSDWidget() {
245 * Set the find provider for the opened sequence diagram viewer<br>
246 * If the provider is not set, the find menu item will not be available in the viewer<br>
247 * A find provider is called back when the user perform a find action<br>
248 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
249 * find criteria as well as to highlight the GraphNode
251 * @param provider the search provider
253 public void setSDFindProvider(ISDFindProvider provider
) {
254 fSdFindProvider
= provider
;
255 fSdExFindProvider
= null;
256 createCoolbarContent();
257 if (provider
!= null) {
258 KeyBindingsManager
.getInstance().setFindEnabled(true);
261 KeyBindingsManager
.getInstance().setFindEnabled(false);
266 * Set the find provider for the opened sequence diagram viewer<br>
267 * If the provider is not set, the find menu item will not be available in
269 * A find provider is called back when the user perform a find action<br>
270 * If the extended find provider is set, it replaces the regular find
271 * provider (sdFindProvider).<br>
274 * The provider to set
276 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
277 fSdExFindProvider
= provider
;
278 fSdFindProvider
= null;
279 createCoolbarContent();
280 if (provider
!= null) {
281 KeyBindingsManager
.getInstance().setFindEnabled(true);
284 KeyBindingsManager
.getInstance().setFindEnabled(false);
289 * Returns the extended find provider
291 * @return extended find provider.
293 public IExtendedFindProvider
getExtendedFindProvider() {
294 return fSdExFindProvider
;
298 * Resets all providers.
300 public void resetProviders() {
301 KeyBindingsManager
.getInstance().setFindEnabled(false);
302 fSdFindProvider
= null;
303 fSdExFindProvider
= null;
304 fSdFilterProvider
= null;
305 fSdExFilterProvider
= null;
306 fSdPagingProvider
= null;
307 fSdExtendedActionBarProvider
= null;
308 fSdPropertiesProvider
= null;
309 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
310 fSdWidget
.setCollapseProvider(null);
315 * Set the filter provider for the opened sequence diagram viewer<br>
316 * If the provider is not set, the filter menu item will not be available in the viewer<br>
317 * A filter provider is called back when the user perform a filter action<br>
319 * @param provider the filter provider
321 public void setSDFilterProvider(ISDFilterProvider provider
) {
322 fSdFilterProvider
= provider
;
323 // Both systems can be used now, commenting out next statement
324 // sdExFilterProvider = null;
325 createCoolbarContent();
329 * Sets the extended filter provider for the opened sequence diagram viewer.
332 * The provider to set
334 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
335 fSdExFilterProvider
= provider
;
336 // Both systems can be used now, commenting out next statement
337 // sdFilterProvider = null;
338 createCoolbarContent();
342 * Returns the extended find provider.
344 * @return The extended find provider.
346 public IExtendedFilterProvider
getExtendedFilterProvider() {
347 return fSdExFilterProvider
;
351 * Register the given provider to support Drag and Drop collapsing. This provider is
352 * responsible of updating the Frame.
354 * @param provider - the provider to register
356 public void setCollapsingProvider(ISDCollapseProvider provider
) {
357 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
358 fSdWidget
.setCollapseProvider(provider
);
363 * Set the page provider for the opened sequence diagram viewer<br>
364 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
365 * provided in order to handle page change requested by the user<br>
366 * Set a page provider will create the next and previous page buttons in the viewer coolBar
368 * @param provider the paging provider
370 public void setSDPagingProvider(ISDPagingProvider provider
) {
371 fSdPagingProvider
= provider
;
372 createCoolbarContent();
376 * Returns the current page provider for the view
378 * @return the paging provider
380 public ISDPagingProvider
getSDPagingProvider() {
381 return fSdPagingProvider
;
385 * Returns the current find provider for the view
387 * @return the find provider
389 public ISDFindProvider
getSDFindProvider() {
390 return fSdFindProvider
;
394 * Returns the current filter provider for the view
396 * @return the filter provider
398 public ISDFilterProvider
getSDFilterProvider() {
399 return fSdFilterProvider
;
403 * Set the extended action bar provider for the opened sequence diagram viewer<br>
404 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
406 * @param provider the search provider
408 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
409 fSdExtendedActionBarProvider
= provider
;
410 createCoolbarContent();
414 * Returns the current extended action bar provider for the view
416 * @return the extended action bar provider
418 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
419 return fSdExtendedActionBarProvider
;
423 * Set the properties view provider for the opened sequence diagram viewer
425 * @param provider the properties provider
427 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
428 fSdPropertiesProvider
= provider
;
432 * Returns the current extended action bar provider for the view.
434 * @return the extended action bar provider
436 public ISDPropertiesProvider
getSDPropertiesProvider() {
437 return fSdPropertiesProvider
;
441 * Creates the basic sequence diagram menu
443 protected void hookContextMenu() {
444 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
445 fMenuMgr
.setRemoveAllWhenShown(true);
446 fMenuMgr
.addMenuListener(new IMenuListener() {
448 public void menuAboutToShow(IMenuManager manager
) {
449 fillContextMenu(manager
);
452 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
453 fSdWidget
.getViewControl().setMenu(menu
);
454 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
458 * Returns the context menu manager
460 * @return the menu manager
462 public MenuManager
getMenuManager() {
467 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
469 * @param manager the menu manager
471 protected void fillContextMenu(IMenuManager manager
) {
472 manager
.add(new Separator("Additions")); //$NON-NLS-1$
473 if (getSDWidget() != null && getSDWidget().fCurrentGraphNode
!= null) {
474 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
475 ISelection sel
= selProvider
.getSelection();
477 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
478 while (it
.hasNext()) {
479 Object node
= it
.next();
480 if (node
instanceof BaseMessage
) {
484 if (nbMessage
!= 1) {
487 GraphNode node
= getSDWidget().fCurrentGraphNode
;
488 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
489 Action goToMessage
= new MoveToMessage(this);
490 goToMessage
.setText(SDMessages
._39
);
491 manager
.add(goToMessage
);
493 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
494 Action goToMessage
= new MoveToMessage(this);
495 goToMessage
.setText(SDMessages
._40
);
496 manager
.add(goToMessage
);
499 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
503 * Enables/Disables an action with given name.
505 * @param actionName The action name
506 * @param state true or false
508 public void setEnableAction(String actionName
, boolean state
) {
509 IActionBars bar
= getViewSite().getActionBars();
511 IContributionItem item
= bar
.getMenuManager().find(actionName
);
512 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
513 IAction action
= ((ActionContributionItem
) item
).getAction();
514 if (action
!= null) {
515 action
.setEnabled(state
);
517 item
.setVisible(state
);
518 bar
.updateActionBars();
524 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
525 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
526 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
528 * @see ISDGraphNodeSupporter Action support definition
529 * @see SDView#setSDFilterProvider(ISDFilterProvider)
530 * @see SDView#setSDFindProvider(ISDFindProvider)
531 * @see SDView#setSDPagingProvider(ISDPagingProvider)
533 protected void createCoolbarContent() {
534 IActionBars bar
= getViewSite().getActionBars();
536 bar
.getMenuManager().removeAll();
537 bar
.getToolBarManager().removeAll();
541 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
542 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
543 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
545 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
546 noZoom
.setChecked(true);
547 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
548 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
550 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
551 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
552 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
554 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
555 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
556 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
558 MenuManager navigation
= new MenuManager(SDMessages
._77
);
560 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
561 showNodeStart
.setText(SDMessages
.uml_25
);
563 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
564 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
565 navigation
.add(showNodeStart
);
567 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
568 showNodeEnd
.setText(SDMessages
.uml_23
);
570 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
571 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
572 navigation
.add(showNodeEnd
);
574 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
576 ConfigureMinMax minMax
= new ConfigureMinMax(this);
577 minMax
.setText(SDMessages
.uml_45
);
578 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
579 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
581 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
582 minMax
.setEnabled(true);
584 minMax
.setEnabled(false);
587 // Do we need to display a paging item
588 if (fSdPagingProvider
!= null) {
589 fNextPageButton
= new NextPage(this);
590 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
591 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
592 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
594 fPrevPageButton
= new PrevPage(this);
595 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
596 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
597 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
599 fFirstPageButton
= new FirstPage(this);
600 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
601 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
602 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
604 fLastPageButton
= new LastPage(this);
605 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
606 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
607 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
610 if (fSdExFilterProvider
!= null) {
611 Action action
= fSdExFilterProvider
.getFilterAction();
612 if (action
!= null) {
613 if (action
.getId() == null)
615 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
617 if (action
.getImageDescriptor() == null) {
618 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
620 if (action
.getText() == null || action
.getText().length() == 0) {
621 action
.setText(SDMessages
._42
);
623 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
624 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
627 // Both systems can be used now: commenting out else keyword
628 /* else */if (fSdFilterProvider
!= null) {
629 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider
)); //$NON-NLS-1$
630 // No longer in the coolbar: commenting out next statement
631 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
633 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
634 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
635 if (sdPaging
!= null) {
636 bar
.getMenuManager().remove(sdPaging
);
639 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
)); //$NON-NLS-1$
640 updatePagesMenuItem(bar
);
643 if (fSdExFindProvider
!= null) {
644 Action action
= fSdExFindProvider
.getFindAction();
645 if (action
!= null) {
646 if (action
.getId() == null) {
647 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
649 if (action
.getImageDescriptor() == null) {
650 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
652 if (action
.getText() == null) {
653 action
.setText(SDMessages
._41
);
655 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
656 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
658 } else if (fSdFindProvider
!= null) {
659 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
660 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
663 if (fSdExtendedActionBarProvider
!= null) {
664 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
667 bar
.updateActionBars();
671 * Updates the view coolbar buttons state according to the value return by: -
672 * ISDExtendedActionBarProvider.hasNextPage()<br>
673 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
676 public void updateCoolBar() {
677 if (fSdPagingProvider
!= null) {
678 IActionBars bar
= getViewSite().getActionBars();
682 IToolBarManager barManager
= bar
.getToolBarManager();
683 if (barManager
== null) {
686 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
687 if (nextPage
instanceof ActionContributionItem
) {
688 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
689 if (nextPageAction
instanceof NextPage
) {
690 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
694 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
695 if (prevPage
instanceof ActionContributionItem
) {
696 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
697 if (prevPageAction
instanceof PrevPage
) {
698 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
702 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
703 if (firstPage
instanceof ActionContributionItem
) {
704 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
705 if (firstPageAction
instanceof FirstPage
) {
706 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
710 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
711 if (lastPage
instanceof ActionContributionItem
) {
712 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
713 if (lastPageAction
instanceof LastPage
) {
714 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
718 updatePagesMenuItem(bar
);
723 * Enables or disables the Pages... menu item, depending on the number of pages
725 * @param bar the bar containing the action
727 protected void updatePagesMenuItem(IActionBars bar
) {
728 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
729 IMenuManager menuManager
= bar
.getMenuManager();
730 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
731 IAction openSDPagesDialog
= null;
732 if (contributionItem
!= null) {
733 openSDPagesDialog
= contributionItem
.getAction();
736 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
737 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
743 * The frame to render (the sequence diagram)
745 * @param frame the frame to display
747 public void setFrame(Frame frame
) {
748 setFrame(frame
, true);
752 * The frame to render (the sequence diagram)
754 * @param frame the frame to display
755 * @param resetPosition boolean Flag whether to reset the position or not.
757 protected void setFrame(Frame frame
, boolean resetPosition
) {
758 if (fSdWidget
== null) {
767 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
769 if ((loader
!= null) && (loader
.getTitleString() != null)) {
770 setContentDescription(loader
.getTitleString());
773 if (getSDWidget() != null) {
774 getSDWidget().setFrame(frame
, resetPosition
);
777 if (fTimeCompressionBar
!= null) {
778 fTimeCompressionBar
.setFrame(frame
);
781 if (!frame
.hasTimeInfo()) {
782 Composite parent
= fTimeCompressionBar
.getParent();
783 fTimeCompressionBar
.setVisible(false);
786 Composite parent
= fTimeCompressionBar
.getParent();
787 fTimeCompressionBar
.setVisible(true);
790 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
791 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
792 if (shortKeys
!= null) {
793 IContributionItem
[] items
= shortKeys
.getItems();
794 for (int i
= 0; i
< items
.length
; i
++) {
795 if (items
[i
] instanceof ActionContributionItem
) {
796 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
797 if (action
!= null) {
798 action
.setEnabled(true);
803 createCoolbarContent();
807 * Activate or deactivate the short key command given in parameter (see plugin.xml)
809 * @param id the command id defined in the plugin.xml
810 * @param value the state value
812 public void setEnableCommand(String id
, boolean value
) {
813 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
814 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
815 if (shortKeys
== null) {
818 IContributionItem item
= shortKeys
.find(id
);
819 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
820 IAction action
= ((ActionContributionItem
) item
).getAction();
821 if (action
!= null) {
822 action
.setEnabled(value
);
828 * Set the frame from an other thread than the one executing the main loop
830 * @param frame The frame to set (and display)
832 public void setFrameSync(final Frame frame
) {
833 if (getSDWidget() == null || getSDWidget().isDisposed()) {
836 getSDWidget().getDisplay().syncExec(new Runnable() {
839 if (getSDWidget() == null || getSDWidget().isDisposed()) {
849 * Ensure an object is visible from an other thread than the one executing the main loop
851 * @param sm The node to make visible in view
853 public void ensureVisibleSync(final GraphNode sm
) {
854 getSDWidget().getDisplay().syncExec(new Runnable() {
857 if (getSDWidget() == null || getSDWidget().isDisposed()) {
860 getSDWidget().ensureVisible(sm
);
866 * Set the frame and 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
869 * @param frame Frame The frame to set
871 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
872 if (getSDWidget() == null || getSDWidget().isDisposed()) {
875 getSDWidget().getDisplay().syncExec(new Runnable() {
878 if (getSDWidget() == null || getSDWidget().isDisposed()) {
881 setFrameAndEnsureVisible(frame
, sm
);
887 * Set the frame and ensure an object is visible
889 * @param sm The node to make visible in view
890 * @param frame Frame The frame to set
892 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
893 getSDWidget().clearSelection();
894 setFrame(frame
, false);
895 getSDWidget().ensureVisible(sm
);
899 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
901 * @param frame The frame to set.
902 * @param x The x coordinate to make visible.
903 * @param y The y coordinate to make visible.
905 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
906 if (getSDWidget() == null || getSDWidget().isDisposed()) {
910 getSDWidget().getDisplay().syncExec(new Runnable() {
913 setFrameAndEnsureVisible(frame
, x
, y
);
919 * Set the frame and ensure an object is visible
921 * @param frame The frame to set.
922 * @param x The x coordinate to make visible.
923 * @param y The y coordinate to make visible.
925 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
926 getSDWidget().clearSelection();
927 setFrame(frame
, false);
928 getSDWidget().ensureVisible(x
, y
);
929 getSDWidget().redraw();
933 * Toggle between default and wait cursors from an other thread than the one executing the main loop
935 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
937 public void toggleWaitCursorAsync(final boolean wait
) {
938 if (getSDWidget() == null || getSDWidget().isDisposed()) {
942 getSDWidget().getDisplay().asyncExec(new Runnable() {
945 if (getSDWidget() == null || getSDWidget().isDisposed()) {
949 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
950 fWaitCursor
.dispose();
952 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
953 getSDWidget().setCursor(fWaitCursor
);
954 getSDWidget().getDisplay().update();
956 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
957 fWaitCursor
.dispose();
960 getSDWidget().setCursor(null);
961 getSDWidget().getDisplay().update();
968 * Return the time compression bar widget
970 * @return the time compression bar
972 public TimeCompressionBar
getTimeCompressionBar() {
973 return fTimeCompressionBar
;
977 * Returns the current Frame (the sequence diagram container)
979 * @return the current frame
981 public Frame
getFrame() {
982 if (getSDWidget() != null) {
983 return getSDWidget().getFrame();
991 * Restores the loader for the view based on the view ID.
993 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
995 protected boolean restoreLoader() {
996 String id
= getViewSite().getId();
997 // System.err.println("restoreLoader() id="+id);
1001 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1002 // System.err.println("restoreLoader() l="+l);
1003 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
1004 loader
.setViewer(this);
1013 * Checks if current view is ready to be used.
1015 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1017 protected boolean isViewReady() {
1018 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1023 IViewReference
[] ref
= page
.getViewReferences();
1024 for (int i
= 0; i
< ref
.length
; i
++) {
1025 if (ref
[i
].getView(false) == this) {
1033 * Creates the menu group.
1035 protected void createMenuGroup() {
1036 IActionBars bar
= getViewSite().getActionBars();
1040 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1041 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1042 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1043 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1044 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1045 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1046 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1047 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1048 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1049 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1050 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1051 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1052 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1053 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1054 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1055 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1059 * Gets adapter for this view for properties.
1061 * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
1063 @SuppressWarnings("rawtypes")
1065 public Object
getAdapter(Class adapter
) {
1066 Object obj
= super.getAdapter(adapter
);
1067 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1068 return fSdPropertiesProvider
.getPropertySheetEntry();
1075 * Loader for a blank sequence diagram.
1079 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1082 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
1085 public void setViewer(SDView viewer
) {
1087 Frame f
= new Frame();
1088 f
.setName(""); //$NON-NLS-1$
1094 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
1097 public String
getTitleString() {
1098 return ""; //$NON-NLS-1$
1103 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
1106 public void dispose() {