p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / navigation / RecentNamesView.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 recentNamesComposite 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.core.databinding.observable.list.WritableList;
14 import org.eclipse.jface.action.IMenuManager;
15 import org.eclipse.jface.action.IToolBarManager;
16 import org.eclipse.swt.SWT;
17 import org.eclipse.swt.layout.FillLayout;
18 import org.eclipse.swt.layout.GridLayout;
19 import org.eclipse.swt.widgets.Composite;
20 import org.eclipse.swt.widgets.Display;
21 import org.eclipse.ui.part.ViewPart;
22
23 import eu.etaxonomy.cdm.model.taxon.Taxon;
24
25 /**
26 * The left navigation pane.
27 *
28 * @author p.ciardelli
29 * @created 27.05.2008
30 * @version 1.0
31 */
32 public class RecentNamesView extends ViewPart {
33 private static final Logger logger = Logger.getLogger(RecentNamesView.class);
34
35 private Composite recentNamesComposite = null;
36 public static final String ID = "eu.etaxonomy.taxeditor.navigation.recentnamesview"; //$NON-NLS-1$
37
38 /**
39 * Create contents of the view part
40 * @param parent
41 */
42 @Override
43 public void createPartControl(Composite parent) {
44
45 parent.setLayout(new FillLayout());
46 GridLayout gridLayout = new GridLayout();
47 gridLayout.horizontalSpacing = 0;
48 gridLayout.marginWidth = 0;
49 gridLayout.marginHeight = 0;
50 gridLayout.verticalSpacing = 0;
51
52 recentNamesComposite = new Composite(parent, SWT.NONE);
53 recentNamesComposite.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
54 recentNamesComposite.setLayout(new FillLayout());
55
56 new RecentNamesTableViewer(recentNamesComposite);
57
58 createActions();
59 initializeToolBar();
60 initializeMenu();
61 }
62
63 private void createActions() {
64 // Create the actions
65 }
66
67 /**
68 * Initialize the toolbar
69 */
70 private void initializeToolBar() {
71 IToolBarManager toolbarManager = getViewSite().getActionBars()
72 .getToolBarManager();
73 }
74
75 /**
76 * Initialize the menu
77 */
78 private void initializeMenu() {
79 IMenuManager menuManager = getViewSite().getActionBars()
80 .getMenuManager();
81 }
82
83 @Override
84 public void setFocus() {
85 // Set the focus
86 }
87
88 private static WritableList observableRecentNamesList = null;
89
90 public static void addRecentName(Taxon taxon) {
91 if (!getObservableRecentNames().contains(taxon)) {
92 getObservableRecentNames().add(taxon);
93 }
94 }
95
96 public static void removeRecentName(Taxon taxon) {
97 getObservableRecentNames().remove(taxon);
98 }
99
100 public static WritableList getObservableRecentNames() {
101 if (observableRecentNamesList == null) {
102 observableRecentNamesList = new WritableList();
103 }
104 return observableRecentNamesList;
105 }
106
107 public static void clearRecentNames() {
108 observableRecentNamesList = null;
109 }
110 }