update copyright
[fedora-idea.git] / plugins / ui-designer / src / com / intellij / uiDesigner / designSurface / QuickFixManagerImpl.java
blob8625d4d5b085343e4b80e807a6f52f0ace9e6281
1 /*
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;
27 import javax.swing.*;
28 import javax.swing.event.TreeSelectionEvent;
29 import javax.swing.event.TreeSelectionListener;
30 import java.awt.*;
31 import java.util.ArrayList;
33 /**
34 * @author yole
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) {
42 hideIntentionHint();
43 updateIntentionHintVisibility();
45 });
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) {
59 return null;
61 RadComponent c = list.get(0);
62 return SwingUtilities.convertRectangle(c.getDelegee().getParent(),
63 c.getBounds(),
64 getEditor().getGlassLayer());
67 @Override
68 protected Rectangle getHintClipRect(final JViewport viewPort) {
69 // allow some overlap with editor bounds
70 Rectangle rc = viewPort.getViewRect();
71 rc.grow(4, 4);
72 return rc;