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
.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 sdWidget
= null;
97 * The time compression bar.
99 protected TimeCompressionBar timeCompressionBar
= null;
101 * The sequence diagram find provider implementation.
103 protected ISDFindProvider sdFindProvider
= null;
105 * The sequence diagram paging provider implementation.
107 protected ISDPagingProvider sdPagingProvider
= null;
109 * The sequence diagram filter provider implementation.
111 protected ISDFilterProvider sdFilterProvider
= null;
113 * The extended sequence diagram filter provider implementation.
115 protected IExtendedFilterProvider sdExFilterProvider
= null;
117 * The extended sequence diagram find provider implementation.
119 protected IExtendedFindProvider sdExFindProvider
= null;
121 * The extended sequence diagram action bar provider implementation.
123 protected ISDExtendedActionBarProvider sdExtendedActionBarProvider
= null;
125 * The sequence diagram property provider implementation.
127 protected ISDPropertiesProvider sdPropertiesProvider
= null;
129 * Button for executing the next page action.
131 protected NextPage nextPageButton
= null;
133 * Button for executing the previous page action.
135 protected PrevPage prevPageButton
= null;
137 * Button for executing the first page page action.
139 protected FirstPage firstPageButton
= null;
141 * Button for executing the last page action.
143 protected LastPage lastPageButton
= null;
145 * The menu manager reference.
147 protected MenuManager menuMgr
= null;
149 * Flag to indicate whether view needs initialization or not.
151 protected boolean needInit
= true;
153 * WaitCursor is the cursor to be displayed when long tasks are running
155 protected Cursor waitCursor
;
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 timeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
178 timeCompressionBar
.setLayoutData(timeLayoutdata
);
179 sdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
180 sdWidget
.setLayoutData(seqDiagLayoutData
);
181 sdWidget
.setSite(this);
182 sdWidget
.setTimeBar(timeCompressionBar
);
184 // Add this view to the key bindings manager
185 KeyBindingsManager
.getInstance().add(this.getSite().getId());
187 createCoolbarContent();
191 timeCompressionBar
.setVisible(false);
194 Print print
= new Print(this);
195 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
197 needInit
= 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 IUml2SDLoader() {
207 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
210 public void setViewer(SDView viewer
) {
212 Frame f
= new Frame();
213 f
.setName(""); //$NON-NLS-1$
219 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
222 public String
getTitleString() {
223 return ""; //$NON-NLS-1$
228 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
231 public void dispose() {
234 loader
.setViewer(this);
235 setContentDescription(loader
.getTitleString());
240 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
243 public void setFocus() {
244 if (sdWidget
!= null) {
245 // update actions for key bindings
246 KeyBindingsManager
.getInstance().setSdView(this);
249 if (isViewReady() && needInit
) {
250 needInit
= restoreLoader();
256 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
259 public void dispose() {
260 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
265 * Returns the SD widget.
267 * @return The SD widget.
269 public SDWidget
getSDWidget() {
274 * Set the find provider for the opened sequence diagram viewer<br>
275 * If the provider is not set, the find menu item will not be available in the viewer<br>
276 * A find provider is called back when the user perform a find action<br>
277 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
278 * find criteria as well as to highlight the GraphNode
280 * @param provider the search provider
282 public void setSDFindProvider(ISDFindProvider provider
) {
283 sdFindProvider
= provider
;
284 sdExFindProvider
= null;
285 createCoolbarContent();
286 if (provider
!= null) {
287 KeyBindingsManager
.getInstance().setFindEnabled(true);
290 KeyBindingsManager
.getInstance().setFindEnabled(false);
295 * Set the find provider for the opened sequence diagram viewer<br>
296 * If the provider is not set, the find menu item will not be available in the viewer<br>
297 * A find provider is called back when the user perform a find action<br>
298 * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
301 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
302 sdExFindProvider
= provider
;
303 sdFindProvider
= null;
304 createCoolbarContent();
305 if (provider
!= null) {
306 KeyBindingsManager
.getInstance().setFindEnabled(true);
309 KeyBindingsManager
.getInstance().setFindEnabled(false);
314 * Returns the extended find provider
316 * @return extended find provider.
318 public IExtendedFindProvider
getExtendedFindProvider() {
319 return sdExFindProvider
;
323 * Resets all providers.
325 public void resetProviders() {
326 KeyBindingsManager
.getInstance().setFindEnabled(false);
327 sdFindProvider
= null;
328 sdExFindProvider
= null;
329 sdFilterProvider
= null;
330 sdExFilterProvider
= null;
331 sdPagingProvider
= null;
332 sdExtendedActionBarProvider
= null;
333 sdPropertiesProvider
= null;
334 if ((sdWidget
!= null) && (!sdWidget
.isDisposed())) {
335 sdWidget
.setCollapseProvider(null);
340 * Set the filter provider for the opened sequence diagram viewer<br>
341 * If the provider is not set, the filter menu item will not be available in the viewer<br>
342 * A filter provider is called back when the user perform a filter action<br>
344 * @param provider the filter provider
346 public void setSDFilterProvider(ISDFilterProvider provider
) {
347 sdFilterProvider
= provider
;
348 // Both systems can be used now, commenting out next statement
349 // sdExFilterProvider = null;
350 createCoolbarContent();
354 * Sets the extended filter provider for the opend sequence diagram viewer.
357 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
358 sdExFilterProvider
= provider
;
359 // Both systems can be used now, commenting out next statement
360 // sdFilterProvider = null;
361 createCoolbarContent();
365 * Returns the extended find provider.
367 * @return The extended find provider.
369 public IExtendedFilterProvider
getExtendedFilterProvider() {
370 return sdExFilterProvider
;
374 * Register the given provider to support Drag and Drop collapsing. This provider is
375 * responsible of updating the Frame.
377 * @param provider - the provider to register
379 public void setCollapsingProvider(ISDCollapseProvider provider
) {
380 if ((sdWidget
!= null) && (!sdWidget
.isDisposed())) {
381 sdWidget
.setCollapseProvider(provider
);
386 * Set the page provider for the opened sequence diagram viewer<br>
387 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
388 * provided in order to handle page change requested by the user<br>
389 * Set a page provider will create the next and previous page buttons in the viewer coolBar
391 * @param provider the paging provider
393 public void setSDPagingProvider(ISDPagingProvider provider
) {
394 sdPagingProvider
= provider
;
395 createCoolbarContent();
399 * Returns the current page provider for the view
401 * @return the paging provider
403 public ISDPagingProvider
getSDPagingProvider() {
404 return sdPagingProvider
;
408 * Returns the current find provider for the view
410 * @return the find provider
412 public ISDFindProvider
getSDFindProvider() {
413 return sdFindProvider
;
417 * Returns the current filter provider for the view
419 * @return the filter provider
421 public ISDFilterProvider
getSDFilterProvider() {
422 return sdFilterProvider
;
426 * Set the extended action bar provider for the opened sequence diagram viewer<br>
427 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
429 * @param provider the search provider
431 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
432 sdExtendedActionBarProvider
= provider
;
433 createCoolbarContent();
437 * Returns the current extended action bar provider for the view
439 * @return the extended action bar provider
441 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
442 return sdExtendedActionBarProvider
;
446 * Set the properties view provider for the opened sequence diagram viewer
448 * @param provider the properties provider
450 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
451 sdPropertiesProvider
= provider
;
455 * Returns the current extended action bar provider for the view.
457 * @return the extended action bar provider
459 public ISDPropertiesProvider
getSDPropertiesProvider() {
460 return sdPropertiesProvider
;
464 * Creates the basic sequence diagram menu
466 protected void hookContextMenu() {
467 menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
468 menuMgr
.setRemoveAllWhenShown(true);
469 menuMgr
.addMenuListener(new IMenuListener() {
471 public void menuAboutToShow(IMenuManager manager
) {
472 fillContextMenu(manager
);
475 Menu menu
= menuMgr
.createContextMenu(sdWidget
.getViewControl());
476 sdWidget
.getViewControl().setMenu(menu
);
477 getSite().registerContextMenu(menuMgr
, sdWidget
.getSelectionProvider());
481 * Returns the context menu manager
483 * @return the menu manager
485 public MenuManager
getMenuManager() {
490 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
492 * @param manager the menu manager
494 protected void fillContextMenu(IMenuManager manager
) {
495 manager
.add(new Separator("Additions")); //$NON-NLS-1$
496 if (getSDWidget() != null && getSDWidget().currentGraphNode
!= null) {
497 ISelectionProvider selProvider
= sdWidget
.getSelectionProvider();
498 ISelection sel
= selProvider
.getSelection();
500 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
501 while (it
.hasNext()) {
502 Object node
= it
.next();
503 if (node
instanceof BaseMessage
) {
507 if (nbMessage
!= 1) {
510 GraphNode node
= getSDWidget().currentGraphNode
;
511 if (node
instanceof SyncMessageReturn
) {
512 if (((SyncMessageReturn
) node
).getMessage() != null) {
513 Action goToMessage
= new MoveToMessage(this);
514 goToMessage
.setText(SDMessages
._39
);
515 manager
.add(goToMessage
);
518 if (node
instanceof SyncMessage
) {
519 if (((SyncMessage
) node
).getMessageReturn() != null) {
520 Action goToMessage
= new MoveToMessage(this);
521 goToMessage
.setText(SDMessages
._40
);
522 manager
.add(goToMessage
);
526 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
530 * Enables/Disables an action with given name.
532 * @param actionName The action name
533 * @param state true or false
535 public void setEnableAction(String actionName
, boolean state
) {
536 IActionBars bar
= getViewSite().getActionBars();
538 IContributionItem item
= bar
.getMenuManager().find(actionName
);
539 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
540 IAction action
= ((ActionContributionItem
) item
).getAction();
541 if (action
!= null) {
542 action
.setEnabled(state
);
544 item
.setVisible(state
);
545 bar
.updateActionBars();
551 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
552 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
553 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
555 * @see ISDGraphNodeSupporter Action support definition
556 * @see SDView#setSDFilterProvider(ISDFilterProvider)
557 * @see SDView#setSDFindProvider(ISDFindProvider)
558 * @see SDView#setSDPagingProvider(ISDPagingProvider)
560 protected void createCoolbarContent() {
561 IActionBars bar
= getViewSite().getActionBars();
563 bar
.getMenuManager().removeAll();
564 bar
.getToolBarManager().removeAll();
568 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
569 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
570 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
572 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
573 noZoom
.setChecked(true);
574 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
575 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
577 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
578 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
579 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
581 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
582 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
583 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
585 MenuManager navigation
= new MenuManager(SDMessages
._77
);
587 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
588 showNodeStart
.setText(SDMessages
.uml_25
);
590 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
591 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
592 navigation
.add(showNodeStart
);
594 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
595 showNodeEnd
.setText(SDMessages
.uml_23
);
597 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
598 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
599 navigation
.add(showNodeEnd
);
601 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
603 ConfigureMinMax minMax
= new ConfigureMinMax(this);
604 minMax
.setText(SDMessages
.uml_45
);
605 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
606 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
608 if ((sdWidget
.getFrame() != null) && (sdWidget
.getFrame().hasTimeInfo())) {
609 minMax
.setEnabled(true);
611 minMax
.setEnabled(false);
614 // Do we need to display a paging item
615 if (sdPagingProvider
!= null) {
616 nextPageButton
= new NextPage(this);
617 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton
); //$NON-NLS-1$
618 nextPageButton
.setEnabled(sdPagingProvider
.hasNextPage());
619 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton
); //$NON-NLS-1$
621 prevPageButton
= new PrevPage(this);
622 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton
); //$NON-NLS-1$
623 prevPageButton
.setEnabled(sdPagingProvider
.hasPrevPage());
624 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton
); //$NON-NLS-1$
626 firstPageButton
= new FirstPage(this);
627 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton
); //$NON-NLS-1$
628 firstPageButton
.setEnabled(sdPagingProvider
.hasPrevPage());
629 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton
); //$NON-NLS-1$
631 lastPageButton
= new LastPage(this);
632 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton
); //$NON-NLS-1$
633 lastPageButton
.setEnabled(sdPagingProvider
.hasNextPage());
634 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton
); //$NON-NLS-1$
637 if (sdExFilterProvider
!= null) {
638 Action action
= sdExFilterProvider
.getFilterAction();
639 if (action
!= null) {
640 if (action
.getId() == null)
641 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
642 if (action
.getImageDescriptor() == null)
643 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
644 if (action
.getText() == null || action
.getText().length() == 0)
645 action
.setText(SDMessages
._42
);
646 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
647 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
650 // Both systems can be used now: commenting out else keyword
651 /* else */if (sdFilterProvider
!= null) {
652 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, sdFilterProvider
)); //$NON-NLS-1$
653 // No longer in the coolbar: commenting out next statement
654 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
656 if (sdPagingProvider
!= null && sdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
657 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
658 if (sdPaging
!= null) {
659 bar
.getMenuManager().remove(sdPaging
);
662 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) sdPagingProvider
)); //$NON-NLS-1$
663 updatePagesMenuItem(bar
);
666 if (sdExFindProvider
!= null) {
667 Action action
= sdExFindProvider
.getFindAction();
668 if (action
!= null) {
669 if (action
.getId() == null) {
670 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
672 if (action
.getImageDescriptor() == null) {
673 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
675 if (action
.getText() == null) {
676 action
.setText(SDMessages
._41
);
678 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
679 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
681 } else if (sdFindProvider
!= null) {
682 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
683 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
686 if (sdExtendedActionBarProvider
!= null) {
687 sdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
690 bar
.updateActionBars();
694 * Updates the view coolbar buttons state according to the value return by: -
695 * ISDExtendedActionBarProvider.hasNextPage()<br>
696 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
699 public void updateCoolBar() {
700 if (sdPagingProvider
!= null) {
701 IActionBars bar
= getViewSite().getActionBars();
705 IToolBarManager barManager
= bar
.getToolBarManager();
706 if (barManager
== null) {
709 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
710 if (nextPage
!= null && nextPage
instanceof ActionContributionItem
) {
711 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
712 if (nextPageAction
!= null && nextPageAction
instanceof NextPage
) {
713 ((NextPage
) nextPageAction
).setEnabled(sdPagingProvider
.hasNextPage());
717 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
718 if (prevPage
!= null && prevPage
instanceof ActionContributionItem
) {
719 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
720 if (prevPageAction
!= null && prevPageAction
instanceof PrevPage
) {
721 ((PrevPage
) prevPageAction
).setEnabled(sdPagingProvider
.hasPrevPage());
725 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
726 if (firstPage
!= null && firstPage
instanceof ActionContributionItem
) {
727 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
728 if (firstPageAction
!= null && firstPageAction
instanceof FirstPage
) {
729 ((FirstPage
) firstPageAction
).setEnabled(sdPagingProvider
.hasPrevPage());
733 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
734 if (lastPage
!= null && lastPage
instanceof ActionContributionItem
) {
735 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
736 if (lastPageAction
!= null && lastPageAction
instanceof LastPage
) {
737 ((LastPage
) lastPageAction
).setEnabled(sdPagingProvider
.hasNextPage());
741 updatePagesMenuItem(bar
);
746 * Enables or disables the Pages... menu item, depending on the number of pages
748 * @param bar the bar containing the action
750 protected void updatePagesMenuItem(IActionBars bar
) {
751 if (sdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
752 IMenuManager menuManager
= bar
.getMenuManager();
753 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
754 IAction openSDPagesDialog
= null;
755 if (contributionItem
!= null) {
756 openSDPagesDialog
= contributionItem
.getAction();
759 if (openSDPagesDialog
!= null && openSDPagesDialog
instanceof OpenSDPagesDialog
) {
760 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) sdPagingProvider
).pagesCount() > 1);
766 * The frame to render (the sequence diagram)
768 * @param frame the frame to display
770 public void setFrame(Frame frame
) {
771 setFrame(frame
, true);
775 * The frame to render (the sequence diagram)
777 * @param frame the frame to display
778 * @param resetPosition boolean Flag whether to reset the position or not.
780 protected void setFrame(Frame frame
, boolean resetPosition
) {
781 if (sdWidget
== null)
789 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
791 if ((loader
!= null) && (loader
.getTitleString() != null)) {
792 setContentDescription(loader
.getTitleString());
795 if (getSDWidget() != null) {
796 getSDWidget().setFrame(frame
, resetPosition
);
799 if (timeCompressionBar
!= null) {
800 timeCompressionBar
.setFrame(frame
);
803 if (!frame
.hasTimeInfo()) {
804 Composite parent
= timeCompressionBar
.getParent();
805 timeCompressionBar
.setVisible(false);
808 Composite parent
= timeCompressionBar
.getParent();
809 timeCompressionBar
.setVisible(true);
812 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
813 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
814 if (shortKeys
!= null) {
815 IContributionItem
[] items
= shortKeys
.getItems();
816 for (int i
= 0; i
< items
.length
; i
++) {
817 if (items
[i
] instanceof ActionContributionItem
) {
818 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
819 if (action
!= null) {
820 action
.setEnabled(true);
825 createCoolbarContent();
829 * Activate or deactivate the short key command given in parameter (see plugin.xml)
831 * @param id the command id defined in the plugin.xml
832 * @param value the state value
834 public void setEnableCommand(String id
, boolean value
) {
835 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
836 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
837 if (shortKeys
== null) {
840 IContributionItem item
= shortKeys
.find(id
);
841 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
842 IAction action
= ((ActionContributionItem
) item
).getAction();
843 if (action
!= null) {
844 action
.setEnabled(value
);
850 * Set the frame from an other thread than the one executing the main loop
852 * @param frame The frame to set (and display)
854 public void setFrameSync(final Frame frame
) {
855 if (getSDWidget() == null || getSDWidget().isDisposed()) {
858 getSDWidget().getDisplay().syncExec(new Runnable() {
861 if (getSDWidget() == null || getSDWidget().isDisposed()) {
871 * Ensure an object is visible from an other thread than the one executing the main loop
873 * @param sm The node to make visible in view
875 public void ensureVisibleSync(final GraphNode sm
) {
876 getSDWidget().getDisplay().syncExec(new Runnable() {
879 if (getSDWidget() == null || getSDWidget().isDisposed()) {
882 getSDWidget().ensureVisible(sm
);
888 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
890 * @param sm The node to make visible in view
891 * @param frame Frame The frame to set
893 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
894 if (getSDWidget() == null || getSDWidget().isDisposed()) {
897 getSDWidget().getDisplay().syncExec(new Runnable() {
900 if (getSDWidget() == null || getSDWidget().isDisposed()) {
903 setFrameAndEnsureVisible(frame
, sm
);
909 * Set the frame and ensure an object is visible
911 * @param sm The node to make visible in view
912 * @param frame Frame The frame to set
914 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
915 getSDWidget().clearSelection();
916 setFrame(frame
, false);
917 getSDWidget().ensureVisible(sm
);
921 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
923 * @param frame The frame to set.
924 * @param x The x coordinate to make visible.
925 * @param y The y coordinate to make visible.
927 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
928 if (getSDWidget() == null || getSDWidget().isDisposed()) {
932 getSDWidget().getDisplay().syncExec(new Runnable() {
935 setFrameAndEnsureVisible(frame
, x
, y
);
941 * Set the frame and ensure an object is visible
943 * @param frame The frame to set.
944 * @param x The x coordinate to make visible.
945 * @param y The y coordinate to make visible.
947 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
948 getSDWidget().clearSelection();
949 setFrame(frame
, false);
950 getSDWidget().ensureVisible(x
, y
);
951 getSDWidget().redraw();
955 * Toggle between default and wait cursors from an other thread than the one executing the main loop
957 * @param wait_ <code>true</code> for wait cursor else <code>false</code> for default cursor.
959 public void toggleWaitCursorAsync(final boolean wait_
) {
960 if (getSDWidget() == null || getSDWidget().isDisposed()) {
964 getSDWidget().getDisplay().asyncExec(new Runnable() {
967 if (getSDWidget() == null || getSDWidget().isDisposed()) {
971 if (waitCursor
!= null && !waitCursor
.isDisposed()) {
972 waitCursor
.dispose();
974 waitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
975 getSDWidget().setCursor(waitCursor
);
976 getSDWidget().getDisplay().update();
978 if (waitCursor
!= null && !waitCursor
.isDisposed()) {
979 waitCursor
.dispose();
982 getSDWidget().setCursor(null);
983 getSDWidget().getDisplay().update();
990 * Return the time compression bar widget
992 * @return the time compression bar
994 public TimeCompressionBar
getTimeCompressionBar() {
995 return timeCompressionBar
;
999 * Returns the current Frame (the sequence diagram container)
1001 * @return the current frame
1003 public Frame
getFrame() {
1004 if (getSDWidget() != null) {
1005 return getSDWidget().getFrame();
1013 * Restores the loader for the view based on the view ID.
1015 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
1017 protected boolean restoreLoader() {
1018 String id
= getViewSite().getId();
1019 // System.err.println("restoreLoader() id="+id);
1023 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1024 // System.err.println("restoreLoader() l="+l);
1025 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
1026 loader
.setViewer(this);
1035 * Checks if current view is ready to be used.
1037 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1039 protected boolean isViewReady() {
1040 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1045 IViewReference
[] ref
= page
.getViewReferences();
1046 for (int i
= 0; i
< ref
.length
; i
++) {
1047 if (ref
[i
].getView(false) == this) {
1055 * Creates the menu group.
1057 protected void createMenuGroup() {
1058 IActionBars bar
= getViewSite().getActionBars();
1062 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1063 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1064 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1065 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1066 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1067 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1068 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1069 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1070 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1071 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1072 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1073 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1074 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1075 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1076 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1077 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1081 * Gets adapter for this view for properties.
1083 * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
1085 @SuppressWarnings("rawtypes")
1087 public Object
getAdapter(Class _adapter
) {
1088 Object obj
= super.getAdapter(_adapter
);
1089 if (sdPropertiesProvider
!= null && _adapter
.equals(IPropertySheetPage
.class)) {
1090 return sdPropertiesProvider
.getPropertySheetEntry();