1 /**********************************************************************
2 * Copyright (c) 2005, 2008, 2011 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 * $Id: SDView.java,v 1.2 2008/01/24 02:29:01 apnan Exp $
10 * IBM - Initial API and implementation
11 * Bernd Hufmann - Updated for TMF
12 **********************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
15 import java
.util
.Iterator
;
17 import org
.eclipse
.jface
.action
.Action
;
18 import org
.eclipse
.jface
.action
.ActionContributionItem
;
19 import org
.eclipse
.jface
.action
.IAction
;
20 import org
.eclipse
.jface
.action
.IContributionItem
;
21 import org
.eclipse
.jface
.action
.IMenuListener
;
22 import org
.eclipse
.jface
.action
.IMenuManager
;
23 import org
.eclipse
.jface
.action
.IToolBarManager
;
24 import org
.eclipse
.jface
.action
.MenuManager
;
25 import org
.eclipse
.jface
.action
.Separator
;
26 import org
.eclipse
.jface
.viewers
.ISelection
;
27 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
28 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
29 import org
.eclipse
.linuxtools
.tmf
.ui
.ITmfImageConstants
;
30 import org
.eclipse
.linuxtools
.tmf
.ui
.TmfUiPlugin
;
31 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessage
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessageReturn
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ConfigureMinMax
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.FirstPage
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.KeyBindingsManager
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.LastPage
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.MoveToMessage
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.NextPage
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFiltersDialog
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFindDialog
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDPagesDialog
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.PrevPage
;
46 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Print
;
47 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeEnd
;
48 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeStart
;
49 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
;
50 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
.ZoomType
;
51 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFilterProvider
;
52 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFindProvider
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IPropertySheetPage
;
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
;
82 public class SDView
extends ViewPart
{
84 protected SDWidget sdWidget
= null;
85 protected TimeCompressionBar timeCompressionBar
= null;
86 protected ISDFindProvider sdFindProvider
= null;
87 protected ISDPagingProvider sdPagingProvider
= null;
88 protected ISDFilterProvider sdFilterProvider
= null;
89 protected IExtendedFilterProvider sdExFilterProvider
= null;
90 protected IExtendedFindProvider sdExFindProvider
= null;
91 protected ISDExtendedActionBarProvider sdExtendedActionBarProvider
= null;
92 protected ISDPropertiesProvider sdPropertiesProvider
= null;
94 protected NextPage nextPageButton
= null;
95 protected PrevPage prevPageButton
= null;
96 protected FirstPage firstPageButton
= null;
97 protected LastPage lastPageButton
= null;
99 protected MenuManager menuMgr
= null;
101 protected boolean needInit
= true;
105 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
108 public void createPartControl(Composite c
) {
109 Composite parent
= new Composite(c
, SWT
.NONE
);
110 GridLayout parentLayout
= new GridLayout();
111 parentLayout
.numColumns
= 2;
112 parentLayout
.marginWidth
= 0;
113 parentLayout
.marginHeight
= 0;
114 parent
.setLayout(parentLayout
);
116 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
117 timeLayoutdata
.widthHint
= 10;
118 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
119 timeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
120 timeCompressionBar
.setLayoutData(timeLayoutdata
);
121 sdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
122 sdWidget
.setLayoutData(seqDiagLayoutData
);
123 sdWidget
.setSite(this);
124 sdWidget
.setTimeBar(timeCompressionBar
);
126 // Add this view to the key bindings manager
127 KeyBindingsManager
.getInstance().add(this.getSite().getId());
129 createCoolbarContent();
133 timeCompressionBar
.setVisible(false);
136 Print print
= new Print(this);
137 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
139 needInit
= restoreLoader();
143 * Load a blank page that is supposed to explain that a kind of interaction must be chosen
145 protected void loadBlank() {
146 IUml2SDLoader l
= new IUml2SDLoader() {
150 * org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui
151 * .views.uml2sd.SDView)
154 public void setViewer(SDView viewer
) {
156 Frame f
= new Frame();
157 f
.setName(""); //$NON-NLS-1$
163 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
166 public String
getTitleString() {
167 return ""; //$NON-NLS-1$
172 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#aboutToBeReplaced()
175 public void dispose() {
179 setContentDescription(l
.getTitleString());
184 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
187 public void setFocus() {
188 if (sdWidget
!= null) {
189 // update actions for key bindings
190 KeyBindingsManager
.getInstance().setSdView(this);
193 if (isViewReady() && needInit
) {
194 needInit
= restoreLoader();
200 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
203 public void dispose() {
204 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
209 * @return The SD widget.
211 public SDWidget
getSDWidget() {
216 * Set the find provider for the opened sequence diagram viewer<br>
217 * If the provider is not set, the find menu item will not be available in the viewer<br>
218 * A find provider is called back when the user perform a find action<br>
219 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
220 * find criteria as well as to highlight the GraphNode
222 * @param provider the search provider
224 public void setSDFindProvider(ISDFindProvider provider
) {
225 sdFindProvider
= provider
;
226 sdExFindProvider
= null;
227 createCoolbarContent();
228 if (provider
!= null) {
229 KeyBindingsManager
.getInstance().setFindEnabled(true);
232 KeyBindingsManager
.getInstance().setFindEnabled(false);
237 * Set the find provider for the opened sequence diagram viewer<br>
238 * If the provider is not set, the find menu item will not be available in the viewer<br>
239 * A find provider is called back when the user perform a find action<br>
240 * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
243 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
244 sdExFindProvider
= provider
;
245 sdFindProvider
= null;
246 createCoolbarContent();
247 if (provider
!= null) {
248 KeyBindingsManager
.getInstance().setFindEnabled(true);
251 KeyBindingsManager
.getInstance().setFindEnabled(false);
256 * Returns the extended find provider
258 * @return extended find provider.
260 public IExtendedFindProvider
getExtendedFindProvider() {
261 return sdExFindProvider
;
265 * Resets all providers.
267 public void resetProviders() {
268 KeyBindingsManager
.getInstance().setFindEnabled(false);
269 sdFindProvider
= null;
270 sdExFindProvider
= null;
271 sdFilterProvider
= null;
272 sdExFilterProvider
= null;
273 sdPagingProvider
= null;
274 sdExtendedActionBarProvider
= null;
275 sdPropertiesProvider
= null;
276 if ((sdWidget
!= null) && (!sdWidget
.isDisposed())) {
277 sdWidget
.setCollapseProvider(null);
282 * Set the filter provider for the opened sequence diagram viewer<br>
283 * If the provider is not set, the filter menu item will not be available in the viewer<br>
284 * A filter provider is called back when the user perform a filter action<br>
286 * @param provider the filter provider
288 public void setSDFilterProvider(ISDFilterProvider provider
) {
289 sdFilterProvider
= provider
;
290 // Both systems can be used now, commenting out next statement
291 // sdExFilterProvider = null;
292 createCoolbarContent();
296 * Sets the extended filter provider for the opend sequence diagram viewer.
299 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
300 sdExFilterProvider
= provider
;
301 // Both systems can be used now, commenting out next statement
302 // sdFilterProvider = null;
303 createCoolbarContent();
307 * Returns the extended find provider.
309 * @return The extended find provider.
311 public IExtendedFilterProvider
getExtendedFilterProvider() {
312 return sdExFilterProvider
;
316 * Register the given provider to support Drag and Drop collapsing. This provider is
317 * responsible of updating the Frame.
319 * @param provider - the provider to register
321 public void setCollapsingProvider(ISDCollapseProvider provider
) {
322 if ((sdWidget
!= null) && (!sdWidget
.isDisposed())) {
323 sdWidget
.setCollapseProvider(provider
);
328 * Set the page provider for the opened sequence diagram viewer<br>
329 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
330 * provided in order to handle page change requested by the user<br>
331 * Set a page provider will create the next and previous page buttons in the viewer coolBar
333 * @param provider the paging provider
335 public void setSDPagingProvider(ISDPagingProvider provider
) {
336 sdPagingProvider
= provider
;
337 createCoolbarContent();
341 * Returns the current page provider for the view
343 * @return the paging provider
345 public ISDPagingProvider
getSDPagingProvider() {
346 return sdPagingProvider
;
350 * Returns the current find provider for the view
352 * @return the find provider
354 public ISDFindProvider
getSDFindProvider() {
355 return sdFindProvider
;
359 * Returns the current filter provider for the view
361 * @return the filter provider
363 public ISDFilterProvider
getSDFilterProvider() {
364 return sdFilterProvider
;
368 * Set the extended action bar provider for the opened sequence diagram viewer<br>
369 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
371 * @param provider the search provider
373 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
374 sdExtendedActionBarProvider
= provider
;
375 createCoolbarContent();
379 * Returns the current extended action bar provider for the view
381 * @return the extended action bar provider
383 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
384 return sdExtendedActionBarProvider
;
388 * Set the properties view provider for the opened sequence diagram viewer<br>
390 * @param provider the properties provider
392 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
393 sdPropertiesProvider
= provider
;
397 * Returns the current extended action bar provider for the view
399 * @return the extended action bar provider
401 public ISDPropertiesProvider
getSDPropertiesProvider() {
402 return sdPropertiesProvider
;
406 * Creates the basic sequence diagram menu
408 protected void hookContextMenu() {
409 menuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
410 menuMgr
.setRemoveAllWhenShown(true);
411 menuMgr
.addMenuListener(new IMenuListener() {
413 public void menuAboutToShow(IMenuManager manager
) {
414 fillContextMenu(manager
);
417 Menu menu
= menuMgr
.createContextMenu(sdWidget
.getViewControl());
418 sdWidget
.getViewControl().setMenu(menu
);
419 getSite().registerContextMenu(menuMgr
, sdWidget
.getSelectionProvider());
423 * Returns the context menu manager
425 * @return the menu manager
427 public MenuManager
getMenuManager() {
432 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
434 * @param manager the menu manager
436 protected void fillContextMenu(IMenuManager manager
) {
437 manager
.add(new Separator("Additions")); //$NON-NLS-1$
438 if (getSDWidget() != null && getSDWidget().currentGraphNode
!= null) {
439 ISelectionProvider selProvider
= sdWidget
.getSelectionProvider();
440 ISelection sel
= selProvider
.getSelection();
442 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
443 while (it
.hasNext()) {
444 Object node
= it
.next();
445 if (node
instanceof BaseMessage
) {
449 if (nbMessage
!= 1) {
452 GraphNode node
= getSDWidget().currentGraphNode
;
453 if (node
instanceof SyncMessageReturn
) {
454 if (((SyncMessageReturn
) node
).getMessage() != null) {
455 Action goToMessage
= new MoveToMessage(this);
456 goToMessage
.setText(SDMessages
._39
);
457 manager
.add(goToMessage
);
460 if (node
instanceof SyncMessage
) {
461 if (((SyncMessage
) node
).getMessageReturn() != null) {
462 Action goToMessage
= new MoveToMessage(this);
463 goToMessage
.setText(SDMessages
._40
);
464 manager
.add(goToMessage
);
468 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
472 * Enables/Disables an action with given name.
474 * @param actionName The action name
475 * @param state true or false
477 public void setEnableAction(String actionName
, boolean state
) {
478 IActionBars bar
= getViewSite().getActionBars();
480 IContributionItem item
= bar
.getMenuManager().find(actionName
);
481 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
482 IAction action
= ((ActionContributionItem
) item
).getAction();
483 if (action
!= null) {
484 action
.setEnabled(state
);
486 item
.setVisible(state
);
487 bar
.updateActionBars();
493 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
494 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
495 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
497 * @see ISDGraphNodeSupporter Action support definition
498 * @see SDView#setSDFilterProvider(ISDFilterProvider)
499 * @see SDView#setSDFindProvider(ISDFindProvider)
500 * @see SDView#setSDPagingProvider(ISDPagingProvider)
502 protected void createCoolbarContent() {
503 IActionBars bar
= getViewSite().getActionBars();
505 bar
.getMenuManager().removeAll();
506 bar
.getToolBarManager().removeAll();
510 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
511 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
512 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
514 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
515 noZoom
.setChecked(true);
516 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
517 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
519 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
520 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
521 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
523 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
524 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
525 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
527 MenuManager navigation
= new MenuManager(SDMessages
._77
);
529 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
530 showNodeStart
.setText(SDMessages
.uml_25
);
532 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
533 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
534 navigation
.add(showNodeStart
);
536 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
537 showNodeEnd
.setText(SDMessages
.uml_23
);
539 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
540 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
541 navigation
.add(showNodeEnd
);
543 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
545 ConfigureMinMax minMax
= new ConfigureMinMax(this);
546 minMax
.setText(SDMessages
.uml_45
);
547 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
548 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
550 if ((sdWidget
.getFrame() != null) && (sdWidget
.getFrame().hasTimeInfo()))
551 minMax
.setEnabled(true);
553 minMax
.setEnabled(false);
555 // Do we need to display a paging item
556 if (sdPagingProvider
!= null) {
557 nextPageButton
= new NextPage(this);
558 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton
); //$NON-NLS-1$
559 nextPageButton
.setEnabled(sdPagingProvider
.hasNextPage());
560 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", nextPageButton
); //$NON-NLS-1$
562 prevPageButton
= new PrevPage(this);
563 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton
); //$NON-NLS-1$
564 prevPageButton
.setEnabled(sdPagingProvider
.hasPrevPage());
565 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", prevPageButton
); //$NON-NLS-1$
567 firstPageButton
= new FirstPage(this);
568 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton
); //$NON-NLS-1$
569 firstPageButton
.setEnabled(sdPagingProvider
.hasPrevPage());
570 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", firstPageButton
); //$NON-NLS-1$
572 lastPageButton
= new LastPage(this);
573 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton
); //$NON-NLS-1$
574 lastPageButton
.setEnabled(sdPagingProvider
.hasNextPage());
575 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", lastPageButton
); //$NON-NLS-1$
578 if (sdExFilterProvider
!= null) {
579 Action action
= sdExFilterProvider
.getFilterAction();
580 if (action
!= null) {
581 if (action
.getId() == null)
582 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
583 if (action
.getImageDescriptor() == null)
584 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
585 if (action
.getText() == null || action
.getText().length() == 0)
586 action
.setText(SDMessages
._42
);
587 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
588 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
591 // Both systems can be used now: commenting out else keyword
592 /* else */if (sdFilterProvider
!= null) {
593 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, sdFilterProvider
)); //$NON-NLS-1$
594 // No longer in the coolbar: commenting out next statement
595 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
597 if (sdPagingProvider
!= null && sdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
598 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
599 if (sdPaging
!= null) {
600 bar
.getMenuManager().remove(sdPaging
);
603 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) sdPagingProvider
)); //$NON-NLS-1$
604 updatePagesMenuItem(bar
);
607 if (sdExFindProvider
!= null) {
608 Action action
= sdExFindProvider
.getFindAction();
609 if (action
!= null) {
610 if (action
.getId() == null)
611 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
612 if (action
.getImageDescriptor() == null)
613 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
614 if (action
.getText() == null)
615 action
.setText(SDMessages
._41
);
616 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
617 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
619 } else if (sdFindProvider
!= null) {
620 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
621 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
624 if (sdExtendedActionBarProvider
!= null) {
625 sdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
628 bar
.updateActionBars();
632 * Updates the view coolbar buttons state according to the value return by: -
633 * ISDExtendedActionBarProvider.hasNextPage()<br>
634 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
637 public void updateCoolBar() {
638 if (sdPagingProvider
!= null) {
639 IActionBars bar
= getViewSite().getActionBars();
642 IToolBarManager barManager
= bar
.getToolBarManager();
643 if (barManager
== null)
645 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
646 if (nextPage
!= null && nextPage
instanceof ActionContributionItem
) {
647 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
648 if (nextPageAction
!= null && nextPageAction
instanceof NextPage
) {
649 ((NextPage
) nextPageAction
).setEnabled(sdPagingProvider
.hasNextPage());
653 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
654 if (prevPage
!= null && prevPage
instanceof ActionContributionItem
) {
655 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
656 if (prevPageAction
!= null && prevPageAction
instanceof PrevPage
) {
657 ((PrevPage
) prevPageAction
).setEnabled(sdPagingProvider
.hasPrevPage());
661 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
662 if (firstPage
!= null && firstPage
instanceof ActionContributionItem
) {
663 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
664 if (firstPageAction
!= null && firstPageAction
instanceof FirstPage
) {
665 ((FirstPage
) firstPageAction
).setEnabled(sdPagingProvider
.hasPrevPage());
669 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
670 if (lastPage
!= null && lastPage
instanceof ActionContributionItem
) {
671 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
672 if (lastPageAction
!= null && lastPageAction
instanceof LastPage
) {
673 ((LastPage
) lastPageAction
).setEnabled(sdPagingProvider
.hasNextPage());
677 updatePagesMenuItem(bar
);
682 * Enables or disables the Pages... menu item, depending on the number of pages
684 * @param bar the bar containing the action
686 protected void updatePagesMenuItem(IActionBars bar
) {
687 if (sdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
688 IMenuManager menuManager
= bar
.getMenuManager();
689 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
690 IAction openSDPagesDialog
= null;
691 if (contributionItem
!= null) {
692 openSDPagesDialog
= contributionItem
.getAction();
695 if (openSDPagesDialog
!= null && openSDPagesDialog
instanceof OpenSDPagesDialog
) {
696 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) sdPagingProvider
).pagesCount() > 1);
702 * The frame to render (the sequence diagram)
704 * @param frame the frame to display
706 public void setFrame(Frame frame
) {
707 setFrame(frame
, true);
711 * The frame to render (the sequence diagram)
713 * @param frame the frame to display
715 protected void setFrame(Frame frame
, boolean resetPosition
) {
716 if (sdWidget
== null)
724 IUml2SDLoader l
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
726 if ((l
!= null) && (l
.getTitleString() != null)) {
727 setContentDescription(l
.getTitleString());
730 if (getSDWidget() != null)
731 getSDWidget().setFrame(frame
, resetPosition
);
733 if (timeCompressionBar
!= null)
734 timeCompressionBar
.setFrame(frame
);
736 if (!frame
.hasTimeInfo()) {
737 Composite parent
= timeCompressionBar
.getParent();
738 timeCompressionBar
.setVisible(false);
741 Composite parent
= timeCompressionBar
.getParent();
742 timeCompressionBar
.setVisible(true);
745 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
746 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
747 if (shortKeys
!= null) {
748 IContributionItem
[] items
= shortKeys
.getItems();
749 for (int i
= 0; i
< items
.length
; i
++) {
750 if (items
[i
] instanceof ActionContributionItem
) {
751 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
753 action
.setEnabled(true);
757 createCoolbarContent();
761 * Activate or deactivate the short key command given in parameter (see plugin.xml)
763 * @param id the command id defined in the plugin.xml
764 * @param value the state value
766 public void setEnableCommand(String id
, boolean value
) {
767 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
768 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
769 if (shortKeys
== null)
771 IContributionItem item
= shortKeys
.find(id
);
772 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
773 IAction action
= ((ActionContributionItem
) item
).getAction();
775 action
.setEnabled(value
);
780 * Set the frame from an other thread than the one executing the main loop
784 public void setFrameSync(final Frame frame
) {
785 if (getSDWidget() == null || getSDWidget().isDisposed()) {
788 getSDWidget().getDisplay().syncExec(new Runnable() {
791 if (getSDWidget() == null || getSDWidget().isDisposed()) {
801 * Ensure an object is visible from an other thread than the one executing the main loop
805 public void ensureVisibleSync(final GraphNode sm
) {
806 getSDWidget().getDisplay().syncExec(new Runnable() {
809 if (getSDWidget() == null || getSDWidget().isDisposed()) {
812 getSDWidget().ensureVisible(sm
);
818 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
822 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
823 if (getSDWidget() == null || getSDWidget().isDisposed()) {
826 getSDWidget().getDisplay().syncExec(new Runnable() {
829 if (getSDWidget() == null || getSDWidget().isDisposed()) {
832 setFrameAndEnsureVisible(frame
, sm
);
838 * Set the frame and ensure an object is visible
842 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
843 getSDWidget().clearSelection();
844 setFrame(frame
, false);
845 getSDWidget().ensureVisible(sm
);
849 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
853 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
854 if (getSDWidget() == null || getSDWidget().isDisposed()) {
858 getSDWidget().getDisplay().syncExec(new Runnable() {
861 setFrameAndEnsureVisible(frame
, x
, y
);
867 * Set the frame and ensure an object is visible
871 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
872 getSDWidget().clearSelection();
873 setFrame(frame
, false);
874 getSDWidget().ensureVisible(x
, y
);
875 getSDWidget().redraw();
879 * waitCursor is the cursor to be displayed when long tasks are running
881 protected Cursor waitCursor
;
884 * Toggle between default and wait cursors from an other thread than the one executing the main loop
886 public void toggleWaitCursorAsync(final boolean wait_
) {
887 if (getSDWidget() == null || getSDWidget().isDisposed()) {
891 getSDWidget().getDisplay().asyncExec(new Runnable() {
894 if (getSDWidget() == null || getSDWidget().isDisposed()) {
898 if (waitCursor
!= null && !waitCursor
.isDisposed()) {
899 waitCursor
.dispose();
901 waitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
902 getSDWidget().setCursor(waitCursor
);
903 getSDWidget().getDisplay().update();
905 if (waitCursor
!= null && !waitCursor
.isDisposed()) {
906 waitCursor
.dispose();
909 getSDWidget().setCursor(null);
910 getSDWidget().getDisplay().update();
917 * Return the time compression bar widget
919 * @return the time compression bar
921 public TimeCompressionBar
getTimeCompressionBar() {
922 return timeCompressionBar
;
926 * Returns the current Frame (the sequence diagram container)
930 public Frame
getFrame() {
931 if (getSDWidget() != null) {
932 return getSDWidget().getFrame();
939 protected boolean restoreLoader() {
940 String id
= getViewSite().getId();
941 // System.err.println("restoreLoader() id="+id);
945 IUml2SDLoader l
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
946 // System.err.println("restoreLoader() l="+l);
947 if ((l
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
956 protected boolean isViewReady() {
957 IWorkbenchPage persp
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
961 IViewReference
[] ref
= persp
.getViewReferences();
962 for (int i
= 0; i
< ref
.length
; i
++) {
963 if (ref
[i
].getView(false) == this) {
970 protected void createMenuGroup() {
971 IActionBars bar
= getViewSite().getActionBars();
975 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
976 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
977 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
978 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
979 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
980 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
981 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
982 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
983 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
984 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
985 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
986 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
987 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
988 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
989 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
990 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
993 @SuppressWarnings("rawtypes")
995 public Object
getAdapter(Class _adapter
) {
996 Object obj
= super.getAdapter(_adapter
);
997 if (sdPropertiesProvider
!= null && _adapter
.equals(IPropertySheetPage
.class)) {
998 return sdPropertiesProvider
.getPropertySheetEntry();