Lines 29-35
Link Here
|
29 |
public class ActionPresentation { |
29 |
public class ActionPresentation { |
30 |
private WorkbenchWindow window; |
30 |
private WorkbenchWindow window; |
31 |
private HashMap mapDescToRec = new HashMap(3); |
31 |
private HashMap mapDescToRec = new HashMap(3); |
32 |
|
32 |
private HashMap invisibleBars = new HashMap(3); |
|
|
33 |
|
33 |
private class SetRec { |
34 |
private class SetRec { |
34 |
public SetRec(IActionSetDescriptor desc, IActionSet set, |
35 |
public SetRec(IActionSetDescriptor desc, IActionSet set, |
35 |
SubActionBars bars) { |
36 |
SubActionBars bars) { |
Lines 78-83
Link Here
|
78 |
SetRec rec = (SetRec)mapDescToRec.get(desc); |
79 |
SetRec rec = (SetRec)mapDescToRec.get(desc); |
79 |
if (rec != null) { |
80 |
if (rec != null) { |
80 |
mapDescToRec.remove(desc); |
81 |
mapDescToRec.remove(desc); |
|
|
82 |
// Remove from the map that stores invisible bars |
83 |
invisibleBars.remove(desc); |
81 |
IActionSet set = rec.set; |
84 |
IActionSet set = rec.set; |
82 |
SubActionBars bars = rec.bars; |
85 |
SubActionBars bars = rec.bars; |
83 |
if (bars != null) { |
86 |
if (bars != null) { |
Lines 103-117
Link Here
|
103 |
if (!newList.contains(desc)) { |
106 |
if (!newList.contains(desc)) { |
104 |
SetRec rec = (SetRec)mapDescToRec.get(desc); |
107 |
SetRec rec = (SetRec)mapDescToRec.get(desc); |
105 |
if (rec != null) { |
108 |
if (rec != null) { |
|
|
109 |
mapDescToRec.remove(desc); |
106 |
IActionSet set = rec.set; |
110 |
IActionSet set = rec.set; |
107 |
SubActionBars bars = rec.bars; |
111 |
SubActionBars bars = rec.bars; |
108 |
if (bars != null) { |
112 |
if (bars != null) { |
|
|
113 |
SetRec invisibleRec = new SetRec(desc, set, bars); |
114 |
invisibleBars.put(desc,invisibleRec); |
109 |
bars.deactivate(); |
115 |
bars.deactivate(); |
110 |
} |
116 |
} |
111 |
if (set != null) { |
|
|
112 |
set.dispose(); |
113 |
} |
114 |
rec.set = null; |
115 |
} |
117 |
} |
116 |
} |
118 |
} |
117 |
} |
119 |
} |
Lines 123-155
Link Here
|
123 |
IActionSetDescriptor desc = (IActionSetDescriptor)iter.next(); |
125 |
IActionSetDescriptor desc = (IActionSetDescriptor)iter.next(); |
124 |
if (!mapDescToRec.containsKey(desc)) { |
126 |
if (!mapDescToRec.containsKey(desc)) { |
125 |
try { |
127 |
try { |
126 |
IActionSet set = desc.createActionSet(); |
128 |
SetRec rec; |
127 |
SubActionBars bars = new ActionSetActionBars(window.getActionBars(), |
129 |
// If the action bars and sets have already been created then |
128 |
desc.getId()); |
130 |
// reuse those action sets |
129 |
SetRec rec = new SetRec(desc, set, bars); |
131 |
if (invisibleBars.containsKey(desc)) { |
|
|
132 |
rec = (SetRec)invisibleBars.get(desc); |
133 |
if (rec.bars != null) { |
134 |
rec.bars.activate(); |
135 |
} |
136 |
invisibleBars.remove(desc); |
137 |
}else { |
138 |
IActionSet set = desc.createActionSet(); |
139 |
SubActionBars bars = new ActionSetActionBars(window.getActionBars(), |
140 |
desc.getId()); |
141 |
rec = new SetRec(desc, set, bars); |
142 |
set.init(window, bars); |
143 |
sets.add(set); |
144 |
} |
130 |
mapDescToRec.put(desc, rec); |
145 |
mapDescToRec.put(desc, rec); |
131 |
set.init(window, bars); |
|
|
132 |
sets.add(set); |
133 |
bars.activate(); |
134 |
} catch (CoreException e) { |
146 |
} catch (CoreException e) { |
135 |
WorkbenchPlugin.log("Unable to create ActionSet: " + desc.getId());//$NON-NLS-1$ |
147 |
WorkbenchPlugin.log("Unable to create ActionSet: " + desc.getId());//$NON-NLS-1$ |
136 |
} |
148 |
} |
137 |
}else { |
|
|
138 |
SetRec rec = (SetRec)mapDescToRec.get(desc); |
139 |
IActionSet set = rec.set; |
140 |
SubActionBars bars = rec.bars; |
141 |
if (set == null) { |
142 |
try { |
143 |
bars.activate(); |
144 |
set = desc.createActionSet(); |
145 |
set.init(window,bars); |
146 |
rec.set = set; |
147 |
} catch (CoreException e) { |
148 |
WorkbenchPlugin.log("Unable to create ActionSet: " + desc.getId());//$NON-NLS-1$ |
149 |
} |
150 |
} |
151 |
|
152 |
|
153 |
} |
149 |
} |
154 |
} |
150 |
} |
155 |
// We process action sets in two passes for coolbar purposes. First we process base contributions |
151 |
// We process action sets in two passes for coolbar purposes. First we process base contributions |