Assert.isLegal(registry != null);
Assert.isLegal(element != null);
fElement= element;
ILog log= TextEditorPlugin.getDefault().getLog();
ExtensionPointHelper helper= new ExtensionPointHelper(element, log);
fId= helper.getNonNullAttribute(ID);
fName= helper.getDefaultAttribute(NAME, fId);
helper.getNonNullAttribute(CLASS); // just check validity
URL iconURL= helper.getDefaultResourceURL(ICON, null);
fIcon= iconURL == null ? null : ImageDescriptor.createFromURL(iconURL);
fDefaultEnablement= helper.getDefaultAttribute(ENABLED, true);
fIsGlobal= helper.getDefaultAttribute(GLOBAL, true);
fIncludeInMenu= helper.getDefaultAttribute(INCLUDE_IN_MENU, true);
IConfigurationElement[] targetEditors= element.getChildren(TARGET_EDITOR);
IConfigurationElement[] targetContentTypes= element.getChildren(TARGET_CONTENT_TYPE);
IConfigurationElement[] targetClasses= element.getChildren(TARGET_CLASS);
if (targetContentTypes.length + targetEditors.length + targetClasses.length == 0) {
helper.fail(RulerColumnMessages.RulerColumnDescriptor_missing_target_msg);
fTarget= null; // dummy
} else {
RulerColumnTarget combined= null;
for (int i= 0; i < targetEditors.length; i++) {
IConfigurationElement targetEditor= targetEditors[i];
RulerColumnTarget target= RulerColumnTarget.createEditorIdTarget(new ExtensionPointHelper(targetEditor, log).getNonNullAttribute(ID));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
for (int i= 0; i < targetContentTypes.length; i++) {
IConfigurationElement targetContentType= targetContentTypes[i];
RulerColumnTarget target= RulerColumnTarget.createContentTypeTarget(new ExtensionPointHelper(targetContentType, log).getNonNullAttribute(ID));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
for (int i= 0; i < targetClasses.length; i++) {
IConfigurationElement targetClass= targetClasses[i];
RulerColumnTarget target= RulerColumnTarget.createClassTarget(new ExtensionPointHelper(targetClass, log).getNonNullAttribute(CLASS));
combined= RulerColumnTarget.createOrTarget(combined, target);
}
fTarget= combined;
}
IConfigurationElement[] placements= element.getChildren(PLACEMENT);
switch (placements.length) {
case 0:
fRulerColumnPlacement= new RulerColumnPlacement();
break;
case 1:
fRulerColumnPlacement= new RulerColumnPlacement(placements[0]);
break;
default:
helper.fail(RulerColumnMessages.RulerColumnDescriptor_invalid_placement_msg);
fRulerColumnPlacement= null; // dummy
break;
}
Assert.isTrue(fTarget != null);