Browse Source

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

Merge in DESIGN/design from ~STARRYI/design:REPORT-60434/feature/x to feature/x

* commit '8a7ec74a9add4f204df02bd9316f3d20edf9f2af':
  REPORT-60434 【主题获取】在线组件右键,鼠标移动点击详情时,偶现详细消失
research/11.0
starryi 3 years ago
parent
commit
80022c2981
  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. 17
      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) { public AbstractOnlineWidgetBlock(OnlineShareWidget widget, OnlineWidgetSelectPane parentPane) {
super(widget); super(widget);
this.parentPane = parentPane; this.parentPane = parentPane;
JPopupMenu popupMenu = createRightClickPopupMenu();
this.setComponentPopupMenu(popupMenu);
} }
protected UILabel initCoverLabel(Image image) { protected UILabel initCoverLabel(Image image) {
@ -51,10 +49,12 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
return widget.getUuid(); return widget.getUuid();
} }
@Override
protected void showPreview(OnlineShareWidget widget) { protected void showPreview(OnlineShareWidget widget) {
parentPane.showPreviewPane(this, widget.getId()); parentPane.showPreviewPane(this, widget.getId());
} }
@Override
protected void hidePreview() { protected void hidePreview() {
parentPane.hidePreviewPane(); parentPane.hidePreviewPane();
} }
@ -66,6 +66,7 @@ public abstract class AbstractOnlineWidgetBlock extends PreviewWidgetBlock<Onlin
return getDefaultDisplayImage(); return getDefaultDisplayImage();
} }
@Override
public Image getPreviewImage() { public Image getPreviewImage() {
try { try {
return ImageIO.read(new URL(UriUtils.encodePath(widget.getPicPath(), EncodeConstants.ENCODING_UTF_8))); 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); super.mouseClicked(e);
if (e.getButton() == MouseEvent.BUTTON3) { if (e.getButton() == MouseEvent.BUTTON3) {
this.parentPane.hidePreviewPane(); 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() { public JPopupMenu createRightClickPopupMenu() {
UIPopupMenu popupMenu = new UIPopupMenu(); UIPopupMenu popupMenu = new UIPopupMenu();
popupMenu.setOnlyText(true); 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.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;
@ -32,12 +33,14 @@ 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;
import javax.swing.Action; import javax.swing.Action;
import javax.swing.Icon; import javax.swing.Icon;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Cursor; import java.awt.Cursor;
@ -135,12 +138,8 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
super.mouseClicked(e); super.mouseClicked(e);
if (e.getButton() == MouseEvent.BUTTON3 && !isEdit) { if (e.getButton() == MouseEvent.BUTTON3 && !isEdit) {
this.parentPane.hidePreviewPane(); this.parentPane.hidePreviewPane();
UIPopupMenu popupMenu = new UIPopupMenu(); JPopupMenu rightClickPopupMenu = getRightClickPopupMenu();
popupMenu.setOnlyText(true); GUICoreUtils.showPopupMenu(rightClickPopupMenu, this, e.getX(), e.getY());
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());
} }
} }
@ -271,6 +270,18 @@ public class LocalWidgetBlock extends PreviewWidgetBlock<DefaultSharableWidget>
return !WidgetSelectedManager.getInstance().isSelectEmpty(); 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 { private class MoveGroupAction extends UpdateAction {
public MoveGroupAction() { public MoveGroupAction() {
this.putValue(Action.SMALL_ICON, null); 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 * 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 isMouseEnter = false;
private boolean downloading = false; private boolean downloading = false;
private boolean popupMenuVisible = false;
private static final Color COVER_COLOR = Color.decode("#333334"); private static final Color COVER_COLOR = Color.decode("#333334");
protected MouseEvent lastPressEvent; protected MouseEvent lastPressEvent;
private double process = 0D; private double process = 0D;
@ -96,7 +95,22 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
@Override @Override
public JPopupMenu createRightClickPopupMenu() { public JPopupMenu createRightClickPopupMenu() {
JPopupMenu popupMenu = super.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; return popupMenu;
} }
@ -124,7 +138,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
super.mouseClicked(e); super.mouseClicked(e);
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY()); boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY());
if (!popupMenuVisible && isLeftClickDownloadIcon && !checkWidgetInstalled()) { if (!isRightClickPopupMenuVisible() && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
downLoadWidget(); downLoadWidget();
} }
} }
@ -281,7 +295,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements Popu
return; return;
} }
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层 //如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!popupMenuVisible && (isMouseEnter || downloading)) { if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite(); 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> { class WidgetDownloadProcess implements com.fr.design.extra.Process<Double> {
@Override @Override

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

Loading…
Cancel
Save