upload tizen1.0 source
[sdk/ide/product.git] / org.eclipse.cdt.ui / src / org / eclipse / cdt / ui / CElementGrouping.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2010 QNX Software Systems 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  *     QNX Software Systems - Initial API and implementation
10  *     IBM Corporation
11  *******************************************************************************/
12 package org.eclipse.cdt.ui;
13
14 import org.eclipse.core.runtime.IAdaptable;
15 import org.eclipse.jface.resource.ImageDescriptor;
16 import org.eclipse.ui.model.IWorkbenchAdapter;
17 import org.eclipse.ui.model.WorkbenchAdapter;
18
19 /**
20  */
21 public abstract class CElementGrouping extends WorkbenchAdapter implements IAdaptable {
22
23         public final static int INCLUDES_GROUPING = 0x00001;
24         
25         /**
26          * @since 5.2
27          */
28         public final static int MACROS_GROUPING = 0x00011;
29         
30         public final static int NAMESPACE_GROUPING = 0x00010;
31         public final static int CLASS_GROUPING = 0x00100;
32         public final static int LIBRARY_REF_CONTAINER = 0x01000;
33         public final static int INCLUDE_REF_CONTAINER = 0x10000;
34         
35         int type;
36         
37         public CElementGrouping(int type) {
38                 this.type = type;
39         }
40
41         public int getType() {
42                 return type;
43         }
44
45         /* (non-Javadoc)
46          * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
47          */
48         @Override
49         public String getLabel(Object object) {
50                 switch (type) {
51                         case INCLUDES_GROUPING:
52                                 return Messages.CElementGrouping_includeGroupingLabel; 
53                         case MACROS_GROUPING:
54                                 return Messages.CElementGrouping_macroGroupingLabel;
55                 }
56                 return super.getLabel(object);
57         }
58
59         /* (non-Javadoc)
60          * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
61          */
62         @Override
63         public ImageDescriptor getImageDescriptor(Object object) {
64                 switch (type) {
65                         case INCLUDES_GROUPING:
66                                 return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_INCCONT);
67                         case NAMESPACE_GROUPING:
68                                 return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_NAMESPACE);
69                         case CLASS_GROUPING:
70                                 return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_CLASS);
71                         case MACROS_GROUPING:
72                                 return CDTSharedImages.getImageDescriptor(CDTSharedImages.IMG_OBJS_MACRO);
73                 }
74                 return super.getImageDescriptor(object);
75         }
76
77         /*
78          * @see org.eclipse.core.runtime.IAdaptable#getAdapter(Class)
79          */
80         @SuppressWarnings("rawtypes")
81         public Object getAdapter(Class clas) {
82                 if (clas == IWorkbenchAdapter.class)
83                         return this;
84                 return null;
85         }
86
87         /*
88          * @see java.lang.Object#toString()
89          */
90         @Override
91         public String toString() {
92                 return getLabel(null);
93         }
94 }