2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com
.intellij
.uiDesigner
.designSurface
;
18 import com
.intellij
.uiDesigner
.ErrorAnalyzer
;
19 import com
.intellij
.uiDesigner
.ErrorInfo
;
20 import com
.intellij
.uiDesigner
.FormEditingUtil
;
21 import com
.intellij
.uiDesigner
.radComponents
.RadComponent
;
22 import com
.intellij
.uiDesigner
.componentTree
.ComponentTree
;
23 import com
.intellij
.uiDesigner
.propertyInspector
.UIDesignerToolWindowManager
;
24 import com
.intellij
.uiDesigner
.quickFixes
.QuickFixManager
;
25 import org
.jetbrains
.annotations
.NotNull
;
28 import javax
.swing
.event
.TreeSelectionEvent
;
29 import javax
.swing
.event
.TreeSelectionListener
;
31 import java
.util
.ArrayList
;
36 public class QuickFixManagerImpl
extends QuickFixManager
<GlassLayer
> {
37 public QuickFixManagerImpl(final GuiEditor editor
, final GlassLayer component
, final JViewport viewPort
) {
38 super(editor
, component
, viewPort
);
39 final ComponentTree tree
= UIDesignerToolWindowManager
.getInstance(editor
.getProject()).getComponentTree();
40 tree
.addTreeSelectionListener(new TreeSelectionListener() {
41 public void valueChanged(TreeSelectionEvent e
) {
43 updateIntentionHintVisibility();
48 @NotNull protected ErrorInfo
[] getErrorInfos() {
49 final ArrayList
<RadComponent
> list
= FormEditingUtil
.getSelectedComponents(getEditor());
50 if (list
.size() != 1) {
51 return ErrorInfo
.EMPTY_ARRAY
;
53 return ErrorAnalyzer
.getAllErrorsForComponent(list
.get(0));
56 protected Rectangle
getErrorBounds() {
57 final ArrayList
<RadComponent
> list
= FormEditingUtil
.getSelectedComponents(getEditor());
58 if (list
.size() != 1) {
61 RadComponent c
= list
.get(0);
62 return SwingUtilities
.convertRectangle(c
.getDelegee().getParent(),
64 getEditor().getGlassLayer());
68 protected Rectangle
getHintClipRect(final JViewport viewPort
) {
69 // allow some overlap with editor bounds
70 Rectangle rc
= viewPort
.getViewRect();