diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java index e08c317d8..72eb35d00 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetBlock.java @@ -1,5 +1,6 @@ package com.fr.design.mainframe.share.ui.block; +import com.fr.base.FRContext; import com.fr.base.GraphHelper; import com.fr.base.iofile.attr.SharableAttrMark; import com.fr.design.base.mode.DesignModeContext; @@ -38,8 +39,10 @@ import org.jetbrains.annotations.Nullable; import javax.swing.Action; import javax.swing.Icon; +import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JPopupMenu; +import javax.swing.UIManager; import java.awt.AlphaComposite; import java.awt.BorderLayout; import java.awt.Color; @@ -57,6 +60,7 @@ import java.awt.dnd.DnDConstants; import java.awt.event.ActionEvent; import java.awt.event.MouseEvent; import java.awt.font.FontRenderContext; +import java.awt.font.LineMetrics; import java.awt.geom.Dimension2D; import java.awt.image.BufferedImage; import java.util.UUID; @@ -224,7 +228,10 @@ public class LocalWidgetBlock extends PreviewWidgetBlock } if (!widget.isCompatibleWithCurrentEnv()) { FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), - Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Incompatible_Component_Tip") + Toolkit.i18nText("Fine-Design_Share_Drag_And_Make_Incompatible_Component_Tip"), + Toolkit.i18nText("Fine-Design_Basic_Error"), + JOptionPane.ERROR_MESSAGE, + UIManager.getIcon("OptionPane.errorIcon") ); return; } @@ -293,17 +300,17 @@ public class LocalWidgetBlock extends PreviewWidgetBlock double canvasH = coverDim.getHeight(); g2d.setColor(new Color(0.0F, 0.0F, 0.0F, 0.4F)); - GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH - 16); + GraphHelper.fillRect(g2d, canvasX, canvasY, canvasW, canvasH); 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); + Font tipFont = FRContext.getDefaultValues().getFRFont().deriveFont(8.0F); FontRenderContext frc = g2d.getFontRenderContext(); double tipTextWidth = GraphHelper.stringWidth(tipText, tipFont, frc); - Dimension2D dim = GraphHelper.stringDimensionWithRotation(tipText, tipFont, 0, frc); - double tipTextHeight = dim.getHeight(); + LineMetrics metrics = tipFont.getLineMetrics(tipText, frc); + double tipTextHeight = metrics.getHeight(); g2d.setColor(Color.WHITE); g2d.setFont(tipFont); GraphHelper.drawString(g2d, tipText, canvasX + (canvasW - tipTextWidth) / 2.0F, canvasY + canvasH - (16 - tipTextHeight) / 2.0F); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java index 083df1b4e..68a3123f7 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java @@ -11,6 +11,9 @@ import com.fr.design.mainframe.share.util.ShareComponentUtils; import com.fr.design.ui.util.UIUtil; import com.fr.form.share.DefaultSharableWidget; import com.fr.form.share.Group; +import com.fr.form.share.GroupManege; +import com.fr.form.share.SharableWidgetProvider; +import com.fr.form.share.group.DefaultShareGroupManager; import com.fr.log.FineLoggerFactory; import com.fr.stable.StableUtils; import com.fr.stable.StringUtils; @@ -20,7 +23,6 @@ import java.awt.Component; import java.awt.Container; import java.io.File; import java.io.IOException; -import java.util.concurrent.ExecutionException; /** * @author Starryi @@ -103,9 +105,12 @@ public class LocalWidgetUpdater implements Process { boolean success = false; try { success = get(); - } catch (InterruptedException | ExecutionException e) { + } catch (Exception e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); } + if (success) { + resetWidgetOfBlock(); + } if (updateListener != null) { updateListener.onUpdated(success, getGroup().getGroupName(), widget.getId()); } @@ -115,19 +120,38 @@ public class LocalWidgetUpdater implements Process { worker.execute(); } + private void resetWidgetOfBlock() { + GroupManege groupManege = DefaultShareGroupManager.getInstance(); + Group group = groupManege.getGroup(getGroup().getGroupName()); + if (group != null) { + String id = widgetBlock.getWidgetUuid(); + if (StringUtils.isNotEmpty(id)) { + SharableWidgetProvider localLatestWidget = group.getElCaseBindInfoById(widgetBlock.getWidgetUuid()); + if (localLatestWidget instanceof DefaultSharableWidget) { + widgetBlock.widget = (DefaultSharableWidget) localLatestWidget; + repaintBlockAndOverlay(); + } + } + } + } + public void cancelUpdate() { - if (worker.isDone() || worker.isCancelled()) { - return; + if (worker != null && !worker.isDone()) { + worker.cancel(true); + worker = null; } - worker.cancel(true); + process(-1.0); } @Override public void process(Double processValue) { this.processValue = processValue; + repaintBlockAndOverlay(); + } - UIUtil.invokeAndWaitIfNeeded(new Runnable() { + private void repaintBlockAndOverlay() { + UIUtil.invokeLaterIfNeeded(new Runnable() { @Override public void run() { Container absoluteLayoutParent = getAbsoluteLayoutAncestor(widgetBlock); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java index 67326c853..c8c7b54ea 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java @@ -46,7 +46,7 @@ public class OnlineShopUtils { } private static String getWidgetReusePath() { - return getReuInfoPath(); + return StableUtils.pathJoin(getReuInfoPath(), "all/detail/"); } private static String getPackageChildrenPath() {