Browse Source

REPORT-66306 组件包下载面板无遮罩阴影

【问题原因】
swing中两个组件上下层叠时,重绘底层组件,会将其内容会知道上方,遮挡上层组件,
因此也需要手动重新绘制上层组件。

【改动思路】
主动调用下阴影层的重绘方法
bugfix/11.0
Starryi 3 years ago
parent
commit
a8572a9e0c
  1. 67
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/OnlineWidgetBlock.java
  2. 8
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineDownloadPackagePane.java
  3. 11
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java
  4. 15
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java

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

@ -337,41 +337,42 @@ public class OnlineWidgetBlock extends AbstractOnlineWidgetBlock {
null,
this
);
return;
}
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 20 / 100.0F));
g2d.setColor(COVER_COLOR);
g2d.fillRect(x, y, w, h);
g2d.setComposite(oldComposite);
//画编辑按钮图标
BufferedImage image = (process > 0 || downloading) ? WIDGET_DOWNLOADING_ICON : WIDGET_DOWNLOAD_ICON;
g2d.drawImage(
image,
(x + w / 2 - 12),
(y + h / 2 - 16),
image.getWidth(),
image.getHeight(),
null,
this
);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(Color.decode("#419BF9"));
double arcAngle = downloading ? (36 + 360 * 0.9 * process) : 0.0;
g2d.drawArc(x + w / 2 - 12, y + h / 2 - 16, 24, 24, 90, -(int) arcAngle);
g2d.setColor(Color.WHITE);
g2d.setStroke(oldStroke);
}
} else {
//如果鼠标移动到布局内且布局不可编辑,画出编辑蒙层
if (!isRightClickPopupMenuVisible() && (isMouseEnter || downloading)) {
Graphics2D g2d = (Graphics2D) g;
Composite oldComposite = g2d.getComposite();
//画白色的编辑层
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 20 / 100.0F));
g2d.setColor(COVER_COLOR);
g2d.fillRect(x, y, w, h);
g2d.setComposite(oldComposite);
//画编辑按钮图标
BufferedImage image = (process > 0 || downloading) ? WIDGET_DOWNLOADING_ICON : WIDGET_DOWNLOAD_ICON;
g2d.drawImage(
image,
(x + w / 2 - 12),
(y + h / 2 - 16),
image.getWidth(),
image.getHeight(),
null,
this
);
Stroke oldStroke = g2d.getStroke();
g2d.setStroke(XCreatorConstants.STROKE);
g2d.setColor(Color.decode("#419BF9"));
double arcAngle = downloading ? (36 + 360 * 0.9 * process) : 0.0;
g2d.drawArc(x + w / 2 - 12, y + h / 2 - 16, 24, 24, 90, -(int) arcAngle);
g2d.setColor(Color.WHITE);
g2d.setStroke(oldStroke);
}
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask((Graphics2D) g);
boolean isUnusable = !getWidget().isCompatibleWithCurrentEnv();
if (isUnusable) {
paintUnusableMask((Graphics2D) g);
}
}
if (this.parentPane != null) {
this.parentPane.refreshShowPaneUI();
}

8
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineDownloadPackagePane.java

@ -256,4 +256,12 @@ public class OnlineDownloadPackagePane extends OnlineWidgetSelectPane {
}
}
}
@Override
public void refreshShowPaneUI() {
if (downloadProgressPane != null && downloadProgressPane.isShowing()) {
downloadProgressPane.invalidate();
downloadProgressPane.repaint();
}
}
}

11
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/OnlineWidgetTabPane.java

@ -16,6 +16,7 @@ import com.fr.form.share.bean.OnlineShareWidget;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JPanel;
import javax.swing.plaf.basic.BasicButtonUI;
import java.awt.BorderLayout;
@ -44,6 +45,7 @@ public class OnlineWidgetTabPane extends JPanel {
private boolean packagePaneCreated = false;
private final List<TabChangeListener> tabChangeListeners;
private OnlineEmbedFilterShowPane embedFilterShowPane;
private OnlineWidgetPackagesShowPane widgetPackagesShowPane;
public OnlineWidgetTabPane(OnlineShareWidget[] sharableWidgets, OnlineShareWidget[] sharableWidgetPackage) {
tabChangeListeners = new ArrayList<>();
@ -70,7 +72,8 @@ public class OnlineWidgetTabPane extends JPanel {
ComponentCollector.getInstance().collectCmpPktClick();
//延迟组件包面板的初始化,防止组件面板里组件和缩略图和组件包面板里组件的缩略图一起加载
if (!packagePaneCreated) {
centerPane.add(new OnlineWidgetPackagesShowPane(sharableWidgetPackages), COMPONENT_PACKAGE);
widgetPackagesShowPane = new OnlineWidgetPackagesShowPane(sharableWidgetPackages);
centerPane.add(widgetPackagesShowPane, COMPONENT_PACKAGE);
packagePaneCreated = true;
}
cardLayout.show(centerPane, COMPONENT_PACKAGE);
@ -89,6 +92,8 @@ public class OnlineWidgetTabPane extends JPanel {
this.add(centerPane, BorderLayout.CENTER);
}
private JPanel createMiniShopEntryPane() {
JPanel container = FRGUIPaneFactory.createBorderLayout_S_Pane();
container.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));
@ -136,6 +141,10 @@ public class OnlineWidgetTabPane extends JPanel {
if (embedFilterShowPane != null) {
this.embedFilterShowPane.refreshUI();
}
if (headGroup.getSelectedIndex() == COMPONENT_PACKAGE_TAB_INDEX && widgetPackagesShowPane != null) {
widgetPackagesShowPane.refreshShowPaneUI();
}
}

15
designer-form/src/main/java/com/fr/design/mainframe/share/ui/online/widgetpackage/OnlineWidgetPackagesShowPane.java

@ -48,6 +48,7 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
private JPanel detailPane;
private String currentPackageId;
private OnlineWidgetSelectPane onlineWidgetSelectPane;
private OnlineDownloadPackagePane onlineDownloadPackagePane;
private UILabel downloadLabel;
private final Map<String, OnlineWidgetSelectPane> cachePanelMap = new HashMap<>();
@ -109,15 +110,15 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
private void downLoadPackage() {
downloadLabel.setVisible(false);
detailPane.removeAll();
OnlineDownloadPackagePane widgetSelectPane = new OnlineDownloadPackagePane(this, onlineWidgetSelectPane.getSharableWidgetProviders(), 50);
detailPane.add(widgetSelectPane, BorderLayout.CENTER);
onlineDownloadPackagePane = new OnlineDownloadPackagePane(this, onlineWidgetSelectPane.getSharableWidgetProviders(), 50);
detailPane.add(onlineDownloadPackagePane, BorderLayout.CENTER);
cardLayout.show(centerPane, WIDGET_DETAIL);
cachePanelMap.put(currentPackageId, widgetSelectPane);
cachePanelMap.put(currentPackageId, onlineDownloadPackagePane);
for (OnlineShareWidget onlineShareWidget : getSharableWidgetProviders()) {
if (StringUtils.equals(onlineShareWidget.getId(), currentPackageId)) {
widgetSelectPane.downloadWidget(onlineShareWidget);
onlineDownloadPackagePane.downloadWidget(onlineShareWidget);
break;
}
}
@ -193,4 +194,10 @@ public class OnlineWidgetPackagesShowPane extends AbstractOnlineWidgetShowPane {
protected FilterPane createFilterPane() {
return FilterPane.createOnlinePackageFilterPane();
}
public void refreshShowPaneUI() {
if (onlineDownloadPackagePane != null && onlineDownloadPackagePane.isShowing()) {
onlineDownloadPackagePane.refreshShowPaneUI();
}
}
}

Loading…
Cancel
Save