mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-186805 Rework plugin page for settings dialog
This commit is contained in:
+446
-192
File diff suppressed because it is too large
Load Diff
@@ -1,105 +0,0 @@
|
||||
// Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.internal.ui;
|
||||
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.ui.JBColor;
|
||||
import com.intellij.util.ui.JBUI;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
@SuppressWarnings("UseJBColor")
|
||||
public class ButtonStyleAction extends DumbAwareAction {
|
||||
private static final String TEXT_COLOR = "JButton.textColor";
|
||||
private static final String FOCUSED_TEXT_COLOR = "JButton.focusedTextColor";
|
||||
private static final String BACKGROUND_PROPERTY = "JButton.backgroundColor";
|
||||
private static final String FOCUSED_BACKGROUND_PROPERTY = "JButton.focusedBackgroundColor";
|
||||
private static final String BORDER_PROPERTY = "JButton.borderColor";
|
||||
private static final String FOCUSED_BORDER_PROPERTY = "JButton.focusedBorderColor";
|
||||
|
||||
private static final Color WHITE_BACKGROUND = new JBColor(Color.WHITE, new Color(0x3c3f41));
|
||||
private static final Color WHITE_FOREGROUND = new JBColor(Color.WHITE, new Color(0xbbbbbb));
|
||||
private static final Color GREEN_BACKGROUND = new JBColor(0x5d9b47, 0x457335);
|
||||
private static final Color GREEN_BORDER = new JBColor(0x5d9b47, 0x457335);
|
||||
private static final Color GREEN_FOCUSED_BACKGROUND = new Color(0xe1f6da);
|
||||
|
||||
private static final Color BLUE_BACKGROUND = new JBColor(0x1d73bf, 0x134d80);
|
||||
|
||||
@Override
|
||||
public void actionPerformed(AnActionEvent e) {
|
||||
Project project = e.getProject();
|
||||
if (project != null) {
|
||||
new MyButtonStyleAction(project).show();
|
||||
}
|
||||
}
|
||||
|
||||
private static class MyButtonStyleAction extends DialogWrapper {
|
||||
private MyButtonStyleAction(Project project) {
|
||||
super(project);
|
||||
init();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
JPanel panel = new JPanel(new GridBagLayout());
|
||||
GridBagConstraints gc = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.LINE_START, GridBagConstraints.HORIZONTAL,
|
||||
JBUI.insets(5), 0, 0);
|
||||
|
||||
JButton button1 = new JButton("Button 1");
|
||||
button1.putClientProperty(BACKGROUND_PROPERTY, WHITE_BACKGROUND);
|
||||
button1.putClientProperty(FOCUSED_BACKGROUND_PROPERTY, GREEN_FOCUSED_BACKGROUND);
|
||||
button1.putClientProperty(BORDER_PROPERTY, GREEN_BORDER);
|
||||
button1.putClientProperty(FOCUSED_BORDER_PROPERTY, GREEN_BORDER);
|
||||
button1.putClientProperty(FOCUSED_TEXT_COLOR, GREEN_BORDER);
|
||||
button1.putClientProperty(TEXT_COLOR, GREEN_BORDER);
|
||||
panel.add(button1, gc);
|
||||
|
||||
JButton button2 = new JButton("Button 2");
|
||||
//Color fg2 = button2.getForeground();
|
||||
//button2.setForeground(new JBColor(() -> button2.hasFocus() ? fg2 : Color.WHITE));
|
||||
button2.putClientProperty(TEXT_COLOR, WHITE_FOREGROUND);
|
||||
button2.putClientProperty(BACKGROUND_PROPERTY, BLUE_BACKGROUND);
|
||||
button2.putClientProperty(BORDER_PROPERTY, BLUE_BACKGROUND);
|
||||
gc.gridy++;
|
||||
panel.add(button2, gc);
|
||||
|
||||
JButton button3 = new JButton("Button 3");
|
||||
//Color fg3 = button3.getForeground();
|
||||
//button3.setForeground(new JBColor(() -> button3.hasFocus() ? fg3 : Color.WHITE));
|
||||
button3.putClientProperty(TEXT_COLOR, WHITE_FOREGROUND);
|
||||
button3.putClientProperty(BACKGROUND_PROPERTY, GREEN_BACKGROUND);
|
||||
button3.putClientProperty(FOCUSED_BACKGROUND_PROPERTY, GREEN_FOCUSED_BACKGROUND);
|
||||
button3.putClientProperty(BORDER_PROPERTY, GREEN_BORDER);
|
||||
button3.putClientProperty(FOCUSED_BORDER_PROPERTY, GREEN_BORDER);
|
||||
gc.gridy++;
|
||||
panel.add(button3, gc);
|
||||
|
||||
JButton button4 = new JButton("Button 4");
|
||||
gc.gridy++;
|
||||
panel.add(button4, gc);
|
||||
|
||||
gc.gridx++;
|
||||
gc.gridy = 0;
|
||||
gc.fill = GridBagConstraints.REMAINDER;
|
||||
gc.insets = JBUI.emptyInsets();
|
||||
gc.weightx = 1.0;
|
||||
panel.add(new JPanel(), gc);
|
||||
|
||||
gc.gridy++;
|
||||
panel.add(new JPanel(), gc);
|
||||
|
||||
gc.gridy++;
|
||||
panel.add(new JPanel(), gc);
|
||||
|
||||
gc.gridy++;
|
||||
panel.add(new JPanel(), gc);
|
||||
|
||||
return panel;
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-29
@@ -60,7 +60,6 @@ import javax.swing.plaf.UIResource;
|
||||
import javax.swing.text.*;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLDocument;
|
||||
import javax.swing.text.html.ParagraphView;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.awt.geom.Rectangle2D;
|
||||
@@ -351,34 +350,7 @@ public class NotificationsManagerImpl extends NotificationsManager {
|
||||
}
|
||||
}
|
||||
};
|
||||
text.setEditorKit(new UIUtil.JBHtmlEditorKit() {
|
||||
final HTMLFactory factory = new HTMLFactory() {
|
||||
public View create(Element e) {
|
||||
View view = super.create(e);
|
||||
if (view instanceof ParagraphView) {
|
||||
// wrap too long words, for example: ATEST_TABLE_SIGNLE_ROW_UPDATE_AUTOCOMMIT_A_FIK
|
||||
return new ParagraphView(e) {
|
||||
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
|
||||
if (r == null) {
|
||||
r = new SizeRequirements();
|
||||
}
|
||||
r.minimum = (int)layoutPool.getMinimumSpan(axis);
|
||||
r.preferred = Math.max(r.minimum, (int)layoutPool.getPreferredSpan(axis));
|
||||
r.maximum = Integer.MAX_VALUE;
|
||||
r.alignment = 0.5f;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ViewFactory getViewFactory() {
|
||||
return factory;
|
||||
}
|
||||
});
|
||||
text.setEditorKit(new UIUtil.JBWordWrapHtmlEditorKit());
|
||||
text.setForeground(foreground);
|
||||
|
||||
final HyperlinkListener listener = NotificationsUtil.wrapListener(notification);
|
||||
|
||||
@@ -767,7 +767,6 @@
|
||||
text="Add Test Notification"/>
|
||||
<action id="TestMessageBoxAction" internal="true" class="com.intellij.diagnostic.TestMessageBoxAction" text="Show Test Dialog"/>
|
||||
<action id="ComponentPanelTestAction" internal="true" class="com.intellij.internal.ui.ComponentPanelTestAction" text="Show standard panels"/>
|
||||
<action id="ButtonStyleAction" internal="true" class="com.intellij.internal.ui.ButtonStyleAction" text="Button styles"/>
|
||||
<separator/>
|
||||
<action id="EditorRenderingBenchmarkAction" internal="true" class="com.intellij.internal.performance.EditorRenderingBenchmarkAction"
|
||||
text="Editor Rendering Benchmark"/>
|
||||
|
||||
@@ -49,6 +49,7 @@ import javax.swing.text.*;
|
||||
import javax.swing.text.html.CSS;
|
||||
import javax.swing.text.html.HTML;
|
||||
import javax.swing.text.html.HTMLEditorKit;
|
||||
import javax.swing.text.html.ParagraphView;
|
||||
import javax.swing.text.html.StyleSheet;
|
||||
import javax.swing.undo.UndoManager;
|
||||
import java.awt.*;
|
||||
@@ -2728,6 +2729,35 @@ public class UIUtil {
|
||||
}
|
||||
}
|
||||
|
||||
public static class JBWordWrapHtmlEditorKit extends JBHtmlEditorKit {
|
||||
private final HTMLFactory myFactory = new HTMLFactory() {
|
||||
public View create(Element e) {
|
||||
View view = super.create(e);
|
||||
if (view instanceof javax.swing.text.html.ParagraphView) {
|
||||
// wrap too long words, for example: ATEST_TABLE_SIGNLE_ROW_UPDATE_AUTOCOMMIT_A_FIK
|
||||
return new ParagraphView(e) {
|
||||
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r) {
|
||||
if (r == null) {
|
||||
r = new SizeRequirements();
|
||||
}
|
||||
r.minimum = (int)layoutPool.getMinimumSpan(axis);
|
||||
r.preferred = Math.max(r.minimum, (int)layoutPool.getPreferredSpan(axis));
|
||||
r.maximum = Integer.MAX_VALUE;
|
||||
r.alignment = 0.5f;
|
||||
return r;
|
||||
}
|
||||
};
|
||||
}
|
||||
return view;
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public ViewFactory getViewFactory() {
|
||||
return myFactory;
|
||||
}
|
||||
}
|
||||
|
||||
public static FontUIResource getFontWithFallback(@NotNull Font font) {
|
||||
return getFontWithFallback(font.getFamily(), font.getStyle(), font.getSize());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user