Browse Source

REPORT-85754 fix:参考cpt图表的类似写法,引入焦点丢失事件

release/11.0
Carlson 2 years ago
parent
commit
fcd0863d29
  1. 98
      designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java
  2. 18
      designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java
  3. 17
      designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java
  4. 18
      designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java
  5. 11
      designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java

98
designer-base/src/main/java/com/fr/design/gui/controlpane/UIControlPane.java

@ -31,7 +31,6 @@ import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
@ -241,51 +240,12 @@ public abstract class UIControlPane extends JControlPane {
}
private void hideDialog() {
// 检查是否有子弹窗,如果有,则不隐藏
for (Window window : getOwnedWindows()) {
if (window.isVisible()) {
return;
}
}
// 如果有可见模态对话框,则不隐藏
for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
return;
}
}
try {
//没有指定owner的弹出框用的是SwingUtilities.getSharedOwnerFrame()
Frame sharedOwnerFrame = Reflect.on(SwingUtilities.class).call("getSharedOwnerFrame").get();
for (Window window : sharedOwnerFrame.getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
// 如果有可见模态对话框,则不隐藏
return;
}
}
} catch (Exception ignore) {
//do nothing
}
// 要隐藏 先检查有没有非法输入
// 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框
try {
checkValid();
} catch (Exception exp) {
// 存在非法输入 拒绝隐藏
this.setAlwaysOnTop(true);
FineJOptionPane.showMessageDialog(this, exp.getMessage());
this.requestFocus();
return;
}
if (JavaFxNativeFileChooser.isShowDialogState()) {
JavaFxNativeFileChooser.setShowDialogState(false);
return;
if (needToHidePopupEditDialog()) {
saveSettings();
setVisible(false);
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class);
saveAction.unregister();
}
saveSettings();
setVisible(false);
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class);
saveAction.unregister();
}
private void initListener() {
@ -302,6 +262,54 @@ public abstract class UIControlPane extends JControlPane {
}
}
/**
* 是否需要隐藏popupEditDialog
*/
protected boolean needToHidePopupEditDialog() {
// 检查是否有子弹窗,如果有,则不隐藏
for (Window window : popupEditDialog.getOwnedWindows()) {
if (window.isVisible()) {
return false;
}
}
// 如果有可见模态对话框,则不隐藏
for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
return false;
}
}
try {
//没有指定owner的弹出框用的是SwingUtilities.getSharedOwnerFrame()
Frame sharedOwnerFrame = Reflect.on(SwingUtilities.class).call("getSharedOwnerFrame").get();
for (Window window : sharedOwnerFrame.getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
// 如果有可见模态对话框,则不隐藏
return false;
}
}
} catch (Exception ignore) {
//do nothing
}
// 要隐藏 先检查有没有非法输入
// 非法输入检查放在最后,因为可能出现面板弹出新弹框而失去焦点的情况,比如 输入公式时,弹出公式编辑对话框
try {
checkValid();
} catch (Exception exp) {
// 存在非法输入 拒绝隐藏
popupEditDialog.setAlwaysOnTop(true);
FineJOptionPane.showMessageDialog(this, exp.getMessage());
popupEditDialog.requestFocus();
return false;
}
if (JavaFxNativeFileChooser.isShowDialogState()) {
JavaFxNativeFileChooser.setShowDialogState(false);
return false;
}
return true;
}
// 移动弹出编辑面板的工具条
private class PopupToolPane extends JPanel {
private JDialog parentDialog; // 如果不在对话框中,值为null

18
designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

@ -24,23 +24,21 @@ import com.fr.design.javascript.jsapi.JSImplUpdateAction;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.mainframe.DesignerContext;
import com.fr.general.IOUtils;
import com.fr.js.JavaScriptImpl;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
import java.awt.BorderLayout;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Window;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import javax.swing.JPanel;
import javax.swing.KeyStroke;
import javax.swing.SwingConstants;
import javax.swing.SwingWorker;
public class JSContentPane extends BasicPane {
protected RSyntaxTextArea contentTextArea;
@ -55,7 +53,6 @@ public class JSContentPane extends BasicPane {
private JSImplUpdateAction jsImplUpdateAction;
private JSImplPopulateAction jsImplPopulateAction;
private boolean modal;
private Window parentWindow;
BasicDialog advancedEditorDialog ;
public JSContentPane(){}
@ -124,9 +121,6 @@ public class JSContentPane extends BasicPane {
super.doCancel();
}
},new Dimension(900,800));
if (parentWindow != null) {
parentWindow.setVisible(false);
}
advancedEditorDialog.setModal(modal);
advancedEditorDialog.setResizable(true);
advancedEditorDialog.pack();
@ -138,10 +132,6 @@ public class JSContentPane extends BasicPane {
labelPane.add(advancedEditorLabel,BorderLayout.EAST);
}
public void setParentWindow(Window parentWindow) {
this.parentWindow = parentWindow;
}
protected UIScrollPane createContentTextAreaPanel(){
contentTextArea = new RSyntaxTextArea();
contentTextArea.setCloseCurlyBraces(true);

17
designer-base/src/main/java/com/fr/design/javascript/JavaScriptImplPane.java

@ -14,22 +14,18 @@ import com.fr.design.javascript.jsapi.JSImplUpdateAction;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.scrollruler.ModLineBorder;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.js.JavaScriptImpl;
import com.fr.stable.ParameterProvider;
import com.fr.stable.StringUtils;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;
import javax.swing.BorderFactory;
import javax.swing.JPanel;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import java.awt.Window;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridLayout;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@ -50,7 +46,6 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
public JavaScriptImplPane(HashMap hyperLinkEditorMap, boolean needRenamePane) {
super(hyperLinkEditorMap, needRenamePane);
this.defaultArgs = new String[0];
this.modal = true;
initComponents();
}
@ -151,10 +146,6 @@ public class JavaScriptImplPane extends AbstractHyperLinkPane<JavaScriptImpl> {
return importedJsPane;
}
public void setParentWindow4ContentPane(Window parentWindow) {
jsPane.setParentWindow(parentWindow);
}
/**
* 参数改变
*

18
designer-chart/src/main/java/com/fr/van/chart/custom/component/VanChartHyperLinkPane.java

@ -39,6 +39,8 @@ import com.fr.stable.Nameable;
import com.fr.stable.bridge.StableFactory;
import com.fr.van.chart.designer.component.VanChartUIListControlPane;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
@ -77,11 +79,7 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane {
Constructor<? extends BasicBeanPane> constructor = null;
try {
constructor = creator.getUpdatePane().getConstructor(HashMap.class, boolean.class);
BasicBeanPane pane = constructor.newInstance(getHyperLinkEditorMap(), false);
if (pane instanceof JavaScriptImplPane) {
((JavaScriptImplPane) pane).setParentWindow4ContentPane(getPopupEditDialog());
}
return pane;
return constructor.newInstance(getHyperLinkEditorMap(), false);
} catch (InstantiationException | IllegalAccessException | InvocationTargetException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -190,6 +188,16 @@ public class VanChartHyperLinkPane extends VanChartUIListControlPane {
}
this.populate(nameObjects.toArray(new NameObject[nameObjects.size()]));
if (popupEditDialog instanceof HyperDialog) {
popupEditDialog.addWindowFocusListener(new WindowAdapter() {
@Override
public void windowLostFocus(WindowEvent e) {
if (needToHidePopupEditDialog()) {
popupEditDialog.setVisible(false);
}
}
});
}
doLayout();
}

11
designer-realize/src/main/java/com/fr/design/condition/HyperlinkPane.java

@ -9,12 +9,16 @@ import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.mainframe.DesignerContext;
import com.fr.design.mainframe.HyperlinkGroupPaneActionImpl;
import com.fr.js.*;
import com.fr.js.EmailJavaScript;
import com.fr.js.JavaScript;
import com.fr.js.JavaScriptImpl;
import com.fr.js.NameJavaScriptGroup;
import com.fr.js.ReportletHyperlink;
import com.fr.js.WebHyperlink;
import com.fr.report.cell.cellattr.highlight.HighlightAction;
import com.fr.report.cell.cellattr.highlight.HyperlinkHighlightAction;
import javax.swing.*;
import javax.swing.SwingUtilities;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -47,6 +51,7 @@ public class HyperlinkPane extends ConditionAttrSingleConditionPane<HighlightAct
setText();
}
});
dialog.setModal(false);
dialog.setVisible(true);
}
});

Loading…
Cancel
Save