Changeset 12273
- Timestamp:
- 2006-07-21T13:12:04+12:00 (18 years ago)
- Location:
- trunk/gli/src/org/greenstone/gatherer/cdm
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gli/src/org/greenstone/gatherer/cdm/Format.java
r12088 r12273 41 41 42 42 /** The default features (not all of these are in the Greenstone Developer's Guide). */ 43 static final public String DEFAULT_FEATURES[] = { " ", "AllowExtendedOptions", "Document", "DocumentArrowsBottom", "DocumentArrowsTop", "DocumentButtons", "DocumentContents", "DocumentHeading", "DocumentImages", "DocumentText", "DocumentTitles", "DocumentUseHTML", "RelatedDocuments", "Search", "SearchTypes" };43 static final public String DEFAULT_FEATURES[] = { "<html><body><i>All Features</i></body></html>", "AllowExtendedOptions", "Document", "DocumentArrowsBottom", "DocumentArrowsTop", "DocumentButtons", "DocumentContents", "DocumentHeading", "DocumentImages", "DocumentText", "DocumentTitles", "DocumentUseHTML", "RelatedDocuments", "Search", "SearchTypes" }; 44 44 /** The list of known feature parts. */ 45 45 static final public String DEFAULT_PARTS[] = { "", "DateList", "HList", "VList" }; 46 46 47 47 48 /** Only "" and "Search" can have parts */ 48 49 static public boolean canHavePart(String name) { 49 return (name. equalsIgnoreCase("") || name.equalsIgnoreCase("Search") || name.equalsIgnoreCase("Document"));50 return (name.startsWith("<html>") || name.equalsIgnoreCase("") || name.equalsIgnoreCase("Search") || name.equalsIgnoreCase("Document")); 50 51 } 51 52 … … 58 59 } 59 60 } 61 60 62 61 63 /** Returns true if the parameter is a boolean type, false otherwise. */ … … 70 72 } 71 73 74 72 75 /** If this format is altering a Classifier then this is the classifier in question. */ 73 76 private Classifier classifier = null; … … 83 86 /** Constructor only to be used during DOMProxyListModel initialization. */ 84 87 public Format() { 88 85 89 } 86 90 87 91 public Format(Element element) { 92 88 93 this.element = element; 89 94 // Immediately check if we are dealing with a classifier, by retrieving the feature name. If it is a classifier, then restore the live reference immediately before anything changes it. … … 110 115 } 111 116 } 117 118 112 119 } 113 120 … … 118 125 */ 119 126 public Format(Object feature, String part, boolean state) { 127 120 128 element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.FORMAT_ELEMENT); 121 129 setName(feature, part); 122 130 setState(state); 131 123 132 } 124 133 … … 129 138 */ 130 139 public Format(Object feature, String part, String value) { 131 element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.FORMAT_ELEMENT); 140 141 element = CollectionDesignManager.collect_config.document.createElement(CollectionConfiguration.FORMAT_ELEMENT); 132 142 setName(feature, part); 133 143 setValue(value); 134 } 135 144 145 } 146 147 148 136 149 public boolean canHavePart() { 137 150 return canHavePart(getName()); … … 190 203 public String getFeatureName() { 191 204 if (feature_name == null) { 192 String name = element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE);205 String name = element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE); 193 206 // Remove part 194 207 String part = getPart(); … … 202 215 name = null; 203 216 } 217 218 if ( feature_name.equals("")){ 219 feature_name = DEFAULT_FEATURES[0]; 220 } 221 204 222 return feature_name; 205 223 … … 207 225 public String getName() { 208 226 if(element != null) { 209 return element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE); 227 String name = element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE); 228 if (name.equals("")){ 229 return DEFAULT_FEATURES[0]; 230 } 231 return element.getAttribute(CollectionConfiguration.NAME_ATTRIBUTE); 210 232 } 211 233 return "Error"; … … 277 299 public void setName(Object feature, String part) { 278 300 // Can't do anything unless an element exists. 301 279 302 if(element != null) { 280 303 this.part = part; // Easier for later on. … … 285 308 } 286 309 else { 287 feature_name = feature.toString(); 288 element.setAttribute(CollectionConfiguration.NAME_ATTRIBUTE, feature.toString() + part); 310 if (feature.toString().startsWith("<html>")){ 311 feature_name = ""; 312 } 313 else{ 314 feature_name = feature.toString(); 315 } 316 element.setAttribute(CollectionConfiguration.NAME_ATTRIBUTE, feature_name + part); 289 317 } 290 318 text = null; -
trunk/gli/src/org/greenstone/gatherer/cdm/FormatManager.java
r12123 r12273 640 640 ignore_event = true; 641 641 Entry entry = (Entry) feature_combobox.getSelectedItem(); 642 // Step one: reset part 642 643 // Step one: reset part 643 644 if (entry.canHavePart()) { 644 645 part_combobox.setEnabled(true); … … 1117 1118 if(classifier != null) { 1118 1119 return classifier; 1120 } 1121 1122 if (text.startsWith("<html>")){ 1123 return ""; 1119 1124 } 1120 1125 return text;
Note:
See TracChangeset
for help on using the changeset viewer.