Browse Source

Merge remote-tracking branch 'origin/feature/x' into feature/x

feature/x
John.Ying 2 years ago
parent
commit
3d3efc25c3
  1. 3
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  2. 4
      designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java
  3. 98
      designer-base/src/main/java/com/fr/design/deeplink/DeepLinkCore.java
  4. 17
      designer-base/src/main/java/com/fr/design/deeplink/DeepLinkPrepare.java
  5. 33
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  6. 12
      designer-base/src/main/java/com/fr/design/file/DefaultTemplateTreeDefineProcessor.java
  7. 8
      designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java
  8. 10
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  10. 7
      designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirSearchRemindPane.java
  11. 4
      designer-base/src/main/java/com/fr/design/utils/LinkStrUtils.java
  12. 9
      designer-base/src/main/java/com/fr/start/common/DesignerStartupConfig.java
  13. 35
      designer-base/src/main/java/com/fr/start/common/DesignerStartupContext.java
  14. 21
      designer-realize/src/main/java/com/fr/design/deeplink/FileOpen4MacDeepLink.java
  15. 38
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java
  16. 39
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java
  17. 152
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateResourceDetailPane.java
  18. 25
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java
  19. 16
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java
  20. 3
      designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java
  21. 4
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

3
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -1,6 +1,7 @@
package com.fr.design; package com.fr.design;
import com.fr.common.report.ReportState; import com.fr.common.report.ReportState;
import com.fr.design.mainframe.manager.clip.TemplateTreeClipboard;
import com.fr.design.plugin.remind.PluginErrorDesignReminder; import com.fr.design.plugin.remind.PluginErrorDesignReminder;
import com.fr.design.data.DesignTableDataManager; import com.fr.design.data.DesignTableDataManager;
import com.fr.design.dialog.BasicDialog; import com.fr.design.dialog.BasicDialog;
@ -150,6 +151,8 @@ public class EnvChangeEntrance {
model.envChanged(); model.envChanged();
} }
NotificationCenter.getInstance().clearAllNotifications(); NotificationCenter.getInstance().clearAllNotifications();
//切换环境后,清空粘贴板里面的内容
TemplateTreeClipboard.getInstance().reset();
return true; return true;
} }

4
designer-base/src/main/java/com/fr/design/actions/file/RenameAction.java

@ -238,10 +238,10 @@ public class RenameAction extends UpdateAction {
private void confirmClose() { private void confirmClose() {
if (TemplateUtils.checkSelectedTemplateIsEditing()) { if (TemplateUtils.checkSelectedTemplateIsEditing()) {
if (FineJOptionPane.showConfirmDialog(DesignerContext.getDesignerFrame(), if (FineJOptionPane.showConfirmDialog(this,
Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"), Toolkit.i18nText("Fine-Design_Basic_Template_Is_Editing"),
Toolkit.i18nText("Fine-Design_Basic_Alert"), Toolkit.i18nText("Fine-Design_Basic_Alert"),
YES_NO_OPTION) == JOptionPane.NO_OPTION) { YES_NO_OPTION) != JOptionPane.YES_OPTION) {
return; return;
} }
} }

98
designer-base/src/main/java/com/fr/design/deeplink/DeepLinkCore.java

@ -44,6 +44,8 @@ public class DeepLinkCore {
private String pendingURL; private String pendingURL;
private final List<DeepLinkPrepare> deepLinkPrepareList = new ArrayList<>();
private final List<DeepLink> deepLinkList = new ArrayList<>(); private final List<DeepLink> deepLinkList = new ArrayList<>();
private boolean isDesignerStartupCompleted = false; private boolean isDesignerStartupCompleted = false;
@ -51,6 +53,9 @@ public class DeepLinkCore {
public void register(DeepLink deepLink) { public void register(DeepLink deepLink) {
if (deepLink != null) { if (deepLink != null) {
deepLinkList.add(deepLink); deepLinkList.add(deepLink);
if (deepLink instanceof DeepLinkPrepare) {
deepLinkPrepareList.add((DeepLinkPrepare) deepLink);
}
} }
} }
@ -129,6 +134,11 @@ public class DeepLinkCore {
private void acceptNewURL(String url) { private void acceptNewURL(String url) {
this.pendingURL = url; this.pendingURL = url;
UrlBean urlBean = UrlBean.create(this.pendingURL);
for (DeepLinkPrepare deepLinkPrepare : deepLinkPrepareList) {
deepLinkPrepare.prepare(urlBean.getUrl(), urlBean.getHost(), urlBean.getPath(), urlBean.getParams());
}
} }
private boolean canConsumePendingURL() { private boolean canConsumePendingURL() {
@ -148,32 +158,11 @@ public class DeepLinkCore {
} }
private void consumePendingURL() { private void consumePendingURL() {
String host = null;
String path = null;
Map<String, Object> params = new HashMap<>();
URL url = null;
try {
url = new URL(null, this.pendingURL, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
return null;
}
});
} catch (MalformedURLException ignored) {}
if (url != null) {
host = url.getHost();
path = url.getPath();
List<NameValuePair> pairs = URLUtils.parse(url.getQuery()); UrlBean urlBean = UrlBean.create(this.pendingURL);
for (NameValuePair pair: pairs) {
params.put(pair.getName(), pair.getValue());
}
}
FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL); FineLoggerFactory.getLogger().info("consume deep link: " + this.pendingURL);
performDeepLinks(this.pendingURL, host, path, params); performDeepLinks(urlBean.getUrl(), urlBean.getHost(), urlBean.getPath(), urlBean.getParams());
markPendingURLConsumed(); markPendingURLConsumed();
} }
@ -194,4 +183,67 @@ public class DeepLinkCore {
private void markPendingURLConsumed() { private void markPendingURLConsumed() {
this.pendingURL = null; this.pendingURL = null;
} }
private static class UrlBean {
private String url;
private String host;
private String path;
private Map<String, Object> params;
public UrlBean(String url, String host, String path, Map<String, Object> params) {
this.url = url;
this.host = host;
this.path = path;
this.params = params;
}
public String getUrl() {
return url;
}
public String getHost() {
return host;
}
public String getPath() {
return path;
}
public Map<String, Object> getParams() {
return params;
}
public static UrlBean create(String pendingUrl) {
String host = null;
String path = null;
Map<String, Object> params = new HashMap<>();
URL url = null;
try {
url = new URL(null, pendingUrl, new URLStreamHandler() {
@Override
protected URLConnection openConnection(URL u) throws IOException {
return null;
}
});
} catch (MalformedURLException ignored) {
}
if (url != null) {
host = url.getHost();
path = url.getPath();
List<NameValuePair> pairs = URLUtils.parse(url.getQuery());
for (NameValuePair pair : pairs) {
params.put(pair.getName(), pair.getValue());
}
}
return new UrlBean(pendingUrl, host, path, params);
}
}
} }

17
designer-base/src/main/java/com/fr/design/deeplink/DeepLinkPrepare.java

@ -0,0 +1,17 @@
package com.fr.design.deeplink;
import java.util.Map;
/**
* created by Harrison on 2022/08/23
**/
public interface DeepLinkPrepare {
/**
* 准备
*
* @param url 链接
* @return 成功/失败
*/
boolean prepare(String url, String host, String path, Map<String, Object> params);
}

33
designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java

@ -23,6 +23,11 @@ import static com.fr.design.utils.LinkStrUtils.LABEL;
*/ */
public class MessageWithLink extends JEditorPane { public class MessageWithLink extends JEditorPane {
private static final String HTML_BODY = "<body";
private static final String HTML_STYLE_FORMAT = " style=\"%s\"";
/** /**
* 直接放入 html 内容 * 直接放入 html 内容
* 如果有超链接标签 <a href=""></a> 的话将会自动点击匹配 url * 如果有超链接标签 <a href=""></a> 的话将会自动点击匹配 url
@ -69,6 +74,34 @@ public class MessageWithLink extends JEditorPane {
this(frontMessage, linkName, link, backMessage, color, font, LABEL.getForeground()); this(frontMessage, linkName, link, backMessage, color, font, LABEL.getForeground());
} }
public MessageWithLink(String htmlText, Font font) {
this(setHtmlFont(htmlText, font));
}
/**
* 将指定的字体赋给html文本
* 任何失败返回原html文本
* */
private static String setHtmlFont(String htmlText, Font font) {
try {
int bodyIndex = htmlText.indexOf(HTML_BODY);
StringBuilder sb = new StringBuilder();
String left = htmlText.substring(0, bodyIndex + HTML_BODY.length());
String right = htmlText.substring(bodyIndex + HTML_BODY.length());
sb.append(left);
sb.append(String.format(HTML_STYLE_FORMAT, LinkStrUtils.generateStyle(Color.WHITE, font, Color.BLACK)));
sb.append(right);
return sb.toString();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage());
}
return htmlText;
}
public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color backgroundColor, Font font, Color fontColor) { public MessageWithLink(String frontMessage, String linkName, String link, String backMessage, Color backgroundColor, Font font, Color fontColor) {
super("text/html", "<html><body style=\"" + LinkStrUtils.generateStyle(backgroundColor, font, fontColor) + "\">" + frontMessage + "<a href=\"" + link + "\">" + linkName + "</a>" + backMessage + "</body></html>"); super("text/html", "<html><body style=\"" + LinkStrUtils.generateStyle(backgroundColor, font, fontColor) + "\">" + frontMessage + "<a href=\"" + link + "\">" + linkName + "</a>" + backMessage + "</body></html>");

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

@ -24,6 +24,7 @@ import com.fr.file.FileNodeFILE;
import com.fr.file.filetree.FileNode; import com.fr.file.filetree.FileNode;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ArrayUtils;
import com.fr.stable.StableUtils; import com.fr.stable.StableUtils;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.collections.CollectionUtils; import com.fr.stable.collections.CollectionUtils;
@ -217,7 +218,8 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
return false; return false;
} }
//确定目标目录并检查权限 //确定目标目录并检查权限
if (getDirTree().getSelectionCount() != 0 && !TemplateDirTreePane.getInstance().selectedAccess()) { FileOperations selectedOperation = DesignerFrameFileDealerPane.getInstance().getSelectedOperation();
if (!selectedOperation.access()) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"), Toolkit.i18nText("Fine-Design_Basic_Template_Permission_Denied"),
Toolkit.i18nText("Fine-Design_Basic_Alert"), Toolkit.i18nText("Fine-Design_Basic_Alert"),
@ -243,7 +245,7 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
if (pasteNodes.isEmpty()) { if (pasteNodes.isEmpty()) {
//提示:复制的文件都不能黏贴 //提示:复制的文件都不能黏贴
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Unable_Delete_Locked_File"), Toolkit.i18nText("Fine-Design_Basic_Confirm_Paste_Unlock_File"),
Toolkit.i18nText("Fine-Design_Basic_Alert"), Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE); WARNING_MESSAGE);
return; return;
@ -507,6 +509,10 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
private void copyDir(String sourceDir, String targetDir) { private void copyDir(String sourceDir, String targetDir) {
FileNode[] fileNodes = getFileTree().listFile(sourceDir); FileNode[] fileNodes = getFileTree().listFile(sourceDir);
if (ArrayUtils.isEmpty(fileNodes)) {
//空目录:相当于新建一个目录
DesignerFrameFileDealerPane.getInstance().getSelectedOperation().mkdir(targetDir);
}
for (FileNode fileNode : fileNodes) { for (FileNode fileNode : fileNodes) {
if (fileNode.isDirectory()) { if (fileNode.isDirectory()) {
copyDir(StableUtils.pathJoin(fileNode.getParent(), fileNode.getName()), StableUtils.pathJoin(targetDir, fileNode.getName())); copyDir(StableUtils.pathJoin(fileNode.getParent(), fileNode.getName()), StableUtils.pathJoin(targetDir, fileNode.getName()));
@ -519,7 +525,7 @@ public class DefaultTemplateTreeDefineProcessor extends AbstractTemplateTreeDefi
//检查源文件是不是还存在 //检查源文件是不是还存在
if (!WorkContext.getWorkResource().exist(sourcePath)) { if (!WorkContext.getWorkResource().exist(sourcePath)) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Basic_Source_File_Not_Exist"), Toolkit.i18nText("Fine-Design_Basic_Source_File_Not_Exist", sourcePath),
Toolkit.i18nText("Fine-Design_Basic_Alert"), Toolkit.i18nText("Fine-Design_Basic_Alert"),
WARNING_MESSAGE); WARNING_MESSAGE);
} else { } else {

8
designer-base/src/main/java/com/fr/design/file/MutilTempalteTabPane.java

@ -15,6 +15,7 @@ import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.mainframe.TemplateSavingChecker; import com.fr.design.mainframe.TemplateSavingChecker;
import com.fr.design.mainframe.manager.search.TemplateTreeSearchManager;
import com.fr.design.utils.DesignUtils; import com.fr.design.utils.DesignUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.design.utils.gui.GUIPaintUtils; import com.fr.design.utils.gui.GUIPaintUtils;
@ -258,6 +259,11 @@ public class MutilTempalteTabPane extends JComponent {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
//处于搜索模式时,先退出搜索模式,再定位
if (TemplateTreeSearchManager.getInstance().isInSearchMode()) {
TemplateTreeSearchManager.getInstance().outOfSearchMode();
TemplateTreePane.getInstance().refreshDockingView();
}
JTemplate<?, ?> template = openedTemplate.get(this.tplIndex); JTemplate<?, ?> template = openedTemplate.get(this.tplIndex);
super.gotoEditingTemplateLeaf(template.getPath()); super.gotoEditingTemplateLeaf(template.getPath());
} }
@ -287,7 +293,7 @@ public class MutilTempalteTabPane extends JComponent {
JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> currentTemplate = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
closeTemplate(templates, currentTemplate); closeTemplate(templates, currentTemplate);
if (currentTemplate == null) { if (option == CloseOption.All) {
DesignerContext.getDesignerFrame().addAndActivateJTemplate(); DesignerContext.getDesignerFrame().addAndActivateJTemplate();
} else { } else {
DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate); DesignerContext.getDesignerFrame().activateJTemplate(currentTemplate);

10
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrameFileDealerPane.java

@ -207,6 +207,16 @@ public class DesignerFrameFileDealerPane extends JPanel implements FileToolbarSt
selectedOperation.refresh(); selectedOperation.refresh();
} }
/**
* 刷新根目录并退出搜索模式
*/
public void refreshAndOutOfSearch() {
if (TemplateTreeSearchManager.getInstance().isInSearchMode()) {
TemplateTreeSearchManager.getInstance().outOfSearchMode();
}
refresh();
}
private JPanel createUpToolBarPane() { private JPanel createUpToolBarPane() {
JPanel panel = new JPanel(new BorderLayout()); JPanel panel = new JPanel(new BorderLayout());
panel.add(toolBar, BorderLayout.CENTER); panel.add(toolBar, BorderLayout.CENTER);

2
designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java

@ -1787,7 +1787,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) { HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().template.getTemplateID())) {
refreshToolArea(); refreshToolArea();
} }
DesignerFrameFileDealerPane.getInstance().refresh(); DesignerFrameFileDealerPane.getInstance().refreshAndOutOfSearch();
DesignerFrameFileDealerPane.getInstance().stateChange(); DesignerFrameFileDealerPane.getInstance().stateChange();
} }
}); });

7
designer-base/src/main/java/com/fr/design/mainframe/manager/search/searcher/control/pane/TemplateDirSearchRemindPane.java

@ -99,18 +99,17 @@ public class TemplateDirSearchRemindPane extends JPanel implements TreeSearchSta
scrollPane = new UIScrollPane(templateFileTree); scrollPane = new UIScrollPane(templateFileTree);
scrollPane.setBorder(null); scrollPane.setBorder(null);
notFoundPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(true, FlowLayout.LEADING, 0, 5); notFoundPane = FRGUIPaneFactory.createVerticalFlowLayout_Pane(false, FlowLayout.CENTER, 0, 5);
UILabel emptyPicLabel = new UILabel(); UILabel emptyPicLabel = new UILabel();
emptyPicLabel.setIcon(IconUtils.readIcon("com/fr/base/images/share/no_match_icon.png")); emptyPicLabel.setIcon(IconUtils.readIcon("com/fr/base/images/share/no_match_icon.png"));
emptyPicLabel.setHorizontalAlignment(SwingConstants.CENTER); emptyPicLabel.setHorizontalAlignment(SwingConstants.CENTER);
emptyPicLabel.setPreferredSize(new Dimension(240, 100)); emptyPicLabel.setPreferredSize(new Dimension(570, 100));
UILabel textLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Tree_Search_Not_Match"), SwingConstants.CENTER); UILabel textLabel = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Tree_Search_Not_Match"), SwingConstants.CENTER);
textLabel.setForeground(Color.gray); textLabel.setForeground(Color.gray);
textLabel.setHorizontalAlignment(SwingConstants.CENTER); textLabel.setHorizontalAlignment(SwingConstants.CENTER);
textLabel.setPreferredSize(new Dimension(240, 20)); textLabel.setPreferredSize(new Dimension(570, 20));
notFoundPane.add(emptyPicLabel); notFoundPane.add(emptyPicLabel);
notFoundPane.add(textLabel); notFoundPane.add(textLabel);
notFoundPane.setBorder(BorderFactory.createEmptyBorder(80, 0, 0, 0));
cardLayout = new CardLayout(); cardLayout = new CardLayout();
this.setLayout(cardLayout); this.setLayout(cardLayout);

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

@ -43,6 +43,10 @@ public class LinkStrUtils {
return "<a href=\"" + link + "\">" + text + "</a>"; return "<a href=\"" + link + "\">" + text + "</a>";
} }
public static String generateLinkTagWithoutUnderLine(String link, String text) {
return "<a style=\"text-decoration:none;\" href=\"" + link + "\">" + text + "</a>";
}
public static String generateStyle(Color backgroundColor, Font font, Color fontColor) { public static String generateStyle(Color backgroundColor, Font font, Color fontColor) {
// 构建相同风格样式 // 构建相同风格样式

9
designer-base/src/main/java/com/fr/start/common/DesignerStartupConfig.java

@ -12,6 +12,11 @@ public class DesignerStartupConfig implements XMLable {
private static final DesignerStartupConfig INSTANCE = new DesignerStartupConfig(); private static final DesignerStartupConfig INSTANCE = new DesignerStartupConfig();
/**
* 加上版本不然回滚到 1107 会有兼容问题
*/
private static final String TAG_ENABLED = "isEnabled1108";
public static DesignerStartupConfig getInstance() { public static DesignerStartupConfig getInstance() {
return INSTANCE; return INSTANCE;
@ -40,14 +45,14 @@ public class DesignerStartupConfig implements XMLable {
@Override @Override
public void readXML(XMLableReader reader) { public void readXML(XMLableReader reader) {
if (reader.isAttr()) { if (reader.isAttr()) {
this.setEnabled(reader.getAttrAsBoolean("isEnabled", true)); this.setEnabled(reader.getAttrAsBoolean(TAG_ENABLED, true));
} }
} }
@Override @Override
public void writeXML(XMLPrintWriter writer) { public void writeXML(XMLPrintWriter writer) {
writer.startTAG(XML_TAG); writer.startTAG(XML_TAG);
writer.attr("isEnabled", this.isEnabled()); writer.attr(TAG_ENABLED, this.isEnabled());
writer.end(); writer.end();
} }

35
designer-base/src/main/java/com/fr/start/common/DesignerStartupContext.java

@ -20,6 +20,12 @@ import java.util.Iterator;
**/ **/
public class DesignerStartupContext { public class DesignerStartupContext {
/**
* 可以启动
* 当遇到 mac 双击启动时需要将这里置为 false, {@link FileOpen4MacDeepLink}
*/
private boolean enabled = true;
/** /**
* 启动参数 * 启动参数
*/ */
@ -79,6 +85,14 @@ public class DesignerStartupContext {
return StartupContextHolder.INSTANCE; return StartupContextHolder.INSTANCE;
} }
public boolean isEnabled() {
return enabled;
}
public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
private static class StartupContextHolder { private static class StartupContextHolder {
private static final DesignerStartupContext INSTANCE = new DesignerStartupContext(); private static final DesignerStartupContext INSTANCE = new DesignerStartupContext();
} }
@ -103,7 +117,7 @@ public class DesignerStartupContext {
/** /**
* 展示启动页 * 展示启动页
* 1. 判断当前的工作目录数量 * 1. 判断当前的工作目录数量为空或者为1
* 2. 判断是否是 demo还是打开目标文件 * 2. 判断是否是 demo还是打开目标文件
* 3. 功能是否开启 * 3. 功能是否开启
* *
@ -111,10 +125,20 @@ public class DesignerStartupContext {
*/ */
public boolean isShowStartupPage() { public boolean isShowStartupPage() {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
return !startupArgs.isDemo() && DesignerStartupUtil.convertArgs2FILE(startupArgs.get()) == null
// 见该 field 的注释
&& enabled
&& isWorkspaceValid()
&& envManager.isStartupPageEnabled();
}
private boolean isWorkspaceValid() {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
Iterator<String> envNameIterator = envManager.getEnvNameIterator(); Iterator<String> envNameIterator = envManager.getEnvNameIterator();
ArrayList<String> envs = Lists.newArrayList(envNameIterator); ArrayList<String> envs = Lists.newArrayList(envNameIterator);
return !startupArgs.isDemo() && DesignerStartupUtil.convertArgs2FILE(startupArgs.get()) == null && !envs.isEmpty() && envManager.isStartupPageEnabled(); return !envs.isEmpty() && (envs.size() != 1);
} }
/* 预热相关 */ /* 预热相关 */
@ -128,7 +152,12 @@ public class DesignerStartupContext {
String curEnvName = DesignerEnvManager.getEnvManager().getCurEnvName(); String curEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(curEnvName); DesignerWorkspaceInfo workspaceInfo = DesignerEnvManager.getEnvManager().getWorkspaceInfo(curEnvName);
return workspaceInfo.getType() == DesignerWorkspaceType.Local; boolean valid = false;
try {
valid = workspaceInfo.checkValid();
} catch (Exception ignore) {
}
return workspaceInfo.getType() == DesignerWorkspaceType.Local && valid;
} }
public void setStartupPageModel(StartupPageModel startupPageModel) { public void setStartupPageModel(StartupPageModel startupPageModel) {

21
designer-realize/src/main/java/com/fr/design/deeplink/FileOpen4MacDeepLink.java

@ -4,6 +4,7 @@ import com.fr.design.mainframe.DesignerContext;
import com.fr.file.FileFILE; import com.fr.file.FileFILE;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.OperatingSystem;
import com.fr.start.common.DesignerStartupContext;
import com.fr.start.common.DesignerStartupUtil; import com.fr.start.common.DesignerStartupUtil;
import java.io.File; import java.io.File;
@ -14,10 +15,11 @@ import java.util.Map;
* @version 1.0 * @version 1.0
* Created by Starryi on 2022/1/13 * Created by Starryi on 2022/1/13
*/ */
public class FileOpen4MacDeepLink extends DeepLink { public class FileOpen4MacDeepLink extends DeepLink implements DeepLinkPrepare{
@Override @Override
public boolean accept(String url, String host, String path, Map<String, Object> params) { public boolean accept(String url, String host, String path, Map<String, Object> params) {
return OperatingSystem.isMacos() && StringUtils.isEmpty(host) && StringUtils.isEmpty(path) && params.isEmpty();
return support(url, host, path, params);
} }
@Override @Override
@ -30,4 +32,19 @@ public class FileOpen4MacDeepLink extends DeepLink {
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file)); DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file));
} }
} }
@Override
public boolean prepare(String url, String host, String path, Map<String, Object> params) {
if (support(url, host, path, params)) {
DesignerStartupContext.getInstance().setEnabled(false);
return true;
}
return false;
}
public static boolean support(String url, String host, String path, Map<String, Object> params) {
return OperatingSystem.isMacos() && StringUtils.isEmpty(host) && StringUtils.isEmpty(path) && params.isEmpty();
}
} }

38
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/component/AlphaFineFrame.java

@ -252,7 +252,7 @@ public class AlphaFineFrame extends JFrame {
new LoadingRightSearchResultPane() new LoadingRightSearchResultPane()
); );
this.templateResourceSearchWorkerManager = new TemplateResourceSearchWorkerManager( templateResourceSearchWorkerManager = new TemplateResourceSearchWorkerManager(
CellType.TEMPLATE_SHOP, CellType.TEMPLATE_SHOP,
searchTextBean -> { searchTextBean -> {
return TemplateResourceSearchManager.getInstance().getSearchResult(searchTextBean.getSearchText()); return TemplateResourceSearchManager.getInstance().getSearchResult(searchTextBean.getSearchText());
@ -438,11 +438,7 @@ public class AlphaFineFrame extends JFrame {
labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20)); labelPane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
labelPane.setBackground(Color.WHITE); labelPane.setBackground(Color.WHITE);
labelContentPane = new JPanel(new BorderLayout()); labelContentPane = new JPanel(new BorderLayout());
tabLabel = new UILabel(PRODUCT_NEWS); tabLabel = createTabLabel(PRODUCT_NEWS);
tabLabel.setForeground(AlphaFineConstants.FOREGROUND_COLOR_6);
tabLabel.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
tabLabel.setPreferredSize(new Dimension(60, 30));
tabLabel.setForeground(AlphaFineConstants.LABEL_SELECTED);
labelWestPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); labelWestPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
labelWestPane.add(tabLabel); labelWestPane.add(tabLabel);
labelContentPane.add(labelWestPane, BorderLayout.WEST); labelContentPane.add(labelWestPane, BorderLayout.WEST);
@ -491,6 +487,14 @@ public class AlphaFineFrame extends JFrame {
return showPane; return showPane;
} }
private UILabel createTabLabel(String labelName) {
UILabel label = new UILabel(labelName);
label.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 0));
label.setPreferredSize(new Dimension(60, 30));
label.setForeground(AlphaFineConstants.LABEL_SELECTED);
return label;
}
public JPanel getLabelWestPane() { public JPanel getLabelWestPane() {
return labelWestPane; return labelWestPane;
} }
@ -588,6 +592,7 @@ public class AlphaFineFrame extends JFrame {
private void refreshLabelPane() { private void refreshLabelPane() {
labelWestPane.removeAll(); labelWestPane.removeAll();
tabLabel.setForeground(AlphaFineConstants.LABEL_SELECTED);
labelWestPane.add(tabLabel); labelWestPane.add(tabLabel);
} }
@ -658,6 +663,8 @@ public class AlphaFineFrame extends JFrame {
boolean networkError; boolean networkError;
if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) { if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) {
networkError = productNewsSearchWorkerManager.isNetWorkError(); networkError = productNewsSearchWorkerManager.isNetWorkError();
} else if (selectedTab.getCellType() == CellType.TEMPLATE_SHOP) {
networkError = templateResourceSearchWorkerManager.isNetWorkError();
} else { } else {
networkError = currentSearchWorkerManager.isNetWorkError(); networkError = currentSearchWorkerManager.isNetWorkError();
} }
@ -669,6 +676,8 @@ public class AlphaFineFrame extends JFrame {
boolean searchOver; boolean searchOver;
if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) { if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) {
searchOver = productNewsSearchWorkerManager.isSearchOver(); searchOver = productNewsSearchWorkerManager.isSearchOver();
} else if (selectedTab.getCellType() == CellType.TEMPLATE_SHOP) {
searchOver = templateResourceSearchWorkerManager.isSearchOver();
} else { } else {
searchOver = currentSearchWorkerManager.isSearchOver(); searchOver = currentSearchWorkerManager.isSearchOver();
} }
@ -692,17 +701,20 @@ public class AlphaFineFrame extends JFrame {
if (searchResultList != null) { if (searchResultList != null) {
searchResultList.requestFocus(); searchResultList.requestFocus();
} }
boolean hasSearchResult = true;
if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) {
hasSearchResult = productNewsSearchWorkerManager.hasSearchResult();
} else {
hasSearchResult = currentSearchWorkerManager.hasSearchResult();
}
if (!hasSearchResult) { if (!hasSearchResult()) {
showResult(CellType.NO_RESULT.getFlagStr4None()); showResult(CellType.NO_RESULT.getFlagStr4None());
} }
}
private boolean hasSearchResult() {
if (selectedTab.getCellType() == CellType.PRODUCT_NEWS) {
return productNewsSearchWorkerManager.hasSearchResult();
} else if (selectedTab.getCellType() == CellType.TEMPLATE_SHOP) {
return templateResourceSearchWorkerManager.hasSearchResult();
} else {
return currentSearchWorkerManager.hasSearchResult();
}
} }
private void initSearchTextField() { private void initSearchTextField() {

39
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/model/TemplateResourceDetail.java

@ -23,11 +23,13 @@ public class TemplateResourceDetail {
private final TemplateResource root; private final TemplateResource root;
private String info; private String info;
private String vendor; private String vendor;
private String htmlText;
private List<String> detailInfo; private List<String> detailInfo;
private String[] tagsId; private String[] tagsId;
private List<String> tagsName; private List<String> tagsName;
private double price; private double price;
private String parentPkgName; private String parentPkgName = "";
private String parentPkgUrl;
private String resourceUrl; private String resourceUrl;
public static final String ID = "id"; public static final String ID = "id";
@ -38,6 +40,7 @@ public class TemplateResourceDetail {
public static final String PRICE = "price"; public static final String PRICE = "price";
public static final String NAME = "name"; public static final String NAME = "name";
public static final String PARENT_NAME = "parentName"; public static final String PARENT_NAME = "parentName";
public static final String PARENT_URL = "parentUrl";
public static final String TAGS_NAME = "tagsName"; public static final String TAGS_NAME = "tagsName";
public static final String URL = "url"; public static final String URL = "url";
@ -88,6 +91,16 @@ public class TemplateResourceDetail {
return tagsName; return tagsName;
} }
public String getTagsString() {
StringBuilder sb = new StringBuilder();
if (tagsName != null) {
for (String tag : tagsName) {
sb.append(tag + " ");
}
}
return sb.toString();
}
public void setTagsName(List<String> tagsName) { public void setTagsName(List<String> tagsName) {
this.tagsName = tagsName; this.tagsName = tagsName;
} }
@ -120,6 +133,21 @@ public class TemplateResourceDetail {
this.resourceUrl = resourceUrl; this.resourceUrl = resourceUrl;
} }
public String getHtmlText() {
return htmlText;
}
public void setHtmlText(String htmlText) {
this.htmlText = htmlText;
}
public String getParentPkgUrl() {
return parentPkgUrl;
}
public void setParentPkgUrl(String parentPkgUrl) {
this.parentPkgUrl = parentPkgUrl;
}
public static TemplateResourceDetail createByTemplateResource(TemplateResource root) { public static TemplateResourceDetail createByTemplateResource(TemplateResource root) {
return Builder.buildByResource(root); return Builder.buildByResource(root);
@ -141,11 +169,12 @@ public class TemplateResourceDetail {
JSONObject resource = embedResources.getJSONObject(i); JSONObject resource = embedResources.getJSONObject(i);
if (resourceId.equals(resource.getString(ID))) { if (resourceId.equals(resource.getString(ID))) {
detail.setInfo(resource.getString(INFO)); detail.setInfo(resource.getString(INFO));
detail.setDetailInfo(parseDetailInfo(resource.getString(DETAIL_INFO))); detail.setHtmlText(resource.getString(DETAIL_INFO));
detail.setVendor(resource.getString(VENDOR)); detail.setVendor(resource.getString(VENDOR));
detail.setPrice(resource.getDouble(PRICE)); detail.setPrice(resource.getDouble(PRICE));
detail.setResourceUrl(resource.getString(URL)); detail.setResourceUrl(resource.getString(URL));
detail.setParentPkgName(resource.getString(PARENT_NAME)); detail.setParentPkgName(resource.getString(PARENT_NAME));
detail.setParentPkgUrl(resource.getString(PARENT_URL));
detail.setTagsName(Arrays.asList(resource.getString(TAGS_NAME).split(","))); detail.setTagsName(Arrays.asList(resource.getString(TAGS_NAME).split(",")));
break; break;
} }
@ -162,7 +191,7 @@ public class TemplateResourceDetail {
// 1请求详细信息 // 1请求详细信息
JSONObject info = helper.getTemplateInfoById(resourceId); JSONObject info = helper.getTemplateInfoById(resourceId);
detail.setInfo(info.getString(INFO)); detail.setInfo(info.getString(INFO));
detail.setDetailInfo(parseDetailInfo(info.getString(DETAIL_INFO))); detail.setHtmlText(info.getString(DETAIL_INFO));
detail.setVendor(info.getString(VENDOR)); detail.setVendor(info.getString(VENDOR));
detail.setTagsId(info.getString(TAGS_ID).split(",")); detail.setTagsId(info.getString(TAGS_ID).split(","));
detail.setPrice(info.getDouble(PRICE)); detail.setPrice(info.getDouble(PRICE));
@ -172,15 +201,17 @@ public class TemplateResourceDetail {
JSONObject parentPkginfo = helper.getTemplateParentPackageByTemplateId(resourceId); JSONObject parentPkginfo = helper.getTemplateParentPackageByTemplateId(resourceId);
if (parentPkginfo != null) { if (parentPkginfo != null) {
detail.setParentPkgName(parentPkginfo.getString(NAME)); detail.setParentPkgName(parentPkginfo.getString(NAME));
detail.setParentPkgUrl(FineMarketClientHelper.getInstance().getTemplateUrlById(parentPkginfo.getString(ID)));
} }
// 3请求标签信息 // 3请求标签信息
detail.setTagsName(helper.getTemplateTagsByTemplateTagIds(detail.getTagsId())); detail.setTagsName(helper.getTemplateTagsByTemplateTagIds(detail.getTagsId()));
return detail;
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
} }
return detail; return null;
} }
/** /**

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

@ -1,23 +1,30 @@
package com.fr.design.mainframe.alphafine.preview; package com.fr.design.mainframe.alphafine.preview;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.constants.UIConstants;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.alphafine.AlphaFineConstants;
import com.fr.design.mainframe.alphafine.action.StartUseAction; import com.fr.design.mainframe.alphafine.action.StartUseAction;
import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel; import com.fr.design.mainframe.alphafine.component.TemplateResourceImagePanel;
import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail; import com.fr.design.mainframe.alphafine.model.TemplateResourceDetail;
import com.fr.design.utils.BrowseUtils; import com.fr.design.utils.BrowseUtils;
import com.fr.design.utils.LinkStrUtils;
import com.fr.stable.StringUtils;
import javax.swing.BorderFactory; import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel; import javax.swing.JLabel;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.SwingConstants; import javax.swing.SwingUtilities;
import java.awt.Color; import java.awt.Color;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.FlowLayout; import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseAdapter; import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.util.List;
public class TemplateResourceDetailPane extends JPanel { public class TemplateResourceDetailPane extends JPanel {
@ -32,14 +39,16 @@ public class TemplateResourceDetailPane extends JPanel {
private static final int IMAGE_HEIGHT = 170; private static final int IMAGE_HEIGHT = 170;
private static final int IMAGE_WIDTH= 310; private static final int IMAGE_WIDTH = 310;
private static final int SCROLL_PANE_WIDTH = 320; private static final int SCROLL_PANE_WIDTH = 315;
private static final int SCROLL_PANE_HEIGHT = 150; private static final int SCROLL_PANE_HEIGHT = 135;
private static final int CONTENT_PANE_WIDTH = 320; private static final int CONTENT_PANE_WIDTH = 320;
private static final int CONTENT_PANE_HEIGHT = 180; private static final int CONTENT_PANE_HEIGHT = 180;
private static final int DETAIL_PANE_HEIGHT = 110; private static final int DETAIL_PANE_HEIGHT = 95;
private static final int TEXT_SCROLL_PANE_HEIGHT = 500; private static final int TEXT_SCROLL_PANE_HEIGHT = 500;
private static final int PANE_WIDTH = 640; private static final int PANE_WIDTH = 635;
private static final int BUTTON_WIDTH = 68;
private static final int BUTTON_HEIGHT = 20;
private static final String GOTO_DETAIL = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Detail_GOTO_DETAIL"); private static final String GOTO_DETAIL = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Detail_GOTO_DETAIL");
private static final String START_USE = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Detail_START_USE"); private static final String START_USE = Toolkit.i18nText("Fine-Design_Report_AlphaFine_Template_Detail_START_USE");
@ -55,27 +64,38 @@ public class TemplateResourceDetailPane extends JPanel {
private static final Color INFO_PANE_BACKGROUND = new Color(0xf9f9f9); private static final Color INFO_PANE_BACKGROUND = new Color(0xf9f9f9);
private static final Color INFO_PANE_FOREGROUND = new Color(0x5b5b5c); 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 String HTML_P_TAG_FORMAT = "<p style=\"margin-top:5pt;\">%s</p>";
public TemplateResourceDetailPane(TemplateResourceDetail detail) { public TemplateResourceDetailPane(TemplateResourceDetail detail) {
this.data = detail; this.data = detail;
initComponent(); initComponent();
this.setLayout(new FlowLayout(FlowLayout.LEFT)); this.setLayout(new FlowLayout(FlowLayout.LEFT));
this.setBorder(BorderFactory.createEmptyBorder(10,20,0,20)); this.setBorder(BorderFactory.createEmptyBorder(10, 20, 0, 20));
this.add(imagePane); this.add(imagePane);
this.add(contentPane); this.add(contentPane);
this.add(detailInfoPane); this.add(detailInfoPane);
this.setBackground(Color.WHITE); this.setBackground(Color.WHITE);
SwingUtilities.invokeLater(()->{scrollToTop();});
} }
public void refresh() { /**
* scrollPane创建后会拉到最底下初始化的时候手动拉到顶
*/
public void scrollToTop() {
infoScrollPane.getVerticalScrollBar().setValue(0);
detailInfoPane.getVerticalScrollBar().setValue(0);
} }
private void initComponent() { private void initComponent() {
createImagePane(); createImagePane();
createContentPane(); createContentPane();
createDetailInfoPane(); createDetailInfoScrollPane();
} }
private void createContentPane() { private void createContentPane() {
@ -89,11 +109,14 @@ public class TemplateResourceDetailPane extends JPanel {
contentPane.setBackground(Color.WHITE); contentPane.setBackground(Color.WHITE);
} }
/**
* 操作区查看详情立即使用
*/
private void createOperatePane() { private void createOperatePane() {
operatePane = new JPanel(new FlowLayout(FlowLayout.LEFT)); operatePane = new JPanel(new FlowLayout(FlowLayout.LEFT));
JLabel emptyLabel = new JLabel(); JLabel emptyLabel = new JLabel();
emptyLabel.setPreferredSize(new Dimension(140, 25)); emptyLabel.setPreferredSize(new Dimension(145, 25));
JLabel priceLabel = new JLabel(); JLabel priceLabel = new JLabel();
priceLabel.setForeground(Color.RED); priceLabel.setForeground(Color.RED);
if (data.getPrice() == 0) { if (data.getPrice() == 0) {
@ -110,10 +133,13 @@ public class TemplateResourceDetailPane extends JPanel {
} }
/**
* 查看详情
*/
JLabel createLinkLabel() { JLabel createLinkLabel() {
JLabel linkLabel = new JLabel(GOTO_DETAIL); JLabel linkLabel = new JLabel(GOTO_DETAIL);
linkLabel.setBackground(Color.WHITE); linkLabel.setBackground(Color.WHITE);
linkLabel.setForeground(Color.BLUE); linkLabel.setForeground(MORE_INFO_LINK);
linkLabel.addMouseListener(new MouseAdapter() { linkLabel.addMouseListener(new MouseAdapter() {
@Override @Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
@ -124,73 +150,79 @@ public class TemplateResourceDetailPane extends JPanel {
return linkLabel; return linkLabel;
} }
// 方便埋点 /**
* 方便埋点
*/
void openResourceUrl(String url) { void openResourceUrl(String url) {
BrowseUtils.browser(url); BrowseUtils.browser(url);
} }
UIButton createStartUseButton() {
UIButton starUseButton = new UIButton(START_USE); /**
* 立即使用 按钮
*/
JButton createStartUseButton() {
JButton starUseButton = new JButton(START_USE) {
@Override
public void paintComponent(Graphics g) {
Graphics2D g2d = (Graphics2D) g;
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g2d.setColor(UIConstants.FLESH_BLUE);
g2d.fillRoundRect(0, 0, getWidth(), getHeight(), 4, 4);
super.paintComponent(g2d);
}
};
starUseButton.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
starUseButton.setForeground(Color.WHITE);
starUseButton.setFont(AlphaFineConstants.MEDIUM_FONT);
starUseButton.addActionListener(new StartUseAction(data)); starUseButton.addActionListener(new StartUseAction(data));
starUseButton.setPreferredSize(new Dimension(BUTTON_WIDTH, BUTTON_HEIGHT));
starUseButton.setContentAreaFilled(false);
return starUseButton; return starUseButton;
} }
private void createImagePane() {
imagePane = new TemplateResourceImagePanel(data.getRoot(), IMAGE_WIDTH, IMAGE_HEIGHT);
}
/**
* 基本信息页
*/
private void createInfoScrollPane() { private void createInfoScrollPane() {
JLabel content = new JLabel();
content.setHorizontalAlignment(SwingConstants.LEFT);
content.setVerticalAlignment(SwingConstants.TOP);
StringBuilder sb = new StringBuilder();
sb.append("<html><body><p>");
sb.append(VENDOR + data.getVendor() + LF); StringBuilder sb = new StringBuilder();
List<String> tags = data.getTagsName(); // 开发者
sb.append(TAGS); sb.append(String.format(HTML_P_TAG_FORMAT, VENDOR + data.getVendor()));
for (String tag : tags) { // 标签
sb.append(tag + SPACE); sb.append(String.format(HTML_P_TAG_FORMAT, TAGS + data.getTagsString()));
// 所属模板包
if (!StringUtils.isEmpty(data.getParentPkgName())) {
sb.append(String.format(HTML_P_TAG_FORMAT, PARENT_PACKAGE + LinkStrUtils.generateLinkTagWithoutUnderLine(data.getParentPkgUrl(), data.getParentPkgName())));
} }
sb.append(LF); // 信息
sb.append(String.format(HTML_P_TAG_FORMAT, data.getInfo()));
sb.append(PARENT_PACKAGE + data.getParentPkgName() + LF); MessageWithLink content = new MessageWithLink(String.format(HTML_FORMAT, sb));
sb.append(data.getInfo());
sb.append("</p></body></html>");
content.setText(sb.toString());
content.setBackground(INFO_PANE_BACKGROUND); content.setBackground(INFO_PANE_BACKGROUND);
content.setForeground(INFO_PANE_FOREGROUND); content.setForeground(INFO_PANE_FOREGROUND);
content.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH - 10, TEXT_SCROLL_PANE_HEIGHT));
infoScrollPane = new UIScrollPane(content); infoScrollPane = new UIScrollPane(content);
infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT - 25)); infoScrollPane.setPreferredSize(new Dimension(SCROLL_PANE_WIDTH, SCROLL_PANE_HEIGHT));
infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); infoScrollPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
}
private void createImagePane() {
imagePane = new TemplateResourceImagePanel(data.getRoot(), IMAGE_WIDTH, IMAGE_HEIGHT);
} }
private void createDetailInfoPane() { /**
* 详细信息页
JLabel content = new JLabel(); */
content.setHorizontalAlignment(SwingConstants.LEFT); private void createDetailInfoScrollPane() {
content.setVerticalAlignment(SwingConstants.TOP); MessageWithLink content = new MessageWithLink(String.format(DETAIL_INFO_HTML_FORMAT, data.getHtmlText()));
StringBuilder sb = new StringBuilder();
sb.append("<html><body><p>");
sb.append(DETAIL_INFO + LF);
List<String> detailInfos = data.getDetailInfo();
for (String info : detailInfos) {
sb.append(info);
}
sb.append("</p></body></html>");
content.setText(sb.toString());
content.setPreferredSize(new Dimension(PANE_WIDTH - 20, TEXT_SCROLL_PANE_HEIGHT));
content.setBackground(Color.WHITE);
detailInfoPane = new UIScrollPane(content); detailInfoPane = new UIScrollPane(content);
detailInfoPane.setPreferredSize(new Dimension(PANE_WIDTH, DETAIL_PANE_HEIGHT)); detailInfoPane.setPreferredSize(new Dimension(PANE_WIDTH, DETAIL_PANE_HEIGHT));
detailInfoPane.setBackground(Color.WHITE); detailInfoPane.setBackground(Color.WHITE);
detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0,0,0,0)); detailInfoPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
} }
} }

25
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/preview/TemplateShopPane.java

@ -29,6 +29,7 @@ public class TemplateShopPane extends JPanel {
public static final String PAGE_PANEL = "pagePane"; public static final String PAGE_PANEL = "pagePane";
public static final String DETAIL_PANEL = "detailPane"; public static final String DETAIL_PANEL = "detailPane";
public static final String LOADING_PANEL = "loadingPane"; public static final String LOADING_PANEL = "loadingPane";
public static final String FAILED_PANEL = "failedPane";
private String currentCard = Strings.EMPTY; private String currentCard = Strings.EMPTY;
private static final String SLASH = "/"; private static final String SLASH = "/";
@ -37,6 +38,7 @@ public class TemplateShopPane extends JPanel {
private JPanel pagePane; private JPanel pagePane;
private JPanel detailPane; private JPanel detailPane;
private JPanel loadingPane; private JPanel loadingPane;
private JPanel failedPane;
private TemplateShopPane() { private TemplateShopPane() {
setLayout(cardLayout); setLayout(cardLayout);
@ -96,12 +98,20 @@ public class TemplateShopPane extends JPanel {
} catch (Exception e) { } catch (Exception e) {
FineLoggerFactory.getLogger().error(e, e.getMessage()); FineLoggerFactory.getLogger().error(e, e.getMessage());
} }
if (detail == null) {
setRetryAction(resource);
switchCard(FAILED_PANEL);
} else {
// detailpane初始化 // detailpane初始化
detailPane = new TemplateResourceDetailPane(detail); detailPane = new TemplateResourceDetailPane(detail);
// 切换 // 切换
INSTANCE.add(detailPane, DETAIL_PANEL); INSTANCE.add(detailPane, DETAIL_PANEL);
switchCard(DETAIL_PANEL); switchCard(DETAIL_PANEL);
} }
}
}.execute(); }.execute();
} }
@ -119,6 +129,9 @@ public class TemplateShopPane extends JPanel {
UILabel resourceLabel = new UILabel(resourceName); UILabel resourceLabel = new UILabel(resourceName);
resourceLabel.setForeground(AlphaFineConstants.LABEL_SELECTED); resourceLabel.setForeground(AlphaFineConstants.LABEL_SELECTED);
labelNamePane.removeAll();
labelNamePane.add(tabLabel);
labelNamePane.add(slash); labelNamePane.add(slash);
labelNamePane.add(resourceLabel); labelNamePane.add(resourceLabel);
@ -153,6 +166,18 @@ public class TemplateShopPane extends JPanel {
return new SearchLoadingPane(); return new SearchLoadingPane();
} }
private void setRetryAction(TemplateResource resource) {
if (failedPane != null) {
INSTANCE.remove(failedPane);
}
failedPane = createFailedPane(resource);
INSTANCE.add(failedPane, FAILED_PANEL);
}
private JPanel createFailedPane(TemplateResource resource) {
return new NetWorkFailedPane(()->{this.searchAndShowDetailPane(resource);});
}
} }

16
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/search/manager/impl/ProductNewsSearchManager.java

@ -20,7 +20,6 @@ import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
@ -104,7 +103,7 @@ public class ProductNewsSearchManager {
} }
} }
filterByDesignerId(productNewsList); productNewsList = filterByDesignerId(productNewsList);
return productNewsList; return productNewsList;
} }
@ -120,9 +119,9 @@ public class ProductNewsSearchManager {
HashMap<String, Set<String>> userGroupInfoCache = new HashMap<>(); HashMap<String, Set<String>> userGroupInfoCache = new HashMap<>();
//遍历资源,获取target下的所有用户组信息,检查是否包含设计器id //遍历资源,获取target下的所有用户组信息,检查是否包含设计器id
Iterator<ProductNews> iterator = list.iterator(); List<ProductNews> newsList = new ArrayList<>();
while (iterator.hasNext()) { for (ProductNews productNews : list) {
List<String> targets = iterator.next().getTarget(); List<String> targets = productNews.getTarget();
boolean targetsContainDesignerId = false; boolean targetsContainDesignerId = false;
@ -140,12 +139,11 @@ public class ProductNewsSearchManager {
} }
} }
if (targetsContainDesignerId) {
if (!targetsContainDesignerId) { newsList.add(productNews);
iterator.remove();
} }
} }
return list; return newsList;
} }
/** /**

3
designer-realize/src/main/java/com/fr/start/module/DesignerStartup.java

@ -33,6 +33,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.project.ProjectConstants; import com.fr.stable.project.ProjectConstants;
import com.fr.start.DesignerProcessType; import com.fr.start.DesignerProcessType;
import com.fr.start.ServerStarter; import com.fr.start.ServerStarter;
import com.fr.start.common.DesignerStartupContext;
import com.fr.start.event.LazyStartupEvent; import com.fr.start.event.LazyStartupEvent;
import com.fr.start.preload.PreLoadService; import com.fr.start.preload.PreLoadService;
import com.fr.start.server.FineEmbedServer; import com.fr.start.server.FineEmbedServer;
@ -120,7 +121,7 @@ public class DesignerStartup extends Activator {
|| FineEmbedServer.isRunning()) { || FineEmbedServer.isRunning()) {
return; return;
} }
if (DaoSelectorFactory.getDaoSelector().useCacheDao()) { if (DaoSelectorFactory.getDaoSelector().useCacheDao() || DesignerStartupContext.getInstance().isOnStartup()) {
listenEvent(LazyStartupEvent.INSTANCE, new Listener<Null>(Integer.MIN_VALUE) { listenEvent(LazyStartupEvent.INSTANCE, new Listener<Null>(Integer.MIN_VALUE) {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, Null param) {

4
designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

@ -1,6 +1,7 @@
package com.fr.start.module.optimized; package com.fr.start.module.optimized;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.module.Activator; import com.fr.module.Activator;
@ -110,6 +111,9 @@ public class DesignerStartupPageActivator extends Activator {
// 将选中的环境设置为当前环境 // 将选中的环境设置为当前环境
StartupWorkspaceBean selectWorkspaceInfo = model.getSelectWorkspaceInfo(); StartupWorkspaceBean selectWorkspaceInfo = model.getSelectWorkspaceInfo();
DesignerEnvManager.getEnvManager().setCurEnvName(selectWorkspaceInfo.getName()); DesignerEnvManager.getEnvManager().setCurEnvName(selectWorkspaceInfo.getName());
UIUtil.invokeLaterIfNeeded(() -> {
DesignerContext.getDesignerFrame().setTitle();
});
} }
private void launchAfterWarmup(DesignerPreWarmTask warmTask) { private void launchAfterWarmup(DesignerPreWarmTask warmTask) {

Loading…
Cancel
Save