Browse Source

Merge branch 'feature/10.0' of https://code.fineres.com/scm/~henry.wang/design into feature/10.0

feature/10.0
Henry.Wang 4 years ago
parent
commit
394b470262
  1. 3
      designer-base/src/main/java/com/fr/design/DesignModelAdapter.java
  2. 11
      designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java
  3. 12
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  4. 22
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  5. 14
      designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java
  6. 23
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  7. 49
      designer-base/src/main/java/com/fr/design/dialog/link/MessageWithLink.java
  8. 8
      designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java
  9. 2
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  10. 29
      designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java
  11. 2
      designer-base/src/main/java/com/fr/design/mainframe/EastRegionContainerPane.java
  12. 11
      designer-base/src/main/java/com/fr/design/mainframe/JTemplate.java
  13. 92
      designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java
  14. 5
      designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java
  15. 2
      designer-base/src/main/java/com/fr/design/menu/MenuDef.java
  16. 47
      designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java
  17. 6
      designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java
  18. 2
      designer-base/src/main/java/com/fr/start/BaseDesigner.java
  19. 12
      designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg
  20. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif
  21. BIN
      designer-base/src/main/resources/com/fr/design/images/mainframe/open_failed.png
  22. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptApp.java
  23. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/CptxApp.java
  24. 2
      designer-realize/src/main/java/com/fr/design/mainframe/app/FormApp.java

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

@ -299,6 +299,9 @@ public abstract class DesignModelAdapter<T extends BaseBook, S extends JTemplate
TableData tableData, TableData tableData,
Map<String, ParameterProvider> map, Map<String, ParameterProvider> map,
Filter<ParameterProvider> filter) { Filter<ParameterProvider> filter) {
// 兼容下通过老数据集参数获取
tableDataParameters = getLatestTableDataParameters();
// 处理初始化添加 // 处理初始化添加
if (tableDataParametersMap.isEmpty()) { if (tableDataParametersMap.isEmpty()) {

11
designer-base/src/main/java/com/fr/design/actions/file/EditEnvAction.java

@ -3,6 +3,8 @@ package com.fr.design.actions.file;
import com.fr.design.EnvChangeEntrance; import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
@ -17,4 +19,13 @@ public class EditEnvAction extends UpdateAction {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
EnvChangeEntrance.getInstance().chooseEnv(); EnvChangeEntrance.getInstance().chooseEnv();
} }
@Override
public void update() {
super.update();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.setEnabled(!template.isSaving());
}
}
} }

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

@ -1,10 +1,11 @@
package com.fr.design.actions.file; package com.fr.design.actions.file;
import com.fr.base.svg.IconUtils;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.EnvChangeEntrance; import com.fr.design.EnvChangeEntrance;
import com.fr.design.actions.UpdateAction; import com.fr.design.actions.UpdateAction;
import com.fr.design.env.DesignerWorkspaceInfo; import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.mainframe.JTemplate;
import com.fr.design.menu.KeySetUtils; import com.fr.design.menu.KeySetUtils;
import com.fr.design.menu.MenuDef; import com.fr.design.menu.MenuDef;
import com.fr.design.menu.SeparatorDef; import com.fr.design.menu.SeparatorDef;
@ -68,5 +69,14 @@ public class SwitchExistEnv extends MenuDef {
EnvChangeEntrance.getInstance().switch2Env(envName); EnvChangeEntrance.getInstance().switch2Env(envName);
} }
} }
@Override
public void update() {
super.update();
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) {
this.setEnabled(!template.isSaving());
}
}
} }
} }

22
designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java

@ -1,7 +1,6 @@
package com.fr.design.data.datapane; package com.fr.design.data.datapane;
import com.fr.base.TableData; import com.fr.base.TableData;
import com.fr.concurrent.NamedThreadFactory;
import com.fr.data.core.DataCoreUtils; import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils; import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure; import com.fr.data.core.db.TableProcedure;
@ -18,7 +17,7 @@ import com.fr.design.data.datapane.preview.PreviewLabel.Previewable;
import com.fr.design.data.datapane.preview.PreviewTablePane; import com.fr.design.data.datapane.preview.PreviewTablePane;
import com.fr.design.data.tabledata.Prepare4DataSourceChange; import com.fr.design.data.tabledata.Prepare4DataSourceChange;
import com.fr.design.dialog.FineJOptionPane; import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.icombobox.SearchPreTaskTreeComboBox; import com.fr.design.gui.icombobox.FRTreeComboBox;
import com.fr.design.gui.icombobox.FilterableComboBoxModel; import com.fr.design.gui.icombobox.FilterableComboBoxModel;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxEditor; import com.fr.design.gui.icombobox.UIComboBoxEditor;
@ -60,10 +59,6 @@ import java.util.Collection;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
/** /**
* @author zhou * @author zhou
@ -85,25 +80,20 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
/** /**
* 表名 * 表名
*/ */
protected SearchPreTaskTreeComboBox tableNameComboBox; protected FRTreeComboBox tableNameComboBox;
private SwingWorker populateWorker; private SwingWorker populateWorker;
private static final ExecutorService SERVICE = Executors.newSingleThreadExecutor(new NamedThreadFactory("ChoosePaneThread"));
private PopupMenuListener popupMenuListener = new PopupMenuListener() { private PopupMenuListener popupMenuListener = new PopupMenuListener() {
@Override @Override
public void popupMenuWillBecomeVisible(PopupMenuEvent e) { public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
FutureTask<Void> task = new FutureTask<Void>(new Callable() { new Thread() {
@Override @Override
public Object call() { public void run() {
calculateTableDataNames(); calculateTableDataNames();
return null;
} }
}); }.start();
SERVICE.submit(task);
tableNameComboBox.setPreSearchTask(task);
} }
@Override @Override
@ -167,7 +157,7 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
schemaBox = new StringUIComboBox(); schemaBox = new StringUIComboBox();
schemaBox.setEditor(new ComboBoxEditor()); schemaBox.setEditor(new ComboBoxEditor());
tableNameComboBox = new SearchPreTaskTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false); tableNameComboBox = new FRTreeComboBox(new JTree(new DefaultMutableTreeNode()), tableNameTreeRenderer, false);
tableNameComboBox.setEditable(true); tableNameComboBox.setEditable(true);
tableNameComboBox.setRenderer(listCellRenderer); tableNameComboBox.setRenderer(listCellRenderer);
registerDSChangeListener(); registerDSChangeListener();

14
designer-base/src/main/java/com/fr/design/data/datapane/connect/DatabaseConnectionPane.java

@ -73,6 +73,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private UIComboBox charSetComboBox; private UIComboBox charSetComboBox;
private String originalCharSet = null; private String originalCharSet = null;
private JPanel mainPanel;
// Database pane // Database pane
public DatabaseConnectionPane() { public DatabaseConnectionPane() {
this.initComponents(); this.initComponents();
@ -248,7 +249,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override @Override
public void populateBean(com.fr.data.impl.Connection ob) { public void populateBean(com.fr.data.impl.Connection ob) {
populateSubDatabaseConnectionBean((E) ob); populateSubDatabaseConnectionBean((E) ob);
if (mainPanel() instanceof JDBCDefPane) { if (mainPanel instanceof JDBCDefPane) {
return; return;
} }
this.originalCharSet = ob.getOriginalCharsetName(); this.originalCharSet = ob.getOriginalCharsetName();
@ -264,7 +265,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
@Override @Override
public com.fr.data.impl.Connection updateBean() { public com.fr.data.impl.Connection updateBean() {
E ob = updateSubDatabaseConnectionBean(); E ob = updateSubDatabaseConnectionBean();
if (mainPanel() instanceof JDBCDefPane) { if (mainPanel instanceof JDBCDefPane) {
return ob; return ob;
} }
ob.setOriginalCharsetName(this.originalCharSet); ob.setOriginalCharsetName(this.originalCharSet);
@ -306,13 +307,14 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4)); testPane.setBorder(BorderFactory.createEmptyBorder(0, 0, 3, 4));
// Center // Center
northPane.add(mainPanel(), BorderLayout.CENTER); mainPanel = mainPanel();
northPane.add(mainPanel, BorderLayout.CENTER);
JPanel advancedPanel = FRGUIPaneFactory.createBorderLayout_L_Pane(); JPanel advancedPanel = FRGUIPaneFactory.createBorderLayout_L_Pane();
advancedPanel.setBorder(BorderFactory.createTitledBorder( advancedPanel.setBorder(BorderFactory.createTitledBorder(
new ModLineBorder(ModLineBorder.TOP), new ModLineBorder(ModLineBorder.TOP),
Toolkit.i18nText("Fine-Design_Basic_Advanced") Toolkit.i18nText("Fine-Design_Basic_Advanced")
)); ));
if (mainPanel() instanceof JDBCDefPane) { if (mainPanel instanceof JDBCDefPane) {
ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr")); ActionLabel actionLabel = new ActionLabel(Toolkit.i18nText("Fine-Design_Basic_ConnectionPool_Attr"));
actionLabel.addActionListener(new ActionListener() { actionLabel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent evt) { public void actionPerformed(ActionEvent evt) {
@ -340,7 +342,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
} }
private JDialog createJDialog() { private JDialog createJDialog() {
return JDBC.getAdvancedAttrPane() != null ? JDBC.getAdvancedAttrPane().showWindow(SwingUtilities.getWindowAncestor(mainPanel())) : null; return JDBC.getAdvancedAttrPane() != null ? JDBC.getAdvancedAttrPane().showWindow(SwingUtilities.getWindowAncestor(mainPanel)) : null;
} }
private void initDialogPane() { private void initDialogPane() {
@ -420,7 +422,7 @@ public abstract class DatabaseConnectionPane<E extends com.fr.data.impl.Connecti
private static JNDIDefPane jndiDefPane = new JNDIDefPane(); private static JNDIDefPane jndiDefPane = new JNDIDefPane();
@Override @Override
protected JPanel mainPanel() { protected JPanel mainPanel() {
return jndiDefPane; return jndiDefPane;
} }

23
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -51,9 +51,10 @@ public class JDBCDefPane extends JPanel {
public static final String DRIVER_TYPE = "driver_type"; public static final String DRIVER_TYPE = "driver_type";
public static final String USER_NAME = "user_name"; public static final String USER_NAME = "user_name";
private static final String OTHER_DB = "Others"; private static final String OTHER_DB = "Others";
private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE); private static final Pattern ORACLE_URL = Pattern.compile("^jdbc:oracle:thin:@[/]*([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?([:/](.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE); private static final Pattern GENERAL_URL = Pattern.compile("^jdbc:(mysql|sqlserver|db2|derby|postgresql|inceptor|inceptor2|hive2)://([-0-9a-zA-Z_\\.]+)(:([0-9]+|port))?((/|;DatabaseName=)(.*))?.*", Pattern.CASE_INSENSITIVE);
private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$"); private static final Pattern PORT = Pattern.compile("^0$|^[1-9][\\d]*[\\d]*$");
private static final Pattern CHAR_NEED_ESCAPE = Pattern.compile("[?|$^*\\\\\\[\\](){}.+]");
// 编码转换. // 编码转换.
private String originalCharSet = null; private String originalCharSet = null;
private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>(); private static Map<String, DriverURLName[]> jdbcMap = new HashMap<String, DriverURLName[]>();
@ -389,6 +390,9 @@ public class JDBCDefPane extends JPanel {
InputMethodListener portInputMethodListener = new InputMethodListener() { InputMethodListener portInputMethodListener = new InputMethodListener() {
@Override @Override
public void inputMethodTextChanged(InputMethodEvent event) { public void inputMethodTextChanged(InputMethodEvent event) {
if (null == event.getText()) {
return;
}
char ch = event.getText().current(); char ch = event.getText().current();
if (!(ch >= '0' && ch <= '9')) { if (!(ch >= '0' && ch <= '9')) {
event.consume(); event.consume();
@ -484,13 +488,13 @@ public class JDBCDefPane extends JPanel {
KeyListener portKeyListener = new KeyAdapter() { KeyListener portKeyListener = new KeyAdapter() {
@Override @Override
public void keyReleased(KeyEvent e) { public void keyReleased(KeyEvent e) {
String port = portTextField.getText().trim(); String port = portTextField.getText();
if (isPortValid(port)) { if (isPortValid(port)) {
updateURL(); updateURL();
} else { } else {
portTextField.setText(port.replaceAll(e.getKeyChar() + "", "")); portTextField.setText(port.replaceAll(getCharNeedReplace(e.getKeyChar()) , ""));
if (!isPortValid(portTextField.getText())) { if (!isPortValid(portTextField.getText())) {
portTextField.setText(""); portTextField.setText(StringUtils.EMPTY);
updateURL(); updateURL();
} }
} }
@ -501,6 +505,15 @@ public class JDBCDefPane extends JPanel {
return PORT.matcher(port).find(); return PORT.matcher(port).find();
} }
private String getCharNeedReplace(char c) {
String charNeedReplace = c + "";
Matcher matcher = CHAR_NEED_ESCAPE.matcher(charNeedReplace);
if (matcher.find()) {
charNeedReplace = "\\" + charNeedReplace;
}
return charNeedReplace;
}
DocumentListener updateURLListener = new DocumentListener() { DocumentListener updateURLListener = new DocumentListener() {
@Override @Override

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

@ -9,6 +9,7 @@ import java.awt.Font;
import java.net.URI; import java.net.URI;
import javax.swing.JEditorPane; import javax.swing.JEditorPane;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/** /**
* 用来构建JOptionPane带超链的消息提示 * 用来构建JOptionPane带超链的消息提示
@ -19,31 +20,45 @@ import javax.swing.event.HyperlinkEvent;
*/ */
public class MessageWithLink extends JEditorPane { public class MessageWithLink extends JEditorPane {
private static final UILabel LABEL = new UILabel();
public MessageWithLink(String message, String linkName, String link) { public MessageWithLink(String message, String linkName, String link) {
super("text/html", "<html><body style=\"" + getStyle() + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>"); this(message, linkName, link, LABEL.getBackground(), LABEL.getFont());
addHyperlinkListener(e -> {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(URI.create(link));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
});
setEditable(false);
setBorder(null);
} }
public MessageWithLink(String linkName, String link ) { public MessageWithLink(String linkName, String link ) {
this(StringUtils.EMPTY, linkName, link); this(StringUtils.EMPTY, linkName, link);
} }
private static StringBuilder getStyle() { public MessageWithLink(String message, String linkName, String link, Color color) {
// 构建和相同风格样式 this(message, linkName, link, color, LABEL.getFont());
UILabel label = new UILabel(); }
Font font = label.getFont();
Color color = label.getBackground(); public MessageWithLink(String message, String linkName, String link, Color color, Font font) {
super("text/html", "<html><body style=\"" + generateStyle(color, font) + "\">" + message + "<a href=\"" + link + "\">" + linkName + "</a>" + "</body></html>");
initListener(link);
setEditable(false);
setBorder(null);
}
protected void initListener(String link) {
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
try {
Desktop.getDesktop().browse(URI.create(link));
} catch (Exception exception) {
FineLoggerFactory.getLogger().error(exception.getMessage(), exception);
}
}
}
});
}
private static StringBuilder generateStyle(Color color, Font font) {
// 构建相同风格样式
StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";"); StringBuilder style = new StringBuilder("font-family:" + font.getFamily() + ";");
style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";"); style.append("font-weight:").append(font.isBold() ? "bold" : "normal").append(";");
style.append("font-size:").append(font.getSize()).append("pt;"); style.append("font-size:").append(font.getSize()).append("pt;");

8
designer-base/src/main/java/com/fr/design/gui/icombobox/SearchPreTaskTreeComboBox.java

@ -1,5 +1,6 @@
package com.fr.design.gui.icombobox; package com.fr.design.gui.icombobox;
import com.fr.design.ui.util.UIUtil;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.JTree; import javax.swing.JTree;
@ -64,7 +65,12 @@ public class SearchPreTaskTreeComboBox extends FRTreeComboBox {
// 任务执行后置空,否则会被别的操作重复触发 // 任务执行后置空,否则会被别的操作重复触发
setPreSearchTask(null); setPreSearchTask(null);
} }
search(); UIUtil.invokeLaterIfNeeded(new Runnable() {
@Override
public void run() {
search();
}
});
return null; return null;
} }
}.execute(); }.execute();

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

@ -4,7 +4,7 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.chart.exception.ChartNotFoundException; import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.DesignModelAdapter; import com.fr.design.DesignModelAdapter;
import com.fr.design.DesignState; import com.fr.design.DesignState;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;

29
designer-base/src/main/java/com/fr/design/mainframe/DesktopCardPane.java

@ -21,10 +21,16 @@ import javax.swing.JLayeredPane;
*/ */
public class DesktopCardPane extends BasicPane implements TargetModifiedListener { public class DesktopCardPane extends BasicPane implements TargetModifiedListener {
private static final int CONTENT_LAYER = 0;
private static final int TRANSPARENT_LAYER = 1;
private static final int LOADING_LAYER = 2;
private static final int FAILED_LAYER = 3;
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private JTemplate<?, ?> component; private JTemplate<?, ?> component;
private TransparentPane transparentPane = new TransparentPane(); private TransparentPane transparentPane = new TransparentPane();
private OpenLoadingPane loadingPane = new OpenLoadingPane(); private OpenLoadingPane loadingPane = new OpenLoadingPane();
private OpenFailedPane failedPane = new OpenFailedPane();
private JLayeredPane layeredPane = new JLayeredPane() { private JLayeredPane layeredPane = new JLayeredPane() {
@Override @Override
public void doLayout() { public void doLayout() {
@ -36,8 +42,9 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
protected DesktopCardPane() { protected DesktopCardPane() {
setLayout(new BorderLayout()); setLayout(new BorderLayout());
layeredPane.add(transparentPane, 1); layeredPane.add(transparentPane, TRANSPARENT_LAYER);
layeredPane.add(loadingPane, 2); layeredPane.add(failedPane, FAILED_LAYER);
add(layeredPane, BorderLayout.CENTER);
} }
protected void showJTemplate(final JTemplate<?, ?> jt) { protected void showJTemplate(final JTemplate<?, ?> jt) {
@ -53,7 +60,7 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
layeredPane.remove(component); layeredPane.remove(component);
} }
component = jt; component = jt;
layeredPane.add(component, 0); layeredPane.add(component, CONTENT_LAYER);
checkSavingAndOpening(jt); checkSavingAndOpening(jt);
add(layeredPane, BorderLayout.CENTER); add(layeredPane, BorderLayout.CENTER);
validate(); validate();
@ -69,18 +76,34 @@ public class DesktopCardPane extends BasicPane implements TargetModifiedListener
showCover(); showCover();
} else if (jt.isOpening()) { } else if (jt.isOpening()) {
showOpenStatus(); showOpenStatus();
} else if (jt.isOpenFailed()) {
showOpenFailedCover();
} else { } else {
hideCover(); hideCover();
} }
} }
/**
* 让loadingPane懒加载
*/
private void checkLoadingPane() {
if (layeredPane.getComponent(LOADING_LAYER) != loadingPane) {
layeredPane.add(loadingPane, LOADING_LAYER);
}
}
private void showOpenStatus() { private void showOpenStatus() {
DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().refreshUIToolBar();
DesignerFrameFileDealerPane.getInstance().stateChange(); DesignerFrameFileDealerPane.getInstance().stateChange();
EastRegionContainerPane.getInstance().updateAllPropertyPane(); EastRegionContainerPane.getInstance().updateAllPropertyPane();
checkLoadingPane();
layeredPane.moveToFront(loadingPane); layeredPane.moveToFront(loadingPane);
} }
public void showOpenFailedCover() {
layeredPane.moveToFront(failedPane);
}
public void showCover() { public void showCover() {
layeredPane.moveToFront(transparentPane); layeredPane.moveToFront(transparentPane);
DesignerContext.getDesignerFrame().refreshUIToolBar(); DesignerContext.getDesignerFrame().refreshUIToolBar();

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

@ -794,7 +794,7 @@ public class EastRegionContainerPane extends UIEastResizableContainer {
public void setEnabled(boolean isEnabled) { public void setEnabled(boolean isEnabled) {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
if (template != null) { if (template != null) {
this.isEnabled = isEnabled && !template.isOpening() && !template.isSaving(); this.isEnabled = isEnabled && template.checkEnable();
} else { } else {
this.isEnabled = isEnabled; this.isEnabled = isEnabled;
} }

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

@ -115,6 +115,7 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer(); protected TimeConsumeTimer consumeTimer = new TimeConsumeTimer();
private volatile boolean saving = false; private volatile boolean saving = false;
private volatile boolean opening = false; private volatile boolean opening = false;
private volatile boolean openFailed = false;
private PluginEventListener pluginListener; private PluginEventListener pluginListener;
@ -1585,8 +1586,16 @@ public abstract class JTemplate<T extends BaseBook, U extends BaseUndoState<?>>
this.opening = opening; this.opening = opening;
} }
public boolean isOpenFailed() {
return openFailed;
}
public void setOpenFailed(boolean openFailed) {
this.openFailed = openFailed;
}
public boolean checkEnable() { public boolean checkEnable() {
return !isSaving() && !isOpening(); return !isSaving() && !isOpening() && !isOpenFailed();
} }
} }

92
designer-base/src/main/java/com/fr/design/mainframe/OpenFailedPane.java

@ -0,0 +1,92 @@
package com.fr.design.mainframe;
import com.fr.design.dialog.link.MessageWithLink;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.general.IOUtils;
import com.fr.stable.StringUtils;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.LayoutManager;
import javax.swing.JPanel;
import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener;
/**
* @author hades
* @version 10.0
* Created by hades on 2021/4/20
*/
public class OpenFailedPane extends JPanel {
private UILabel label;
private MessageWithLink link;
public OpenFailedPane() {
this.setLayout(new LayoutManager() {
@Override
public void addLayoutComponent(String name, Component comp) {
}
@Override
public void removeLayoutComponent(Component comp) {
}
@Override
public Dimension preferredLayoutSize(Container parent) {
return parent.getPreferredSize();
}
@Override
public Dimension minimumLayoutSize(Container parent) {
return null;
}
@Override
public void layoutContainer(Container parent) {
int width = parent.getParent().getWidth();
int height = parent.getParent().getHeight();
int labelWidth = label.getPreferredSize().width;
int labelHeight = label.getPreferredSize().height;
int labelX = (width - labelWidth) / 2;
int labelY = (height - labelHeight) / 2;
int linkWidth = link.getPreferredSize().width;
int linkHeight = link.getPreferredSize().height;
int linkX = (width - linkWidth) / 2;
int linkY = (height - labelHeight) / 2 + labelHeight;
label.setBounds(labelX, labelY, labelWidth, labelHeight);
link.setBounds(linkX, linkY, linkWidth, linkHeight);
}
});
this.setBackground(Color.WHITE);
label = new UILabel(IOUtils.readIcon("/com/fr/design/images/mainframe/open_failed.png"), UILabel.CENTER);
link = new MessageWithLink(Toolkit.i18nText("Fine-Design_Open_Failed_Tip"), Toolkit.i18nText("Fine-Design_Open_Failed_Retry"), StringUtils.EMPTY, Color.WHITE) {
@Override
protected void initListener(String link) {
addHyperlinkListener(new HyperlinkListener() {
@Override
public void hyperlinkUpdate(HyperlinkEvent e) {
if (e.getEventType().equals(HyperlinkEvent.EventType.ACTIVATED)) {
// 重试
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
template = JTemplateFactory.createJTemplate(template.getEditingFILE());
DesignerContext.getDesignerFrame().addAndActivateJTemplate(template);
HistoryTemplateListCache.getInstance(). setCurrentEditingTemplate(template);
}
}
});
}
};
link.setBackground(Color.WHITE);
this.add(label);
this.add(link);
}
}

5
designer-base/src/main/java/com/fr/design/mainframe/OpenLoadingPane.java

@ -1,7 +1,6 @@
package com.fr.design.mainframe; package com.fr.design.mainframe;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.general.IOUtils;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
import java.awt.Container; import java.awt.Container;
@ -17,6 +16,8 @@ import javax.swing.JPanel;
*/ */
public class OpenLoadingPane extends JPanel { public class OpenLoadingPane extends JPanel {
private static final ImageIcon LOADING_ICON = new ImageIcon(OpenLoadingPane.class.getResource("/com/fr/design/images/mainframe/loading.gif"));
private UILabel loadingLabel; private UILabel loadingLabel;
public OpenLoadingPane() { public OpenLoadingPane() {
@ -53,7 +54,7 @@ public class OpenLoadingPane extends JPanel {
} }
}); });
setBackground(Color.WHITE); setBackground(Color.WHITE);
loadingLabel = new UILabel(new ImageIcon(IOUtils.readImage("com/fr/plugin/chart/vanchart/export/loading.png"))); loadingLabel = new UILabel(LOADING_ICON);
add(loadingLabel); add(loadingLabel);
} }

2
designer-base/src/main/java/com/fr/design/menu/MenuDef.java

@ -411,7 +411,7 @@ public class MenuDef extends ShortCut {
JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate(); JTemplate<?, ?> template = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate();
boolean flag = true; boolean flag = true;
if (template != null) { if (template != null) {
flag = !template.isSaving() && !template.isOpening(); flag = template.checkEnable();
} }
component.setEnabled(flag); component.setEnabled(flag);
if (!flag) { if (!flag) {

47
designer-base/src/main/java/com/fr/design/worker/open/OpenWorker.java

@ -1,19 +1,26 @@
package com.fr.design.worker.open; package com.fr.design.worker.open;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.DesignerFrameFileDealerPane; import com.fr.design.mainframe.DesignerFrameFileDealerPane;
import com.fr.design.mainframe.EastRegionContainerPane; import com.fr.design.mainframe.EastRegionContainerPane;
import com.fr.design.mainframe.JTemplate; import com.fr.design.mainframe.JTemplate;
import com.fr.design.worker.WorkerManager; import com.fr.design.worker.WorkerManager;
import com.fr.exception.DecryptTemplateException;
import com.fr.file.FILE; import com.fr.file.FILE;
import com.fr.general.ComparatorUtils; import com.fr.general.ComparatorUtils;
import com.fr.log.FineLoggerFactory; import com.fr.log.FineLoggerFactory;
import javax.swing.JOptionPane;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import java.util.concurrent.Callable; import java.util.concurrent.Callable;
import java.util.concurrent.CancellationException; import java.util.concurrent.CancellationException;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException; import java.util.concurrent.TimeoutException;
import javax.swing.SwingWorker;
/** /**
* 模板打开的worker * 模板打开的worker
@ -54,11 +61,34 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
result = get(); result = get();
} catch (CancellationException ignored) { } catch (CancellationException ignored) {
return; return;
} catch (Exception e) { } catch (Throwable t) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); processFailed();
Throwable cause = t.getCause();
if (cause instanceof DecryptTemplateException) {
FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Encrypt_Decrypt_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon")
);
}
if (cause instanceof ChartNotFoundException) {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design_Chart_Not_Found_Exception"),
Toolkit.i18nText("Fine-Design_Basic_Error"),
JOptionPane.ERROR_MESSAGE,
UIManager.getIcon("OptionPane.errorIcon"));
}
FineLoggerFactory.getLogger().error(t.getMessage(), t);
return;
} }
this.template.setOpening(false);
// 后续动作 // 后续动作
processResult();
}
private void processResult() {
this.template.setOpening(false);
if (slowly && templateCallable != null) { if (slowly && templateCallable != null) {
try { try {
JTemplate<?, ?> book = templateCallable.call(); JTemplate<?, ?> book = templateCallable.call();
@ -89,6 +119,15 @@ public class OpenWorker<T> extends SwingWorker<T, Void> {
WorkerManager.getInstance().removeWorker(taskName); WorkerManager.getInstance().removeWorker(taskName);
} }
private void processFailed() {
this.template.setOpenFailed(true);
this.template.setOpening(false);
DesignerContext.getDesignerFrame().getCenterTemplateCardPane().showOpenFailedCover();
DesignerFrameFileDealerPane.getInstance().stateChange();
WorkerManager.getInstance().removeWorker(taskName);
}
public void addCallBack(Callable<JTemplate<?, ?>> templateCallable) { public void addCallBack(Callable<JTemplate<?, ?>> templateCallable) {
this.templateCallable = templateCallable; this.templateCallable = templateCallable;
} }

6
designer-base/src/main/java/com/fr/design/worker/save/SaveWorker.java

@ -52,13 +52,19 @@ public class SaveWorker extends SwingWorker<Boolean, Void> {
try { try {
success = get(); success = get();
} catch (Exception e) { } catch (Exception e) {
processResult();
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineJOptionPane.showMessageDialog( FineJOptionPane.showMessageDialog(
DesignerContext.getDesignerFrame(), DesignerContext.getDesignerFrame(),
Toolkit.i18nText("Fine-Design-Basic_Save_Failure"), Toolkit.i18nText("Fine-Design-Basic_Save_Failure"),
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Tool_Tips"),
JOptionPane.ERROR_MESSAGE); JOptionPane.ERROR_MESSAGE);
return;
} }
processResult();
}
private void processResult() {
this.template.setSaving(false); this.template.setSaving(false);
// 恢复界面 // 恢复界面
if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) { if (slowly && ComparatorUtils.equals(this.template.getName(), HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getName())) {

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

@ -155,7 +155,7 @@ public abstract class BaseDesigner extends ToolBarMenuDock {
isException = true;//此时有文件nullpointer异常,执行打开空文件 isException = true;//此时有文件nullpointer异常,执行打开空文件
} }
} }
if (file.exists() && !isException) { if (file != null && file.exists() && !isException) {
df.openTemplate(file); df.openTemplate(file);
} else { } else {
df.addAndActivateJTemplate(); df.addAndActivateJTemplate();

12
designer-base/src/main/resources/com/fr/design/images/m_file/preview_disabled.svg

@ -1,11 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<svg width="16px" height="16px" viewBox="0 0 12 14" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <svg width="16px" height="16px" viewBox="0 0 16 16" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>icon_报表web属性_打印预览_normal</title> <title>icon_预览_disabled</title>
<g id="Symbols" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.3"> <g id="icon_预览_disabled" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd" opacity="0.3">
<g id="工具栏/导入数据集" transform="translate(-116.000000, -7.000000)" fill="#333334"> <path d="M9.5,7 C11.432875,7 13,8.567125 13,10.5 C13,11.1075915 12.845147,11.679042 12.5727578,12.1770349 C12.6203353,12.2075319 12.6650188,12.2450114 12.7069,12.287 L13.7129,13.293 C14.1039,13.684 14.1039,14.316 13.7129,14.707 C13.5179,14.902 13.2619,15 13.0059,15 C12.7499,15 12.4939,14.902 12.2989,14.707 L11.2929,13.701 C11.251507,13.6597129 11.2144961,13.6157024 11.1818672,13.5695439 C10.6844106,13.8436886 10.110446,14 9.5,14 C7.567125,14 6,12.432875 6,10.5 C6,8.567125 7.567125,7 9.5,7 Z M10,1 L14,5 L14,8 L13,8 L13,6 L9,6 L9,2 L3,2 L3,14 L7,14 L7,15 L2,15 L2,1 L10,1 Z M9.5,8 C10.8783333,8 12,9.12166667 12,10.5 C12,11.8783333 10.8783333,13 9.5,13 C8.12166667,13 7,11.8783333 7,10.5 C7,9.12166667 8.12166667,8 9.5,8 Z M12.587,5 L10,2.414 L10,5 L12.587,5 Z" id="Combined-Shape" fill="#333334"></path>
<g id="icon_报表web属性_打印预览_normal" transform="translate(114.000000, 6.000000)">
<path d="M9.5,7 C11.432875,7 13,8.567125 13,10.5 C13,11.1075915 12.845147,11.679042 12.5727578,12.1770349 C12.6203353,12.2075319 12.6650188,12.2450114 12.7069,12.287 L13.7129,13.293 C14.1039,13.684 14.1039,14.316 13.7129,14.707 C13.5179,14.902 13.2619,15 13.0059,15 C12.7499,15 12.4939,14.902 12.2989,14.707 L11.2929,13.701 C11.251507,13.6597129 11.2144961,13.6157024 11.1818672,13.5695439 C10.6844106,13.8436886 10.110446,14 9.5,14 C7.567125,14 6,12.432875 6,10.5 C6,8.567125 7.567125,7 9.5,7 Z M10,1 L14,5 L14,8 L13,8 L13,6 L9,6 L9,2 L3,2 L3,14 L7,14 L7,15 L2,15 L2,1 L10,1 Z M9.5,8 C10.8783333,8 12,9.12166667 12,10.5 C12,11.8783333 10.8783333,13 9.5,13 C8.12166667,13 7,11.8783333 7,10.5 C7,9.12166667 8.12166667,8 9.5,8 Z M12.587,5 L10,2.414 L10,5 L12.587,5 Z" id="Combined-Shape"></path>
</g>
</g>
</g> </g>
</svg> </svg>

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

BIN
designer-base/src/main/resources/com/fr/design/images/mainframe/loading.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

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

@ -3,9 +3,9 @@ package com.fr.design.mainframe.app;
import com.fr.base.BaseUtils; import com.fr.base.BaseUtils;
import com.fr.base.Style; import com.fr.base.Style;
import com.fr.base.TempNameStyle; import com.fr.base.TempNameStyle;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
import com.fr.chart.exception.ChartNotFoundException;
import com.fr.config.ServerPreferenceConfig; import com.fr.config.ServerPreferenceConfig;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.actions.server.StyleListAction; import com.fr.design.actions.server.StyleListAction;

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

@ -1,9 +1,9 @@
package com.fr.design.mainframe.app; package com.fr.design.mainframe.app;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.extension.FileExtension; import com.fr.base.extension.FileExtension;
import com.fr.base.frpx.exception.FRPackageRunTimeException; import com.fr.base.frpx.exception.FRPackageRunTimeException;
import com.fr.base.frpx.exception.InvalidWorkBookException; import com.fr.base.frpx.exception.InvalidWorkBookException;
import com.fr.chart.exception.ChartNotFoundException;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.exception.DecryptTemplateException; import com.fr.exception.DecryptTemplateException;
import com.fr.exception.RemoteDesignPermissionDeniedException; import com.fr.exception.RemoteDesignPermissionDeniedException;

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

@ -1,8 +1,8 @@
package com.fr.design.mainframe.app; package com.fr.design.mainframe.app;
import com.fr.base.Parameter; import com.fr.base.Parameter;
import com.fr.base.chart.exception.ChartNotFoundException;
import com.fr.base.io.XMLEncryptUtils; import com.fr.base.io.XMLEncryptUtils;
import com.fr.chart.exception.ChartNotFoundException;
import com.fr.design.DesignerEnvManager; import com.fr.design.DesignerEnvManager;
import com.fr.design.i18n.Toolkit; import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.AbstractAppProvider; import com.fr.design.mainframe.AbstractAppProvider;

Loading…
Cancel
Save