|
|
|
@ -35,8 +35,11 @@ import com.fr.stable.StableUtils;
|
|
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
|
|
|
|
|
|
import javax.swing.JPanel; |
|
|
|
|
import javax.swing.JPopupMenu; |
|
|
|
|
import javax.swing.SwingConstants; |
|
|
|
|
import javax.swing.SwingWorker; |
|
|
|
|
import javax.swing.event.PopupMenuEvent; |
|
|
|
|
import javax.swing.event.PopupMenuListener; |
|
|
|
|
import java.awt.AlphaComposite; |
|
|
|
|
import java.awt.BorderLayout; |
|
|
|
|
import java.awt.Color; |
|
|
|
@ -60,9 +63,10 @@ import java.util.concurrent.ExecutionException;
|
|
|
|
|
* Created by kerry on 2020-10-19 |
|
|
|
|
* 商城组件块 |
|
|
|
|
*/ |
|
|
|
|
public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock { |
|
|
|
|
public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock implements PopupMenuListener { |
|
|
|
|
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; |
|
|
|
@ -89,6 +93,13 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
|
|
|
|
|
return southPane; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public JPopupMenu createRightClickPopupMenu() { |
|
|
|
|
JPopupMenu popupMenu = super.createRightClickPopupMenu(); |
|
|
|
|
popupMenu.addPopupMenuListener(this); |
|
|
|
|
return popupMenu; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void mouseEntered(MouseEvent e) { |
|
|
|
|
super.mouseEntered(e); |
|
|
|
@ -113,7 +124,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
|
|
|
|
|
public void mouseClicked(MouseEvent e) { |
|
|
|
|
super.mouseClicked(e); |
|
|
|
|
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY()); |
|
|
|
|
if (isLeftClickDownloadIcon && !checkWidgetInstalled()) { |
|
|
|
|
if (!popupMenuVisible && isLeftClickDownloadIcon && !checkWidgetInstalled()) { |
|
|
|
|
downLoadWidget(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -270,7 +281,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
|
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
|
|
|
|
|
if (isMouseEnter || downloading) { |
|
|
|
|
if (!popupMenuVisible && (isMouseEnter || downloading)) { |
|
|
|
|
Graphics2D g2d = (Graphics2D) g; |
|
|
|
|
Composite oldComposite = g2d.getComposite(); |
|
|
|
|
//画白色的编辑层
|
|
|
|
@ -299,6 +310,24 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@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> { |
|
|
|
|
|
|
|
|
|