Search in sources :

Example 1 with ErrorInfo

use of com.intellij.uiDesigner.ErrorInfo in project intellij-community by JetBrains.

the class PropertyInspectorTable method getErrorForRow.

/**
   * @return first error for the property at the specified row. If component doesn't contain
   * any error then the method returns <code>null</code>.
   */
@Nullable
private String getErrorForRow(final int row) {
    LOG.assertTrue(row < myProperties.size());
    final ErrorInfo errorInfo = getErrorInfoForRow(row);
    return errorInfo != null ? errorInfo.myDescription : null;
}
Also used : ErrorInfo(com.intellij.uiDesigner.ErrorInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 2 with ErrorInfo

use of com.intellij.uiDesigner.ErrorInfo in project intellij-community by JetBrains.

the class FormEditorErrorCollector method addError.

public void addError(@NotNull final String inspectionId, final IComponent component, @Nullable IProperty prop, @NotNull String errorMessage, EditorQuickFixProvider... editorQuickFixProviders) {
    if (myResults == null) {
        myResults = new ArrayList<>();
    }
    List<QuickFix> quickFixes = new ArrayList<>();
    for (EditorQuickFixProvider provider : editorQuickFixProviders) {
        if (provider != null) {
            quickFixes.add(provider.createQuickFix(myEditor, myComponent));
        }
    }
    final ErrorInfo errorInfo = new ErrorInfo(myComponent, prop == null ? null : prop.getName(), errorMessage, myProfile.getErrorLevel(HighlightDisplayKey.find(inspectionId), myFormPsiFile), quickFixes.toArray(new QuickFix[quickFixes.size()]));
    errorInfo.setInspectionId(inspectionId);
    myResults.add(errorInfo);
}
Also used : QuickFix(com.intellij.uiDesigner.quickFixes.QuickFix) ErrorInfo(com.intellij.uiDesigner.ErrorInfo) ArrayList(java.util.ArrayList)

Example 3 with ErrorInfo

use of com.intellij.uiDesigner.ErrorInfo in project intellij-community by JetBrains.

the class PropertyInspectorTable method getErrorInfoForRow.

@Nullable
ErrorInfo getErrorInfoForRow(final int row) {
    LOG.assertTrue(row < myProperties.size());
    if (mySelection.size() != 1) {
        return null;
    }
    RadComponent component = mySelection.get(0);
    final Property property = myProperties.get(row);
    ErrorInfo errorInfo = null;
    if (myClassToBindProperty.equals(property)) {
        errorInfo = (ErrorInfo) component.getClientProperty(ErrorAnalyzer.CLIENT_PROP_CLASS_TO_BIND_ERROR);
    } else if (myBindingProperty.equals(property)) {
        errorInfo = (ErrorInfo) component.getClientProperty(ErrorAnalyzer.CLIENT_PROP_BINDING_ERROR);
    } else {
        //noinspection unchecked
        ArrayList<ErrorInfo> errors = (ArrayList<ErrorInfo>) component.getClientProperty(ErrorAnalyzer.CLIENT_PROP_ERROR_ARRAY);
        if (errors != null) {
            for (ErrorInfo err : errors) {
                if (property.getName().equals(err.getPropertyName())) {
                    errorInfo = err;
                    break;
                }
            }
        }
    }
    return errorInfo;
}
Also used : ErrorInfo(com.intellij.uiDesigner.ErrorInfo) Nullable(org.jetbrains.annotations.Nullable)

Example 4 with ErrorInfo

use of com.intellij.uiDesigner.ErrorInfo in project intellij-community by JetBrains.

the class QuickFixManagerImpl method getErrorInfos.

@NotNull
public ErrorInfo[] getErrorInfos() {
    final int selectedRow = myComponent.getSelectedRow();
    if (selectedRow < 0 || selectedRow >= myComponent.getRowCount()) {
        return ErrorInfo.EMPTY_ARRAY;
    }
    final ErrorInfo info = myComponent.getErrorInfoForRow(selectedRow);
    if (info != null) {
        return new ErrorInfo[] { info };
    }
    return ErrorInfo.EMPTY_ARRAY;
}
Also used : ErrorInfo(com.intellij.uiDesigner.ErrorInfo) NotNull(org.jetbrains.annotations.NotNull)

Example 5 with ErrorInfo

use of com.intellij.uiDesigner.ErrorInfo in project intellij-community by JetBrains.

the class QuickFixManager method showIntentionPopup.

final void showIntentionPopup() {
    LOG.debug("showIntentionPopup()");
    if (myHint == null || !myHint.isVisible()) {
        return;
    }
    final ErrorInfo[] errorInfos = getErrorInfos();
    if (!haveFixes(errorInfos)) {
        return;
    }
    final ArrayList<ErrorWithFix> fixList = new ArrayList<>();
    for (ErrorInfo errorInfo : errorInfos) {
        final QuickFix[] quickFixes = errorInfo.myFixes;
        if (quickFixes.length > 0) {
            for (QuickFix fix : quickFixes) {
                fixList.add(new ErrorWithFix(errorInfo, fix));
            }
        } else if (errorInfo.getInspectionId() != null) {
            buildSuppressFixes(errorInfo, fixList, true);
        }
    }
    final ListPopup popup = JBPopupFactory.getInstance().createListPopup(new QuickFixPopupStep(fixList, true));
    popup.showUnderneathOf(myHint.getComponent());
}
Also used : ErrorInfo(com.intellij.uiDesigner.ErrorInfo) ArrayList(java.util.ArrayList) ListPopup(com.intellij.openapi.ui.popup.ListPopup)

Aggregations

ErrorInfo (com.intellij.uiDesigner.ErrorInfo)6 ArrayList (java.util.ArrayList)2 Nullable (org.jetbrains.annotations.Nullable)2 ListPopup (com.intellij.openapi.ui.popup.ListPopup)1 HintHint (com.intellij.ui.HintHint)1 LightweightHint (com.intellij.ui.LightweightHint)1 QuickFix (com.intellij.uiDesigner.quickFixes.QuickFix)1 NotNull (org.jetbrains.annotations.NotNull)1