mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
project structure: show warning if any part of configuration for a module imported from an external system is changed manually (IDEA-171948)
Previously it showed notification only after change on 'Dependencies' tab, now it listens for changes in all module editors.
This commit is contained in:
@@ -68,6 +68,7 @@ public class AnnotationsEditor extends ModuleElementsEditor {
|
||||
urls[row] = item.getUrl();
|
||||
}
|
||||
getModel().getModuleExtension(JavaModuleExternalPaths.class).setExternalAnnotationUrls(urls);
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -76,6 +76,7 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
public void saveUrl(String url) {
|
||||
if (myInheritCompilerOutput.isSelected()) return; //do not override settings if any
|
||||
getCompilerExtension().setCompilerOutputPath(url);
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
});
|
||||
myTestsOutputPathPanel = createOutputPathPanel(ProjectBundle.message("module.paths.test.output.title"), new CommitPathRunnable() {
|
||||
@@ -83,6 +84,7 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
public void saveUrl(String url) {
|
||||
if (myInheritCompilerOutput.isSelected()) return; //do not override settings if any
|
||||
getCompilerExtension().setCompilerOutputPathForTests(url);
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -91,6 +93,7 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
getCompilerExtension().setExcludeOutput(myCbExcludeOutput.isSelected());
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -187,6 +190,7 @@ public class BuildElementsEditor extends ModuleElementsEditor {
|
||||
myCbExcludeOutput.setEnabled(enabled);
|
||||
getCompilerExtension().inheritCompilerOutputPath(!enabled);
|
||||
updateOutputPathPresentation();
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
private CommitableFieldPanel createOutputPathPanel(final String title, final CommitPathRunnable commitPathRunnable) {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class ContentEntriesEditor extends JavaContentEntriesEditor {
|
||||
|
||||
@Override
|
||||
protected void addAdditionalSettingsToPanel(final JPanel mainPanel) {
|
||||
myLanguageLevelConfigurable = new LanguageLevelConfigurable(myProject) {
|
||||
myLanguageLevelConfigurable = new LanguageLevelConfigurable(myProject, this::fireConfigurationChanged) {
|
||||
@NotNull
|
||||
@Override
|
||||
public LanguageLevelModuleExtensionImpl getLanguageLevelExtension() {
|
||||
|
||||
@@ -71,6 +71,7 @@ public class JavadocEditor extends ModuleElementsEditor {
|
||||
urls[row] = item.getUrl();
|
||||
}
|
||||
getModel().getModuleExtension(JavaModuleExternalPaths.class).setJavadocUrls(urls);
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-1
@@ -39,7 +39,7 @@ public abstract class LanguageLevelConfigurable implements UnnamedConfigurable {
|
||||
private LanguageLevelCombo myLanguageLevelCombo;
|
||||
private JPanel myPanel = new JPanel(new GridBagLayout());
|
||||
|
||||
public LanguageLevelConfigurable(final Project project) {
|
||||
public LanguageLevelConfigurable(final Project project, Runnable onChange) {
|
||||
myLanguageLevelCombo = new LanguageLevelCombo(ProjectBundle.message("project.language.level.combo.item")) {
|
||||
@Override
|
||||
protected LanguageLevel getDefaultLevel() {
|
||||
@@ -52,6 +52,7 @@ public abstract class LanguageLevelConfigurable implements UnnamedConfigurable {
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
final Object languageLevel = myLanguageLevelCombo.getSelectedItem();
|
||||
getLanguageLevelExtension().setLanguageLevel(languageLevel instanceof LanguageLevel ? (LanguageLevel)languageLevel : null);
|
||||
onChange.run();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -221,6 +221,11 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
}
|
||||
}
|
||||
}
|
||||
for (ModuleConfigurationEditor editor : myEditors) {
|
||||
if (editor instanceof ModuleElementsEditor) {
|
||||
((ModuleElementsEditor)editor).addListener(this::updateImportedModelWarning);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Set<Class<?>> ourReportedDeprecatedClasses = new HashSet<>();
|
||||
@@ -297,6 +302,8 @@ public abstract class ModuleEditor implements Place.Navigator, Disposable {
|
||||
}
|
||||
|
||||
private void updateImportedModelWarning() {
|
||||
if (!myEditorsInitialized) return;
|
||||
|
||||
ProjectModelExternalSource externalSource = ModuleRootManager.getInstance(myModule).getExternalSource();
|
||||
if (externalSource != null && isModified()) {
|
||||
myModificationOfImportedModelWarningLabel.setVisible(true);
|
||||
|
||||
@@ -32,18 +32,23 @@ import org.jetbrains.annotations.Nullable;
|
||||
import javax.swing.*;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import java.awt.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class OutputEditor extends ModuleElementsEditor {
|
||||
public static final String NAME = ProjectBundle.message("project.roots.path.tab.title");
|
||||
private final BuildElementsEditor myCompilerOutputEditor;
|
||||
private final JavadocEditor myJavadocEditor;
|
||||
private final AnnotationsEditor myAnnotationsEditor;
|
||||
private final List<ModuleElementsEditor> myEditors;
|
||||
|
||||
protected OutputEditor(final ModuleConfigurationState state) {
|
||||
super(state);
|
||||
myCompilerOutputEditor = new BuildElementsEditor(state);
|
||||
myJavadocEditor = new JavadocEditor(state);
|
||||
myAnnotationsEditor = new AnnotationsEditor(state);
|
||||
myEditors = Arrays.asList(myCompilerOutputEditor, myJavadocEditor, myAnnotationsEditor);
|
||||
myEditors.forEach(editor -> editor.addListener(this::fireConfigurationChanged));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -65,9 +70,8 @@ public class OutputEditor extends ModuleElementsEditor {
|
||||
|
||||
@Override
|
||||
public void saveData() {
|
||||
myCompilerOutputEditor.saveData();
|
||||
myJavadocEditor.saveData();
|
||||
myAnnotationsEditor.saveData();
|
||||
super.saveData();
|
||||
myEditors.forEach(ModuleElementsEditor::saveData);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -78,18 +82,14 @@ public class OutputEditor extends ModuleElementsEditor {
|
||||
@Override
|
||||
public void moduleStateChanged() {
|
||||
super.moduleStateChanged();
|
||||
myCompilerOutputEditor.moduleStateChanged();
|
||||
myJavadocEditor.moduleStateChanged();
|
||||
myAnnotationsEditor.moduleStateChanged();
|
||||
myEditors.forEach(ModuleElementsEditor::moduleStateChanged);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void moduleCompileOutputChanged(final String baseUrl, final String moduleName) {
|
||||
super.moduleCompileOutputChanged(baseUrl, moduleName);
|
||||
myCompilerOutputEditor.moduleCompileOutputChanged(baseUrl, moduleName);
|
||||
myJavadocEditor.moduleCompileOutputChanged(baseUrl, moduleName);
|
||||
myAnnotationsEditor.moduleCompileOutputChanged(baseUrl, moduleName);
|
||||
myEditors.forEach(editor -> editor.moduleCompileOutputChanged(baseUrl, moduleName));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+26
@@ -30,6 +30,7 @@ import com.intellij.openapi.project.ProjectBundle;
|
||||
import com.intellij.openapi.roots.ContentEntry;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.roots.ModuleRootModel;
|
||||
import com.intellij.openapi.roots.SourceFolder;
|
||||
import com.intellij.openapi.roots.ui.componentsList.components.ScrollablePanel;
|
||||
import com.intellij.openapi.roots.ui.componentsList.layout.VerticalStackLayout;
|
||||
import com.intellij.openapi.roots.ui.configuration.actions.IconWithTextAction;
|
||||
@@ -355,6 +356,31 @@ public class CommonContentEntriesEditor extends ModuleElementsEditor {
|
||||
}
|
||||
|
||||
private final class MyContentEntryEditorListener extends ContentEntryEditorListenerAdapter {
|
||||
@Override
|
||||
public void sourceFolderAdded(@NotNull ContentEntryEditor editor, SourceFolder folder) {
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sourceFolderRemoved(@NotNull ContentEntryEditor editor, VirtualFile file) {
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void folderExcluded(@NotNull ContentEntryEditor editor, VirtualFile file) {
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void folderIncluded(@NotNull ContentEntryEditor editor, String fileUrl) {
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sourceRootPropertiesChanged(@NotNull ContentEntryEditor editor, @NotNull SourceFolder folder) {
|
||||
fireConfigurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void editingStarted(@NotNull ContentEntryEditor editor) {
|
||||
selectContentEntry(editor.getContentEntryUrl(), true);
|
||||
|
||||
+15
@@ -24,9 +24,11 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.roots.ModifiableRootModel;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.ui.navigation.History;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.EventListener;
|
||||
|
||||
/**
|
||||
* @author Eugene Zhuravlev
|
||||
@@ -37,6 +39,7 @@ public abstract class ModuleElementsEditor implements ModuleConfigurationEditor
|
||||
@NotNull protected final Project myProject;
|
||||
protected JComponent myComponent;
|
||||
private final CompositeDisposable myDisposables = new CompositeDisposable();
|
||||
private final EventDispatcher<ModuleElementsEditorListener> myDispatcher = EventDispatcher.create(ModuleElementsEditorListener.class);
|
||||
|
||||
protected History myHistory;
|
||||
private final ModuleConfigurationState myState;
|
||||
@@ -50,6 +53,14 @@ public abstract class ModuleElementsEditor implements ModuleConfigurationEditor
|
||||
myHistory = history;
|
||||
}
|
||||
|
||||
public void addListener(ModuleElementsEditorListener listener) {
|
||||
myDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
protected void fireConfigurationChanged() {
|
||||
myDispatcher.getMulticaster().configurationChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isModified() {
|
||||
return getModel() != null && getModel().isChanged();
|
||||
@@ -98,4 +109,8 @@ public abstract class ModuleElementsEditor implements ModuleConfigurationEditor
|
||||
}
|
||||
|
||||
protected abstract JComponent createComponentImpl();
|
||||
|
||||
interface ModuleElementsEditorListener extends EventListener {
|
||||
void configurationChanged();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user