tmf: API clean-up of sequence diagram framework
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDView.java
index 504b7fac1493d0bfe804503e838f44ca312a1918..541785d7006c0250dedb7851b488a072406c3bc6 100644 (file)
@@ -85,73 +85,117 @@ import org.eclipse.ui.views.properties.IPropertySheetPage;
  */
 public class SDView extends ViewPart {
 
+    // ------------------------------------------------------------------------
+    // Constants
+    // ------------------------------------------------------------------------
+    /**
+     * Name of menu separator for view modes
+     * @since 2.0
+     */
+    public final static String UML2SD_VIEW_MODES_SEPARATOR = "UML2SD_VIEW_MODES"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for working set
+     * @since 2.0
+     */
+    public final static String UML2SD_WORKING_SET_SEPARATOR = "UML2SD_WORKING_SET"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for sorting
+     * @since 2.0
+     */
+    public final static String UML2SD_SORTING_SEPARATOR = "UML2SD_SORTING"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for filtering
+     * @since 2.0
+     */
+    public final static String UML2SD_FILTERING_SEPARATOR = "UML2SD_FILTERING"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for view layout
+     * @since 2.0
+     */
+    public final static String UML2SD_VIEW_LAYOUT_SEPARATOR = "UML2SD_VIEW_LAYOUT"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for link editor
+     * @since 2.0
+     */
+    public final static String UML2SD_LINK_EDITOR_SEPARATOR = "UML2SD_LINK_EDITOR"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for other commands
+     * @since 2.0
+     */
+    public final static String UML2SD_OTHER_COMMANDS_SEPARATOR = "UML2SD_OTHER_COMMANDS"; //$NON-NLS-1$
+    /**
+     * Name of menu separator for other plug-in commands
+     * @since 2.0
+     */
+    public final static String UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR = "UML2SD_OTHER_PLUGINS_COMMANDS"; //$NON-NLS-1$
+
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
     /**
      * The sequence diagram widget.
      */
-    protected SDWidget fSdWidget = null;
+    private SDWidget fSdWidget = null;
     /**
      * The time compression bar.
      */
-    protected TimeCompressionBar fTimeCompressionBar = null;
+    private TimeCompressionBar fTimeCompressionBar = null;
     /**
      * The sequence diagram find provider implementation.
      */
-    protected ISDFindProvider fSdFindProvider = null;
+    private ISDFindProvider fSdFindProvider = null;
     /**
      * The sequence diagram paging provider implementation.
      */
-    protected ISDPagingProvider fSdPagingProvider = null;
+    private ISDPagingProvider fSdPagingProvider = null;
     /**
      * The sequence diagram filter provider implementation.
      */
-    protected ISDFilterProvider fSdFilterProvider = null;
+    private ISDFilterProvider fSdFilterProvider = null;
     /**
      * The extended sequence diagram filter provider implementation.
      */
-    protected IExtendedFilterProvider fSdExFilterProvider = null;
+    private IExtendedFilterProvider fSdExFilterProvider = null;
     /**
      * The extended sequence diagram find provider implementation.
      */
-    protected IExtendedFindProvider fSdExFindProvider = null;
+    private IExtendedFindProvider fSdExFindProvider = null;
     /**
      * The extended sequence diagram action bar provider implementation.
      */
-    protected ISDExtendedActionBarProvider fSdExtendedActionBarProvider = null;
+    private ISDExtendedActionBarProvider fSdExtendedActionBarProvider = null;
     /**
      * The sequence diagram property provider implementation.
      */
-    protected ISDPropertiesProvider fSdPropertiesProvider = null;
+    private ISDPropertiesProvider fSdPropertiesProvider = null;
     /**
      * Button for executing the next page action.
      */
-    protected NextPage fNextPageButton = null;
+    private NextPage fNextPageButton = null;
     /**
      * Button for executing the previous page action.
      */
-    protected PrevPage fPrevPageButton = null;
+    private PrevPage fPrevPageButton = null;
     /**
      * Button for executing the first page page action.
      */
-    protected FirstPage fFirstPageButton = null;
+    private FirstPage fFirstPageButton = null;
     /**
      * Button for executing the last page action.
      */
-    protected LastPage fLastPageButton = null;
+    private LastPage fLastPageButton = null;
     /**
      * The menu manager reference.
      */
-    protected MenuManager fMenuMgr = null;
+    private MenuManager fMenuMgr = null;
     /**
      * Flag to indicate whether view needs initialization or not.
      */
-    protected boolean fNeedInit = true;
+    private boolean fNeedInit = true;
     /**
      * WaitCursor is the cursor to be displayed when long tasks are running
      */
-    protected Cursor fWaitCursor;
+    private Cursor fWaitCursor;
 
     // ------------------------------------------------------------------------
     // Methods
@@ -171,7 +215,7 @@ public class SDView extends ViewPart {
         GridData seqDiagLayoutData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.VERTICAL_ALIGN_FILL);
         fTimeCompressionBar = new TimeCompressionBar(parent, SWT.NONE);
         fTimeCompressionBar.setLayoutData(timeLayoutdata);
-        fSdWidget = new SDWidget(parent, SWT.NONE);// SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+        fSdWidget = new SDWidget(parent, SWT.NONE);
         fSdWidget.setLayoutData(seqDiagLayoutData);
         fSdWidget.setSite(this);
         fSdWidget.setTimeBar(fTimeCompressionBar);
@@ -308,7 +352,6 @@ public class SDView extends ViewPart {
     public void setSDFilterProvider(ISDFilterProvider provider) {
         fSdFilterProvider = provider;
         // Both systems can be used now, commenting out next statement
-        // sdExFilterProvider = null;
         createCoolbarContent();
     }
 
@@ -321,7 +364,6 @@ public class SDView extends ViewPart {
     public void setExtendedFilterProvider(IExtendedFilterProvider provider) {
         fSdExFilterProvider = provider;
         // Both systems can be used now, commenting out next statement
-        // sdFilterProvider = null;
         createCoolbarContent();
     }
 
@@ -424,6 +466,39 @@ public class SDView extends ViewPart {
         return fSdPropertiesProvider;
     }
 
+    /**
+     * Sets the sdWidget.
+     *
+     * @param sdWidget
+     *          A sdWidget to set
+     * @since 2.0
+     */
+    protected void setSDWidget(SDWidget sdWidget) {
+        fSdWidget = sdWidget;
+    }
+
+    /**
+     * Sets the time compression bar.
+     *
+     * @param timeCompressionbar
+     *          A sdWidget to set
+     * @since 2.0
+     */
+    protected void setTimeBar(TimeCompressionBar timeCompressionbar) {
+        fTimeCompressionBar = timeCompressionbar;
+    }
+
+    /**
+     * Sets the initialization flag.
+     *
+     * @param needInit
+     *          flag value to set
+     * @since 2.0
+     */
+    protected void setNeedInit(boolean needInit) {
+        fNeedInit = needInit;
+    }
+
     /**
      * Creates the basic sequence diagram menu
      */
@@ -457,7 +532,7 @@ public class SDView extends ViewPart {
      */
     protected void fillContextMenu(IMenuManager manager) {
         manager.add(new Separator("Additions")); //$NON-NLS-1$
-        if (getSDWidget() != null && getSDWidget().fCurrentGraphNode != null) {
+        if (getSDWidget() != null && getSDWidget().getCurrentGraphNode() != null) {
             ISelectionProvider selProvider = fSdWidget.getSelectionProvider();
             ISelection sel = selProvider.getSelection();
             int nbMessage = 0;
@@ -471,7 +546,7 @@ public class SDView extends ViewPart {
             if (nbMessage != 1) {
                 return;
             }
-            GraphNode node = getSDWidget().fCurrentGraphNode;
+            GraphNode node = getSDWidget().getCurrentGraphNode();
             if ((node instanceof SyncMessageReturn) && (((SyncMessageReturn) node).getMessage() != null)) {
                 Action goToMessage = new MoveToMessage(this);
                 goToMessage.setText(Messages.SequenceDiagram_GoToMessage);
@@ -526,21 +601,21 @@ public class SDView extends ViewPart {
         createMenuGroup();
 
         Zoom resetZoom = new Zoom(this, ZoomType.ZOOM_RESET);
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom);//$NON-NLS-1$
-        bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", resetZoom); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom);
+        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, resetZoom);
 
         Zoom noZoom = new Zoom(this, ZoomType.ZOOM_NONE);
         noZoom.setChecked(true);
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom);//$NON-NLS-1$
-        bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", noZoom); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom);
+        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, noZoom);
 
         Zoom zoomIn = new Zoom(this, ZoomType.ZOOM_IN);
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn);//$NON-NLS-1$
-        bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomIn); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn);
+        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomIn);
 
         Zoom zoomOut = new Zoom(this, ZoomType.ZOOM_OUT);
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut);//$NON-NLS-1$
-        bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", zoomOut); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut);
+        bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, zoomOut);
 
         MenuManager navigation = new MenuManager(Messages.SequenceDiagram_Navigation);
 
@@ -558,12 +633,12 @@ public class SDView extends ViewPart {
         showNodeEnd.setActionDefinitionId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ShowNodeEnd");//$NON-NLS-1$
         navigation.add(showNodeEnd);
 
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", navigation); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, navigation);
 
         ConfigureMinMax minMax = new ConfigureMinMax(this);
         minMax.setText(Messages.SequenceDiagram_ConfigureMinMax);
         minMax.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.ConfigureMinMax");//$NON-NLS-1$
-        bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", minMax); //$NON-NLS-1$
+        bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, minMax);
 
         if ((fSdWidget.getFrame() != null) && (fSdWidget.getFrame().hasTimeInfo())) {
             minMax.setEnabled(true);
@@ -574,24 +649,24 @@ public class SDView extends ViewPart {
         // Do we need to display a paging item
         if (fSdPagingProvider != null) {
             fNextPageButton = new NextPage(this);
-            bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$
+            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton);
             fNextPageButton.setEnabled(fSdPagingProvider.hasNextPage());
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fNextPageButton); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fNextPageButton);
 
             fPrevPageButton = new PrevPage(this);
-            bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
+            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton);
             fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fPrevPageButton);
 
             fFirstPageButton = new FirstPage(this);
-            bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$
+            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton);
             fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fFirstPageButton);
 
             fLastPageButton = new LastPage(this);
-            bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$
+            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton);
             fLastPageButton.setEnabled(fSdPagingProvider.hasNextPage());
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fLastPageButton); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, fLastPageButton);
         }
 
         if (fSdExFilterProvider != null) {
@@ -607,15 +682,13 @@ public class SDView extends ViewPart {
                 if (action.getText() == null || action.getText().length() == 0) {
                     action.setText(Messages.SequenceDiagram_EditFilters);
                 }
-                bar.getMenuManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
-                bar.getToolBarManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
+                bar.getMenuManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action);
+                bar.getToolBarManager().prependToGroup(UML2SD_FILTERING_SEPARATOR, action);
             }
         }
         // Both systems can be used now: commenting out else keyword
-        /* else */if (fSdFilterProvider != null) {
-            bar.getMenuManager().appendToGroup("UML2SD_FILTERING", new OpenSDFiltersDialog(this, fSdFilterProvider)); //$NON-NLS-1$
-            // No longer in the coolbar: commenting out next statement
-            //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider));       //$NON-NLS-1$
+        if (fSdFilterProvider != null) {
+            bar.getMenuManager().appendToGroup(UML2SD_FILTERING_SEPARATOR, new OpenSDFiltersDialog(this, fSdFilterProvider));
         }
         if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
             IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID);
@@ -623,7 +696,7 @@ public class SDView extends ViewPart {
                 bar.getMenuManager().remove(sdPaging);
                 sdPaging = null;
             }
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider)); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDPagesDialog(this, (ISDAdvancedPagingProvider) fSdPagingProvider));
             updatePagesMenuItem(bar);
         }
 
@@ -639,12 +712,12 @@ public class SDView extends ViewPart {
                 if (action.getText() == null) {
                     action.setText(Messages.SequenceDiagram_Find + "..."); //$NON-NLS-1$
                 }
-                bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
-                bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", action); //$NON-NLS-1$
+                bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action);
+                bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, action);
             }
         } else if (fSdFindProvider != null) {
-            bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
-            bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", new OpenSDFindDialog(this)); //$NON-NLS-1$
+            bar.getMenuManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this));
+            bar.getToolBarManager().appendToGroup(UML2SD_OTHER_COMMANDS_SEPARATOR, new OpenSDFindDialog(this));
         }
 
         if (fSdExtendedActionBarProvider != null) {
@@ -976,6 +1049,15 @@ public class SDView extends ViewPart {
         return null;
     }
 
+    /**
+     * Gets the initialization flag.
+     * @return the value of the initialization flag.
+     * @since 2.0
+     */
+    private boolean isNeedInit() {
+        return fNeedInit;
+    }
+
     /**
      * Restores the loader for the view based on the view ID.
      *
@@ -983,13 +1065,11 @@ public class SDView extends ViewPart {
      */
     protected boolean restoreLoader() {
         String id = getViewSite().getId();
-        // System.err.println("restoreLoader() id="+id);
         if (id == null) {
             return true;
         }
         IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(id, this);
-        // System.err.println("restoreLoader() l="+l);
-        if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
+        if ((loader != null)) {
             loader.setViewer(this);
             return false;
         }
@@ -1025,22 +1105,22 @@ public class SDView extends ViewPart {
         if (bar == null) {
             return;
         }
-        bar.getToolBarManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
-        bar.getToolBarManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_VIEW_MODES")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_WORKING_SET")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_SORTING")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_FILTERING")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_VIEW_LAYOUT")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_LINK_EDITOR")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_OTHER_COMMANDS")); //$NON-NLS-1$
-        bar.getMenuManager().add(new Separator("UML2SD_OTHER_PLUGINS_COMMANDS")); //$NON-NLS-1$
+        bar.getToolBarManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_SORTING_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_FILTERING_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR));
+        bar.getToolBarManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_VIEW_MODES_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_WORKING_SET_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_SORTING_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_FILTERING_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_VIEW_LAYOUT_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_LINK_EDITOR_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_OTHER_COMMANDS_SEPARATOR));
+        bar.getMenuManager().add(new Separator(UML2SD_OTHER_PLUGINS_COMMANDS_SEPARATOR));
     }
 
     @Override
This page took 0.038972 seconds and 5 git commands to generate.