Browse Source

Merge pull request #9910 in DESIGN/design from release/11.0 to bugfix/11.0

* commit '3460ccc05ae8170ea597fd91be1c9c6e17103466':
  REPORT-79096【运营产品化二期】交互问题集合二 REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则
  REPORT-79096【运营产品化二期】交互问题集合二 REPORT-79341【运营产品化二期】立即使用下载的模板名称目前是开头加了(1),是否可按浏览器规则 1、改ui 2、改文件重名规则
  改一下写法
  REPORT-79492 复制多张模板,删除一部分,触发粘贴后没有定位到粘贴的位置
  REPORT-79456 【运营产品化二期】远程设计下 立即使用下载不成功 远程设计获取的下载路径是个url,不可用 改为下载到桌面
bugfix/11.0
superman 2 years ago
parent
commit
6efa8f65b8
  1. 7
      designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java
  2. 12
      designer-base/src/main/java/com/fr/design/file/FileOperationHelper.java
  3. 13
      designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java
  4. 23
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java
  5. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java
  6. 10
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java
  7. 1
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java
  8. 30
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java
  9. 6
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java
  10. 9
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  11. 40
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

7
designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java

@ -215,7 +215,7 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
WARNING_MESSAGE);
return;
}
doPaste(targetDir, pasteNodes);
doPaste(targetDir, treeNodeList);
}
/**
@ -256,7 +256,10 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
for (ExpandMutableTreeNode node : pasteNodes) {
if (node.getUserObject() instanceof FileNode) {
FileNode fileNode = (FileNode) node.getUserObject();
targetFile = FileOperationHelper.getInstance().copyFile(fileNode, targetDir);
String newTargetFile = FileOperationHelper.getInstance().copyFile(fileNode, targetDir);
if (StringUtils.isNotEmpty(newTargetFile)) {
targetFile = newTargetFile;
}
FineLoggerFactory.getLogger().debug("Template: {} paste to {} success.", fileNode.getEnvPath(), targetDir);
}
}

12
designer-base/src/main/java/com/fr/design/file/FileOperationHelper.java

@ -119,12 +119,20 @@ public class FileOperationHelper {
}
private String copyFile(FileNode sourceFile, String targetDir, boolean withCopyVcs) {
String sourcePath = sourceFile.getEnvPath();
if (!TemplateResourceManager.getResource().exist(sourcePath)) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Source_File_Not_Exist", sourcePath),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE);
return StringUtils.EMPTY;
}
String name = getNoRepeatedName4Paste(targetDir, sourceFile.getName());
String targetFile = StableUtils.pathJoin(targetDir, name);
if (sourceFile.isDirectory()) {
copyDir(sourceFile.getEnvPath(), targetFile, withCopyVcs);
copyDir(sourcePath, targetFile, withCopyVcs);
} else {
copyFile(sourceFile.getEnvPath(), targetFile, withCopyVcs);
copyFile(sourcePath, targetFile, withCopyVcs);
}
return targetFile;
}

13
designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java

@ -60,6 +60,19 @@ public class LinkStrUtils {
return style.toString();
}
public static String generateStyle(Font font, Color fontColor) {
// 构建相同风格样式
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;");
style.append("color:rgb(").append(fontColor.getRed()).append(",").append(fontColor.getGreen()).append(",").append(fontColor.getBlue()).append(");");
return style.toString();
}
public static String generateDefaultStyle() {
return generateStyle(LABEL.getBackground(), LABEL.getFont(), LABEL.getForeground());

23
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/action/StartUseAction.java

@ -54,28 +54,33 @@ public class StartUseAction implements ActionListener {
}.execute();
}
/**
* 打开模板并打开文件目录
* */
void open(String fileName) throws IOException {
if (Strings.isEmpty(fileName)) {
return;
}
// 打开模板
openInDesigner(fileName);
// 打开系统文件夹
File parentDir = new File(fileName).getParentFile();
Desktop.getDesktop().open(parentDir);
}
void openInDesigner(String fileName) {
File fileNeedOpen = new File(fileName);
if (fileName.endsWith(FineMarketConstants.ZIP)) {
File[] files = fileNeedOpen.getParentFile().listFiles();
fileNeedOpen = getFirstCptOrFrm(files);
} else if (fileName.endsWith(FineMarketConstants.RAR)) {
// rar直接打开系统文件夹
File parentDir = new File(fileName).getParentFile();
Desktop.getDesktop().open(parentDir);
// rar资源没有解压,所以不用打开模板
return;
}
openInDesigner(fileNeedOpen);
}
void openInDesigner(File file) {
// 刷新目录
DesignerFrameFileDealerPane.getInstance().refresh();
// 打开模板
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file));
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(fileNeedOpen));
}

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/RecommendSearchPane.java

@ -27,27 +27,27 @@ public class RecommendSearchPane extends TemplateResourcePanel {
this.setBorder(BorderFactory.createLineBorder(BORDER_WHITE, 1));
this.add(getNorthPane(), BorderLayout.NORTH);
this.add(getSouthPane(), BorderLayout.SOUTH);
this.add(getCenterPane(), BorderLayout.CENTER);
}
private void initComponent() {
createNorthPane();
createSouthPane();
createCenterPane();
}
private void createSouthPane() {
setSouthPane(new JPanel(new FlowLayout(FlowLayout.LEFT)));
JPanel southPane = getSouthPane();
southPane.setBackground(Color.WHITE);
private void createCenterPane() {
setCenterPane(new JPanel(new FlowLayout(FlowLayout.LEFT)));
JPanel centerPane = getCenterPane();
centerPane.setBackground(Color.WHITE);
JLabel recommend = new JLabel(Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Resource_Recommend_For_You"));
southPane.add(recommend);
centerPane.add(recommend);
List<String> searchKeys = getTemplateResource().getRecommendSearchKey();
for (String key : searchKeys) {
JLabel keyLabel = new SearchKeyLabel(key);
southPane.add(keyLabel);
centerPane.add(keyLabel);
}
}

10
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourceImagePanel.java

@ -2,11 +2,15 @@ package com.fr.design.mainframe.alphafine.component;
import com.fr.base.GraphHelper;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.utils.DesignUtils;
import com.fr.general.FRFont;
import com.fr.third.jodd.util.StringUtil;
import javax.swing.JPanel;
import java.awt.AlphaComposite;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Image;
@ -17,7 +21,9 @@ public class TemplateResourceImagePanel extends JPanel {
private static final int BACKGROUND_HEIGHT = 20;
private static final Color BACKGROUND_COLOR = new Color(116, 181, 249);
private static final Color BACKGROUND_COLOR = new Color(0x419BF9);
private static final Font TAG_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color COVER_COLOR = new Color(116, 181, 249, 26);
@ -56,10 +62,12 @@ public class TemplateResourceImagePanel extends JPanel {
String tagName = templateResource.getType().getName();
if (!StringUtil.isEmpty(tagName)) {
g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP, .8f));
g2.setColor(BACKGROUND_COLOR);
g2.fillRect(0, getHeight() - BACKGROUND_HEIGHT, getWidth(), BACKGROUND_HEIGHT);
g2.setColor(Color.WHITE);
int x = (getWidth() - GraphHelper.getWidth(tagName, g2.getFont())) / 2;
g2.setFont(TAG_FONT);
g2.drawString(tagName, x, getHeight() - 5);
}
g2.setColor(defaultColor);

1
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePageGridPane.java

@ -126,6 +126,7 @@ public class TemplateResourcePageGridPane extends JPanel {
this.add(pageButtonPane, BorderLayout.SOUTH);
}
this.setBackground(Color.WHITE);
this.setBorder(BorderFactory.createEmptyBorder());
}
private void initComponents() {

30
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/TemplateResourcePanel.java

@ -4,6 +4,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.model.TemplateResource;
import com.fr.design.mainframe.alphafine.preview.TemplateShopPane;
import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.log.FineLoggerFactory;
import javax.swing.BorderFactory;
@ -12,6 +13,7 @@ import javax.swing.JPanel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
@ -19,11 +21,13 @@ import java.awt.event.MouseEvent;
public class TemplateResourcePanel extends JPanel {
private JPanel northPane;
private JPanel southPane;
private JPanel centerPane;
private TemplateResource templateResource;
private static final Color PANEL_BORDER_COLOR = new Color(0xe8e8e9);
private static final Color DEMO_LABEL_FOREGROUND = new Color(0x419bf9);
private static final Font RESOURCE_NAME_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color RESOURCE_NAME_COLOR = new Color(0x5c5c5d);
protected TemplateResourcePanel() {
@ -35,7 +39,7 @@ public class TemplateResourcePanel extends JPanel {
this.setLayout(new BorderLayout());
this.setBorder(BorderFactory.createLineBorder(PANEL_BORDER_COLOR, 1));
this.add(northPane, BorderLayout.NORTH);
this.add(southPane, BorderLayout.SOUTH);
this.add(centerPane, BorderLayout.CENTER);
addAction();
}
@ -60,8 +64,8 @@ public class TemplateResourcePanel extends JPanel {
public JPanel getNorthPane() {
return northPane;
}
public JPanel getSouthPane() {
return southPane;
public JPanel getCenterPane() {
return centerPane;
}
public TemplateResource getTemplateResource() {
return templateResource;
@ -71,8 +75,8 @@ public class TemplateResourcePanel extends JPanel {
this.northPane = northPane;
}
public void setSouthPane(JPanel southPane) {
this.southPane = southPane;
public void setCenterPane(JPanel centerPane) {
this.centerPane = centerPane;
}
public void setTemplateResource(TemplateResource templateResource) {
@ -81,15 +85,17 @@ public class TemplateResourcePanel extends JPanel {
private void initComponent() {
createNorthPane();
createSouthPane();
createCenterPane();
}
protected void createNorthPane() {
northPane = new TemplateResourceImagePanel(templateResource);
}
private void createSouthPane() {
private void createCenterPane() {
JLabel nameLabel = new JLabel(templateResource.getName());
nameLabel.setFont(RESOURCE_NAME_FONT);
nameLabel.setForeground(RESOURCE_NAME_COLOR);
nameLabel.setBackground(Color.WHITE);
nameLabel.setBorder(BorderFactory.createEmptyBorder());
@ -109,10 +115,10 @@ public class TemplateResourcePanel extends JPanel {
});
}
southPane = new JPanel(new BorderLayout());
southPane.setBackground(Color.WHITE);
southPane.add(nameLabel, BorderLayout.WEST);
southPane.add(demoLabel, BorderLayout.EAST);
centerPane = new JPanel(new BorderLayout());
centerPane.setBackground(Color.WHITE);
centerPane.add(nameLabel, BorderLayout.WEST);
centerPane.add(demoLabel, BorderLayout.EAST);
}
@Override

6
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/download/FineMarketDownloadManager.java

@ -13,9 +13,9 @@ import com.fr.design.mainframe.alphafine.search.helper.FineMarketClientHelper;
import com.fr.design.mainframe.toast.SimpleToast;
import com.fr.log.FineLoggerFactory;
import com.fr.third.jodd.io.ZipUtil;
import com.fr.workspace.WorkContext;
import javax.swing.SwingUtilities;
import javax.swing.filechooser.FileSystemView;
import java.awt.Window;
import java.io.File;
import java.io.IOException;
@ -57,8 +57,8 @@ public class FineMarketDownloadManager {
}
private String install(TemplateResource resource, Window parentWindow) {
// 获取报表录作为下载位置
String workDir = WorkContext.getCurrent().getPath() + FineMarketConstants.REPORTLETS;
// 默认下载到桌面
String workDir = FileSystemView.getFileSystemView().getHomeDirectory().getPath();
File destDir = new File(workDir);
DownloadProcess downloadProcess = new DownloadProcess(parentWindow);

9
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java

@ -9,6 +9,7 @@ import com.fr.design.mainframe.alphafine.action.StartUseAction;
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel;
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail;
import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.LinkStrUtils;
import com.fr.stable.StringUtils;
@ -20,6 +21,7 @@ import javax.swing.SwingUtilities;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
@ -66,8 +68,10 @@ public class TemplateResourceDetailPane extends JPanel {
private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c);
private static final Color MORE_INFO_LINK = new Color(0x419bf9);
private static final String HTML_FORMAT = "<html><body style=\"font-size: 12pt\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><body style=\"font-size: 12pt\"><h3>" + DETAIL_INFO + "</h3>%s</body></html>";
private static final Font HTML_FONT = DesignUtils.getDefaultGUIFont().applySize(12);
private static final Color HTML_COLOR = new Color(0x5c5c5d);
private static final String HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;"+ LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) +"\">%s</body></html>";
private static final String DETAIL_INFO_HTML_FORMAT = "<html><style>a {color: #419BF9;text-decoration:none;}</style><body style=\"line-height: 20px;" + LinkStrUtils.generateStyle(HTML_FONT, HTML_COLOR) + "\"><p>" + DETAIL_INFO + "</p>%s</body></html>";
private static final String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>";
@ -208,6 +212,7 @@ public class TemplateResourceDetailPane extends JPanel {
content.setBackground(INFO_PANE_BACKGROUND);
content.setForeground(INFO_PANE_FOREGROUND);
infoScrollPane = new UIScrollPane(content);
infoScrollPane.setForeground(INFO_PANE_FOREGROUND);
infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT));
infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}

40
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/helper/FineMarketClientHelper.java

@ -61,6 +61,8 @@ public class FineMarketClientHelper {
public static final String TAGS_ITEMS = "items";
public static final String TAG_NAME = "name";
public static final String TAG_ID = "id";
private static final String FILENAME_FORMAT = ".+?(.zip|.rar|.cpt|.frm)";
private static final Pattern FILENAME_PATTERN = Pattern.compile(FILENAME_FORMAT);
// 缓存下所有tag标签
private Map<String, String> tags;
@ -161,17 +163,41 @@ public class FineMarketClientHelper {
finalDir.mkdir();
}
// 获取文件名(含后缀)
fileName = resource.getFileName();
fileName = rename(fileName, finalDir);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
fileName = UUID.randomUUID() + fileName;
File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return dest;
}
/**
* 处理下文件名比如重复下载需要处理重名的情况
* */
String rename(String fileName, File parentDir) throws Exception {
if (!FILENAME_PATTERN.matcher(fileName).matches()) {
throw new Exception("fileName format error: " + fileName);
}
// 获取文件名(含后缀)
String prefix = fileName.substring(0, fileName.length() - 4);
String suffix = fileName.substring(fileName.length() - 4);
File file = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(parentDir), fileName));
// 处理重复文件名
if (file.exists()) {
String fileNameFormat = prefix + "(%d)" + suffix;
Pattern pattern = Pattern.compile(prefix + "\\((\\d)\\)" + suffix);
int cnt = 0;
File[] files = finalDir.listFiles();
File[] files = parentDir.listFiles();
for (File f : files) {
Matcher matcher = pattern.matcher(f.getName());
if (matcher.find()) {
@ -180,15 +206,9 @@ public class FineMarketClientHelper {
}
cnt++;
fileName = String.format(fileNameFormat, cnt);
File destFile = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return destFile;
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
fileName = UUID.randomUUID() + fileName;
File dest = new File(StableUtils.pathJoin(FileCommonUtils.getAbsolutePath(finalDir), fileName));
return dest;
return fileName;
}
private static CloseableHttpResponse getDownloadHttpResponse(String url) throws Exception {

Loading…
Cancel
Save