KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > ui > packageview > PackageExplorerProblemsDecorator


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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.jdt.internal.ui.packageview;
12
13 import org.eclipse.core.runtime.IAdaptable;
14
15 import org.eclipse.ui.IWorkingSet;
16
17 import org.eclipse.jdt.internal.ui.viewsupport.TreeHierarchyLayoutProblemsDecorator;
18
19 import org.eclipse.jdt.ui.JavaElementImageDescriptor;
20
21
22 public class PackageExplorerProblemsDecorator extends TreeHierarchyLayoutProblemsDecorator {
23
24     public PackageExplorerProblemsDecorator() {
25         super();
26     }
27     
28     public PackageExplorerProblemsDecorator(boolean isFlatLayout) {
29         super(isFlatLayout);
30     }
31     
32     protected int computeAdornmentFlags(Object JavaDoc obj) {
33         if (!(obj instanceof IWorkingSet))
34             return super.computeAdornmentFlags(obj);
35         
36         IWorkingSet workingSet= (IWorkingSet)obj;
37         IAdaptable[] elements= workingSet.getElements();
38         int result= 0;
39         for (int i= 0; i < elements.length; i++) {
40             IAdaptable element= elements[i];
41             int flags= super.computeAdornmentFlags(element);
42             if ((flags & JavaElementImageDescriptor.ERROR) != 0)
43                 return JavaElementImageDescriptor.ERROR;
44             if ((flags & JavaElementImageDescriptor.WARNING) != 0)
45                 result= JavaElementImageDescriptor.WARNING;
46         }
47         return result;
48     }
49 }
50
Popular Tags