Browse Source

Merge pull request #5794 in DESIGN/design from feature/10.0 to research/10.0

* commit '7251580650872d3b5593a8fec3f7b20320cd6c73':
  v7打开调试窗口失败的问题
  还原范围
  CHART-20642 图表预定义配色避免重名和空字符串名
  新接口
  新接口
  REPORT-59099 给帮助文档的网址补上默认值
  CHART-20402 增加几个接口
  CHART-20402 增加几个接口
  CHART-20402 增加几个接口
research/10.0
superman 3 years ago
parent
commit
9c0facd60d
  1. 2
      designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java
  2. 2
      designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java
  3. 23
      designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java
  4. 38
      designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java
  5. 2
      designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java
  6. 19
      designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java
  7. 53
      designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java
  8. 41
      designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java

2
designer-base/src/main/java/com/fr/design/actions/help/TutorialAction.java

@ -28,7 +28,7 @@ public class TutorialAction extends AbstractDesignerSSO {
@Override
public String getJumpUrl() {
return CloudCenter.getInstance().acquireUrlByKind(createDocKey());
return CloudCenter.getInstance().acquireUrlByKind(createDocKey(), "http://help.finereport.com");
}
public String getOffLineWarnMessage() {

2
designer-base/src/main/java/com/fr/design/gui/controlpane/JListControlPane.java

@ -23,12 +23,12 @@ import javax.swing.ListSelectionModel;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.util.Collection;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.Collection;
public abstract class JListControlPane extends JControlPane implements ListControlPaneProvider {
private static final String LIST_NAME = "JControl_List";

23
designer-base/src/main/java/com/fr/design/gui/ilist/JNameEdList.java

@ -1,25 +1,22 @@
package com.fr.design.gui.ilist;
import com.fr.design.gui.NameInspector;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.general.GeneralUtils;
import com.fr.general.NameObject;
import com.fr.base.Utils;
import com.fr.design.gui.itextfield.UITextField;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import com.fr.stable.core.PropertyChangeAdapter;
import javax.swing.*;
import javax.swing.ListModel;
import javax.swing.event.CellEditorListener;
import javax.swing.event.ChangeEvent;
import java.awt.*;
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 java.util.Vector;
import java.awt.Component;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
public class JNameEdList extends UIList implements CellEditorListener {
private static final int ICON_WIDTH = 20;
@ -38,6 +35,8 @@ public class JNameEdList extends UIList implements CellEditorListener {
*/
private String oldName;
private boolean replaceEmptyName = true;
public JNameEdList(ListModel dataModel) {
super(dataModel);
}
@ -70,6 +69,10 @@ public class JNameEdList extends UIList implements CellEditorListener {
return this.editable;
}
public void setReplaceEmptyName(boolean replaceEmptyName) {
this.replaceEmptyName = replaceEmptyName;
}
public void setNameShouldNumber(boolean isNameShouldNumber) {
this.isNameShouldNumber = isNameShouldNumber;
}
@ -301,7 +304,7 @@ public class JNameEdList extends UIList implements CellEditorListener {
ListCellEditor editor = getCellEditor();
if (editor != null && editorComp != null) {
Object value = editor.getCellEditorValue();
String name = StringUtils.isBlank(value.toString()) ? oldName : value.toString();
String name = StringUtils.isBlank(value.toString()) && replaceEmptyName ? oldName : value.toString();
setNameAt(name, editingIndex);
removeComp();
doAfterStopEditing();

38
designer-base/src/main/java/com/fr/design/ui/ModernUIPane.java

@ -11,12 +11,14 @@ import com.fr.web.struct.AssembleComponent;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.Browser;
import com.teamdev.jxbrowser.chromium.BrowserType;
import com.teamdev.jxbrowser.chromium.JSObject;
import com.teamdev.jxbrowser.chromium.JSValue;
import com.teamdev.jxbrowser.chromium.events.LoadListener;
import com.teamdev.jxbrowser.chromium.events.ScriptContextAdapter;
import com.teamdev.jxbrowser.chromium.events.ScriptContextEvent;
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.chromium.swing.BrowserView;
import com.teamdev.jxbrowser.event.Observer;
import javax.swing.JDialog;
import javax.swing.SwingUtilities;
@ -157,6 +159,36 @@ public class ModernUIPane<T> extends BasicPane {
return null;
}
public void disposeBrowser() {
if(browser != null) {
browser.dispose();
browser = null;
}
}
public void clearCache() {
if (browser != null) {
browser.getCacheStorage().clearCache();
}
}
public void executeJavaScript(String javaScript) {
if (browser != null) {
browser.executeJavaScript(javaScript);
}
}
public JSObject getEmptyJSObjectV6() {
if (browser != null) {
return browser.executeJavaScriptAndReturnValue("var __empty_props__ = {};__empty_props__").asObject();
}
return null;
}
public static class Builder<T> implements BuilderDiff<T> {
private ModernUIPane<T> pane;
@ -293,6 +325,12 @@ public class ModernUIPane<T> extends BasicPane {
return this;
}
@Override
public Builder<T> prepareForV7(Class event, Observer listener) {
// do nothing
return this;
}
public ModernUIPane<T> build() {
return pane;
}

2
designer-base/src/main/java/com/fr/design/ui/compatible/BuilderDiff.java

@ -4,6 +4,7 @@ import com.fr.design.ui.ModernUIPane;
import com.teamdev.jxbrowser.browser.callback.InjectJsCallback;
import com.teamdev.jxbrowser.chromium.events.LoadListener;
import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.event.Observer;
/**
* 封装jxbrwoser v6/v7的构建方式的差异
@ -20,5 +21,6 @@ public interface BuilderDiff<T> {
ModernUIPane.Builder<T> prepareForV7(InjectJsCallback callback);
ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener);
}

19
designer-base/src/main/java/com/fr/design/ui/compatible/ModernUIPaneFactory.java

@ -11,6 +11,17 @@ import com.fr.stable.os.OperatingSystem;
public class ModernUIPaneFactory {
public static <T> ModernUIPane.Builder<T> modernUIPaneBuilder() {
if (isV7()) {
return new NewModernUIPane.Builder<>();
} else {
return new ModernUIPane.Builder<>();
}
}
public static boolean isV7() {
// 7.15的class不存在时 走老版本
boolean hasJxBrowserV7_15 = true;
try {
@ -18,10 +29,8 @@ public class ModernUIPaneFactory {
} catch (ClassNotFoundException e) {
hasJxBrowserV7_15 = false;
}
if (OperatingSystem.isWindows() && hasJxBrowserV7_15) {
return new NewModernUIPane.Builder<>();
} else {
return new ModernUIPane.Builder<>();
}
return OperatingSystem.isWindows() && hasJxBrowserV7_15;
}
}

53
designer-base/src/main/java/com/fr/design/ui/compatible/NewModernUIPane.java

@ -15,6 +15,7 @@ import com.teamdev.jxbrowser.chromium.events.ScriptContextListener;
import com.teamdev.jxbrowser.engine.Engine;
import com.teamdev.jxbrowser.engine.EngineOptions;
import com.teamdev.jxbrowser.engine.RenderingMode;
import com.teamdev.jxbrowser.event.Observer;
import com.teamdev.jxbrowser.js.JsObject;
import com.teamdev.jxbrowser.net.Scheme;
import com.teamdev.jxbrowser.view.swing.BrowserView;
@ -80,30 +81,33 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
private void showDebuggerDialog() {
JDialog dialog = new JDialog(SwingUtilities.getWindowAncestor(this));
Engine engine = Engine.newInstance(
EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED)
.addSwitch("--disable-google-traffic")
.remoteDebuggingPort(9222).build());
Browser debugger = engine.newBrowser();
Browser debugger = browser.engine().newBrowser();
BrowserView debuggerView = BrowserView.newInstance(debugger);
dialog.add(debuggerView, BorderLayout.CENTER);
dialog.setSize(new Dimension(800, 400));
GUICoreUtils.centerWindow(dialog);
dialog.setVisible(true);
dialog.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
browser.devTools().remoteDebuggingUrl().ifPresent(url -> {
debugger.navigation().loadUrl(url);
});
}
private void initializeBrowser() {
EngineOptions options;
EngineOptions.Builder builder;
if (scheme != null && requestCallback != null) {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback).build();
builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").addScheme(scheme, requestCallback);
} else {
options = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic").build();
builder = EngineOptions.newBuilder(RenderingMode.HARDWARE_ACCELERATED).addSwitch("--disable-google-traffic");
}
if (DesignerEnvManager.getEnvManager().isOpenDebug()) {
builder.remoteDebuggingPort(9222);
}
Engine engine = Engine.newInstance(options);
Engine engine = Engine.newInstance(builder.build());
browser = engine.newBrowser();
// 初始化的时候,就把命名空间对象初始化好,确保window.a.b.c("a.b.c"为命名空间)对象都是初始化过的
@ -161,6 +165,29 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
return null;
}
public void disposeBrowser() {
if (browser != null) {
browser.close();
browser = null;
}
}
public void clearCache() {
if (browser != null) {
browser.engine().httpCache().clear();
}
}
public void executeJavaScript(String javaScript) {
if (browser != null) {
browser.mainFrame().ifPresent(frame -> {
frame.executeJavaScript(javaScript);
});
}
}
public static class Builder<T> extends ModernUIPane.Builder<T> {
private NewModernUIPane<T> pane = new NewModernUIPane<>();
@ -301,6 +328,14 @@ public class NewModernUIPane<T> extends ModernUIPane<T> {
return prepare(callback);
}
@Override
public ModernUIPane.Builder<T> prepareForV7(Class event, Observer listener) {
pane.browser.navigation().on(event, listener);
return this;
}
@Override
public NewModernUIPane<T> build() {
return pane;

41
designer-chart/src/main/java/com/fr/design/module/ChartPreStyleListPane.java

@ -4,19 +4,28 @@ import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.base.Utils;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.gui.controlpane.JListControlPane;
import com.fr.design.gui.controlpane.NameObjectCreator;
import com.fr.design.gui.controlpane.NameableCreator;
import com.fr.design.gui.controlpane.ShortCut4JControlPane;
import com.fr.design.gui.ilist.JNameEdList;
import com.fr.design.gui.ilist.ModNameActionListener;
import com.fr.design.i18n.Toolkit;
import com.fr.design.menu.ShortCut;
import com.fr.general.ComparatorUtils;
import com.fr.general.NameObject;
import com.fr.stable.Nameable;
import com.fr.stable.StringUtils;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
/**
* @author Bjorn
@ -31,6 +40,38 @@ public class ChartPreStyleListPane extends JListControlPane {
super();
this.chartPreStyleManagerPane = chartPreStyleManagerPane;
initListener();
addModNameActionListener((int index, String oldName, String newName) -> {
if (ComparatorUtils.equals(oldName, newName)) {
return;
}
String[] allNames = nameableList.getAllNames();
allNames[index] = StringUtils.EMPTY;
if (StringUtils.isEmpty(newName)) {
showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Empty_Name_Tip"));
nameableList.setNameAt(oldName, index);
return;
}
if (isNameRepeated(new List[]{Arrays.asList(allNames)}, newName)) {
showTipDialog(Toolkit.i18nText("Fine-Design_Chart_Fill_Style_Exist_Name_Tip", newName));
nameableList.setNameAt(oldName, index);
return;
}
populateSelectedValue();
});
}
private void showTipDialog(String content) {
FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(ChartPreStyleListPane.this),
content,
Toolkit.i18nText("Fine-Design_Basic_Alert"),
JOptionPane.WARNING_MESSAGE);
}
@Override
protected JNameEdList createJNameList() {
JNameEdList jNameList = super.createJNameList();
jNameList.setReplaceEmptyName(false);
return jNameList;
}
/**

Loading…
Cancel
Save