Browse Source

Pull request #7353: REPORT-64811 & REPORT-64738 & REPORT-65049 & REPORT-65059 & REPORT-65060

Merge in DESIGN/design from ~STARRYI/design:release/11.0 to release/11.0

* commit 'ba0d7751751b22a01d7b78fe5ef855eb153e037c':
  REPORT-65072 【主题边框】单元格样式的预览小图中,内部边框线看着比较粗
  REPORT-65060 【视觉验收】模板主题管理
  REPORT-65059 设计器-给多个单元格设置边框,预览时只有一个
  REPORT-65049 【主题边框】悬浮元素的跟随主题单元格样式显示,出现两种样式重叠的效果
  REPORT-64738 设计器在线组件库中可见组件应去重且仅显示兼容当前设计器的组件
  REPORT-64811 保持设计器商城下载reu文件名中的版本信息
bugfix/11.0
starryi 3 years ago
parent
commit
102bf09779
  1. 2
      designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java
  2. 60
      designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java
  3. 1
      designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java
  4. BIN
      designer-base/src/main/resources/com/fr/design/images/transparent_background.png
  5. 5
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java
  6. 2
      designer-form/src/main/java/com/fr/design/mainframe/share/ui/local/LocalWidgetRepoPane.java
  7. 43
      designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java
  8. 5
      designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java
  9. 12
      designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java
  10. 3
      designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

2
designer-base/src/main/java/com/fr/design/cell/CellRectangleStylePreviewPane.java

@ -46,7 +46,7 @@ public class CellRectangleStylePreviewPane extends JPanel {
for (int r = 0; r < ROW_COUNT; r++) {
for (int c = 0; c < COLUMN_COUNT; c++) {
CellStylePreviewPane pane = new CellStylePreviewPane();
CellStylePreviewPane pane = new CellStylePreviewPane(false, false);
TemplateCellElement cellElement = DefaultThemedTemplateCellElementCase.createInstance(c, r);
int flags = CellBorderSourceFlag.INVALID_BORDER_SOURCE;
if (supportInnerBorder) {

60
designer-base/src/main/java/com/fr/design/cell/CellStylePreviewPane.java

@ -30,10 +30,20 @@ import java.util.List;
public class CellStylePreviewPane extends JPanel {
public static final int MINIMUM_HEIGHT = 40;
private static final BufferedImage transparentBackgroundImage = IOUtils.readImage("/com/fr/design/images/transparent_background.png");
private final float transparentBackgroundWidth;
private final float transparentBackgroundHeight;
private String paintText = "Report";
private Style style = Style.DEFAULT_STYLE;
public CellStylePreviewPane() {
private final boolean autoClearCanvas;
private final boolean paintingMosaic;
public CellStylePreviewPane(boolean autoClearCanvas, boolean paintingMosaic) {
this.autoClearCanvas = autoClearCanvas;
this.paintingMosaic = paintingMosaic;
transparentBackgroundWidth = transparentBackgroundImage.getWidth(null);
transparentBackgroundHeight = transparentBackgroundImage.getHeight(null);
setPreferredSize(new Dimension(0, 0));
}
@ -55,15 +65,58 @@ public class CellStylePreviewPane extends JPanel {
@Override
public void paint(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
if (autoClearCanvas) {
g2d.clearRect(0, 0, getWidth(), getHeight());
}
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
if (paintingMosaic) {
paintTransparentBackground(g2d, style);
}
paintCellStyle(g2d, style);
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF);
g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_OFF);
}
private void paintTransparentBackground(Graphics2D g2d, Style style) {
float alpha = computeTransparentBackgroundAlpha(style);
float scaleWidth = 1.0F * getWidth() / transparentBackgroundWidth;
float scaleHeight = 1.0F * getHeight() / transparentBackgroundHeight;
float maxScale = Math.max(scaleWidth, scaleHeight);
if (maxScale <= 1) {
scaleWidth = scaleHeight = 1;
} else {
scaleHeight = scaleWidth = maxScale;
}
Composite oldComposite = g2d.getComposite();
g2d.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, alpha));
g2d.drawImage(transparentBackgroundImage, 0, 0, (int) (transparentBackgroundWidth * scaleWidth), (int) (transparentBackgroundHeight * scaleHeight), null);
g2d.setComposite(oldComposite);
}
private float computeTextColorBrightness(Style style) {
Color fontColor = style.getFRFont().getForeground();
return fontColor.getRed() * 0.299F + fontColor.getGreen() * 0.587F + fontColor.getBlue() * 0.114F;
}
private float computeTransparentBackgroundAlpha(Style style) {
float textBrightness = computeTextColorBrightness(style);
float alpha = 1.0F;
if (textBrightness < 50) {
alpha = 0.2F;
} else if (textBrightness < 160){
alpha = 0.5F;
}
return alpha;
}
private void paintCellStyle(Graphics2D g2d, Style style) {
int resolution = ScreenResolution.getScreenResolution();
@ -80,9 +133,8 @@ public class CellStylePreviewPane extends JPanel {
Style.paintContent(g2d, paintText, style, width, height, resolution);
Style.paintBorder(g2d, style,
width - GraphHelper.getLineStyleSize(style.getBorderRight()) / 2F,
height - GraphHelper.getLineStyleSize(style.getBorderBottom()) / 2F);
g2d.setClip(null);
Style.paintBorder(g2d, style, width, height);
}
@Override

1
designer-base/src/main/java/com/fr/design/mainframe/theme/preview/ecpreview/cell/AbstractPreviewCell.java

@ -40,6 +40,7 @@ public abstract class AbstractPreviewCell extends JComponent {
if (style.getBorderBottom() == Constants.LINE_SLIM || style.getBorderTop() == Constants.LINE_SLIM) {
height -= BORDER_INSET;
}
g2d.setClip(null);
Style.paintBorder(g2d, style, width, height);
}

BIN
designer-base/src/main/resources/com/fr/design/images/transparent_background.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 36 KiB

After

Width:  |  Height:  |  Size: 26 KiB

5
designer-form/src/main/java/com/fr/design/mainframe/share/ui/block/LocalWidgetUpdater.java

@ -13,6 +13,7 @@ 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.bean.OnlineShareWidget;
import com.fr.form.share.group.DefaultShareGroupManager;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StableUtils;
@ -54,7 +55,7 @@ public class LocalWidgetUpdater implements Process<Double> {
return 0 <= processValue && processValue <= 1;
}
public void updateWidget(String remoteLatestWidgetId, UpdateListener updateListener) {
public void updateWidget(OnlineShareWidget remoteLatestWidget, UpdateListener updateListener) {
if (OnlineWidgetRepoPane.getInstance().isShowPackagePanel()) {
ComponentCollector.getInstance().collectDownloadPktNum();
}
@ -77,7 +78,7 @@ public class LocalWidgetUpdater implements Process<Double> {
}
String filePath;
try {
filePath = DownloadUtils.download(remoteLatestWidgetId, widget.getName() + "." + widget.getId(), LocalWidgetUpdater.this);
filePath = DownloadUtils.download(remoteLatestWidget.getId(), remoteLatestWidget.getFileLoca(), LocalWidgetUpdater.this);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
return false;

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

@ -438,7 +438,7 @@ public class LocalWidgetRepoPane extends BasicPane {
LocalWidgetRepoUpdater updater = LocalWidgetRepoUpdater.getInstance();
for (LocalWidgetBlock block: blockList) {
OnlineShareWidget remoteLatestWidget = updater.findLatestRemoteWidget(block.getWidget());
block.getUpdater().updateWidget(remoteLatestWidget.getId(), new LocalWidgetUpdater.UpdateListener() {
block.getUpdater().updateWidget(remoteLatestWidget, new LocalWidgetUpdater.UpdateListener() {
@Override
public void onUpdated(boolean success, String group, String id) {
updateGuard -= 1;

43
designer-form/src/main/java/com/fr/design/mainframe/share/util/DownloadUtils.java

@ -37,6 +37,9 @@ import java.nio.charset.StandardCharsets;
import java.security.KeyFactory;
import java.security.interfaces.RSAPublicKey;
import java.security.spec.X509EncodedKeySpec;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* created by Harrison on 2020/05/27
@ -68,9 +71,9 @@ public class DownloadUtils {
@NotNull
public static String download(String id, String fileName, com.fr.design.extra.Process<Double> process) throws Exception {
CloseableHttpResponse fileRes = getHttpResponse(getReusesUrl(), id);
CloseableHttpResponse fileRes = postDownloadHttpResponse(getReusesUrl(), id);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue());
fileRes = getDownloadHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
String realPath = StableUtils.pathJoin(ProductConstants.getEnvHome(), ShareComponentConstants.PLUGIN_CACHE, ShareComponentConstants.DOWNLOAD_SHARE);
@ -106,9 +109,11 @@ public class DownloadUtils {
public static String downloadPackage(String id, String fileName, CancelCheck cancelCheck) throws Exception {
CloseableHttpResponse fileRes = getHttpResponse(getPackageReusesUrl(), id);
Map<String, String> params = new HashMap<>();
params.put("designerVersion", ProductConstants.RELEASE_VERSION);
CloseableHttpResponse fileRes = postDownloadHttpResponse(getPackageReusesUrl(), id, params);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue());
fileRes = getDownloadHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}
String realPath = StableUtils.pathJoin(ProductConstants.getEnvHome(), ShareComponentConstants.PLUGIN_CACHE, ShareComponentConstants.DOWNLOAD_PACKAGE_SHARE);
String filePath;
@ -145,9 +150,9 @@ public class DownloadUtils {
public static FormTheme downloadThemeFile(String themePath) {
try {
CloseableHttpResponse fileRes = getHttpResponse(themePath);
CloseableHttpResponse fileRes = getDownloadHttpResponse(themePath);
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_MOVED_TEMPORARILY) {
fileRes = getHttpResponse(fileRes.getHeaders("Location")[0].getValue());
fileRes = getDownloadHttpResponse(fileRes.getHeaders("Location")[0].getValue());
}
if (fileRes.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
HttpEntity entity = fileRes.getEntity();
@ -177,21 +182,33 @@ public class DownloadUtils {
return null;
}
private static CloseableHttpResponse getHttpResponse(String url, String id) throws Exception {
private static CloseableHttpResponse postDownloadHttpResponse(String url, String id) throws Exception {
return postDownloadHttpResponse(url, id, new HashMap<>());
}
private static CloseableHttpResponse postDownloadHttpResponse(String url, String id, Map<String, String> params) throws Exception {
//先登录一下。不然可能失败
CloseableHttpClient client = createClient();
FineLoggerFactory.getLogger().info("login fr-market");
FineLoggerFactory.getLogger().info("start download widget {}", id);
HttpUriRequest file = RequestBuilder.post()
RequestBuilder builder = RequestBuilder.post()
.setHeader("User-Agent", "Mozilla/5.0")
.setUri(url).addParameter("id", encrypt(id)).addParameter("userId",
String.valueOf(DesignerEnvManager.getEnvManager().getDesignerLoginUid()))
.build();
return client.execute(file);
.setUri(url)
.addParameter("id", encrypt(id))
.addParameter("userId", String.valueOf(DesignerEnvManager.getEnvManager().getDesignerLoginUid()));
if (params != null) {
Set<String> keys = params.keySet();
for (String key: keys) {
builder.addParameter(key, params.get(key));
}
}
return client.execute(builder.build());
}
private static CloseableHttpResponse getHttpResponse(String url) throws Exception {
private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {
//先登录一下。不然可能失败
CloseableHttpClient client = createClient();
HttpUriRequest file = RequestBuilder.get()

5
designer-form/src/main/java/com/fr/design/mainframe/share/util/OnlineShopUtils.java

@ -14,6 +14,7 @@ import com.fr.general.http.HttpToolbox;
import com.fr.json.JSONArray;
import com.fr.json.JSONObject;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils;
@ -251,7 +252,7 @@ public class OnlineShopUtils {
}
public static OnlineShareWidget[] getPackageWidgets(OnlineShareWidget widgetPackage) {
String plistUrl = getPackageChildrenPath() + widgetPackage.getId();
String plistUrl = getPackageChildrenPath() + widgetPackage.getId() + "?designerVersion="+ ProductConstants.RELEASE_VERSION;
OnlineShareWidget[] widgets = getOnlineShareWidgets(plistUrl);
for (OnlineShareWidget widget : widgets) {
widget.setParentPackage(widgetPackage);
@ -287,7 +288,7 @@ public class OnlineShopUtils {
onlineShareWidgets.add(widget);
}
}
return onlineShareWidgets.toArray(new OnlineShareWidget[onlineShareWidgets.size()]);
return onlineShareWidgets.toArray(new OnlineShareWidget[0]);
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}

12
designer-realize/src/main/java/com/fr/design/actions/cell/BorderAction.java

@ -110,13 +110,17 @@ public class BorderAction extends ElementCaseAction implements ChangeListener {
public boolean update(ElementCasePane<?> elementCasePane) {
resetSelectedElementsStyleToCustom(elementCasePane);
boolean success;
if (oldCellBorderStyle.isNoneBorderStyle()) {
//无边框格式
return BorderUtils.updateCellBorderStyle(elementCasePane, oldCellBorderStyle);
success = BorderUtils.updateCellBorderStyle(elementCasePane, oldCellBorderStyle);
} else {
success = BorderUtils.update(elementCasePane, oldCellBorderStyle);
}
if (success) {
resetSelectedElementsStyleToCustom(elementCasePane);
}
return BorderUtils.update(elementCasePane, oldCellBorderStyle);
return success;
}
@Override

3
designer-realize/src/main/java/com/fr/design/report/ReportStylePane.java

@ -53,6 +53,7 @@ import java.awt.CardLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
@ -78,7 +79,7 @@ public class ReportStylePane extends BasicPane {
setLayout(FRGUIPaneFactory.createBorderLayout());
setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 10));
previewArea = new CellStylePreviewPane();
previewArea = new CellStylePreviewPane(true, true);
followingThemeButtonGroup = new UIButtonGroup<>(FOLLOWING_THEME_STRING_ARRAYS);
followingThemeButtonGroup.setAutoFireStateChanged(false);
customStylePane = new CustomFloatStyleSettingPane();

Loading…
Cancel
Save