mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-127672 Settings: add "Current Project" icon to panel header
This commit is contained in:
@@ -16,6 +16,8 @@
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.icons.AllIcons;
|
||||
import com.intellij.openapi.options.OptionsBundle;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.components.labels.LinkLabel;
|
||||
import com.intellij.ui.components.labels.LinkListener;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
@@ -35,7 +37,7 @@ import java.util.Set;
|
||||
class Banner extends NonOpaquePanel implements PropertyChangeListener{
|
||||
private int myBannerMinHeight;
|
||||
private final JComponent myText = new MyText();
|
||||
|
||||
private final JLabel myProjectIcon = new JLabel(AllIcons.General.ProjectConfigurableBanner, SwingConstants.LEFT);
|
||||
private final NonOpaquePanel myActionsPanel = new NonOpaquePanel(new FlowLayout(FlowLayout.RIGHT, 2, 2));
|
||||
|
||||
private final Map<Action, LinkLabel> myActions = new HashMap<Action, LinkLabel>();
|
||||
@@ -45,7 +47,10 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{
|
||||
|
||||
setBorder(new EmptyBorder(2, 6, 2, 4));
|
||||
|
||||
add(myText, BorderLayout.CENTER);
|
||||
myProjectIcon.setVisible(false);
|
||||
myProjectIcon.setBorder(new EmptyBorder(0, 12, 0, 4));
|
||||
add(myText, BorderLayout.WEST);
|
||||
add(myProjectIcon, BorderLayout.CENTER);
|
||||
add(myActionsPanel, BorderLayout.EAST);
|
||||
}
|
||||
|
||||
@@ -112,6 +117,17 @@ class Banner extends NonOpaquePanel implements PropertyChangeListener{
|
||||
repaint();
|
||||
}
|
||||
|
||||
public void forProject(Project project) {
|
||||
if (project != null) {
|
||||
myProjectIcon.setVisible(true);
|
||||
myProjectIcon.setText(OptionsBundle.message(project.isDefault()
|
||||
? "configurable.default.project.tooltip"
|
||||
: "configurable.current.project.tooltip"));
|
||||
} else {
|
||||
myProjectIcon.setVisible(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void setText(@NotNull final String... text) {
|
||||
myText.removeAll();
|
||||
for (int i = 0; i < text.length; i++) {
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package com.intellij.openapi.ui;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.ui.components.panels.NonOpaquePanel;
|
||||
import com.intellij.ui.components.panels.Wrapper;
|
||||
@@ -174,6 +175,9 @@ public class DetailsComponent {
|
||||
}
|
||||
}
|
||||
|
||||
public void forProject(Project project) {
|
||||
myBannerLabel.forProject(project);
|
||||
}
|
||||
|
||||
public void setPrefix(@Nullable String... prefix) {
|
||||
myPrefix = prefix;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
+25
-16
@@ -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,6 +407,7 @@ 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()
|
||||
? "configurable.default.project.tooltip"
|
||||
@@ -418,21 +419,6 @@ public class OptionsTree extends JPanel implements Disposable, OptionsEditorColl
|
||||
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;
|
||||
@@ -877,4 +863,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());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user