mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
UI for generated sources output dir handling
This commit is contained in:
@@ -54,6 +54,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.compiler.CompilerConfiguration");
|
||||
@NonNls public static final String TESTS_EXTERNAL_COMPILER_HOME_PROPERTY_NAME = "tests.external.compiler.home";
|
||||
public static final int DEPENDENCY_FORMAT_VERSION = 54;
|
||||
private static final String DEFAULT_GENERATED_DIR_NAME = "generated";
|
||||
|
||||
@SuppressWarnings({"WeakerAccess"}) public String DEFAULT_COMPILER;
|
||||
@NotNull private BackendCompiler myDefaultJavaCompiler;
|
||||
@@ -80,11 +81,10 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
private boolean myEnableAnnotationProcessors = false;
|
||||
private final Map<String, String> myProcessorsMap = new HashMap<String, String>(); // map: AnnotationProcessorName -> options
|
||||
private boolean myObtainProcessorsFromClasspath = true;
|
||||
private boolean myStoreGenerateSourcesUnderModuleContent = false;
|
||||
private String myGeneratedDirName = "generated";
|
||||
private String myGeneratedDirName = DEFAULT_GENERATED_DIR_NAME;
|
||||
private String myProcessorPath = "";
|
||||
private final Set<Module> myExcludedModules = new HashSet<Module>();
|
||||
private final Set<String> myExcludedModuleNames = new HashSet<String>();
|
||||
private final Map<Module, Boolean> myProcessedModules = new HashMap<Module, Boolean>();
|
||||
private final Map<String, Boolean> myModuleNames = new HashMap<String, Boolean>();
|
||||
|
||||
|
||||
public CompilerConfigurationImpl(Project project, ModuleManager moduleManager) {
|
||||
@@ -100,13 +100,14 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
}
|
||||
|
||||
public void beforeModuleRemoved(Project project, Module module) {
|
||||
myExcludedModules.remove(module);
|
||||
myExcludedModuleNames.remove(module.getName());
|
||||
myProcessedModules.remove(module);
|
||||
myModuleNames.remove(module.getName());
|
||||
}
|
||||
|
||||
public void moduleAdded(Project project, Module module) {
|
||||
if (myExcludedModuleNames.remove(module.getName())) {
|
||||
myExcludedModules.add(module);
|
||||
final Boolean storeUnderContent = myModuleNames.remove(module.getName());
|
||||
if (storeUnderContent != null) {
|
||||
myProcessedModules.put(module, storeUnderContent);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -312,22 +313,18 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
myObtainProcessorsFromClasspath = obtainProcessorsFromClasspath;
|
||||
}
|
||||
|
||||
public boolean isStoreGenerateSourcesUnderModuleContent(Module module) {
|
||||
// todo: make this per-module setting
|
||||
return myStoreGenerateSourcesUnderModuleContent;
|
||||
}
|
||||
|
||||
public void setStoreGenerateSourcesUnderModuleContent(boolean storeGenerateSourcesUnderModuleContent) {
|
||||
myStoreGenerateSourcesUnderModuleContent = storeGenerateSourcesUnderModuleContent;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getGeneratedDirName() {
|
||||
return myGeneratedDirName;
|
||||
}
|
||||
|
||||
public void setGeneratedDirName(String generatedDirName) {
|
||||
myGeneratedDirName = generatedDirName;
|
||||
if (generatedDirName == null || generatedDirName.length() == 0) {
|
||||
myGeneratedDirName = DEFAULT_GENERATED_DIR_NAME;
|
||||
}
|
||||
else {
|
||||
myGeneratedDirName = generatedDirName;
|
||||
}
|
||||
}
|
||||
|
||||
public String getProcessorPath() {
|
||||
@@ -347,14 +344,22 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
myProcessorsMap.putAll(map);
|
||||
}
|
||||
|
||||
public Set<Module> getExcludedModules() {
|
||||
return Collections.unmodifiableSet(myExcludedModules);
|
||||
public void setAnotationProcessedModules(Map<Module, Boolean> modules) {
|
||||
myProcessedModules.clear();
|
||||
myModuleNames.clear();
|
||||
myProcessedModules.putAll(modules);
|
||||
}
|
||||
|
||||
public void setExcludedModules(Collection<Module> modules) {
|
||||
myExcludedModules.clear();
|
||||
myExcludedModuleNames.clear();
|
||||
myExcludedModules.addAll(modules);
|
||||
public Map<Module, Boolean> getAnotationProcessedModules() {
|
||||
return Collections.unmodifiableMap(myProcessedModules);
|
||||
}
|
||||
|
||||
public boolean isAnnotationProcessingEnabled(Module module) {
|
||||
return myProcessedModules.containsKey(module);
|
||||
}
|
||||
|
||||
public boolean isStoreGeneratedSourcesUnderContent(Module module) {
|
||||
return Boolean.TRUE.equals(myProcessedModules.get(module));
|
||||
}
|
||||
|
||||
private void addWildcardResourcePattern(@NonNls final String wildcardPattern) throws MalformedPatternException {
|
||||
@@ -542,8 +547,7 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
if (annotationProcessingSettings != null) {
|
||||
myEnableAnnotationProcessors = Boolean.valueOf(annotationProcessingSettings.getAttributeValue("enabled", "false"));
|
||||
myObtainProcessorsFromClasspath = Boolean.valueOf(annotationProcessingSettings.getAttributeValue("useClasspath", "true"));
|
||||
myStoreGenerateSourcesUnderModuleContent = Boolean.valueOf(annotationProcessingSettings.getAttributeValue("storeGeneratedUnderContent", "false"));
|
||||
myGeneratedDirName = annotationProcessingSettings.getAttributeValue("generatedDirName", "generated");
|
||||
myGeneratedDirName = annotationProcessingSettings.getAttributeValue("generatedDirName", DEFAULT_GENERATED_DIR_NAME);
|
||||
|
||||
final StringBuilder pathBuilder = new StringBuilder();
|
||||
for (Element pathElement : ((Collection<Element>)annotationProcessingSettings.getChildren("processorPath"))) {
|
||||
@@ -563,23 +567,25 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
final String options = processorChild.getAttributeValue("options", "");
|
||||
myProcessorsMap.put(name, options);
|
||||
}
|
||||
myExcludedModules.clear();
|
||||
myExcludedModuleNames.clear();
|
||||
final Collection<Element> excluded = (Collection<Element>)annotationProcessingSettings.getChildren("excludeModule");
|
||||
if (excluded.size() > 0) {
|
||||
myProcessedModules.clear();
|
||||
myModuleNames.clear();
|
||||
|
||||
final Collection<Element> processed = (Collection<Element>)annotationProcessingSettings.getChildren("processModule");
|
||||
if (processed.size() > 0) {
|
||||
final Map<String, Module> moduleMap = new com.intellij.util.containers.HashMap<String, Module>();
|
||||
for (Module module : myModuleManager.getModules()) {
|
||||
moduleMap.put(module.getName(), module);
|
||||
}
|
||||
for (Element moduleElement : excluded) {
|
||||
for (Element moduleElement : processed) {
|
||||
final String name = moduleElement.getAttributeValue("name");
|
||||
final Boolean isStoreUnderContent = Boolean.valueOf(moduleElement.getAttributeValue("storeGeneratedUnderContent", "false"));
|
||||
if (name != null) {
|
||||
final Module module = moduleMap.get(name);
|
||||
if (module != null) {
|
||||
myExcludedModules.add(module);
|
||||
myProcessedModules.put(module, isStoreUnderContent);
|
||||
}
|
||||
else {
|
||||
myExcludedModuleNames.add(name);
|
||||
myModuleNames.put(name, isStoreUnderContent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,7 +624,6 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
parentNode.addContent(annotationProcessingSettings);
|
||||
annotationProcessingSettings.setAttribute("enabled", String.valueOf(myEnableAnnotationProcessors));
|
||||
annotationProcessingSettings.setAttribute("useClasspath", String.valueOf(myObtainProcessorsFromClasspath));
|
||||
annotationProcessingSettings.setAttribute("storeGeneratedUnderContent", String.valueOf(myStoreGenerateSourcesUnderModuleContent));
|
||||
annotationProcessingSettings.setAttribute("generatedDirName", myGeneratedDirName);
|
||||
if (myProcessorPath.length() > 0) {
|
||||
final StringTokenizer tokenizer = new StringTokenizer(myProcessorPath, File.pathSeparator, false);
|
||||
@@ -635,16 +640,17 @@ public class CompilerConfigurationImpl extends CompilerConfiguration implements
|
||||
processor.setAttribute("name", entry.getKey());
|
||||
processor.setAttribute("options", entry.getValue());
|
||||
}
|
||||
final List<Module> modules = new ArrayList<Module>(getExcludedModules());
|
||||
final List<Module> modules = new ArrayList<Module>(myProcessedModules.keySet());
|
||||
Collections.sort(modules, new Comparator<Module>() {
|
||||
public int compare(Module o1, Module o2) {
|
||||
return o1.getName().compareToIgnoreCase(o2.getName());
|
||||
}
|
||||
});
|
||||
for (Module module : modules) {
|
||||
final Element moduleElement = new Element("excludeModule");
|
||||
final Element moduleElement = new Element("processModule");
|
||||
annotationProcessingSettings.addContent(moduleElement);
|
||||
moduleElement.setAttribute("name", module.getName());
|
||||
moduleElement.setAttribute("storeGeneratedUnderContent", String.valueOf(isStoreGeneratedSourcesUnderContent(module)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -155,7 +155,7 @@ public class CompileDriver {
|
||||
myGenerationCompilerModuleToOutputDirMap.put(pair, outputs);
|
||||
}
|
||||
if (config.isAnnotationProcessorsEnabled()) {
|
||||
if (!config.getExcludedModules().contains(module)) {
|
||||
if (config.isAnnotationProcessingEnabled(module)) {
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
if (path != null) {
|
||||
lookupVFile(lfs, path); // ensure the file is created and added to VFS
|
||||
@@ -1181,7 +1181,7 @@ public class CompileDriver {
|
||||
final CompilerConfiguration config = CompilerConfiguration.getInstance(myProject);
|
||||
if (config.isAnnotationProcessorsEnabled()) {
|
||||
for (Module module : modules) {
|
||||
if (!config.getExcludedModules().contains(module)) {
|
||||
if (config.isAnnotationProcessingEnabled(module)) {
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
if (path != null) {
|
||||
outputDirs.add(new File(path));
|
||||
@@ -1874,10 +1874,11 @@ public class CompileDriver {
|
||||
modulesWithoutOutputPathSpecified.add(module.getName());
|
||||
}
|
||||
}
|
||||
if (config.isAnnotationProcessorsEnabled() && !config.getExcludedModules().contains(module)) {
|
||||
if (config.isAnnotationProcessorsEnabled() && config.isAnnotationProcessingEnabled(module)) {
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
if (path == null) {
|
||||
if (CompilerProjectExtension.getInstance(module.getProject()).getCompilerOutputUrl() == null) {
|
||||
final CompilerProjectExtension extension = CompilerProjectExtension.getInstance(module.getProject());
|
||||
if (extension == null || extension.getCompilerOutputUrl() == null) {
|
||||
isProjectCompilePathSpecified = false;
|
||||
}
|
||||
else {
|
||||
@@ -1958,9 +1959,8 @@ public class CompileDriver {
|
||||
continue; // no need to check one-module chunks
|
||||
}
|
||||
if (config.isAnnotationProcessorsEnabled()) {
|
||||
final Set<Module> excluded = config.getExcludedModules();
|
||||
for (Module chunkModule : chunkModules) {
|
||||
if (!excluded.contains(chunkModule)) {
|
||||
if (config.isAnnotationProcessingEnabled(chunkModule)) {
|
||||
showCyclesNotSupportedForAnnotationProcessors(chunkModules.toArray(new Module[chunkModules.size()]));
|
||||
return false;
|
||||
}
|
||||
|
||||
+1
-1
@@ -112,7 +112,7 @@ public class AnnotationProcessingCompiler implements TranslatingCompiler{
|
||||
private boolean isExcludedFromAnnotationProcessing(VirtualFile file, CompileContext context) {
|
||||
final Module module = context.getModuleByFile(file);
|
||||
if (module != null) {
|
||||
if (myConfig.getExcludedModules().contains(module)) {
|
||||
if (!myConfig.isAnnotationProcessingEnabled(module)) {
|
||||
return true;
|
||||
}
|
||||
final String path = CompilerPaths.getAnnotationProcessorsGenerationPath(module);
|
||||
|
||||
+31
-10
@@ -9,6 +9,8 @@ import com.intellij.openapi.options.Configurable;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.ui.ex.MultiLineLabel;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.TableUtil;
|
||||
@@ -29,7 +31,10 @@ import java.awt.event.ActionListener;
|
||||
import java.awt.event.ItemEvent;
|
||||
import java.awt.event.ItemListener;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -43,6 +48,7 @@ public class AnnotationProcessorsConfigurable implements Configurable{
|
||||
private TextFieldWithBrowseButton myProcessorPathField;
|
||||
private ProcessorTableModel myProcessorsModel;
|
||||
private JCheckBox myCbEnableProcessing;
|
||||
private JTextField myGeneratedSourcesDirField;
|
||||
private JButton myRemoveButton;
|
||||
private Table myProcessorTable;
|
||||
private JButton myAddButton;
|
||||
@@ -107,12 +113,19 @@ public class AnnotationProcessorsConfigurable implements Configurable{
|
||||
|
||||
myModulesChooser = new ProcessedModulesChooser();
|
||||
myModulesChooser.setBorder(BorderFactory.createTitledBorder("Processed Modules"));
|
||||
final JLabel noteMessage = new MultiLineLabel("Source files generated by annotation processors will be stored under the project output directory.\n" +
|
||||
"To override this behaviour for certain modules see the corresponding option in the table below.\n" +
|
||||
"If checked, the directory will be created under corresponding module's content root.");
|
||||
myGeneratedSourcesDirField = new JTextField();
|
||||
|
||||
mainPanel.add(myCbEnableProcessing, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
mainPanel.add(myRbClasspath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 0, 0, 0), 0, 0));
|
||||
mainPanel.add(myRbProcessorsPath, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 0, 0, 0), 0, 0));
|
||||
mainPanel.add(myProcessorPathField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 0, 0), 0, 0));
|
||||
mainPanel.add(processorTablePanel, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
mainPanel.add(noteMessage, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 5, 0, 0), 0, 0));
|
||||
mainPanel.add(new JLabel("Generated sources directory name: "), new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(10, 5, 0, 0), 0, 0));
|
||||
mainPanel.add(myGeneratedSourcesDirField, new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 0, 0, 0), 0, 0));
|
||||
mainPanel.add(myModulesChooser, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.BOTH, new Insets(10, 0, 0, 0), 0, 0));
|
||||
|
||||
|
||||
@@ -191,7 +204,11 @@ public class AnnotationProcessorsConfigurable implements Configurable{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getExcludedModules().equals(config.getExcludedModules())) {
|
||||
if (!myGeneratedSourcesDirField.getText().trim().equals(config.getGeneratedDirName().trim())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!getMarkedModules().equals(config.getAnotationProcessedModules())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -207,13 +224,17 @@ public class AnnotationProcessorsConfigurable implements Configurable{
|
||||
|
||||
config.setAnnotationProcessorsMap(myProcessorsModel.exportToMap());
|
||||
|
||||
config.setExcludedModules(getExcludedModules());
|
||||
config.setGeneratedDirName(myGeneratedSourcesDirField.getText().trim());
|
||||
|
||||
config.setAnotationProcessedModules(getMarkedModules());
|
||||
}
|
||||
|
||||
private Set<Module> getExcludedModules() {
|
||||
final Set<Module> excludedModules = new HashSet<Module>(Arrays.asList(ModuleManager.getInstance(myProject).getModules()));
|
||||
excludedModules.removeAll(new HashSet<Module>(myModulesChooser.getMarkedElements()));
|
||||
return excludedModules;
|
||||
private Map<Module, Boolean> getMarkedModules() {
|
||||
final Map<Module, Boolean> result = new HashMap<Module, Boolean>();
|
||||
for (Pair<Module, Boolean> pair : myModulesChooser.getMarkedModules()) {
|
||||
result.put(pair.getFirst(), pair.getSecond());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
@@ -232,11 +253,11 @@ public class AnnotationProcessorsConfigurable implements Configurable{
|
||||
|
||||
myProcessorsModel.setProcessorMap(config.getAnnotationProcessorsMap());
|
||||
|
||||
// excludes
|
||||
final Set<Module> excludedModules = new HashSet<Module>(config.getExcludedModules());
|
||||
myGeneratedSourcesDirField.setText(config.getGeneratedDirName().trim());
|
||||
|
||||
myModulesChooser.removeAllElements();
|
||||
for (final Module module : ModuleManager.getInstance(myProject).getModules()) {
|
||||
myModulesChooser.addElement(module, !excludedModules.contains(module));
|
||||
myModulesChooser.addModule(module, config.isAnnotationProcessingEnabled(module), config.isStoreGeneratedSourcesUnderContent(module));
|
||||
}
|
||||
myModulesChooser.sort(new Comparator<Module>() {
|
||||
public int compare(Module o1, Module o2) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
package com.intellij.compiler.options;
|
||||
|
||||
import com.intellij.openapi.module.Module;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.ui.ScrollPaneFactory;
|
||||
import com.intellij.ui.SpeedSearchBase;
|
||||
@@ -37,28 +38,43 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
private Table myTable = null;
|
||||
private MyTableModel myTableModel = null;
|
||||
private boolean myColorUnmarkedElements = true;
|
||||
private final Map<Module, Boolean> myDisabledMap = new HashMap<Module, Boolean>();
|
||||
|
||||
public ProcessedModulesChooser() {
|
||||
super(new BorderLayout());
|
||||
|
||||
myTableModel = new MyTableModel(true);
|
||||
myTableModel = new MyTableModel();
|
||||
myTable = new Table(myTableModel);
|
||||
myTable.setShowGrid(false);
|
||||
myTable.setIntercellSpacing(new Dimension(0, 0));
|
||||
myTable.setTableHeader(null);
|
||||
myTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
|
||||
myTable.setColumnSelectionAllowed(false);
|
||||
JScrollPane pane = ScrollPaneFactory.createScrollPane(myTable);
|
||||
pane.setPreferredSize(new Dimension(100, 155));
|
||||
int width = new JCheckBox().getPreferredSize().width;
|
||||
TableColumnModel columnModel = myTable.getColumnModel();
|
||||
|
||||
TableColumn checkMarkColumn = columnModel.getColumn(myTableModel.CHECK_MARK_COLUM_INDEX);
|
||||
checkMarkColumn.setPreferredWidth(width);
|
||||
checkMarkColumn.setMaxWidth(width);
|
||||
checkMarkColumn.setCellRenderer(new CheckMarkColumnCellRenderer(myTable.getDefaultRenderer(Boolean.class)));
|
||||
columnModel.getColumn(myTableModel.ELEMENT_COLUMN_INDEX).setCellRenderer(new MyElementColumnCellRenderer());
|
||||
final TableColumnModel columnModel = myTable.getColumnModel();
|
||||
|
||||
final int checkmarkWidth = new JCheckBox().getPreferredSize().width;
|
||||
final CheckMarkColumnCellRenderer checkmarkRenderer = new CheckMarkColumnCellRenderer(myTable.getDefaultRenderer(Boolean.class));
|
||||
|
||||
final TableColumn checkMarkColumn = columnModel.getColumn(myTableModel.CHECK_MARK_COLUM_INDEX);
|
||||
checkMarkColumn.setHeaderValue("");
|
||||
checkMarkColumn.setPreferredWidth(checkmarkWidth);
|
||||
checkMarkColumn.setMaxWidth(checkmarkWidth);
|
||||
checkMarkColumn.setCellRenderer(checkmarkRenderer);
|
||||
|
||||
TableColumn storeUnderContent = columnModel.getColumn(myTableModel.STORE_UNDER_CONTENT_COLUM_INDEX);
|
||||
final String title = "Generate Sources Under Content";
|
||||
storeUnderContent.setHeaderValue(title);
|
||||
final JTableHeader tableHeader = myTable.getTableHeader();
|
||||
final FontMetrics metrics = tableHeader.getFontMetrics(tableHeader.getFont());
|
||||
final int preferredWidth = metrics.stringWidth(title) + 12;
|
||||
storeUnderContent.setPreferredWidth(preferredWidth);
|
||||
storeUnderContent.setMaxWidth(preferredWidth);
|
||||
storeUnderContent.setCellRenderer(checkmarkRenderer);
|
||||
|
||||
final TableColumn moduleColumn = columnModel.getColumn(myTableModel.ELEMENT_COLUMN_INDEX);
|
||||
moduleColumn.setHeaderValue("Module");
|
||||
moduleColumn.setCellRenderer(new MyElementColumnCellRenderer());
|
||||
|
||||
add(pane, BorderLayout.CENTER);
|
||||
myTable.registerKeyboardAction(
|
||||
@@ -67,7 +83,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
final int[] selectedRows = myTable.getSelectedRows();
|
||||
boolean currentlyMarked = true;
|
||||
for (int selectedRow : selectedRows) {
|
||||
currentlyMarked = myTableModel.isElementMarked(selectedRow);
|
||||
currentlyMarked = myTableModel.isMarked(selectedRow);
|
||||
if (!currentlyMarked) {
|
||||
break;
|
||||
}
|
||||
@@ -88,7 +104,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
final int count = myTableModel.getRowCount();
|
||||
Object[] elements = new Object[count];
|
||||
for (int idx = 0; idx < count; idx++) {
|
||||
elements[idx] = myTableModel.getElementAt(idx);
|
||||
elements[idx] = myTableModel.getModuleAt(idx);
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
@@ -100,7 +116,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
public void selectElement(Object element, String selectedText) {
|
||||
final int count = myTableModel.getRowCount();
|
||||
for (int row = 0; row < count; row++) {
|
||||
if (element.equals(myTableModel.getElementAt(row))) {
|
||||
if (element.equals(myTableModel.getModuleAt(row))) {
|
||||
myTable.getSelectionModel().setSelectionInterval(row, row);
|
||||
TableUtil.scrollSelectionToVisible(myTable);
|
||||
break;
|
||||
@@ -134,22 +150,26 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
}
|
||||
}
|
||||
|
||||
public void addElement(Module element, final boolean isMarked) {
|
||||
myTableModel.addElement(element, isMarked);
|
||||
public void addModule(Module element, final boolean isMarked, boolean isStoreGeneratedSourcesUnderContent) {
|
||||
myTableModel.addElement(element, isMarked, isStoreGeneratedSourcesUnderContent);
|
||||
selectRow(myTableModel.getRowCount() - 1);
|
||||
myTable.requestFocus();
|
||||
}
|
||||
|
||||
public boolean isElementMarked(Module element) {
|
||||
final int elementRow = myTableModel.getElementRow(element);
|
||||
return myTableModel.isElementMarked(elementRow);
|
||||
return myTableModel.isMarked(elementRow);
|
||||
}
|
||||
|
||||
public void setElementMarked(Module element, boolean marked) {
|
||||
final int elementRow = myTableModel.getElementRow(element);
|
||||
myTableModel.setMarked(elementRow, marked);
|
||||
myTableModel.updateBooleanMap(elementRow, marked, myTableModel.myMarkedMap);
|
||||
}
|
||||
|
||||
public void setStoreGeneratedSourcesUnderContent(Module element, boolean value) {
|
||||
final int elementRow = myTableModel.getElementRow(element);
|
||||
myTableModel.updateBooleanMap(elementRow, value, myTableModel.myStoreUnderContentMap);
|
||||
}
|
||||
|
||||
public void removeElement(Module element) {
|
||||
final int elementRow = myTableModel.getElementRow(element);
|
||||
@@ -185,7 +205,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
@Nullable
|
||||
public Module getSelectedElement() {
|
||||
final int selectedRow = getSelectedElementRow();
|
||||
return selectedRow < 0? null : myTableModel.getElementAt(selectedRow);
|
||||
return selectedRow < 0? null : myTableModel.getModuleAt(selectedRow);
|
||||
}
|
||||
|
||||
public int getSelectedElementRow() {
|
||||
@@ -199,7 +219,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
if (selectedRow < 0) {
|
||||
continue;
|
||||
}
|
||||
elements.add(myTableModel.getElementAt(selectedRow));
|
||||
elements.add(myTableModel.getModuleAt(selectedRow));
|
||||
}
|
||||
return elements;
|
||||
}
|
||||
@@ -224,17 +244,13 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
return rows;
|
||||
}
|
||||
|
||||
public void markElements(Collection<Module> elements) {
|
||||
myTableModel.setMarked(getElementsRows(elements), true);
|
||||
}
|
||||
|
||||
public List<Module> getMarkedElements() {
|
||||
public List<Pair<Module, Boolean>> getMarkedModules() {
|
||||
final int count = myTableModel.getRowCount();
|
||||
List<Module> elements = new ArrayList<Module>();
|
||||
List<Pair<Module, Boolean>> elements = new ArrayList<Pair<Module, Boolean>>();
|
||||
for (int idx = 0; idx < count; idx++) {
|
||||
final Module element = myTableModel.getElementAt(idx);
|
||||
if (myTableModel.isElementMarked(idx)) {
|
||||
elements.add(element);
|
||||
final Module module = myTableModel.getModuleAt(idx);
|
||||
if (myTableModel.isMarked(idx)) {
|
||||
elements.add(new Pair<Module, Boolean>(module, myTableModel.isGenerateSourcesToContent(module)));
|
||||
}
|
||||
}
|
||||
return elements;
|
||||
@@ -270,50 +286,45 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
}
|
||||
|
||||
public Module getElementAt(int row) {
|
||||
return myTableModel.getElementAt(row);
|
||||
}
|
||||
|
||||
public void disableElement(Module element) {
|
||||
myDisabledMap.put(element, Boolean.TRUE);
|
||||
return myTableModel.getModuleAt(row);
|
||||
}
|
||||
|
||||
private final class MyTableModel extends AbstractTableModel {
|
||||
private final List<Module> myElements = new ArrayList<Module>();
|
||||
private final Map<Module, Boolean> myMarkedMap = new HashMap<Module, Boolean>();
|
||||
public final int CHECK_MARK_COLUM_INDEX;
|
||||
public final int ELEMENT_COLUMN_INDEX;
|
||||
private final boolean myElementsCanBeMarked;
|
||||
|
||||
public MyTableModel(final boolean elementsCanBeMarked) {
|
||||
myElementsCanBeMarked = elementsCanBeMarked;
|
||||
if (elementsCanBeMarked) {
|
||||
CHECK_MARK_COLUM_INDEX = 0;
|
||||
ELEMENT_COLUMN_INDEX = 1;
|
||||
}
|
||||
else {
|
||||
CHECK_MARK_COLUM_INDEX = -1;
|
||||
ELEMENT_COLUMN_INDEX = 0;
|
||||
}
|
||||
}
|
||||
private final Map<Module, Boolean> myStoreUnderContentMap = new HashMap<Module, Boolean>();
|
||||
public final int CHECK_MARK_COLUM_INDEX = 0;
|
||||
public final int ELEMENT_COLUMN_INDEX = 1;
|
||||
public final int STORE_UNDER_CONTENT_COLUM_INDEX = 2;
|
||||
|
||||
public void sort(Comparator<Module> comparator) {
|
||||
Collections.sort(myElements, comparator);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
|
||||
public Module getElementAt(int index) {
|
||||
public Module getModuleAt(int index) {
|
||||
return myElements.get(index);
|
||||
}
|
||||
|
||||
public boolean isElementMarked(int index) {
|
||||
public boolean isMarked(int index) {
|
||||
final Module element = myElements.get(index);
|
||||
final Boolean isMarked = myMarkedMap.get(element);
|
||||
return isMarked.booleanValue();
|
||||
return myMarkedMap.get(element).booleanValue();
|
||||
}
|
||||
|
||||
void addElement(Module element, boolean isMarked) {
|
||||
public boolean isGenerateSourcesToContent(int index) {
|
||||
final Module element = myElements.get(index);
|
||||
return myStoreUnderContentMap.get(element).booleanValue();
|
||||
}
|
||||
|
||||
public boolean isGenerateSourcesToContent(Module module) {
|
||||
final Boolean value = myStoreUnderContentMap.get(module);
|
||||
return value != null && value.booleanValue();
|
||||
}
|
||||
|
||||
void addElement(Module element, boolean isMarked, boolean isStoreGeneratedSourcesUnderContent) {
|
||||
myElements.add(element);
|
||||
myMarkedMap.put(element, isMarked? Boolean.TRUE : Boolean.FALSE);
|
||||
myMarkedMap.put(element, Boolean.valueOf(isMarked));
|
||||
myStoreUnderContentMap.put(element, Boolean.valueOf(isStoreGeneratedSourcesUnderContent));
|
||||
int row = myElements.size() - 1;
|
||||
fireTableRowsInserted(row, row);
|
||||
}
|
||||
@@ -325,6 +336,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
for (final Module element : elements) {
|
||||
myElements.add(element);
|
||||
myMarkedMap.put(element, isMarked ? Boolean.TRUE : Boolean.FALSE);
|
||||
myStoreUnderContentMap.put(element, Boolean.FALSE);
|
||||
}
|
||||
fireTableRowsInserted(myElements.size() - elements.size(), myElements.size() - 1);
|
||||
}
|
||||
@@ -333,6 +345,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
final boolean reallyRemoved = myElements.remove(element);
|
||||
if (reallyRemoved) {
|
||||
myMarkedMap.remove(element);
|
||||
myStoreUnderContentMap.remove(element);
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
@@ -360,6 +373,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
final Module element = myElements.get(row);
|
||||
toRemove.add(element);
|
||||
myMarkedMap.remove(element);
|
||||
myStoreUnderContentMap.remove(element);
|
||||
}
|
||||
myElements.removeAll(toRemove);
|
||||
fireTableDataChanged();
|
||||
@@ -370,7 +384,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
}
|
||||
|
||||
public int getColumnCount() {
|
||||
return myElementsCanBeMarked? 2 : 1;
|
||||
return 3;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -382,19 +396,25 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
if (columnIndex == CHECK_MARK_COLUM_INDEX) {
|
||||
return myMarkedMap.get(element);
|
||||
}
|
||||
if (columnIndex == STORE_UNDER_CONTENT_COLUM_INDEX) {
|
||||
return myStoreUnderContentMap.get(element);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
|
||||
public void setValueAt(Object value, int rowIndex, int columnIndex) {
|
||||
if (columnIndex == CHECK_MARK_COLUM_INDEX) {
|
||||
setMarked(rowIndex, ((Boolean)aValue).booleanValue());
|
||||
updateBooleanMap(rowIndex, ((Boolean)value).booleanValue(), myMarkedMap);
|
||||
}
|
||||
else if (columnIndex == STORE_UNDER_CONTENT_COLUM_INDEX) {
|
||||
updateBooleanMap(rowIndex, ((Boolean)value).booleanValue(), myStoreUnderContentMap);
|
||||
}
|
||||
}
|
||||
|
||||
private void setMarked(int rowIndex, final boolean marked) {
|
||||
private void updateBooleanMap(int rowIndex, boolean marked, final Map<Module, Boolean> map) {
|
||||
final Module element = myElements.get(rowIndex);
|
||||
final Boolean newValue = marked? Boolean.TRUE : Boolean.FALSE;
|
||||
myMarkedMap.put(element, newValue);
|
||||
map.put(element, newValue);
|
||||
fireTableRowsUpdated(rowIndex, rowIndex);
|
||||
}
|
||||
|
||||
@@ -415,23 +435,29 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
}
|
||||
|
||||
public Class getColumnClass(int columnIndex) {
|
||||
if (columnIndex == CHECK_MARK_COLUM_INDEX) {
|
||||
if (columnIndex == CHECK_MARK_COLUM_INDEX || columnIndex == STORE_UNDER_CONTENT_COLUM_INDEX) {
|
||||
return Boolean.class;
|
||||
}
|
||||
return super.getColumnClass(columnIndex);
|
||||
}
|
||||
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
if (!ProcessedModulesChooser.this.isEnabled() || columnIndex != CHECK_MARK_COLUM_INDEX) {
|
||||
if (!ProcessedModulesChooser.this.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
final Module o = (Module)getValueAt(rowIndex, ELEMENT_COLUMN_INDEX);
|
||||
return myDisabledMap.get(o) == null;
|
||||
if (columnIndex == CHECK_MARK_COLUM_INDEX) {
|
||||
return true;
|
||||
}
|
||||
if (columnIndex == STORE_UNDER_CONTENT_COLUM_INDEX) {
|
||||
return isMarked(rowIndex);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void clear() {
|
||||
myElements.clear();
|
||||
myMarkedMap.clear();
|
||||
myStoreUnderContentMap.clear();
|
||||
fireTableDataChanged();
|
||||
}
|
||||
}
|
||||
@@ -453,7 +479,7 @@ public class ProcessedModulesChooser extends JPanel {
|
||||
UIManager.put(UIUtil.TABLE_FOCUS_CELL_BACKGROUND_PROPERTY, color);
|
||||
}
|
||||
final MyTableModel model = (MyTableModel)table.getModel();
|
||||
component.setEnabled(ProcessedModulesChooser.this.isEnabled() && (myColorUnmarkedElements? model.isElementMarked(row) : true));
|
||||
component.setEnabled(ProcessedModulesChooser.this.isEnabled() && (myColorUnmarkedElements? model.isMarked(row) : true));
|
||||
if (component instanceof JLabel) {
|
||||
final Icon icon = module != null ? module.getModuleType().getNodeIcon(false) : null;
|
||||
JLabel label = (JLabel)component;
|
||||
|
||||
@@ -21,9 +21,7 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public abstract class CompilerConfiguration {
|
||||
// need this flag for profiling purposes. In production code is always set to 'true'
|
||||
@@ -57,13 +55,13 @@ public abstract class CompilerConfiguration {
|
||||
|
||||
public abstract void setAnnotationProcessorsMap(Map<String, String> map);
|
||||
|
||||
public abstract Set<Module> getExcludedModules();
|
||||
public abstract void setAnotationProcessedModules(Map<Module, Boolean> modules);
|
||||
|
||||
public abstract void setExcludedModules(Collection<Module> modules);
|
||||
public abstract Map<Module, Boolean> getAnotationProcessedModules();
|
||||
|
||||
public abstract boolean isStoreGenerateSourcesUnderModuleContent(Module module);
|
||||
public abstract boolean isAnnotationProcessingEnabled(Module module);
|
||||
|
||||
public abstract void setStoreGenerateSourcesUnderModuleContent(boolean storeGenerateSourcesUnderModuleContent);
|
||||
public abstract boolean isStoreGeneratedSourcesUnderContent(Module module);
|
||||
|
||||
@NotNull
|
||||
public abstract String getGeneratedDirName();
|
||||
|
||||
@@ -193,7 +193,7 @@ public class CompilerPaths {
|
||||
public static String getAnnotationProcessorsGenerationPath(Module module) {
|
||||
final CompilerConfiguration config = CompilerConfiguration.getInstance(module.getProject());
|
||||
|
||||
if (config.isStoreGenerateSourcesUnderModuleContent(module)) {
|
||||
if (config.isStoreGeneratedSourcesUnderContent(module)) {
|
||||
final String[] roots = ModuleRootManager.getInstance(module).getContentRootUrls();
|
||||
if (roots.length == 0) {
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user