blob: 754d64f68e4681f726c734501a0c6249ee705dab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
/*******************************************************************************
* Copyright (c) 2010 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.commons.repositories.ui;
import org.eclipse.jface.action.ContributionItem;
import org.eclipse.jface.action.IContributionItem;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.actions.ContributionItemFactory;
/**
* @author Steffen Pingel
*/
public class ShowInMenuContribution extends ContributionItem {
private IContributionItem item;
public ShowInMenuContribution() {
}
public ShowInMenuContribution(String id) {
super(id);
}
@Override
public void fill(Menu menu, int index) {
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
if (item != null) {
item.dispose();
}
item = ContributionItemFactory.VIEWS_SHOW_IN.create(window);
item.fill(menu, index);
}
}
@Override
public void dispose() {
if (item != null) {
item.dispose();
item = null;
}
super.dispose();
}
}
|