Merged refactoring from development branch.
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / model / AbstractUtility.java
index 78c690bb237c1c804728db556540146170ae9239..36f2d5197aa68b51e79a0825460cc44e5da36d9e 100644 (file)
@@ -34,6 +34,7 @@ import org.eclipse.swt.graphics.Color;
 import org.eclipse.swt.graphics.Font;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
 import org.eclipse.ui.IViewPart;
 import org.eclipse.ui.IViewReference;
 import org.eclipse.ui.IWorkbench;
@@ -51,6 +52,9 @@ import org.eclipse.ui.themes.IThemeManager;
 import eu.etaxonomy.taxeditor.operation.AbstractPostOperation;
 import eu.etaxonomy.taxeditor.operation.IPostOperationEnabled;
 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
+import eu.etaxonomy.taxeditor.view.AbstractCdmDataViewer;
+import eu.etaxonomy.taxeditor.view.detail.DetailsViewPart;
+import eu.etaxonomy.taxeditor.view.supplementaldata.SupplementalDataViewPart;
 
 /**
  * <p>Abstract AbstractUtility class.</p>
@@ -115,16 +119,20 @@ public abstract class AbstractUtility {
                return getActivePage() != null ? getActivePage().getActivePart() : null;
        }
        
+       public static IWorkbench getWorkbench(){
+               return TaxeditorStorePlugin.getDefault().getWorkbench();
+       }
+       
        /**
         * <p>getWorkbenchWindow</p>
         *
         * @return a {@link org.eclipse.jface.window.ApplicationWindow} object.
         */
        public static ApplicationWindow getWorkbenchWindow(){
-               if(TaxeditorStorePlugin.getDefault().getWorkbench().getWorkbenchWindowCount() > 1){
+               if(getWorkbench().getWorkbenchWindowCount() > 1){
                        throw new IllegalStateException("More than one workbench window");
                }
-               return (ApplicationWindow) TaxeditorStorePlugin.getDefault().getWorkbench().getWorkbenchWindows()[0];
+               return (ApplicationWindow) getWorkbench().getWorkbenchWindows()[0];
        }
        
        /**
@@ -632,4 +640,50 @@ public abstract class AbstractUtility {
        protected static String getPluginId(){
                return "eu.taxeditor";
        }
+       
+       /**
+        * <p>getActiveEditor</p>
+        *
+        * @return a {@link org.eclipse.ui.IEditorPart} object.
+        */
+       public static IEditorPart getActiveEditor(){
+               return getActivePage() != null ? getActivePage().getActiveEditor() : null;
+       }
+       
+       /**
+        * <p>getDetailsView</p>
+        *
+        * @return a {@link eu.etaxonomy.taxeditor.view.detail.DetailsViewPart} object.
+        */
+       public static DetailsViewPart getDetailsView(){
+               return  (DetailsViewPart) getView(DetailsViewPart.ID, false);
+       }
+       
+       /**
+        * <p>refreshDetailsViewer</p>
+        */
+       public static void refreshDetailsViewer(){
+               if(getDetailsView() != null){
+                       ((AbstractCdmDataViewer) getDetailsView().getViewer()).refresh();
+               }
+       }
+       
+       /**
+        * <p>reflowDetailsViewer</p>
+        */
+       public static void reflowDetailsViewer(){
+               if(getDetailsView() != null){
+                       ((AbstractCdmDataViewer) getDetailsView().getViewer()).reflow();
+               }
+       }
+       
+       public static SupplementalDataViewPart getSupplementalDataView(){
+               return (SupplementalDataViewPart) getView(SupplementalDataViewPart.ID, false);
+       }
+       
+       public static void reflowSupplementalViewer(){
+               if(getSupplementalDataView() != null){
+                       ((AbstractCdmDataViewer) getSupplementalDataView().getViewer()).reflow();
+               }
+       }
 }