Browse Source

Pull request #6297: REPORT-61108 【视觉验收】--主题获取

Merge in DESIGN/design from ~STARRYI/design:release/11.0 to release/11.0

* commit '2c6bfcc0f76c86b5663f8d9078408e787d35a638':
  REPORT-61108 【视觉验收】--主题获取
bugfix/11.0
starryi 3 years ago
parent
commit
9af2842810
  1. 14
      designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupMenu.java
  2. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java
  3. 13
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java
  4. 28
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java
  5. 49
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItem.java
  6. 8
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItemUI.java
  7. 31
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupAction.java
  8. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupMenu.java
  9. 8
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  10. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  11. BIN
      designer-form/src/main/resources/com/fr/design/form/images/loading.gif

14
designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupMenu.java

@ -8,8 +8,10 @@ import javax.swing.*;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
public class UIPopupMenu extends JPopupMenu{ public class UIPopupMenu extends JPopupMenu{
private static final float REC = 8f; private static final float DEFAULT_REC = 8f;
private boolean onlyText = false; private boolean onlyText = false;
private float rec = DEFAULT_REC;
public static UIPopupMenu EMPTY = new UIPopupMenu(); public static UIPopupMenu EMPTY = new UIPopupMenu();
public UIPopupMenu() { public UIPopupMenu() {
super(); super();
@ -19,8 +21,7 @@ public class UIPopupMenu extends JPopupMenu{
@Override @Override
protected void paintComponent(Graphics g) { protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Shape shape = null; Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), rec, rec);
shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
g2d.setClip(shape); g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d); super.paintComponent(g2d);
@ -29,10 +30,9 @@ public class UIPopupMenu extends JPopupMenu{
@Override @Override
protected void paintBorder(Graphics g) { protected void paintBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR); g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, rec, rec); g2d.drawRoundRect(0, 0, getWidth() - 1, getHeight() - 1, (int) rec, (int) rec);
} }
@Override @Override
@ -46,4 +46,8 @@ public class UIPopupMenu extends JPopupMenu{
public void setOnlyText(boolean onlyText) { public void setOnlyText(boolean onlyText) {
this.onlyText = onlyText; this.onlyText = onlyText;
} }
public void setRadius(float radius) {
this.rec = radius;
}
} }

2
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java

@ -38,7 +38,7 @@ import java.util.concurrent.ExecutionException;
* @version 1.0 * @version 1.0
* Created by Starryi on 2021/9/28 * Created by Starryi on 2021/9/28
*/ */
public class DownloadSuitableThemeAction extends UpdateAction { public class DownloadSuitableThemeAction extends SharedComponentPopupAction {
private final String themePath; private final String themePath;
private final UIPopupMenu popupMenu; private final UIPopupMenu popupMenu;
private boolean downloading = false; private boolean downloading = false;

13
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java

@ -8,6 +8,8 @@ import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.SwingConstants;
import java.awt.Color; import java.awt.Color;
import java.awt.Desktop; import java.awt.Desktop;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -20,7 +22,7 @@ import java.net.URISyntaxException;
* @version 1.0 * @version 1.0
* Created by Starryi on 2021/9/28 * Created by Starryi on 2021/9/28
*/ */
public class Jump2DetailAction extends UpdateAction { public class Jump2DetailAction extends SharedComponentPopupAction {
private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = "https://market.fanruan.com/reuse/%s"; private static final String ONLINE_WIDGET_DETAIL_FORMATTED_URL = "https://market.fanruan.com/reuse/%s";
private final String id; private final String id;
@ -30,15 +32,6 @@ public class Jump2DetailAction extends UpdateAction {
this.setName(Toolkit.i18nText("Fine-Design_Share_Jump_To_Detail")); this.setName(Toolkit.i18nText("Fine-Design_Share_Jump_To_Detail"));
} }
@Override
public UIMenuItem createMenuItem() {
UIMenuItem menuItem = super.createMenuItem();
menuItem.setOpaque(true);
menuItem.setBackground(ColorConstants.BACKGROUND);
menuItem.setUI(new SharedComponentActionMenuItemUI());
return menuItem;
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (StringUtils.isNotEmpty(id)) { if (StringUtils.isNotEmpty(id)) {

28
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java

@ -1,41 +1,35 @@
package com.fr.design.mainframe.share.ui.actions; package com.fr.design.mainframe.share.ui.actions;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.BorderFactory; import java.awt.Dimension;
import javax.swing.Icon;
import java.awt.Graphics; import java.awt.Graphics;
import java.awt.image.BufferedImage;
/** /**
* @author Starryi * @author Starryi
* @version 1.0 * @version 1.0
* Created by Starryi on 2021/10/19 * Created by Starryi on 2021/10/19
*/ */
public class LoadingMenuItem extends UIMenuItem { public class LoadingMenuItem extends SharedComponentMenuItem {
private boolean loading = false; private boolean loading = false;
private final Icon profileIcon = IOUtils.readIcon("/com/fr/design/form/images/loading.gif"); private final BufferedImage loadingImage = IOUtils.readImageWithCache("/com/fr/design/form/images/loading.gif");
public static final int LOADING_ICON_PAINT_SIZE = 12;
public LoadingMenuItem(Action action) { public LoadingMenuItem(Action action) {
super(action); super(action);
setOpaque(true);
setBackground(ColorConstants.BACKGROUND);
setUI(new SharedComponentActionMenuItemUI());
} }
public void startLoading() { public void startLoading() {
loading = true; loading = true;
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
revalidate(); revalidate();
repaint(); repaint();
} }
public void stopLoading() { public void stopLoading() {
loading = false; loading = false;
setBorder(BorderFactory.createEmptyBorder());
revalidate(); revalidate();
repaint(); repaint();
} }
@ -45,10 +39,16 @@ public class LoadingMenuItem extends UIMenuItem {
} }
@Override @Override
protected void paintBorder(Graphics g) { public Dimension getPreferredSize() {
super.paintBorder(g); Dimension dimension = super.getPreferredSize();
return new Dimension(dimension.width + 12, dimension.height);
}
@Override
public void paint(Graphics g) {
super.paint(g);
if (loading) { if (loading) {
profileIcon.paintIcon(this, g, getWidth() - 20, 0); g.drawImage(loadingImage, getWidth() - 16, 6, LOADING_ICON_PAINT_SIZE, LOADING_ICON_PAINT_SIZE, null);
} }
} }
} }

49
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItem.java

@ -0,0 +1,49 @@
package com.fr.design.mainframe.share.ui.actions;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.SwingConstants;
import java.awt.Dimension;
import java.awt.Insets;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/10/20
*/
public class SharedComponentMenuItem extends UIMenuItem {
public SharedComponentMenuItem(Action action) {
super(action);
setBackground(ColorConstants.BACKGROUND);
setUI(new SharedComponentMenuItemUI());
setHorizontalAlignment(SwingConstants.LEFT);
setVerticalAlignment(SwingConstants.CENTER);
setBorder(BorderFactory.createEmptyBorder());
setIcon(null);
setIconTextGap(4);
}
@Override
public Dimension getPreferredSize() {
Dimension dimension = super.getPreferredSize();
return new Dimension(dimension.width, dimension.height + 8);
}
@Override
public Dimension getMinimumSize() {
return new Dimension(0, 0);
}
@Override
public Insets getInsets() {
return new Insets(0, 0, 0, 0);
}
@Override
public String getText() {
return super.getText().trim();
}
}

8
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentActionMenuItemUI.java → designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItemUI.java

@ -22,7 +22,7 @@ import java.awt.Graphics2D;
* @version 1.0 * @version 1.0
* Created by Starryi on 2021/10/18 * Created by Starryi on 2021/10/18
*/ */
public class SharedComponentActionMenuItemUI extends UIMenuItemUI { public class SharedComponentMenuItemUI extends UIMenuItemUI {
@Override @Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) { protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
@ -35,14 +35,14 @@ public class SharedComponentActionMenuItemUI extends UIMenuItemUI {
g.fillRect(0, 0, menuWidth, menuHeight); g.fillRect(0, 0, menuWidth, menuHeight);
if (menuItem.isOpaque()) { if (menuItem.isOpaque()) {
if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) { if (model.isArmed() || (menuItem instanceof JMenu && model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0);
} else { } else {
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 7); GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, menuItem.getBackground(), 0);
} }
g.setColor(oldColor); g.setColor(oldColor);
} else if (model.isArmed() || (menuItem instanceof JMenu && } else if (model.isArmed() || (menuItem instanceof JMenu &&
model.isSelected())) { model.isSelected())) {
GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 7); GUIPaintUtils.fillPaint((Graphics2D) g, 0, 0, menuWidth, menuHeight, true, Constants.NULL, UIConstants.FLESH_BLUE, 0);
g.setColor(oldColor); g.setColor(oldColor);
} }
} }

31
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupAction.java

@ -0,0 +1,31 @@
package com.fr.design.mainframe.share.ui.actions;
import com.fr.design.actions.UpdateAction;
import com.fr.design.gui.imenu.UIMenuItem;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/10/20
*/
public abstract class SharedComponentPopupAction extends UpdateAction {
@Override
public UIMenuItem createMenuItem() {
Object object = this.getValue(SharedComponentMenuItem.class.getName());
if (object == null) {
SharedComponentMenuItem menuItem = newSharedComponentMenuItem();
// 设置名字用作单元测
menuItem.setName(getName());
setPressedIcon4Button(menuItem);
setDisabledIcon4Button(menuItem);
object = menuItem;
this.putValue(SharedComponentMenuItem.class.getName(), object);
}
return (SharedComponentMenuItem) object;
}
protected SharedComponentMenuItem newSharedComponentMenuItem() {
return new SharedComponentMenuItem(this);
}
}

32
designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupMenu.java

@ -0,0 +1,32 @@
package com.fr.design.mainframe.share.ui.actions;
import com.fr.design.gui.imenu.UIPopupMenu;
import javax.swing.BorderFactory;
import java.awt.Dimension;
import java.awt.Insets;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/10/20
*/
public class SharedComponentPopupMenu extends UIPopupMenu {
public SharedComponentPopupMenu() {
setBorder(BorderFactory.createEmptyBorder());
setRadius(2);
}
@Override
public Insets getInsets() {
return new Insets(2, 2, 2, 2);
}
@Override
public Dimension getMinimumSize() {
Dimension dimension = super.getMinimumSize();
dimension.width = 0;
dimension.height = 0;
return dimension;
}
}

8
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java

@ -1,10 +1,9 @@
package com.fr.design.mainframe.share.ui.block; package com.fr.design.mainframe.share.ui.block;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.imenu.UIPopupMenu;
import com.fr.design.mainframe.share.ui.actions.DownloadSuitableThemeAction; import com.fr.design.mainframe.share.ui.actions.DownloadSuitableThemeAction;
import com.fr.design.mainframe.share.ui.actions.Jump2DetailAction; import com.fr.design.mainframe.share.ui.actions.Jump2DetailAction;
import com.fr.design.mainframe.share.ui.constants.ColorConstants; import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupMenu;
import com.fr.design.mainframe.share.ui.online.OnlineResourceManager; import com.fr.design.mainframe.share.ui.online.OnlineResourceManager;
import com.fr.design.mainframe.share.ui.online.OnlineWidgetSelectPane; import com.fr.design.mainframe.share.ui.online.OnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.ResourceLoader; import com.fr.design.mainframe.share.ui.online.ResourceLoader;
@ -114,10 +113,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
@Override @Override
public JPopupMenu createRightClickPopupMenu() { public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu(); SharedComponentPopupMenu popupMenu = new SharedComponentPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setOpaque(true);
popupMenu.setBackground(ColorConstants.BACKGROUND);
OnlineShareWidget widget = getWidget(); OnlineShareWidget widget = getWidget();
String suitableThemeFile = widget.getThemePath(); String suitableThemeFile = widget.getThemePath();

32
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java

@ -4,7 +4,6 @@ import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext; import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator; import com.fr.design.designer.creator.XCreator;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.form.util.XCreatorConstants; import com.fr.design.form.util.XCreatorConstants;
@ -16,8 +15,9 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.WidgetToolBarPane; import com.fr.design.mainframe.WidgetToolBarPane;
import com.fr.design.mainframe.share.collect.ComponentCollector; import com.fr.design.mainframe.share.collect.ComponentCollector;
import com.fr.design.mainframe.share.group.ui.GroupMoveDialog; import com.fr.design.mainframe.share.group.ui.GroupMoveDialog;
import com.fr.design.mainframe.share.ui.actions.SharedComponentActionMenuItemUI; import com.fr.design.mainframe.share.ui.actions.SharedComponentMenuItemUI;
import com.fr.design.mainframe.share.ui.base.PopupMenuItem; import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupAction;
import com.fr.design.mainframe.share.ui.actions.SharedComponentPopupMenu;
import com.fr.design.mainframe.share.ui.constants.ColorConstants; import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane; import com.fr.design.mainframe.share.ui.local.LocalWidgetRepoPane;
import com.fr.design.mainframe.share.ui.local.LocalWidgetSelectPane; import com.fr.design.mainframe.share.ui.local.LocalWidgetSelectPane;
@ -27,7 +27,6 @@ import com.fr.design.mainframe.share.util.ShareUIUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.DefaultSharableWidget;
import com.fr.form.share.SharableWidgetProvider; import com.fr.form.share.SharableWidgetProvider;
import com.fr.form.share.bean.OnlineShareWidget;
import com.fr.form.share.constants.ShareComponentConstants; import com.fr.form.share.constants.ShareComponentConstants;
import com.fr.form.share.Group; import com.fr.form.share.Group;
import com.fr.form.share.record.ShareWidgetInfoManager; import com.fr.form.share.record.ShareWidgetInfoManager;
@ -36,7 +35,6 @@ import com.fr.form.ui.Widget;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils; import com.fr.general.IOUtils;
import com.fr.stable.Constants; import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
@ -276,7 +274,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
@Override @Override
public JPopupMenu createRightClickPopupMenu() { public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu(); UIPopupMenu popupMenu = new SharedComponentPopupMenu();
popupMenu.setOnlyText(true); popupMenu.setOnlyText(true);
popupMenu.setOpaque(true); popupMenu.setOpaque(true);
popupMenu.setBackground(ColorConstants.BACKGROUND); popupMenu.setBackground(ColorConstants.BACKGROUND);
@ -286,21 +284,12 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
return popupMenu; return popupMenu;
} }
private class MoveGroupAction extends UpdateAction { private class MoveGroupAction extends SharedComponentPopupAction {
public MoveGroupAction() { public MoveGroupAction() {
this.putValue(Action.SMALL_ICON, null); this.putValue(Action.SMALL_ICON, null);
this.setName(Toolkit.i18nText("Fine-Design_Share_Group_Move")); this.setName(Toolkit.i18nText("Fine-Design_Share_Group_Move"));
} }
@Override
public UIMenuItem createMenuItem() {
UIMenuItem menuItem = super.createMenuItem();
menuItem.setOpaque(true);
menuItem.setBackground(ColorConstants.BACKGROUND);
menuItem.setUI(new SharedComponentActionMenuItemUI());
return menuItem;
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
new GroupMoveDialog(DesignerContext.getDesignerFrame()) { new GroupMoveDialog(DesignerContext.getDesignerFrame()) {
@ -321,21 +310,12 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
} }
} }
private class RemoveAction extends UpdateAction { private class RemoveAction extends SharedComponentPopupAction {
public RemoveAction() { public RemoveAction() {
this.putValue(Action.SMALL_ICON, null); this.putValue(Action.SMALL_ICON, null);
this.setName(Toolkit.i18nText("Fine-Design_Share_Remove")); this.setName(Toolkit.i18nText("Fine-Design_Share_Remove"));
} }
@Override
public UIMenuItem createMenuItem() {
UIMenuItem menuItem = super.createMenuItem();
menuItem.setOpaque(true);
menuItem.setBackground(ColorConstants.BACKGROUND);
menuItem.setUI(new SharedComponentActionMenuItemUI());
return menuItem;
}
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int rv = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), int rv = FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(),

BIN
designer-form/src/main/resources/com/fr/design/form/images/loading.gif

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.3 KiB

After

Width:  |  Height:  |  Size: 49 KiB

Loading…
Cancel
Save