Browse Source

Pull request #13528: REPORT-107973 windows下颜色选择弹窗立即消失 && 东区面板兼容插件图标 && 西区搜索面板及间距

Merge in DESIGN/design from ~LEO.QIN/design:newui to newui

* commit 'bc891be86ad1a5e53d536167f2d630c08dc60237':
  REPORT-107973 修改西区搜索面板以及toolbar间距
  REPORT-107973 东区面板兼容插件图标
  REPORT-107973 兼容插件图标
  REPORT-107973 windows下颜色选择弹窗立即消失
newui
Leo.Qin-覃宇攀 11 months ago
parent
commit
d55200c4e8
  1. 30
      designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java
  2. 31
      designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java
  3. 5
      designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java
  4. 40
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  5. 91
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java
  6. 14
      designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java
  7. 2
      designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java
  8. 1
      designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java

30
designer-base/src/main/java/com/fr/design/data/datapane/management/search/pane/FineSearchPane.java

@ -8,6 +8,7 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
@ -60,7 +61,24 @@ public class FineSearchPane extends JPanel implements HoverAware {
// 中间输入框
searchTextField = new UITextField();
setStyle(searchTextField, TRANSPARENT_TEXT_FIELD);
searchTextField.addMouseListener(new MouseAdapter() {
// 右侧返回图标
clearButton = new UIButton(new LazyIcon("clear"));
setStyle(clearButton, STYLE_TEXT);
Insets buttonInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.buttonBorderInsets", defaultButtonInsets);
clearButton.setBorder(BorderFactory.createEmptyBorder(buttonInsets.top, buttonInsets.left, buttonInsets.bottom, buttonInsets.right));
this.add(searchLabel, BorderLayout.WEST);
this.add(searchTextField, BorderLayout.CENTER);
this.add(clearButton, BorderLayout.EAST);
addHoverStatusListener(searchLabel);
addHoverStatusListener(searchTextField);
addHoverStatusListener(clearButton);
}
private void addHoverStatusListener(JComponent component) {
component.addMouseListener(new MouseAdapter() {
@Override
public void mouseEntered(MouseEvent e) {
hover = true;
@ -73,16 +91,6 @@ public class FineSearchPane extends JPanel implements HoverAware {
repaint();
}
});
// 右侧返回图标
clearButton = new UIButton(new LazyIcon("clear"));
setStyle(clearButton, STYLE_TEXT);
Insets buttonInsets = FineUIUtils.getAndScaleUIInsets("SearchPanel.buttonBorderInsets", defaultButtonInsets);
clearButton.setBorder(BorderFactory.createEmptyBorder(buttonInsets.top, buttonInsets.left, buttonInsets.bottom, buttonInsets.right));
this.add(searchLabel, BorderLayout.WEST);
this.add(searchTextField, BorderLayout.CENTER);
this.add(clearButton, BorderLayout.EAST);
}
@Override

31
designer-base/src/main/java/com/fr/design/gui/itextfield/UITextField.java

@ -7,22 +7,20 @@ import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.HoverAware;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.text.Document;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.LayoutManager;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import static com.formdev.flatlaf.FlatClientProperties.PLACEHOLDER_TEXT;
/**
* 文本框
@ -40,7 +38,6 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
private String textFieldName = StringUtils.EMPTY;
private GlobalNameListener globalNameListener = null;
private Dimension preferredSize = null;
private String placeholder = StringUtils.EMPTY;
//有些情况下setText的时候不希望触发attributeChange,添加一个属性标识
private boolean isSetting = false;
@ -121,11 +118,11 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
}
public String getPlaceholder() {
return placeholder;
return (String) this.getClientProperty(PLACEHOLDER_TEXT);
}
public void setPlaceholder(String placeholder) {
this.placeholder = placeholder;
this.putClientProperty(PLACEHOLDER_TEXT, placeholder);
}
@ -212,26 +209,6 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
return true;
}
/**
* 主函数
*
* @param args 参数
*/
public static void main(String... args) {
LayoutManager layoutManager = null;
JFrame jf = new JFrame("test");
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel content = (JPanel) jf.getContentPane();
content.setLayout(layoutManager);
UITextField bb = new UITextField(5);
bb.setBounds(20, 20, bb.getPreferredSize().width, bb.getPreferredSize().height);
content.add(bb);
GUICoreUtils.centerWindow(jf);
jf.setSize(400, 400);
jf.setVisible(true);
}
public void setBorderPainted(boolean isBorderPainted) {
this.isBorderPainted = isBorderPainted;
}

5
designer-base/src/main/java/com/fr/design/gui/itoolbar/UIToolbar.java

@ -1,5 +1,7 @@
package com.fr.design.gui.itoolbar;
import com.fine.theme.utils.FineUIScale;
import javax.swing.JToolBar;
import java.awt.Component;
import java.awt.FlowLayout;
@ -8,6 +10,7 @@ import java.util.HashMap;
import java.util.Map;
public class UIToolbar extends JToolBar {
int hgap = 2;
public UIToolbar() {
this(FlowLayout.LEFT);
@ -17,7 +20,7 @@ public class UIToolbar extends JToolBar {
super();
setFloatable(false);
setRollover(true);
setLayout(new FlowLayout(align, 4, 0));
setLayout(new FlowLayout(align, FineUIScale.scale(hgap), 0));
setBorderPainted(false);
}

40
designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java

@ -7,6 +7,7 @@ import com.fine.theme.utils.FineUIStyle;
import com.fine.theme.utils.FineUIUtils;
import com.formdev.flatlaf.FlatDarkLaf;
import com.fr.base.FRContext;
import com.fr.base.svg.IconUtils;
import com.fr.base.vcs.DesignerMode;
import com.fr.design.DesignerEnvManager;
import com.fr.design.ExtraDesignClassManager;
@ -756,6 +757,14 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
// 完整icon路径为 ICON_BASE_DIR + btnIconName + iconSuffix
private static final String ICON_BASE_DIR = "/com/fr/design/standard/propertiestab/";
@Deprecated
private static final String ICON_SUFFIX_NORMAL_DEPRECATED = "_normal.svg";
@Deprecated
private static final String ICON_SUFFIX_DISABLED_DEPRECATED = "_disabled.svg";
@Deprecated
private static final String ICON_SUFFIX_SELECTED_DEPRECATED = "_selected.svg";
private static final String ICON_SUFFIX_NORMAL = StringUtils.EMPTY;
private static final String ICON_SUFFIX_DISABLED = "_disabled";
private static final String ICON_SUFFIX_SELECTED = "_selected";
@ -769,15 +778,15 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, null, null);
this(name, title, btnIconName, null, visibleModes, enableModes, null, null);
}
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes, SnapChat snapChat, PromptWindow promptWindow, ActionListener actionListener) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, snapChat, promptWindow, actionListener);
this(name, title, btnIconName, null, visibleModes, enableModes, snapChat, promptWindow, actionListener);
}
public PropertyItem(String name, String title, String btnIconName, PropertyMode[] visibleModes, PropertyMode[] enableModes, ActionListener actionListener) {
this(name, title, btnIconName, ICON_BASE_DIR, visibleModes, enableModes, null, null, actionListener);
this(name, title, btnIconName, null, visibleModes, enableModes, null, null, actionListener);
}
public PropertyItem(String name, String title, String btnIconName, String iconBaseDir, PropertyMode[] visibleModes, PropertyMode[] enableModes, SnapChat snapChat, PromptWindow promptWindow) {
@ -968,13 +977,22 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
iconSuffix = ICON_SUFFIX_NORMAL;
button.setIcon(new LazyIcon(getBtnIconId()));
button.setOpaque(false);
} else if (ICON_SUFFIX_SELECTED_DEPRECATED.equals(iconSuffix)) {
iconSuffix = ICON_SUFFIX_NORMAL_DEPRECATED;
button.setIcon(IconUtils.readIcon(getBtnIconUrl()));
button.setOpaque(false);
}
}
public void setTabButtonSelected() {
resetPropertyIcons();
iconSuffix = ICON_SUFFIX_SELECTED;
if (StringUtils.isEmpty(iconBaseDir)) {
button.setIcon(new LazyIcon(getBtnIconId()));
iconSuffix = ICON_SUFFIX_SELECTED;
} else {
iconSuffix = ICON_SUFFIX_SELECTED_DEPRECATED;
button.setIcon(IconUtils.readIcon(getBtnIconUrl()));
}
button.setBackground(selectedBtnBackground);
button.setOpaque(true);
selectedItem = this;
@ -985,12 +1003,12 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
}
private void initButton() {
button = new UIButton(new LazyIcon(getBtnIconId())) {
button = new UIButton() {
public Dimension getPreferredSize() {
return new Dimension(TAB_BUTTON_WIDTH, TAB_BUTTON_HEIGHT);
}
};
button.setDisabledIcon(new LazyIcon(btnIconName + ICON_SUFFIX_DISABLED));
initButtonIcon();
button.set4LargeToolbarButton();
button.setUI(new RectangleButtonUI(false));
setStyle(button, STYLE_TEXT);
@ -1013,6 +1031,16 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
button.setName(name);
}
private void initButtonIcon() {
if (StringUtils.isEmpty(iconBaseDir)) {
button.setIcon(new LazyIcon(getBtnIconId()));
button.setDisabledIcon(new LazyIcon(btnIconName + ICON_SUFFIX_DISABLED));
} else {
button.setIcon(IconUtils.readIcon(getBtnIconUrl()));
button.setDisabledIcon(IconUtils.readIcon(getIconBaseDir() + btnIconName + ICON_SUFFIX_DISABLED_DEPRECATED));
}
}
public void processSnapChat() {
if (snapChat != null && !snapChat.hasRead()) {
snapChat.markRead();

91
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateTreeSearchToolbarPane.java

@ -1,13 +1,9 @@
package com.fr.design.mainframe.manager.search.searcher.control.pane;
import com.fine.theme.icon.LazyIcon;
import com.fr.base.svg.IconUtils;
import com.fr.design.constants.UIConstants;
import com.formdev.flatlaf.util.ScaledEmptyBorder;
import com.fr.design.data.datapane.management.search.pane.FineSearchPane;
import com.fr.design.file.TemplateTreePane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.search.TreeSearchStatus;
@ -15,20 +11,13 @@ import com.fr.design.search.event.TreeSearchStatusChangeEvent;
import com.fr.design.search.event.TreeSearchStatusChangeListener;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Insets;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
/**
* 模板搜索工具栏
@ -57,12 +46,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
/**
* 搜索面板
*/
private JPanel searchPane;
/**
* 搜索输入框
*/
private UITextField searchTextField;
private FineSearchPane searchPane;
/**
* 内容面板
@ -78,7 +62,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
@Override
public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_ENTER) {
TemplateTreeSearchManager.getInstance().startSearch(searchTextField.getText());
TemplateTreeSearchManager.getInstance().startSearch(searchPane.getText());
}
}
};
@ -99,63 +83,24 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
contentPane.add(searchPane, SEARCH_PANE);
contentPane.add(toolbarPane, TOOLBAR_PANE);
cardLayout.show(contentPane, TOOLBAR_PANE);
contentPane.setBorder(new ScaledEmptyBorder(6, 8, 6, 8));
}
private void initSearchPane() {
searchPane = new JPanel(FRGUIPaneFactory.createBorderLayout());
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR));
searchPane.setBackground(Color.WHITE);
// 左侧搜索图标
UILabel searchLabel = new UILabel(new LazyIcon("search"));
searchLabel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 0));
searchLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
// do nothing
}
});
// 中间输入框
initSearchTextField();
// 右侧返回图标
UILabel returnLabel = new UILabel(IconUtils.readIcon("/com/fr/design/standard/clear"));
returnLabel.setToolTipText(Toolkit.i18nText("Fine-Design_Tree_Search_Return"));
returnLabel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 11));
returnLabel.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
searchPane = new FineSearchPane();
searchPane.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Search_Press_Enter_For_Search"));
initSearchTextFieldListener();
searchPane.addClearActionListener(e -> {
TemplateTreeSearchManager.getInstance().outOfSearchMode();
TemplateTreePane.getInstance().refreshDockingView();
}
});
searchPane.add(searchLabel, BorderLayout.WEST);
searchPane.add(searchTextField, BorderLayout.CENTER);
searchPane.add(returnLabel, BorderLayout.EAST);
}
private void initSearchTextField() {
searchTextField = new UITextField(){
@Override
public Insets getInsets() {
return new Insets(2, 4, 0, 4);
}
};
searchTextField.setBorderPainted(false);
searchTextField.setPlaceholder(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Template_Search_Press_Enter_For_Search"));
searchTextField.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.NORMAL_BLUE));
searchPane.repaint();
}
@Override
public void focusLost(FocusEvent e) {
searchPane.setBorder(BorderFactory.createLineBorder(UIConstants.TOOLBAR_BORDER_COLOR));
searchPane.repaint();
}
});
this.searchTextField.getDocument().addDocumentListener(new DocumentListener() {
private void initSearchTextFieldListener() {
searchPane.addDocumentListener(new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
}
@ -169,11 +114,11 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
public void changedUpdate(DocumentEvent e) {
}
});
this.searchTextField.addKeyListener(enterPressed);
searchPane.addKeyListener(enterPressed);
}
private void dealWithTextChange() {
if (StringUtils.isEmpty(searchTextField.getText()) && TemplateTreeSearchManager.getInstance().isInSearchMode()) {
if (StringUtils.isEmpty(searchPane.getText()) && TemplateTreeSearchManager.getInstance().isInSearchMode()) {
// 如果是搜索模式下,看作是用户删除输入框文字,仅复原TemplateTreePane
TemplateTreeSearchManager.getInstance().restoreTreePane();
TemplateTreePane.getInstance().refreshDockingView();
@ -195,7 +140,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
}
public void setPlaceHolder(String placeHolder) {
this.searchTextField.setPlaceholder(placeHolder);
this.searchPane.setPlaceholder(placeHolder);
}
/**
@ -207,7 +152,7 @@ public class TemplateTreeSearchToolbarPane extends JPanel implements TreeSearchS
public void updateTreeSearchChange(TreeSearchStatusChangeEvent event) {
TreeSearchStatus treeSearchStatus = event.getTreeSearchStatus();
if (treeSearchStatus == TreeSearchStatus.NOT_IN_SEARCH_MODE) {
this.searchTextField.setText(StringUtils.EMPTY);
searchPane.setText(StringUtils.EMPTY);
switchPane(TOOLBAR_PANE);
} else {
switchPane(SEARCH_PANE);

14
designer-base/src/main/java/com/fr/design/menu/ToolBarDef.java

@ -5,14 +5,18 @@ import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.itoolbar.UIToolBarUI;
import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.mainframe.JTemplate;
import java.util.Set;
import org.jetbrains.annotations.Nullable;
import javax.swing.*;
import java.awt.*;
import javax.swing.BorderFactory;
import javax.swing.JComponent;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
* Define toolbar..
@ -43,9 +47,7 @@ public class ToolBarDef {
* 一个static的方法生成一个JToolBar
*/
public static UIToolbar createJToolBar() {
UIToolbar toolbar = new UIToolbar(FlowLayout.LEFT);
toolbar.setBorder(BorderFactory.createEmptyBorder(2, 0, 2, 0));
return toolbar;
return new UIToolbar(FlowLayout.LEFT);
}
public ToolBarDef() {

2
designer-base/src/main/java/com/fr/design/style/color/ColorControlWindow.java

@ -56,6 +56,8 @@ public abstract class ColorControlWindow extends JPopupMenu {
private void initComponents(boolean isSupportTransparent) {
setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled());
// windows下 需要手动处理焦点,不去抢占焦点,防止菜单栏弹窗消失
setFocusable(false);
this.setLayout(FRGUIPaneFactory.createBorderLayout());
initSelectionPopupPane(isSupportTransparent);
this.pack();

1
designer-realize/src/main/java/com/fr/design/actions/cell/UIToolbarBorderButton.java

@ -129,6 +129,7 @@ public class UIToolbarBorderButton extends UICombinationButton implements PopupH
setLightWeightPopupEnabled(JPopupMenu.getDefaultLightWeightPopupEnabled());
this.setLayout(FRGUIPaneFactory.createBorderLayout());
// windows下 需要手动处理焦点,不去抢占焦点,防止菜单栏弹窗消失
setFocusable(false);
setStyle(this, POPUP_MENU_DROPDOWN);

Loading…
Cancel
Save