aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Besedin2012-03-15 14:07:33 (EDT)
committerOleg Besedin2012-03-19 09:39:03 (EDT)
commit02f167505cf2db0746453efbc26291832f045a2d (patch)
tree0ef9063bc94e37848a2b9f7ee4da7794f3928162
parent884b73ac201456cb81617acf0d87728bfa0c61e1 (diff)
downloadeclipse.platform.ui-02f167505cf2db0746453efbc26291832f045a2d.zip
eclipse.platform.ui-02f167505cf2db0746453efbc26291832f045a2d.tar.gz
eclipse.platform.ui-02f167505cf2db0746453efbc26291832f045a2d.tar.bz2
Bug 373294 - Improve startup time
-rw-r--r--bundles/org.eclipse.e4.core.contexts.debug/src/org/eclipse/e4/core/internal/contexts/debug/ui/e4/ContextsDebugProcessor.java2
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java69
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java76
-rw-r--r--bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java99
4 files changed, 100 insertions, 146 deletions
diff --git a/bundles/org.eclipse.e4.core.contexts.debug/src/org/eclipse/e4/core/internal/contexts/debug/ui/e4/ContextsDebugProcessor.java b/bundles/org.eclipse.e4.core.contexts.debug/src/org/eclipse/e4/core/internal/contexts/debug/ui/e4/ContextsDebugProcessor.java
index 11a2f6a..9454e2a 100644
--- a/bundles/org.eclipse.e4.core.contexts.debug/src/org/eclipse/e4/core/internal/contexts/debug/ui/e4/ContextsDebugProcessor.java
+++ b/bundles/org.eclipse.e4.core.contexts.debug/src/org/eclipse/e4/core/internal/contexts/debug/ui/e4/ContextsDebugProcessor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2011 IBM Corporation and others.
+ * Copyright (c) 2010, 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
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
index d587832..9d267fa 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/BindingToModelProcessor.java
@@ -16,7 +16,6 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.eclipse.core.commands.CommandManager;
-import org.eclipse.core.commands.ParameterizedCommand;
import org.eclipse.core.commands.contexts.ContextManager;
import org.eclipse.e4.core.di.annotations.Execute;
import org.eclipse.e4.ui.bindings.EBindingService;
@@ -25,19 +24,14 @@ import org.eclipse.e4.ui.model.application.commands.MBindingContext;
import org.eclipse.e4.ui.model.application.commands.MBindingTable;
import org.eclipse.e4.ui.model.application.commands.MCommand;
import org.eclipse.e4.ui.model.application.commands.MCommandsFactory;
-import org.eclipse.e4.ui.model.application.commands.MKeyBinding;
-import org.eclipse.e4.ui.model.application.commands.MParameter;
import org.eclipse.e4.ui.model.application.commands.impl.CommandsFactoryImpl;
import org.eclipse.jface.bindings.Binding;
import org.eclipse.jface.bindings.BindingManager;
import org.eclipse.ui.internal.commands.CommandPersistence;
import org.eclipse.ui.internal.contexts.ContextPersistence;
import org.eclipse.ui.internal.keys.BindingPersistence;
+import org.eclipse.ui.internal.keys.BindingService;
-/**
- *
- *
- */
public class BindingToModelProcessor {
private Map<String, MBindingContext> contexts = new HashMap<String, MBindingContext>();
@@ -64,7 +58,7 @@ public class BindingToModelProcessor {
application.getTags().add(
EBindingService.ACTIVE_SCHEME_TAG + ':' + bindingManager.getActiveScheme().getId());
- Collection activeBindingsForScheme = bindingManager
+ Collection<?> activeBindingsForScheme = bindingManager
.getActiveBindingsDisregardingContextFlat();
for (Object obj : activeBindingsForScheme) {
@@ -75,9 +69,6 @@ public class BindingToModelProcessor {
persistence.dispose();
}
- /**
- * @param bindingTables
- */
private void gatherTables(List<MBindingTable> bindingTables) {
for (MBindingTable table : bindingTables) {
tables.put(table.getBindingContext().getElementId(), table);
@@ -86,49 +77,12 @@ public class BindingToModelProcessor {
public final void addBinding(final MApplication application, final Binding binding) {
+
MBindingTable table = tables.get(binding.getContextId());
if (table == null) {
table = createTable(application, binding.getContextId());
}
- final MKeyBinding keyBinding = CommandsFactoryImpl.eINSTANCE.createKeyBinding();
- ParameterizedCommand parmCmd = binding.getParameterizedCommand();
-
- MCommand cmd = commands.get(parmCmd.getId());
- if (cmd == null) {
- return;
- }
- keyBinding.setCommand(cmd);
- keyBinding.setKeySequence(binding.getTriggerSequence().format());
- for (Object obj : parmCmd.getParameterMap().entrySet()) {
- Map.Entry entry = (Map.Entry) obj;
- MParameter p = CommandsFactoryImpl.eINSTANCE.createParameter();
- p.setElementId((String) entry.getKey());
- p.setName((String) entry.getKey());
- p.setValue((String) entry.getValue());
- keyBinding.getParameters().add(p);
- }
-
- List<String> tags = keyBinding.getTags();
- // just add the 'schemeId' tag if it's anything other than the default
- // scheme id
- if (binding.getSchemeId() != null
- && !binding.getSchemeId().equals(
- org.eclipse.ui.keys.IBindingService.DEFAULT_DEFAULT_ACTIVE_SCHEME_ID)) {
- tags.add(EBindingService.SCHEME_ID_ATTR_TAG + ":" + binding.getSchemeId()); //$NON-NLS-1$
- }
- if (binding.getLocale() != null) {
- tags.add(EBindingService.LOCALE_ATTR_TAG + ":" + binding.getLocale()); //$NON-NLS-1$
- }
- if (binding.getPlatform() != null) {
- tags.add(EBindingService.PLATFORM_ATTR_TAG + ":" + binding.getPlatform()); //$NON-NLS-1$
- }
- // just add the 'type' tag if it's a user binding
- if (binding.getType() == Binding.USER) {
- tags.add(EBindingService.TYPE_ATTR_TAG + ":user"); //$NON-NLS-1$
- }
-
- keyBinding.getTransientData().put(EBindingService.MODEL_TO_BINDING_KEY, binding);
- table.getBindings().add(keyBinding);
+ BindingService.createORupdateMKeyBinding(application, table, binding);
}
public MBindingContext getBindingContext(MApplication application, String id) {
@@ -151,11 +105,6 @@ public class BindingToModelProcessor {
return result;
}
- /**
- * @param id
- * @param rootContext
- * @return
- */
private MBindingContext searchContexts(String id, List<MBindingContext> rootContext) {
for (MBindingContext context : rootContext) {
if (context.getElementId().equals(id)) {
@@ -169,10 +118,6 @@ public class BindingToModelProcessor {
return null;
}
- /**
- * @param contextId
- * @return
- */
private MBindingTable createTable(MApplication application, String contextId) {
MBindingTable table = CommandsFactoryImpl.eINSTANCE.createBindingTable();
table.setBindingContext(getBindingContext(application, contextId));
@@ -182,9 +127,6 @@ public class BindingToModelProcessor {
return table;
}
- /**
- * @param commands
- */
private void gatherCommands(List<MCommand> commandList) {
for (MCommand cmd : commandList) {
commands.put(cmd.getElementId(), cmd);
@@ -197,9 +139,6 @@ public class BindingToModelProcessor {
}
}
- /**
- * @param ctx
- */
private void gatherContexts(MBindingContext ctx) {
if (ctx == null) {
return;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java
index 9292e3f..74fca24 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/keys/BindingService.java
@@ -375,15 +375,6 @@ public final class BindingService implements IBindingService {
bp.read();
}
- private MCommand findCommand(String id) {
- for (MCommand cmd : application.getCommands()) {
- if (id.equals(cmd.getElementId())) {
- return cmd;
- }
- }
- return null;
- }
-
private void saveLegacyPreferences(Scheme activeScheme, Binding[] bindings) throws IOException {
BindingPersistence.write(activeScheme, bindings);
try {
@@ -645,10 +636,7 @@ public final class BindingService implements IBindingService {
*/
public final void addBinding(final Binding binding) {
MBindingTable table = getMTable(binding.getContextId());
- MKeyBinding keyBinding = createMKeyBinding(binding);
- if (keyBinding != null) {
- table.getBindings().add(keyBinding);
- }
+ createORupdateMKeyBinding(application, table, binding);
}
/**
@@ -671,26 +659,64 @@ public final class BindingService implements IBindingService {
}
- private MKeyBinding createMKeyBinding(Binding binding) {
- final MKeyBinding keyBinding = CommandsFactoryImpl.eINSTANCE.createKeyBinding();
-
+ // TBD the "update" procedure should not typically be run.
+ // Add some sort of timestamp on the source files and update
+ // only when it changes
+ // TBD placement: this should be in the "3.x bridge" code
+ static public MKeyBinding createORupdateMKeyBinding(MApplication application,
+ MBindingTable table,
+ Binding binding) {
ParameterizedCommand parmCmd = binding.getParameterizedCommand();
- MCommand cmd = findCommand(parmCmd.getId());
+ String id = parmCmd.getId();
+ MCommand cmd = null;
+ for (MCommand appCommand : application.getCommands()) {
+ if (id.equals(appCommand.getElementId())) {
+ cmd = appCommand;
+ break;
+ }
+ }
if (cmd == null) {
return null;
}
- keyBinding.setCommand(cmd);
- // keyBinding.setKeySequence(binding.getTriggerSequence().format());
+
+ MKeyBinding keyBinding = null;
+ for (MKeyBinding existingBinding : table.getBindings()) {
+ if (cmd.equals(existingBinding.getCommand())) {
+ keyBinding = existingBinding;
+ break;
+ }
+ }
+
+ if (keyBinding == null) {
+ keyBinding = CommandsFactoryImpl.eINSTANCE.createKeyBinding();
+ keyBinding.setCommand(cmd);
+ table.getBindings().add(keyBinding);
+ }
keyBinding.setKeySequence(binding.getTriggerSequence().format());
for (Object obj : parmCmd.getParameterMap().entrySet()) {
- Map.Entry entry = (Map.Entry) obj;
- MParameter p = CommandsFactoryImpl.eINSTANCE.createParameter();
- p.setElementId((String) entry.getKey());
- p.setName((String) entry.getKey());
- p.setValue((String) entry.getValue());
- keyBinding.getParameters().add(p);
+ @SuppressWarnings({ "unchecked" })
+ Map.Entry<String, String> entry = (Map.Entry<String, String>) obj;
+
+ String paramID = entry.getKey();
+ if (paramID == null)
+ continue;
+ List<MParameter> bindingParams = keyBinding.getParameters();
+ MParameter p = null;
+ for (MParameter param : bindingParams) {
+ if (paramID.equals(param.getElementId())) {
+ p = param;
+ break;
+ }
+ }
+ if (p == null) {
+ p = CommandsFactoryImpl.eINSTANCE.createParameter();
+ p.setElementId(entry.getKey());
+ keyBinding.getParameters().add(p);
+ }
+ p.setName(entry.getKey());
+ p.setValue(entry.getValue());
}
List<String> tags = keyBinding.getTags();
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 8978552..206ef4b 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
@@ -95,71 +95,60 @@ public class ViewRegistry implements IViewRegistry {
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$
- }
+ application.getDescriptors().add(descriptor);
+ }
+ // ==> Update descriptor
+ descriptor.setLabel(element.getAttribute(IWorkbenchRegistryConstants.ATT_NAME));
+ 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);
+ 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$
}
+ // ==> End of update descriptor
ViewDescriptor viewDescriptor = new ViewDescriptor(application, descriptor,
element);
descriptors.put(descriptor.getElementId(), viewDescriptor);
-
- if (category == null) {
- String categoryId = element
- .getAttribute(IWorkbenchRegistryConstants.ATT_CATEGORY);
- category = findCategory(categoryId);
- }
-
- if (category != null) {
- category.addDescriptor(viewDescriptor);
- }
}
}
}