1 /**********************************************************************
2 * Copyright (c) 2005, 2013 IBM Corporation, Ericsson
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
9 * IBM - Initial API and implementation
10 * Bernd Hufmann - Updated for TMF
11 **********************************************************************/
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
.internal
.tmf
.ui
.Activator
;
30 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
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
.ISDAdvancedPagingProvider
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDExtendedActionBarProvider
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFilterProvider
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFindProvider
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDGraphNodeSupporter
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPagingProvider
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPropertiesProvider
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.IUml2SDLoader
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
64 import org
.eclipse
.swt
.SWT
;
65 import org
.eclipse
.swt
.graphics
.Cursor
;
66 import org
.eclipse
.swt
.layout
.GridData
;
67 import org
.eclipse
.swt
.layout
.GridLayout
;
68 import org
.eclipse
.swt
.widgets
.Composite
;
69 import org
.eclipse
.swt
.widgets
.Menu
;
70 import org
.eclipse
.ui
.IActionBars
;
71 import org
.eclipse
.ui
.IViewReference
;
72 import org
.eclipse
.ui
.IWorkbenchPage
;
73 import org
.eclipse
.ui
.PlatformUI
;
74 import org
.eclipse
.ui
.actions
.ActionFactory
;
75 import org
.eclipse
.ui
.part
.ViewPart
;
76 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
80 * This class is a generic sequence diagram view implementation.
86 public class SDView
extends ViewPart
{
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
92 * The sequence diagram widget.
94 protected SDWidget fSdWidget
= null;
96 * The time compression bar.
98 protected TimeCompressionBar fTimeCompressionBar
= null;
100 * The sequence diagram find provider implementation.
102 protected ISDFindProvider fSdFindProvider
= null;
104 * The sequence diagram paging provider implementation.
106 protected ISDPagingProvider fSdPagingProvider
= null;
108 * The sequence diagram filter provider implementation.
110 protected ISDFilterProvider fSdFilterProvider
= null;
112 * The extended sequence diagram filter provider implementation.
114 protected IExtendedFilterProvider fSdExFilterProvider
= null;
116 * The extended sequence diagram find provider implementation.
118 protected IExtendedFindProvider fSdExFindProvider
= null;
120 * The extended sequence diagram action bar provider implementation.
122 protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider
= null;
124 * The sequence diagram property provider implementation.
126 protected ISDPropertiesProvider fSdPropertiesProvider
= null;
128 * Button for executing the next page action.
130 protected NextPage fNextPageButton
= null;
132 * Button for executing the previous page action.
134 protected PrevPage fPrevPageButton
= null;
136 * Button for executing the first page page action.
138 protected FirstPage fFirstPageButton
= null;
140 * Button for executing the last page action.
142 protected LastPage fLastPageButton
= null;
144 * The menu manager reference.
146 protected MenuManager fMenuMgr
= null;
148 * Flag to indicate whether view needs initialization or not.
150 protected boolean fNeedInit
= true;
152 * WaitCursor is the cursor to be displayed when long tasks are running
154 protected Cursor fWaitCursor
;
156 // ------------------------------------------------------------------------
158 // ------------------------------------------------------------------------
161 public void createPartControl(Composite c
) {
162 Composite parent
= new Composite(c
, SWT
.NONE
);
163 GridLayout parentLayout
= new GridLayout();
164 parentLayout
.numColumns
= 2;
165 parentLayout
.marginWidth
= 0;
166 parentLayout
.marginHeight
= 0;
167 parent
.setLayout(parentLayout
);
169 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
170 timeLayoutdata
.widthHint
= 10;
171 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
172 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
173 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
174 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
175 fSdWidget
.setLayoutData(seqDiagLayoutData
);
176 fSdWidget
.setSite(this);
177 fSdWidget
.setTimeBar(fTimeCompressionBar
);
179 // Add this view to the key bindings manager
180 KeyBindingsManager
.getInstance().add(this.getSite().getId());
182 createCoolbarContent();
186 fTimeCompressionBar
.setVisible(false);
189 Print print
= new Print(this);
190 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
192 fNeedInit
= restoreLoader();
196 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
198 protected void loadBlank() {
199 IUml2SDLoader loader
= new BlankUml2SdLoader();
200 loader
.setViewer(this);
201 setContentDescription(loader
.getTitleString());
205 public void setFocus() {
206 if (fSdWidget
!= null) {
207 // update actions for key bindings
208 KeyBindingsManager
.getInstance().setSdView(this);
209 fSdWidget
.setFocus();
211 if (isViewReady() && fNeedInit
) {
212 fNeedInit
= restoreLoader();
217 public void dispose() {
218 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
223 * Returns the SD widget.
225 * @return The SD widget.
227 public SDWidget
getSDWidget() {
232 * Set the find provider for the opened sequence diagram viewer<br>
233 * If the provider is not set, the find menu item will not be available in the viewer<br>
234 * A find provider is called back when the user perform a find action<br>
235 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
236 * find criteria as well as to highlight the GraphNode
238 * @param provider the search provider
240 public void setSDFindProvider(ISDFindProvider provider
) {
241 fSdFindProvider
= provider
;
242 fSdExFindProvider
= null;
243 createCoolbarContent();
244 if (provider
!= null) {
245 KeyBindingsManager
.getInstance().setFindEnabled(true);
248 KeyBindingsManager
.getInstance().setFindEnabled(false);
253 * Set the find provider for the opened sequence diagram viewer<br>
254 * If the provider is not set, the find menu item will not be available in
256 * A find provider is called back when the user perform a find action<br>
257 * If the extended find provider is set, it replaces the regular find
258 * provider (sdFindProvider).<br>
261 * The provider to set
263 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
264 fSdExFindProvider
= provider
;
265 fSdFindProvider
= null;
266 createCoolbarContent();
267 if (provider
!= null) {
268 KeyBindingsManager
.getInstance().setFindEnabled(true);
271 KeyBindingsManager
.getInstance().setFindEnabled(false);
276 * Returns the extended find provider
278 * @return extended find provider.
280 public IExtendedFindProvider
getExtendedFindProvider() {
281 return fSdExFindProvider
;
285 * Resets all providers.
287 public void resetProviders() {
288 KeyBindingsManager
.getInstance().setFindEnabled(false);
289 fSdFindProvider
= null;
290 fSdExFindProvider
= null;
291 fSdFilterProvider
= null;
292 fSdExFilterProvider
= null;
293 fSdPagingProvider
= null;
294 fSdExtendedActionBarProvider
= null;
295 fSdPropertiesProvider
= null;
296 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
297 fSdWidget
.setCollapseProvider(null);
302 * Set the filter provider for the opened sequence diagram viewer<br>
303 * If the provider is not set, the filter menu item will not be available in the viewer<br>
304 * A filter provider is called back when the user perform a filter action<br>
306 * @param provider the filter provider
308 public void setSDFilterProvider(ISDFilterProvider provider
) {
309 fSdFilterProvider
= provider
;
310 // Both systems can be used now, commenting out next statement
311 // sdExFilterProvider = null;
312 createCoolbarContent();
316 * Sets the extended filter provider for the opened sequence diagram viewer.
319 * The provider to set
321 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
322 fSdExFilterProvider
= provider
;
323 // Both systems can be used now, commenting out next statement
324 // sdFilterProvider = null;
325 createCoolbarContent();
329 * Returns the extended find provider.
331 * @return The extended find provider.
333 public IExtendedFilterProvider
getExtendedFilterProvider() {
334 return fSdExFilterProvider
;
338 * Register the given provider to support Drag and Drop collapsing. This provider is
339 * responsible of updating the Frame.
341 * @param provider - the provider to register
343 public void setCollapsingProvider(ISDCollapseProvider provider
) {
344 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
345 fSdWidget
.setCollapseProvider(provider
);
350 * Set the page provider for the opened sequence diagram viewer<br>
351 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
352 * provided in order to handle page change requested by the user<br>
353 * Set a page provider will create the next and previous page buttons in the viewer coolBar
355 * @param provider the paging provider
357 public void setSDPagingProvider(ISDPagingProvider provider
) {
358 fSdPagingProvider
= provider
;
359 createCoolbarContent();
363 * Returns the current page provider for the view
365 * @return the paging provider
367 public ISDPagingProvider
getSDPagingProvider() {
368 return fSdPagingProvider
;
372 * Returns the current find provider for the view
374 * @return the find provider
376 public ISDFindProvider
getSDFindProvider() {
377 return fSdFindProvider
;
381 * Returns the current filter provider for the view
383 * @return the filter provider
385 public ISDFilterProvider
getSDFilterProvider() {
386 return fSdFilterProvider
;
390 * Set the extended action bar provider for the opened sequence diagram viewer<br>
391 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
393 * @param provider the search provider
395 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
396 fSdExtendedActionBarProvider
= provider
;
397 createCoolbarContent();
401 * Returns the current extended action bar provider for the view
403 * @return the extended action bar provider
405 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
406 return fSdExtendedActionBarProvider
;
410 * Set the properties view provider for the opened sequence diagram viewer
412 * @param provider the properties provider
414 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
415 fSdPropertiesProvider
= provider
;
419 * Returns the current extended action bar provider for the view.
421 * @return the extended action bar provider
423 public ISDPropertiesProvider
getSDPropertiesProvider() {
424 return fSdPropertiesProvider
;
428 * Creates the basic sequence diagram menu
430 protected void hookContextMenu() {
431 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
432 fMenuMgr
.setRemoveAllWhenShown(true);
433 fMenuMgr
.addMenuListener(new IMenuListener() {
435 public void menuAboutToShow(IMenuManager manager
) {
436 fillContextMenu(manager
);
439 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
440 fSdWidget
.getViewControl().setMenu(menu
);
441 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
445 * Returns the context menu manager
447 * @return the menu manager
449 public MenuManager
getMenuManager() {
454 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
456 * @param manager the menu manager
458 protected void fillContextMenu(IMenuManager manager
) {
459 manager
.add(new Separator("Additions")); //$NON-NLS-1$
460 if (getSDWidget() != null && getSDWidget().fCurrentGraphNode
!= null) {
461 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
462 ISelection sel
= selProvider
.getSelection();
464 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
465 while (it
.hasNext()) {
466 Object node
= it
.next();
467 if (node
instanceof BaseMessage
) {
471 if (nbMessage
!= 1) {
474 GraphNode node
= getSDWidget().fCurrentGraphNode
;
475 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
476 Action goToMessage
= new MoveToMessage(this);
477 goToMessage
.setText(SDMessages
._39
);
478 manager
.add(goToMessage
);
480 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
481 Action goToMessage
= new MoveToMessage(this);
482 goToMessage
.setText(SDMessages
._40
);
483 manager
.add(goToMessage
);
486 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
490 * Enables/Disables an action with given name.
492 * @param actionName The action name
493 * @param state true or false
495 public void setEnableAction(String actionName
, boolean state
) {
496 IActionBars bar
= getViewSite().getActionBars();
498 IContributionItem item
= bar
.getMenuManager().find(actionName
);
499 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
500 IAction action
= ((ActionContributionItem
) item
).getAction();
501 if (action
!= null) {
502 action
.setEnabled(state
);
504 item
.setVisible(state
);
505 bar
.updateActionBars();
511 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
512 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
513 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
515 * @see ISDGraphNodeSupporter Action support definition
516 * @see SDView#setSDFilterProvider(ISDFilterProvider)
517 * @see SDView#setSDFindProvider(ISDFindProvider)
518 * @see SDView#setSDPagingProvider(ISDPagingProvider)
520 protected void createCoolbarContent() {
521 IActionBars bar
= getViewSite().getActionBars();
523 bar
.getMenuManager().removeAll();
524 bar
.getToolBarManager().removeAll();
528 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
529 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
530 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
532 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
533 noZoom
.setChecked(true);
534 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
535 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
537 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
538 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
539 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
541 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
542 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
543 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
545 MenuManager navigation
= new MenuManager(SDMessages
._77
);
547 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
548 showNodeStart
.setText(SDMessages
.uml_25
);
550 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
551 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
552 navigation
.add(showNodeStart
);
554 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
555 showNodeEnd
.setText(SDMessages
.uml_23
);
557 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
558 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
559 navigation
.add(showNodeEnd
);
561 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
563 ConfigureMinMax minMax
= new ConfigureMinMax(this);
564 minMax
.setText(SDMessages
.uml_45
);
565 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
566 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
568 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
569 minMax
.setEnabled(true);
571 minMax
.setEnabled(false);
574 // Do we need to display a paging item
575 if (fSdPagingProvider
!= null) {
576 fNextPageButton
= new NextPage(this);
577 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
578 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
579 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
581 fPrevPageButton
= new PrevPage(this);
582 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
583 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
584 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
586 fFirstPageButton
= new FirstPage(this);
587 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
588 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
589 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
591 fLastPageButton
= new LastPage(this);
592 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
593 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
594 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
597 if (fSdExFilterProvider
!= null) {
598 Action action
= fSdExFilterProvider
.getFilterAction();
599 if (action
!= null) {
600 if (action
.getId() == null)
602 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
604 if (action
.getImageDescriptor() == null) {
605 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
607 if (action
.getText() == null || action
.getText().length() == 0) {
608 action
.setText(SDMessages
._42
);
610 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
611 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
614 // Both systems can be used now: commenting out else keyword
615 /* else */if (fSdFilterProvider
!= null) {
616 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider
)); //$NON-NLS-1$
617 // No longer in the coolbar: commenting out next statement
618 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
620 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
621 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
622 if (sdPaging
!= null) {
623 bar
.getMenuManager().remove(sdPaging
);
626 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
)); //$NON-NLS-1$
627 updatePagesMenuItem(bar
);
630 if (fSdExFindProvider
!= null) {
631 Action action
= fSdExFindProvider
.getFindAction();
632 if (action
!= null) {
633 if (action
.getId() == null) {
634 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
636 if (action
.getImageDescriptor() == null) {
637 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
639 if (action
.getText() == null) {
640 action
.setText(SDMessages
._41
);
642 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
643 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
645 } else if (fSdFindProvider
!= null) {
646 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
647 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
650 if (fSdExtendedActionBarProvider
!= null) {
651 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
654 bar
.updateActionBars();
658 * Updates the view coolbar buttons state according to the value return by: -
659 * ISDExtendedActionBarProvider.hasNextPage()<br>
660 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
663 public void updateCoolBar() {
664 if (fSdPagingProvider
!= null) {
665 IActionBars bar
= getViewSite().getActionBars();
669 IToolBarManager barManager
= bar
.getToolBarManager();
670 if (barManager
== null) {
673 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
674 if (nextPage
instanceof ActionContributionItem
) {
675 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
676 if (nextPageAction
instanceof NextPage
) {
677 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
681 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
682 if (prevPage
instanceof ActionContributionItem
) {
683 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
684 if (prevPageAction
instanceof PrevPage
) {
685 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
689 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
690 if (firstPage
instanceof ActionContributionItem
) {
691 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
692 if (firstPageAction
instanceof FirstPage
) {
693 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
697 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
698 if (lastPage
instanceof ActionContributionItem
) {
699 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
700 if (lastPageAction
instanceof LastPage
) {
701 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
705 updatePagesMenuItem(bar
);
710 * Enables or disables the Pages... menu item, depending on the number of pages
712 * @param bar the bar containing the action
714 protected void updatePagesMenuItem(IActionBars bar
) {
715 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
716 IMenuManager menuManager
= bar
.getMenuManager();
717 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
718 IAction openSDPagesDialog
= null;
719 if (contributionItem
!= null) {
720 openSDPagesDialog
= contributionItem
.getAction();
723 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
724 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
730 * The frame to render (the sequence diagram)
732 * @param frame the frame to display
734 public void setFrame(Frame frame
) {
735 setFrame(frame
, true);
739 * The frame to render (the sequence diagram)
741 * @param frame the frame to display
742 * @param resetPosition boolean Flag whether to reset the position or not.
744 protected void setFrame(Frame frame
, boolean resetPosition
) {
745 if (getSDWidget() == null) {
754 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
755 if (loader
== null) {
759 if (loader
.getTitleString() != null) {
760 setContentDescription(loader
.getTitleString());
763 getSDWidget().setFrame(frame
, resetPosition
);
765 if (fTimeCompressionBar
!= null) {
766 fTimeCompressionBar
.setFrame(frame
);
769 if (fTimeCompressionBar
!= null) {
770 if (!frame
.hasTimeInfo()) {
771 Composite parent
= fTimeCompressionBar
.getParent();
772 fTimeCompressionBar
.setVisible(false);
775 Composite parent
= fTimeCompressionBar
.getParent();
776 fTimeCompressionBar
.setVisible(true);
780 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
781 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
782 if (shortKeys
!= null) {
783 IContributionItem
[] items
= shortKeys
.getItems();
784 for (int i
= 0; i
< items
.length
; i
++) {
785 if (items
[i
] instanceof ActionContributionItem
) {
786 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
787 if (action
!= null) {
788 action
.setEnabled(true);
793 createCoolbarContent();
797 * Activate or deactivate the short key command given in parameter (see plugin.xml)
799 * @param id the command id defined in the plugin.xml
800 * @param value the state value
802 public void setEnableCommand(String id
, boolean value
) {
803 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
804 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
805 if (shortKeys
== null) {
808 IContributionItem item
= shortKeys
.find(id
);
809 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
810 IAction action
= ((ActionContributionItem
) item
).getAction();
811 if (action
!= null) {
812 action
.setEnabled(value
);
818 * Set the frame from an other thread than the one executing the main loop
820 * @param frame The frame to set (and display)
822 public void setFrameSync(final Frame frame
) {
823 if (getSDWidget() == null || getSDWidget().isDisposed()) {
826 getSDWidget().getDisplay().syncExec(new Runnable() {
829 if (getSDWidget() == null || getSDWidget().isDisposed() ||
830 ((fTimeCompressionBar
!= null) && fTimeCompressionBar
.isDisposed())) {
840 * Ensure an object is visible from an other thread than the one executing the main loop
842 * @param sm The node to make visible in view
844 public void ensureVisibleSync(final GraphNode sm
) {
845 getSDWidget().getDisplay().syncExec(new Runnable() {
848 if (getSDWidget() == null || getSDWidget().isDisposed()) {
851 getSDWidget().ensureVisible(sm
);
857 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
859 * @param sm The node to make visible in view
860 * @param frame Frame The frame to set
862 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
863 if (getSDWidget() == null || getSDWidget().isDisposed()) {
866 getSDWidget().getDisplay().syncExec(new Runnable() {
869 if (getSDWidget() == null || getSDWidget().isDisposed()) {
872 setFrameAndEnsureVisible(frame
, sm
);
878 * Set the frame and ensure an object is visible
880 * @param sm The node to make visible in view
881 * @param frame Frame The frame to set
883 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
884 getSDWidget().clearSelection();
885 setFrame(frame
, false);
886 getSDWidget().ensureVisible(sm
);
890 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
892 * @param frame The frame to set.
893 * @param x The x coordinate to make visible.
894 * @param y The y coordinate to make visible.
896 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
897 if (getSDWidget() == null || getSDWidget().isDisposed()) {
901 getSDWidget().getDisplay().syncExec(new Runnable() {
904 setFrameAndEnsureVisible(frame
, x
, y
);
910 * Set the frame and ensure an object is visible
912 * @param frame The frame to set.
913 * @param x The x coordinate to make visible.
914 * @param y The y coordinate to make visible.
916 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
917 getSDWidget().clearSelection();
918 setFrame(frame
, false);
919 getSDWidget().ensureVisible(x
, y
);
920 getSDWidget().redraw();
924 * Toggle between default and wait cursors from an other thread than the one executing the main loop
926 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
928 public void toggleWaitCursorAsync(final boolean wait
) {
929 if (getSDWidget() == null || getSDWidget().isDisposed()) {
933 getSDWidget().getDisplay().asyncExec(new Runnable() {
936 if (getSDWidget() == null || getSDWidget().isDisposed()) {
940 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
941 fWaitCursor
.dispose();
943 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
944 getSDWidget().setCursor(fWaitCursor
);
945 getSDWidget().getDisplay().update();
947 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
948 fWaitCursor
.dispose();
951 getSDWidget().setCursor(null);
952 getSDWidget().getDisplay().update();
959 * Return the time compression bar widget
961 * @return the time compression bar
963 public TimeCompressionBar
getTimeCompressionBar() {
964 return fTimeCompressionBar
;
968 * Returns the current Frame (the sequence diagram container)
970 * @return the current frame
972 public Frame
getFrame() {
973 if (getSDWidget() != null) {
974 return getSDWidget().getFrame();
980 * Restores the loader for the view based on the view ID.
982 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
984 protected boolean restoreLoader() {
985 String id
= getViewSite().getId();
986 // System.err.println("restoreLoader() id="+id);
990 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
991 // System.err.println("restoreLoader() l="+l);
992 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
993 loader
.setViewer(this);
1001 * Checks if current view is ready to be used.
1003 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1005 protected boolean isViewReady() {
1006 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1011 IViewReference
[] ref
= page
.getViewReferences();
1012 for (int i
= 0; i
< ref
.length
; i
++) {
1013 if (ref
[i
].getView(false) == this) {
1021 * Creates the menu group.
1023 protected void createMenuGroup() {
1024 IActionBars bar
= getViewSite().getActionBars();
1028 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1029 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1030 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1031 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1032 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1033 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1034 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1035 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1036 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1037 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1038 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1039 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1040 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1041 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1042 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1043 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1047 public Object
getAdapter(Class adapter
) {
1048 Object obj
= super.getAdapter(adapter
);
1049 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1050 return fSdPropertiesProvider
.getPropertySheetEntry();
1057 * Loader for a blank sequence diagram.
1061 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1063 public void setViewer(SDView viewer
) {
1065 Frame f
= new Frame();
1066 f
.setName(""); //$NON-NLS-1$
1071 public String
getTitleString() {
1072 return ""; //$NON-NLS-1$
1076 public void dispose() {