editor now updatable via updateSite
[taxeditor.git] / taxeditor-navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / RecentNamesContributionItem.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.navigation;
12
13 import org.eclipse.jface.action.ContributionItem;
14 import org.eclipse.jface.action.IContributionItem;
15 import org.eclipse.jface.action.IContributionManager;
16 import org.eclipse.swt.widgets.Menu;
17 import org.eclipse.ui.actions.ContributionItemFactory;
18
19 /**
20 * This is a wrapper for Eclipse's recently opened editors functionality. IsDirty()
21 * and isDynamic() are both set to true to force redraw every time menu is opened.
22 *
23 * @author p.ciardelli
24 * @created 23.04.2009
25 * @version 1.0
26 */
27 public class RecentNamesContributionItem extends ContributionItem {
28
29 private IContributionItem recentWindows;
30 private IContributionManager parent;
31
32
33 private IContributionItem getRecentWindows() {
34 if (recentWindows == null) {
35 recentWindows = ContributionItemFactory.REOPEN_EDITORS.create(NavigationUtil.getActiveWindow());
36 recentWindows.setParent(parent);
37 }
38 return recentWindows;
39 }
40
41 /* (non-Javadoc)
42 * @see org.eclipse.jface.action.IContributionItem#dispose()
43 */
44 @Override
45 public void dispose() {
46 getRecentWindows().dispose();
47 super.dispose();
48 }
49
50 /* (non-Javadoc)
51 * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
52 */
53 @Override
54 public void fill(Menu parent, int index) {
55 getRecentWindows().fill(parent, index);
56 }
57
58 /* (non-Javadoc)
59 * @see org.eclipse.jface.action.IContributionItem#isDirty()
60 */
61 @Override
62 public boolean isDirty() {
63 return true;
64 }
65
66 /* (non-Javadoc)
67 * @see org.eclipse.jface.action.IContributionItem#isDynamic()
68 */
69 @Override
70 public boolean isDynamic() {
71 return true;
72 }
73 }