1 11 package org.eclipse.ui.internal.intro.universal; 12 13 import java.io.PrintWriter ; 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 name; 30 31 private int fImportance = LOW; 32 33 private boolean implicit = false; 34 35 public static final String [] IMPORTANCE_TABLE = { 36 IUniversalIntroConstants.CALLOUT, IUniversalIntroConstants.LOW, 37 IUniversalIntroConstants.MEDIUM, IUniversalIntroConstants.HIGH, 38 IUniversalIntroConstants.NEW }; 39 40 public static final String [] 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 [] 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 id, String name) { 53 this(id, name, IUniversalIntroConstants.LOW, false); 54 } 55 56 public ExtensionData(String id, String 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 id, String name, String 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 getName() { 89 return name; 90 } 91 92 public void setName(String 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 getImportanceAttributeValue() { 109 return IMPORTANCE_TABLE[fImportance]; 110 } 111 112 public String toString() { 113 return name != null ? name : id; 114 } 115 116 public void write(PrintWriter writer, String indent) { 117 writer.print(indent); 118 writer.print("<extension id=\"" + id + "\""); if (!isHidden()) 120 writer 121 .println(" importance=\"" + getImportanceAttributeValue() + "\"/>"); else 123 writer.println("/>"); } 125 } | Popular Tags |