diff --git a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java index 8ced2c5c0e5f..c80cc39e88b6 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java +++ b/plugins/android-designer/src/com/intellij/android/designer/designSurface/AndroidDesignerEditorPanel.java @@ -518,7 +518,7 @@ public final class AndroidDesignerEditorPanel extends DesignerEditorPanel { @Override public void loadInspections(ProgressIndicator progress) { if (myRootComponent != null) { - ErrorAnalyzer.load(myXmlFile, myRootComponent, progress); + ErrorAnalyzer.load(getProject(), myXmlFile, myRootComponent, progress); } } } \ No newline at end of file diff --git a/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java b/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java index 8bdb4bfb8fbc..53130b5e5cce 100644 --- a/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java +++ b/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java @@ -22,12 +22,16 @@ import com.intellij.codeHighlighting.HighlightDisplayLevel; import com.intellij.codeInsight.daemon.HighlightDisplayKey; import com.intellij.codeInsight.intention.IntentionAction; import com.intellij.codeInspection.SuppressIntentionAction; +import com.intellij.codeInspection.ex.DisableInspectionToolAction; +import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction; +import com.intellij.designer.inspection.AbstractQuickFixManager; import com.intellij.designer.inspection.ErrorInfo; import com.intellij.designer.inspection.QuickFix; import com.intellij.designer.model.RadComponent; import com.intellij.designer.model.RadComponentVisitor; import com.intellij.designer.propertyTable.Property; import com.intellij.openapi.progress.ProgressIndicator; +import com.intellij.openapi.project.Project; import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.TextRange; import com.intellij.psi.PsiElement; @@ -42,7 +46,7 @@ import java.util.List; * @author Alexander Lobas */ public final class ErrorAnalyzer { - public static void load(XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) { + public static void load(final Project project, final XmlFile xmlFile, RadComponent rootComponent, ProgressIndicator progress) { ErrorInfo.clear(rootComponent); AndroidLintExternalAnnotator annotator = new AndroidLintExternalAnnotator(); @@ -69,8 +73,8 @@ public final class ErrorAnalyzer { HighlightDisplayKey key = HighlightDisplayKey.find(inspection.getShortName()); if (key != null) { - PsiElement startElement = xmlFile.findElementAt(range.getStartOffset()); - PsiElement endElement = xmlFile.findElementAt(range.getEndOffset() - 1); + final PsiElement startElement = xmlFile.findElementAt(range.getStartOffset()); + final PsiElement endElement = xmlFile.findElementAt(range.getEndOffset() - 1); if (startElement != null && endElement != null && !inspection.isSuppressedFor(startElement)) { Pair componentInfo = findComponent(rootComponent, startElement); @@ -79,52 +83,51 @@ public final class ErrorAnalyzer { List designerFixes = errorInfo.getQuickFixes(); - for (AndroidLintQuickFix fix : inspection.public_getQuickFixes(message)) { + for (final AndroidLintQuickFix fix : inspection.public_getQuickFixes(message)) { if (fix.isApplicable(startElement, endElement, false)) { - designerFixes.add(new QuickFix(fix.getName(), null) { + designerFixes.add(new QuickFix(fix.getName(), AbstractQuickFixManager.ICON) { @Override - public void run() throws Exception { - System.out.println("00000000"); - // TODO: Auto-generated method stub + public void run() { + fix.apply(startElement, endElement, null); } }); } } - for (IntentionAction intention : inspection.getIntentions(startElement, endElement)) { - designerFixes.add(new QuickFix(intention.getText(), null) { + for (final IntentionAction intention : inspection.getIntentions(startElement, endElement)) { + designerFixes.add(new QuickFix(intention.getText(), AbstractQuickFixManager.ICON) { @Override - public void run() throws Exception { - System.out.println("1111111"); - // TODO: Auto-generated method stub + public void run() { + intention.invoke(project, null, xmlFile); } }); } - designerFixes.add(new QuickFix("Disable inspection", null) { + final DisableInspectionToolAction disableAction = new DisableInspectionToolAction(key); + designerFixes.add(new QuickFix("Disable inspection", disableAction.getIcon(0)) { @Override - public void run() throws Exception { - System.out.println("22222"); - // TODO: Auto-generated method stub - } - }); - designerFixes.add(new QuickFix("Edit '" + inspection.getDisplayName() + "' inspection settings", null) { - @Override - public void run() throws Exception { - System.out.println("3333333"); - // TODO: Auto-generated method stub + public void run() { + disableAction.invoke(project, null, xmlFile); } }); + final EditInspectionToolsSettingsAction editSettingsAction = new EditInspectionToolsSettingsAction(key); + designerFixes + .add(new QuickFix("Edit '" + inspection.getDisplayName() + "' inspection settings", editSettingsAction.getIcon(0)) { + @Override + public void run() { + editSettingsAction.invoke(project, null, xmlFile); + } + }); + SuppressIntentionAction[] suppressActions = inspection.getSuppressActions(startElement); if (suppressActions != null) { - for (SuppressIntentionAction action : suppressActions) { + for (final SuppressIntentionAction action : suppressActions) { if (action.isAvailable(xmlFile.getProject(), null, startElement)) { - designerFixes.add(new QuickFix("Suppress: " + action.getText(), action.getIcon(0)) { + designerFixes.add(new QuickFix(action.getText(), action.getIcon(0)) { @Override - public void run() throws Exception { - System.out.println("4444444"); - // TODO: Auto-generated method stub + public void run() { + action.invoke(project, null, startElement); } }); } diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/AbstractQuickFixManager.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/AbstractQuickFixManager.java index d71d0f4ed758..306a03ddb570 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/AbstractQuickFixManager.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/AbstractQuickFixManager.java @@ -18,6 +18,7 @@ package com.intellij.designer.inspection; import com.intellij.designer.DesignerBundle; import com.intellij.designer.designSurface.DesignerEditorPanel; import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.keymap.KeymapUtil; import com.intellij.openapi.ui.popup.JBPopupFactory; import com.intellij.openapi.ui.popup.ListPopup; @@ -270,6 +271,11 @@ public abstract class AbstractQuickFixManager { public boolean hasSubstep(ErrorInfo selectedValue) { return true; } + + @Override + public boolean isAutoSelectionEnabled() { + return false; + } } private class SecondStep extends BaseListPopupStep { @@ -301,7 +307,7 @@ public abstract class AbstractQuickFixManager { myDesigner.getToolProvider().execute(new ThrowableRunnable() { @Override public void run() throws Exception { - value.run(); + ApplicationManager.getApplication().runWriteAction(value); } }, "Run '" + value.getName() + "' QuickFix", true); } @@ -316,7 +322,7 @@ public abstract class AbstractQuickFixManager { private static final Icon INTENTION_ICON = IconLoader.getIcon("/actions/realIntentionBulb.png"); private static final Icon ARROW_ICON = IconLoader.getIcon("/general/arrowDown.png"); private static final Icon INACTIVE_ARROW_ICON = new EmptyIcon(ARROW_ICON.getIconWidth(), ARROW_ICON.getIconHeight()); - private static final Icon ICON = IconLoader.findIcon("/actions/intentionBulb.png"); + public static final Icon ICON = IconLoader.findIcon("/actions/intentionBulb.png"); private class InspectionHint extends JLabel { private final RowIcon myInactiveIcon; diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/QuickFix.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/QuickFix.java index 90b83cbcd0e4..f617d9d44886 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/QuickFix.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/inspection/QuickFix.java @@ -20,7 +20,7 @@ import javax.swing.*; /** * @author Alexander Lobas */ -public abstract class QuickFix { +public abstract class QuickFix implements Runnable { private final String myName; private final Icon myIcon; @@ -36,6 +36,4 @@ public abstract class QuickFix { public final Icon getIcon() { return myIcon; } - - public abstract void run() throws Exception; } \ No newline at end of file diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java index 6c21a0a99fda..83b245867218 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/propertyTable/PropertyTable.java @@ -215,6 +215,10 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi } Property property = myProperties.get(row); + if (property.getParent() != null) { + return null; + } + for (ErrorInfo errorInfo : ErrorInfo.get(myComponents.get(0))) { if (property.getName().equals(errorInfo.getPropertyName())) { return errorInfo; @@ -223,6 +227,18 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi return null; } + @Override + public String getToolTipText(MouseEvent event) { + int row = rowAtPoint(event.getPoint()); + if (row != -1) { + ErrorInfo errorInfo = getErrorInfoForRow(row); + if (errorInfo != null) { + return errorInfo.getName(); + } + } + return super.getToolTipText(event); + } + ////////////////////////////////////////////////////////////////////////////////////////// // // @@ -648,18 +664,6 @@ public final class PropertyTable extends JBTable implements ComponentSelectionLi Messages.getErrorIcon()); } - @Override - public String getToolTipText(MouseEvent event) { - int row = rowAtPoint(event.getPoint()); - if (row != -1) { - ErrorInfo errorInfo = getErrorInfoForRow(row); - if (errorInfo != null) { - return errorInfo.getName(); - } - } - return super.getToolTipText(event); - } - ////////////////////////////////////////////////////////////////////////////////////////// // //