View | Details | Raw Unified | Return to bug 253002 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/actions/CompoundContributionItem.java (-12 / +29 lines)
Lines 13-23 Link Here
13
import org.eclipse.jface.action.ContributionItem;
13
import org.eclipse.jface.action.ContributionItem;
14
import org.eclipse.jface.action.IContributionItem;
14
import org.eclipse.jface.action.IContributionItem;
15
import org.eclipse.jface.action.IContributionManager;
15
import org.eclipse.jface.action.IContributionManager;
16
import org.eclipse.jface.action.IMenuListener;
16
import org.eclipse.jface.action.IMenuListener2;
17
import org.eclipse.jface.action.IMenuManager;
17
import org.eclipse.jface.action.IMenuManager;
18
import org.eclipse.swt.SWT;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.widgets.Display;
19
import org.eclipse.swt.widgets.Menu;
20
import org.eclipse.swt.widgets.Menu;
20
import org.eclipse.swt.widgets.MenuItem;
21
import org.eclipse.swt.widgets.MenuItem;
22
import org.eclipse.ui.PlatformUI;
21
23
22
/**
24
/**
23
 * A compound contribution is a contribution item consisting of a
25
 * A compound contribution is a contribution item consisting of a
Lines 29-39 Link Here
29
31
30
    private boolean dirty = true;
32
    private boolean dirty = true;
31
33
32
    private IMenuListener menuListener = new IMenuListener() {
34
	private IMenuListener2 menuListener = new IMenuListener2() {
33
        public void menuAboutToShow(IMenuManager manager) {
35
        public void menuAboutToShow(IMenuManager manager) {
34
            manager.markDirty();
36
            manager.markDirty();
35
            dirty = true;
37
            dirty = true;
36
        }
38
        }
39
40
		public void menuAboutToHide(IMenuManager manager) {
41
			disposeOldItems();
42
		}
37
    };
43
    };
38
    
44
    
39
    private IContributionItem[] oldItems;
45
    private IContributionItem[] oldItems;
Lines 91-106 Link Here
91
    protected abstract IContributionItem[] getContributionItems();
97
    protected abstract IContributionItem[] getContributionItems();
92
    
98
    
93
    private IContributionItem[] getContributionItemsToFill() {
99
    private IContributionItem[] getContributionItemsToFill() {
94
        if (oldItems != null) {
100
		oldItems = getContributionItems();
95
            for (int i = 0; i < oldItems.length; i++) {
101
		return oldItems;
96
                IContributionItem oldItem = oldItems[i];
102
	}
97
                oldItem.dispose();
103
98
            }
104
	private void disposeOldItems() {
99
            oldItems = null;
105
		if (oldItems == null) {
100
        }
106
			return;
101
        oldItems = getContributionItems();
107
		}
102
        return oldItems;
108
		final Display display = PlatformUI.getWorkbench().getDisplay();
103
    }
109
		final IContributionItem[] itemsToDispose = oldItems;
110
		oldItems = null;
111
		final Runnable dispose = new Runnable() {
112
			public void run() {
113
				for (int i = 0; i < itemsToDispose.length; i++) {
114
					IContributionItem oldItem = itemsToDispose[i];
115
					oldItem.dispose();
116
				}
117
			}
118
		};
119
		display.asyncExec(dispose);
120
	}
104
    
121
    
105
    /* (non-Javadoc)
122
    /* (non-Javadoc)
106
     * @see org.eclipse.jface.action.ContributionItem#isDirty()
123
     * @see org.eclipse.jface.action.ContributionItem#isDirty()

Return to bug 253002