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 108-113
Link Here
|
108 |
keywords(e, r.keywords(), r.keywordsCategory(), r, file); |
115 |
keywords(e, r.keywords(), r.keywordsCategory(), r, file); |
109 |
file.write(); |
116 |
file.write(); |
110 |
} |
117 |
} |
|
|
118 |
|
119 |
ArrayList<KeywordPanel> advanced = new ArrayList<KeywordPanel>(); |
120 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanel.class)) { |
121 |
KeywordPanel annotation = e.getAnnotation(KeywordPanel.class); |
122 |
if (annotation != null) { |
123 |
String location = annotation.location(); |
124 |
if(location.equals(OptionsDisplayer.ADVANCED)) { |
125 |
advanced.add(annotation); |
126 |
} |
127 |
} |
128 |
} |
129 |
Collections.sort(advanced, new AdvancedComparable()); |
130 |
|
131 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanel.class)) { |
132 |
handleElement(e, e.getAnnotation(KeywordPanel.class), advanced, null); |
133 |
} |
134 |
for (Element e : roundEnv.getElementsAnnotatedWith(KeywordPanels.class)) { |
135 |
KeywordPanels r = e.getAnnotation(KeywordPanels.class); |
136 |
KeywordPanel[] panels = r.value(); |
137 |
for (int i = 0; i < panels.length; i++) { |
138 |
handleElement(e, panels[i], advanced, e.asType().toString()); |
139 |
} |
140 |
} |
111 |
for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) { |
141 |
for (Element e : roundEnv.getElementsAnnotatedWith(ContainerRegistration.class)) { |
112 |
ContainerRegistration r = e.getAnnotation(ContainerRegistration.class); |
142 |
ContainerRegistration r = e.getAnnotation(ContainerRegistration.class); |
113 |
LayerBuilder builder = layer(e); |
143 |
LayerBuilder builder = layer(e); |
Lines 123-128
Link Here
|
123 |
} |
153 |
} |
124 |
return true; |
154 |
return true; |
125 |
} |
155 |
} |
|
|
156 |
|
157 |
private void handleElement(Element e, KeywordPanel annotation, ArrayList<KeywordPanel> advanced, String name) throws LayerGenerationException { |
158 |
int index = annotation.index(); |
159 |
if (annotation.location().equals(OptionsDisplayer.ADVANCED)) { |
160 |
index = advanced.indexOf(annotation); |
161 |
} |
162 |
File file = layer(e). |
163 |
instanceFile("OptionsDialog/PanelKeywords", name, annotation, null). |
164 |
stringvalue("instanceOf", JPanel.class.getName()). |
165 |
bundlevalue("location", annotation.location(), annotation, "location"). |
166 |
bundlevalue("id", annotation.id()). |
167 |
intvalue("index", index); |
168 |
int i = 1; |
169 |
for (String keyword : annotation.keywords()) { |
170 |
file.bundlevalue("keyword-".concat(Integer.toString(i++)), keyword, annotation, "keywords"); |
171 |
} |
172 |
file.write(); |
173 |
} |
174 |
|
175 |
private class AdvancedComparable implements Comparator<KeywordPanel> { |
176 |
|
177 |
@Override |
178 |
public int compare(KeywordPanel r1, KeywordPanel r2) { |
179 |
return r1.id().compareTo(r2.id()); |
180 |
} |
181 |
} |
126 |
|
182 |
|
127 |
private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException { |
183 |
private void iconBase(Element e, String iconBase, Annotation r, File file, LayerBuilder builder) throws LayerGenerationException { |
128 |
builder.validateResource(iconBase, e, r, "iconBase", true); |
184 |
builder.validateResource(iconBase, e, r, "iconBase", true); |