mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
annotation processors: allow configuration of generated sources production/test directory names either relative to module content root or module output directory
This commit is contained in:
@@ -56,6 +56,8 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
private TextFieldWithBrowseButton myProcessorPathField;
|
||||
private JTextField myGeneratedProductionDirField;
|
||||
private JTextField myGeneratedTestsDirField;
|
||||
private JRadioButton myRbRelativeToOutputRoot;
|
||||
private JRadioButton myRbRelativeToContentRoot;
|
||||
private ProcessorTableModel myProcessorsModel;
|
||||
private JCheckBox myCbEnableProcessing;
|
||||
private JBTable myProcessorTable;
|
||||
@@ -63,6 +65,12 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
private JPanel myProcessorPanel;
|
||||
private JPanel myOptionsPanel;
|
||||
private OptionsTableModel myOptionsModel;
|
||||
private JLabel myWarninglabel;
|
||||
private JLabel myStoreGenSourcesLabel;
|
||||
private JLabel myProductionLabel;
|
||||
private JLabel myTestLabel;
|
||||
private JPanel myProcessorTablePanel;
|
||||
private JPanel myOptionsTablePanel;
|
||||
|
||||
|
||||
public ProcessorProfilePanel(Project project) {
|
||||
@@ -71,11 +79,21 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
|
||||
myCbEnableProcessing = new JCheckBox("Enable annotation processing");
|
||||
|
||||
myRbClasspath = new JRadioButton("Obtain processors from project classpath");
|
||||
myRbProcessorsPath = new JRadioButton("Processor path:");
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(myRbClasspath);
|
||||
group.add(myRbProcessorsPath);
|
||||
{
|
||||
myRbClasspath = new JRadioButton("Obtain processors from project classpath");
|
||||
myRbProcessorsPath = new JRadioButton("Processor path:");
|
||||
ButtonGroup group = new ButtonGroup();
|
||||
group.add(myRbClasspath);
|
||||
group.add(myRbProcessorsPath);
|
||||
}
|
||||
|
||||
{
|
||||
myRbRelativeToContentRoot = new JRadioButton("Module content root");
|
||||
myRbRelativeToOutputRoot = new JRadioButton("Module output directory");
|
||||
final ButtonGroup group = new ButtonGroup();
|
||||
group.add(myRbRelativeToContentRoot);
|
||||
group.add(myRbRelativeToOutputRoot);
|
||||
}
|
||||
|
||||
myProcessorPathField = new TextFieldWithBrowseButton(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@@ -94,62 +112,66 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
}
|
||||
});
|
||||
|
||||
final JPanel processorTablePanel = new JPanel(new BorderLayout());
|
||||
myProcessorTablePanel = new JPanel(new BorderLayout());
|
||||
myProcessorsModel = new ProcessorTableModel();
|
||||
processorTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processors", false));
|
||||
myProcessorTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processors", false));
|
||||
myProcessorTable = new JBTable(myProcessorsModel);
|
||||
myProcessorTable.getEmptyText().setText("Compiler will run all automatically discovered processors");
|
||||
myProcessorPanel = createTablePanel(myProcessorTable);
|
||||
processorTablePanel.add(myProcessorPanel, BorderLayout.CENTER);
|
||||
myProcessorTablePanel.add(myProcessorPanel, BorderLayout.CENTER);
|
||||
|
||||
final JPanel optionsTablePanel = new JPanel(new BorderLayout());
|
||||
myOptionsTablePanel = new JPanel(new BorderLayout());
|
||||
myOptionsModel = new OptionsTableModel();
|
||||
optionsTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processor options", false));
|
||||
myOptionsTablePanel.setBorder(IdeBorderFactory.createTitledBorder("Annotation Processor options", false));
|
||||
myOptionsTable = new JBTable(myOptionsModel);
|
||||
myOptionsTable.getEmptyText().setText("No processor-specific options configured");
|
||||
myOptionsPanel = createTablePanel(myOptionsTable);
|
||||
optionsTablePanel.add(myOptionsPanel, BorderLayout.CENTER);
|
||||
myOptionsTablePanel.add(myOptionsPanel, BorderLayout.CENTER);
|
||||
|
||||
myGeneratedProductionDirField = new JTextField();
|
||||
myGeneratedTestsDirField = new JTextField();
|
||||
|
||||
final JLabel warning = new JLabel("<html>WARNING!<br>" +
|
||||
myWarninglabel = new JLabel("<html>WARNING!<br>" +
|
||||
/*"All source files located in the generated sources output directory WILL BE EXCLUDED from annotation processing. " +*/
|
||||
"If option 'Clear output directory on rebuild' is enabled, " +
|
||||
"the entire contents of directories where generated sources are stored WILL BE CLEARED on rebuild.</html>");
|
||||
warning.setFont(warning.getFont().deriveFont(Font.BOLD));
|
||||
myWarninglabel.setFont(myWarninglabel.getFont().deriveFont(Font.BOLD));
|
||||
|
||||
add(myCbEnableProcessing,
|
||||
new GridBagConstraints(0, 0, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
|
||||
add(myRbClasspath,
|
||||
new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
|
||||
add(myRbProcessorsPath,
|
||||
new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
add(myProcessorPathField,
|
||||
new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
|
||||
|
||||
final JLabel noteMessage = new JLabel("<html>Source files generated by annotation processors will be stored under the project output directory. " +
|
||||
"To override this behaviour for this profile you may specify the directory name in the field below. " +
|
||||
"If specified, the directory will be created under corresponding module's content root.</html>");
|
||||
add(noteMessage,
|
||||
new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
myStoreGenSourcesLabel = new JLabel("Store generated sources relative to: ");
|
||||
add(myStoreGenSourcesLabel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0));
|
||||
add(myRbRelativeToOutputRoot,
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0));
|
||||
add(myRbRelativeToContentRoot,
|
||||
new GridBagConstraints(2, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(15, 5, 0, 0), 0, 0));
|
||||
|
||||
add(new JLabel("Production sources directory:"),
|
||||
new GridBagConstraints(0, 4, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
myProductionLabel = new JLabel("Production sources directory:");
|
||||
add(myProductionLabel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
add(myGeneratedProductionDirField,
|
||||
new GridBagConstraints(1, 4, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
|
||||
add(new JLabel("Test sources directory:"),
|
||||
new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
myTestLabel = new JLabel("Test sources directory:");
|
||||
add(myTestLabel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
add(myGeneratedTestsDirField,
|
||||
new GridBagConstraints(1, 5, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
new GridBagConstraints(1, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
|
||||
add(processorTablePanel,
|
||||
new GridBagConstraints(0, 6, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
add(optionsTablePanel,
|
||||
new GridBagConstraints(0, 7, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
add(warning,
|
||||
new GridBagConstraints(0, 8, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
add(myProcessorTablePanel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
add(myOptionsTablePanel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
add(myWarninglabel,
|
||||
new GridBagConstraints(0, GridBagConstraints.RELATIVE, 3, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
|
||||
myRbClasspath.addItemListener(new ItemListener() {
|
||||
public void itemStateChanged(ItemEvent e) {
|
||||
@@ -185,6 +207,12 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
myGeneratedProductionDirField.setText(productionDirName != null? productionDirName.trim() : "");
|
||||
final String testsDirName = config.getGeneratedSourcesDirectoryName(true);
|
||||
myGeneratedTestsDirField.setText(testsDirName != null? testsDirName.trim() : "");
|
||||
if (config.isOutputRelativeToContentRoot()) {
|
||||
myRbRelativeToContentRoot.setSelected(true);
|
||||
}
|
||||
else {
|
||||
myRbRelativeToOutputRoot.setSelected(true);
|
||||
}
|
||||
myProcessorsModel.setProcessors(config.getProcessors());
|
||||
myOptionsModel.setOptions(config.getProcessorOptions());
|
||||
|
||||
@@ -201,6 +229,8 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
final String testsDir = myGeneratedTestsDirField.getText().trim();
|
||||
profile.setGeneratedSourcesDirectoryName(StringUtil.isEmpty(testsDir)? null : testsDir, true);
|
||||
|
||||
profile.setOutputRelativeToContentRoot(myRbRelativeToContentRoot.isSelected());
|
||||
|
||||
profile.clearProcessors();
|
||||
for (String processor : myProcessorsModel.getProcessors()) {
|
||||
profile.addProcessor(processor);
|
||||
@@ -240,6 +270,14 @@ public class ProcessorProfilePanel extends JPanel {
|
||||
updateTable(myOptionsPanel, myOptionsTable, enabled);
|
||||
myGeneratedProductionDirField.setEnabled(enabled);
|
||||
myGeneratedTestsDirField.setEnabled(enabled);
|
||||
myRbRelativeToOutputRoot.setEnabled(enabled);
|
||||
myRbRelativeToContentRoot.setEnabled(enabled);
|
||||
myWarninglabel.setEnabled(enabled);
|
||||
myStoreGenSourcesLabel.setEnabled(enabled);
|
||||
myProductionLabel.setEnabled(enabled);
|
||||
myTestLabel.setEnabled(enabled);
|
||||
myProcessorTablePanel.setEnabled(enabled);
|
||||
myOptionsTablePanel.setEnabled(enabled);
|
||||
}
|
||||
|
||||
private static void updateTable(final JPanel tablePanel, final JBTable table, boolean enabled) {
|
||||
|
||||
Reference in New Issue
Block a user