1 /**********************************************************************
2 * Copyright (c) 2005, 2012 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 // ------------------------------------------------------------------------
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
268 * A find provider is called back when the user perform a find action<br>
269 * If the extended find provider is set, it replaces the regular find
270 * provider (sdFindProvider).<br>
273 * The provider to set
275 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
276 fSdExFindProvider
= provider
;
277 fSdFindProvider
= null;
278 createCoolbarContent();
279 if (provider
!= null) {
280 KeyBindingsManager
.getInstance().setFindEnabled(true);
283 KeyBindingsManager
.getInstance().setFindEnabled(false);
288 * Returns the extended find provider
290 * @return extended find provider.
292 public IExtendedFindProvider
getExtendedFindProvider() {
293 return fSdExFindProvider
;
297 * Resets all providers.
299 public void resetProviders() {
300 KeyBindingsManager
.getInstance().setFindEnabled(false);
301 fSdFindProvider
= null;
302 fSdExFindProvider
= null;
303 fSdFilterProvider
= null;
304 fSdExFilterProvider
= null;
305 fSdPagingProvider
= null;
306 fSdExtendedActionBarProvider
= null;
307 fSdPropertiesProvider
= null;
308 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
309 fSdWidget
.setCollapseProvider(null);
314 * Set the filter provider for the opened sequence diagram viewer<br>
315 * If the provider is not set, the filter menu item will not be available in the viewer<br>
316 * A filter provider is called back when the user perform a filter action<br>
318 * @param provider the filter provider
320 public void setSDFilterProvider(ISDFilterProvider provider
) {
321 fSdFilterProvider
= provider
;
322 // Both systems can be used now, commenting out next statement
323 // sdExFilterProvider = null;
324 createCoolbarContent();
328 * Sets the extended filter provider for the opened sequence diagram viewer.
331 * The provider to set
333 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
334 fSdExFilterProvider
= provider
;
335 // Both systems can be used now, commenting out next statement
336 // sdFilterProvider = null;
337 createCoolbarContent();
341 * Returns the extended find provider.
343 * @return The extended find provider.
345 public IExtendedFilterProvider
getExtendedFilterProvider() {
346 return fSdExFilterProvider
;
350 * Register the given provider to support Drag and Drop collapsing. This provider is
351 * responsible of updating the Frame.
353 * @param provider - the provider to register
355 public void setCollapsingProvider(ISDCollapseProvider provider
) {
356 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
357 fSdWidget
.setCollapseProvider(provider
);
362 * Set the page provider for the opened sequence diagram viewer<br>
363 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
364 * provided in order to handle page change requested by the user<br>
365 * Set a page provider will create the next and previous page buttons in the viewer coolBar
367 * @param provider the paging provider
369 public void setSDPagingProvider(ISDPagingProvider provider
) {
370 fSdPagingProvider
= provider
;
371 createCoolbarContent();
375 * Returns the current page provider for the view
377 * @return the paging provider
379 public ISDPagingProvider
getSDPagingProvider() {
380 return fSdPagingProvider
;
384 * Returns the current find provider for the view
386 * @return the find provider
388 public ISDFindProvider
getSDFindProvider() {
389 return fSdFindProvider
;
393 * Returns the current filter provider for the view
395 * @return the filter provider
397 public ISDFilterProvider
getSDFilterProvider() {
398 return fSdFilterProvider
;
402 * Set the extended action bar provider for the opened sequence diagram viewer<br>
403 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
405 * @param provider the search provider
407 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
408 fSdExtendedActionBarProvider
= provider
;
409 createCoolbarContent();
413 * Returns the current extended action bar provider for the view
415 * @return the extended action bar provider
417 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
418 return fSdExtendedActionBarProvider
;
422 * Set the properties view provider for the opened sequence diagram viewer
424 * @param provider the properties provider
426 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
427 fSdPropertiesProvider
= provider
;
431 * Returns the current extended action bar provider for the view.
433 * @return the extended action bar provider
435 public ISDPropertiesProvider
getSDPropertiesProvider() {
436 return fSdPropertiesProvider
;
440 * Creates the basic sequence diagram menu
442 protected void hookContextMenu() {
443 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
444 fMenuMgr
.setRemoveAllWhenShown(true);
445 fMenuMgr
.addMenuListener(new IMenuListener() {
447 public void menuAboutToShow(IMenuManager manager
) {
448 fillContextMenu(manager
);
451 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
452 fSdWidget
.getViewControl().setMenu(menu
);
453 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
457 * Returns the context menu manager
459 * @return the menu manager
461 public MenuManager
getMenuManager() {
466 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
468 * @param manager the menu manager
470 protected void fillContextMenu(IMenuManager manager
) {
471 manager
.add(new Separator("Additions")); //$NON-NLS-1$
472 if (getSDWidget() != null && getSDWidget().fCurrentGraphNode
!= null) {
473 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
474 ISelection sel
= selProvider
.getSelection();
476 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
477 while (it
.hasNext()) {
478 Object node
= it
.next();
479 if (node
instanceof BaseMessage
) {
483 if (nbMessage
!= 1) {
486 GraphNode node
= getSDWidget().fCurrentGraphNode
;
487 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
488 Action goToMessage
= new MoveToMessage(this);
489 goToMessage
.setText(SDMessages
._39
);
490 manager
.add(goToMessage
);
492 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
493 Action goToMessage
= new MoveToMessage(this);
494 goToMessage
.setText(SDMessages
._40
);
495 manager
.add(goToMessage
);
498 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
502 * Enables/Disables an action with given name.
504 * @param actionName The action name
505 * @param state true or false
507 public void setEnableAction(String actionName
, boolean state
) {
508 IActionBars bar
= getViewSite().getActionBars();
510 IContributionItem item
= bar
.getMenuManager().find(actionName
);
511 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
512 IAction action
= ((ActionContributionItem
) item
).getAction();
513 if (action
!= null) {
514 action
.setEnabled(state
);
516 item
.setVisible(state
);
517 bar
.updateActionBars();
523 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
524 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
525 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
527 * @see ISDGraphNodeSupporter Action support definition
528 * @see SDView#setSDFilterProvider(ISDFilterProvider)
529 * @see SDView#setSDFindProvider(ISDFindProvider)
530 * @see SDView#setSDPagingProvider(ISDPagingProvider)
532 protected void createCoolbarContent() {
533 IActionBars bar
= getViewSite().getActionBars();
535 bar
.getMenuManager().removeAll();
536 bar
.getToolBarManager().removeAll();
540 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
541 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
);//$NON-NLS-1$
542 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom
); //$NON-NLS-1$
544 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
545 noZoom
.setChecked(true);
546 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
);//$NON-NLS-1$
547 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom
); //$NON-NLS-1$
549 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
550 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
);//$NON-NLS-1$
551 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn
); //$NON-NLS-1$
553 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
554 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
);//$NON-NLS-1$
555 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut
); //$NON-NLS-1$
557 MenuManager navigation
= new MenuManager(SDMessages
._77
);
559 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
560 showNodeStart
.setText(SDMessages
.uml_25
);
562 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
563 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
564 navigation
.add(showNodeStart
);
566 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
567 showNodeEnd
.setText(SDMessages
.uml_23
);
569 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
570 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
571 navigation
.add(showNodeEnd
);
573 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation
); //$NON-NLS-1$
575 ConfigureMinMax minMax
= new ConfigureMinMax(this);
576 minMax
.setText(SDMessages
.uml_45
);
577 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
578 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax
); //$NON-NLS-1$
580 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
581 minMax
.setEnabled(true);
583 minMax
.setEnabled(false);
586 // Do we need to display a paging item
587 if (fSdPagingProvider
!= null) {
588 fNextPageButton
= new NextPage(this);
589 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
590 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
591 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton
); //$NON-NLS-1$
593 fPrevPageButton
= new PrevPage(this);
594 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
595 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
596 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton
); //$NON-NLS-1$
598 fFirstPageButton
= new FirstPage(this);
599 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
600 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
601 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton
); //$NON-NLS-1$
603 fLastPageButton
= new LastPage(this);
604 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
605 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
606 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton
); //$NON-NLS-1$
609 if (fSdExFilterProvider
!= null) {
610 Action action
= fSdExFilterProvider
.getFilterAction();
611 if (action
!= null) {
612 if (action
.getId() == null)
614 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
616 if (action
.getImageDescriptor() == null) {
617 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
619 if (action
.getText() == null || action
.getText().length() == 0) {
620 action
.setText(SDMessages
._42
);
622 bar
.getMenuManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
623 bar
.getToolBarManager().prependToGroup("UML2SD_FILTERING", action
); //$NON-NLS-1$
626 // Both systems can be used now: commenting out else keyword
627 /* else */if (fSdFilterProvider
!= null) {
628 bar
.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider
)); //$NON-NLS-1$
629 // No longer in the coolbar: commenting out next statement
630 //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider)); //$NON-NLS-1$
632 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
633 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
634 if (sdPaging
!= null) {
635 bar
.getMenuManager().remove(sdPaging
);
638 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
)); //$NON-NLS-1$
639 updatePagesMenuItem(bar
);
642 if (fSdExFindProvider
!= null) {
643 Action action
= fSdExFindProvider
.getFindAction();
644 if (action
!= null) {
645 if (action
.getId() == null) {
646 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
648 if (action
.getImageDescriptor() == null) {
649 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
651 if (action
.getText() == null) {
652 action
.setText(SDMessages
._41
);
654 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
655 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action
); //$NON-NLS-1$
657 } else if (fSdFindProvider
!= null) {
658 bar
.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
659 bar
.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
662 if (fSdExtendedActionBarProvider
!= null) {
663 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
666 bar
.updateActionBars();
670 * Updates the view coolbar buttons state according to the value return by: -
671 * ISDExtendedActionBarProvider.hasNextPage()<br>
672 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
675 public void updateCoolBar() {
676 if (fSdPagingProvider
!= null) {
677 IActionBars bar
= getViewSite().getActionBars();
681 IToolBarManager barManager
= bar
.getToolBarManager();
682 if (barManager
== null) {
685 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
686 if (nextPage
instanceof ActionContributionItem
) {
687 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
688 if (nextPageAction
instanceof NextPage
) {
689 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
693 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
694 if (prevPage
instanceof ActionContributionItem
) {
695 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
696 if (prevPageAction
instanceof PrevPage
) {
697 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
701 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
702 if (firstPage
instanceof ActionContributionItem
) {
703 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
704 if (firstPageAction
instanceof FirstPage
) {
705 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
709 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
710 if (lastPage
instanceof ActionContributionItem
) {
711 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
712 if (lastPageAction
instanceof LastPage
) {
713 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
717 updatePagesMenuItem(bar
);
722 * Enables or disables the Pages... menu item, depending on the number of pages
724 * @param bar the bar containing the action
726 protected void updatePagesMenuItem(IActionBars bar
) {
727 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
728 IMenuManager menuManager
= bar
.getMenuManager();
729 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
730 IAction openSDPagesDialog
= null;
731 if (contributionItem
!= null) {
732 openSDPagesDialog
= contributionItem
.getAction();
735 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
736 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
742 * The frame to render (the sequence diagram)
744 * @param frame the frame to display
746 public void setFrame(Frame frame
) {
747 setFrame(frame
, true);
751 * The frame to render (the sequence diagram)
753 * @param frame the frame to display
754 * @param resetPosition boolean Flag whether to reset the position or not.
756 protected void setFrame(Frame frame
, boolean resetPosition
) {
757 if (getSDWidget() == null) {
766 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
767 if (loader
== null) {
771 if (loader
.getTitleString() != null) {
772 setContentDescription(loader
.getTitleString());
775 getSDWidget().setFrame(frame
, resetPosition
);
777 if (fTimeCompressionBar
!= null) {
778 fTimeCompressionBar
.setFrame(frame
);
781 if (fTimeCompressionBar
!= null) {
782 if (!frame
.hasTimeInfo()) {
783 Composite parent
= fTimeCompressionBar
.getParent();
784 fTimeCompressionBar
.setVisible(false);
787 Composite parent
= fTimeCompressionBar
.getParent();
788 fTimeCompressionBar
.setVisible(true);
792 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
793 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
794 if (shortKeys
!= null) {
795 IContributionItem
[] items
= shortKeys
.getItems();
796 for (int i
= 0; i
< items
.length
; i
++) {
797 if (items
[i
] instanceof ActionContributionItem
) {
798 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
799 if (action
!= null) {
800 action
.setEnabled(true);
805 createCoolbarContent();
809 * Activate or deactivate the short key command given in parameter (see plugin.xml)
811 * @param id the command id defined in the plugin.xml
812 * @param value the state value
814 public void setEnableCommand(String id
, boolean value
) {
815 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
816 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
817 if (shortKeys
== null) {
820 IContributionItem item
= shortKeys
.find(id
);
821 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
822 IAction action
= ((ActionContributionItem
) item
).getAction();
823 if (action
!= null) {
824 action
.setEnabled(value
);
830 * Set the frame from an other thread than the one executing the main loop
832 * @param frame The frame to set (and display)
834 public void setFrameSync(final Frame frame
) {
835 if (getSDWidget() == null || getSDWidget().isDisposed()) {
838 getSDWidget().getDisplay().syncExec(new Runnable() {
841 if (getSDWidget() == null || getSDWidget().isDisposed() ||
842 ((fTimeCompressionBar
!= null) && fTimeCompressionBar
.isDisposed())) {
852 * Ensure an object is visible from an other thread than the one executing the main loop
854 * @param sm The node to make visible in view
856 public void ensureVisibleSync(final GraphNode sm
) {
857 getSDWidget().getDisplay().syncExec(new Runnable() {
860 if (getSDWidget() == null || getSDWidget().isDisposed()) {
863 getSDWidget().ensureVisible(sm
);
869 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
871 * @param sm The node to make visible in view
872 * @param frame Frame The frame to set
874 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
875 if (getSDWidget() == null || getSDWidget().isDisposed()) {
878 getSDWidget().getDisplay().syncExec(new Runnable() {
881 if (getSDWidget() == null || getSDWidget().isDisposed()) {
884 setFrameAndEnsureVisible(frame
, sm
);
890 * Set the frame and ensure an object is visible
892 * @param sm The node to make visible in view
893 * @param frame Frame The frame to set
895 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
896 getSDWidget().clearSelection();
897 setFrame(frame
, false);
898 getSDWidget().ensureVisible(sm
);
902 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
904 * @param frame The frame to set.
905 * @param x The x coordinate to make visible.
906 * @param y The y coordinate to make visible.
908 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
909 if (getSDWidget() == null || getSDWidget().isDisposed()) {
913 getSDWidget().getDisplay().syncExec(new Runnable() {
916 setFrameAndEnsureVisible(frame
, x
, y
);
922 * Set the frame and ensure an object is visible
924 * @param frame The frame to set.
925 * @param x The x coordinate to make visible.
926 * @param y The y coordinate to make visible.
928 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
929 getSDWidget().clearSelection();
930 setFrame(frame
, false);
931 getSDWidget().ensureVisible(x
, y
);
932 getSDWidget().redraw();
936 * Toggle between default and wait cursors from an other thread than the one executing the main loop
938 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
940 public void toggleWaitCursorAsync(final boolean wait
) {
941 if (getSDWidget() == null || getSDWidget().isDisposed()) {
945 getSDWidget().getDisplay().asyncExec(new Runnable() {
948 if (getSDWidget() == null || getSDWidget().isDisposed()) {
952 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
953 fWaitCursor
.dispose();
955 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
956 getSDWidget().setCursor(fWaitCursor
);
957 getSDWidget().getDisplay().update();
959 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
960 fWaitCursor
.dispose();
963 getSDWidget().setCursor(null);
964 getSDWidget().getDisplay().update();
971 * Return the time compression bar widget
973 * @return the time compression bar
975 public TimeCompressionBar
getTimeCompressionBar() {
976 return fTimeCompressionBar
;
980 * Returns the current Frame (the sequence diagram container)
982 * @return the current frame
984 public Frame
getFrame() {
985 if (getSDWidget() != null) {
986 return getSDWidget().getFrame();
992 * Restores the loader for the view based on the view ID.
994 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
996 protected boolean restoreLoader() {
997 String id
= getViewSite().getId();
998 // System.err.println("restoreLoader() id="+id);
1002 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1003 // System.err.println("restoreLoader() l="+l);
1004 if ((loader
!= null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
1005 loader
.setViewer(this);
1013 * Checks if current view is ready to be used.
1015 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1017 protected boolean isViewReady() {
1018 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1023 IViewReference
[] ref
= page
.getViewReferences();
1024 for (int i
= 0; i
< ref
.length
; i
++) {
1025 if (ref
[i
].getView(false) == this) {
1033 * Creates the menu group.
1035 protected void createMenuGroup() {
1036 IActionBars bar
= getViewSite().getActionBars();
1040 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1041 bar
.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1042 bar
.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1043 bar
.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1044 bar
.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1045 bar
.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1046 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1047 bar
.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1048 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
1049 bar
.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
1050 bar
.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
1051 bar
.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
1052 bar
.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
1053 bar
.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
1054 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
1055 bar
.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
1059 * Gets adapter for this view for properties.
1061 * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
1064 public Object
getAdapter(Class adapter
) {
1065 Object obj
= super.getAdapter(adapter
);
1066 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1067 return fSdPropertiesProvider
.getPropertySheetEntry();
1074 * Loader for a blank sequence diagram.
1078 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1081 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#setViewer(org.eclipse.linuxtools.tmf.ui.views.uml2sd.SDView)
1084 public void setViewer(SDView viewer
) {
1086 Frame f
= new Frame();
1087 f
.setName(""); //$NON-NLS-1$
1093 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#getTitleString()
1096 public String
getTitleString() {
1097 return ""; //$NON-NLS-1$
1102 * @see org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader#dispose()
1105 public void dispose() {