Browse Source

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

newui
Carlson 2 years ago
parent
commit
fcd0863d29
  1. 62
      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

62
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,16 +240,42 @@ public abstract class UIControlPane extends JControlPane {
}
private void hideDialog() {
if (needToHidePopupEditDialog()) {
saveSettings();
setVisible(false);
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class);
saveAction.unregister();
}
}
private void initListener() {
addWindowFocusListener(new WindowAdapter() {
@Override
public void windowLostFocus(WindowEvent e) {
//在Linux上拉回焦点,不然导致一些面板关不掉
if(OperatingSystem.isLinux()) {
requestFocus();
}
hideDialog();
}
});
}
}
/**
* 是否需要隐藏popupEditDialog
*/
protected boolean needToHidePopupEditDialog() {
// 检查是否有子弹窗,如果有,则不隐藏
for (Window window : getOwnedWindows()) {
for (Window window : popupEditDialog.getOwnedWindows()) {
if (window.isVisible()) {
return;
return false;
}
}
// 如果有可见模态对话框,则不隐藏
for (Window window : DesignerContext.getDesignerFrame().getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
return;
return false;
}
}
@ -260,7 +285,7 @@ public abstract class UIControlPane extends JControlPane {
for (Window window : sharedOwnerFrame.getOwnedWindows()) {
if (window instanceof JDialog && window.isVisible() && ((JDialog) window).isModal()) {
// 如果有可见模态对话框,则不隐藏
return;
return false;
}
}
} catch (Exception ignore) {
@ -273,33 +298,16 @@ public abstract class UIControlPane extends JControlPane {
checkValid();
} catch (Exception exp) {
// 存在非法输入 拒绝隐藏
this.setAlwaysOnTop(true);
popupEditDialog.setAlwaysOnTop(true);
FineJOptionPane.showMessageDialog(this, exp.getMessage());
this.requestFocus();
return;
popupEditDialog.requestFocus();
return false;
}
if (JavaFxNativeFileChooser.isShowDialogState()) {
JavaFxNativeFileChooser.setShowDialogState(false);
return;
}
saveSettings();
setVisible(false);
PopupDialogSaveAction saveAction = OSSupportCenter.getAction(PopupDialogSaveAction.class);
saveAction.unregister();
}
private void initListener() {
addWindowFocusListener(new WindowAdapter() {
@Override
public void windowLostFocus(WindowEvent e) {
//在Linux上拉回焦点,不然导致一些面板关不掉
if(OperatingSystem.isLinux()) {
requestFocus();
}
hideDialog();
}
});
return false;
}
return true;
}
// 移动弹出编辑面板的工具条

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