public void addGlobalTLCErrorMessage(String key, String message) { IMessageManager mm = getManagedForm().getMessageManager(); mm.addMessage(key, message, null, IMessageProvider.WARNING); /*globalTLCErrorHyperLink.setText(TLC_ERROR_STRING); globalTLCErrorHyperLink.setToolTipText(tooltipText); globalTLCErrorHyperLink.setForeground(TLCUIActivator.getColor(SWT.COLOR_DARK_YELLOW)); globalTLCErrorHyperLink.addHyperlinkListener(globalTLCErrorHyperLinkListener);*/ }
/** * Checks if the elements of the given list comply with the requirement of being not already defined in the context * of the current model and the specification. The method will iterate through the list and check whether every element * satisfies the requirement. On violation, it adds the error message to the message manager. * @param values The list to check * @param listSource the control serving as the origin of the list, on errors a small error icon will be added next to it * @param errorMessagePrefix the prefix of the error messages to be used * @param elementType the type of the element, used in the error message * @param listSourceDescription the description of the list source, used in error reporting * @param sectionIndex index of the section to expand * @param addToContext iff true, the values will be added to the context of the current model */ public void validateUsage(String attributeName, List<String> values, String errorMessagePrefix, String elementType, String listSourceDescription, boolean addToContext) { if (values == null) { return; } DataBindingManager dm = getDataBindingManager(); // find the section for the attribute String sectionId = dm.getSectionForAttribute(attributeName); if (sectionId == null) { throw new IllegalArgumentException("No section for attribute " + attributeName + " found"); } // retrieve the control Control widget = UIHelper.getWidget(dm.getAttributeControl(attributeName)); IMessageManager mm = getManagedForm().getMessageManager(); SemanticHelper helper = getLookupHelper(); String message; for (int i = 0; i < values.size(); i++) { String value = values.get(i); Object usageHint = helper.getUsedHint(value); if (usageHint != null) { message = elementType + " " + value + " may not be used, since it is "; if (usageHint instanceof SymbolNode) { message += ""; SymbolNode node = (SymbolNode) usageHint; Location location = node.getLocation(); if (location.source().equals(SemanticHelper.TLA_BUILTIN)) { message += "a built-in TLA+ definition."; } else { message += "an identifier already defined at " + location.toString() + "."; } } else if (usageHint instanceof String) { if (SemanticHelper.KEYWORD.equals(usageHint)) { message += "a TLA+ keyword."; } else { message += "already used in " + usageHint; } } else { message = "Error during validation. This is a bug"; } mm.addMessage(errorMessagePrefix + i, message, value.toString(), IMessageProvider.ERROR, widget); setComplete(false); expandSection(sectionId); } else { // just adding the name if (addToContext) { helper.addName(value, this, listSourceDescription); } } } }
/** * Validates if the elements of the list are ids * @param attributeName name of the attribute * @param values * @param errorMessagePrefix * @param elementType */ public void validateId(String attributeName, List<String> values, String errorMessagePrefix, String elementType) { if (values == null) { return; } DataBindingManager dm = getDataBindingManager(); // find the section for the attribute String sectionId = dm.getSectionForAttribute(attributeName); if (sectionId == null) { throw new IllegalArgumentException("No section for attribute " + attributeName + " found"); } // retrieve the control Control widget = UIHelper.getWidget(dm.getAttributeControl(attributeName)); String message; IMessageManager mm = getManagedForm().getMessageManager(); for (int i = 0; i < values.size(); i++) { String value = values.get(i); if (!FormHelper.isIdentifier(value)) { if (value.trim().equals("")) { message = elementType + " has been omitted."; } else { message = elementType + " " + value + " may not be used, since it is not a valid identifier." + "\nAn identifier is a non-empty sequence of letters, digits and '_' with at least one letter."; } mm.addMessage(errorMessagePrefix + i, message, value.toString(), IMessageProvider.ERROR, widget); setComplete(false); expandSection(sectionId); } } }
/** * @return the messageManager */ public IMessageManager getMessageManager() { return messageManager; }
public void setMessageManager(IMessageManager manager) { this.manager = manager; }
/** * @param messageManager * the messageManager to set */ public void setMessageManager(IMessageManager messageManager) { this.messageManager = messageManager; }