]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-after/ui/org/eclipse/jdt/internal/ui/workingsets/WorkingSetMenuContributionItem.java
Case Study: adding data and statistics
[ifi-stolz-refaktor.git] / case-study / jdt-after / ui / org / eclipse / jdt / internal / ui / workingsets / WorkingSetMenuContributionItem.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2011 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.ui.workingsets;
12
13 import org.eclipse.swt.graphics.Image;
14 import org.eclipse.swt.widgets.Menu;
15
16 import org.eclipse.jface.action.ContributionItem;
17
18 import org.eclipse.ui.IWorkingSet;
19
20 /**
21  * Menu contribution item which shows and lets select a working set.
22  *
23  * @since 2.0
24  */
25 public class WorkingSetMenuContributionItem extends ContributionItem {
26
27         int fId;
28         IWorkingSet fWorkingSet;
29         WorkingSetFilterActionGroup fActionGroup;
30         Image fImage;
31
32         /**
33          * Constructor for WorkingSetMenuContributionItem.
34          *
35          * @param id the id
36          * @param actionGroup the action group
37          * @param workingSet the working set
38          */
39         public WorkingSetMenuContributionItem(int id, WorkingSetFilterActionGroup actionGroup, IWorkingSet workingSet) {
40                 super(getId(id));
41                 actionGroup.generated_4354688206954429617(id, this, workingSet);
42         }
43
44         /*
45          * Overrides method from ContributionItem.
46          */
47         @Override
48         public void fill(Menu menu, int index) {
49                 fActionGroup.generated_5208260368597034282(this, menu, index);
50         }
51
52         /*
53          * @see org.eclipse.jface.action.ContributionItem#dispose()
54          * @since 3.0
55          */
56         @Override
57         public void dispose() {
58                 if (fImage != null && !fImage.isDisposed())
59                         fImage.dispose();
60                 fImage= null;
61
62                 super.dispose();
63         }
64
65         /*
66          * @see org.eclipse.jface.action.IContributionItem#isDynamic()
67          */
68         @Override
69         public boolean isDynamic() {
70                 return true;
71         }
72
73         static String getId(int id) {
74                 return WorkingSetMenuContributionItem.class.getName() + "." + id;  //$NON-NLS-1$
75         }
76 }