ref #4611 german i18n for taxeditor.navigator plugin
[taxeditor.git] / eu.etaxonomy.taxeditor.navigation / src / main / java / eu / etaxonomy / taxeditor / navigation / RecentNamesContributionItem.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9
10 package eu.etaxonomy.taxeditor.navigation;
11
12 import org.apache.log4j.Logger;
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 import org.eclipse.ui.internal.IPreferenceConstants;
19 import org.eclipse.ui.internal.Workbench;
20 import org.eclipse.ui.internal.WorkbenchPlugin;
21
22 import eu.etaxonomy.taxeditor.editor.internal.TaxeditorEditorPlugin;
23 import eu.etaxonomy.taxeditor.navigation.internal.TaxeditorNavigationPlugin;
24 import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
25
26 /**
27 * This is a wrapper for Eclipse's recently opened editors functionality. IsDirty()
28 * and isDynamic() are both set to true to force redraw every time menu is opened.
29 *
30 * @author p.ciardelli
31 * @created 23.04.2009
32 * @version 1.0
33 */
34 public class RecentNamesContributionItem extends ContributionItem {
35 private static final Logger logger = Logger
36 .getLogger(RecentNamesContributionItem.class);
37
38 private IContributionItem recentWindows;
39 private IContributionManager parent;
40
41 // @SuppressWarnings("restriction")
42 // RecentNamesContributionItem() {
43 //// WorkbenchPlugin.getDefault().getPreferenceStore().setValue(IPreferenceConstants.RECENT_FILES, 10);
44 // TaxeditorNavigationPlugin.getDefault().getPreferenceStore().setValue("RECENT_FILES", 10);
45 // }
46
47 private IContributionItem getRecentWindows() {
48 if (recentWindows == null) {
49
50 // int itemsToShow = TaxeditorNavigationPlugin.getDefault().getPreferenceStore()
51 // .getInt("RECENT_FILES");
52
53 recentWindows = ContributionItemFactory.REOPEN_EDITORS.create(NavigationUtil.getActiveWindow());
54 recentWindows.setParent(parent);
55 }
56 return recentWindows;
57 }
58
59 /* (non-Javadoc)
60 * @see org.eclipse.jface.action.IContributionItem#dispose()
61 */
62 /** {@inheritDoc} */
63 @Override
64 public void dispose() {
65 getRecentWindows().dispose();
66 super.dispose();
67 }
68
69 /* (non-Javadoc)
70 * @see org.eclipse.jface.action.IContributionItem#fill(org.eclipse.swt.widgets.Menu, int)
71 */
72 /** {@inheritDoc} */
73 @Override
74 public void fill(Menu parent, int index) {
75 // getRecentWindows().fill(parent, index);
76 }
77
78 /* (non-Javadoc)
79 * @see org.eclipse.jface.action.IContributionItem#isDirty()
80 */
81 /** {@inheritDoc} */
82 @Override
83 public boolean isDirty() {
84 return true;
85 }
86
87 /* (non-Javadoc)
88 * @see org.eclipse.jface.action.IContributionItem#isDynamic()
89 */
90 /** {@inheritDoc} */
91 @Override
92 public boolean isDynamic() {
93 return true;
94 }
95 }