Browse Source

Pull request #9801: REPORT-72828 设计器启动优化之 起始页设计

Merge in DESIGN/design from ~HARRISON/design:feature/x to feature/x

* commit 'ca024a4f6b0d43a547db871ecfa0ce97571d65af':
  REPORT-76079【迭代】【起始页】交互问题 1-处理全屏问题 2-上下间距改变的问题
  REPORT-78472【迭代】【起始页】不打开任何报表启动,点控件管理保存报错npe npe 处理
  REPORT-78469【迭代】【起始页】不打开任何报表启动,点模板主题管理没反应 模板管理部分消除 npe
  REPORT-76061【迭代】【起始页】起始页已打开,系统文件夹直接打开模板 1-文件名变更为全文件名 2-支持 mac
  REPORT-76061【迭代】【起始页】起始页已打开,系统文件夹直接打开模板 1-文件名变更为全文件名 2-支持 mac
  REPORT-76068【迭代】【起始页】埋点没记
  REPORT-76068【迭代】【起始页】埋点没记
  REPORT-76079【迭代】【起始页】交互问题 处理一下 util 里面的鲁棒性
  REPORT-78365【迭代】【起始页】不打开任何报表,普通报表聚合报表都新建失败 规避 npe
  REPORT-78361 【迭代】【起始页】不打开任何报表启动,设计器目录树打开模板报错npe 规避 npe
  REPORT-76079【迭代】【起始页】交互问题 1-远程下只显示 ip 2-调整新建报表的按钮位置
feature/x
Harrison 2 years ago
parent
commit
5bec344624
  1. 8
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  2. 2
      designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java
  3. 16
      designer-base/src/main/java/com/fr/design/utils/DesignUtils.java
  4. 2
      designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java
  5. 31
      designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java
  6. 5
      designer-base/src/main/java/com/fr/startup/metric/DesignerMetrics.java
  7. 71
      designer-base/src/main/java/com/fr/startup/metric/DesignerStartupPageStatistic.java
  8. 3
      designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java
  9. 31
      designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java
  10. 20
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java
  11. 55
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java
  12. 21
      designer-base/src/test/java/com/fr/startup/ui/StartupPageUtilTest.java
  13. 8
      designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java
  14. 4
      designer-realize/src/main/java/com/fr/design/deeplink/FileOpen4MacDeepLink.java
  15. 2
      designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java
  16. 9
      designer-realize/src/main/java/com/fr/start/MainDesigner.java
  17. 5
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

8
designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java

@ -153,7 +153,7 @@ public class FRGUIPaneFactory {
}
public static LayoutManager createCenterLayout(JComponent centerBody) {
return createCenterLayout(centerBody, 0.3d);
return createCenterLayout(centerBody, 0.5d, 0.3d);
}
/**
@ -162,7 +162,7 @@ public class FRGUIPaneFactory {
* @param centerBody 中心组件
* @return 布局方式
*/
public static LayoutManager createCenterLayout(JComponent centerBody, double factor) {
public static LayoutManager createCenterLayout(JComponent centerBody, double factorX, double factorY) {
return new LayoutManager() {
@ -188,8 +188,8 @@ public class FRGUIPaneFactory {
// 这个时候大小是不确定的
int bodyWidth = centerBody.getPreferredSize().width;
int bodyHeight = centerBody.getPreferredSize().height;
int labelX = (width - bodyWidth) / 2;
int labelY = (int) ((height - bodyHeight) * factor);
int labelX = (int) ((width - bodyWidth) * factorX);
int labelY = (int) ((height - bodyHeight) * factorY);
centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight);
}

2
designer-base/src/main/java/com/fr/design/mainframe/theme/utils/DefaultThemedTemplateCellElementCase.java

@ -33,7 +33,7 @@ public class DefaultThemedTemplateCellElementCase {
private static DefaultTemplateCellElement themingCellElement(DefaultTemplateCellElement cellElement) {
JTemplate<?,?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
if (JTemplate.isValid(template)) {
TemplateTheme theme = template.getTemplateTheme();
ThemedCellStyle themedCellStyle = theme.getCellStyleList().getUse4Default();
if (themedCellStyle != null) {

16
designer-base/src/main/java/com/fr/design/utils/DesignUtils.java

@ -25,7 +25,7 @@ import com.fr.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.start.ServerStarter;
import com.fr.start.common.DesignerStartupContext;
import com.fr.startup.ui.StartupPageModel;
import com.fr.start.common.DesignerStartupUtil;
import com.fr.value.NotNullLazyValue;
import com.fr.workspace.WorkContext;
import org.jetbrains.annotations.NotNull;
@ -48,7 +48,6 @@ import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.Locale;
import java.util.Optional;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@ -216,18 +215,9 @@ public class DesignUtils {
@Override
public void run() {
DesignerStartupContext context = DesignerStartupContext.getInstance();
// 如果在启动页展示中
if (context.isOnWaiting()) {
FileFILE fileFILE = new FileFILE(f);
// 设置上一次启动模板为
DesignerEnvManager.getEnvManager().setLastOpenFile(fileFILE.getPath());
StartupPageModel model = context.getStartupPageModel();
Optional.ofNullable(model)
.ifPresent((e) -> {
// 执行上一次模板的启动
Runnable openLastTemplateRunnable = e.getOpenLastTemplateRunnable();
openLastTemplateRunnable.run();
});
if (DesignerStartupUtil.openTemplateIfOnWaiting(f)) {
return;
}
// 如果是在启动中

2
designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java

@ -70,7 +70,7 @@ public class DesignerOpenEmptyPanel extends JPanel {
this.body.add(createIcon, BorderLayout.NORTH);
this.body.add(createButtonPanel, BorderLayout.SOUTH);
setLayout(FRGUIPaneFactory.createCenterLayout(this.body, 0.4d));
setLayout(FRGUIPaneFactory.createCenterLayout(this.body, 0.4d, 0.4d));
ColorUtils.syncBackground(this, Color.WHITE);

31
designer-base/src/main/java/com/fr/start/common/DesignerStartupUtil.java

@ -6,16 +6,45 @@ import com.fr.file.FILE;
import com.fr.file.FILEFactory;
import com.fr.file.FileFILE;
import com.fr.general.ComparatorUtils;
import com.fr.startup.ui.StartupPageModel;
import org.jetbrains.annotations.Nullable;
import java.io.File;
import java.util.Optional;
/**
* created by Harrison on 2022/07/09
**/
public class DesignerStartupUtil {
@Nullable
/**
* 如果是在启动页中
*
* @param file 文件
* @return 成功/失败
*/
public static boolean openTemplateIfOnWaiting(File file) {
DesignerStartupContext context = DesignerStartupContext.getInstance();
// 如果在启动页展示中
if (context.isOnWaiting()) {
FileFILE fileFILE = new FileFILE(file);
// 设置上一次启动模板为当前模板
// 注意这里需要设置为 envFullName
DesignerEnvManager.getEnvManager().setLastOpenFile(fileFILE.getEnvFullName());
StartupPageModel model = context.getStartupPageModel();
Optional.ofNullable(model)
.ifPresent((e) -> {
// 执行上一次模板的启动
Runnable openLastTemplateRunnable = e.getOpenLastTemplateRunnable();
openLastTemplateRunnable.run();
});
return true;
}
return false;
}
@Nullable
public static FILE convertArgs2FILE(String[] args) {
// p:需要打开这个报表文件,这个代码不能删除.

5
designer-base/src/main/java/com/fr/startup/metric/DesignerMetrics.java

@ -7,8 +7,6 @@ public class DesignerMetrics {
private DesignerStartupModel model = new DesignerStartupModel();
private DesignerStartupPageStatistic statistic = new DesignerStartupPageStatistic();
public DesignerMetrics() {
}
@ -16,7 +14,4 @@ public class DesignerMetrics {
return model;
}
public DesignerStartupPageStatistic getStatistic() {
return statistic;
}
}

71
designer-base/src/main/java/com/fr/startup/metric/DesignerStartupPageStatistic.java

@ -1,71 +0,0 @@
package com.fr.startup.metric;
/**
* 设计器启动页使用数据
*
* created by Harrison on 2022/08/12
**/
public class DesignerStartupPageStatistic {
/**
* operate0-双击工作目录进入 点击蓝色箭头进入1-切换其他工作目录2-点击展开全部3-点击工作目录中的模版直接打开 直接点击蓝色箭头进入
*/
private int operate;
/**
* workplace工作目录名称当operate为 0或1时记录
*/
private String workspace;
/**
* workplaceNumber工作目录的个数当operate为 0或1或2或3时记录
*/
private String workspaceNum;
/**
* template模板名称当operate为 3时记录
*/
private String template;
public DesignerStartupPageStatistic(int operate, String workspace, String workspaceNum, String template) {
this.operate = operate;
this.workspace = workspace;
this.workspaceNum = workspaceNum;
this.template = template;
}
public DesignerStartupPageStatistic() {
}
public int getOperate() {
return operate;
}
public void setOperate(int operate) {
this.operate = operate;
}
public String getWorkspace() {
return workspace;
}
public void setWorkspace(String workspace) {
this.workspace = workspace;
}
public String getWorkspaceNum() {
return workspaceNum;
}
public void setWorkspaceNum(String workspaceNum) {
this.workspaceNum = workspaceNum;
}
public String getTemplate() {
return template;
}
public void setTemplate(String template) {
this.template = template;
}
}

3
designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java

@ -45,7 +45,8 @@ public class StartupPageModel {
DesignerWorkspaceInfo workspaceInfo = envManager.getWorkspaceInfo(e);
if (workspaceInfo.getType() == DesignerWorkspaceType.Remote) {
WorkspaceConnectionInfo connection = workspaceInfo.getConnection();
return new StartupWorkspaceBean(e, connection.getUrl(), workspaceInfo.getType());
String remoteAddress = StartupPageUtil.getRemoteAddress(connection.getUrl());
return new StartupWorkspaceBean(e, remoteAddress, workspaceInfo.getType());
} else {
return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType());
}

31
designer-base/src/main/java/com/fr/startup/ui/StartupPageUtil.java

@ -2,14 +2,20 @@ package com.fr.startup.ui;
import com.fr.base.svg.SVGIcon;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.StringUtils;
import javax.swing.Icon;
import java.net.URL;
/**
* created by Harrison on 2022/07/11
**/
public class StartupPageUtil {
public static final int INVALID_PORT = -1;
public static final String COLON = ":";
/**
* 获取最近区域的 ICON
*
@ -37,4 +43,29 @@ public class StartupPageUtil {
}
return SVGIcon.readSVGIcon("/com/fr/design/startup/remote_server_background_28.svg", 28, 28);
}
/**
* 返回 ip : port
*
* @param urlStr 完整的 url 例如 https://localhost:3090/xxx
* @return localhost:3090
*/
public static String getRemoteAddress(String urlStr) {
try {
if (StringUtils.isEmpty(urlStr)) {
return StringUtils.EMPTY;
}
URL url = new URL(urlStr);
String host = url.getHost();
int port = url.getPort();
if (port == INVALID_PORT) {
return host;
}
return host + COLON + port;
} catch (Exception e) {
FineLoggerFactory.getLogger().debug(e.getMessage(), e);
return urlStr;
}
}
}

20
designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java

@ -11,7 +11,6 @@ import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.ColorUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exit.DesignerExiter;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory;
@ -68,7 +67,7 @@ public class StartupPageWindow extends JFrame {
private static final int TITLE_FONT_SIZE = 24;
private static final int ITEM_VERTICAL_GAP = 5;
private static final Dimension SCREEN_SIZE = new Dimension(1600, 820);
private static final Dimension SCREEN_SIZE = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
private StartupPageWorkspacePanel workspacePanel;
@ -147,7 +146,14 @@ public class StartupPageWindow extends JFrame {
validate();
revalidate();
GUICoreUtils.centerWindow(this);
setFullScreen();
}
private void setFullScreen() {
Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
this.setLocation(0, 0);
this.setSize(screenSize.width, screenSize.height);
}
private void addDefaultListeners() {
@ -333,8 +339,7 @@ public class StartupPageWindow extends JFrame {
@Override
public void mouseClicked(MouseEvent e) {
DesignerEnvManager.getEnvManager().setLastOpenFile(recentFile);
pageModel.getOpenLastTemplateRunnable().run();
doOpenLastTemplateAction(recentFile, pageModel);
}
});
Dimension preferredSize = recentItemPanel.getPreferredSize();
@ -366,4 +371,9 @@ public class StartupPageWindow extends JFrame {
return FRGUIPaneFactory.createCenterLayout(centerBody);
}
private void doOpenLastTemplateAction(String recentFile, StartupPageModel pageModel) {
DesignerEnvManager.getEnvManager().setLastOpenFile(recentFile);
pageModel.getOpenLastTemplateRunnable().run();
}
}

55
designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java

@ -127,6 +127,10 @@ public class StartupPageWorkspacePanel extends JPanel {
private JComponent generateUnLimitContentPanel(List<List<StartupWorkspaceBean>> partitions) {
JPanel workspaceDescWrapper = new JPanel();
workspaceDescWrapper.setLayout(new BorderLayout(0, 0));
workspaceDescWrapper.setBorder(new EmptyBorder(20, 0, 0, 0));
JPanel workspaceDescPanel = new JPanel();
workspaceDescPanel.setLayout(new GridLayout(partitions.size(), 1, 0, ITEM_VERTICAL_GAP));
for (List<StartupWorkspaceBean> partition : partitions) {
@ -139,9 +143,11 @@ public class StartupPageWorkspacePanel extends JPanel {
UIScrollPane scrollPane = new UIScrollPane(workspaceDescPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(new EmptyBorder(10, 0, 0, 0));
scrollPane.setPreferredSize(new Dimension(CONTENT_WIDTH, SCROLL_HEIGHT));
workspaceDescWrapper.add(scrollPane, BorderLayout.CENTER);
return scrollPane;
}
return workspaceDescPanel;
workspaceDescWrapper.add(workspaceDescPanel, BorderLayout.CENTER);
return workspaceDescWrapper;
}
private JPanel generateLimitContentPanel(List<List<StartupWorkspaceBean>> partitions) {
@ -194,17 +200,7 @@ public class StartupPageWorkspacePanel extends JPanel {
@Override
public void mousePressed(MouseEvent e) {
if (showMore) {
fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Collapse_Workspace"));
iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_less.svg"));
showMoreContent();
showMore = !showMore;
} else {
fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Expand_All"));
iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_more.svg"));
showLessContent();
showMore = !showMore;
}
doShowAllAction(fontLabel, iconLabel);
}
});
tailPanel.add(showAllPanel);
@ -382,13 +378,10 @@ public class StartupPageWorkspacePanel extends JPanel {
int clickCount = e.getClickCount();
if (clickCount == DOUBLE_CLICK_COUNT) {
pageModel.setSelectWorkspaceInfo(workspaceInfo);
openEmptyTemplateRunnable.run();
doOpenEmptyTemplate(workspaceInfo);
return;
}
// selectWorkspaceRunnable
pageModel.setSelectWorkspaceInfo(workspaceInfo);
selectWorkspaceRunnable.run();
doSwitchWorkspace(workspaceInfo);
}
};
@ -415,7 +408,7 @@ public class StartupPageWorkspacePanel extends JPanel {
@Override
public void mousePressed(MouseEvent e) {
openEmptyTemplateRunnable.run();
doOpenEmptyTemplate(workspaceInfo);
}
});
descPanel.add(arrowLabel, BorderLayout.EAST);
@ -515,4 +508,30 @@ public class StartupPageWorkspacePanel extends JPanel {
this.selectWorkspaceRunnable = selectWorkspaceRunnable;
}
private void doOpenEmptyTemplate(StartupWorkspaceBean workspaceInfo) {
pageModel.setSelectWorkspaceInfo(workspaceInfo);
openEmptyTemplateRunnable.run();
}
private void doSwitchWorkspace(StartupWorkspaceBean workspaceInfo) {
// selectWorkspaceRunnable
pageModel.setSelectWorkspaceInfo(workspaceInfo);
selectWorkspaceRunnable.run();
}
private void doShowAllAction(UILabel fontLabel, UILabel iconLabel) {
if (showMore) {
fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Collapse_Workspace"));
iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_less.svg"));
showMoreContent();
showMore = !showMore;
} else {
fontLabel.setText(Toolkit.i18nText("Fine-Design_Startup_Page_Expand_All"));
iconLabel.setIcon(IconUtils.readIcon("/com/fr/design/startup/show_more.svg"));
showLessContent();
showMore = !showMore;
}
}
}

21
designer-base/src/test/java/com/fr/startup/ui/StartupPageUtilTest.java

@ -0,0 +1,21 @@
package com.fr.startup.ui;
import org.junit.Assert;
import org.junit.Test;
import static org.junit.Assert.*;
public class StartupPageUtilTest {
@Test
public void testGetRemoteAddress() throws Exception {
String remoteAddress = StartupPageUtil.getRemoteAddress("https://localhost:9090/webroot");
Assert.assertEquals("localhost:9090", remoteAddress);
String remoteAddress1 = StartupPageUtil.getRemoteAddress("https://localhost/webroot");
Assert.assertEquals("localhost", remoteAddress1);
String remoteAddress2 = StartupPageUtil.getRemoteAddress(null);
Assert.assertEquals("", remoteAddress2);
}
}

8
designer-realize/src/main/java/com/fr/design/actions/server/WidgetManagerAction.java

@ -1,16 +1,15 @@
package com.fr.design.actions.server;
import com.fr.base.svg.IconUtils;
import com.fr.design.DesignModelAdapter;
import com.fr.design.actions.UpdateAction;
import com.fr.design.dialog.BasicDialog;
import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrame;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.MenuKeySet;
import com.fr.design.webattr.WidgetManagerPane;
import com.fr.form.ui.WidgetInfoConfig;
import com.fr.transaction.CallBackAdaptor;
import com.fr.transaction.Configurations;
import com.fr.transaction.WorkerFacade;
@ -61,7 +60,10 @@ public class WidgetManagerAction extends UpdateAction {
if (model != null) {
model.widgetConfigChanged();
}
designerFrame.getSelectedJTemplate().refreshToolArea();
JTemplate<?, ?> jt = designerFrame.getSelectedJTemplate();
if (JTemplate.isValid(jt)) {
jt.refreshToolArea();
}
}
}));
}

4
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.stable.StringUtils;
import com.fr.stable.os.OperatingSystem;
import com.fr.start.common.DesignerStartupUtil;
import java.io.File;
import java.util.Map;
@ -23,6 +24,9 @@ public class FileOpen4MacDeepLink extends DeepLink {
public void run(String url, String host, String path, Map<String, Object> params) {
File file = new File(url);
if (file.exists()) {
if (DesignerStartupUtil.openTemplateIfOnWaiting(file)) {
return;
}
DesignerContext.getDesignerFrame().openTemplate(new FileFILE(file));
}
}

2
designer-realize/src/main/java/com/fr/design/mainframe/ElementCasePaneDelegate.java

@ -86,7 +86,7 @@ public class ElementCasePaneDelegate extends ElementCasePane<WorkSheet> {
QuickEditorRegion.getInstance().populate(getCurrentEditor());
JTemplate editingTemplate = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate();
// 模板初始化完成后,才能初始化超级链接面板
if (editingTemplate != null && !editingTemplate.isUpMode()) {
if (JTemplate.isValid(editingTemplate) && !editingTemplate.isUpMode()) {
Selection editingSelection = getSelection();
// 获取超级链接面板并刷新显示
HyperlinkGroupPane hyperlinkGroupPane = editingTemplate.getHyperLinkPane(HyperlinkGroupPaneActionImpl.getInstance());

9
designer-realize/src/main/java/com/fr/start/MainDesigner.java

@ -240,8 +240,13 @@ public class MainDesigner extends BaseDesigner {
if (WorkContext.getCurrent().isRoot()) {
menuDef.addShortCut(
new ServerConfigManagerAction(),
new TemplateThemeManagerAction(),
new ServerConfigManagerAction()
);
JTemplate<?, ?> jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (JTemplate.isValid(jt)) {
menuDef.addShortCut(new TemplateThemeManagerAction());
}
menuDef.addShortCut(
new WidgetManagerAction()
);
menuDef.addShortCut(new ChartPreStyleAction(), new ChartEmptyDataStyleAction(),new ChartMapEditorAction());

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

@ -139,8 +139,9 @@ public class DesignerStartupPageActivator extends Activator {
}
private void recordStartupEnd(StopWatch stopWatch) {
DesignerMetrics designerMetrics = DesignerStartupContext.getInstance().getDesignerMetrics();
DesignerStartupContext context = DesignerStartupContext.getInstance();
DesignerMetrics designerMetrics = context.getDesignerMetrics();
DesignerStartupModel model = designerMetrics.getModel();
model.setStartingTime(stopWatch.getTime(TimeUnit.MILLISECONDS));
model.fill();

Loading…
Cancel
Save