Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 340565
Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/actions/CompoundContributionItem.java (-13 / +2 lines)
Lines 1-5 Link Here
1
/*******************************************************************************
1
/*******************************************************************************
2
 * Copyright (c) 2004, 2009 IBM Corporation and others.
2
 * Copyright (c) 2004, 2011 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
5
 * which accompanies this distribution, and is available at
Lines 15-23 Link Here
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.IMenuListener;
17
import org.eclipse.jface.action.IMenuManager;
17
import org.eclipse.jface.action.IMenuManager;
18
import org.eclipse.swt.SWT;
19
import org.eclipse.swt.widgets.Menu;
18
import org.eclipse.swt.widgets.Menu;
20
import org.eclipse.swt.widgets.MenuItem;
21
19
22
/**
20
/**
23
 * A compound contribution is a contribution item consisting of a
21
 * A compound contribution is a contribution item consisting of a
Lines 27-38 Link Here
27
 */
25
 */
28
public abstract class CompoundContributionItem extends ContributionItem {
26
public abstract class CompoundContributionItem extends ContributionItem {
29
27
30
    private boolean dirty = true;
31
32
    private IMenuListener menuListener = new IMenuListener() {
28
    private IMenuListener menuListener = new IMenuListener() {
33
        public void menuAboutToShow(IMenuManager manager) {
29
        public void menuAboutToShow(IMenuManager manager) {
34
            manager.markDirty();
30
            manager.markDirty();
35
            dirty = true;
36
        }
31
        }
37
    };
32
    };
38
    
33
    
Lines 61-71 Link Here
61
        if (index == -1) {
56
        if (index == -1) {
62
			index = menu.getItemCount();
57
			index = menu.getItemCount();
63
		}
58
		}
64
        if (!dirty && menu.getParentItem() != null) {
65
            // insert a dummy item so that the parent item is not disabled
66
            new MenuItem(menu, SWT.NONE, index);
67
            return;
68
        }
69
        
59
        
70
        IContributionItem[] items = getContributionItemsToFill();
60
        IContributionItem[] items = getContributionItemsToFill();
71
		if (index > menu.getItemCount()) {
61
		if (index > menu.getItemCount()) {
Lines 81-87 Link Here
81
            int numAdded = newItemCount - oldItemCount;
71
            int numAdded = newItemCount - oldItemCount;
82
            index += numAdded;
72
            index += numAdded;
83
        }
73
        }
84
        dirty = false;
85
    }
74
    }
86
    
75
    
87
    /**
76
    /**
Lines 109-115 Link Here
109
     * @see org.eclipse.jface.action.ContributionItem#isDirty()
98
     * @see org.eclipse.jface.action.ContributionItem#isDirty()
110
     */
99
     */
111
    public boolean isDirty() {
100
    public boolean isDirty() {
112
        return dirty;
101
		return true;
113
    }
102
    }
114
    
103
    
115
    /* (non-Javadoc)
104
    /* (non-Javadoc)

Return to bug 340565