From 19c1e579dd270cb9d557821d8162bb6733cbefc8 Mon Sep 17 00:00:00 2001 From: Alexander Lobas Date: Fri, 29 Jun 2012 13:53:38 +0400 Subject: [PATCH] EA-37024 - NPE: PropertyTable.findProperty --- .../designer/componentTree/ComponentTree.java | 61 ++++++++----------- .../designer/designSurface/CaptionPanel.java | 2 +- .../designSurface/DecorationLayer.java | 19 ++++-- .../designSurface/DesignerEditorPanel.java | 2 +- 4 files changed, 42 insertions(+), 42 deletions(-) diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/ComponentTree.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/ComponentTree.java index d14b512a8c69..ae57adc24068 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/ComponentTree.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/componentTree/ComponentTree.java @@ -30,7 +30,6 @@ import com.intellij.openapi.actionSystem.PlatformDataKeys; import com.intellij.openapi.editor.colors.EditorColorsManager; import com.intellij.openapi.editor.colors.TextAttributesKey; import com.intellij.openapi.editor.markup.TextAttributes; -import com.intellij.openapi.fileEditor.FileEditor; import com.intellij.openapi.project.Project; import com.intellij.ui.ColoredTreeCellRenderer; import com.intellij.ui.SimpleTextAttributes; @@ -58,10 +57,7 @@ public final class ComponentTree extends Tree implements DataProvider { new HashMap>(); private final StartInplaceEditing myInplaceEditingAction; private QuickFixManager myQuickFixManager; - private TreeComponentDecorator myDecorator; - private DesignerActionPanel myActionPanel; - private Project myProject; - private FileEditor myFileEditor; + private DesignerEditorPanel myDesigner; private EditableArea myArea; private RadComponent myMarkComponent; private int myMarkFeedback; @@ -97,18 +93,7 @@ public final class ComponentTree extends Tree implements DataProvider { } public void setDesignerPanel(@Nullable DesignerEditorPanel designer) { - if (designer == null) { - myDecorator = null; - myActionPanel = null; - myProject = null; - myFileEditor = null; - } - else { - myDecorator = designer.getTreeDecorator(); - myActionPanel = designer.getActionPanel(); - myProject = designer.getProject(); - myFileEditor = designer.getEditor(); - } + myDesigner = designer; myMarkComponent = null; myArea = null; myInplaceEditingAction.setDesignerPanel(designer); @@ -131,11 +116,11 @@ public final class ComponentTree extends Tree implements DataProvider { if (EditableArea.DATA_KEY.is(dataId)) { return myArea; } - if (PlatformDataKeys.FILE_EDITOR.is(dataId)) { - return myFileEditor; - } - if (myActionPanel != null) { - return myActionPanel.getData(dataId); + if (myDesigner != null) { + if (PlatformDataKeys.FILE_EDITOR.is(dataId)) { + return myDesigner.getEditor(); + } + return myDesigner.getActionPanel().getData(dataId); } return null; } @@ -145,7 +130,7 @@ public final class ComponentTree extends Tree implements DataProvider { DefaultMutableTreeNode node = (DefaultMutableTreeNode)value; Object userObject = node.getUserObject(); - if (myDecorator != null && userObject instanceof TreeNodeDescriptor) { + if (myDesigner != null && userObject instanceof TreeNodeDescriptor) { TreeNodeDescriptor descriptor = (TreeNodeDescriptor)userObject; Object element = descriptor.getElement(); @@ -189,11 +174,11 @@ public final class ComponentTree extends Tree implements DataProvider { private AttributeWrapper getAttributeWrapper(RadComponent component) { AttributeWrapper wrapper = AttributeWrapper.DEFAULT; - final HighlightDisplayLevel level = getHighlightDisplayLevel(myProject, component); + final HighlightDisplayLevel level = getHighlightDisplayLevel(myDesigner.getProject(), component); if (level != null) { TextAttributesKey attributesKey = - SeverityRegistrar.getInstance(myProject).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); + SeverityRegistrar.getInstance(myDesigner.getProject()).getHighlightInfoTypeBySeverity(level.getSeverity()).getAttributesKey(); final TextAttributes textAttributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(attributesKey); wrapper = new AttributeWrapper() { @@ -229,22 +214,30 @@ public final class ComponentTree extends Tree implements DataProvider { boolean leaf, int row, boolean hasFocus) { - RadComponent component = extractComponent(value); + try { + RadComponent component = extractComponent(value); - if (component != null) { - myDecorator.decorate(component, this, getAttributeWrapper(component), true); + if (component != null) { + myDesigner.getTreeDecorator().decorate(component, this, getAttributeWrapper(component), true); - if (myMarkComponent == component) { - if (myMarkFeedback == FeedbackTreeLayer.INSERT_SELECTION) { - setBorder(BorderFactory.createLineBorder(Color.RED, 1)); + if (myMarkComponent == component) { + if (myMarkFeedback == FeedbackTreeLayer.INSERT_SELECTION) { + setBorder(BorderFactory.createLineBorder(Color.RED, 1)); + } + else { + setBorder(new InsertBorder(myMarkFeedback)); + } } else { - setBorder(new InsertBorder(myMarkFeedback)); + setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); } } - else { - setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1)); + } + catch (RuntimeException e) { + if (myDesigner == null) { + throw e; } + myDesigner.showError("Tree paint operation", e); } } }); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/CaptionPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/CaptionPanel.java index 7eb831645f13..1005ccfa4a87 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/CaptionPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/CaptionPanel.java @@ -142,7 +142,7 @@ public class CaptionPanel extends JLayeredPane implements DataProvider, DeletePr add(new GlassLayer(designer.getToolProvider(), myArea), DesignerEditorPanel.LAYER_GLASS); - myDecorationLayer = new DecorationLayer(myArea); + myDecorationLayer = new DecorationLayer(designer, myArea); add(myDecorationLayer, DesignerEditorPanel.LAYER_DECORATION); myFeedbackLayer = new FeedbackLayer(); diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DecorationLayer.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DecorationLayer.java index d82ebae61dbb..91c010fba0f9 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DecorationLayer.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DecorationLayer.java @@ -29,10 +29,12 @@ import java.util.List; * @author Alexander Lobas */ public class DecorationLayer extends JComponent { + private final DesignerEditorPanel myDesigner; private final EditableArea myArea; private boolean myShowSelection = true; - public DecorationLayer(EditableArea area) { + public DecorationLayer(DesignerEditorPanel designer, EditableArea area) { + myDesigner = designer; myArea = area; } @@ -66,13 +68,18 @@ public class DecorationLayer extends JComponent { @Override public void paint(Graphics g) { - if (myArea.getRootComponent() != null) { - Graphics2D g2d = (Graphics2D)g; - paintStaticDecorators(g2d); - if (myShowSelection) { - paintSelection(g2d); + try { + if (myArea.getRootComponent() != null) { + Graphics2D g2d = (Graphics2D)g; + paintStaticDecorators(g2d); + if (myShowSelection) { + paintSelection(g2d); + } } } + catch (Throwable e) { + myDesigner.showError("Paint operation", e); + } } private void paintStaticDecorators(Graphics2D g) { diff --git a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java index 503b4ad58db2..b6dd0ebf50a4 100644 --- a/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java +++ b/plugins/ui-designer/ui-designer-new/src/com/intellij/designer/designSurface/DesignerEditorPanel.java @@ -262,7 +262,7 @@ public abstract class DesignerEditorPanel extends JPanel implements DataProvider myGlassLayer = new GlassLayer(myToolProvider, mySurfaceArea); myLayeredPane.add(myGlassLayer, LAYER_GLASS); - myDecorationLayer = new DecorationLayer(mySurfaceArea); + myDecorationLayer = new DecorationLayer(this, mySurfaceArea); myLayeredPane.add(myDecorationLayer, LAYER_DECORATION); myFeedbackLayer = new FeedbackLayer();