package eu.etaxonomy.taxeditor.store;
-import java.util.UUID;
-
import org.eclipse.core.commands.operations.IOperationHistory;
import org.eclipse.core.commands.operations.IUndoContext;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
import eu.etaxonomy.cdm.common.CdmUtils;
import eu.etaxonomy.cdm.model.common.CdmBase;
import eu.etaxonomy.cdm.model.term.TermNode;
*
* @author n.hoffmann
* @created 11.05.2009
- * @version 1.0
*/
public class StoreUtil extends AbstractUtility {
- /**
- * <p>checktaxonExists</p>
- *
- * @param fromString a {@link java.util.UUID} object.
- */
- public static void checktaxonExists(UUID fromString) {
-// if (CdmStore.getTaxonService().getTaxonByUuid(UUID.fromString(uuid)) == null) {
-// logger.warn("Couldn't find taxon with UUID " + uuid);
-// return null;
-// }
- }
-
/**
* If the object given is already a {@link CdmBase} then it is returned.<br>
* If it is a kind of "container" for CDM objects then it is asked for its "responsible" CdmBase entity.<br>
throw new IllegalArgumentException("Object " + object.toString() + " is neither a CdmBase nor a CDM \"container\"");
}
- /**
- * <p>getOperationHistory</p>
- *
- * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
- */
public static IOperationHistory getOperationHistory() {
return TaxeditorStorePlugin.getDefault().getWorkbench().
getOperationSupport().getOperationHistory();
}
- /**
- * <p>setStatusLineManager</p>
- *
- * @param manager a {@link org.eclipse.jface.action.IStatusLineManager} object.
- */
public static void setStatusLineManager(IStatusLineManager manager) {
statusLineManager = manager;
}
public static void reflowParentScrolledForm(Composite composite, boolean flushCashes){
ScrolledForm scrolledForm = null;
Composite parent = composite;
- while(parent!=null && !(parent instanceof ScrolledForm)){
+ while(parent!=null && !(parent instanceof ScrolledForm) && !parent.isDisposed()){
parent = parent.getParent();
}
- scrolledForm = (ScrolledForm)parent;
+ if (parent instanceof ScrolledForm){
+ scrolledForm = (ScrolledForm)parent;
+ }else if ( parent != null && !parent.isDisposed() && parent.getParent() != null && !parent.getParent().isDisposed() &&parent.getParent() instanceof ScrolledForm ){
+ scrolledForm = (ScrolledForm)parent.getParent();
+ }
+
if(scrolledForm!=null){
- scrolledForm.reflow(flushCashes);
- scrolledForm.redraw();
+ if (!scrolledForm.isDisposed()){
+ scrolledForm.reflow(flushCashes);
+ scrolledForm.redraw();
+ }
}
}
-
- /**
- * <p>getUndoContext</p>
- *
- * @return a {@link org.eclipse.core.commands.operations.IUndoContext} object.
- */
public static IUndoContext getUndoContext(){
return IOperationHistory.GLOBAL_UNDO_CONTEXT;
}
- /**
- * <p>getPluginId</p>
- *
- * @return a {@link java.lang.String} object.
- */
public static String getPluginId(){
return TaxeditorStorePlugin.PLUGIN_ID;
}
int style = ExpandableComposite.TWISTIE;
String prefKey = getPrefKey(clazz, input);
if(PreferencesUtil.contains(prefKey)){
- style = PreferencesUtil.getStringValue(prefKey).equals(CdmSectionPart.EXPANDED)?style |= ExpandableComposite.EXPANDED:style;
+ String string = PreferencesUtil.getStringValue(prefKey, true);
+ if (string != null){
+ style = string.equals(CdmSectionPart.EXPANDED)?style |= ExpandableComposite.EXPANDED:style;
+ }else{
+ style = initiallyExpanded?style |= ExpandableComposite.EXPANDED:style;
+ }
}
else{
style = initiallyExpanded?style |= ExpandableComposite.EXPANDED:style;
return style;
}
- public static String getPath(TermNode node){
+ public static String getPath(TermNode<?> node){
String path = node.getTerm().getLabel();
- TermNode parent = node.getParent();
+ TermNode<?> parent = node.getParent();
while(parent != null && parent.getTerm()!=null){
path = parent.getTerm().getLabel() + "/" + path;
parent = parent.getParent();
text.addListener(SWT.Modify, listener);
}
}
+
+ public static Exception mergeUpdateResultExceptions(UpdateResult result) {
+ Exception t = new Exception();
+ if (result.getExceptions().size() >1){
+ for (Exception e:result.getExceptions()){
+ t.addSuppressed(e);
+ }
+ }else {
+ t = result.getExceptions().iterator().next();
+ }
+ return t;
+ }
}