tmf: Update copyright headers in tmf.ui
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / uml2sd / SDView.java
old mode 100755 (executable)
new mode 100644 (file)
index 5c2fe3f..9631704
@@ -1,16 +1,15 @@
 /**********************************************************************
- * Copyright (c) 2005, 2008 IBM Corporation and others.
- * Copyright (c) 2011, 2012 Ericsson.
- * 
+ * Copyright (c) 2005, 2012 IBM Corporation, Ericsson
  * All rights reserved.   This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
  * http://www.eclipse.org/legal/epl-v10.html
- * 
- * Contributors: 
- * IBM - Initial API and implementation
- * Bernd Hufmann - Updated for TMF
+ *
+ * Contributors:
+ *     IBM - Initial API and implementation
+ *     Bernd Hufmann - Updated for TMF
  **********************************************************************/
+
 package org.eclipse.linuxtools.tmf.ui.views.uml2sd;
 
 import java.util.Iterator;
@@ -27,8 +26,8 @@ import org.eclipse.jface.action.Separator;
 import org.eclipse.jface.viewers.ISelection;
 import org.eclipse.jface.viewers.ISelectionProvider;
 import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.linuxtools.internal.tmf.ui.Activator;
 import org.eclipse.linuxtools.internal.tmf.ui.ITmfImageConstants;
-import org.eclipse.linuxtools.internal.tmf.ui.TmfUiPlugin;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.BaseMessage;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.Frame;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.core.GraphNode;
@@ -56,6 +55,7 @@ import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDCollapseP
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDExtendedActionBarProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFilterProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDFindProvider;
+import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDGraphNodeSupporter;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPagingProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.provider.ISDPropertiesProvider;
 import org.eclipse.linuxtools.tmf.ui.views.uml2sd.load.IUml2SDLoader;
@@ -80,7 +80,7 @@ import org.eclipse.ui.views.properties.IPropertySheetPage;
  * This class is a generic sequence diagram view implementation.
  * </p>
 
- * @version 1.0 
+ * @version 1.0
  * @author sveyrier
  */
 public class SDView extends ViewPart {
@@ -125,19 +125,19 @@ public class SDView extends ViewPart {
      */
     protected ISDPropertiesProvider fSdPropertiesProvider = null;
     /**
-     * Button for executing the next page action.  
+     * Button for executing the next page action.
      */
     protected NextPage fNextPageButton = null;
     /**
-     * Button for executing the previous page action.  
+     * Button for executing the previous page action.
      */
     protected PrevPage fPrevPageButton = null;
     /**
-     * Button for executing the first page page action.  
+     * Button for executing the first page page action.
      */
     protected FirstPage fFirstPageButton = null;
     /**
-     * Button for executing the last page action.  
+     * Button for executing the last page action.
      */
     protected LastPage fLastPageButton = null;
     /**
@@ -145,7 +145,7 @@ public class SDView extends ViewPart {
      */
     protected MenuManager fMenuMgr = null;
     /**
-     * Flag to indicate whether view needs initialization or not. 
+     * Flag to indicate whether view needs initialization or not.
      */
     protected boolean fNeedInit = true;
     /**
@@ -182,7 +182,7 @@ public class SDView extends ViewPart {
 
         // Add this view to the key bindings manager
         KeyBindingsManager.getInstance().add(this.getSite().getId());
-        
+
         createCoolbarContent();
 
         hookContextMenu();
@@ -200,7 +200,7 @@ public class SDView extends ViewPart {
      * Load a blank page that is supposed to explain that a kind of interaction must be chosen.
      */
     protected void loadBlank() {
-        IUml2SDLoader loader = new BlankUml2SdLoader(); 
+        IUml2SDLoader loader = new BlankUml2SdLoader();
         loader.setViewer(this);
         setContentDescription(loader.getTitleString());
     }
@@ -233,7 +233,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the SD widget.
-     * 
+     *
      * @return The SD widget.
      */
     public SDWidget getSDWidget() {
@@ -244,9 +244,9 @@ public class SDView extends ViewPart {
      * Set the find provider for the opened sequence diagram viewer<br>
      * If the provider is not set, the find menu item will not be available in the viewer<br>
      * A find provider is called back when the user perform a find action<br>
-     * The find provider is responsible to move the sequence diagram to the GraphNode which match the 
+     * The find provider is responsible to move the sequence diagram to the GraphNode which match the
      * find criteria as well as to highlight the GraphNode
-     * 
+     *
      * @param provider the search provider
      */
     public void setSDFindProvider(ISDFindProvider provider) {
@@ -260,13 +260,17 @@ public class SDView extends ViewPart {
             KeyBindingsManager.getInstance().setFindEnabled(false);
         }
     }
-    
+
     /**
      * Set the find provider for the opened sequence diagram viewer<br>
-     * If the provider is not set, the find menu item will not be available in the viewer<br>
+     * If the provider is not set, the find menu item will not be available in
+     * the viewer<br>
      * A find provider is called back when the user perform a find action<br>
-     * If the extended find provider is set, it replaces the regular find provider (sdFindProvider).<br>
+     * If the extended find provider is set, it replaces the regular find
+     * provider (sdFindProvider).<br>
+     *
      * @param provider
+     *            The provider to set
      */
     public void setExtendedFindProvider(IExtendedFindProvider provider) {
         fSdExFindProvider = provider;
@@ -282,7 +286,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the extended find provider
-     * 
+     *
      * @return extended find provider.
      */
     public IExtendedFindProvider getExtendedFindProvider() {
@@ -310,7 +314,7 @@ public class SDView extends ViewPart {
      * Set the filter provider for the opened sequence diagram viewer<br>
      * If the provider is not set, the filter menu item will not be available in the viewer<br>
      * A filter provider is called back when the user perform a filter action<br>
-     * 
+     *
      * @param provider the filter provider
      */
     public void setSDFilterProvider(ISDFilterProvider provider) {
@@ -319,10 +323,12 @@ public class SDView extends ViewPart {
         // sdExFilterProvider = null;
         createCoolbarContent();
     }
-    
+
     /**
-     * Sets the extended filter provider for the opend sequence diagram viewer.
+     * Sets the extended filter provider for the opened sequence diagram viewer.
+     *
      * @param provider
+     *            The provider to set
      */
     public void setExtendedFilterProvider(IExtendedFilterProvider provider) {
         fSdExFilterProvider = provider;
@@ -333,7 +339,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the extended find provider.
-     * 
+     *
      * @return The extended find provider.
      */
     public IExtendedFilterProvider getExtendedFilterProvider() {
@@ -341,9 +347,9 @@ public class SDView extends ViewPart {
     }
 
     /**
-     * Register the given provider to support Drag and Drop collapsing. This provider is 
+     * Register the given provider to support Drag and Drop collapsing. This provider is
      * responsible of updating the Frame.
-     * 
+     *
      * @param provider - the provider to register
      */
     public void setCollapsingProvider(ISDCollapseProvider provider) {
@@ -357,7 +363,7 @@ public class SDView extends ViewPart {
      * If the sequence diagram provided (see setFrame) need to be split in many parts, a paging provider must be
      * provided in order to handle page change requested by the user<br>
      * Set a page provider will create the next and previous page buttons in the viewer coolBar
-     * 
+     *
      * @param provider the paging provider
      */
     public void setSDPagingProvider(ISDPagingProvider provider) {
@@ -367,7 +373,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current page provider for the view
-     * 
+     *
      * @return the paging provider
      */
     public ISDPagingProvider getSDPagingProvider() {
@@ -376,7 +382,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current find provider for the view
-     * 
+     *
      * @return the find provider
      */
     public ISDFindProvider getSDFindProvider() {
@@ -385,7 +391,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current filter provider for the view
-     * 
+     *
      * @return the filter provider
      */
     public ISDFilterProvider getSDFilterProvider() {
@@ -395,7 +401,7 @@ public class SDView extends ViewPart {
     /**
      * Set the extended action bar provider for the opened sequence diagram viewer<br>
      * This allow to add programmatically actions in the coolbar and/or in the drop-down menu
-     * 
+     *
      * @param provider the search provider
      */
     public void setSDExtendedActionBarProvider(ISDExtendedActionBarProvider provider) {
@@ -405,7 +411,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current extended action bar provider for the view
-     * 
+     *
      * @return the extended action bar provider
      */
     public ISDExtendedActionBarProvider getSDExtendedActionBarProvider() {
@@ -414,7 +420,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the properties view provider for the opened sequence diagram viewer
-     * 
+     *
      * @param provider the properties provider
      */
     public void setSDPropertiesProvider(ISDPropertiesProvider provider) {
@@ -423,7 +429,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current extended action bar provider for the view.
-     * 
+     *
      * @return the extended action bar provider
      */
     public ISDPropertiesProvider getSDPropertiesProvider() {
@@ -449,7 +455,7 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the context menu manager
-     * 
+     *
      * @return the menu manager
      */
     public MenuManager getMenuManager() {
@@ -458,7 +464,7 @@ public class SDView extends ViewPart {
 
     /**
      * Fills the basic sequence diagram menu and define the dynamic menu item insertion point
-     * 
+     *
      * @param manager the menu manager
      */
     protected void fillContextMenu(IMenuManager manager) {
@@ -494,7 +500,7 @@ public class SDView extends ViewPart {
 
     /**
      * Enables/Disables an action with given name.
-     * 
+     *
      * @param actionName The action name
      * @param state true or false
      */
@@ -517,7 +523,7 @@ public class SDView extends ViewPart {
      * Creates the coolBar icon depending on the actions supported by the Sequence Diagram provider<br>
      * - Navigation buttons are displayed if ISDPovider.HasPaging return true<br>
      * - Navigation buttons are enabled depending on the value return by ISDPovider.HasNext and HasPrev<br>
-     * 
+     *
      * @see ISDGraphNodeSupporter Action support definition
      * @see SDView#setSDFilterProvider(ISDFilterProvider)
      * @see SDView#setSDFindProvider(ISDFindProvider)
@@ -588,7 +594,7 @@ public class SDView extends ViewPart {
             bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
             fPrevPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
             bar.getMenuManager().appendToGroup("UML2SD_OTHER_COMMANDS", fPrevPageButton); //$NON-NLS-1$
-            
+
             fFirstPageButton = new FirstPage(this);
             bar.getToolBarManager().appendToGroup("UML2SD_OTHER_COMMANDS", fFirstPageButton); //$NON-NLS-1$
             fFirstPageButton.setEnabled(fSdPagingProvider.hasPrevPage());
@@ -604,20 +610,24 @@ public class SDView extends ViewPart {
             Action action = fSdExFilterProvider.getFilterAction();
             if (action != null) {
                 if (action.getId() == null)
+                 {
                     action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFilter"); //$NON-NLS-1$
-                if (action.getImageDescriptor() == null)
-                    action.setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS));
-                if (action.getText() == null || action.getText().length() == 0)
+                }
+                if (action.getImageDescriptor() == null) {
+                    action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_FILTERS));
+                }
+                if (action.getText() == null || action.getText().length() == 0) {
                     action.setText(SDMessages._42);
+                }
                 bar.getMenuManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
                 bar.getToolBarManager().prependToGroup("UML2SD_FILTERING", action); //$NON-NLS-1$
             }
         }
         // 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$    
+            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$   
+            //bar.getToolBarManager().appendToGroup("UML2SD_FILTERING",new OpenSDFiltersDialog(this, sdFilterProvider));       //$NON-NLS-1$
         }
         if (fSdPagingProvider instanceof ISDAdvancedPagingProvider) {
             IContributionItem sdPaging = bar.getMenuManager().find(OpenSDPagesDialog.ID);
@@ -636,7 +646,7 @@ public class SDView extends ViewPart {
                     action.setId("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers.extendedFind"); //$NON-NLS-1$
                 }
                 if (action.getImageDescriptor() == null) {
-                    action.setImageDescriptor(TmfUiPlugin.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
+                    action.setImageDescriptor(Activator.getDefault().getImageDescripterFromPath(ITmfImageConstants.IMG_UI_SEARCH_SEQ));
                 }
                 if (action.getText() == null) {
                     action.setText(SDMessages._41);
@@ -660,7 +670,7 @@ public class SDView extends ViewPart {
      * Updates the view coolbar buttons state according to the value return by: -
      * ISDExtendedActionBarProvider.hasNextPage()<br>
      * - ISDExtendedActionBarProvider.hasPrevPage()<br>
-     * 
+     *
      */
     public void updateCoolBar() {
         if (fSdPagingProvider != null) {
@@ -703,14 +713,14 @@ public class SDView extends ViewPart {
                     ((LastPage) lastPageAction).setEnabled(fSdPagingProvider.hasNextPage());
                 }
             }
-            
+
             updatePagesMenuItem(bar);
         }
     }
 
     /**
      * Enables or disables the Pages... menu item, depending on the number of pages
-     * 
+     *
      * @param bar the bar containing the action
      */
     protected void updatePagesMenuItem(IActionBars bar) {
@@ -730,7 +740,7 @@ public class SDView extends ViewPart {
 
     /**
      * The frame to render (the sequence diagram)
-     * 
+     *
      * @param frame the frame to display
      */
     public void setFrame(Frame frame) {
@@ -739,13 +749,14 @@ public class SDView extends ViewPart {
 
     /**
      * The frame to render (the sequence diagram)
-     * 
+     *
      * @param frame the frame to display
      * @param resetPosition boolean Flag whether to reset the position or not.
      */
     protected void setFrame(Frame frame, boolean resetPosition) {
-        if (fSdWidget == null)
+        if (getSDWidget() == null) {
             return;
+        }
 
         if (frame == null) {
             loadBlank();
@@ -753,27 +764,30 @@ public class SDView extends ViewPart {
         }
 
         IUml2SDLoader loader = LoadersManager.getInstance().getCurrentLoader(getViewSite().getId(), this);
+        if (loader == null) {
+            return;
+        }
 
-        if ((loader != null) && (loader.getTitleString() != null)) {
+        if (loader.getTitleString() != null) {
             setContentDescription(loader.getTitleString());
         }
 
-        if (getSDWidget() != null) {
-            getSDWidget().setFrame(frame, resetPosition);
-        }
+        getSDWidget().setFrame(frame, resetPosition);
 
         if (fTimeCompressionBar != null) {
             fTimeCompressionBar.setFrame(frame);
         }
         updateCoolBar();
-        if (!frame.hasTimeInfo()) {
-            Composite parent = fTimeCompressionBar.getParent();
-            fTimeCompressionBar.setVisible(false);
-            parent.layout(true);
-        } else {
-            Composite parent = fTimeCompressionBar.getParent();
-            fTimeCompressionBar.setVisible(true);
-            parent.layout(true);
+        if (fTimeCompressionBar != null) {
+            if (!frame.hasTimeInfo()) {
+                Composite parent = fTimeCompressionBar.getParent();
+                fTimeCompressionBar.setVisible(false);
+                parent.layout(true);
+            } else {
+                Composite parent = fTimeCompressionBar.getParent();
+                fTimeCompressionBar.setVisible(true);
+                parent.layout(true);
+            }
         }
         IContributionItem shortKeysMenu = getViewSite().getActionBars().getMenuManager().find("org.eclipse.linuxtools.tmf.ui.views.uml2sd.handlers");//$NON-NLS-1$
         MenuManager shortKeys = (MenuManager) shortKeysMenu;
@@ -793,7 +807,7 @@ public class SDView extends ViewPart {
 
     /**
      * Activate or deactivate the short key command given in parameter (see plugin.xml)
-     * 
+     *
      * @param id the command id defined in the plugin.xml
      * @param value the state value
      */
@@ -814,7 +828,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the frame from an other thread than the one executing the main loop
-     * 
+     *
      * @param frame The frame to set (and display)
      */
     public void setFrameSync(final Frame frame) {
@@ -824,7 +838,8 @@ public class SDView extends ViewPart {
         getSDWidget().getDisplay().syncExec(new Runnable() {
             @Override
             public void run() {
-                if (getSDWidget() == null || getSDWidget().isDisposed()) {
+                if (getSDWidget() == null || getSDWidget().isDisposed() ||
+                        ((fTimeCompressionBar != null) && fTimeCompressionBar.isDisposed())) {
                     return;
                 }
                 setFrame(frame);
@@ -835,7 +850,7 @@ public class SDView extends ViewPart {
 
     /**
      * Ensure an object is visible from an other thread than the one executing the main loop
-     * 
+     *
      * @param sm The node to make visible in view
      */
     public void ensureVisibleSync(final GraphNode sm) {
@@ -852,7 +867,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
-     * 
+     *
      * @param sm The node to make visible in view
      * @param frame Frame The frame to set
      */
@@ -873,7 +888,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the frame and ensure an object is visible
-     * 
+     *
      * @param sm The node to make visible in view
      * @param frame Frame The frame to set
      */
@@ -885,7 +900,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the frame and ensure an object is visible from an other thread than the one executing the main loop
-     * 
+     *
      * @param frame The frame to set.
      * @param x The x coordinate to make visible.
      * @param y The y coordinate to make visible.
@@ -894,7 +909,7 @@ public class SDView extends ViewPart {
         if (getSDWidget() == null || getSDWidget().isDisposed()) {
             return;
         }
-        
+
         getSDWidget().getDisplay().syncExec(new Runnable() {
             @Override
             public void run() {
@@ -905,7 +920,7 @@ public class SDView extends ViewPart {
 
     /**
      * Set the frame and ensure an object is visible
-     * 
+     *
      * @param frame The frame to set.
      * @param x The x coordinate to make visible.
      * @param y The y coordinate to make visible.
@@ -919,8 +934,8 @@ public class SDView extends ViewPart {
 
     /**
      * Toggle between default and wait cursors from an other thread than the one executing the main loop
-     * 
-     * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor. 
+     *
+     * @param wait <code>true</code> for wait cursor else <code>false</code> for default cursor.
      */
     public void toggleWaitCursorAsync(final boolean wait) {
         if (getSDWidget() == null || getSDWidget().isDisposed()) {
@@ -954,8 +969,8 @@ public class SDView extends ViewPart {
 
     /**
      * Return the time compression bar widget
-     * 
-     * @return the time compression bar 
+     *
+     * @return the time compression bar
      */
     public TimeCompressionBar getTimeCompressionBar() {
         return fTimeCompressionBar;
@@ -963,21 +978,19 @@ public class SDView extends ViewPart {
 
     /**
      * Returns the current Frame (the sequence diagram container)
-     * 
-     * @return the current frame 
+     *
+     * @return the current frame
      */
     public Frame getFrame() {
         if (getSDWidget() != null) {
             return getSDWidget().getFrame();
         }
-        else {
-            return null;
-        }
+        return null;
     }
 
     /**
      * Restores the loader for the view based on the view ID.
-     * 
+     *
      * @return boolean <code>true</code> if initialization is needed else <code>false</code>.
      */
     protected boolean restoreLoader() {
@@ -991,15 +1004,14 @@ public class SDView extends ViewPart {
         if ((loader != null)) {// &&( LoadersManager.getLoadersManager().getViewer(l)==this)){
             loader.setViewer(this);
             return false;
-        } else {
-            loadBlank();
-            return true;
         }
+        loadBlank();
+        return true;
     }
 
     /**
      * Checks if current view is ready to be used.
-     * 
+     *
      * @return boolean <code>true</code> if view is ready else <code>false</code>.
      */
     protected boolean isViewReady() {
@@ -1048,7 +1060,6 @@ public class SDView extends ViewPart {
      * (non-Javadoc)
      * @see org.eclipse.ui.part.WorkbenchPart#getAdapter(java.lang.Class)
      */
-    @SuppressWarnings("rawtypes")
     @Override
     public Object getAdapter(Class adapter) {
         Object obj = super.getAdapter(adapter);
@@ -1058,10 +1069,10 @@ public class SDView extends ViewPart {
 
         return obj;
     }
-    
+
     /**
      * Loader for a blank sequence diagram.
-     * 
+     *
      * @version 1.0
      */
     public static class BlankUml2SdLoader implements IUml2SDLoader {
@@ -1093,5 +1104,5 @@ public class SDView extends ViewPart {
         @Override
         public void dispose() {
         }
-    } 
+    }
 }
This page took 0.032909 seconds and 5 git commands to generate.