1 /**********************************************************************
2 * Copyright (c) 2005, 2008 IBM Corporation and others.
3 * Copyright (c) 2011, 2012 Ericsson.
5 * All rights reserved. This program and the accompanying materials
6 * are made available under the terms of the Eclipse Public License v1.0
7 * which accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
11 * IBM - Initial API and implementation
12 * Bernd Hufmann - Updated for TMF
13 **********************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
;
16 import java
.util
.Iterator
;
18 import org
.eclipse
.jface
.action
.Action
;
19 import org
.eclipse
.jface
.action
.ActionContributionItem
;
20 import org
.eclipse
.jface
.action
.IAction
;
21 import org
.eclipse
.jface
.action
.IContributionItem
;
22 import org
.eclipse
.jface
.action
.IMenuListener
;
23 import org
.eclipse
.jface
.action
.IMenuManager
;
24 import org
.eclipse
.jface
.action
.IToolBarManager
;
25 import org
.eclipse
.jface
.action
.MenuManager
;
26 import org
.eclipse
.jface
.action
.Separator
;
27 import org
.eclipse
.jface
.viewers
.ISelection
;
28 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
29 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
30 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.ITmfImageConstants
;
31 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.TmfUiPlugin
;
32 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.BaseMessage
;
33 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.Frame
;
34 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.GraphNode
;
35 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessage
;
36 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.core
.SyncMessageReturn
;
37 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ConfigureMinMax
;
38 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.FirstPage
;
39 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.KeyBindingsManager
;
40 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.LastPage
;
41 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.MoveToMessage
;
42 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.NextPage
;
43 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFiltersDialog
;
44 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDFindDialog
;
45 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.OpenSDPagesDialog
;
46 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.PrevPage
;
47 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Print
;
48 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeEnd
;
49 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.ShowNodeStart
;
50 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
;
51 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.Zoom
.ZoomType
;
52 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFilterProvider
;
53 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.IExtendedFindProvider
;
54 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDAdvancedPagingProvider
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDCollapseProvider
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDExtendedActionBarProvider
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFilterProvider
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDFindProvider
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPagingProvider
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.handlers
.provider
.ISDPropertiesProvider
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.IUml2SDLoader
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.load
.LoadersManager
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.uml2sd
.util
.SDMessages
;
64 import org
.eclipse
.swt
.SWT
;
65 import org
.eclipse
.swt
.graphics
.Cursor
;
66 import org
.eclipse
.swt
.layout
.GridData
;
67 import org
.eclipse
.swt
.layout
.GridLayout
;
68 import org
.eclipse
.swt
.widgets
.Composite
;
69 import org
.eclipse
.swt
.widgets
.Menu
;
70 import org
.eclipse
.ui
.IActionBars
;
71 import org
.eclipse
.ui
.IViewReference
;
72 import org
.eclipse
.ui
.IWorkbenchPage
;
73 import org
.eclipse
.ui
.PlatformUI
;
74 import org
.eclipse
.ui
.actions
.ActionFactory
;
75 import org
.eclipse
.ui
.part
.ViewPart
;
76 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
80 * This class is a generic sequence diagram view implementation.
86 public class SDView
extends ViewPart
{
88 // ------------------------------------------------------------------------
90 // ------------------------------------------------------------------------
92 * The sequence diagram widget.
94 protected SDWidget fSdWidget
= null;
96 * The time compression bar.
98 protected TimeCompressionBar fTimeCompressionBar
= null;
100 * The sequence diagram find provider implementation.
102 protected ISDFindProvider fSdFindProvider
= null;
104 * The sequence diagram paging provider implementation.
106 protected ISDPagingProvider fSdPagingProvider
= null;
108 * The sequence diagram filter provider implementation.
110 protected ISDFilterProvider fSdFilterProvider
= null;
112 * The extended sequence diagram filter provider implementation.
114 protected IExtendedFilterProvider fSdExFilterProvider
= null;
116 * The extended sequence diagram find provider implementation.
118 protected IExtendedFindProvider fSdExFindProvider
= null;
120 * The extended sequence diagram action bar provider implementation.
122 protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider
= null;
124 * The sequence diagram property provider implementation.
126 protected ISDPropertiesProvider fSdPropertiesProvider
= null;
128 * Button for executing the next page action.
130 protected NextPage fNextPageButton
= null;
132 * Button for executing the previous page action.
134 protected PrevPage fPrevPageButton
= null;
136 * Button for executing the first page page action.
138 protected FirstPage fFirstPageButton
= null;
140 * Button for executing the last page action.
142 protected LastPage fLastPageButton
= null;
144 * The menu manager reference.
146 protected MenuManager fMenuMgr
= null;
148 * Flag to indicate whether view needs initialization or not.
150 protected boolean fNeedInit
= true;
152 * WaitCursor is the cursor to be displayed when long tasks are running
154 protected Cursor fWaitCursor
;
156 // ------------------------------------------------------------------------
158 // ------------------------------------------------------------------------
162 * @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
165 public void createPartControl(Composite c
) {
166 Composite parent
= new Composite(c
, SWT
.NONE
);
167 GridLayout parentLayout
= new GridLayout();
168 parentLayout
.numColumns
= 2;
169 parentLayout
.marginWidth
= 0;
170 parentLayout
.marginHeight
= 0;
171 parent
.setLayout(parentLayout
);
173 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
174 timeLayoutdata
.widthHint
= 10;
175 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
176 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
177 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
178 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
179 fSdWidget
.setLayoutData(seqDiagLayoutData
);
180 fSdWidget
.setSite(this);
181 fSdWidget
.setTimeBar(fTimeCompressionBar
);
183 // Add this view to the key bindings manager
184 KeyBindingsManager
.getInstance().add(this.getSite().getId());
186 createCoolbarContent();
190 fTimeCompressionBar
.setVisible(false);
193 Print print
= new Print(this);
194 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
196 fNeedInit
= restoreLoader();
200 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
202 protected void loadBlank() {
203 IUml2SDLoader loader
= new BlankUml2SdLoader();
204 loader
.setViewer(this);
205 setContentDescription(loader
.getTitleString());
210 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
213 public void setFocus() {
214 if (fSdWidget
!= null) {
215 // update actions for key bindings
216 KeyBindingsManager
.getInstance().setSdView(this);
217 fSdWidget
.setFocus();
219 if (isViewReady() && fNeedInit
) {
220 fNeedInit
= restoreLoader();
226 * @see org.eclipse.ui.part.WorkbenchPart#dispose()
229 public void dispose() {
230 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
235 * Returns the SD widget.
237 * @return The SD widget.
239 public SDWidget
getSDWidget() {
244 * Set the find provider for the opened sequence diagram viewer<br>
245 * If the provider is not set, the find menu item will not be available in the viewer<br>
246 * A find provider is called back when the user perform a find action<br>
247 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
248 * find criteria as well as to highlight the GraphNode
250 * @param provider the search provider
252 public void setSDFindProvider(ISDFindProvider provider
) {
253 fSdFindProvider
= provider
;
254 fSdExFindProvider
= null;
255 createCoolbarContent();
256 if (provider
!= null) {
257 KeyBindingsManager
.getInstance().setFindEnabled(true);
260 KeyBindingsManager
.getInstance().setFindEnabled(false);
265 * Set the find provider for the opened sequence diagram viewer<br>
266 * If the provider is not set, the find menu item will not be available in the viewer<br>
267 * A find provider is called back when the user perform a find action<br>
268 * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
271 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
272 fSdExFindProvider
= provider
;
273 fSdFindProvider
= null;
274 createCoolbarContent();
275 if (provider
!= null) {
276 KeyBindingsManager
.getInstance().setFindEnabled(true);
279 KeyBindingsManager
.getInstance().setFindEnabled(false);
284 * Returns the extended find provider
286 * @return extended find provider.
288 public IExtendedFindProvider
getExtendedFindProvider() {
289 return fSdExFindProvider
;
293 * Resets all providers.
295 public void resetProviders() {
296 KeyBindingsManager
.getInstance().setFindEnabled(false);
297 fSdFindProvider
= null;
298 fSdExFindProvider
= null;
299 fSdFilterProvider
= null;
300 fSdExFilterProvider
= null;
301 fSdPagingProvider
= null;
302 fSdExtendedActionBarProvider
= null;
303 fSdPropertiesProvider
= null;
304 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
305 fSdWidget
.setCollapseProvider(null);
310 * Set the filter provider for the opened sequence diagram viewer<br>
311 * If the provider is not set, the filter menu item will not be available in the viewer<br>
312 * A filter provider is called back when the user perform a filter action<br>
314 * @param provider the filter provider
316 public void setSDFilterProvider(ISDFilterProvider provider
) {
317 fSdFilterProvider
= provider
;
318 // Both systems can be used now, commenting out next statement
319 // sdExFilterProvider = null;
320 createCoolbarContent();
324 * Sets the extended filter provider for the opend sequence diagram viewer.
327 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
328 fSdExFilterProvider
= provider
;
329 // Both systems can be used now, commenting out next statement
330 // sdFilterProvider = null;
331 createCoolbarContent();
335 * Returns the extended find provider.
337 * @return The extended find provider.
339 public IExtendedFilterProvider
getExtendedFilterProvider() {
340 return fSdExFilterProvider
;
344 * Register the given provider to support Drag and Drop collapsing. This provider is
345 * responsible of updating the Frame.
347 * @param provider - the provider to register
349 public void setCollapsingProvider(ISDCollapseProvider provider
) {
350 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
351 fSdWidget
.setCollapseProvider(provider
);
356 * Set the page provider for the opened sequence diagram viewer<br>
357 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
358 * provided in order to handle page change requested by the user<br>
359 * Set a page provider will create the next and previous page buttons in the viewer coolBar
361 * @param provider the paging provider
363 public void setSDPagingProvider(ISDPagingProvider provider
) {
364 fSdPagingProvider
= provider
;
365 createCoolbarContent();
369 * Returns the current page provider for the view
371 * @return the paging provider
373 public ISDPagingProvider
getSDPagingProvider() {
374 return fSdPagingProvider
;
378 * Returns the current find provider for the view
380 * @return the find provider
382 public ISDFindProvider
getSDFindProvider() {
383 return fSdFindProvider
;
387 * Returns the current filter provider for the view
389 * @return the filter provider
391 public ISDFilterProvider
getSDFilterProvider() {
392 return fSdFilterProvider
;
396 * Set the extended action bar provider for the opened sequence diagram viewer<br>
397 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
399 * @param provider the search provider
401 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
402 fSdExtendedActionBarProvider
= provider
;
403 createCoolbarContent();
407 * Returns the current extended action bar provider for the view
409 * @return the extended action bar provider
411 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
412 return fSdExtendedActionBarProvider
;
416 * Set the properties view provider for the opened sequence diagram viewer
418 * @param provider the properties provider
420 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
421 fSdPropertiesProvider
= provider
;
425 * Returns the current extended action bar provider for the view.
427 * @return the extended action bar provider
429 public ISDPropertiesProvider
getSDPropertiesProvider() {
430 return fSdPropertiesProvider
;
434 * Creates the basic sequence diagram menu
436 protected void hookContextMenu() {
437 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
438 fMenuMgr
.setRemoveAllWhenShown(true);
439 fMenuMgr
.addMenuListener(new IMenuListener() {
441 public void menuAboutToShow(IMenuManager manager
) {
442 fillContextMenu(manager
);
445 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
446 fSdWidget
.getViewControl().setMenu(menu
);
447 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
451 * Returns the context menu manager
453 * @return the menu manager
455 public MenuManager
getMenuManager() {
460 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
462 * @param manager the menu manager
464 protected void fillContextMenu(IMenuManager manager
) {
465 manager
.add(new Separator("Additions")); //$NON-NLS-1$
466 if (getSDWidget() != null && getSDWidget().fCurrentGraphNode
!= null) {
467 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
468 ISelection sel
= selProvider
.getSelection();
470 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
471 while (it
.hasNext()) {
472 Object node
= it
.next();
473 if (node
instanceof BaseMessage
) {
477 if (nbMessage
!= 1) {
480 GraphNode node
= getSDWidget().fCurrentGraphNode
;
481 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
482 Action goToMessage
= new MoveToMessage(this);
483 goToMessage
.setText(SDMessages
._39
);
484 manager
.add(goToMessage
);
486 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
487 Action goToMessage
= new MoveToMessage(this);
488 goToMessage
.setText(SDMessages
._40
);
489 manager
.add(goToMessage
);
492 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
496 * Enables/Disables an action with given name.
498 * @param actionName The action name
499 * @param state true or false
501 public void setEnableAction(String actionName
, boolean state
) {
502 IActionBars bar
= getViewSite().getActionBars();
504 IContributionItem item
= bar
.getMenuManager().find(actionName
);
505 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
506 IAction action
= ((ActionContributionItem
) item
).getAction();
507 if (action
!= null) {
508 action
.setEnabled(state
);
510 item
.setVisible(state
);
511 bar
.updateActionBars();
517 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
518 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
519 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
521 * @see ISDGraphNodeSupporter Action support definition
522 * @see SDView#setSDFilterProvider(ISDFilterProvider)
523 * @see SDView#setSDFindProvider(ISDFindProvider)
524 * @see SDView#setSDPagingProvider(ISDPagingProvider)
526 protected void createCoolbarContent() {
527 IActionBars bar
= getViewSite().getActionBars();
529 bar
.getMenuManager().removeAll();
530 bar
.getToolBarManager().removeAll();
534 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
535 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
536 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
538 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
539 noZoom
.setChecked(true);
540 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
541 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
543 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
544 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
545 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
547 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
548 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
549 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
551 MenuManager navigation
= new MenuManager(SDMessages
._77
);
553 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
554 showNodeStart
.setText(SDMessages
.uml_25
);
556 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
557 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
558 navigation
.add(showNodeStart
);
560 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
561 showNodeEnd
.setText(SDMessages
.uml_23
);
563 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
564 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
565 navigation
.add(showNodeEnd
);
567 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
569 ConfigureMinMax minMax
= new ConfigureMinMax(this);
570 minMax
.setText(SDMessages
.uml_45
);
571 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
572 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
574 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
575 minMax
.setEnabled(true);
577 minMax
.setEnabled(false);
580 // Do we need to display a paging item
581 if (fSdPagingProvider
!= null) {
582 fNextPageButton
= new NextPage(this);
583 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
584 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
585 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
587 fPrevPageButton
= new PrevPage(this);
588 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
589 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
590 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
592 fFirstPageButton
= new FirstPage(this);
593 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
594 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
595 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
597 fLastPageButton
= new LastPage(this);
598 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
599 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
600 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
603 if (fSdExFilterProvider
!= null) {
604 Action action
= fSdExFilterProvider
.getFilterAction();
605 if (action
!= null) {
606 if (action
.getId() == null)
607 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
608 if (action
.getImageDescriptor() == null)
609 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
610 if (action
.getText() == null || action
.getText().length() == 0)
611 action
.setText(SDMessages
._42
);
612 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
613 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
616 // Both systems can be used now: commenting out else keyword
617 /* else */if (fSdFilterProvider
!= null) {
618 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider
)); //$NON-NLS-1$
619 // No longer in the coolbar: commenting out next statement
620 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
622 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
623 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
624 if (sdPaging
!= null) {
625 bar
.getMenuManager().remove(sdPaging
);
628 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
)); //$NON-NLS-1$
629 updatePagesMenuItem(bar
);
632 if (fSdExFindProvider
!= null) {
633 Action action
= fSdExFindProvider
.getFindAction();
634 if (action
!= null) {
635 if (action
.getId() == null) {
636 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
638 if (action
.getImageDescriptor() == null) {
639 action
.setImageDescriptor(TmfUiPlugin
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
641 if (action
.getText() == null) {
642 action
.setText(SDMessages
._41
);
644 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
645 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
647 } else if (fSdFindProvider
!= null) {
648 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
649 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
652 if (fSdExtendedActionBarProvider
!= null) {
653 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
656 bar
.updateActionBars();
660 * Updates the view coolbar buttons state according to the value return by: -
661 * ISDExtendedActionBarProvider.hasNextPage()<br>
662 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
665 public void updateCoolBar() {
666 if (fSdPagingProvider
!= null) {
667 IActionBars bar
= getViewSite().getActionBars();
671 IToolBarManager barManager
= bar
.getToolBarManager();
672 if (barManager
== null) {
675 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
676 if (nextPage
instanceof ActionContributionItem
) {
677 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
678 if (nextPageAction
instanceof NextPage
) {
679 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
683 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
684 if (prevPage
instanceof ActionContributionItem
) {
685 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
686 if (prevPageAction
instanceof PrevPage
) {
687 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
691 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
692 if (firstPage
instanceof ActionContributionItem
) {
693 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
694 if (firstPageAction
instanceof FirstPage
) {
695 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
699 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
700 if (lastPage
instanceof ActionContributionItem
) {
701 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
702 if (lastPageAction
instanceof LastPage
) {
703 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
707 updatePagesMenuItem(bar
);
712 * Enables or disables the Pages... menu item, depending on the number of pages
714 * @param bar the bar containing the action
716 protected void updatePagesMenuItem(IActionBars bar
) {
717 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
718 IMenuManager menuManager
= bar
.getMenuManager();
719 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
720 IAction openSDPagesDialog
= null;
721 if (contributionItem
!= null) {
722 openSDPagesDialog
= contributionItem
.getAction();
725 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
726 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
732 * The frame to render (the sequence diagram)
734 * @param frame the frame to display
736 public void setFrame(Frame frame
) {
737 setFrame(frame
, true);
741 * The frame to render (the sequence diagram)
743 * @param frame the frame to display
744 * @param resetPosition boolean Flag whether to reset the position or not.
746 protected void setFrame(Frame frame
, boolean resetPosition
) {
747 if (fSdWidget
== null)
755 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
757 if ((loader
!= null) && (loader
.getTitleString() != null)) {
758 setContentDescription(loader
.getTitleString());
761 if (getSDWidget() != null) {
762 getSDWidget().setFrame(frame
, resetPosition
);
765 if (fTimeCompressionBar
!= null) {
766 fTimeCompressionBar
.setFrame(frame
);
769 if (!frame
.hasTimeInfo()) {
770 Composite parent
= fTimeCompressionBar
.getParent();
771 fTimeCompressionBar
.setVisible(false);
774 Composite parent
= fTimeCompressionBar
.getParent();
775 fTimeCompressionBar
.setVisible(true);
778 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
779 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
780 if (shortKeys
!= null) {
781 IContributionItem
[] items
= shortKeys
.getItems();
782 for (int i
= 0; i
< items
.length
; i
++) {
783 if (items
[i
] instanceof ActionContributionItem
) {
784 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
785 if (action
!= null) {
786 action
.setEnabled(true);
791 createCoolbarContent();
795 * Activate or deactivate the short key command given in parameter (see plugin.xml)
797 * @param id the command id defined in the plugin.xml
798 * @param value the state value
800 public void setEnableCommand(String id
, boolean value
) {
801 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
802 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
803 if (shortKeys
== null) {
806 IContributionItem item
= shortKeys
.find(id
);
807 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
808 IAction action
= ((ActionContributionItem
) item
).getAction();
809 if (action
!= null) {
810 action
.setEnabled(value
);
816 * Set the frame from an other thread than the one executing the main loop
818 * @param frame The frame to set (and display)
820 public void setFrameSync(final Frame frame
) {
821 if (getSDWidget() == null || getSDWidget().isDisposed()) {
824 getSDWidget().getDisplay().syncExec(new Runnable() {
827 if (getSDWidget() == null || getSDWidget().isDisposed()) {
837 * Ensure an object is visible from an other thread than the one executing the main loop
839 * @param sm The node to make visible in view
841 public void ensureVisibleSync(final GraphNode sm
) {
842 getSDWidget().getDisplay().syncExec(new Runnable() {
845 if (getSDWidget() == null || getSDWidget().isDisposed()) {
848 getSDWidget().ensureVisible(sm
);
854 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
856 * @param sm The node to make visible in view
857 * @param frame Frame The frame to set
859 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
860 if (getSDWidget() == null || getSDWidget().isDisposed()) {
863 getSDWidget().getDisplay().syncExec(new Runnable() {
866 if (getSDWidget() == null || getSDWidget().isDisposed()) {
869 setFrameAndEnsureVisible(frame
, sm
);
875 * Set the frame and ensure an object is visible
877 * @param sm The node to make visible in view
878 * @param frame Frame The frame to set
880 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
881 getSDWidget().clearSelection();
882 setFrame(frame
, false);
883 getSDWidget().ensureVisible(sm
);
887 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
889 * @param frame The frame to set.
890 * @param x The x coordinate to make visible.
891 * @param y The y coordinate to make visible.
893 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
894 if (getSDWidget() == null || getSDWidget().isDisposed()) {
898 getSDWidget().getDisplay().syncExec(new Runnable() {
901 setFrameAndEnsureVisible(frame
, x
, y
);
907 * Set the frame and ensure an object is visible
909 * @param frame The frame to set.
910 * @param x The x coordinate to make visible.
911 * @param y The y coordinate to make visible.
913 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
914 getSDWidget().clearSelection();
915 setFrame(frame
, false);
916 getSDWidget().ensureVisible(x
, y
);
917 getSDWidget().redraw();
921 * Toggle between default and wait cursors from an other thread than the one executing the main loop
923 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
925 public void toggleWaitCursorAsync(final boolean wait
) {
926 if (getSDWidget() == null || getSDWidget().isDisposed()) {
930 getSDWidget().getDisplay().asyncExec(new Runnable() {
933 if (getSDWidget() == null || getSDWidget().isDisposed()) {
937 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
938 fWaitCursor
.dispose();
940 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
941 getSDWidget().setCursor(fWaitCursor
);
942 getSDWidget().getDisplay().update();
944 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
945 fWaitCursor
.dispose();
948 getSDWidget().setCursor(null);
949 getSDWidget().getDisplay().update();
956 * Return the time compression bar widget
958 * @return the time compression bar
960 public TimeCompressionBar
getTimeCompressionBar() {
961 return fTimeCompressionBar
;
965 * Returns the current Frame (the sequence diagram container)
967 * @return the current frame
969 public Frame
getFrame() {
970 if (getSDWidget() != null) {
971 return getSDWidget().getFrame();
979 * Restores the loader for the view based on the view ID.
981 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
983 protected boolean restoreLoader() {
984 String id
= getViewSite().getId();
985 // System.err.println("restoreLoader() id="+id);
989 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
990 // System.err.println("restoreLoader() l="+l);
991 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
992 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 * Gets adapter for this view for properties.
1049 * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
1051 @SuppressWarnings("rawtypes")
1053 public Object
getAdapter(Class adapter
) {
1054 Object obj
= super.getAdapter(adapter
);
1055 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1056 return fSdPropertiesProvider
.getPropertySheetEntry();
1063 * Loader for a blank sequence diagram.
1067 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1070 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
1073 public void setViewer(SDView viewer
) {
1075 Frame f
= new Frame();
1076 f
.setName(""); //$NON-NLS-1$
1082 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
1085 public String
getTitleString() {
1086 return ""; //$NON-NLS-1$
1091 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
1094 public void dispose() {