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
.Messages
;
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 * Name of menu separator for view modes
95 public final static String UML2SD_VIEW_MODES_SEPARATOR
= "UML2SD_VIEW_MODES"; //$NON-NLS-1$
97 * Name of menu separator for working set
100 public final static String UML2SD_WORKING_SET_SEPARATOR
= "UML2SD_WORKING_SET"; //$NON-NLS-1$
102 * Name of menu separator for sorting
105 public final static String UML2SD_SORTING_SEPARATOR
= "UML2SD_SORTING"; //$NON-NLS-1$
107 * Name of menu separator for filtering
110 public final static String UML2SD_FILTERING_SEPARATOR
= "UML2SD_FILTERING"; //$NON-NLS-1$
112 * Name of menu separator for view layout
115 public final static String UML2SD_VIEW_LAYOUT_SEPARATOR
= "UML2SD_VIEW_LAYOUT"; //$NON-NLS-1$
117 * Name of menu separator for link editor
120 public final static String UML2SD_LINK_EDITOR_SEPARATOR
= "UML2SD_LINK_EDITOR"; //$NON-NLS-1$
122 * Name of menu separator for other commands
125 public final static String UML2SD_OTHER_COMMANDS_SEPARATOR
= "UML2SD_OTHER_COMMANDS"; //$NON-NLS-1$
127 * Name of menu separator for other plug-in commands
130 public final static String UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR
= "UML2SD_OTHER_PLUGINS_COMMANDS"; //$NON-NLS-1$
132 // ------------------------------------------------------------------------
134 // ------------------------------------------------------------------------
136 * The sequence diagram widget.
138 private SDWidget fSdWidget
= null;
140 * The time compression bar.
142 private TimeCompressionBar fTimeCompressionBar
= null;
144 * The sequence diagram find provider implementation.
146 private ISDFindProvider fSdFindProvider
= null;
148 * The sequence diagram paging provider implementation.
150 private ISDPagingProvider fSdPagingProvider
= null;
152 * The sequence diagram filter provider implementation.
154 private ISDFilterProvider fSdFilterProvider
= null;
156 * The extended sequence diagram filter provider implementation.
158 private IExtendedFilterProvider fSdExFilterProvider
= null;
160 * The extended sequence diagram find provider implementation.
162 private IExtendedFindProvider fSdExFindProvider
= null;
164 * The extended sequence diagram action bar provider implementation.
166 private ISDExtendedActionBarProvider fSdExtendedActionBarProvider
= null;
168 * The sequence diagram property provider implementation.
170 private ISDPropertiesProvider fSdPropertiesProvider
= null;
172 * Button for executing the next page action.
174 private NextPage fNextPageButton
= null;
176 * Button for executing the previous page action.
178 private PrevPage fPrevPageButton
= null;
180 * Button for executing the first page page action.
182 private FirstPage fFirstPageButton
= null;
184 * Button for executing the last page action.
186 private LastPage fLastPageButton
= null;
188 * The menu manager reference.
190 private MenuManager fMenuMgr
= null;
192 * Flag to indicate whether view needs initialization or not.
194 private boolean fNeedInit
= true;
196 * WaitCursor is the cursor to be displayed when long tasks are running
198 private Cursor fWaitCursor
;
200 // ------------------------------------------------------------------------
202 // ------------------------------------------------------------------------
205 public void createPartControl(Composite c
) {
206 Composite parent
= new Composite(c
, SWT
.NONE
);
207 GridLayout parentLayout
= new GridLayout();
208 parentLayout
.numColumns
= 2;
209 parentLayout
.marginWidth
= 0;
210 parentLayout
.marginHeight
= 0;
211 parent
.setLayout(parentLayout
);
213 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
214 timeLayoutdata
.widthHint
= 10;
215 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
216 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
217 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
218 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);
219 fSdWidget
.setLayoutData(seqDiagLayoutData
);
220 fSdWidget
.setSite(this);
221 fSdWidget
.setTimeBar(fTimeCompressionBar
);
223 // Add this view to the key bindings manager
224 KeyBindingsManager
.getInstance().add(this.getSite().getId());
226 createCoolbarContent();
230 fTimeCompressionBar
.setVisible(false);
233 Print print
= new Print(this);
234 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
236 fNeedInit
= restoreLoader();
240 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
242 protected void loadBlank() {
243 IUml2SDLoader loader
= new BlankUml2SdLoader();
244 loader
.setViewer(this);
245 setContentDescription(loader
.getTitleString());
249 public void setFocus() {
250 if (fSdWidget
!= null) {
251 // update actions for key bindings
252 KeyBindingsManager
.getInstance().setSdView(this);
253 fSdWidget
.setFocus();
255 if (isViewReady() && fNeedInit
) {
256 fNeedInit
= restoreLoader();
261 public void dispose() {
262 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
267 * Returns the SD widget.
269 * @return The SD widget.
271 public SDWidget
getSDWidget() {
276 * Set the find provider for the opened sequence diagram viewer<br>
277 * If the provider is not set, the find menu item will not be available in the viewer<br>
278 * A find provider is called back when the user perform a find action<br>
279 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
280 * find criteria as well as to highlight the GraphNode
282 * @param provider the search provider
284 public void setSDFindProvider(ISDFindProvider provider
) {
285 fSdFindProvider
= provider
;
286 fSdExFindProvider
= null;
287 createCoolbarContent();
288 if (provider
!= null) {
289 KeyBindingsManager
.getInstance().setFindEnabled(true);
292 KeyBindingsManager
.getInstance().setFindEnabled(false);
297 * Set the find provider for the opened sequence diagram viewer<br>
298 * If the provider is not set, the find menu item will not be available in
300 * A find provider is called back when the user perform a find action<br>
301 * If the extended find provider is set, it replaces the regular find
302 * provider (sdFindProvider).<br>
305 * The provider to set
307 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
308 fSdExFindProvider
= provider
;
309 fSdFindProvider
= null;
310 createCoolbarContent();
311 if (provider
!= null) {
312 KeyBindingsManager
.getInstance().setFindEnabled(true);
315 KeyBindingsManager
.getInstance().setFindEnabled(false);
320 * Returns the extended find provider
322 * @return extended find provider.
324 public IExtendedFindProvider
getExtendedFindProvider() {
325 return fSdExFindProvider
;
329 * Resets all providers.
331 public void resetProviders() {
332 KeyBindingsManager
.getInstance().setFindEnabled(false);
333 fSdFindProvider
= null;
334 fSdExFindProvider
= null;
335 fSdFilterProvider
= null;
336 fSdExFilterProvider
= null;
337 fSdPagingProvider
= null;
338 fSdExtendedActionBarProvider
= null;
339 fSdPropertiesProvider
= null;
340 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
341 fSdWidget
.setCollapseProvider(null);
346 * Set the filter provider for the opened sequence diagram viewer<br>
347 * If the provider is not set, the filter menu item will not be available in the viewer<br>
348 * A filter provider is called back when the user perform a filter action<br>
350 * @param provider the filter provider
352 public void setSDFilterProvider(ISDFilterProvider provider
) {
353 fSdFilterProvider
= provider
;
354 // Both systems can be used now, commenting out next statement
355 createCoolbarContent();
359 * Sets the extended filter provider for the opened sequence diagram viewer.
362 * The provider to set
364 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
365 fSdExFilterProvider
= provider
;
366 // Both systems can be used now, commenting out next statement
367 createCoolbarContent();
371 * Returns the extended find provider.
373 * @return The extended find provider.
375 public IExtendedFilterProvider
getExtendedFilterProvider() {
376 return fSdExFilterProvider
;
380 * Register the given provider to support Drag and Drop collapsing. This provider is
381 * responsible of updating the Frame.
383 * @param provider - the provider to register
385 public void setCollapsingProvider(ISDCollapseProvider provider
) {
386 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
387 fSdWidget
.setCollapseProvider(provider
);
392 * Set the page provider for the opened sequence diagram viewer<br>
393 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
394 * provided in order to handle page change requested by the user<br>
395 * Set a page provider will create the next and previous page buttons in the viewer coolBar
397 * @param provider the paging provider
399 public void setSDPagingProvider(ISDPagingProvider provider
) {
400 fSdPagingProvider
= provider
;
401 createCoolbarContent();
405 * Returns the current page provider for the view
407 * @return the paging provider
409 public ISDPagingProvider
getSDPagingProvider() {
410 return fSdPagingProvider
;
414 * Returns the current find provider for the view
416 * @return the find provider
418 public ISDFindProvider
getSDFindProvider() {
419 return fSdFindProvider
;
423 * Returns the current filter provider for the view
425 * @return the filter provider
427 public ISDFilterProvider
getSDFilterProvider() {
428 return fSdFilterProvider
;
432 * Set the extended action bar provider for the opened sequence diagram viewer<br>
433 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
435 * @param provider the search provider
437 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
438 fSdExtendedActionBarProvider
= provider
;
439 createCoolbarContent();
443 * Returns the current extended action bar provider for the view
445 * @return the extended action bar provider
447 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
448 return fSdExtendedActionBarProvider
;
452 * Set the properties view provider for the opened sequence diagram viewer
454 * @param provider the properties provider
456 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
457 fSdPropertiesProvider
= provider
;
461 * Returns the current extended action bar provider for the view.
463 * @return the extended action bar provider
465 public ISDPropertiesProvider
getSDPropertiesProvider() {
466 return fSdPropertiesProvider
;
476 protected void setSDWidget(SDWidget sdWidget
) {
477 fSdWidget
= sdWidget
;
481 * Sets the time compression bar.
483 * @param timeCompressionbar
487 protected void setTimeBar(TimeCompressionBar timeCompressionbar
) {
488 fTimeCompressionBar
= timeCompressionbar
;
492 * Sets the initialization flag.
498 protected void setNeedInit(boolean needInit
) {
499 fNeedInit
= needInit
;
503 * Creates the basic sequence diagram menu
505 protected void hookContextMenu() {
506 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
507 fMenuMgr
.setRemoveAllWhenShown(true);
508 fMenuMgr
.addMenuListener(new IMenuListener() {
510 public void menuAboutToShow(IMenuManager manager
) {
511 fillContextMenu(manager
);
514 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
515 fSdWidget
.getViewControl().setMenu(menu
);
516 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
520 * Returns the context menu manager
522 * @return the menu manager
524 public MenuManager
getMenuManager() {
529 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
531 * @param manager the menu manager
533 protected void fillContextMenu(IMenuManager manager
) {
534 manager
.add(new Separator("Additions")); //$NON-NLS-1$
535 if (getSDWidget() != null && getSDWidget().getCurrentGraphNode() != null) {
536 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
537 ISelection sel
= selProvider
.getSelection();
539 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
540 while (it
.hasNext()) {
541 Object node
= it
.next();
542 if (node
instanceof BaseMessage
) {
546 if (nbMessage
!= 1) {
549 GraphNode node
= getSDWidget().getCurrentGraphNode();
550 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
551 Action goToMessage
= new MoveToMessage(this);
552 goToMessage
.setText(Messages
.SequenceDiagram_GoToMessage
);
553 manager
.add(goToMessage
);
555 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
556 Action goToMessage
= new MoveToMessage(this);
557 goToMessage
.setText(Messages
.SequenceDiagram_GoToMessageReturn
);
558 manager
.add(goToMessage
);
561 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
565 * Enables/Disables an action with given name.
567 * @param actionName The action name
568 * @param state true or false
570 public void setEnableAction(String actionName
, boolean state
) {
571 IActionBars bar
= getViewSite().getActionBars();
573 IContributionItem item
= bar
.getMenuManager().find(actionName
);
574 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
575 IAction action
= ((ActionContributionItem
) item
).getAction();
576 if (action
!= null) {
577 action
.setEnabled(state
);
579 item
.setVisible(state
);
580 bar
.updateActionBars();
586 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
587 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
588 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
590 * @see ISDGraphNodeSupporter Action support definition
591 * @see SDView#setSDFilterProvider(ISDFilterProvider)
592 * @see SDView#setSDFindProvider(ISDFindProvider)
593 * @see SDView#setSDPagingProvider(ISDPagingProvider)
595 protected void createCoolbarContent() {
596 IActionBars bar
= getViewSite().getActionBars();
598 bar
.getMenuManager().removeAll();
599 bar
.getToolBarManager().removeAll();
603 Zoom resetZoom
= new Zoom(this, ZoomType
.ZOOM_RESET
);
604 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, resetZoom
);
605 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, resetZoom
);
607 Zoom noZoom
= new Zoom(this, ZoomType
.ZOOM_NONE
);
608 noZoom
.setChecked(true);
609 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, noZoom
);
610 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, noZoom
);
612 Zoom zoomIn
= new Zoom(this, ZoomType
.ZOOM_IN
);
613 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, zoomIn
);
614 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, zoomIn
);
616 Zoom zoomOut
= new Zoom(this, ZoomType
.ZOOM_OUT
);
617 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, zoomOut
);
618 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, zoomOut
);
620 MenuManager navigation
= new MenuManager(Messages
.SequenceDiagram_Navigation
);
622 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
623 showNodeStart
.setText(Messages
.SequenceDiagram_ShowNodeStart
);
625 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
626 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
627 navigation
.add(showNodeStart
);
629 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
630 showNodeEnd
.setText(Messages
.SequenceDiagram_ShowNodeEnd
);
632 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
633 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
634 navigation
.add(showNodeEnd
);
636 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, navigation
);
638 ConfigureMinMax minMax
= new ConfigureMinMax(this);
639 minMax
.setText(Messages
.SequenceDiagram_ConfigureMinMax
);
640 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
641 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, minMax
);
643 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
644 minMax
.setEnabled(true);
646 minMax
.setEnabled(false);
649 // Do we need to display a paging item
650 if (fSdPagingProvider
!= null) {
651 fNextPageButton
= new NextPage(this);
652 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNextPageButton
);
653 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
654 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNextPageButton
);
656 fPrevPageButton
= new PrevPage(this);
657 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fPrevPageButton
);
658 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
659 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fPrevPageButton
);
661 fFirstPageButton
= new FirstPage(this);
662 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fFirstPageButton
);
663 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
664 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fFirstPageButton
);
666 fLastPageButton
= new LastPage(this);
667 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fLastPageButton
);
668 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
669 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fLastPageButton
);
672 if (fSdExFilterProvider
!= null) {
673 Action action
= fSdExFilterProvider
.getFilterAction();
674 if (action
!= null) {
675 if (action
.getId() == null)
677 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
679 if (action
.getImageDescriptor() == null) {
680 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
682 if (action
.getText() == null || action
.getText().length() == 0) {
683 action
.setText(Messages
.SequenceDiagram_EditFilters
);
685 bar
.getMenuManager().prependToGroup(UML2SD_FILTERING_SEPARATOR
, action
);
686 bar
.getToolBarManager().prependToGroup(UML2SD_FILTERING_SEPARATOR
, action
);
689 // Both systems can be used now: commenting out else keyword
690 if (fSdFilterProvider
!= null) {
691 bar
.getMenuManager().appendToGroup(UML2SD_FILTERING_SEPARATOR
, new OpenSDFiltersDialog(this, fSdFilterProvider
));
693 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
694 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
695 if (sdPaging
!= null) {
696 bar
.getMenuManager().remove(sdPaging
);
699 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
));
700 updatePagesMenuItem(bar
);
703 if (fSdExFindProvider
!= null) {
704 Action action
= fSdExFindProvider
.getFindAction();
705 if (action
!= null) {
706 if (action
.getId() == null) {
707 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
709 if (action
.getImageDescriptor() == null) {
710 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
712 if (action
.getText() == null) {
713 action
.setText(Messages
.SequenceDiagram_Find
+ "..."); //$NON-NLS-1$
715 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, action
);
716 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, action
);
718 } else if (fSdFindProvider
!= null) {
719 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDFindDialog(this));
720 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDFindDialog(this));
723 if (fSdExtendedActionBarProvider
!= null) {
724 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
727 bar
.updateActionBars();
731 * Updates the view coolbar buttons state according to the value return by: -
732 * ISDExtendedActionBarProvider.hasNextPage()<br>
733 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
736 public void updateCoolBar() {
737 if (fSdPagingProvider
!= null) {
738 IActionBars bar
= getViewSite().getActionBars();
742 IToolBarManager barManager
= bar
.getToolBarManager();
743 if (barManager
== null) {
746 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
747 if (nextPage
instanceof ActionContributionItem
) {
748 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
749 if (nextPageAction
instanceof NextPage
) {
750 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
754 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
755 if (prevPage
instanceof ActionContributionItem
) {
756 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
757 if (prevPageAction
instanceof PrevPage
) {
758 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
762 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
763 if (firstPage
instanceof ActionContributionItem
) {
764 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
765 if (firstPageAction
instanceof FirstPage
) {
766 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
770 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
771 if (lastPage
instanceof ActionContributionItem
) {
772 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
773 if (lastPageAction
instanceof LastPage
) {
774 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
778 updatePagesMenuItem(bar
);
783 * Enables or disables the Pages... menu item, depending on the number of pages
785 * @param bar the bar containing the action
787 protected void updatePagesMenuItem(IActionBars bar
) {
788 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
789 IMenuManager menuManager
= bar
.getMenuManager();
790 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
791 IAction openSDPagesDialog
= null;
792 if (contributionItem
!= null) {
793 openSDPagesDialog
= contributionItem
.getAction();
796 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
797 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
803 * The frame to render (the sequence diagram)
805 * @param frame the frame to display
807 public void setFrame(Frame frame
) {
808 setFrame(frame
, true);
812 * The frame to render (the sequence diagram)
814 * @param frame the frame to display
815 * @param resetPosition boolean Flag whether to reset the position or not.
817 protected void setFrame(Frame frame
, boolean resetPosition
) {
818 if (getSDWidget() == null) {
827 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
828 if (loader
== null) {
832 if (loader
.getTitleString() != null) {
833 setContentDescription(loader
.getTitleString());
836 getSDWidget().setFrame(frame
, resetPosition
);
838 if (fTimeCompressionBar
!= null) {
839 fTimeCompressionBar
.setFrame(frame
);
842 if (fTimeCompressionBar
!= null) {
843 if (!frame
.hasTimeInfo()) {
844 Composite parent
= fTimeCompressionBar
.getParent();
845 fTimeCompressionBar
.setVisible(false);
848 Composite parent
= fTimeCompressionBar
.getParent();
849 fTimeCompressionBar
.setVisible(true);
853 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
854 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
855 if (shortKeys
!= null) {
856 IContributionItem
[] items
= shortKeys
.getItems();
857 for (int i
= 0; i
< items
.length
; i
++) {
858 if (items
[i
] instanceof ActionContributionItem
) {
859 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
860 if (action
!= null) {
861 action
.setEnabled(true);
866 createCoolbarContent();
870 * Activate or deactivate the short key command given in parameter (see plugin.xml)
872 * @param id the command id defined in the plugin.xml
873 * @param value the state value
875 public void setEnableCommand(String id
, boolean value
) {
876 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
877 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
878 if (shortKeys
== null) {
881 IContributionItem item
= shortKeys
.find(id
);
882 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
883 IAction action
= ((ActionContributionItem
) item
).getAction();
884 if (action
!= null) {
885 action
.setEnabled(value
);
891 * Set the frame from an other thread than the one executing the main loop
893 * @param frame The frame to set (and display)
895 public void setFrameSync(final Frame frame
) {
896 if (getSDWidget() == null || getSDWidget().isDisposed()) {
899 getSDWidget().getDisplay().syncExec(new Runnable() {
902 if (getSDWidget() == null || getSDWidget().isDisposed() ||
903 ((fTimeCompressionBar
!= null) && fTimeCompressionBar
.isDisposed())) {
913 * Ensure an object is visible from an other thread than the one executing the main loop
915 * @param sm The node to make visible in view
917 public void ensureVisibleSync(final GraphNode sm
) {
918 getSDWidget().getDisplay().syncExec(new Runnable() {
921 if (getSDWidget() == null || getSDWidget().isDisposed()) {
924 getSDWidget().ensureVisible(sm
);
930 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
932 * @param sm The node to make visible in view
933 * @param frame Frame The frame to set
935 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
936 if (getSDWidget() == null || getSDWidget().isDisposed()) {
939 getSDWidget().getDisplay().syncExec(new Runnable() {
942 if (getSDWidget() == null || getSDWidget().isDisposed()) {
945 setFrameAndEnsureVisible(frame
, sm
);
951 * Set the frame and ensure an object is visible
953 * @param sm The node to make visible in view
954 * @param frame Frame The frame to set
956 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
957 getSDWidget().clearSelection();
958 setFrame(frame
, false);
959 getSDWidget().ensureVisible(sm
);
963 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
965 * @param frame The frame to set.
966 * @param x The x coordinate to make visible.
967 * @param y The y coordinate to make visible.
969 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
970 if (getSDWidget() == null || getSDWidget().isDisposed()) {
974 getSDWidget().getDisplay().syncExec(new Runnable() {
977 setFrameAndEnsureVisible(frame
, x
, y
);
983 * Set the frame and ensure an object is visible
985 * @param frame The frame to set.
986 * @param x The x coordinate to make visible.
987 * @param y The y coordinate to make visible.
989 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
990 getSDWidget().clearSelection();
991 setFrame(frame
, false);
992 getSDWidget().ensureVisible(x
, y
);
993 getSDWidget().redraw();
997 * Toggle between default and wait cursors from an other thread than the one executing the main loop
999 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
1001 public void toggleWaitCursorAsync(final boolean wait
) {
1002 if (getSDWidget() == null || getSDWidget().isDisposed()) {
1006 getSDWidget().getDisplay().asyncExec(new Runnable() {
1009 if (getSDWidget() == null || getSDWidget().isDisposed()) {
1013 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
1014 fWaitCursor
.dispose();
1016 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
1017 getSDWidget().setCursor(fWaitCursor
);
1018 getSDWidget().getDisplay().update();
1020 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
1021 fWaitCursor
.dispose();
1024 getSDWidget().setCursor(null);
1025 getSDWidget().getDisplay().update();
1032 * Return the time compression bar widget
1034 * @return the time compression bar
1036 public TimeCompressionBar
getTimeCompressionBar() {
1037 return fTimeCompressionBar
;
1041 * Returns the current Frame (the sequence diagram container)
1043 * @return the current frame
1045 public Frame
getFrame() {
1046 if (getSDWidget() != null) {
1047 return getSDWidget().getFrame();
1053 * Gets the initialization flag.
1054 * @return the value of the initialization flag.
1057 private boolean isNeedInit() {
1062 * Restores the loader for the view based on the view ID.
1064 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
1066 protected boolean restoreLoader() {
1067 String id
= getViewSite().getId();
1071 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1072 if ((loader
!= null)) {
1073 loader
.setViewer(this);
1081 * Checks if current view is ready to be used.
1083 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1085 protected boolean isViewReady() {
1086 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1091 IViewReference
[] ref
= page
.getViewReferences();
1092 for (int i
= 0; i
< ref
.length
; i
++) {
1093 if (ref
[i
].getView(false) == this) {
1101 * Creates the menu group.
1103 protected void createMenuGroup() {
1104 IActionBars bar
= getViewSite().getActionBars();
1108 bar
.getToolBarManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR
));
1109 bar
.getToolBarManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR
));
1110 bar
.getToolBarManager().add(new Separator(UML2SD_SORTING_SEPARATOR
));
1111 bar
.getToolBarManager().add(new Separator(UML2SD_FILTERING_SEPARATOR
));
1112 bar
.getToolBarManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR
));
1113 bar
.getToolBarManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR
));
1114 bar
.getToolBarManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR
));
1115 bar
.getToolBarManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR
));
1116 bar
.getMenuManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR
));
1117 bar
.getMenuManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR
));
1118 bar
.getMenuManager().add(new Separator(UML2SD_SORTING_SEPARATOR
));
1119 bar
.getMenuManager().add(new Separator(UML2SD_FILTERING_SEPARATOR
));
1120 bar
.getMenuManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR
));
1121 bar
.getMenuManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR
));
1122 bar
.getMenuManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR
));
1123 bar
.getMenuManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR
));
1127 public Object
getAdapter(Class adapter
) {
1128 Object obj
= super.getAdapter(adapter
);
1129 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1130 return fSdPropertiesProvider
.getPropertySheetEntry();
1137 * Loader for a blank sequence diagram.
1141 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1143 public void setViewer(SDView viewer
) {
1145 Frame f
= new Frame();
1146 f
.setName(""); //$NON-NLS-1$
1151 public String
getTitleString() {
1152 return ""; //$NON-NLS-1$
1156 public void dispose() {