KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > progress > ProgressContentProvider


1 /*******************************************************************************
2  * Copyright (c) 2003, 2006 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.ui.internal.progress;
12
13 import org.eclipse.jface.viewers.IStructuredContentProvider;
14 import org.eclipse.jface.viewers.Viewer;
15
16 /**
17  * The ProgressContentProvider is the content provider used for classes that
18  * listen to the progress changes.
19  */

20 public abstract class ProgressContentProvider implements
21         IProgressUpdateCollector, IStructuredContentProvider {
22
23     /**
24      * Return whether or not we check the preferences or overide.
25      */

26     private boolean canShowDebug = false;
27
28     /**
29      * Create a new instance of the receiver with all of the
30      * default values.
31      */

32     public ProgressContentProvider() {
33         ProgressViewUpdater.getSingleton().addCollector(this);
34     }
35
36     /**
37      * Create a new instance of the receiver with a flag to
38      * indicate if there will be debug info shown or not.
39      * @param debug If true debug information will be shown
40      * if the debug flag in the ProgressManager is true.
41      */

42     public ProgressContentProvider(boolean debug) {
43         this();
44         canShowDebug = debug;
45     }
46
47     /*
48      * (non-Javadoc)
49      *
50      * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
51      */

52     public Object JavaDoc[] getElements(Object JavaDoc inputElement) {
53
54         return ProgressManager.getInstance().getRootElements(debug());
55     }
56
57     /*
58      * (non-Javadoc)
59      *
60      * @see org.eclipse.jface.viewers.IContentProvider#dispose()
61      */

62     public void dispose() {
63         ProgressViewUpdater.getSingleton().removeCollector(this);
64     }
65
66     /*
67      * (non-Javadoc)
68      *
69      * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer,
70      * java.lang.Object, java.lang.Object)
71      */

72     public void inputChanged(Viewer viewer, Object JavaDoc oldInput, Object JavaDoc newInput) {
73         //No change when input changes
74
}
75     
76     /**
77      * Return whether or not we are debugging. Check the
78      * system settings unless we are overiding them.
79      * @return boolean <code>true</code> if debug
80      * (system) jobs are being shown.
81      */

82     public boolean debug(){
83         if(!canShowDebug) {
84             return false;
85         }
86         return ProgressViewUpdater.getSingleton().debug;
87         
88     }
89
90 }
91
Popular Tags