Browse Source

Pull request #6301: REPORT-61267 & REPORT-61108

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

* commit '9af28428108042d7fbf92688dd5887b7e63f1cfe':
  REPORT-61108 【视觉验收】--主题获取
  REPORT-61267 【FR11】【组件背景分离】组件复用-组件标题图案的“图案相对位置”切换不生效了,只有在重新上传图案的时候才生效;“位置”也不生效
new-design
starryi 3 years ago
parent
commit
8d07d62ebb
  1. 18
      designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java
  2. 14
      designer-base/src/main/java/com/fr/design/gui/imenu/UIPopupMenu.java
  3. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/DownloadSuitableThemeAction.java
  4. 13
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/Jump2DetailAction.java
  5. 28
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/LoadingMenuItem.java
  6. 49
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItem.java
  7. 8
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentMenuItemUI.java
  8. 31
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupAction.java
  9. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/actions/SharedComponentPopupMenu.java
  10. 8
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  11. 32
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  12. BIN
      designer-form/src/main/resources/com/fr/design/form/images/loading.gif

18
designer-base/src/main/java/com/fr/design/gui/ibutton/UIButtonGroup.java

@ -3,6 +3,8 @@ package com.fr.design.gui.ibutton;
import com.fr.design.constants.UIConstants;
import com.fr.design.event.GlobalNameListener;
import com.fr.design.event.GlobalNameObserver;
import com.fr.design.event.UIObserver;
import com.fr.design.event.UIObserverListener;
import com.fr.design.utils.gui.UIComponentUtils;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StringUtils;
@ -24,7 +26,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver, UIObserver {
private static final long serialVersionUID = 1L;
private static final int TEXT_LENGTH = 3;
private static final int BUTTON_SIZE = 2;
@ -37,6 +39,7 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
private boolean isToolBarComponent = false;
private boolean isClick;
private UIObserverListener uiObserverListener;
private boolean autoFireStateChanged = true;
public UIButtonGroup(String[] textArray) {
@ -326,6 +329,9 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
((ChangeListener) listeners[i + 1]).stateChanged(e);
}
}
if (uiObserverListener != null) {
uiObserverListener.doChange();
}
}
/**
@ -368,6 +374,16 @@ public class UIButtonGroup<T> extends JPanel implements GlobalNameObserver {
return true;
}
@Override
public void registerChangeListener(UIObserverListener listener) {
this.uiObserverListener = listener;
}
@Override
public boolean shouldResponseChangeListener() {
return true;
}
/**
* @param l

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;
public class UIPopupMenu extends JPopupMenu{
private static final float REC = 8f;
private static final float DEFAULT_REC = 8f;
private boolean onlyText = false;
private float rec = DEFAULT_REC;
public static UIPopupMenu EMPTY = new UIPopupMenu();
public UIPopupMenu() {
super();
@ -19,8 +21,7 @@ public class UIPopupMenu extends JPopupMenu{
@Override
protected void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
Shape shape = null;
shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), REC, REC);
Shape shape = new RoundRectangle2D.Double(0, 0, getWidth(), getHeight(), rec, rec);
g2d.setClip(shape);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
super.paintComponent(g2d);
@ -29,10 +30,9 @@ public class UIPopupMenu extends JPopupMenu{
@Override
protected void paintBorder(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
int rec = (int) REC;
g2d.setColor(UIConstants.UIPOPUPMENU_LINE_COLOR);
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
@ -46,4 +46,8 @@ public class UIPopupMenu extends JPopupMenu{
public void setOnlyText(boolean 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
* Created by Starryi on 2021/9/28
*/
public class DownloadSuitableThemeAction extends UpdateAction {
public class DownloadSuitableThemeAction extends SharedComponentPopupAction {
private final String themePath;
private final UIPopupMenu popupMenu;
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 javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.SwingConstants;
import java.awt.Color;
import java.awt.Desktop;
import java.awt.event.ActionEvent;
@ -20,7 +22,7 @@ import java.net.URISyntaxException;
* @version 1.0
* 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 final String id;
@ -30,15 +32,6 @@ public class Jump2DetailAction extends UpdateAction {
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
public void actionPerformed(ActionEvent e) {
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;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.share.ui.constants.ColorConstants;
import com.fr.general.IOUtils;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
/**
* @author Starryi
* @version 1.0
* Created by Starryi on 2021/10/19
*/
public class LoadingMenuItem extends UIMenuItem {
public class LoadingMenuItem extends SharedComponentMenuItem {
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) {
super(action);
setOpaque(true);
setBackground(ColorConstants.BACKGROUND);
setUI(new SharedComponentActionMenuItemUI());
}
public void startLoading() {
loading = true;
setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 20));
revalidate();
repaint();
}
public void stopLoading() {
loading = false;
setBorder(BorderFactory.createEmptyBorder());
revalidate();
repaint();
}
@ -45,10 +39,16 @@ public class LoadingMenuItem extends UIMenuItem {
}
@Override
protected void paintBorder(Graphics g) {
super.paintBorder(g);
public Dimension getPreferredSize() {
Dimension dimension = super.getPreferredSize();
return new Dimension(dimension.width + 12, dimension.height);
}
@Override
public void paint(Graphics g) {
super.paint(g);
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
* Created by Starryi on 2021/10/18
*/
public class SharedComponentActionMenuItemUI extends UIMenuItemUI {
public class SharedComponentMenuItemUI extends UIMenuItemUI {
@Override
protected void paintBackground(Graphics g, JMenuItem menuItem, Color bgColor) {
@ -35,14 +35,14 @@ public class SharedComponentActionMenuItemUI extends UIMenuItemUI {
g.fillRect(0, 0, menuWidth, menuHeight);
if (menuItem.isOpaque()) {
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 {
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);
} else 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);
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;
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.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.OnlineWidgetSelectPane;
import com.fr.design.mainframe.share.ui.online.ResourceLoader;
@ -114,10 +113,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
@Override
public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setOpaque(true);
popupMenu.setBackground(ColorConstants.BACKGROUND);
SharedComponentPopupMenu popupMenu = new SharedComponentPopupMenu();
OnlineShareWidget widget = getWidget();
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.design.actions.UpdateAction;
import com.fr.design.base.mode.DesignModeContext;
import com.fr.design.constants.UIConstants;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.dialog.FineJOptionPane;
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.share.collect.ComponentCollector;
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.base.PopupMenuItem;
import com.fr.design.mainframe.share.ui.actions.SharedComponentMenuItemUI;
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.local.LocalWidgetRepoPane;
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.form.share.DefaultSharableWidget;
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.Group;
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.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.StringUtils;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@ -276,7 +274,7 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
@Override
public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu();
UIPopupMenu popupMenu = new SharedComponentPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setOpaque(true);
popupMenu.setBackground(ColorConstants.BACKGROUND);
@ -286,21 +284,12 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
return popupMenu;
}
private class MoveGroupAction extends UpdateAction {
private class MoveGroupAction extends SharedComponentPopupAction {
public MoveGroupAction() {
this.putValue(Action.SMALL_ICON, null);
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
public void actionPerformed(ActionEvent e) {
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() {
this.putValue(Action.SMALL_ICON, null);
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
public void actionPerformed(ActionEvent e) {
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