Read conditions before reading commands. Assure that conditions are applied
when commands are being obtained so that they can depend on OS, etc.
This is a fix of issue #45974.
1.1 --- a/vcs.advanced/src/org/netbeans/modules/vcs/advanced/globalcommands/GlobalExecutionContext.java Mon Jul 12 13:46:45 2004 +0000
1.2 +++ b/vcs.advanced/src/org/netbeans/modules/vcs/advanced/globalcommands/GlobalExecutionContext.java Mon Jul 12 15:52:56 2004 +0000
1.3 @@ -44,6 +44,7 @@
1.4
1.5 import org.netbeans.modules.vcs.advanced.CommandLineVcsFileSystem;
1.6 import org.netbeans.modules.vcs.advanced.Profile;
1.7 +import org.netbeans.modules.vcs.advanced.variables.Condition;
1.8 import org.netbeans.modules.vcs.advanced.variables.ConditionedVariables;
1.9
1.10 /**
1.11 @@ -195,7 +196,26 @@
1.12 if (commandsRoot == null) {
1.13 Profile profile = (Profile) profileRef.get();
1.14 if (profile != null) {
1.15 - profile.preLoadContent(false, false, false, true);
1.16 + if (variables == null) {
1.17 + // It's too expensive to load all variables, obtaining of commands must be fast,
1.18 + // because a GUI menu is created from them. Therefore conditions used in
1.19 + // global commands are resolved according to defined conditions, not variables.
1.20 + // This should be sufficient anyway.
1.21 + profile.preLoadContent(true, false, false, true);
1.22 + Condition[] conditions = profile.getConditions();
1.23 + if (conditions != null) {
1.24 + for (int i = 0; i < conditions.length; i++) {
1.25 + String name = conditions[i].getName();
1.26 + if (conditions[i].isSatisfied(variablesByNames)) {
1.27 + variablesByNames.put(name, Boolean.TRUE.toString());
1.28 + } else {
1.29 + variablesByNames.remove(name);
1.30 + }
1.31 + }
1.32 + }
1.33 + } else {
1.34 + profile.preLoadContent(false, false, false, true);
1.35 + }
1.36 setCommands(copySharedCommands(profile.getGlobalCommands().getCommands(variablesByNames)));
1.37 }
1.38 }