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.apache.log4j.Logger;
|
14
|
import org.eclipse.jface.action.ContributionItem;
|
15
|
import org.eclipse.jface.action.IContributionItem;
|
16
|
import org.eclipse.jface.action.IContributionManager;
|
17
|
import org.eclipse.swt.widgets.Menu;
|
18
|
import org.eclipse.ui.actions.ContributionItemFactory;
|
19
|
import org.eclipse.ui.internal.IPreferenceConstants;
|
20
|
import org.eclipse.ui.internal.Workbench;
|
21
|
import org.eclipse.ui.internal.WorkbenchPlugin;
|
22
|
|
23
|
import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
|
24
|
import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin;
|
25
|
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
|
26
|
|
27
|
/**
|
28
|
* This is a wrapper for Eclipse's recently opened editors functionality. IsDirty()
|
29
|
* and isDynamic() are both set to true to force redraw every time menu is opened.
|
30
|
*
|
31
|
* @author p.ciardelli
|
32
|
* @created 23.04.2009
|
33
|
* @version 1.0
|
34
|
*/
|
35
|
public class RecentNamesContributionItem extends ContributionItem {
|
36
|
private static final Logger logger = Logger
|
37
|
.getLogger(RecentNamesContributionItem.class);
|
38
|
|
39
|
private IContributionItem recentWindows;
|
40
|
private IContributionManager parent;
|
41
|
|
42
|
// @SuppressWarnings("restriction")
|
43
|
// RecentNamesContributionItem() {
|
44
|
//// WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 10);
|
45
|
// TaxeditorNavigationPlugin.getDefault().getPreferenceStore().setValue("RECENT_FILES", 10);
|
46
|
// }
|
47
|
|
48
|
private IContributionItem getRecentWindows() {
|
49
|
if (recentWindows == null) {
|
50
|
|
51
|
// int itemsToShow = TaxeditorNavigationPlugin.getDefault().getPreferenceStore()
|
52
|
// .getInt("RECENT_FILES");
|
53
|
|
54
|
recentWindows = ContributionItemFactory.REOPEN_EDITORS.create(NavigationUtil.getActiveWindow());
|
55
|
recentWindows.setParent(parent);
|
56
|
}
|
57
|
return recentWindows;
|
58
|
}
|
59
|
|
60
|
/* (non-Javadoc)
|
61
|
* @see org.eclipse.jface.action.IContributionItem#dispose()
|
62
|
*/
|
63
|
/** {@inheritDoc} */
|
64
|
@Override
|
65
|
public void dispose() {
|
66
|
getRecentWindows().dispose();
|
67
|
super.dispose();
|
68
|
}
|
69
|
|
70
|
/* (non-Javadoc)
|
71
|
* @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
|
72
|
*/
|
73
|
/** {@inheritDoc} */
|
74
|
@Override
|
75
|
public void fill(Menu parent, int index) {
|
76
|
getRecentWindows().fill(parent, index);
|
77
|
}
|
78
|
|
79
|
/* (non-Javadoc)
|
80
|
* @see org.eclipse.jface.action.IContributionItem#isDirty()
|
81
|
*/
|
82
|
/** {@inheritDoc} */
|
83
|
@Override
|
84
|
public boolean isDirty() {
|
85
|
return true;
|
86
|
}
|
87
|
|
88
|
/* (non-Javadoc)
|
89
|
* @see org.eclipse.jface.action.IContributionItem#isDynamic()
|
90
|
*/
|
91
|
/** {@inheritDoc} */
|
92
|
@Override
|
93
|
public boolean isDynamic() {
|
94
|
return true;
|
95
|
}
|
96
|
}
|