]> git.uio.no Git - ifi-stolz-refaktor.git/blob - case-study/jdt-before/ui/org/eclipse/jdt/internal/ui/viewsupport/ViewHistory.java
3b81eb7907a1c33b16c5032950f767300dcc9b51
[ifi-stolz-refaktor.git] / case-study / jdt-before / ui / org / eclipse / jdt / internal / ui / viewsupport / ViewHistory.java
1 /*******************************************************************************
2  * Copyright (c) 2006, 2011 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11
12 package org.eclipse.jdt.internal.ui.viewsupport;
13
14 import java.util.List;
15
16 import org.eclipse.swt.widgets.Shell;
17
18 import org.eclipse.jface.action.Action;
19 import org.eclipse.jface.action.IAction;
20 import org.eclipse.jface.action.MenuManager;
21 import org.eclipse.jface.resource.ImageDescriptor;
22
23
24 /**
25  * History support for a view.
26  * 
27  * @param <E> the type of elements managed by this history
28  */
29 public abstract class ViewHistory<E> {
30
31         /**
32          * Configure the history List action.
33          * Clients typically want to set a text and an image.
34          *
35          * @param action the action
36          */
37         public abstract void configureHistoryListAction(IAction action);
38
39         /**
40          * Configure the history drop down action.
41          * Clients typically want to set a tooltip and an image.
42          *
43          * @param action the action
44          */
45         public abstract void configureHistoryDropDownAction(IAction action);
46
47         /**
48          * @return action to clear history entries, or <code>null</code>
49          */
50         public abstract Action getClearAction();
51
52         public abstract String getHistoryListDialogTitle();
53
54         public abstract String getHistoryListDialogMessage();
55
56         public abstract Shell getShell();
57
58
59         /**
60          * @return An unmodifiable list of history entries, can be empty. The list
61          *         is sorted by age, youngest first.
62          */
63         public abstract List<E> getHistoryEntries();
64
65         /**
66          * @return the active entry from the history
67          */
68         public abstract E getCurrentEntry();
69
70         /**
71          * @param entry the entry to activate, or <code>null</code> if none should be active
72          */
73         public abstract void setActiveEntry(E entry);
74
75         /**
76          * @param remainingEntries all the remaining history entries, can be empty
77          * @param activeEntry the entry to activate, or <code>null</code> if none should be active
78          */
79         public abstract void setHistoryEntries(List<E> remainingEntries, E activeEntry);
80
81         /**
82          * @param element the element to render
83          * @return the image descriptor for the given element, or <code>null</code>
84          */
85         public abstract ImageDescriptor getImageDescriptor(Object element);
86
87         /**
88          * @param element the element to render
89          * @return the label text for the given element
90          */
91         public abstract String getText(E element);
92
93         /**
94          * @return a history drop down action, ready for inclusion in a view toolbar
95          */
96         public final IAction createHistoryDropDownAction() {
97                 return new HistoryDropDownAction<E>(this);
98         }
99
100         public abstract void addMenuEntries(MenuManager manager);
101
102         public abstract String getMaxEntriesMessage();
103         public abstract int getMaxEntries();
104         public abstract void setMaxEntries(int maxEntries);
105
106 }