summaryrefslogtreecommitdiff
path: root/platform/platform-impl/src/com/intellij/openapi/options
diff options
context:
space:
mode:
Diffstat (limited to 'platform/platform-impl/src/com/intellij/openapi/options')
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/ConfigurableBase.java46
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/ConfigurableUi.java15
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/SimpleConfigurable.java52
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java1
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java4
-rw-r--r--platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java62
6 files changed, 162 insertions, 18 deletions
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableBase.java b/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableBase.java
index 104dc7b30ec7..d7c7dca2f19b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableBase.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableBase.java
@@ -1,18 +1,64 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.openapi.options;
+import org.jetbrains.annotations.Nls;
+import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
public abstract class ConfigurableBase<UI extends ConfigurableUi<S>, S> implements SearchableConfigurable, Configurable.NoScroll {
+ private final String id;
+ private final String displayName;
+ private final String helpTopic;
+
private UI ui;
+ protected ConfigurableBase(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic) {
+ this.id = id;
+ this.displayName = displayName;
+ this.helpTopic = helpTopic;
+ }
+
+ @NotNull
+ @Override
+ public final String getId() {
+ return id;
+ }
+
+ @Nls
+ @Override
+ public final String getDisplayName() {
+ return displayName;
+ }
+
+ @Nullable
+ @Override
+ public final String getHelpTopic() {
+ return helpTopic;
+ }
+
@Nullable
@Override
public Runnable enableSearch(String option) {
return null;
}
+ @NotNull
protected abstract S getSettings();
@Override
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableUi.java b/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableUi.java
index e454099318ea..0ecb19a7ce8e 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableUi.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/ConfigurableUi.java
@@ -1,3 +1,18 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package com.intellij.openapi.options;
import org.jetbrains.annotations.NotNull;
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/SimpleConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/options/SimpleConfigurable.java
new file mode 100644
index 000000000000..9812165932a2
--- /dev/null
+++ b/platform/platform-impl/src/com/intellij/openapi/options/SimpleConfigurable.java
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2000-2014 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.options;
+
+import com.intellij.openapi.util.Getter;
+import com.intellij.util.ReflectionUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public final class SimpleConfigurable<UI extends ConfigurableUi<S>, S> extends ConfigurableBase<UI, S> {
+ private final Class<UI> uiClass;
+ private final Getter<S> settingsGetter;
+
+ private SimpleConfigurable(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ super(id, displayName, helpTopic);
+
+ this.uiClass = uiClass;
+ this.settingsGetter = settingsGetter;
+ }
+
+ public static <UI extends ConfigurableUi<S>, S> SimpleConfigurable<UI, S> create(@NotNull String id, @NotNull String displayName, @Nullable String helpTopic, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ return new SimpleConfigurable<UI, S>(id, displayName, helpTopic, uiClass, settingsGetter);
+ }
+
+ public static <UI extends ConfigurableUi<S>, S> SimpleConfigurable<UI, S> create(@NotNull String id, @NotNull String displayName, @NotNull Class<UI> uiClass, @NotNull Getter<S> settingsGetter) {
+ return create(id, displayName, id, uiClass, settingsGetter);
+ }
+
+ @NotNull
+ @Override
+ protected S getSettings() {
+ return settingsGetter.get();
+ }
+
+ @Override
+ protected UI createUi() {
+ return ReflectionUtil.newInstance(uiClass);
+ }
+} \ No newline at end of file
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java b/platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java
index 35b75fe7c8d2..47d3881ee815 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/TabbedConfigurable.java
@@ -33,6 +33,7 @@ public abstract class TabbedConfigurable extends CompositeConfigurable<Configura
myParent = parent;
}
+ @Override
public JComponent createComponent() {
myTabbedPane = new TabbedPaneWrapper(myParent);
createConfigurableTabs();
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
index 6ee4a1b947ef..07e5a93670e6 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsEditor.java
@@ -36,6 +36,7 @@ import com.intellij.openapi.ui.*;
import com.intellij.openapi.util.ActionCallback;
import com.intellij.openapi.util.Disposer;
import com.intellij.openapi.util.EdtRunnable;
+import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.wm.IdeGlassPaneUtil;
import com.intellij.ui.DocumentAdapter;
@@ -366,6 +367,9 @@ public class OptionsEditor extends JPanel implements DataProvider, Place.Navigat
myOwnDetails.setContent(myContentWrapper);
myOwnDetails.setBannerMinHeight(mySearchWrapper.getHeight());
myOwnDetails.setText(getBannerText(configurable));
+ if (Registry.is("ide.file.settings.order.new")) {
+ myOwnDetails.forProject(myTree.getConfigurableProject(configurable));
+ }
final ConfigurableContent content = myConfigurable2Content.get(current);
diff --git a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
index 5524df2bb2cb..e0ab24815ece 100644
--- a/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
+++ b/platform/platform-impl/src/com/intellij/openapi/options/newEditor/OptionsTree.java
@@ -308,7 +308,7 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
myHandle.setOpaque(false);
content.add(myHandle, BorderLayout.WEST);
content.add(myComponent, BorderLayout.CENTER);
- myProjectIcon = new JLabel(" ", AllIcons.General.ProjectConfigurable, SwingConstants.LEFT);
+ myProjectIcon = new JLabel(" ", SwingConstants.LEFT);
myProjectIcon.setOpaque(true);
content.add(myProjectIcon, BorderLayout.EAST);
myRendererComponent.add(content, BorderLayout.CENTER);
@@ -407,32 +407,17 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
Project project = getConfigurableProject(base);
if (project != null && Registry.is("ide.file.settings.order.new")) {
myProjectIcon.setBackground(selected ? getSelectionBackground() : getBackground());
+ myProjectIcon.setIcon(selected ? AllIcons.General.ProjectConfigurableSelected : AllIcons.General.ProjectConfigurable);
myProjectIcon.setVisible(true);
- tree.setToolTipText(OptionsBundle.message(project.isDefault()
+ myProjectIcon.setToolTipText(OptionsBundle.message(project.isDefault()
? "configurable.default.project.tooltip"
: "configurable.current.project.tooltip"));
} else {
myProjectIcon.setVisible(false);
- tree.setToolTipText(null);
}
return result;
}
- private Project getConfigurableProject(SimpleNode node) {
- if (node == null) {
- return null;
- }
- if (node instanceof EditorNode) {
- EditorNode editor = (EditorNode)node;
- Configurable configurable = editor.getConfigurable();
- if (configurable instanceof ConfigurableWrapper) {
- ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
- return wrapper.getExtensionPoint().getProject();
- }
- }
- return getConfigurableProject(node.getParent());
- }
-
protected JComponent createItemComponent() {
myTextLabel = new ErrorLabel();
return myTextLabel;
@@ -642,6 +627,24 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
@Override
+ public final String getToolTipText(MouseEvent event) {
+ if (event != null) {
+ Point point = event.getPoint();
+ Component component = getDeepestRendererComponentAt(point.x, point.y);
+ if (component instanceof JLabel) {
+ JLabel label = (JLabel)component;
+ if (label.getIcon() != null) {
+ String text = label.getToolTipText();
+ if (text != null) {
+ return text;
+ }
+ }
+ }
+ }
+ return super.getToolTipText(event);
+ }
+
+ @Override
protected boolean paintNodes() {
return false;
}
@@ -877,4 +880,27 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
}
}
+
+ Project getConfigurableProject(Configurable configurable) {
+ if (configurable instanceof ConfigurableWrapper) {
+ ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
+ return wrapper.getExtensionPoint().getProject();
+ }
+ return getConfigurableProject(myConfigurable2Node.get(configurable));
+ }
+
+ private static Project getConfigurableProject(SimpleNode node) {
+ if (node == null) {
+ return null;
+ }
+ if (node instanceof EditorNode) {
+ EditorNode editor = (EditorNode)node;
+ Configurable configurable = editor.getConfigurable();
+ if (configurable instanceof ConfigurableWrapper) {
+ ConfigurableWrapper wrapper = (ConfigurableWrapper)configurable;
+ return wrapper.getExtensionPoint().getProject();
+ }
+ }
+ return getConfigurableProject(node.getParent());
+ }
}