Browse Source

REPORT-60601 组件可更新提醒

【问题原因】
1. 处理在线组件不兼容当前设计器的场景
2. 本地组件更新中时不能刷新本地组件列表界面

【改动思路】
同上
feature/x
Starryi 3 years ago
parent
commit
5144ea2216
  1. 91
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  2. 44
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java

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

@ -1,5 +1,6 @@
package com.fr.design.mainframe.share.ui.block;
import com.fr.base.GraphHelper;
import com.fr.base.iofile.attr.SharableAttrMark;
import com.fr.design.DesignerEnvManager;
import com.fr.design.base.mode.DesignModeContext;
@ -30,11 +31,13 @@ import com.fr.form.share.Group;
import com.fr.form.share.utils.ShareUtils;
import com.fr.form.ui.AbstractBorderStyleWidget;
import com.fr.form.ui.Widget;
import com.fr.general.FRFont;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.SwingConstants;
@ -47,6 +50,7 @@ import java.awt.Color;
import java.awt.Composite;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Rectangle;
@ -54,6 +58,8 @@ import java.awt.RenderingHints;
import java.awt.Stroke;
import java.awt.dnd.DnDConstants;
import java.awt.event.MouseEvent;
import java.awt.font.FontRenderContext;
import java.awt.geom.Dimension2D;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@ -73,6 +79,7 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
private static final BufferedImage WIDGET_INSTALLED_ICON = IOUtils.readImage("/com/fr/base/images/share/widget_installed.png");
private static final BufferedImage WIDGET_DOWNLOAD_ICON = IOUtils.readImage("/com/fr/base/images/share/download.png");
private static final BufferedImage WIDGET_DOWNLOADING_ICON = IOUtils.readImage("/com/fr/base/images/share/downloading.png");
private static final Icon incompatibleMarker = IOUtils.readIcon("/com/fr/base/images/share/marker_incompatible.png");
public OnlineWidgetBlock(OnlineShareWidget widget, AbstractOnlineWidgetSelectPane parentPane) {
super(widget, parentPane);
@ -117,6 +124,9 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
@Override
public void mouseEntered(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mouseEntered(e);
this.isMouseEnter = true;
this.repaint();
@ -124,6 +134,9 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
@Override
public void mouseExited(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mouseExited(e);
this.isMouseEnter = false;
this.repaint();
@ -131,12 +144,18 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
@Override
public void mousePressed(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mousePressed(e);
this.lastPressEvent = e;
}
@Override
public void mouseClicked(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mouseClicked(e);
boolean isLeftClickDownloadIcon = e.getButton() != MouseEvent.BUTTON3 && getDownloadIconRec().contains(e.getX(), e.getY());
if (!isRightClickPopupMenuVisible() && isLeftClickDownloadIcon && !checkWidgetInstalled()) {
@ -146,6 +165,9 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
@Override
public void mouseDragged(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mouseDragged(e);
if (DesignModeContext.isAuthorityEditing() || !checkWidgetInstalled()) {
return;
@ -184,6 +206,21 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
}
}
@Override
public void mouseMoved(MouseEvent e) {
if (!getWidget().isCompatibleWithCurrentEnv()) {
return;
}
super.mouseMoved(e);
if (checkWidgetInstalled()) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else if (getDownloadIconRec().contains(e.getX(), e.getY())) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
private void downLoadWidget() {
CarouselStateManger.getInstance().suspend(CarouselStateManger.DOWNLOAD_COMPONENT);
if (OnlineWidgetRepoPane.getInstance().isShowPackagePanel()) {
@ -249,19 +286,6 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
}.execute();
}
@Override
public void mouseMoved(MouseEvent e) {
super.mouseMoved(e);
if (checkWidgetInstalled()) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR));
} else if (getDownloadIconRec().contains(e.getX(), e.getY())) {
this.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
} else {
this.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
}
}
private Rectangle getDownloadIconRec() {
return new Rectangle(ShareComponentConstants.SHARE_THUMB_WIDTH / 2 - 12, ShareComponentConstants.SHARE_BLOCK_HEIGHT / 2 - 16, 24, 24);
}
@ -328,6 +352,47 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
g2d.setColor(Color.WHITE);
g2d.setStroke(oldStroke);
}
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask((Graphics2D) g);
}
}
protected void paintUnusableMask(Graphics2D g2d) {
Color oldColor = g2d.getColor();
Font oldFont = g2d.getFont();
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Dimension coverDim = getCoverDimension();
double canvasX = 0;
double canvasY = 0;
double canvasW = coverDim.getWidth();
double canvasH = coverDim.getHeight();
g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.4F));
GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH - 16);
g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.5F));
GraphHelper.fillRect(g2d, canvasX, canvasH - 16, canvasW, 16);
String tipText = Toolkit.i18nText("Fine-Design_Share_Incompatible_Version_Tip");
Font tipFont = FRFont.getInstance().deriveFont(8F);
FontRenderContext frc = g2d.getFontRenderContext();
double tipTextWidth = GraphHelper.stringWidth(tipText, tipFont, frc);
Dimension2D dim = GraphHelper.stringDimensionWithRotation(tipText, tipFont, 0, frc);
double tipTextHeight = dim.getHeight();
g2d.setColor(Color.WHITE);
g2d.setFont(tipFont);
GraphHelper.drawString(g2d, tipText, canvasX + (canvasW - tipTextWidth) / 2.0F, canvasY + canvasH - (16 - tipTextHeight) / 2.0F);
int markerX = (int) (canvasX + (canvasW - incompatibleMarker.getIconWidth()) / 2);
int markerY = (int) (canvasY + (canvasH - incompatibleMarker.getIconHeight()) / 2);
incompatibleMarker.paintIcon(this, g2d, markerX, markerY);
g2d.setColor(oldColor);
g2d.setFont(oldFont);
}
@Override

44
designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java

@ -223,10 +223,16 @@ public class LocalWidgetRepoPane extends BasicPane {
}
public void refreshAllGroupPane() {
if (isUpdating()) {
return;
}
refreshAllGroupPane(GroupPane.GroupCreateStrategy.DEFAULT);
}
public void refreshAllGroupPane(GroupPane.GroupCreateStrategy createStrategy) {
if (isUpdating()) {
return;
}
editable = false;
groupPaneMap.clear();
if (groupsScrollPane != null) {
@ -249,21 +255,33 @@ public class LocalWidgetRepoPane extends BasicPane {
}
public void refreshPane() {
if (isUpdating()) {
return;
}
managePane.switchPanel(false);
switchPane(LocalPaneStatus.LOADING);
doRefresh();
}
public void switch2InstallingPane() {
if (isUpdating()) {
return;
}
switchPane(LocalPaneStatus.INSTALLING);
}
public void refreshShowPanel(boolean isEdit) {
if (isUpdating()) {
return;
}
this.editable = isEdit;
refreshShowPanel();
}
public void refreshShowPanel() {
if (isUpdating()) {
return;
}
for (GroupPane groupPane : groupPaneMap.values()) {
groupPane.refreshShowPanel();
}
@ -271,6 +289,9 @@ public class LocalWidgetRepoPane extends BasicPane {
}
public void refreshShowPanel(Group group) {
if (isUpdating()) {
return;
}
if (groupPaneMap.containsKey(group.getGroupName())) {
groupPaneMap.get(group.getGroupName()).refreshShowPanel();
}
@ -286,12 +307,18 @@ public class LocalWidgetRepoPane extends BasicPane {
}
public void removeGroup(String groupName) {
if (isUpdating()) {
return;
}
JPanel jPanel = groupPaneMap.remove(groupName);
groupsPane.remove(jPanel);
switchPane();
}
public void addGroup(Group group) {
if (isUpdating()) {
return;
}
GroupPane groupPane = GroupPane.GroupCreateStrategy.DEFAULT.creteGroupPane(group);
groupPaneMap.put(group.getGroupName(), groupPane);
groupsPane.add(groupPane);
@ -383,7 +410,6 @@ public class LocalWidgetRepoPane extends BasicPane {
return;
}
updateGuard = 0;
toolbarPane.reset();
managePane.switchPanel(false);
switchPane(LocalPaneStatus.NORMAL);
@ -394,6 +420,8 @@ public class LocalWidgetRepoPane extends BasicPane {
return;
}
updateGuard = blockList.size();
updateTipPane.setVisible(false);
updateProgressPane.updateProgress(0.0F);
updateProgressPane.setVisible(true);
@ -404,10 +432,9 @@ public class LocalWidgetRepoPane extends BasicPane {
block.getUpdater().updateWidget(remoteLatestWidget.getId(), new LocalWidgetUpdater.UpdateListener() {
@Override
public void onUpdated(boolean success, String group, String id) {
updateGuard += 1;
updateProgressPane.updateProgress(1.0F * updateGuard / blockList.size());
if (updateGuard == blockList.size()) {
updateGuard = 0;
updateGuard -= 1;
updateProgressPane.updateProgress(1.0F - 1.0F * updateGuard / blockList.size());
if (updateGuard == 0) {
updater.clearUpdate();
updateProgressPane.setVisible(false);
refreshAllGroupPane();
@ -422,6 +449,9 @@ public class LocalWidgetRepoPane extends BasicPane {
* 切换为要显示的面板
*/
private void switchPane() {
if (isUpdating()) {
return;
}
switchPane(getStatus());
}
@ -457,6 +487,10 @@ public class LocalWidgetRepoPane extends BasicPane {
return groups.length == 1 && groups[0].getAllBindInfoList().length == 0;
}
private boolean isUpdating() {
return updateGuard > 0;
}
private List<LocalWidgetBlock> getUpdatableBlocks() {
List<LocalWidgetBlock> blockList = new ArrayList<>();

Loading…
Cancel
Save