mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FIXED IDEA-149066 Code style is not per project (confusing "Per project" message)
This commit is contained in:
+6
-1
@@ -34,7 +34,7 @@ import javax.swing.*;
|
||||
import java.util.*;
|
||||
|
||||
public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent.Abstract
|
||||
implements OptionsContainingConfigurable, Configurable.NoMargin, Configurable.NoScroll {
|
||||
implements OptionsContainingConfigurable, Configurable.NoMargin, Configurable.NoScroll, Configurable.VariableProjectAppLevel {
|
||||
|
||||
private CodeStyleSchemesPanel myRootSchemesPanel;
|
||||
private CodeStyleSchemesModel myModel;
|
||||
@@ -323,6 +323,11 @@ public class CodeStyleSchemesConfigurable extends SearchableConfigurable.Parent.
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isProjectLevel() {
|
||||
return myModel != null && myModel.isUsePerProjectSettings();
|
||||
}
|
||||
|
||||
private class CodeStyleConfigurableWrapper implements SearchableConfigurable, NoMargin, NoScroll, OptionsContainingConfigurable {
|
||||
private boolean myInitialResetInvoked;
|
||||
private CodeStyleMainPanel myPanel;
|
||||
|
||||
@@ -186,4 +186,16 @@ public interface Configurable extends UnnamedConfigurable {
|
||||
interface NoMargin {
|
||||
// see ConfigurableCardPanel#create(Configurable)
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows to dynamically define if current configurable settings apply to current project or to the IDE and update "For current project"
|
||||
* indicator accordingly.
|
||||
*/
|
||||
interface VariableProjectAppLevel {
|
||||
/**
|
||||
* @return True if current settings apply to the current project (enable "For current project" indicator), false for application-level
|
||||
* (IDE) settings.
|
||||
*/
|
||||
boolean isProjectLevel();
|
||||
}
|
||||
}
|
||||
|
||||
+11
-4
@@ -269,8 +269,7 @@ final class SettingsTreeView extends JComponent implements Accessible, Disposabl
|
||||
@Nullable
|
||||
Project findConfigurableProject(@Nullable Configurable configurable) {
|
||||
if (configurable instanceof ConfigurableWrapper) {
|
||||
ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
|
||||
return wrapper.getExtensionPoint().getProject();
|
||||
return getProjectFromWrapper((ConfigurableWrapper)configurable);
|
||||
}
|
||||
return findConfigurableProject(findNode(configurable));
|
||||
}
|
||||
@@ -280,8 +279,7 @@ final class SettingsTreeView extends JComponent implements Accessible, Disposabl
|
||||
if (node != null) {
|
||||
Configurable configurable = node.myConfigurable;
|
||||
if (configurable instanceof ConfigurableWrapper) {
|
||||
ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
|
||||
return wrapper.getExtensionPoint().getProject();
|
||||
return getProjectFromWrapper((ConfigurableWrapper)configurable);
|
||||
}
|
||||
SimpleNode parent = node.getParent();
|
||||
if (parent instanceof MyNode) {
|
||||
@@ -290,6 +288,15 @@ final class SettingsTreeView extends JComponent implements Accessible, Disposabl
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static Project getProjectFromWrapper(@NotNull ConfigurableWrapper wrapper) {
|
||||
UnnamedConfigurable wrapped = wrapper.getConfigurable();
|
||||
if (wrapped instanceof Configurable.VariableProjectAppLevel && !((Configurable.VariableProjectAppLevel)wrapped).isProjectLevel()) {
|
||||
return null;
|
||||
}
|
||||
return wrapper.getExtensionPoint().getProject();
|
||||
}
|
||||
|
||||
private static int getLeftMargin(int level) {
|
||||
return 3 + level * (11 + ICON_GAP);
|
||||
|
||||
Reference in New Issue
Block a user