import org.eclipse.e4.core.di.annotations.Optional;
import org.eclipse.e4.ui.di.UIEventTopic;
import org.eclipse.e4.ui.model.application.MApplication;
-import org.eclipse.e4.ui.model.application.ui.MElementContainer;
-import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
import org.eclipse.e4.ui.workbench.UIEvents;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.views.IViewDescriptor;
import org.osgi.service.event.Event;
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
+import eu.etaxonomy.taxeditor.editor.AppModelId;
import eu.etaxonomy.taxeditor.model.IContextListener;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
@Inject
private EModelService modelService;
+ @Inject
+ private EPartService partService;
+
@Inject
public LifeCycleManager() {
CdmStore.getContextManager().addContextListener(this);
}
private void hideParts() {
- List<MPart> elements = modelService.findElements(application, null, MPart.class, Arrays.asList(NON_RESTORE));
- for (MPart part : elements) {
- MElementContainer<MUIElement> parent = part.getParent();
- if(parent!=null){
- if(parent.getSelectedElement()!=null
- && parent.getSelectedElement().equals(part)){
- parent.setSelectedElement(null);
+ if (CdmStore.isActive()) {
+ try{
+ List<MPart> elements = modelService.findElements(application, null, MPart.class, Arrays.asList(NON_RESTORE));
+
+ Collection<MPart> parts = partService.getParts();
+ for (MPart element : elements) {
+ String elementId = element.getElementId();
+ for (MPart part : parts) {
+ String partID = part.getElementId();
+ if (elementId.equals(partID)){
+ partService.hidePart(part);
+ }
+ }
}
- parent.getChildren().remove(part);
+ }catch(IllegalStateException e){
+ //application does not have an active window
}
+
}
+
+
}
/**
*/
@Override
public void contextAboutToStop(IMemento memento, IProgressMonitor monitor) {
+
}
/**
@Override
public void contextStop(IMemento memento, IProgressMonitor monitor) {
hideParts();
+ if (CdmStore.isActive()){
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench
+ .getActiveWorkbenchWindow();
+ IViewDescriptor viewDescriptor = workbench.getViewRegistry().find(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_DESCRIPTIVE_E4_FACTUALDATAPARTE4);
+ if(viewDescriptor == null){
+ memento.putBoolean("facts", false);
+ }
+ viewDescriptor = workbench.getViewRegistry().find(AppModelId.PARTDESCRIPTOR_EU_ETAXONOMY_TAXEDITOR_EDITOR_VIEW_MEDIA_E4_MEDIAVIEWPARTE4);
+ if(viewDescriptor == null){
+ memento.putBoolean("media", false);
+ }
+ }
}
/**
PreferencesUtil.updateDBPreferences();
hideParts();
+
+ IWorkbench workbench = PlatformUI.getWorkbench();
+ IWorkbenchWindow window = workbench
+ .getActiveWorkbenchWindow();
if (PreferencesUtil.getBooleanValue(PreferencePredicate.ShowChecklistPerspective.getKey())){
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow window = workbench
- .getActiveWorkbenchWindow();
+
IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
IWorkbenchPage page = window.getActivePage();
page.setPerspective(registry.findPerspectiveWithId("eu.etaxonomy.taxeditor.perspective.checklistperspective"));
}else{
- IWorkbench workbench = PlatformUI.getWorkbench();
- IWorkbenchWindow window = workbench
- .getActiveWorkbenchWindow();
+
IPerspectiveRegistry registry = workbench.getPerspectiveRegistry();
IWorkbenchPage page = window.getActivePage();
page.setPerspective(registry.findPerspectiveWithId("eu.etaxonomy.taxeditor.application.perspective.taxonomic"));
+
}
+ hideParts();
+
PreferencesUtil.checkNomenclaturalCode();
}