ref #4302 Escape '&' in section titles
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / store / StoreUtil.java
index f38ef3aa9bc696c0cc562f8e963cd87e2a5f70a2..dd3d284a8b4a5905ae215c1c89f90c42c54b6663 100644 (file)
@@ -14,8 +14,8 @@ import java.util.UUID;
 import org.eclipse.core.commands.operations.IOperationHistory;
 import org.eclipse.core.commands.operations.IUndoContext;
 import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
 
 import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
 import eu.etaxonomy.cdm.model.common.CdmBase;
@@ -87,6 +87,19 @@ public class StoreUtil extends AbstractUtility {
                statusLineManager = manager;
        }
 
+       public static void reflowParentScrolledForm(Composite composite, boolean flushCashes){
+        ScrolledForm scrolledForm = null;
+        Composite parent = composite;
+        while(parent!=null && !(parent instanceof ScrolledForm)){
+            parent = parent.getParent();
+        }
+        scrolledForm = (ScrolledForm)parent;
+        if(scrolledForm!=null){
+            scrolledForm.reflow(flushCashes);
+            scrolledForm.redraw();
+        }
+    }
+
 
        /**
         * <p>getUndoContext</p>
@@ -106,15 +119,18 @@ public class StoreUtil extends AbstractUtility {
                return TaxeditorStorePlugin.PLUGIN_ID;
        }
 
-       /**
-        *
-        * @return
-        */
-       public static IEditorInput getActiveEditorInput() {
-               IEditorPart activeEditor = getActiveEditor();
-               if (activeEditor != null){
-                       return activeEditor.getEditorInput();
-               }
-               return null;
+    /**
+     * Cleans title string for output in section titles<br>
+     * E.g. escapes '&' with "&&" to avoid mnemonic handling (see
+     * Label.setText() documentation)<br>
+     * see also #4302
+     *
+     * @param title
+     *            the title string to clean
+     * @return the cleaned title string
+     */
+       public static String cleanTitleString(String title){
+           return title.replace("&", "&&");
        }
+
 }