Browse Source

REPORT-60434 【主题获取】在线组件右键,鼠标移动点击详情时,偶现详细消失

【问题原因】
1. 弹窗按钮可见时,鼠标位于弹窗按钮左上角,只要用户向左或向上轻微移动鼠标,
都会导致鼠标移除弹窗按钮区域,并触发其下方控件的鼠标移动事件,进而弹出弹窗预览
界面
2. 共享组件的弹窗预览和弹窗按钮互斥,从而自动关闭弹窗按钮

【改动思路】
重新确定共享组件弹窗的交互方式,包括本地共享组件和在线共享
组件。
1. 弹窗按钮出现时,不支持弹窗预览相关的交互.
2. 使用swing默认行为取消隐藏弹窗按钮
research/11.0
Starryi 3 years ago
parent
commit
8a7ec74a9a
  1. 9
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/AbstractOnlineWidgetBlock.java
  2. 23
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java
  3. 43
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  4. 25
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

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

@ -37,8 +37,6 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
public AbstractOnlineWidgetBlock(OnlineShareWidget widget, OnlineWidgetSelectPane parentPane) {
super(widget);
this.parentPane = parentPane;
JPopupMenu popupMenu = createRightClickPopupMenu();
this.setComponentPopupMenu(popupMenu);
}
protected UILabel initCoverLabel(Image image) {
@ -51,10 +49,12 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
return widget.getUuid();
}
@Override
protected void showPreview(OnlineShareWidget widget) {
parentPane.showPreviewPane(this, widget.getId());
}
@Override
protected void hidePreview() {
parentPane.hidePreviewPane();
}
@ -66,6 +66,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
return getDefaultDisplayImage();
}
@Override
public Image getPreviewImage() {
try {
return ImageIO.read(new URL(UriUtils.encodePath(widget.getPicPath(), EncodeConstants.ENCODING_UTF_8)));
@ -106,10 +107,12 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
super.mouseClicked(e);
if (e.getButton() == MouseEvent.BUTTON3) {
this.parentPane.hidePreviewPane();
GUICoreUtils.showPopupMenu(getComponentPopupMenu(), this, e.getX(), e.getY());
JPopupMenu rightClickPopupMenu = getRightClickPopupMenu();
GUICoreUtils.showPopupMenu(rightClickPopupMenu, this, e.getX(), e.getY());
}
}
@Override
public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true);

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

@ -24,6 +24,7 @@ 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;
@ -32,12 +33,14 @@ 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;
import javax.swing.Action;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Cursor;
@ -135,12 +138,8 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
super.mouseClicked(e);
if (e.getButton() == MouseEvent.BUTTON3 && !isEdit) {
this.parentPane.hidePreviewPane();
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER);
popupMenu.add(new PopupMenuItem(new MoveGroupAction()));
popupMenu.add(new PopupMenuItem(new RemoveAction()));
GUICoreUtils.showPopupMenu(popupMenu, this, e.getX(), e.getY());
JPopupMenu rightClickPopupMenu = getRightClickPopupMenu();
GUICoreUtils.showPopupMenu(rightClickPopupMenu, this, e.getX(), e.getY());
}
}
@ -271,6 +270,18 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
return !WidgetSelectedManager.getInstance().isSelectEmpty();
}
@Override
public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true);
popupMenu.setBackground(UIConstants.DEFAULT_BG_RULER);
popupMenu.add(new PopupMenuItem(new MoveGroupAction()));
popupMenu.add(new PopupMenuItem(new RemoveAction()));
return popupMenu;
}
private class MoveGroupAction extends UpdateAction {
public MoveGroupAction() {
this.putValue(Action.SMALL_ICON, null);

43
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java

@ -63,10 +63,9 @@ import java.util.concurrent.ExecutionException;
* Created by kerry on 2020-10-19
* 商城组件块
*/
public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements PopupMenuListener {
public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
private boolean isMouseEnter = false;
private boolean downloading = false;
private boolean popupMenuVisible = false;
private static final Color COVER_COLOR = Color.decode("#333334");
protected MouseEvent lastPressEvent;
private double process = 0D;
@ -96,7 +95,22 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
@Override
public JPopupMenu createRightClickPopupMenu() {
JPopupMenu popupMenu = super.createRightClickPopupMenu();
popupMenu.addPopupMenuListener(this);
popupMenu.addPopupMenuListener(new PopupMenuListener() {
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
OnlineWidgetBlock.this.repaint();
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
OnlineWidgetBlock.this.repaint();
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
OnlineWidgetBlock.this.repaint();
}
});
return popupMenu;
}
@ -124,7 +138,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY());
if (!popupMenuVisible && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
if (!isRightClickPopupMenuVisible() && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
downLoadWidget();
}
}
@ -281,7 +295,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
return;
}
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!popupMenuVisible && (isMouseEnter || downloading)) {
if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
@ -310,25 +324,6 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
}
}
@Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
this.popupMenuVisible = true;
repaint();
}
@Override
public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {
this.popupMenuVisible = false;
repaint();
}
@Override
public void popupMenuCanceled(PopupMenuEvent e) {
this.popupMenuVisible = false;
repaint();
}
class WidgetDownloadProcess implements com.fr.design.extra.Process<Double> {
@Override

25
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/PreviewWidgetBlock.java

@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
@ -25,12 +26,14 @@ import java.io.Serializable;
public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListener, MouseMotionListener, Serializable {
protected T widget;
private boolean showing = false;
private final JPopupMenu rightClickPopupMenu;
public PreviewWidgetBlock(T widget) {
this.widget = widget;
initPane();
this.addMouseListener(this);
this.addMouseMotionListener(this);
rightClickPopupMenu = this.createRightClickPopupMenu();
}
protected void initPane() {
@ -51,6 +54,18 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
return widget;
}
protected JPopupMenu createRightClickPopupMenu() {
return null;
}
protected JPopupMenu getRightClickPopupMenu() {
return rightClickPopupMenu;
}
protected boolean isRightClickPopupMenuVisible() {
return rightClickPopupMenu != null && rightClickPopupMenu.isVisible();
}
@NotNull
protected abstract Image getCoverImage();
@ -116,10 +131,12 @@ public abstract class PreviewWidgetBlock<T> extends JPanel implements MouseListe
public void mouseMoved(MouseEvent e) {
Dimension dimension = getCoverDimension();
Rectangle containerRec = new Rectangle(0, 0, dimension.width, dimension.height);
if (containerRec.contains(e.getX(), e.getY())) {
this.showPreviewPane();
} else {
this.hidePreviewPane();
if (!isRightClickPopupMenuVisible()) {
if (containerRec.contains(e.getX(), e.getY())) {
this.showPreviewPane();
} else {
this.hidePreviewPane();
}
}
}

Loading…
Cancel
Save