KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > compare > internal > OutlineViewerCreator


1 /*******************************************************************************
2  * Copyright (c) 2007 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 package org.eclipse.compare.internal;
12
13 import org.eclipse.compare.CompareConfiguration;
14 import org.eclipse.compare.structuremergeviewer.ICompareInput;
15 import org.eclipse.core.runtime.*;
16 import org.eclipse.jface.util.IPropertyChangeListener;
17 import org.eclipse.jface.util.PropertyChangeEvent;
18 import org.eclipse.jface.viewers.Viewer;
19 import org.eclipse.swt.widgets.Composite;
20
21 /**
22  * Class which allows content merge viewer to provide a structure viewer that can be used in the outline
23  * view.
24  */

25 public abstract class OutlineViewerCreator {
26
27     /**
28      * Property constant that identifies the input of the outline view.
29      */

30     public static final String JavaDoc PROP_INPUT = "org.eclipse.compare.OutlineInput"; //$NON-NLS-1$
31

32     private ListenerList listeners = new ListenerList(ListenerList.IDENTITY);
33     
34     /**
35      * Method called by the editor to create a structure viewer for the current content merge viewer.
36      * @param oldViewer the current viewer that is being used to show the structure
37      * @param input the input
38      * @param parent the parent composite
39      * @param configuration the compare configuration
40      * @return a viewer to be placed in the outline viewer or <code>null</code>
41      */

42     public abstract Viewer findStructureViewer(Viewer oldViewer, ICompareInput input,
43             Composite parent, CompareConfiguration configuration);
44     
45     public abstract boolean hasViewerFor(Object JavaDoc input);
46     
47     public void addPropertyChangeListener(IPropertyChangeListener listener) {
48         listeners.add(listener);
49     }
50
51     public void removePropertyChangeListener(IPropertyChangeListener listener) {
52         listeners.remove(listener);
53     }
54     
55     public void fireInputChange(Object JavaDoc oldInput, Object JavaDoc newInput) {
56         Object JavaDoc[] list = listeners.getListeners();
57         final PropertyChangeEvent event = new PropertyChangeEvent(this, PROP_INPUT, oldInput, newInput);
58         for (int i = 0; i < list.length; i++) {
59             final IPropertyChangeListener listener = (IPropertyChangeListener)list[i];
60             SafeRunner.run(new ISafeRunnable() {
61                 public void run() throws Exception JavaDoc {
62                     listener.propertyChange(event);
63                 }
64                 public void handleException(Throwable JavaDoc exception) {
65                     // Logged by SafeRunner
66
}
67             });
68         }
69     }
70
71     public abstract Object JavaDoc getInput();
72
73 }
74
Popular Tags