From 0a32b3ac133c5db971156d42276f28d605a89c20 Mon Sep 17 00:00:00 2001 From: "Link.Zhao" Date: Fri, 23 Sep 2022 11:56:13 +0800 Subject: [PATCH] =?UTF-8?q?REPORT-80734=E3=80=90=E8=BF=90=E8=90=A5?= =?UTF-8?q?=E4=BA=A7=E5=93=81=E5=8C=96=E4=BA=8C=E6=9C=9F=E3=80=91=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E6=8E=92=E5=BA=8F=E4=BA=A4=E4=BA=92=E9=97=AE?= =?UTF-8?q?=E9=A2=98=201=E3=80=81=E4=BA=A4=E4=BA=92=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=B8=80=E4=B8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../help/alphafine/AlphaFineConfigPane.java | 30 +++++++++--------- .../alphafine/component/CustomSortPane.java | 31 ++++++++++++++++--- .../help/alphafine/component/MenuLabel.java | 4 +-- .../com/fr/design/gui/ibutton/UIButton.java | 12 +++++++ 4 files changed, 57 insertions(+), 20 deletions(-) diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java index 2a64eeba6d..dcc20f6ea7 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/AlphaFineConfigPane.java @@ -114,7 +114,9 @@ public class AlphaFineConfigPane extends BasicPane { customSortLabel = new ActionLabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_AlphaFine_Config_Custom_Sort"), false); customSortLabel.setForeground(UIConstants.NORMAL_BLUE); customSortLabel.addActionListener((event)->{ + if (customSortLabel.isEnabled()) { openCustomSortMenu(); + } }); customSortWrapperPane.add(customSortLabel); if (!hasSelectedSearchRangeCheckBox()) { @@ -178,25 +180,25 @@ public class AlphaFineConfigPane extends BasicPane { return res; } - // 搜索范围-我的模板 + /** + * 搜索范围-我的模板 + */ private void initMyTemplateSearchPane() { - containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT,4,5)); + containMyTemplatePane = new JPanel(new FlowLayout(FlowLayout.LEFT, 4, 5)); containMyTemplateCheckbox.setBorder(BorderFactory.createEmptyBorder()); - containMyTemplateCheckbox.addActionListener( - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - if (containMyTemplateCheckbox.isSelected()) { - myTemplateSearchConfigButton.setVisible(true); - } else { - myTemplateSearchConfigButton.setVisible(false); - } - } + containMyTemplateCheckbox.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + if (containMyTemplateCheckbox.isSelected()) { + myTemplateSearchConfigButton.setVisible(true); + } else { + myTemplateSearchConfigButton.setVisible(false); } - ); + } + }); myTemplateSearchConfigButton = new JButton(); myTemplateSearchConfigButton.setBorder(BorderFactory.createEmptyBorder()); - myTemplateSearchConfigButton.setMargin(new Insets(0,0,0,0)); + myTemplateSearchConfigButton.setMargin(new Insets(0, 0, 0, 0)); myTemplateSearchConfigButton.setIcon(IconUtils.readIcon("/com/fr/design/mainframe/alphafine/images/config.svg")); myTemplateSearchMenu = new UIPopupMenu(); containTemplateNameSearchCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_AlphaFine_Config_Name_Search")); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java index 09415d5327..747b8d8ce0 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/CustomSortPane.java @@ -74,10 +74,14 @@ public class CustomSortPane extends JPanel { } private void createToolbarPane() { - top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg")); - bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg")); - up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg")); - down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg")); + top = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top.svg"), false); + bottom = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom.svg"), false); + up = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up.svg"), false); + down = new UIButton(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down.svg"), false); + top.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/top_disable.svg")); + bottom.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/bottom_disable.svg")); + up.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/up_disable.svg")); + down.setDisabledIcon(IconUtils.readIcon("com/fr/design/mainframe/alphafine/images/down_disable.svg")); top.addActionListener(e -> { SwingUtilities.invokeLater(() -> { sortItemPane.setComponentZOrder(selectedLabel, 0); @@ -132,6 +136,7 @@ public class CustomSortPane extends JPanel { for (UICheckBox item : sortItems) { MenuLabel label = new MenuLabel(item.getText(), (Function) o -> { selectedLabel = o; + disableButton(); return null; }); sortLabels.add(label); @@ -140,6 +145,24 @@ public class CustomSortPane extends JPanel { sortItemPane = new MenuLabelPane(sortLabels); } + /** + * 如果选中第一个和最后一个,则置灰向上和向下的按钮 + */ + private void disableButton() { + int order = sortItemPane.getComponentZOrder(selectedLabel); + if (order == 0) { + top.setEnabled(false); + up.setEnabled(false); + } else if (order == sortItemPane.getComponentCount() - 1) { + down.setEnabled(false); + bottom.setEnabled(false); + } else { + up.setEnabled(true); + top.setEnabled(true); + down.setEnabled(true); + bottom.setEnabled(true); + } + } private void refreshCurrentOrder() { String[] currentTabOrder = parentPane.getCurrentOrder(); diff --git a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java index 96c7a17971..5f3708ed97 100644 --- a/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java +++ b/designer-base/src/main/java/com/fr/design/actions/help/alphafine/component/MenuLabel.java @@ -61,10 +61,10 @@ public class MenuLabel extends UILabel { parentMenu.setNoneSelected(); setBackground(SELECTED_COLOR); function.apply(this); - selected = true; + this.selected = true; } else { setBackground(BACKGROUND_COLOR); - selected = false; + this.selected = false; } } diff --git a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java index 335397d908..e5f2c03ff8 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java +++ b/designer-base/src/main/java/com/fr/design/gui/ibutton/UIButton.java @@ -61,6 +61,14 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { init(); } + public UIButton(Icon icon, boolean decorate) { + this(icon); + if (!decorate) { + setContentAreaFilled(false); + setFocusPainted(false); + setBorderPainted(false); + } + } public UIButton(Icon icon) { super(icon); @@ -397,4 +405,8 @@ public class UIButton extends JButton implements UIObserver, UITextComponent { public boolean shouldResponseChangeListener() { return true; } + + + + }