1 /**********************************************************************
2 * Copyright (c) 2005, 2014 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 static final String UML2SD_VIEW_MODES_SEPARATOR
= "UML2SD_VIEW_MODES"; //$NON-NLS-1$
97 * Name of menu separator for working set
100 public static final String UML2SD_WORKING_SET_SEPARATOR
= "UML2SD_WORKING_SET"; //$NON-NLS-1$
102 * Name of menu separator for sorting
105 public static final String UML2SD_SORTING_SEPARATOR
= "UML2SD_SORTING"; //$NON-NLS-1$
107 * Name of menu separator for filtering
110 public static final String UML2SD_FILTERING_SEPARATOR
= "UML2SD_FILTERING"; //$NON-NLS-1$
112 * Name of menu separator for view layout
115 public static final String UML2SD_VIEW_LAYOUT_SEPARATOR
= "UML2SD_VIEW_LAYOUT"; //$NON-NLS-1$
117 * Name of menu separator for link editor
120 public static final String UML2SD_LINK_EDITOR_SEPARATOR
= "UML2SD_LINK_EDITOR"; //$NON-NLS-1$
122 * Name of menu separator for other commands
125 public static final String UML2SD_OTHER_COMMANDS_SEPARATOR
= "UML2SD_OTHER_COMMANDS"; //$NON-NLS-1$
127 * Name of menu separator for other plug-in commands
130 public static final 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 private Zoom fResetZoomAction
;
201 private Zoom fNoZoomAction
;
202 private Zoom fZoomInAction
;
203 private Zoom fZoomOutAction
;
205 // ------------------------------------------------------------------------
207 // ------------------------------------------------------------------------
210 public void createPartControl(Composite c
) {
211 Composite parent
= new Composite(c
, SWT
.NONE
);
212 GridLayout parentLayout
= new GridLayout();
213 parentLayout
.numColumns
= 2;
214 parentLayout
.marginWidth
= 0;
215 parentLayout
.marginHeight
= 0;
216 parent
.setLayout(parentLayout
);
218 GridData timeLayoutdata
= new GridData(GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
219 timeLayoutdata
.widthHint
= 10;
220 GridData seqDiagLayoutData
= new GridData(GridData
.HORIZONTAL_ALIGN_FILL
| GridData
.GRAB_HORIZONTAL
| GridData
.GRAB_VERTICAL
| GridData
.VERTICAL_ALIGN_FILL
);
221 fTimeCompressionBar
= new TimeCompressionBar(parent
, SWT
.NONE
);
222 fTimeCompressionBar
.setLayoutData(timeLayoutdata
);
223 fSdWidget
= new SDWidget(parent
, SWT
.NONE
);
224 fSdWidget
.setLayoutData(seqDiagLayoutData
);
225 fSdWidget
.setSite(this);
226 fSdWidget
.setTimeBar(fTimeCompressionBar
);
228 // Add this view to the key bindings manager
229 KeyBindingsManager
.getInstance().add(this.getSite().getId());
231 createCoolbarContent();
235 fTimeCompressionBar
.setVisible(false);
238 Print print
= new Print(this);
239 getViewSite().getActionBars().setGlobalActionHandler(ActionFactory
.PRINT
.getId(), print
);
241 fNeedInit
= restoreLoader();
245 * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
247 protected void loadBlank() {
248 IUml2SDLoader loader
= new BlankUml2SdLoader();
249 loader
.setViewer(this);
250 setContentDescription(loader
.getTitleString());
254 public void setFocus() {
255 if (fSdWidget
!= null) {
256 // update actions for key bindings
257 KeyBindingsManager
.getInstance().setSdView(this);
258 fSdWidget
.setFocus();
260 if (isViewReady() && fNeedInit
) {
261 fNeedInit
= restoreLoader();
266 public void dispose() {
267 KeyBindingsManager
.getInstance().remove(this.getSite().getId());
268 disposeZoomActions();
272 private void disposeZoomActions() {
273 if (fResetZoomAction
!= null) {
274 fResetZoomAction
.dispose();
276 if (fNoZoomAction
!= null) {
277 fNoZoomAction
.dispose();
279 if (fZoomInAction
!= null) {
280 fZoomInAction
.dispose();
282 if (fZoomOutAction
!= null) {
283 fZoomOutAction
.dispose();
288 * Returns the SD widget.
290 * @return The SD widget.
292 public SDWidget
getSDWidget() {
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 the viewer<br>
299 * A find provider is called back when the user perform a find action<br>
300 * The find provider is responsible to move the sequence diagram to the GraphNode which match the
301 * find criteria as well as to highlight the GraphNode
303 * @param provider the search provider
305 public void setSDFindProvider(ISDFindProvider provider
) {
306 fSdFindProvider
= provider
;
307 fSdExFindProvider
= null;
308 createCoolbarContent();
309 if (provider
!= null) {
310 KeyBindingsManager
.getInstance().setFindEnabled(true);
313 KeyBindingsManager
.getInstance().setFindEnabled(false);
318 * Set the find provider for the opened sequence diagram viewer<br>
319 * If the provider is not set, the find menu item will not be available in
321 * A find provider is called back when the user perform a find action<br>
322 * If the extended find provider is set, it replaces the regular find
323 * provider (sdFindProvider).<br>
326 * The provider to set
328 public void setExtendedFindProvider(IExtendedFindProvider provider
) {
329 fSdExFindProvider
= provider
;
330 fSdFindProvider
= null;
331 createCoolbarContent();
332 if (provider
!= null) {
333 KeyBindingsManager
.getInstance().setFindEnabled(true);
336 KeyBindingsManager
.getInstance().setFindEnabled(false);
341 * Returns the extended find provider
343 * @return extended find provider.
345 public IExtendedFindProvider
getExtendedFindProvider() {
346 return fSdExFindProvider
;
350 * Resets all providers.
352 public void resetProviders() {
353 KeyBindingsManager
.getInstance().setFindEnabled(false);
354 fSdFindProvider
= null;
355 fSdExFindProvider
= null;
356 fSdFilterProvider
= null;
357 fSdExFilterProvider
= null;
358 fSdPagingProvider
= null;
359 fSdExtendedActionBarProvider
= null;
360 fSdPropertiesProvider
= null;
361 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
362 fSdWidget
.setCollapseProvider(null);
367 * Set the filter provider for the opened sequence diagram viewer<br>
368 * If the provider is not set, the filter menu item will not be available in the viewer<br>
369 * A filter provider is called back when the user perform a filter action<br>
371 * @param provider the filter provider
373 public void setSDFilterProvider(ISDFilterProvider provider
) {
374 fSdFilterProvider
= provider
;
375 // Both systems can be used now, commenting out next statement
376 createCoolbarContent();
380 * Sets the extended filter provider for the opened sequence diagram viewer.
383 * The provider to set
385 public void setExtendedFilterProvider(IExtendedFilterProvider provider
) {
386 fSdExFilterProvider
= provider
;
387 // Both systems can be used now, commenting out next statement
388 createCoolbarContent();
392 * Returns the extended find provider.
394 * @return The extended find provider.
396 public IExtendedFilterProvider
getExtendedFilterProvider() {
397 return fSdExFilterProvider
;
401 * Register the given provider to support Drag and Drop collapsing. This provider is
402 * responsible of updating the Frame.
404 * @param provider - the provider to register
406 public void setCollapsingProvider(ISDCollapseProvider provider
) {
407 if ((fSdWidget
!= null) && (!fSdWidget
.isDisposed())) {
408 fSdWidget
.setCollapseProvider(provider
);
413 * Set the page provider for the opened sequence diagram viewer<br>
414 * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
415 * provided in order to handle page change requested by the user<br>
416 * Set a page provider will create the next and previous page buttons in the viewer coolBar
418 * @param provider the paging provider
420 public void setSDPagingProvider(ISDPagingProvider provider
) {
421 fSdPagingProvider
= provider
;
422 createCoolbarContent();
426 * Returns the current page provider for the view
428 * @return the paging provider
430 public ISDPagingProvider
getSDPagingProvider() {
431 return fSdPagingProvider
;
435 * Returns the current find provider for the view
437 * @return the find provider
439 public ISDFindProvider
getSDFindProvider() {
440 return fSdFindProvider
;
444 * Returns the current filter provider for the view
446 * @return the filter provider
448 public ISDFilterProvider
getSDFilterProvider() {
449 return fSdFilterProvider
;
453 * Set the extended action bar provider for the opened sequence diagram viewer<br>
454 * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
456 * @param provider the search provider
458 public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider
) {
459 fSdExtendedActionBarProvider
= provider
;
460 createCoolbarContent();
464 * Returns the current extended action bar provider for the view
466 * @return the extended action bar provider
468 public ISDExtendedActionBarProvider
getSDExtendedActionBarProvider() {
469 return fSdExtendedActionBarProvider
;
473 * Set the properties view provider for the opened sequence diagram viewer
475 * @param provider the properties provider
477 public void setSDPropertiesProvider(ISDPropertiesProvider provider
) {
478 fSdPropertiesProvider
= provider
;
482 * Returns the current extended action bar provider for the view.
484 * @return the extended action bar provider
486 public ISDPropertiesProvider
getSDPropertiesProvider() {
487 return fSdPropertiesProvider
;
497 protected void setSDWidget(SDWidget sdWidget
) {
498 fSdWidget
= sdWidget
;
502 * Sets the time compression bar.
504 * @param timeCompressionbar
508 protected void setTimeBar(TimeCompressionBar timeCompressionbar
) {
509 fTimeCompressionBar
= timeCompressionbar
;
513 * Sets the initialization flag.
519 protected void setNeedInit(boolean needInit
) {
520 fNeedInit
= needInit
;
524 * Creates the basic sequence diagram menu
526 protected void hookContextMenu() {
527 fMenuMgr
= new MenuManager("#PopupMenu"); //$NON-NLS-1$
528 fMenuMgr
.setRemoveAllWhenShown(true);
529 fMenuMgr
.addMenuListener(new IMenuListener() {
531 public void menuAboutToShow(IMenuManager manager
) {
532 fillContextMenu(manager
);
535 Menu menu
= fMenuMgr
.createContextMenu(fSdWidget
.getViewControl());
536 fSdWidget
.getViewControl().setMenu(menu
);
537 getSite().registerContextMenu(fMenuMgr
, fSdWidget
.getSelectionProvider());
541 * Returns the context menu manager
543 * @return the menu manager
545 public MenuManager
getMenuManager() {
550 * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
552 * @param manager the menu manager
554 protected void fillContextMenu(IMenuManager manager
) {
555 manager
.add(new Separator("Additions")); //$NON-NLS-1$
556 if (getSDWidget() != null && getSDWidget().getCurrentGraphNode() != null) {
557 ISelectionProvider selProvider
= fSdWidget
.getSelectionProvider();
558 ISelection sel
= selProvider
.getSelection();
560 Iterator
<?
> it
= ((StructuredSelection
) sel
).iterator();
561 while (it
.hasNext()) {
562 Object node
= it
.next();
563 if (node
instanceof BaseMessage
) {
567 if (nbMessage
!= 1) {
570 GraphNode node
= getSDWidget().getCurrentGraphNode();
571 if ((node
instanceof SyncMessageReturn
) && (((SyncMessageReturn
) node
).getMessage() != null)) {
572 Action goToMessage
= new MoveToMessage(this);
573 goToMessage
.setText(Messages
.SequenceDiagram_GoToMessage
);
574 manager
.add(goToMessage
);
576 if ((node
instanceof SyncMessage
) && (((SyncMessage
) node
).getMessageReturn() != null)) {
577 Action goToMessage
= new MoveToMessage(this);
578 goToMessage
.setText(Messages
.SequenceDiagram_GoToMessageReturn
);
579 manager
.add(goToMessage
);
582 manager
.add(new Separator("MultiSelectAdditions")); //$NON-NLS-1$
586 * Enables/Disables an action with given name.
588 * @param actionName The action name
589 * @param state true or false
591 public void setEnableAction(String actionName
, boolean state
) {
592 IActionBars bar
= getViewSite().getActionBars();
594 IContributionItem item
= bar
.getMenuManager().find(actionName
);
595 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
596 IAction action
= ((ActionContributionItem
) item
).getAction();
597 if (action
!= null) {
598 action
.setEnabled(state
);
600 item
.setVisible(state
);
601 bar
.updateActionBars();
607 * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
608 * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
609 * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
611 * @see ISDGraphNodeSupporter Action support definition
612 * @see SDView#setSDFilterProvider(ISDFilterProvider)
613 * @see SDView#setSDFindProvider(ISDFindProvider)
614 * @see SDView#setSDPagingProvider(ISDPagingProvider)
616 protected void createCoolbarContent() {
617 IActionBars bar
= getViewSite().getActionBars();
619 bar
.getMenuManager().removeAll();
620 bar
.getToolBarManager().removeAll();
621 disposeZoomActions();
625 fResetZoomAction
= new Zoom(this, ZoomType
.ZOOM_RESET
);
626 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fResetZoomAction
);
627 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fResetZoomAction
);
629 fNoZoomAction
= new Zoom(this, ZoomType
.ZOOM_NONE
);
630 fNoZoomAction
.setChecked(true);
631 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNoZoomAction
);
632 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNoZoomAction
);
634 fZoomInAction
= new Zoom(this, ZoomType
.ZOOM_IN
);
635 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fZoomInAction
);
636 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fZoomInAction
);
638 fZoomOutAction
= new Zoom(this, ZoomType
.ZOOM_OUT
);
639 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fZoomOutAction
);
640 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fZoomOutAction
);
642 MenuManager navigation
= new MenuManager(Messages
.SequenceDiagram_Navigation
);
644 ShowNodeStart showNodeStart
= new ShowNodeStart(this);
645 showNodeStart
.setText(Messages
.SequenceDiagram_ShowNodeStart
);
647 showNodeStart
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
648 showNodeStart
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeStart");//$NON-NLS-1$
649 navigation
.add(showNodeStart
);
651 ShowNodeEnd showNodeEnd
= new ShowNodeEnd(this);
652 showNodeEnd
.setText(Messages
.SequenceDiagram_ShowNodeEnd
);
654 showNodeEnd
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
655 showNodeEnd
.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
656 navigation
.add(showNodeEnd
);
658 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, navigation
);
660 ConfigureMinMax minMax
= new ConfigureMinMax(this);
661 minMax
.setText(Messages
.SequenceDiagram_ConfigureMinMax
);
662 minMax
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
663 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, minMax
);
665 if ((fSdWidget
.getFrame() != null) && (fSdWidget
.getFrame().hasTimeInfo())) {
666 minMax
.setEnabled(true);
668 minMax
.setEnabled(false);
671 // Do we need to display a paging item
672 if (fSdPagingProvider
!= null) {
673 fNextPageButton
= new NextPage(this);
674 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNextPageButton
);
675 fNextPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
676 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fNextPageButton
);
678 fPrevPageButton
= new PrevPage(this);
679 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fPrevPageButton
);
680 fPrevPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
681 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fPrevPageButton
);
683 fFirstPageButton
= new FirstPage(this);
684 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fFirstPageButton
);
685 fFirstPageButton
.setEnabled(fSdPagingProvider
.hasPrevPage());
686 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fFirstPageButton
);
688 fLastPageButton
= new LastPage(this);
689 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fLastPageButton
);
690 fLastPageButton
.setEnabled(fSdPagingProvider
.hasNextPage());
691 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, fLastPageButton
);
694 if (fSdExFilterProvider
!= null) {
695 Action action
= fSdExFilterProvider
.getFilterAction();
696 if (action
!= null) {
697 if (action
.getId() == null)
699 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
701 if (action
.getImageDescriptor() == null) {
702 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_FILTERS
));
704 if (action
.getText() == null || action
.getText().length() == 0) {
705 action
.setText(Messages
.SequenceDiagram_EditFilters
);
707 bar
.getMenuManager().prependToGroup(UML2SD_FILTERING_SEPARATOR
, action
);
708 bar
.getToolBarManager().prependToGroup(UML2SD_FILTERING_SEPARATOR
, action
);
711 // Both systems can be used now: commenting out else keyword
712 if (fSdFilterProvider
!= null) {
713 bar
.getMenuManager().appendToGroup(UML2SD_FILTERING_SEPARATOR
, new OpenSDFiltersDialog(this, fSdFilterProvider
));
715 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
716 IContributionItem sdPaging
= bar
.getMenuManager().find(OpenSDPagesDialog
.ID
);
717 if (sdPaging
!= null) {
718 bar
.getMenuManager().remove(sdPaging
);
721 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider
) fSdPagingProvider
));
722 updatePagesMenuItem(bar
);
725 if (fSdExFindProvider
!= null) {
726 Action action
= fSdExFindProvider
.getFindAction();
727 if (action
!= null) {
728 if (action
.getId() == null) {
729 action
.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
731 if (action
.getImageDescriptor() == null) {
732 action
.setImageDescriptor(Activator
.getDefault().getImageDescripterFromPath(ITmfImageConstants
.IMG_UI_SEARCH_SEQ
));
734 if (action
.getText() == null) {
735 action
.setText(Messages
.SequenceDiagram_Find
+ "..."); //$NON-NLS-1$
737 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, action
);
738 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, action
);
740 } else if (fSdFindProvider
!= null) {
741 bar
.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDFindDialog(this));
742 bar
.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR
, new OpenSDFindDialog(this));
745 if (fSdExtendedActionBarProvider
!= null) {
746 fSdExtendedActionBarProvider
.supplementCoolbarContent(bar
);
749 bar
.updateActionBars();
753 * Updates the view coolbar buttons state according to the value return by: -
754 * ISDExtendedActionBarProvider.hasNextPage()<br>
755 * - ISDExtendedActionBarProvider.hasPrevPage()<br>
758 public void updateCoolBar() {
759 if (fSdPagingProvider
!= null) {
760 IActionBars bar
= getViewSite().getActionBars();
764 IToolBarManager barManager
= bar
.getToolBarManager();
765 if (barManager
== null) {
768 IContributionItem nextPage
= barManager
.find(NextPage
.ID
);
769 if (nextPage
instanceof ActionContributionItem
) {
770 IAction nextPageAction
= ((ActionContributionItem
) nextPage
).getAction();
771 if (nextPageAction
instanceof NextPage
) {
772 ((NextPage
) nextPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
776 IContributionItem prevPage
= barManager
.find(PrevPage
.ID
);
777 if (prevPage
instanceof ActionContributionItem
) {
778 IAction prevPageAction
= ((ActionContributionItem
) prevPage
).getAction();
779 if (prevPageAction
instanceof PrevPage
) {
780 ((PrevPage
) prevPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
784 IContributionItem firstPage
= barManager
.find(FirstPage
.ID
);
785 if (firstPage
instanceof ActionContributionItem
) {
786 IAction firstPageAction
= ((ActionContributionItem
) firstPage
).getAction();
787 if (firstPageAction
instanceof FirstPage
) {
788 ((FirstPage
) firstPageAction
).setEnabled(fSdPagingProvider
.hasPrevPage());
792 IContributionItem lastPage
= barManager
.find(LastPage
.ID
);
793 if (lastPage
instanceof ActionContributionItem
) {
794 IAction lastPageAction
= ((ActionContributionItem
) lastPage
).getAction();
795 if (lastPageAction
instanceof LastPage
) {
796 ((LastPage
) lastPageAction
).setEnabled(fSdPagingProvider
.hasNextPage());
800 updatePagesMenuItem(bar
);
805 * Enables or disables the Pages... menu item, depending on the number of pages
807 * @param bar the bar containing the action
809 protected void updatePagesMenuItem(IActionBars bar
) {
810 if (fSdPagingProvider
instanceof ISDAdvancedPagingProvider
) {
811 IMenuManager menuManager
= bar
.getMenuManager();
812 ActionContributionItem contributionItem
= (ActionContributionItem
) menuManager
.find(OpenSDPagesDialog
.ID
);
813 IAction openSDPagesDialog
= null;
814 if (contributionItem
!= null) {
815 openSDPagesDialog
= contributionItem
.getAction();
818 if (openSDPagesDialog
instanceof OpenSDPagesDialog
) {
819 openSDPagesDialog
.setEnabled(((ISDAdvancedPagingProvider
) fSdPagingProvider
).pagesCount() > 1);
825 * The frame to render (the sequence diagram)
827 * @param frame the frame to display
829 public void setFrame(Frame frame
) {
830 setFrame(frame
, true);
834 * The frame to render (the sequence diagram)
836 * @param frame the frame to display
837 * @param resetPosition boolean Flag whether to reset the position or not.
839 protected void setFrame(Frame frame
, boolean resetPosition
) {
840 if (getSDWidget() == null) {
849 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(getViewSite().getId(), this);
850 if (loader
== null) {
854 if (loader
.getTitleString() != null) {
855 setContentDescription(loader
.getTitleString());
858 getSDWidget().setFrame(frame
, resetPosition
);
860 if (fTimeCompressionBar
!= null) {
861 fTimeCompressionBar
.setFrame(frame
);
864 if (fTimeCompressionBar
!= null) {
865 if (!frame
.hasTimeInfo()) {
866 Composite parent
= fTimeCompressionBar
.getParent();
867 fTimeCompressionBar
.setVisible(false);
870 Composite parent
= fTimeCompressionBar
.getParent();
871 fTimeCompressionBar
.setVisible(true);
875 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
876 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
877 if (shortKeys
!= null) {
878 IContributionItem
[] items
= shortKeys
.getItems();
879 for (int i
= 0; i
< items
.length
; i
++) {
880 if (items
[i
] instanceof ActionContributionItem
) {
881 IAction action
= ((ActionContributionItem
) items
[i
]).getAction();
882 if (action
!= null) {
883 action
.setEnabled(true);
888 createCoolbarContent();
892 * Activate or deactivate the short key command given in parameter (see plugin.xml)
894 * @param id the command id defined in the plugin.xml
895 * @param value the state value
897 public void setEnableCommand(String id
, boolean value
) {
898 IContributionItem shortKeysMenu
= getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
899 MenuManager shortKeys
= (MenuManager
) shortKeysMenu
;
900 if (shortKeys
== null) {
903 IContributionItem item
= shortKeys
.find(id
);
904 if ((item
!= null) && (item
instanceof ActionContributionItem
)) {
905 IAction action
= ((ActionContributionItem
) item
).getAction();
906 if (action
!= null) {
907 action
.setEnabled(value
);
913 * Set the frame from an other thread than the one executing the main loop
915 * @param frame The frame to set (and display)
917 public void setFrameSync(final Frame frame
) {
918 if (getSDWidget() == null || getSDWidget().isDisposed()) {
921 getSDWidget().getDisplay().syncExec(new Runnable() {
924 if (getSDWidget() == null || getSDWidget().isDisposed() ||
925 ((fTimeCompressionBar
!= null) && fTimeCompressionBar
.isDisposed())) {
935 * Ensure an object is visible from an other thread than the one executing the main loop
937 * @param sm The node to make visible in view
939 public void ensureVisibleSync(final GraphNode sm
) {
940 getSDWidget().getDisplay().syncExec(new Runnable() {
943 if (getSDWidget() == null || getSDWidget().isDisposed()) {
946 getSDWidget().ensureVisible(sm
);
952 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
954 * @param sm The node to make visible in view
955 * @param frame Frame The frame to set
957 public void setFrameAndEnsureVisibleSync(final Frame frame
, final GraphNode sm
) {
958 if (getSDWidget() == null || getSDWidget().isDisposed()) {
961 getSDWidget().getDisplay().syncExec(new Runnable() {
964 if (getSDWidget() == null || getSDWidget().isDisposed()) {
967 setFrameAndEnsureVisible(frame
, sm
);
973 * Set the frame and ensure an object is visible
975 * @param sm The node to make visible in view
976 * @param frame Frame The frame to set
978 public void setFrameAndEnsureVisible(Frame frame
, GraphNode sm
) {
979 getSDWidget().clearSelection();
980 setFrame(frame
, false);
981 getSDWidget().ensureVisible(sm
);
985 * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
987 * @param frame The frame to set.
988 * @param x The x coordinate to make visible.
989 * @param y The y coordinate to make visible.
991 public void setFrameAndEnsureVisibleSync(final Frame frame
, final int x
, final int y
) {
992 if (getSDWidget() == null || getSDWidget().isDisposed()) {
996 getSDWidget().getDisplay().syncExec(new Runnable() {
999 setFrameAndEnsureVisible(frame
, x
, y
);
1005 * Set the frame and ensure an object is visible
1007 * @param frame The frame to set.
1008 * @param x The x coordinate to make visible.
1009 * @param y The y coordinate to make visible.
1011 public void setFrameAndEnsureVisible(Frame frame
, int x
, int y
) {
1012 getSDWidget().clearSelection();
1013 setFrame(frame
, false);
1014 getSDWidget().ensureVisible(x
, y
);
1015 getSDWidget().redraw();
1019 * Toggle between default and wait cursors from an other thread than the one executing the main loop
1021 * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
1023 public void toggleWaitCursorAsync(final boolean wait
) {
1024 if (getSDWidget() == null || getSDWidget().isDisposed()) {
1028 getSDWidget().getDisplay().asyncExec(new Runnable() {
1031 if (getSDWidget() == null || getSDWidget().isDisposed()) {
1035 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
1036 fWaitCursor
.dispose();
1038 fWaitCursor
= new Cursor(getSDWidget().getDisplay(), SWT
.CURSOR_WAIT
);
1039 getSDWidget().setCursor(fWaitCursor
);
1040 getSDWidget().getDisplay().update();
1042 if (fWaitCursor
!= null && !fWaitCursor
.isDisposed()) {
1043 fWaitCursor
.dispose();
1046 getSDWidget().setCursor(null);
1047 getSDWidget().getDisplay().update();
1054 * Return the time compression bar widget
1056 * @return the time compression bar
1058 public TimeCompressionBar
getTimeCompressionBar() {
1059 return fTimeCompressionBar
;
1063 * Returns the current Frame (the sequence diagram container)
1065 * @return the current frame
1067 public Frame
getFrame() {
1068 if (getSDWidget() != null) {
1069 return getSDWidget().getFrame();
1075 * Gets the initialization flag.
1076 * @return the value of the initialization flag.
1079 protected boolean isNeedInit() {
1084 * Restores the loader for the view based on the view ID.
1086 * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
1088 protected boolean restoreLoader() {
1089 String id
= getViewSite().getId();
1093 IUml2SDLoader loader
= LoadersManager
.getInstance().getCurrentLoader(id
, this);
1094 if ((loader
!= null)) {
1095 loader
.setViewer(this);
1103 * Checks if current view is ready to be used.
1105 * @return boolean <code>true</code> if view is ready else <code>false</code>.
1107 protected boolean isViewReady() {
1108 IWorkbenchPage page
= PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage();
1113 IViewReference
[] ref
= page
.getViewReferences();
1114 for (int i
= 0; i
< ref
.length
; i
++) {
1115 if (ref
[i
].getView(false) == this) {
1123 * Creates the menu group.
1125 protected void createMenuGroup() {
1126 IActionBars bar
= getViewSite().getActionBars();
1130 bar
.getToolBarManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR
));
1131 bar
.getToolBarManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR
));
1132 bar
.getToolBarManager().add(new Separator(UML2SD_SORTING_SEPARATOR
));
1133 bar
.getToolBarManager().add(new Separator(UML2SD_FILTERING_SEPARATOR
));
1134 bar
.getToolBarManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR
));
1135 bar
.getToolBarManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR
));
1136 bar
.getToolBarManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR
));
1137 bar
.getToolBarManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR
));
1138 bar
.getMenuManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR
));
1139 bar
.getMenuManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR
));
1140 bar
.getMenuManager().add(new Separator(UML2SD_SORTING_SEPARATOR
));
1141 bar
.getMenuManager().add(new Separator(UML2SD_FILTERING_SEPARATOR
));
1142 bar
.getMenuManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR
));
1143 bar
.getMenuManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR
));
1144 bar
.getMenuManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR
));
1145 bar
.getMenuManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR
));
1149 public Object
getAdapter(Class adapter
) {
1150 Object obj
= super.getAdapter(adapter
);
1151 if (fSdPropertiesProvider
!= null && adapter
.equals(IPropertySheetPage
.class)) {
1152 return fSdPropertiesProvider
.getPropertySheetEntry();
1159 * Loader for a blank sequence diagram.
1163 public static class BlankUml2SdLoader
implements IUml2SDLoader
{
1165 public void setViewer(SDView viewer
) {
1167 Frame f
= new Frame();
1168 f
.setName(""); //$NON-NLS-1$
1173 public String
getTitleString() {
1174 return ""; //$NON-NLS-1$
1178 public void dispose() {