public void refreshIntentionHint() { if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){ hideIntentionHint(); return; } if (myHint == null || !myHint.isVisible()) { updateIntentionHintVisibility(); } else { final ErrorInfo[] errorInfos = getErrorInfos(); final Rectangle bounds = getErrorBounds(); if (!haveFixes(errorInfos) || bounds == null || !bounds.equals(myLastHintBounds)) { hideIntentionHint(); updateIntentionHintVisibility(); } } }
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<ErrorWithFix>(); 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()); }
public void addError(@NotNull final String inspectionId, final IComponent component, @Nullable IProperty prop, @NotNull String errorMessage, EditorQuickFixProvider... editorQuickFixProviders) { if (myResults == null) { myResults = new ArrayList<ErrorInfo>(); } List<QuickFix> quickFixes = new ArrayList<QuickFix>(); 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); }
public void valueChanged(final TreeSelectionEvent e) { hideIntentionHint(); updateIntentionHintVisibility(); ErrorInfo[] errorInfos = getErrorInfos(); final String text; if (errorInfos.length > 0 && errorInfos [0].myDescription != null) { text = errorInfos [0].myDescription; } else { text = ""; } StatusBar.Info.set(text, myComponent.getProject()); }
@Override @Nullable public String getToolTipText(final MouseEvent e) { final TreePath path = getPathForLocation(e.getX(), e.getY()); final RadComponent component = getComponentFromPath(path); if(component != null) { final ErrorInfo errorInfo = ErrorAnalyzer.getErrorForComponent(component); if(errorInfo != null) { return errorInfo.myDescription; } } return null; }
/** * Shows intention hint (light bulb) if it's not visible yet. */ final void showIntentionHint(){ if(!myComponent.isShowing() || !IJSwingUtilities.hasFocus(myComponent)){ hideIntentionHint(); return; } // 1. Hide previous hint (if any) hideIntentionHint(); // 2. Found error (if any) final ErrorInfo[] errorInfos = getErrorInfos(); if(!haveFixes(errorInfos)) { hideIntentionHint(); return; } // 3. Determine position where this hint should be shown final Rectangle bounds = getErrorBounds(); if(bounds == null){ return; } // 4. Show light bulb to fix this error final LightBulbComponentImpl lightBulbComponent = new LightBulbComponentImpl(this, AllIcons.Actions.IntentionBulb); myHint = new LightweightHint(lightBulbComponent); myLastHintBounds = bounds; myHint.show(myComponent, bounds.x - AllIcons.Actions.IntentionBulb.getIconWidth() - 4, bounds.y, myComponent, new HintHint(myComponent, bounds.getLocation())); }
private void buildSuppressFixes(final ErrorInfo errorInfo, final ArrayList<ErrorWithFix> suppressList, boolean named) { final String suppressName = named ? UIDesignerBundle.message("action.suppress.named.for.component", errorInfo.myDescription) : UIDesignerBundle.message("action.suppress.for.component"); final String suppressAllName = named ? UIDesignerBundle.message("action.suppress.named.for.all.components", errorInfo.myDescription) : UIDesignerBundle.message("action.suppress.for.all.components"); final SuppressFix suppressFix = new SuppressFix(myEditor, suppressName, errorInfo.getInspectionId(), errorInfo.getComponent()); final SuppressFix suppressAllFix = new SuppressFix(myEditor, suppressAllName, errorInfo.getInspectionId(), null); suppressList.add(new ErrorWithFix(errorInfo, suppressFix)); suppressList.add(new ErrorWithFix(errorInfo, suppressAllFix)); }
/** * @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; }
@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; }
@NotNull protected ErrorInfo[] getErrorInfos() { final ArrayList<RadComponent> list = FormEditingUtil.getSelectedComponents(getEditor()); if (list.size() != 1) { return ErrorInfo.EMPTY_ARRAY; } return ErrorAnalyzer.getAllErrorsForComponent(list.get(0)); }
@NotNull protected ErrorInfo[] getErrorInfos() { final RadComponent component = myComponent.getSelectedComponent(); if(component == null){ return ErrorInfo.EMPTY_ARRAY; } return ErrorAnalyzer.getAllErrorsForComponent(component); }
/** * @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; }
@Override @NotNull protected ErrorInfo[] getErrorInfos() { final ArrayList<RadComponent> list = FormEditingUtil.getSelectedComponents(getEditor()); if(list.size() != 1) { return ErrorInfo.EMPTY_ARRAY; } return ErrorAnalyzer.getAllErrorsForComponent(list.get(0)); }
public ErrorWithFix(final ErrorInfo first, final QuickFix second) { super(first, second); }
private SimpleTextAttributes getTextAttributes(final int row, final Property property) { // 1. Text ErrorInfo errInfo = getErrorInfoForRow(row); SimpleTextAttributes result; boolean modified; try { modified = isModifiedForSelection(property); } catch(Exception ex) { // ignore exceptions here - they'll be reported as red property values modified = false; } if (errInfo == null) { result = modified ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES; } else { final HighlightSeverity severity = errInfo.getHighlightDisplayLevel().getSeverity(); Map<HighlightSeverity, SimpleTextAttributes> cache = modified ? myModifiedHighlightAttributes : myHighlightAttributes; result = cache.get(severity); if (result == null) { final TextAttributesKey attrKey = SeverityRegistrar.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey); if (modified) { textAttrs = textAttrs.clone(); textAttrs.setFontType(textAttrs.getFontType() | Font.BOLD); } result = SimpleTextAttributes.fromTextAttributes(textAttrs); cache.put(severity, result); } } if (property instanceof IntrospectedProperty) { final RadComponent c = mySelection.get(0); if (Properties.getInstance().isPropertyDeprecated(c.getModule(), c.getComponentClass(), property.getName())) { return new SimpleTextAttributes(result.getBgColor(), result.getFgColor(), result.getWaveColor(), result.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT); } } return result; }
@Nullable public ErrorInfo[] checkComponent(@NotNull GuiEditor editor, @NotNull RadComponent component) { FormEditorErrorCollector collector = new FormEditorErrorCollector(editor, component); checkComponentProperties(component.getModule(), component, collector); return collector.result(); }
public ErrorInfo[] result() { return myResults == null ? null : myResults.toArray(new ErrorInfo[myResults.size()]); }
@Nullable ErrorInfo[] checkComponent(@NotNull GuiEditor editor, @NotNull RadComponent component);
private SimpleTextAttributes getTextAttributes(final int row, final Property property) { // 1. Text ErrorInfo errInfo = getErrorInfoForRow(row); SimpleTextAttributes result; boolean modified; try { modified = isModifiedForSelection(property); } catch(Exception ex) { // ignore exceptions here - they'll be reported as red property values modified = false; } if (errInfo == null) { result = modified ? SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES; } else { final HighlightSeverity severity = errInfo.getHighlightDisplayLevel().getSeverity(); Map<HighlightSeverity, SimpleTextAttributes> cache = modified ? myModifiedHighlightAttributes : myHighlightAttributes; result = cache.get(severity); if (result == null) { final TextAttributesKey attrKey = SeverityUtil.getSeverityRegistrar(myProject).getHighlightInfoTypeBySeverity(severity).getAttributesKey(); TextAttributes textAttrs = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attrKey); if (modified) { textAttrs = textAttrs.clone(); textAttrs.setFontType(textAttrs.getFontType() | Font.BOLD); } result = SimpleTextAttributes.fromTextAttributes(textAttrs); cache.put(severity, result); } } if (property instanceof IntrospectedProperty) { final RadComponent c = mySelection.get(0); if (Properties.getInstance().isPropertyDeprecated(c.getModule(), c.getComponentClass(), property.getName())) { return new SimpleTextAttributes(result.getBgColor(), result.getFgColor(), result.getWaveColor(), result.getStyle() | SimpleTextAttributes.STYLE_STRIKEOUT); } } return result; }