Lines 43-49
Link Here
|
43 |
package org.netbeans.modules.options; |
43 |
package org.netbeans.modules.options; |
44 |
|
44 |
|
45 |
import java.lang.annotation.Annotation; |
45 |
import java.lang.annotation.Annotation; |
|
|
46 |
import java.util.ArrayList; |
46 |
import java.util.Arrays; |
47 |
import java.util.Arrays; |
|
|
48 |
import java.util.Collections; |
49 |
import java.util.Comparator; |
47 |
import java.util.HashSet; |
50 |
import java.util.HashSet; |
48 |
import java.util.Set; |
51 |
import java.util.Set; |
49 |
import javax.annotation.processing.Processor; |
52 |
import javax.annotation.processing.Processor; |
Lines 52-61
Link Here
|
52 |
import javax.lang.model.SourceVersion; |
55 |
import javax.lang.model.SourceVersion; |
53 |
import javax.lang.model.element.Element; |
56 |
import javax.lang.model.element.Element; |
54 |
import javax.lang.model.element.TypeElement; |
57 |
import javax.lang.model.element.TypeElement; |
|
|
58 |
import javax.swing.JPanel; |
59 |
import org.netbeans.api.options.OptionsDisplayer; |
55 |
import org.netbeans.spi.options.AdvancedOption; |
60 |
import org.netbeans.spi.options.AdvancedOption; |
56 |
import org.netbeans.spi.options.OptionsCategory; |
61 |
import org.netbeans.spi.options.OptionsCategory; |
57 |
import org.netbeans.spi.options.OptionsPanelController; |
62 |
import org.netbeans.spi.options.OptionsPanelController; |
58 |
import org.netbeans.spi.options.OptionsPanelController.ContainerRegistration; |
63 |
import org.netbeans.spi.options.OptionsPanelController.ContainerRegistration; |
|
|
64 |
import org.netbeans.spi.options.OptionsPanelController.KeywordPanel; |
65 |
import org.netbeans.spi.options.OptionsPanelController.KeywordPanels; |
59 |
import org.netbeans.spi.options.OptionsPanelController.SubRegistration; |
66 |
import org.netbeans.spi.options.OptionsPanelController.SubRegistration; |
60 |
import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration; |
67 |
import org.netbeans.spi.options.OptionsPanelController.TopLevelRegistration; |
61 |
import org.openide.filesystems.annotations.LayerBuilder; |
68 |
import org.openide.filesystems.annotations.LayerBuilder; |
Lines 72-78
Link Here
|
72 |
return new HashSet<String>(Arrays.asList( |
79 |
return new HashSet<String>(Arrays.asList( |
73 |
TopLevelRegistration.class.getCanonicalName(), |
80 |
TopLevelRegistration.class.getCanonicalName(), |
74 |
ContainerRegistration.class.getCanonicalName(), |
81 |
ContainerRegistration.class.getCanonicalName(), |
75 |
SubRegistration.class.getCanonicalName() |
82 |
SubRegistration.class.getCanonicalName(), |
|
|
83 |
KeywordPanels.class.getCanonicalName(), |
84 |
KeywordPanel.class.getCanonicalName() |
76 |
)); |
85 |
)); |
77 |
} |
86 |
} |
78 |
|
87 |
|
Lines 108-113
Link Here
|
108 |
keywords(e, r.keywords(), r.keywordsCategory(), r, file); |
117 |
keywords(e, r.keywords(), r.keywordsCategory(), r, file); |
109 |
file.write(); |
118 |
file.write(); |
110 |
} |
119 |
} |
|
|
120 |
|
121 |
ArrayList<KeywordPanel> advanced = new ArrayList<KeywordPanel>(); |
122 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanel.class)) { |
123 |
KeywordPanel annotation = e.getAnnotation(KeywordPanel.class); |
124 |
if (annotation != null) { |
125 |
String location = annotation.location(); |
126 |
if(location.equals(OptionsDisplayer.ADVANCED)) { |
127 |
advanced.add(annotation); |
128 |
} |
129 |
} |
130 |
} |
131 |
Collections.sort(advanced, new AdvancedComparable()); |
132 |
|
133 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanel.class)) { |
134 |
handleElement(e, e.getAnnotation(KeywordPanel.class), advanced, ""); |
135 |
} |
136 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanels.class)) { |
137 |
KeywordPanels r = e.getAnnotation(KeywordPanels.class); |
138 |
KeywordPanel[] panels = r.value(); |
139 |
for (int i = 0; i < panels.length; i++) { |
140 |
handleElement(e, panels[i], advanced, Integer.toString(-(i + 1))); |
141 |
} |
142 |
} |
111 |
for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) { |
143 |
for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) { |
112 |
ContainerRegistration r = e.getAnnotation(ContainerRegistration.class); |
144 |
ContainerRegistration r = e.getAnnotation(ContainerRegistration.class); |
113 |
LayerBuilder builder = layer(e); |
145 |
LayerBuilder builder = layer(e); |
Lines 123-128
Link Here
|
123 |
} |
155 |
} |
124 |
return true; |
156 |
return true; |
125 |
} |
157 |
} |
|
|
158 |
|
159 |
private void handleElement(Element e, KeywordPanel annotation, ArrayList<KeywordPanel> advanced, String name) throws LayerGenerationException { |
160 |
int index = annotation.index(); |
161 |
if (annotation.location().equals(OptionsDisplayer.ADVANCED)) { |
162 |
index = advanced.indexOf(annotation); |
163 |
} |
164 |
File file = layer(e). |
165 |
file("OptionsDialog/KeywordPanels/".concat(e.asType().toString()).concat(name)). |
166 |
stringvalue("instanceOf", JPanel.class.getName()). |
167 |
bundlevalue("location", annotation.location(), annotation, "location"). |
168 |
bundlevalue("id", annotation.id()). |
169 |
intvalue("index", index); |
170 |
int i = 1; |
171 |
for (String keyword : annotation.keywords()) { |
172 |
file.bundlevalue("keyword-".concat(Integer.toString(i++)), keyword, annotation, "keywords"); |
173 |
} |
174 |
file.write(); |
175 |
} |
176 |
|
177 |
private class AdvancedComparable implements Comparator<KeywordPanel> { |
178 |
|
179 |
@Override |
180 |
public int compare(KeywordPanel r1, KeywordPanel r2) { |
181 |
return r1.id().compareTo(r2.id()); |
182 |
} |
183 |
} |
126 |
|
184 |
|
127 |
private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException { |
185 |
private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException { |
128 |
builder.validateResource(iconBase, e, r, "iconBase", true); |
186 |
builder.validateResource(iconBase, e, r, "iconBase", true); |