/** @return Returns the ValidatorStrategy. */ protected ValidatorStrategy getValidatorStrategy() { ValidatorStrategy validatorStrategy = null; if (fValidatorStrategy == null && fValidationEnabled) { if (getTextViewer() instanceof ISourceViewer) { ISourceViewer viewer = (ISourceViewer) getTextViewer(); String contentTypeId = null; IDocument doc = viewer.getDocument(); contentTypeId = getContentType(doc); if (contentTypeId != null) { validatorStrategy = new ValidatorStrategy(viewer, contentTypeId); ValidatorBuilder vBuilder = new ValidatorBuilder(); ValidatorMetaData[] vmds = vBuilder.getValidatorMetaData(SSE_UI_ID); List enabledValidators = new ArrayList(1); /* if any "must" handle this content type, just add them */ boolean foundSpecificContentTypeValidators = false; for (int i = 0; i < vmds.length; i++) { if (vmds[i].mustHandleContentType(contentTypeId)) { if (DEBUG_VALIDATORS) Logger.log( Logger.INFO, contentTypeId + " using specific validator " + vmds[i].getValidatorId()); // $NON-NLS-1$ foundSpecificContentTypeValidators = true; enabledValidators.add(vmds[i]); } } if (!foundSpecificContentTypeValidators) { for (int i = 0; i < vmds.length; i++) { if (vmds[i].canHandleContentType(contentTypeId)) { if (DEBUG_VALIDATORS) Logger.log( Logger.INFO, contentTypeId + " using inherited(?) validator " + vmds[i].getValidatorId()); // $NON-NLS-1$ enabledValidators.add(vmds[i]); } } } for (int i = 0; i < enabledValidators.size(); i++) { validatorStrategy.addValidatorMetaData((ValidatorMetaData) enabledValidators.get(i)); } } } fValidatorStrategy = validatorStrategy; } else if (fValidatorStrategy != null && fValidationEnabled) { validatorStrategy = fValidatorStrategy; } return validatorStrategy; }
/** * Logs the error in the workbench log using the provided text and the information in the * configuration element. */ protected void logError(IConfigurationElement element, String text) { IExtension extension = element.getDeclaringExtension(); StringBuffer buf = new StringBuffer(); buf.append( "Plugin " + extension.getNamespace() + ", extension " + extension.getExtensionPointUniqueIdentifier()); // $NON-NLS-2$//$NON-NLS-1$ buf.append("\n" + text); // $NON-NLS-1$ Logger.log(Logger.ERROR, buf.toString()); }
/** * Process the accelerator definition. If it is a number then process the code directly - if not * then parse it and create the code */ private void processAccelerator(IAction action, String acceleratorText) { if (acceleratorText.length() == 0) return; // Is it a numeric definition? if (Character.isDigit(acceleratorText.charAt(0))) { try { action.setAccelerator(Integer.valueOf(acceleratorText).intValue()); } catch (NumberFormatException exception) { Logger.log(Logger.ERROR, "Invalid accelerator declaration: " + id); // $NON-NLS-1$ } } else action.setAccelerator(convertAccelerator(acceleratorText)); }
public void setItems(String[] newItems) { if (getControl() == null || getControl().isDisposed()) { Logger.log( Logger.ERROR, "Attempted to update item list for disposed cell editor"); // $NON-NLS-1$ return; } // keep selection if possible Object previousSelectedValue = getValue(); super.setItems(newItems); if (previousSelectedValue != null && getControl() instanceof StyleCombo) { for (int i = 0; i < newItems.length; i++) { if (newItems[i].equals(previousSelectedValue)) { setValue(previousSelectedValue); } } } }