KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > intro > universal > ExtensionData


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.intro.universal;
12
13 import java.io.PrintWriter JavaDoc;
14
15 public class ExtensionData extends BaseData {
16
17     public static final int HIDDEN = -1;
18
19     public static final int CALLOUT = 0;
20
21     public static final int LOW = 1;
22
23     public static final int MEDIUM = 2;
24
25     public static final int HIGH = 3;
26
27     public static final int NEW = 4;
28
29     private String JavaDoc name;
30
31     private int fImportance = LOW;
32
33     private boolean implicit = false;
34
35     public static final String JavaDoc[] IMPORTANCE_TABLE = {
36             IUniversalIntroConstants.CALLOUT, IUniversalIntroConstants.LOW,
37             IUniversalIntroConstants.MEDIUM, IUniversalIntroConstants.HIGH,
38             IUniversalIntroConstants.NEW };
39
40     public static final String JavaDoc[] IMPORTANCE_STYLE_TABLE = {
41             IUniversalIntroConstants.STYLE_CALLOUT,
42             IUniversalIntroConstants.STYLE_LOW,
43             IUniversalIntroConstants.STYLE_MEDIUM,
44             IUniversalIntroConstants.STYLE_HIGH,
45             IUniversalIntroConstants.STYLE_NEW };
46
47     public static final String JavaDoc[] IMPORTANCE_NAME_TABLE = {
48             org.eclipse.ui.internal.intro.universal.Messages.ExtensionData_callout,
49             Messages.ExtensionData_low, Messages.ExtensionData_medium,
50             Messages.ExtensionData_high, Messages.ExtensionData_new };
51
52     public ExtensionData(String JavaDoc id, String JavaDoc name) {
53         this(id, name, IUniversalIntroConstants.LOW, false);
54     }
55
56     public ExtensionData(String JavaDoc id, String JavaDoc name, int importance) {
57         this.id = id;
58         this.name = name;
59         this.fImportance = importance;
60         this.implicit = false;
61     }
62
63     public boolean isImplicit() {
64         return implicit;
65     }
66
67     public ExtensionData(String JavaDoc id, String JavaDoc name, String JavaDoc importance,
68             boolean implicit) {
69         this.id = id;
70         this.name = name;
71         this.implicit = implicit;
72         if (importance != null) {
73             if (importance.equals(IUniversalIntroConstants.HIGH))
74                 fImportance = HIGH;
75             else if (importance.equals(IUniversalIntroConstants.MEDIUM))
76                 fImportance = MEDIUM;
77             else if (importance.equals(IUniversalIntroConstants.LOW))
78                 fImportance = LOW;
79             else if (importance.equals(IUniversalIntroConstants.CALLOUT))
80                 fImportance = CALLOUT;
81             else if (importance.equals(IUniversalIntroConstants.NEW))
82                 fImportance = NEW;
83             else if (importance.equals(IUniversalIntroConstants.HIDDEN))
84                 fImportance = HIDDEN;
85         }
86     }
87
88     public String JavaDoc getName() {
89         return name;
90     }
91
92     public void setName(String JavaDoc name) {
93         this.name = name;
94     }
95
96     public int getImportance() {
97         return fImportance;
98     }
99
100     public void setImportance(int newValue) {
101         fImportance = newValue;
102     }
103
104     public boolean isHidden() {
105         return fImportance == HIDDEN;
106     }
107
108     String JavaDoc getImportanceAttributeValue() {
109         return IMPORTANCE_TABLE[fImportance];
110     }
111
112     public String JavaDoc toString() {
113         return name != null ? name : id;
114     }
115
116     public void write(PrintWriter JavaDoc writer, String JavaDoc indent) {
117         writer.print(indent);
118         writer.print("<extension id=\"" + id + "\""); //$NON-NLS-1$ //$NON-NLS-2$
119
if (!isHidden())
120             writer
121                     .println(" importance=\"" + getImportanceAttributeValue() + "\"/>"); //$NON-NLS-1$ //$NON-NLS-2$
122
else
123             writer.println("/>"); //$NON-NLS-1$
124
}
125 }
Popular Tags