Browse Source

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

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

* commit 'd896eaca451fa19fbc8284e5de8fee48f5c906ed':
  无 JIRA 任务,处理圈复杂度的问题
  REPORT-76049【迭代】【起始页】云端运维插件没有自动更新 设计器,预热过程中,不自动更新。
  REPORT-76057【迭代】【起始页】进入的一直都是默认工作目录 进入工作目录前,先将环境准备好
  REPORT-76091 【迭代】【起始页】不打开任何报表,启动,不能新建fvs 兼容 fvs 的插件,并且规避 npe
  REPORT-76079【迭代】【起始页】交互问题 7. 展示的效果不够居中
  REPORT-76079【迭代】【起始页】交互问题 7. 展示的效果不够居中
  REPORT-76098 【迭代】【起始页】起始页和空报表两个配置项均开启,点击最近使用的模板启动,没有打开对应模板 优先判断起始页,再判断老的打开方式
  REPORT-76086 【迭代】【起始页】在起始页不做任何操作,会出现预期外的启动弹窗 在子进程的监听中屏蔽启动页的影响
  REPORT-76091 && REPORT-76041 1-新建决策报表 2-fvs npe 处理
  REPORT-76040 【迭代】【起始页】打开起始页再关闭,上次的进程应该杀掉
  REPORT-76079【迭代】【起始页】交互问题 1. 起始页标题缺失 3. 显示全部处理 4. 路径显示不全的问题 5. 悬浮有点虚的效果 6. 只显示前六张即可
feature/x
Harrison 2 years ago
parent
commit
f7dfc72505
  1. 2
      designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java
  2. 8
      designer-base/src/main/java/com/fr/design/file/HistoryTemplateListCache.java
  3. 9
      designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java
  4. 11
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  5. 207
      designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java
  6. 9
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  7. 93
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  8. 2
      designer-base/src/main/java/com/fr/start/common/DesignerOpenEmptyPanel.java
  9. 10
      designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java
  10. 19
      designer-base/src/main/java/com/fr/startup/ui/StartupPageModel.java
  11. 32
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWindow.java
  12. 45
      designer-base/src/main/java/com/fr/startup/ui/StartupPageWorkspacePanel.java
  13. 8
      designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java
  14. 5
      designer-realize/src/main/java/com/fr/start/DesignerSubListener.java
  15. 25
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java
  16. 12
      designer-realize/src/main/java/com/fr/start/module/optimized/DesignerStartupPageActivator.java

2
designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java

@ -188,7 +188,7 @@ public abstract class DesignTableDataManager {
public static void addDsChangeListener(ChangeListener l) { public static void addDsChangeListener(ChangeListener l) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
String key = StringUtils.EMPTY; String key = StringUtils.EMPTY;
if (template != null) { if (JTemplate.isValid(template)) {
key = template.getPath(); key = template.getPath();
} }
List<ChangeListener> dsListeners = dsListenersMap.get(key); List<ChangeListener> dsListeners = dsListenersMap.get(key);

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

@ -19,6 +19,7 @@ import com.fr.plugin.context.PluginContext;
import com.fr.stable.CoreConstants; import com.fr.stable.CoreConstants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import com.fr.third.org.apache.commons.io.FilenameUtils; import com.fr.third.org.apache.commons.io.FilenameUtils;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -26,7 +27,6 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.ListIterator; import java.util.ListIterator;
import java.util.Map; import java.util.Map;
import java.util.Set;
/** /**
* 历史模板缓存 * 历史模板缓存
@ -99,6 +99,7 @@ public class HistoryTemplateListCache implements CallbackEvent {
} }
@Nullable
public JTemplate<?, ?> getCurrentEditingTemplate() { public JTemplate<?, ?> getCurrentEditingTemplate() {
return this.editingTemplate; return this.editingTemplate;
} }
@ -109,8 +110,11 @@ public class HistoryTemplateListCache implements CallbackEvent {
*/ */
public void setCurrentEditingTemplate(JTemplate<?, ?> jt) { public void setCurrentEditingTemplate(JTemplate<?, ?> jt) {
this.editingTemplate = jt; this.editingTemplate = jt;
//如果当前历史面板中没有
if (!JTemplate.isValid(jt)) {
return;
}
//如果当前历史面板中没有
if (contains(jt) == -1) { if (contains(jt) == -1) {
addHistory(); addHistory();
} }

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

@ -152,15 +152,18 @@ public class FRGUIPaneFactory {
return new FRGridLayout(nColumn); return new FRGridLayout(nColumn);
} }
public static LayoutManager createCenterLayout(JComponent centerBody) {
return createCenterLayout(centerBody, 0.3d);
}
/** /**
* centerBody 为中心创建一个布局 * centerBody 为中心创建一个布局
* 只有当且仅当有一个组件且希望组件 上下左右 居中时使用 * 只有当且仅当有一个组件且希望组件 上下左右 居中时使用
* @param centerBody 中心组件 * @param centerBody 中心组件
* @return 布局方式 * @return 布局方式
*/ */
public static LayoutManager createCenterLayout(JComponent centerBody) { public static LayoutManager createCenterLayout(JComponent centerBody, double factor) {
final double yFactor = 0.30;
return new LayoutManager() { return new LayoutManager() {
@Override @Override
@ -186,7 +189,7 @@ public class FRGUIPaneFactory {
int bodyWidth = centerBody.getPreferredSize().width; int bodyWidth = centerBody.getPreferredSize().width;
int bodyHeight = centerBody.getPreferredSize().height; int bodyHeight = centerBody.getPreferredSize().height;
int labelX = (width - bodyWidth) / 2; int labelX = (width - bodyWidth) / 2;
int labelY = (int) ((height - bodyHeight) * yFactor); int labelY = (int) ((height - bodyHeight) * factor);
centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight); centerBody.setBounds(labelX, labelY, bodyWidth, bodyHeight);
} }

11
designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java

@ -696,7 +696,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
username = connection == null ? StringUtils.EMPTY : connection.getUserName(); username = connection == null ? StringUtils.EMPTY : connection.getUserName();
} }
defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]"); defaultTitleSB.append(username).append("@").append(envName).append("[").append(workspace.getDescription()).append("]");
if (editingTemplate != null) { if (JTemplate.isValid(editingTemplate)) {
String path = editingTemplate.getPath(); String path = editingTemplate.getPath();
if (!editingTemplate.getEditingFILE().exists()) { if (!editingTemplate.getEditingFILE().exists()) {
path = FILEFactory.MEM_PREFIX + path; path = FILEFactory.MEM_PREFIX + path;
@ -815,6 +815,13 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
basePane.remove(layout.getLayoutComponent(BorderLayout.EAST)); basePane.remove(layout.getLayoutComponent(BorderLayout.EAST));
basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER); basePane.add(designerOpenEmptyPanel, BorderLayout.CENTER);
resetToolkitByPlus(ToolBarMenuDock.NULLAVOID);
// 这里挺恶心的,是为了保证对插件的兼容性适配
// 不然的话,插件就会 npe
// 见 https://work.fineres.com/browse/REPORT-76091
HistoryTemplateListCache.getInstance().setCurrentEditingTemplate(JNullTemplate.NULL);
layeredPane.repaint(); layeredPane.repaint();
} }
@ -1081,7 +1088,7 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
} }
JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate jt = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (jt != null) { if (JTemplate.isValid(jt)) {
DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath()); DesignerEnvManager.getEnvManager().setLastOpenFile(jt.getEditingFILE().getPath());
} }

207
designer-base/src/main/java/com/fr/design/mainframe/JNullTemplate.java

@ -0,0 +1,207 @@
package com.fr.design.mainframe;
import com.fr.design.DesignModelAdapter;
import com.fr.design.designer.TargetComponent;
import com.fr.design.gui.frpane.HyperlinkGroupPane;
import com.fr.design.gui.frpane.HyperlinkGroupPaneActionProvider;
import com.fr.design.gui.imenu.UIMenuItem;
import com.fr.design.mainframe.template.info.TemplateProcessInfo;
import com.fr.design.menu.ShortCut;
import com.fr.design.menu.ToolBarDef;
import javax.swing.Icon;
import javax.swing.JComponent;
import javax.swing.JPanel;
/**
* created by Harrison on 2022/08/09
**/
public class JNullTemplate extends JTemplate {
public static final JTemplate NULL = new JNullTemplate();
@Override
public void copy() {
}
@Override
public boolean paste() {
return false;
}
@Override
public boolean cut() {
return false;
}
@Override
public AuthorityEditPane createAuthorityEditPane() {
return null;
}
@Override
public JPanel getEastUpPane() {
return null;
}
@Override
public JPanel getEastDownPane() {
return null;
}
@Override
public ToolBarDef[] toolbars4Target() {
return new ToolBarDef[0];
}
@Override
public JComponent[] toolBarButton4Form() {
return new JComponent[0];
}
@Override
public void refreshEastPropertiesPane() {
}
@Override
public TargetComponent getCurrentElementCasePane() {
return null;
}
@Override
public JComponent getCurrentReportComponentPane() {
return null;
}
@Override
public TemplateProcessInfo getProcessInfo() {
return null;
}
@Override
public void setJTemplateResolution(int resolution) {
}
@Override
public int getJTemplateResolution() {
return 0;
}
@Override
protected JComponent createCenterPane() {
return null;
}
@Override
public void removeTemplateSelection() {
}
@Override
public void refreshContainer() {
}
@Override
public void removeParameterPaneSelection() {
}
@Override
public void setScale(int resolution) {
}
@Override
public int getScale() {
return 0;
}
@Override
public int selfAdaptUpdate() {
return 0;
}
@Override
protected DesignModelAdapter createDesignModel() {
return null;
}
@Override
public UIMenuItem[] createMenuItem4Preview() {
return new UIMenuItem[0];
}
@Override
protected BaseUndoState<?> createUndoState() {
return null;
}
@Override
protected void applyUndoState(BaseUndoState baseUndoState) {
}
@Override
public String suffix() {
return null;
}
@Override
public ShortCut[] shortcut4TemplateMenu() {
return new ShortCut[0];
}
@Override
public ShortCut[] shortCuts4Authority() {
return new ShortCut[0];
}
@Override
public boolean isJWorkBook() {
return false;
}
@Override
public HyperlinkGroupPane getHyperLinkPane(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) {
return null;
}
@Override
public HyperlinkGroupPane getHyperLinkPaneNoPop(HyperlinkGroupPaneActionProvider hyperlinkGroupPaneActionProvider) {
return null;
}
@Override
public void setAuthorityMode(boolean isUpMode) {
}
@Override
public Icon getIcon() {
return null;
}
@Override
public String route() {
return null;
}
@Override
public JPanel[] toolbarPanes4Form() {
return new JPanel[0];
}
@Override
public JComponent toolBar4Authority() {
return null;
}
@Override
public int getToolBarHeight() {
return 0;
}
}

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

@ -1974,4 +1974,13 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode(); DesignerUIModeConfig.getInstance().setAbsoluteMeasureUIMode();
} }
/**
* 判断当前的模板是否是有效的模板
*
* @param jt 模板
* @return /
*/
public static boolean isValid(JTemplate jt) {
return jt != null && jt != JNullTemplate.NULL;
}
} }

93
designer-base/src/main/java/com/fr/start/BaseDesigner.java

@ -38,6 +38,7 @@ import com.fr.workspace.base.WorkspaceStatus;
import java.awt.Window; import java.awt.Window;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.util.concurrent.atomic.AtomicBoolean;
/** /**
* The main class of Report Designer. * The main class of Report Designer.
@ -143,6 +144,45 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
private boolean openFile(final DesignerFrame df, boolean isException, FILE file) { private boolean openFile(final DesignerFrame df, boolean isException, FILE file) {
AtomicBoolean isExWrapper = new AtomicBoolean(isException);
openTemplate(df, isExWrapper, file);
if (OperatingSystem.isMacOS()) {
enableFullScreenMode(df);
}
JTemplate<?, ?> selectedJTemplate = df.getSelectedJTemplate();
if (selectedJTemplate != null) {
selectedJTemplate.requestGridFocus();
}
return isExWrapper.get();
}
private void openTemplate(DesignerFrame df, AtomicBoolean isException, FILE file) {
// 如果是起始页启动中
if (openTemplateOnStartup(df, isException, file)) {
return;
}
openTemplate0(df, isException, file);
}
private void openTemplate0(DesignerFrame df, AtomicBoolean isException, FILE file) {
file = getExtraFILE(isException, file);
if (file != null && file.exists() && !isException.get()) {
df.openTemplate(file);
} else {
df.addAndActivateJTemplate();
// 如果没有模板,则需要确认一下
MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
}
}
private FILE getExtraFILE(AtomicBoolean isException, FILE file) {
//启动时打开指定文件的接口 //启动时打开指定文件的接口
DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG); DesignerStartOpenFileProcessor processor = ExtraDesignClassManager.getInstance().getSingle(DesignerStartOpenFileProcessor.XML_TAG);
// 如果插件没有,且又开启了启动时打开空文件,则使用启动时打开空文件 // 如果插件没有,且又开启了启动时打开空文件,则使用启动时打开空文件
@ -154,53 +194,50 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
if (f != null) { if (f != null) {
file = f;//避免null file = f;//避免null
} else { } else {
isException = true;//此时有文件nullpointer异常,执行打开空文件 isException.set(true);//此时有文件nullpointer异常,执行打开空文件
}
} }
openTemplate(df, isException, file);
if (OperatingSystem.isMacOS()) {
enableFullScreenMode(df);
} }
return file;
JTemplate<?, ?> selectedJTemplate = df.getSelectedJTemplate();
if (selectedJTemplate != null) {
selectedJTemplate.requestGridFocus();
}
return isException;
} }
private void openTemplate(DesignerFrame df, boolean isException, FILE file) { private boolean openTemplateOnStartup(DesignerFrame df, AtomicBoolean isException, FILE file) {
boolean onStartup = DesignerStartupContext.getInstance().isSupport(); boolean onStartup = DesignerStartupContext.getInstance().isSupport();
if (onStartup) { if (onStartup) {
DesignerStartupContext context = DesignerStartupContext.getInstance(); DesignerStartupContext context = DesignerStartupContext.getInstance();
if (context.isCreateNew()) { if (context.isCreateNew()) {
df.addAndActivateJTemplate(); return createNewTemplate(df);
// 如果没有模板,则需要确认一下
MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
return;
}
if (context.isOpenLastFile()) {
if (file != null && file.exists() && !isException) {
df.openTemplate(file);
return;
} }
if (isOpenTemplate(isException, file, context)) {
return openTemplate(df, file);
} }
if (context.isOpenEmpty()) { if (context.isOpenEmpty()) {
df.showEmptyJTemplate(); return openEmpty(df);
return; }
}
return false;
}
private boolean isOpenTemplate(AtomicBoolean isException, FILE file, DesignerStartupContext context) {
return context.isOpenLastFile() && file != null && file.exists() && !isException.get();
} }
private boolean openEmpty(DesignerFrame df) {
df.showEmptyJTemplate();
return true;
} }
if (file != null && file.exists() && !isException) { private boolean openTemplate(DesignerFrame df, FILE file) {
df.openTemplate(file); df.openTemplate(file);
} else { return true;
}
private boolean createNewTemplate(DesignerFrame df) {
df.addAndActivateJTemplate(); df.addAndActivateJTemplate();
// 如果没有模板,则需要确认一下 // 如果没有模板,则需要确认一下
MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate()); MutilTempalteTabPane.getInstance().setTemTemplate(HistoryTemplateListPane.getInstance().getCurrentEditingTemplate());
} return true;
} }
private void enableFullScreenMode(Window window) { private void enableFullScreenMode(Window window) {

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

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

10
designer-base/src/main/java/com/fr/start/common/DesignerStartupExecutor.java

@ -1,15 +1,10 @@
package com.fr.start.common; package com.fr.start.common;
import java.util.ArrayList;
import java.util.List;
/** /**
* created by Harrison on 2022/07/03 * created by Harrison on 2022/07/03
**/ **/
public class DesignerStartupExecutor { public class DesignerStartupExecutor {
private List<Runnable> warmupTasks = new ArrayList<>();
public void execute(Runnable runnable) { public void execute(Runnable runnable) {
if (!DesignerStartupContext.getInstance().onWarmup()) { if (!DesignerStartupContext.getInstance().onWarmup()) {
@ -17,11 +12,6 @@ public class DesignerStartupExecutor {
} }
} }
public void reset() {
warmupTasks.clear();
}
public static DesignerStartupExecutor getInstance() { public static DesignerStartupExecutor getInstance() {
return DesignerStartupExecutorHolder.INSTANCE; return DesignerStartupExecutorHolder.INSTANCE;
} }

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

@ -3,10 +3,12 @@ package com.fr.startup.ui;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType; import com.fr.design.env.DesignerWorkspaceType;
import com.fr.stable.StringUtils;
import com.fr.third.guava.collect.Lists; import com.fr.third.guava.collect.Lists;
import com.fr.workspace.connect.WorkspaceConnectionInfo; import com.fr.workspace.connect.WorkspaceConnectionInfo;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -33,7 +35,10 @@ public class StartupPageModel {
public static StartupPageModel create() { public static StartupPageModel create() {
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager(); DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
String curEnvName = envManager.getCurEnvName();
Iterator<String> envNameIterator = envManager.getEnvNameIterator(); Iterator<String> envNameIterator = envManager.getEnvNameIterator();
Comparator<StartupWorkspaceBean> startupWorkspaceBeanComparator = convertComparator(curEnvName);
List<StartupWorkspaceBean> infos = Lists.newArrayList(envNameIterator) List<StartupWorkspaceBean> infos = Lists.newArrayList(envNameIterator)
.stream() .stream()
.map((e) -> { .map((e) -> {
@ -45,6 +50,7 @@ public class StartupPageModel {
return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType()); return new StartupWorkspaceBean(e, workspaceInfo.getPath(), workspaceInfo.getType());
} }
}) })
.sorted(startupWorkspaceBeanComparator)
.collect(Collectors.toList()); .collect(Collectors.toList());
Map<String, List<String>> recentFileMap = new HashMap<>(); Map<String, List<String>> recentFileMap = new HashMap<>();
for (StartupWorkspaceBean info : infos) { for (StartupWorkspaceBean info : infos) {
@ -108,4 +114,17 @@ public class StartupPageModel {
public void setOpenEmptyTemplateRunnable(Runnable openEmptyTemplateRunnable) { public void setOpenEmptyTemplateRunnable(Runnable openEmptyTemplateRunnable) {
this.openEmptyTemplateRunnable = openEmptyTemplateRunnable; this.openEmptyTemplateRunnable = openEmptyTemplateRunnable;
} }
private static Comparator<StartupWorkspaceBean> convertComparator(String curEnvName) {
return (o1, o2) -> {
if (StringUtils.equals(curEnvName, o1.getName())) {
return -1;
}
if (StringUtils.equals(curEnvName, o2.getName())) {
return 1;
}
return 0;
};
}
} }

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

@ -12,7 +12,10 @@ import com.fr.design.layout.VerticalFlowLayout;
import com.fr.design.ui.util.UIUtil; import com.fr.design.ui.util.UIUtil;
import com.fr.design.utils.ColorUtils; import com.fr.design.utils.ColorUtils;
import com.fr.design.utils.gui.GUICoreUtils; import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.exit.DesignerExiter;
import com.fr.general.GeneralUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import com.fr.stable.ProductConstants;
import com.fr.stable.collections.CollectionUtils; import com.fr.stable.collections.CollectionUtils;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -39,6 +42,8 @@ import java.awt.LayoutManager;
import java.awt.RenderingHints; 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.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -135,6 +140,8 @@ public class StartupPageWindow extends JFrame {
// Workspace-detail // Workspace-detail
setSize(SCREEN_SIZE); setSize(SCREEN_SIZE);
setDefaultTitle();
addDefaultListeners();
repaint(); repaint();
validate(); validate();
@ -143,6 +150,29 @@ public class StartupPageWindow extends JFrame {
GUICoreUtils.centerWindow(this); GUICoreUtils.centerWindow(this);
} }
private void addDefaultListeners() {
addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent e) {
DesignerExiter.getInstance().execute();
}
});
}
private void setDefaultTitle() {
StringBuilder sb = new StringBuilder();
sb.append(ProductConstants.APP_NAME);
sb.append(" ");
sb.append(GeneralUtils.getVersion());
sb.append(" ");
sb.append(ProductConstants.BRANCH);
sb.append(" ");
sb.append(Toolkit.i18nText("Fine-Design_Startup_Page_Title"));
setTitle(sb.toString());
}
private void patchUIAction(StartupPageModel pageModel) { private void patchUIAction(StartupPageModel pageModel) {
Runnable selectAndOpenLastTemplateRunnable = pageModel.getOpenLastTemplateRunnable(); Runnable selectAndOpenLastTemplateRunnable = pageModel.getOpenLastTemplateRunnable();
@ -317,7 +347,7 @@ public class StartupPageWindow extends JFrame {
recentOpenGroupPanel.setPreferredSize(new Dimension(GROUP_WIDTH, (int) preferredSize.getHeight())); recentOpenGroupPanel.setPreferredSize(new Dimension(GROUP_WIDTH, (int) preferredSize.getHeight()));
if (needScroll) { if (needScroll) {
int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_SCROLL)); int scrollHeight = (int) Math.round(itemHeight * RECENT_FILE_LIMIT + ITEM_VERTICAL_GAP * (RECENT_FILE_LIMIT));
UIScrollPane scrollPane = new UIScrollPane(recentOpenGroupPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); UIScrollPane scrollPane = new UIScrollPane(recentOpenGroupPanel, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
scrollPane.setPreferredSize(new Dimension(GROUP_WIDTH, scrollHeight)); scrollPane.setPreferredSize(new Dimension(GROUP_WIDTH, scrollHeight));

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

@ -63,7 +63,10 @@ public class StartupPageWorkspacePanel extends JPanel {
private static final Dimension PATH_DIMENSION = new Dimension(100, 20); private static final Dimension PATH_DIMENSION = new Dimension(100, 20);
private static final Dimension SELECT_WORKSPACE_DIMENSION = new Dimension(210, 72); private static final Dimension SELECT_WORKSPACE_DIMENSION = new Dimension(210, 72);
private static final Dimension SELECT_CREATE_DIMENSION = new Dimension(60, 72); private static final Dimension SELECT_CREATE_DIMENSION = new Dimension(60, 72);
public static final int COLUMN_LIMIT = 3;
private static final int COLUMN_LIMIT = 3;
private static final int DOUBLE_CLICK_COUNT = 2;
public static final int PARTITION_LIMIT = 2;
/* model */ /* model */
@ -95,12 +98,14 @@ public class StartupPageWorkspacePanel extends JPanel {
this.contentPanel = generateLimitContentPanel(partitions); this.contentPanel = generateLimitContentPanel(partitions);
this.add(contentPanel, BorderLayout.NORTH); this.add(contentPanel, BorderLayout.NORTH);
if (partitions.size() > PARTITION_LIMIT) {
this.tailPanel = generateTailPanel(); this.tailPanel = generateTailPanel();
this.add(tailPanel, BorderLayout.SOUTH);
}
this.createNewTemplateRunnable = pageModel.getCreateNewTemplateRunnable(); this.createNewTemplateRunnable = pageModel.getCreateNewTemplateRunnable();
this.openEmptyTemplateRunnable = pageModel.getOpenEmptyTemplateRunnable(); this.openEmptyTemplateRunnable = pageModel.getOpenEmptyTemplateRunnable();
this.add(tailPanel, BorderLayout.SOUTH);
this.repaint(); this.repaint();
} }
@ -221,7 +226,7 @@ public class StartupPageWorkspacePanel extends JPanel {
layoutSelectWorkspacePanel(workspaceInfo, workspaceItemDesc); layoutSelectWorkspacePanel(workspaceInfo, workspaceItemDesc);
layoutSelectAndCreatePanel(workspaceItemDesc); layoutSelectAndCreatePanel(workspaceInfo, workspaceItemDesc);
partitionPanel.add(workspaceItemDesc); partitionPanel.add(workspaceItemDesc);
@ -293,10 +298,8 @@ public class StartupPageWorkspacePanel extends JPanel {
int roundOffset = 15; int roundOffset = 15;
// 画一个圆角 // 画一个圆角
int fixRoundWidth = getWidth() - rectOffset; int fixRoundWidth = getWidth() - rectOffset;
int fixRoundHeight = getHeight() - BORDER_THIN; int fixRoundHeight = getHeight() - BORDER_THIN * 2;
g2d.drawRoundRect(strokeOffset, strokeOffset, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER); g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, fixRoundWidth, fixRoundHeight, ARC_DIAMETER, ARC_DIAMETER);
// 画一个直角
g2d.drawRoundRect(getWidth() - roundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, 0, 0);
g2d.setColor(backColor); g2d.setColor(backColor);
@ -306,8 +309,13 @@ public class StartupPageWorkspacePanel extends JPanel {
// 偏左一点的 fixedX // 偏左一点的 fixedX
int fixedX = getWidth() - roundOffset - BORDER_THIN; int fixedX = getWidth() - roundOffset - BORDER_THIN;
// 圆角和直角相交的区域 // 圆角和直角相交的区域
int coverWidth = 10; int coverWidth = 15;
g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight); g2d.fillRect(fixedX, BORDER_THIN, coverWidth, coverHeight);
g2d.setColor(borderColor);
g2d.drawLine(getWidth() / 2, BORDER_THIN, getWidth(), BORDER_THIN);
g2d.drawLine(getWidth() / 2, getHeight() - BORDER_THIN, getWidth(), getHeight() - BORDER_THIN);
g2d.drawLine(getWidth() - strokeOffset, BORDER_THIN, getWidth() - strokeOffset, getHeight() - BORDER_THIN);
} }
} }
}; };
@ -335,6 +343,7 @@ public class StartupPageWorkspacePanel extends JPanel {
Font font = nameLabel.getFont(); Font font = nameLabel.getFont();
Font newSizeFont = font.deriveFont(font.getStyle(), NAME_LABEL_SIZE); Font newSizeFont = font.deriveFont(font.getStyle(), NAME_LABEL_SIZE);
nameLabel.setFont(newSizeFont); nameLabel.setFont(newSizeFont);
nameLabel.setPreferredSize(PATH_DIMENSION);
Color nameForeground = nameLabel.getForeground(); Color nameForeground = nameLabel.getForeground();
simpleDescPanel.add(nameLabel,BorderLayout.NORTH); simpleDescPanel.add(nameLabel,BorderLayout.NORTH);
@ -372,7 +381,7 @@ public class StartupPageWorkspacePanel extends JPanel {
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
int clickCount = e.getClickCount(); int clickCount = e.getClickCount();
if (clickCount == BORDER_THIN) { if (clickCount == DOUBLE_CLICK_COUNT) {
pageModel.setSelectWorkspaceInfo(workspaceInfo); pageModel.setSelectWorkspaceInfo(workspaceInfo);
openEmptyTemplateRunnable.run(); openEmptyTemplateRunnable.run();
return; return;
@ -420,7 +429,7 @@ public class StartupPageWorkspacePanel extends JPanel {
workspaceItemDesc.add(selectWorkspacePanel, BorderLayout.WEST); workspaceItemDesc.add(selectWorkspacePanel, BorderLayout.WEST);
} }
private void layoutSelectAndCreatePanel(JPanel workspaceItemDesc) { private void layoutSelectAndCreatePanel(StartupWorkspaceBean workspaceInfo, JPanel workspaceItemDesc) {
// 选择并新建 // 选择并新建
AtomicReference<Color> borderColorRef = new AtomicReference<>(null); AtomicReference<Color> borderColorRef = new AtomicReference<>(null);
@ -450,12 +459,19 @@ public class StartupPageWorkspacePanel extends JPanel {
if (borderColor != null) { if (borderColor != null) {
g2d.setColor(borderColor); g2d.setColor(borderColor);
g2d.setStroke(new BasicStroke(BORDER_THIN)); g2d.setStroke(new BasicStroke(BORDER_THIN));
int borderOffset = BORDER_THIN * 2;
// 画画的笔触需要调整一下 // 画画的笔触需要调整一下
g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0); //g2d.drawRoundRect(strokeOffset, strokeOffset, getWidth() - rectOffset, getHeight() - BORDER_THIN, 0, 0);
g2d.drawRoundRect(getWidth() - fixedRoundOffset, strokeOffset, roundOffset - strokeOffset, getHeight() - BORDER_THIN, ARC_DIAMETER, ARC_DIAMETER); g2d.drawRoundRect(BORDER_THIN, BORDER_THIN, getWidth() - borderOffset, getHeight() - borderOffset, ARC_DIAMETER, ARC_DIAMETER);
g2d.setColor(backColor); g2d.setColor(backColor);
int fillWidth = 11; int fillWidth = 15;
g2d.fillRect(getWidth() - fixedRoundOffset - BORDER_THIN, BORDER_THIN, fillWidth, getHeight() - BORDER_THIN * 2); g2d.fillRect(0, 0, fillWidth, getHeight());
g2d.setColor(borderColor);
g2d.drawLine(BORDER_THIN, BORDER_THIN, fillWidth, BORDER_THIN);
g2d.drawLine(BORDER_THIN, getHeight() - BORDER_THIN, fillWidth, getHeight() - BORDER_THIN);
g2d.drawLine(BORDER_THIN, BORDER_THIN, BORDER_THIN, getHeight() - BORDER_THIN);
} }
} }
@ -484,6 +500,7 @@ public class StartupPageWorkspacePanel extends JPanel {
} }
@Override @Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
pageModel.setSelectWorkspaceInfo(workspaceInfo);
createNewTemplateRunnable.run(); createNewTemplateRunnable.run();
} }
}); });

8
designer-base/src/test/java/com/fr/startup/ui/StartupPageWindowTest.java

@ -16,13 +16,13 @@ public class StartupPageWindowTest {
@Override @Override
public void run() { public void run() {
HashMap<String, List<String>> recentOpenFileMap = new HashMap<>(); HashMap<String, List<String>> recentOpenFileMap = new HashMap<>();
recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt")); recentOpenFileMap.put("111", Lists.newArrayList("111.cpt", "222//3333.cpt","333.cpt", "444.cpt", "555.cpt", "666.cpt", "777.cpt"));
StartupPageModel model = new StartupPageModel(Stream.of( StartupPageModel model = new StartupPageModel(Stream.of(
StartupWorkspaceBean.create("111", "222333344455556663333444555566633334445555666"), StartupWorkspaceBean.create("113", "222"), StartupWorkspaceBean.create("111", "222333344455556663333444555566633334445555666"), StartupWorkspaceBean.create("113", "222"),
StartupWorkspaceBean.create("114", "222"), StartupWorkspaceBean.create("115", "222"), StartupWorkspaceBean.create("116", "222"), StartupWorkspaceBean.create("114", "222"), StartupWorkspaceBean.create("115", "222"), StartupWorkspaceBean.create("116", "222"),
StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"), //StartupWorkspaceBean.create("117", "222"), StartupWorkspaceBean.create("118", "222"), StartupWorkspaceBean.create("119", "222"),
StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"), //StartupWorkspaceBean.create("121", "222"), StartupWorkspaceBean.create("122", "222"), StartupWorkspaceBean.create("123", "222"),
StartupWorkspaceBean.create("124", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222") StartupWorkspaceBean.create("1245678888888", "222"), StartupWorkspaceBean.create("125", "222"), StartupWorkspaceBean.create("126", "222")
).collect(Collectors.toList()), recentOpenFileMap); ).collect(Collectors.toList()), recentOpenFileMap);
StartupPageWindow window = new StartupPageWindow(model); StartupPageWindow window = new StartupPageWindow(model);
window.setVisible(true); window.setVisible(true);

5
designer-realize/src/main/java/com/fr/start/DesignerSubListener.java

@ -8,6 +8,7 @@ import com.fr.exit.DesignerExiter;
import com.fr.process.engine.core.CarryMessageEvent; import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext; import com.fr.process.engine.core.FineProcessContext;
import com.fr.process.engine.core.FineProcessEngineEvent; import com.fr.process.engine.core.FineProcessEngineEvent;
import com.fr.start.common.DesignerStartupContext;
/** /**
* @author hades * @author hades
@ -31,6 +32,10 @@ public class DesignerSubListener {
FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener<Null>() { FineProcessContext.getParentPipe().listen(FineProcessEngineEvent.READY, new Listener<Null>() {
@Override @Override
public void on(Event event, Null param) { public void on(Event event, Null param) {
// 如果是在起始页的等待过程中
if (DesignerStartupContext.getInstance().isOnWaiting()) {
return;
}
if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) { if (DesignerContext.getDesignerFrame() == null || !DesignerContext.getDesignerFrame().isShowing()) {
DesignerExiter.getInstance().exitUnexpectedly(() -> { DesignerExiter.getInstance().exitUnexpectedly(() -> {

25
designer-realize/src/main/java/com/fr/start/module/optimized/DesignUpdateActivator.java

@ -0,0 +1,25 @@
package com.fr.start.module.optimized;
import com.fr.start.common.DesignerStartupContext;
import com.fr.update.activator.BasicUpdateActivator;
import com.fr.update.base.FineUpdateUnit;
/**
* created by Harrison on 2022/08/11
**/
public class DesignUpdateActivator extends BasicUpdateActivator {
@Override
public void start() {
if (DesignerStartupContext.getInstance().onWarmup()) {
try {
prepare4Start();
FineUpdateUnit.makeNew();
} catch (Throwable ignore) {
}
} else {
super.start();
}
}
}

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

@ -1,5 +1,6 @@
package com.fr.start.module.optimized; package com.fr.start.module.optimized;
import com.fr.design.DesignerEnvManager;
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;
@ -10,6 +11,7 @@ import com.fr.start.util.DesignerStartupPageUtil;
import com.fr.start.warmup.DesignerPreWarmTask; import com.fr.start.warmup.DesignerPreWarmTask;
import com.fr.startup.ui.StartupPageModel; import com.fr.startup.ui.StartupPageModel;
import com.fr.startup.ui.StartupPageWindow; import com.fr.startup.ui.StartupPageWindow;
import com.fr.startup.ui.StartupWorkspaceBean;
import com.fr.third.org.apache.commons.lang3.time.StopWatch; import com.fr.third.org.apache.commons.lang3.time.StopWatch;
import com.fr.value.NotNullLazyValue; import com.fr.value.NotNullLazyValue;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -66,18 +68,21 @@ public class DesignerStartupPageActivator extends Activator {
// selectAndOpenLast // selectAndOpenLast
model.setOpenLastTemplateRunnable(() -> { model.setOpenLastTemplateRunnable(() -> {
context.setOpenLastFile(true); context.setOpenLastFile(true);
handleModel(model);
launchAfterWarmup(warmTask); launchAfterWarmup(warmTask);
}); });
// selectAndOpenEmpty // selectAndOpenEmpty
model.setOpenEmptyTemplateRunnable(() -> { model.setOpenEmptyTemplateRunnable(() -> {
context.setOpenEmpty(true); context.setOpenEmpty(true);
handleModel(model);
launchAfterWarmup(warmTask); launchAfterWarmup(warmTask);
}); });
// selectAndCreateNew // selectAndCreateNew
model.setCreateNewTemplateRunnable(() -> { model.setCreateNewTemplateRunnable(() -> {
context.setCreateNew(true); context.setCreateNew(true);
handleModel(model);
launchAfterWarmup(warmTask); launchAfterWarmup(warmTask);
}); });
@ -87,6 +92,13 @@ public class DesignerStartupPageActivator extends Activator {
}); });
} }
private void handleModel(StartupPageModel model) {
// 将选中的环境设置为当前环境
StartupWorkspaceBean selectWorkspaceInfo = model.getSelectWorkspaceInfo();
DesignerEnvManager.getEnvManager().setCurEnvName(selectWorkspaceInfo.getName());
}
private void launchAfterWarmup(DesignerPreWarmTask warmTask) { private void launchAfterWarmup(DesignerPreWarmTask warmTask) {
StopWatch stopWatch = StopWatch.createStarted(); StopWatch stopWatch = StopWatch.createStarted();

Loading…
Cancel
Save