aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-03-14 10:31:08 (EDT)
committerOleg Besedin2012-03-19 09:38:43 (EDT)
commitbd105d713f616ea81f3d0c9c7b93e81e306e4810 (patch)
treec4a224af33c05aa6f3a0698b6e02f6c6824e53b2
parent38a5eeacd4567683894d42c082c46f669f3a636a (diff)
downloadeclipse.platform.ui-bd105d713f616ea81f3d0c9c7b93e81e306e4810.zip
eclipse.platform.ui-bd105d713f616ea81f3d0c9c7b93e81e306e4810.tar.gz
eclipse.platform.ui-bd105d713f616ea81f3d0c9c7b93e81e306e4810.tar.bz2
Bug 373294 - Improve startup time
-rw-r--r--bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java5
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java29
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java106
3 files changed, 86 insertions, 54 deletions
diff --git a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java
index cbe9fda..1e120f9 100644
--- a/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java
+++ b/bundles/org.eclipse.e4.ui.workbench/src/org/eclipse/e4/ui/internal/workbench/ResourceHandler.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
+ * Copyright (c) 2009, 2012 IBM Corporation and others.
* 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
@@ -166,10 +166,9 @@ public class ResourceHandler implements IModelResourceHandler {
if (deltaRestore) {
resource = loadResource(applicationDefinitionInstance);
} else {
- resource = new E4XMIResource();
MApplication theApp = loadDefaultModel(applicationDefinitionInstance);
+ resource = resourceSetImpl.createResource(restoreLocation);
resource.getContents().add((EObject) theApp);
- resource.setURI(restoreLocation);
}
return resource;
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
index 256dcb6..9e48cb5 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/Workbench.java
@@ -1677,15 +1677,26 @@ UIEvents.Context.TOPIC_CONTEXT,
}
});
- MPartDescriptor descriptor = org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicFactoryImpl.eINSTANCE
- .createPartDescriptor();
- descriptor.getTags().add("Editor"); //$NON-NLS-1$
- descriptor.setCloseable(true);
- descriptor.setAllowMultiple(true);
- descriptor.setElementId(CompatibilityEditor.MODEL_ELEMENT_ID);
- descriptor.setContributionURI(CompatibilityPart.COMPATIBILITY_EDITOR_URI);
- descriptor.setCategory("org.eclipse.e4.primaryDataStack"); //$NON-NLS-1$
- application.getDescriptors().add(descriptor);
+ boolean found = false;
+ List<MPartDescriptor> currentDescriptors = application.getDescriptors();
+ for (MPartDescriptor desc : currentDescriptors) {
+ // do we have a matching descriptor?
+ if (desc.getElementId().equals(CompatibilityEditor.MODEL_ELEMENT_ID)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ MPartDescriptor descriptor = org.eclipse.e4.ui.model.application.descriptor.basic.impl.BasicFactoryImpl.eINSTANCE
+ .createPartDescriptor();
+ descriptor.getTags().add("Editor"); //$NON-NLS-1$
+ descriptor.setCloseable(true);
+ descriptor.setAllowMultiple(true);
+ descriptor.setElementId(CompatibilityEditor.MODEL_ELEMENT_ID);
+ descriptor.setContributionURI(CompatibilityPart.COMPATIBILITY_EDITOR_URI);
+ descriptor.setCategory("org.eclipse.e4.primaryDataStack"); //$NON-NLS-1$
+ application.getDescriptors().add(descriptor);
+ }
WorkbenchPlugin.getDefault().getViewRegistry();
}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java
index 142a30b..8978552 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java
@@ -82,60 +82,82 @@ public class ViewRegistry implements IViewRegistry {
for (IExtension extension : point.getExtensions()) {
for (IConfigurationElement element : extension.getConfigurationElements()) {
if (element.getName().equals(IWorkbenchRegistryConstants.TAG_VIEW)) {
- MPartDescriptor descriptor = BasicFactoryImpl.eINSTANCE.createPartDescriptor();
- descriptor.setLabel(element.getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
String id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID);
- descriptor.setElementId(id);
- if (id.equals(IPageLayout.ID_RES_NAV)
- || id.equals(IPageLayout.ID_PROJECT_EXPLORER)) {
- descriptor.setCategory("org.eclipse.e4.primaryNavigationStack"); //$NON-NLS-1$
- } else if (id.equals(IPageLayout.ID_OUTLINE)) {
- descriptor.setCategory("org.eclipse.e4.secondaryNavigationStack"); //$NON-NLS-1$
- } else {
- descriptor.setCategory("org.eclipse.e4.secondaryDataStack"); //$NON-NLS-1$
+ MPartDescriptor descriptor = null;
+ List<MPartDescriptor> currentDescriptors = application.getDescriptors();
+ for (MPartDescriptor desc : currentDescriptors) {
+ // do we have a matching descriptor?
+ if (desc.getElementId().equals(id)) {
+ descriptor = desc;
+ break;
+ }
}
+ ViewCategory category = null;
+ if (descriptor == null) { // create a new descriptor
+ descriptor = BasicFactoryImpl.eINSTANCE.createPartDescriptor();
+ descriptor.setLabel(element
+ .getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
+ descriptor.setElementId(id);
+ if (id.equals(IPageLayout.ID_RES_NAV)
+ || id.equals(IPageLayout.ID_PROJECT_EXPLORER)) {
+ descriptor.setCategory("org.eclipse.e4.primaryNavigationStack"); //$NON-NLS-1$
+ } else if (id.equals(IPageLayout.ID_OUTLINE)) {
+ descriptor.setCategory("org.eclipse.e4.secondaryNavigationStack"); //$NON-NLS-1$
+ } else {
+ descriptor.setCategory("org.eclipse.e4.secondaryDataStack"); //$NON-NLS-1$
+ }
+
+ List<String> tags = descriptor.getTags();
+ tags.add("View"); //$NON-NLS-1$
+
+ descriptor.setCloseable(true);
+ descriptor.setAllowMultiple(Boolean.parseBoolean(element
+ .getAttribute(IWorkbenchRegistryConstants.ATT_ALLOW_MULTIPLE)));
+ descriptor.setContributionURI(CompatibilityPart.COMPATIBILITY_VIEW_URI);
+
+ String iconURI = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
+ if (iconURI == null) {
+ descriptor.setIconURI(MenuHelper.getImageUrl(workbench
+ .getSharedImages().getImageDescriptor(
+ ISharedImages.IMG_DEF_VIEW)));
+ } else if (!iconURI.startsWith("platform:/plugin/")) { //$NON-NLS-1$
+ StringBuilder builder = new StringBuilder("platform:/plugin/"); //$NON-NLS-1$
+ builder.append(element.getContributor().getName()).append('/');
+
+ // FIXME: need to get rid of $nl$ properly
+ if (iconURI.startsWith("$nl$")) { //$NON-NLS-1$
+ iconURI = iconURI.substring(4);
+ }
+
+ builder.append(iconURI);
+ descriptor.setIconURI(builder.toString());
+ } else {
+ descriptor.setIconURI(iconURI);
+ }
- List<String> tags = descriptor.getTags();
- tags.add("View"); //$NON-NLS-1$
-
- descriptor.setCloseable(true);
- descriptor.setAllowMultiple(Boolean.parseBoolean(element
- .getAttribute(IWorkbenchRegistryConstants.ATT_ALLOW_MULTIPLE)));
- descriptor.setContributionURI(CompatibilityPart.COMPATIBILITY_VIEW_URI);
-
- String iconURI = element.getAttribute(IWorkbenchRegistryConstants.ATT_ICON);
- if (iconURI == null) {
- descriptor.setIconURI(MenuHelper.getImageUrl(workbench.getSharedImages()
- .getImageDescriptor(ISharedImages.IMG_DEF_VIEW)));
- } else if (!iconURI.startsWith("platform:/plugin/")) { //$NON-NLS-1$
- StringBuilder builder = new StringBuilder("platform:/plugin/"); //$NON-NLS-1$
- builder.append(element.getContributor().getName()).append('/');
-
- // FIXME: need to get rid of $nl$ properly
- if (iconURI.startsWith("$nl$")) { //$NON-NLS-1$
- iconURI = iconURI.substring(4);
+ String categoryId = element
+ .getAttribute(IWorkbenchRegistryConstants.ATT_CATEGORY);
+ category = findCategory(categoryId);
+ if (category == null) {
+ tags.add("categoryTag:" + WorkbenchMessages.ICategory_other); //$NON-NLS-1$
+ } else {
+ tags.add("categoryTag:" + category.getLabel()); //$NON-NLS-1$
}
- builder.append(iconURI);
- descriptor.setIconURI(builder.toString());
- } else {
- descriptor.setIconURI(iconURI);
+ application.getDescriptors().add(descriptor);
}
ViewDescriptor viewDescriptor = new ViewDescriptor(application, descriptor,
element);
-
- application.getDescriptors().add(descriptor);
descriptors.put(descriptor.getElementId(), viewDescriptor);
- String categoryId = element
- .getAttribute(IWorkbenchRegistryConstants.ATT_CATEGORY);
- ViewCategory category = findCategory(categoryId);
-
if (category == null) {
- tags.add("categoryTag:" + WorkbenchMessages.ICategory_other); //$NON-NLS-1$
- } else {
- tags.add("categoryTag:" + category.getLabel()); //$NON-NLS-1$
+ String categoryId = element
+ .getAttribute(IWorkbenchRegistryConstants.ATT_CATEGORY);
+ category = findCategory(categoryId);
+ }
+
+ if (category != null) {
category.addDescriptor(viewDescriptor);
}
}