This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 271069
Collapse All | Expand All

(-)a/spi.editor.hints/src/org/netbeans/modules/editor/hints/FixAction.java (-7 / +28 lines)
Lines 44-49 Link Here
44
package org.netbeans.modules.editor.hints;
44
package org.netbeans.modules.editor.hints;
45
45
46
import java.awt.event.ActionEvent;
46
import java.awt.event.ActionEvent;
47
import java.util.Collections;
48
import java.util.HashSet;
49
import java.util.Set;
47
import javax.swing.AbstractAction;
50
import javax.swing.AbstractAction;
48
import javax.swing.Action;
51
import javax.swing.Action;
49
import javax.swing.text.JTextComponent;
52
import javax.swing.text.JTextComponent;
Lines 59-74 Link Here
59
 */
62
 */
60
public class FixAction extends AbstractAction {
63
public class FixAction extends AbstractAction {
61
    
64
    
65
    private static final Set<String> fixableAnnotations = new HashSet<>();
66
    static {
67
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_err_fixable"); // NOI18N
68
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_hint_fixable"); // NOI18N
69
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable"); // NOI18N
70
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_warn_fixable"); // NOI18N    
71
    }
72
62
    public FixAction() {
73
    public FixAction() {
63
        putValue(NAME, NbBundle.getMessage(FixAction.class, "NM_FixAction"));
74
        putValue(NAME, NbBundle.getMessage(FixAction.class, "NM_FixAction"));
64
        putValue("supported-annotation-types", new String[] {
65
            "org-netbeans-spi-editor-hints-parser_annotation_err_fixable",
66
            "org-netbeans-spi-editor-hints-parser_annotation_warn_fixable",
67
            "org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable",
68
            "org-netbeans-spi-editor-hints-parser_annotation_hint_fixable"
69
        });
70
    }
75
    }
71
    
76
77
    /*package*/ static void addFixableAnnotationType(String fixableAnnotation) {
78
        fixableAnnotations.add(fixableAnnotation);
79
    }
80
81
    /*package*/ static  Set<String> getFixableAnnotationTypes() {
82
        return Collections.unmodifiableSet(fixableAnnotations);
83
    }
84
85
    @Override
86
    public Object getValue(String key) {
87
        if ("supported-annotation-types".equals(key)) {//NOI18N
88
            return fixableAnnotations.toArray(new String[0]);
89
        }
90
        return super.getValue(key); //To change body of generated methods, choose Tools | Templates.
91
    }
92
72
    public void actionPerformed(ActionEvent e) {
93
    public void actionPerformed(ActionEvent e) {
73
        if (!HintsUI.getDefault().invokeDefaultAction(true)) {
94
        if (!HintsUI.getDefault().invokeDefaultAction(true)) {
74
            Object source = e.getSource();
95
            Object source = e.getSource();
(-)a/spi.editor.hints/src/org/netbeans/modules/editor/hints/HintsUI.java (-13 / +1 lines)
Lines 51-57 Link Here
51
import java.awt.Container;
51
import java.awt.Container;
52
import java.awt.Cursor;
52
import java.awt.Cursor;
53
import java.awt.Dimension;
53
import java.awt.Dimension;
54
import java.awt.GraphicsConfiguration;
55
import java.awt.GraphicsDevice;
54
import java.awt.GraphicsDevice;
56
import java.awt.GraphicsEnvironment;
55
import java.awt.GraphicsEnvironment;
57
import java.awt.HeadlessException;
56
import java.awt.HeadlessException;
Lines 73-83 Link Here
73
import java.lang.ref.WeakReference;
72
import java.lang.ref.WeakReference;
74
import java.util.Arrays;
73
import java.util.Arrays;
75
import java.util.Collection;
74
import java.util.Collection;
76
import java.util.HashSet;
77
import java.util.LinkedList;
75
import java.util.LinkedList;
78
import java.util.List;
76
import java.util.List;
79
import java.util.Map;
77
import java.util.Map;
80
import java.util.Set;
81
import java.util.concurrent.atomic.AtomicBoolean;
78
import java.util.concurrent.atomic.AtomicBoolean;
82
import java.util.logging.Level;
79
import java.util.logging.Level;
83
import java.util.logging.LogRecord;
80
import java.util.logging.LogRecord;
Lines 155-174 Link Here
155
    //-J-Dorg.netbeans.modules.editor.hints.HintsUI.always.show.error=true
152
    //-J-Dorg.netbeans.modules.editor.hints.HintsUI.always.show.error=true
156
    private static final boolean ALWAYS_SHOW_ERROR_MESSAGE = Boolean.getBoolean(HintsUI.class.getName() + ".always.show.error");
153
    private static final boolean ALWAYS_SHOW_ERROR_MESSAGE = Boolean.getBoolean(HintsUI.class.getName() + ".always.show.error");
157
    private static HintsUI INSTANCE;
154
    private static HintsUI INSTANCE;
158
    private static final Set<String> fixableAnnotations;
159
    private static final String POPUP_NAME = "hintsPopup"; // NOI18N
155
    private static final String POPUP_NAME = "hintsPopup"; // NOI18N
160
    private static final String SUB_POPUP_NAME = "subHintsPopup"; // NOI18N
156
    private static final String SUB_POPUP_NAME = "subHintsPopup"; // NOI18N
161
    private static final int POPUP_VERTICAL_OFFSET = 5;
157
    private static final int POPUP_VERTICAL_OFFSET = 5;
162
    private static final RequestProcessor WORKER = new RequestProcessor(HintsUI.class.getName(), 1, false, false);
158
    private static final RequestProcessor WORKER = new RequestProcessor(HintsUI.class.getName(), 1, false, false);
163
159
164
    static {
165
        fixableAnnotations = new HashSet<String>(3);
166
167
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_err_fixable"); // NOI18N
168
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_hint_fixable"); // NOI18N
169
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_verifier_fixable"); // NOI18N
170
        fixableAnnotations.add("org-netbeans-spi-editor-hints-parser_annotation_warn_fixable"); // NOI18N
171
    }
172
160
173
    public static synchronized HintsUI getDefault() {
161
    public static synchronized HintsUI getDefault() {
174
        if (INSTANCE == null)
162
        if (INSTANCE == null)
Lines 681-687 Link Here
681
                        return false;
669
                        return false;
682
                    }
670
                    }
683
                    String type = activeAnnotation.getAnnotationType();
671
                    String type = activeAnnotation.getAnnotationType();
684
                    if (!fixableAnnotations.contains(type) && onlyActive) {
672
                    if (!FixAction.getFixableAnnotationTypes().contains(type) && onlyActive) {
685
                        return false;
673
                        return false;
686
                    }
674
                    }
687
                    if (onlyActive) {
675
                    if (onlyActive) {
(-)a/spi.editor.hints/src/org/netbeans/modules/editor/hints/ParseErrorAnnotation.java (+4 lines)
Lines 128-133 Link Here
128
                    throw new IllegalArgumentException(String.valueOf(severity));
128
                    throw new IllegalArgumentException(String.valueOf(severity));
129
            }
129
            }
130
        } else {
130
        } else {
131
            if (hasFixes) {
132
                //dynamicly change the regiister of fixable annotations Fix action (click on the icon) will work for.
133
                FixAction.addFixableAnnotationType(customType);
134
            }
131
            return customType;
135
            return customType;
132
        }
136
        }
133
    }
137
    }

Return to bug 271069