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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
12 package org.eclipse.jdt.internal.ui.viewsupport;
14 import java.util.List;
16 import org.eclipse.swt.widgets.Shell;
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;
25 * History support for a view.
27 * @param <E> the type of elements managed by this history
29 public abstract class ViewHistory<E> {
32 * Configure the history List action.
33 * Clients typically want to set a text and an image.
35 * @param action the action
37 public abstract void configureHistoryListAction(IAction action);
40 * Configure the history drop down action.
41 * Clients typically want to set a tooltip and an image.
43 * @param action the action
45 public abstract void configureHistoryDropDownAction(IAction action);
48 * @return action to clear history entries, or <code>null</code>
50 public abstract Action getClearAction();
52 public abstract String getHistoryListDialogTitle();
54 public abstract String getHistoryListDialogMessage();
56 public abstract Shell getShell();
60 * @return An unmodifiable list of history entries, can be empty. The list
61 * is sorted by age, youngest first.
63 public abstract List<E> getHistoryEntries();
66 * @return the active entry from the history
68 public abstract E getCurrentEntry();
71 * @param entry the entry to activate, or <code>null</code> if none should be active
73 public abstract void setActiveEntry(E entry);
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
79 public abstract void setHistoryEntries(List<E> remainingEntries, E activeEntry);
82 * @param element the element to render
83 * @return the image descriptor for the given element, or <code>null</code>
85 public abstract ImageDescriptor getImageDescriptor(Object element);
88 * @param element the element to render
89 * @return the label text for the given element
91 public abstract String getText(E element);
94 * @return a history drop down action, ready for inclusion in a view toolbar
96 public final IAction createHistoryDropDownAction() {
97 return new HistoryDropDownAction<E>(this);
100 public abstract void addMenuEntries(MenuManager manager);
102 public abstract String getMaxEntriesMessage();
103 public abstract int getMaxEntries();
104 public abstract void setMaxEntries(int maxEntries);