Browse Source

Merge branch 'release/10.0' of https://code.fineres.com/scm/~qinghui.liu/design into release/10.0

feature/big-screen
Qinghui.Liu 4 years ago
parent
commit
c5005dda87
  1. 8
      .gitignore
  2. 82
      build.gradle
  3. 43
      designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java
  4. 9
      designer-base/src/main/java/com/fr/design/actions/file/SwitchExistEnv.java
  5. 3
      designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java
  6. 31
      designer-base/src/main/java/com/fr/design/data/datapane/ChoosePane.java
  7. 4
      designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java
  8. 12
      designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java
  9. 7
      designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java
  10. 234
      designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java
  11. 15
      designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java
  12. 2
      designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java
  13. 31
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java
  14. 17
      designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java
  15. 1
      designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java
  16. 13
      designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java
  17. 3
      designer-base/src/main/java/com/fr/design/mainframe/DesignerFrame.java
  18. 20
      designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java
  19. 10
      designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java
  20. 2
      designer-base/src/main/java/com/fr/design/upm/UpmBridge.java
  21. 2
      designer-base/src/main/java/com/fr/design/upm/UpmFinder.java
  22. 200
      designer-base/src/main/java/com/fr/design/utils/AWTUtilities.java
  23. 28
      designer-base/src/main/java/com/fr/env/RemoteEnvPane.java
  24. 3
      designer-base/src/main/java/com/fr/start/SplashWindow.java
  25. 30
      designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java
  26. 3
      designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java
  27. 41
      designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java
  28. 3
      designer-chart/build.gradle
  29. 21
      designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java
  30. 167
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java
  31. 210
      designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java
  32. 92
      designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java
  33. 27
      designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java
  34. 18
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java
  35. 17
      designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java
  36. 77
      designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java
  37. 3
      designer-form/build.gradle
  38. 11
      designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java
  39. 55
      designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java
  40. 11
      designer-form/src/main/java/com/fr/design/designer/creator/DedicateLayoutContainer.java
  41. 32
      designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java
  42. 17
      designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java
  43. 206
      designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java
  44. 4
      designer-realize/build.gradle
  45. 2
      designer-realize/src/main/java/com/fr/design/mainframe/alphafine/listener/ComponentHandler.java
  46. 29
      globalConfigHook.gradle
  47. BIN
      gradle/wrapper/gradle-wrapper.jar
  48. 6
      gradle/wrapper/gradle-wrapper.properties
  49. 172
      gradlew
  50. 84
      gradlew.bat
  51. 12
      settings.gradle

8
.gitignore vendored

@ -3,6 +3,14 @@
.DS_Store
.classpath
.project
.gradle
target/
*/build
designer-base/${web-inf-path}
designer-chart/${web-inf-path}
designer-form/${web-inf-path}
designer-realize/${web-inf-path}

82
build.gradle

@ -0,0 +1,82 @@
import org.gradle.plugins.ide.idea.model.IdeaLanguageLevel
plugins {
id 'java'
id 'java-library'
id 'com.fr.common' version '1.0-SNAPSHOT'
}
//
ext {
frVersion = ""
outputPath = "build"
ignoreTestFailureSetting = true
languageLevelSetting = 1.8
}
applyGlobalConfigPathIfExist()
if (versions.frVersion) {
frVersion = versions.frVersion
}
def frDevVersion = "DEV" + frVersion
dependencies {
api project(':designer-base')
api project(':designer-chart')
api project(':designer-form')
api project(':designer-realize')
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
group 'com.fr.design'
version frDevVersion
sourceCompatibility = languageLevelSetting
targetCompatibility = languageLevelSetting
tasks.withType(JavaCompile) {
options.encoding = "UTF-8"
}
repositories {
mavenLocal()
}
idea {
module {
inheritOutputDirs = false
outputDir = file(outputPath +"/classes")
testOutputDir = file(outputPath +"/test-classes")
languageLevel = new IdeaLanguageLevel(sourceCompatibility)
targetBytecodeVersion = targetCompatibility
}
}
dependencies {
implementation 'com.fr.third:jxbrowser:7.5'
implementation 'com.fr.third:jxbrowser-swing:7.5'
implementation 'com.fr.third:jxbrowser-mac:7.5'
implementation 'com.fr.third:jxbrowser-win64:7.5'
implementation 'com.fr.third.server:servlet-api:3.0'
implementation 'org.swingexplorer:swexpl:2.0.1'
implementation 'org.swingexplorer:swag:1.0'
implementation 'net.java.dev.jna:jna:5.4.0'
implementation 'org.apache.tomcat:tomcat-catalina:8.5.32'
implementation 'io.socket:socket.io-client:0.7.0'
implementation 'com.fr.third:fine-third:' + frVersion
implementation 'com.fr.core:fine-core:' + frDevVersion
implementation 'com.fr.activator:fine-activator:' + frVersion
implementation 'com.fr.datasource:fine-datasource:' + frVersion
implementation 'com.fr.decision:fine-decision:' + frVersion
implementation 'com.fr.schedule:fine-schedule:' + frVersion
implementation 'com.fr.report:fine-report-engine:' + frDevVersion
testImplementation 'org.easymock:easymock:3.5.1'
testImplementation 'org.powermock:powermock-module-junit4:1.7.1'
testImplementation 'org.powermock:powermock-api-easymock:1.7.1'
testImplementation 'junit:junit:4.12'
}
}

43
designer-base/src/main/java/com/fr/design/EnvChangeEntrance.java

@ -8,6 +8,7 @@ import com.fr.design.dialog.FineJOptionPane;
import com.fr.design.env.DesignerWorkspaceGenerator;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.design.env.RemoteWorkspace;
import com.fr.design.file.HistoryTemplateListCache;
import com.fr.design.file.TemplateTreePane;
@ -18,7 +19,6 @@ import com.fr.design.utils.DesignUtils;
import com.fr.env.CheckServiceDialog;
import com.fr.env.EnvListPane;
import com.fr.exit.DesignerExiter;
import com.fr.general.GeneralContext;
import com.fr.general.GeneralUtils;
import com.fr.invoke.Reflect;
import com.fr.json.JSONArray;
@ -30,7 +30,6 @@ import com.fr.process.engine.core.CarryMessageEvent;
import com.fr.process.engine.core.FineProcessContext;
import com.fr.rpc.Result;
import com.fr.stable.AssistUtils;
import com.fr.stable.EnvChangedListener;
import com.fr.stable.StringUtils;
import com.fr.start.server.ServerTray;
import com.fr.workspace.WorkContext;
@ -63,8 +62,6 @@ import static javax.swing.JOptionPane.QUESTION_MESSAGE;
public class EnvChangeEntrance {
private String currentEnvName = "";
public static EnvChangeEntrance getInstance() {
return HOLDER.singleton;
}
@ -75,13 +72,7 @@ public class EnvChangeEntrance {
private EnvChangeEntrance() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
GeneralContext.addEnvChangedListener(new EnvChangedListener() {
@Override
public void envChanged() {
currentEnvName = DesignerEnvManager.getEnvManager().getCurEnvName();
}
});
}
private boolean envListOkAction(EnvListPane envListPane, PopTipStrategy strategy) {
@ -380,15 +371,21 @@ public class EnvChangeEntrance {
* 出现对话框选择使用的工作环境
*/
public void chooseEnv() {
chooseEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
}
public void chooseEnv(final String envName) {
final EnvListPane envListPane = new EnvListPane();
final BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListPane.populateEnvManager(currentEnvName);
envListPane.populateEnvManager(envName);
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@Override
public void doOk() {
envListOkAction(envListPane, PopTipStrategy.LATER);
// 切换完成后清理密码
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
}
@Override
@ -409,7 +406,7 @@ public class EnvChangeEntrance {
eventPipe.fire(new CarryMessageEvent(ReportState.STOP.getValue()));
}
final EnvListPane envListPane = new EnvListPane();
envListPane.populateEnvManager(currentEnvName);
envListPane.populateEnvManager(DesignerEnvManager.getEnvManager().getCurEnvName());
BasicDialog envListDialog = envListPane.showWindow(SwingUtilities.getWindowAncestor(DesignerContext.getDesignerFrame()));
envListDialog.addDialogActionListener(new DialogActionAdapter() {
@ -418,6 +415,8 @@ public class EnvChangeEntrance {
FineProcessContext.getParentPipe().fire(new CarryMessageEvent(ReportState.ACTIVE.getValue()));
if (!envListOkAction(envListPane, PopTipStrategy.NOW)) {
DesignerExiter.getInstance().execute();
} else {
updateSelectEnv(DesignerEnvManager.getEnvManager().getCurEnvName());
}
}
@ -429,6 +428,24 @@ public class EnvChangeEntrance {
envListDialog.setVisible(true);
}
/**
* 切换环境后 刷新远程目录需要忘记密码的情况
* @param envName 环境名
*/
private void updateSelectEnv(String envName) {
DesignerEnvManager mgr = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo info = mgr.getWorkspaceInfo(envName);
if (info != null) {
WorkspaceConnectionInfo connection = info.getConnection();
if (connection != null && !connection.isRememberPwd()) {
DesignerWorkspaceInfo workspaceInfo = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo(
connection.getUrl(), connection.getUserName(), StringUtils.EMPTY, connection.getCertPath(), connection.getCertSecretKey(), false));
mgr.putEnv(envName, workspaceInfo);
}
}
}
/**
* 提示显示策略

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

@ -59,7 +59,14 @@ public class SwitchExistEnv extends MenuDef {
*/
public void actionPerformed(ActionEvent e) {
final String envName = getName();
EnvChangeEntrance.getInstance().switch2Env(envName);
DesignerEnvManager envManager = DesignerEnvManager.getEnvManager();
DesignerWorkspaceInfo selectedEnv = envManager.getWorkspaceInfo(envName);
if (selectedEnv.getConnection() != null && !selectedEnv.getConnection().isRememberPwd()) {
// 打开配置目录面板
EnvChangeEntrance.getInstance().chooseEnv(envName);
} else {
EnvChangeEntrance.getInstance().switch2Env(envName);
}
}
}
}

3
designer-base/src/main/java/com/fr/design/bridge/exec/JSExecutor.java

@ -4,5 +4,8 @@ package com.fr.design.bridge.exec;
* Created by ibm on 2017/6/21.
*/
public interface JSExecutor {
String CALLBACK_FUNCTION_NAME = "action";
void executor(String newValue);
}

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

@ -4,6 +4,7 @@ import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.TableProcedure;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.core.db.dialect.DialectFactory;
import com.fr.data.impl.DBTableData;
import com.fr.data.operator.DataOperator;
@ -37,11 +38,7 @@ import com.fr.stable.StringUtils;
import com.fr.workspace.WorkContext;
import com.fr.workspace.server.connection.DBConnectAuth;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTree;
import javax.swing.SwingWorker;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.PopupMenuEvent;
@ -52,9 +49,7 @@ import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreeCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.*;
import java.awt.event.FocusAdapter;
import java.awt.event.FocusEvent;
import java.awt.event.ItemEvent;
@ -469,6 +464,15 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
* @return 数据集数据
*/
public TableData createSelectTableData() {
return createSelectTableData(new SelectSqlProcessor() {
@Override
public String createSelectSql(String schema, String tableName, Dialect dialect) {
return DataCoreUtils.createSelectSQL(schema, tableName, dialect);
}
});
}
public TableData createSelectTableData(SelectSqlProcessor sqlProcessor) {
DataBaseItems paras = this.updateBean();
boolean connect = false;
com.fr.data.impl.Connection database = DBUtils.checkDBConnection(paras.getDatabaseName());
@ -491,11 +495,11 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
TableData tableData = null;
if (WorkContext.getCurrent().isLocal()) {
tableData = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(),
tableData = new DBTableData(database, sqlProcessor.createSelectSql(paras.getSchemaName(), paras.getTableName(),
DialectFactory.getDialectByName(paras.getDatabaseName())));
} else {
try {
TableData tableDataLocal = new DBTableData(database, DataCoreUtils.createSelectSQL(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName())));
TableData tableDataLocal = new DBTableData(database, sqlProcessor.createSelectSql(paras.getSchemaName(), paras.getTableName(), DialectFactory.getDialectByName(paras.getDatabaseName())));
tableData = DataOperator.getInstance().previewTableData(tableDataLocal, java.util.Collections.EMPTY_MAP,
DesignerEnvManager.getEnvManager().getMaxNumberOrPreviewRow());
} catch (Exception e) {
@ -605,6 +609,13 @@ public class ChoosePane extends BasicBeanPane<DataBaseItems> implements Refresha
});
}
/**
* 数据集选择面板里的生成sql语句的接口
*/
public interface SelectSqlProcessor {
String createSelectSql(String schema, String tableName, Dialect dialect);
}
protected class StringUIComboBox extends UIComboBox {
private boolean refreshingModel = false;

4
designer-base/src/main/java/com/fr/design/env/RemoteDesignerWorkspaceInfo.java vendored

@ -72,7 +72,8 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
String password = SecurityToolbox.defaultDecrypt(reader.getAttrAsString("password", StringUtils.EMPTY).replaceAll(" ", "\r\n"));
String certPath = reader.getAttrAsString("certPath", StringUtils.EMPTY);
String certSecretKey = reader.getAttrAsString("certSecretKey", StringUtils.EMPTY);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey);
boolean rememberPwd = reader.getAttrAsBoolean("rememberPwd", true);
this.connection = new WorkspaceConnectionInfo(url, username, password, certPath, certSecretKey, rememberPwd);
}
}
}
@ -89,6 +90,7 @@ public class RemoteDesignerWorkspaceInfo implements DesignerWorkspaceInfo {
writer.attr("password", SecurityToolbox.defaultEncrypt(connection.getPassword()));
writer.attr("certPath", connection.getCertPath());
writer.attr("certSecretKey", connection.getCertSecretKey());
writer.attr("rememberPwd", connection.isRememberPwd());
writer.end();
}
}

12
designer-base/src/main/java/com/fr/design/extra/LoginWebBridge.java

@ -196,18 +196,6 @@ public class LoginWebBridge {
uiLabel.setBackground(LOGIN_BACKGROUND);
}
/**
* 弹出QQ授权页面
*/
public void showQQ() {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
WebViewDlgHelper.createQQLoginDialog();
}
});
}
/**
* 关闭QQ授权窗口
*/

7
designer-base/src/main/java/com/fr/design/extra/PluginWebBridge.java

@ -533,13 +533,6 @@ public class PluginWebBridge {
threadPoolExecutor.submit(task);
}
/**
* 弹出QQ授权页面
*/
public void showQQ() {
LoginWebBridge.getHelper().showQQ();
}
/**
* 通过QQ登录后通知登录
*/

234
designer-base/src/main/java/com/fr/design/extra/QQLoginWebPane.java

@ -1,234 +0,0 @@
package com.fr.design.extra;
import com.fr.design.dialog.FineJOptionPane;
import com.fr.general.CloudCenter;
import com.fr.general.ComparatorUtils;
import com.fr.general.IOUtils;
import com.fr.log.FineLoggerFactory;
import javafx.application.Platform;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.concurrent.Worker;
import javafx.embed.swing.JFXPanel;
import javafx.event.ActionEvent;
import javafx.event.EventHandler;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.ButtonBuilder;
import javafx.scene.control.LabelBuilder;
import javafx.scene.input.MouseEvent;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBoxBuilder;
import javafx.scene.paint.Color;
import javafx.scene.web.WebEngine;
import javafx.scene.web.WebEvent;
import javafx.scene.web.WebView;
import javafx.stage.Modality;
import javafx.stage.Screen;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.stage.WindowEvent;
import javafx.util.Callback;
import netscape.javascript.JSObject;
import javax.swing.JOptionPane;
import javax.swing.SwingUtilities;
import java.awt.Toolkit;
/**
* Created by zhaohehe on 16/7/28.
*/
public class QQLoginWebPane extends JFXPanel {
private WebEngine webEngine;
private String url;
private static JSObject window;
private static int DEFAULT_PRIMARYSTAGE_WIDTH = 100;
private static int DEFAULT_PRIMARYSTAGE_HEIGHT = 100;
private static int DEFAULT_CONFIRM_WIDTH = 450;
private static int DEFAULT_CONFIRM_HEIGHT = 160;
private static int DEFAULT_OFFEST = 20;
class Delta {
double x, y;
}
public QQLoginWebPane(final String installHome) {
Platform.setImplicitExit(false);
Platform.runLater(new Runnable() {
@Override
public void run() {
BorderPane root = new BorderPane();
Scene scene = new Scene(root);
QQLoginWebPane.this.setScene(scene);
final WebView webView = new WebView();
webEngine = webView.getEngine();
url = "file:///" + installHome + "/scripts/qqLogin.html";
webEngine.load(url);
final Stage primaryStage = new Stage();
HBox layout = new HBox();
try {
primaryStage.initStyle(StageStyle.TRANSPARENT);
primaryStage.setScene(new Scene(layout));
webView.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm());
primaryStage.initStyle(StageStyle.UTILITY);
primaryStage.setScene(new Scene(new Group(), DEFAULT_PRIMARYSTAGE_WIDTH, DEFAULT_PRIMARYSTAGE_HEIGHT));
primaryStage.setX(0);
primaryStage.setY(Screen.getPrimary().getBounds().getHeight() + DEFAULT_PRIMARYSTAGE_HEIGHT);
primaryStage.show();
} catch (Exception e) {
FineLoggerFactory.getLogger().info(e.getMessage());
}
webEngine.setConfirmHandler(new Callback<String, Boolean>() {
@Override
public Boolean call(String msg) {
Boolean confirmed = confirm(primaryStage, msg, webView);
return confirmed;
}
});
configWebEngine();
webView.setContextMenuEnabled(false);//屏蔽右键
root.setCenter(webView);
}
});
}
private void configWebEngine() {
webEngine.locationProperty().addListener(new ChangeListener<String>() {
@Override
public void changed(ObservableValue<? extends String> observable, final String oldValue, String newValue) {
disableLink(webEngine);
// webView好像默认以手机版显示网页,浏览器里过滤掉这个跳转
if (ComparatorUtils.equals(newValue, url) || ComparatorUtils.equals(newValue, CloudCenter.getInstance().acquireUrlByKind("bbs.mobile"))) {
return;
}
LoginWebBridge.getHelper().openUrlAtLocalWebBrowser(webEngine, newValue);
}
});
webEngine.setOnAlert(new EventHandler<WebEvent<String>>() {
@Override
public void handle(WebEvent<String> event) {
showAlert(event.getData());
}
});
webEngine.getLoadWorker().stateProperty().addListener(
new ChangeListener<Worker.State>() {
public void changed(ObservableValue ov, Worker.State oldState, Worker.State newState) {
if (newState == Worker.State.SUCCEEDED) {
window = (JSObject) webEngine.executeScript("window");
window.setMember("QQLoginHelper", LoginWebBridge.getHelper());
}
}
}
);
}
private void showAlert(final String message) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
FineJOptionPane.showMessageDialog(QQLoginWebPane.this, message);
}
});
}
private void disableLink(final WebEngine eng) {
try {
// webView端不跳转 虽然webView可以指定本地浏览器打开某个链接,但是当本地浏览器跳转到指定链接的同时,webView也做了跳转,
// 为了避免出现在一个600*400的资讯框里加载整个网页的情况,webView不跳转到新网页
Platform.runLater(new Runnable() {
@Override
public void run() {
eng.executeScript("location.reload()");
LoginWebBridge.getHelper().closeQQWindow();
}
});
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
}
private Boolean confirm(final Stage parent, String msg, final WebView webView) {
final BooleanProperty confirmationResult = new SimpleBooleanProperty();
// initialize the confirmation dialog
final Stage dialog = new Stage(StageStyle.UTILITY);
dialog.setX(Toolkit.getDefaultToolkit().getScreenSize().getWidth() / 2 - DEFAULT_CONFIRM_WIDTH / 2.0D + DEFAULT_OFFEST);
dialog.setY(Toolkit.getDefaultToolkit().getScreenSize().getHeight() / 2 + DEFAULT_OFFEST);
dialog.setHeight(DEFAULT_CONFIRM_HEIGHT);
dialog.setWidth(DEFAULT_CONFIRM_WIDTH);
dialog.setIconified(false);
dialog.initOwner(parent);
dialog.initModality(Modality.WINDOW_MODAL);
dialog.setScene(
new Scene(
HBoxBuilder.create().styleClass("modal-dialog").children(
LabelBuilder.create().text(msg).build(),
ButtonBuilder.create().text(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_BBSLogin_Switch_Account")).defaultButton(true).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
// take action and close the dialog.
confirmationResult.set(true);
webView.getEngine().reload();
dialog.close();
}
}).build(),
ButtonBuilder.create().text(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Engine_Cancel")).cancelButton(true).onAction(new EventHandler<ActionEvent>() {
@Override
public void handle(ActionEvent actionEvent) {
// abort action and close the dialog.
confirmationResult.set(false);
dialog.close();
}
}).build()
).build()
, Color.TRANSPARENT
)
);
configDrag(dialog);
// style and show the dialog.
dialog.getScene().getStylesheets().add(IOUtils.getResource("modal-dialog.css", getClass()).toExternalForm());
dialog.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
event.consume();
dialog.close();
}
});
dialog.showAndWait();
return confirmationResult.get();
}
private void configDrag(final Stage dialog) {
// allow the dialog to be dragged around.
final Node root = dialog.getScene().getRoot();
final Delta dragDelta = new Delta();
root.setOnMousePressed(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
// record a delta distance for the drag and drop operation.
dragDelta.x = dialog.getX() - mouseEvent.getScreenX();
dragDelta.y = dialog.getY() - mouseEvent.getScreenY();
}
});
root.setOnMouseDragged(new EventHandler<MouseEvent>() {
@Override
public void handle(MouseEvent mouseEvent) {
dialog.setX(mouseEvent.getScreenX() + dragDelta.x);
dialog.setY(mouseEvent.getScreenY() + dragDelta.y);
}
});
}
}

15
designer-base/src/main/java/com/fr/design/extra/WebViewDlgHelper.java

@ -183,21 +183,6 @@ public class WebViewDlgHelper {
}
}
public static void createQQLoginDialog() {
try {
Class<?> clazz = Class.forName("com.fr.design.extra.QQLoginWebPane");
Constructor constructor = clazz.getConstructor(String.class);
Component webPane = (Component) constructor.newInstance(new File(installHome).getAbsolutePath());
UIDialog qqLoginDialog = new QQLoginDialog(DesignerContext.getDesignerFrame(), webPane);
LoginWebBridge.getHelper().setQQDialog(qqLoginDialog);
qqLoginDialog.setVisible(true);
} catch (Throwable ignored) {
// ignored
}
}
private static void confirmDownLoadShopJS() {
int rv = FineJOptionPane.showConfirmDialog(
null,

2
designer-base/src/main/java/com/fr/design/gui/frpane/UIBubbleFloatPane.java

@ -2,9 +2,9 @@ package com.fr.design.gui.frpane;
import com.fr.design.beans.BasicBeanPane;
import com.fr.design.dialog.UIDialog;
import com.fr.design.utils.AWTUtilities;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.Constants;
import com.sun.awt.AWTUtilities;
import javax.swing.JComponent;
import javax.swing.JPanel;

31
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UICheckListPopup.java

@ -36,14 +36,20 @@ public class UICheckListPopup extends UIPopupMenu {
private UIScrollPane jScrollPane;
private Color mouseEnteredColor = UIConstants.CHECKBOX_HOVER_SELECTED;
private int maxDisplayNumber = 8;
private boolean supportSelectAll = true;
public static final String COMMIT_EVENT = "commit";
public static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All");
private static final String SELECT_ALL = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Choose_All");
private static final int CHECKBOX_HEIGHT = 25;
public UICheckListPopup(Object[] value) {
public UICheckListPopup(Object[] values) {
this(values, true);
}
public UICheckListPopup(Object[] value, boolean supportSelectAll) {
super();
values = value;
this.supportSelectAll = supportSelectAll;
initComponent();
}
@ -78,7 +84,9 @@ public class UICheckListPopup extends UIPopupMenu {
checkBoxList.clear();
//全选加在第一个位置
addOneCheckValue(SELECT_ALL);
if (supportSelectAll) {
addOneCheckValue(SELECT_ALL);
}
for (Object checkValue : values) {
addOneCheckValue(checkValue);
}
@ -151,7 +159,7 @@ public class UICheckListPopup extends UIPopupMenu {
private void addSelectListener() {
for (int i = 0; i < checkBoxList.size(); i++) {
JCheckBox checkBox = checkBoxList.get(i);
if (i == 0) {
if (supportSelectAll && i == 0) {
checkBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
@ -189,7 +197,8 @@ public class UICheckListPopup extends UIPopupMenu {
List<Object> allValue = Arrays.asList(values);
for (Object value : selectedValues.keySet()) {
int index = allValue.indexOf(value);
checkBoxList.get(index + 1).setSelected(selectedValues.get(value));
index = supportSelectAll ? index + 1 : index;
checkBoxList.get(index).setSelected(selectedValues.get(value));
}
}
@ -201,15 +210,19 @@ public class UICheckListPopup extends UIPopupMenu {
public Object[] getSelectedValues() {
List<Object> selectedValues = new ArrayList<Object>();
int selectCount = 0;
for (int i = 1; i < checkBoxList.size(); i++) {
int startIndex = supportSelectAll ? 1 : 0;
for (int i = startIndex; i < checkBoxList.size(); i++) {
if (checkBoxList.get(i).isSelected()) {
selectedValues.add(values[i - 1]);
int valueIndex = supportSelectAll ? i - 1 : i;
selectedValues.add(values[valueIndex]);
selectCount++;
}
}
//全选半选切换
switchSelectIcon(selectCount);
if (supportSelectAll) {
switchSelectIcon(selectCount);
}
return selectedValues.toArray(new Object[selectedValues.size()]);
}

17
designer-base/src/main/java/com/fr/design/gui/icombocheckbox/UIComboCheckBox.java

@ -59,8 +59,18 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private String multiComboName = StringUtils.EMPTY;
private boolean showOmitText = true;
private boolean supportSelectAll = true;
public UIComboCheckBox(Object[] value) {
this(value, DEFAULT_VALUE_SPERATOR);
this(value, DEFAULT_VALUE_SPERATOR, true);
}
public UIComboCheckBox(Object[] value, boolean supportSelectAll) {
this(value, DEFAULT_VALUE_SPERATOR, supportSelectAll);
}
public UIComboCheckBox(Object[] values, String valueSperator) {
this(values, valueSperator, true);
}
/**
@ -69,8 +79,9 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
* @param value
* @param valueSperator
*/
public UIComboCheckBox(Object[] value, String valueSperator) {
public UIComboCheckBox(Object[] value, String valueSperator, boolean supportSelectAll) {
values = value;
this.supportSelectAll = supportSelectAll;
this.valueSperator = valueSperator;
initComponent();
}
@ -102,7 +113,7 @@ public class UIComboCheckBox extends JComponent implements UIObserver, GlobalNam
private void initComponent() {
this.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
this.popup = new UICheckListPopup(values);
this.popup = new UICheckListPopup(values, supportSelectAll);
this.popup.addActionListener(new PopupAction());
this.editor = createEditor();
this.arrowButton = createArrowButton();

1
designer-base/src/main/java/com/fr/design/gui/ifilechooser/UINativeFileChooser.java

@ -1,5 +1,6 @@
package com.fr.design.gui.ifilechooser;
import com.fr.design.gui.ifilechooser.AbstractFileChooser;
import com.fr.design.mainframe.DesignerContext;
import com.fr.stable.os.OperatingSystem;

13
designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/RSyntaxTextArea.java

@ -9,16 +9,7 @@
*/
package com.fr.design.gui.syntax.ui.rsyntaxtextarea;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
@ -604,7 +595,7 @@ private boolean fractionalFontMetricsEnabled;
SecurityManager sm = System.getSecurityManager();
if (sm!=null) {
try {
sm.checkSystemClipboardAccess();
sm.checkPermission(new AWTPermission("accessClipboard"));
} catch (SecurityException se) {
UIManager.getLookAndFeel().provideErrorFeedback(null);
return;

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

@ -509,7 +509,8 @@ public class DesignerFrame extends JFrame implements JTemplateActionListener, Ta
if (OperatingSystem.isMacos()) {
Class clazz = Class.forName("com.apple.eawt.Application");
BufferedImage icon = image.isEmpty() ? IOUtils.readImage("/com/fr/base/images/oem/logo.png") : image.get(image.size() - 1);
Reflect.on(Reflect.on(clazz).call("getApplication").get()).call("setDockIconImage", icon);
Object application = Reflect.on(clazz).call("getApplication").get();
Reflect.on(application).call("setDockIconImage", icon);
} else {
this.setIconImages(image);
}

20
designer-base/src/main/java/com/fr/design/os/impl/MacOsAddListenerAction.java

@ -9,11 +9,16 @@ import com.fr.invoke.Reflect;
import com.fr.log.FineLoggerFactory;
import com.fr.stable.os.support.OSBasedAction;
import java.awt.*;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
/**
* com.apple.eawt.Application属于jdk1.8及以下mac jdk特有的api
* 在jdk9中被移除由Desktop.getDesktop().setQuitHandler等jdk9.0引入的新api替代
* 参见 https://stackoverflow.com/questions/38381824/how-can-i-use-apple-com-apple-eawt-functionality-on-java-8
*
* @author hades
* @version 10.0
* Created by hades on 2020/3/13
@ -28,10 +33,21 @@ public class MacOsAddListenerAction implements OSBasedAction {
Object quitInstance = getProxy(quitHandler, "handleQuitRequestWith", new QuitAction());
Class aboutHandler = Class.forName("com.apple.eawt.AboutHandler");
Object aboutInstance = getProxy(aboutHandler, "handleAbout", new AboutAction());
Reflect.on(Reflect.on(app).call("getApplication").get()).call("setQuitHandler", quitInstance)
Object application = Reflect.on(app).call("getApplication").get();
Reflect.on(application).call("setQuitHandler", quitInstance)
.call("setAboutHandler", aboutInstance);
} catch (ClassNotFoundException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
// 上面的不能移除,同时要保证再jdk1.8下面能运行
// 抛出异常时 说明使用>=jdk9运行行设计器,但由于编译使用1.8构建,使用反射运行
try {
Class quitHandler = Class.forName("java.awt.desktop.QuitHandler");
Object quitInstance = getProxy(quitHandler, "handleQuitRequestWith", new QuitAction());
Class aboutHandler = Class.forName("java.awt.desktop.AboutHandler");
Object aboutInstance = getProxy(aboutHandler, "handleAbout", new AboutAction());
Reflect.on(Desktop.getDesktop()).call("setQuitHandler", quitInstance).call("setAboutHandler", aboutInstance);
} catch (ClassNotFoundException ex) {
FineLoggerFactory.getLogger().error(ex.getMessage(), ex);
}
}
}

10
designer-base/src/main/java/com/fr/design/present/dict/DatabaseDictPane.java

@ -2,7 +2,9 @@ package com.fr.design.present.dict;
import com.fr.base.BaseFormula;
import com.fr.base.TableData;
import com.fr.data.core.DataCoreUtils;
import com.fr.data.core.db.DBUtils;
import com.fr.data.core.db.dialect.Dialect;
import com.fr.data.impl.DatabaseDictionary;
import com.fr.data.impl.NameDatabaseConnection;
import com.fr.design.beans.FurtherBasicBeanPane;
@ -23,7 +25,6 @@ import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.stable.StringUtils;
import javax.swing.*;
@ -215,7 +216,12 @@ public class DatabaseDictPane extends FurtherBasicBeanPane<DatabaseDictionary> i
*
*/
public void dbChange() {
TableData tableData = this.chooseTable.createSelectTableData();
TableData tableData = this.chooseTable.createSelectTableData(new ChoosePane.SelectSqlProcessor() {
@Override
public String createSelectSql(String schema, String tableName, Dialect dialect) {
return DataCoreUtils.createColumnSelectSQL(schema, tableName, dialect);
}
});
String[] columnNames = DesignTableDataManager.getColumnNamesByTableData(tableData).toArray(new String[0]);
ColumnNameEditor columnNameEditor1 = new ColumnNameEditor(columnNames);
columnNameEditor1.addItemListener(itemListener);

2
designer-base/src/main/java/com/fr/design/upm/UpmBridge.java

@ -318,7 +318,7 @@ public class UpmBridge {
try {
return future.get();
} catch (Exception e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e);
FineLoggerFactory.getLogger().error(e.getMessage(), e);
}
return null;
}

2
designer-base/src/main/java/com/fr/design/upm/UpmFinder.java

@ -88,7 +88,7 @@ public class UpmFinder {
dialog.setVisible(true);
}
} else {
FineJOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
JOptionPane.showMessageDialog(DesignerContext.getDesignerFrame(), Toolkit.i18nText("Fine-Design_Update_Info_Plugin_Message"));
UpdateMainDialog dialog = new UpdateMainDialog(DesignerContext.getDesignerFrame());
dialog.setAutoUpdateAfterInit();
dialog.showDialog();

200
designer-base/src/main/java/com/fr/design/utils/AWTUtilities.java

@ -0,0 +1,200 @@
package com.fr.design.utils;
import sun.awt.SunToolkit;
import java.awt.*;
/**
* 适配jdk10之后被移除的 com.sun.awt.AWTUtilities
* 参照 https://github.com/frohoff/jdk8u-dev-jdk/blob/master/src/share/classes/com/sun/awt/AWTUtilities.java中实现
*
* @author hades
* @version 10.0
* Created by hades on 2020/5/29
*/
public class AWTUtilities {
/**
* @param window the window to set the shape to
* @param shape the shape to set to the window
*
*/
public static void setWindowShape(Window window, Shape shape) {
if (window == null) {
throw new NullPointerException("The window argument should not be null.");
}
window.setShape(shape);
}
/**
*
*
* @param window the window to set the shape to
* @param opaque whether the window must be opaque (true),
* or translucent (false)
*
*/
public static void setWindowOpaque(Window window, boolean opaque) {
if (window == null) {
throw new NullPointerException("The window argument should not be null.");
}
if (!opaque && !isTranslucencySupported(Translucency.PERPIXEL_TRANSLUCENT)) {
throw new UnsupportedOperationException("The PERPIXEL_TRANSLUCENT translucency kind is not supported");
}
Color color = window.getBackground();
if (color == null) {
color = new Color(0, 0, 0, 0);
}
window.setBackground(new Color(color.getRed(), color.getGreen(), color.getBlue(), opaque ? 255 : 0));
}
public static enum Translucency {
/**
* Represents support in the underlying system for windows each pixel
* of which is guaranteed to be either completely opaque, with
* an alpha value of 1.0, or completely transparent, with an alpha
* value of 0.0.
*/
PERPIXEL_TRANSPARENT,
/**
* Represents support in the underlying system for windows all of
* the pixels of which have the same alpha value between or including
* 0.0 and 1.0.
*/
TRANSLUCENT,
/**
* Represents support in the underlying system for windows that
* contain or might contain pixels with arbitrary alpha values
* between and including 0.0 and 1.0.
*/
PERPIXEL_TRANSLUCENT;
}
/**
* Returns whether the given level of translucency is supported by
* the underlying system.
*
* Note that this method may sometimes return the value
* indicating that the particular level is supported, but
* the native windowing system may still not support the
* given level of translucency (due to the bugs in
* the windowing system).
*
* @param translucencyKind a kind of translucency support
* (either PERPIXEL_TRANSPARENT,
* TRANSLUCENT, or PERPIXEL_TRANSLUCENT)
* @return whether the given translucency kind is supported
*/
private static boolean isTranslucencySupported(Translucency translucencyKind) {
switch (translucencyKind) {
case PERPIXEL_TRANSPARENT:
return isWindowShapingSupported();
case TRANSLUCENT:
return isWindowOpacitySupported();
case PERPIXEL_TRANSLUCENT:
return isWindowTranslucencySupported();
}
return false;
}
/**
* Returns whether the windowing system supports changing the opacity
* value of top-level windows.
* Note that this method may sometimes return true, but the native
* windowing system may still not support the concept of
* translucency (due to the bugs in the windowing system).
*/
private static boolean isWindowOpacitySupported() {
Toolkit curToolkit = Toolkit.getDefaultToolkit();
if (!(curToolkit instanceof SunToolkit)) {
return false;
}
return ((SunToolkit)curToolkit).isWindowOpacitySupported();
}
/**
* Returns whether the windowing system supports changing the shape
* of top-level windows.
* Note that this method may sometimes return true, but the native
* windowing system may still not support the concept of
* shaping (due to the bugs in the windowing system).
*/
private static boolean isWindowShapingSupported() {
Toolkit curToolkit = Toolkit.getDefaultToolkit();
if (!(curToolkit instanceof SunToolkit)) {
return false;
}
return ((SunToolkit)curToolkit).isWindowShapingSupported();
}
private static boolean isWindowTranslucencySupported() {
/*
* Per-pixel alpha is supported if all the conditions are TRUE:
* 1. The toolkit is a sort of SunToolkit
* 2. The toolkit supports translucency in general
* (isWindowTranslucencySupported())
* 3. There's at least one translucency-capable
* GraphicsConfiguration
*/
Toolkit curToolkit = Toolkit.getDefaultToolkit();
if (!(curToolkit instanceof SunToolkit)) {
return false;
}
if (!((SunToolkit)curToolkit).isWindowTranslucencySupported()) {
return false;
}
GraphicsEnvironment env =
GraphicsEnvironment.getLocalGraphicsEnvironment();
// If the default GC supports translucency return true.
// It is important to optimize the verification this way,
// see CR 6661196 for more details.
if (isTranslucencyCapable(env.getDefaultScreenDevice()
.getDefaultConfiguration()))
{
return true;
}
// ... otherwise iterate through all the GCs.
GraphicsDevice[] devices = env.getScreenDevices();
for (int i = 0; i < devices.length; i++) {
GraphicsConfiguration[] configs = devices[i].getConfigurations();
for (int j = 0; j < configs.length; j++) {
if (isTranslucencyCapable(configs[j])) {
return true;
}
}
}
return false;
}
private static boolean isTranslucencyCapable(GraphicsConfiguration gc) {
if (gc == null) {
throw new NullPointerException("The gc argument should not be null");
}
/*
return gc.isTranslucencyCapable();
*/
Toolkit curToolkit = Toolkit.getDefaultToolkit();
if (!(curToolkit instanceof SunToolkit)) {
return false;
}
return ((SunToolkit)curToolkit).isTranslucencyCapable(gc);
}
}

28
designer-base/src/main/java/com/fr/env/RemoteEnvPane.java vendored

@ -96,6 +96,10 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
* 密码
*/
private UIPassWordField passwordInput = new UIPassWordField();
/**
* 是否记住密码
*/
private UICheckBox rememberPwdCheckbox = new UICheckBox(Toolkit.i18nText("Fine-Design_Basic_Remote_Env_Remember_Password"));
/**
* https证书路径
*/
@ -212,7 +216,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
updateHttpsConfigPanel();
remoteWorkspaceURL.setHttps(isHttps);
// reset下url,将勾选状态是否htpps加到url里
// reset下url,将勾选状态是否https加到url里
remoteWorkspaceURL.resetUrl();
fillRemoteEnvURLField();
@ -286,6 +290,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
contentPanel.add(configPanel, BorderLayout.NORTH);
contentPanel.add(accountPanel, BorderLayout.CENTER);
contentPanel.add(packRememberPwdConfigPanel(), BorderLayout.SOUTH);
JPanel panel = FRGUIPaneFactory.createBorderLayout_S_Pane();
panel.add(contentPanel, BorderLayout.NORTH);
panel.add(testPanel, BorderLayout.CENTER);
@ -306,15 +311,18 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String pwd = fromNullable(connection.getPassword()).or(StringUtils.EMPTY);
String certPath = fromNullable(connection.getCertPath()).or(StringUtils.EMPTY);
String certSecretKey = fromNullable(connection.getCertSecretKey()).or(StringUtils.EMPTY);
boolean rememberPwd = fromNullable(connection.isRememberPwd()).or(true);
this.usernameInput.setText(username);
this.passwordInput.setText(pwd);
this.certPathInput.setText(certPath);
this.certSecretKeyInput.setText(certSecretKey);
this.rememberPwdCheckbox.setSelected(rememberPwd);
} else {
this.remoteWorkspaceURL = RemoteWorkspaceURL.createDefaultURL();
this.usernameInput.setText(StringUtils.EMPTY);
this.passwordInput.setText(StringUtils.EMPTY);
this.rememberPwdCheckbox.setSelected(true);
}
fillRemoteEnvURLField();
@ -333,6 +341,7 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
String url = this.remoteWorkspaceURL.getURL();
String username = this.usernameInput.getText();
String password = new String(this.passwordInput.getPassword());
boolean rememberPwd = this.rememberPwdCheckbox.isSelected();
DesignerEnvProcessor envProcessor = ExtraDesignClassManager.getInstance().getSingle(DesignerEnvProcessor.XML_TAG);
if (envProcessor != null) {
url = envProcessor.changeEnvPathBeforeConnect(username, password, url);
@ -342,7 +351,8 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
username,
password,
this.certPathInput.getText(),
new String(this.certSecretKeyInput.getPassword()));
new String(this.certSecretKeyInput.getPassword()),
rememberPwd);
return RemoteDesignerWorkspaceInfo.create(connection);
}
@ -522,6 +532,20 @@ public class RemoteEnvPane extends BasicBeanPane<RemoteDesignerWorkspaceInfo> {
accountPanel.add(content, BorderLayout.CENTER);
}
private JPanel packRememberPwdConfigPanel() {
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(
new Component[][]{
new Component[]{rememberPwdCheckbox}
},
new double[]{PREFERRED},
new double[]{PREFERRED},
5,
10
);
TableLayoutHelper.modifyTableLayoutIndexHGap(panel, 0, 50);
return panel;
}
private JPanel createHttpsCertFileInputPanel() {
JPanel inputPanel = FRGUIPaneFactory.createRightFlowInnerContainer_S_Pane();

3
designer-base/src/main/java/com/fr/start/SplashWindow.java

@ -2,9 +2,9 @@ package com.fr.start;
import com.fr.base.BaseUtils;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.utils.AWTUtilities;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.stable.OperatingSystem;
import com.sun.awt.AWTUtilities;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
@ -41,7 +41,6 @@ public class SplashWindow extends JFrame {
this.setAlwaysOnTop(false);
this.setUndecorated(true);
AWTUtilities.setWindowOpaque(this, false);
//使窗体背景透明
if (OperatingSystem.isWindows()) {
this.setBackground(new Color(0, 0, 0, 0));

30
designer-base/src/test/java/com/fr/design/EnvChangeEntranceTest.java

@ -2,7 +2,9 @@ package com.fr.design;
import com.fr.design.env.DesignerWorkspaceInfo;
import com.fr.design.env.DesignerWorkspaceType;
import com.fr.design.env.RemoteDesignerWorkspaceInfo;
import com.fr.env.CheckServiceDialog;
import com.fr.invoke.Reflect;
import com.fr.workspace.connect.WorkspaceConnectionInfo;
import com.fr.workspace.engine.channel.http.FunctionalHttpRequest;
import org.easymock.EasyMock;
@ -19,7 +21,7 @@ import org.powermock.modules.junit4.PowerMockRunner;
* @Description:
*/
@RunWith(PowerMockRunner.class)
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class})
@PrepareForTest({FunctionalHttpRequest.class,EnvChangeEntrance.class,CheckServiceDialog.class, DesignerEnvManager.class})
public class EnvChangeEntranceTest {
@Test
@ -55,4 +57,30 @@ public class EnvChangeEntranceTest {
}
}
@Test
public void testUpdateSelectEnv() {
DesignerEnvManager manager = new DesignerEnvManager();
PowerMock.mockStatic(DesignerEnvManager.class);
EasyMock.expect(DesignerEnvManager.getEnvManager()).andReturn(manager).anyTimes();
PowerMock.replayAll();
EnvChangeEntrance entrance = EnvChangeEntrance.getInstance();
manager.putEnv("test1", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)));
manager.putEnv("test2", RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", false)));
Reflect.on(entrance).call("updateSelectEnv", "test1");
Reflect.on(entrance).call("updateSelectEnv", "test2");
Assert.assertEquals(manager.getWorkspaceInfo("test1").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "password", "", "", true)).getConnection());
Assert.assertEquals(manager.getWorkspaceInfo("test2").getConnection(), RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("url", "userName", "", "", "", false)).getConnection());
PowerMock.verifyAll();
}
}

3
designer-base/src/test/java/com/fr/design/env/RemoteWorkspaceTest.java vendored

@ -38,7 +38,7 @@ public class RemoteWorkspaceTest {
EasyMock.replay(workspace, operator);
PowerMock.replayAll();
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey");
WorkspaceConnectionInfo info = new WorkspaceConnectionInfo("url", "username", "password", "certPath", "certSecretKey", true);
RemoteWorkspace remoteWorkspace= new RemoteWorkspace(null, info);
@ -51,4 +51,5 @@ public class RemoteWorkspaceTest {
}
}

41
designer-base/src/test/java/com/fr/design/gui/icombocheckbox/UICheckListPopupTest.java

@ -0,0 +1,41 @@
package com.fr.design.gui.icombocheckbox;
import junit.framework.TestCase;
import org.junit.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
/**
* @author hades
* @version 10.0
* Created by hades on 2020/4/3
*/
public class UICheckListPopupTest extends TestCase {
@Test
public void testGetSelectedValues() {
Object[] values = new Object[]{"a", "b", "c"};
Map<Object, Boolean> map = new TreeMap<>();
map.put("a", true);
map.put("b", false);
map.put("c", true);
List<Object> list = new ArrayList<>();
for (Map.Entry<Object, Boolean> entry : map.entrySet()) {
if (entry.getValue()) {
list.add(entry.getKey());
}
}
Object[] selectValues = list.toArray();
UICheckListPopup uiCheckListPopup1 = new UICheckListPopup(values);
uiCheckListPopup1.setSelectedValue(map);
Assert.assertArrayEquals(selectValues, uiCheckListPopup1.getSelectedValues());
UICheckListPopup uiCheckListPopup2 = new UICheckListPopup(values, false);
uiCheckListPopup2.setSelectedValue(map);
Assert.assertArrayEquals(selectValues, uiCheckListPopup2.getSelectedValues());
}
}

3
designer-chart/build.gradle

@ -0,0 +1,3 @@
dependencies {
compile project(':designer-base')
}

21
designer-chart/src/main/java/com/fr/design/chartx/component/combobox/ColorSchemeComboBox.java

@ -2,6 +2,8 @@ package com.fr.design.chartx.component.combobox;
import com.fr.base.ChartColorMatching;
import com.fr.base.ChartPreStyleConfig;
import com.fr.cert.token.lang.Collections;
import com.fr.chart.base.ChartConstants;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxRenderer;
import com.fr.design.i18n.Toolkit;
@ -60,13 +62,20 @@ public class ColorSchemeComboBox extends UIComboBox {
//添加默认的方案和第一个方案
String defaultName = config.getCurrentStyle();
ChartColorMatching defaultStyle = (ChartColorMatching) config.getPreStyle(defaultName);
Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) {
defaultStyle = firstStyle;
if (names.hasNext()) {
Object firstName = names.next();
ChartColorMatching firstStyle = (ChartColorMatching) config.getPreStyle(firstName);
if (defaultStyle == null) {
defaultStyle = firstStyle;
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
} else {
ColorInfo colorInfo = new ColorInfo();
colorInfo.setGradient(false);
colorInfo.setColors(Collections.arrayToList(ChartConstants.CHART_COLOR_ARRAY));
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorInfo);
}
colorSchemes.put(Toolkit.i18nText("Fine-Design_Report_Default"), colorMatchingToColorInfo(defaultStyle));
colorSchemes.put(firstStyle.getId(), colorMatchingToColorInfo(firstStyle));
//添加其他的配色方案
while (names.hasNext()) {

167
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/report/MeterPlotReportDataContentPane.java

@ -6,11 +6,11 @@ import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
@ -20,19 +20,22 @@ import java.awt.Component;
/**
* 仪表盘 属性表 单元格数据界面
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午02:47:57
*/
public class MeterPlotReportDataContentPane extends AbstractReportDataContentPane {
private static final String CATENAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String NVALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private TinyFormulaPane singCatePane;
private TinyFormulaPane singValuePane;
private ChartDataFilterPane filterPane;
public MeterPlotReportDataContentPane(ChartDataPane parent) {
private static final String CATENAME = Toolkit.i18nText("Fine-Design_Chart_Category_Name");
private static final String NVALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private TinyFormulaPane singCatePane;
public TinyFormulaPane singValuePane;
private TinyFormulaPane customPane;
private ChartDataFilterPane filterPane;
public MeterPlotReportDataContentPane(ChartDataPane parent) {
// initEveryPane();
//
// List list = new ArrayList();
@ -41,73 +44,97 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
// seriesPane.populateBean(list);
//
// seriesPane.noAddUse();
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = { p, f };
double[] rowSize = { p, p, p};
Component[][] components = new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{null, null}
};
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components,rowSize,columnSize,24,6);
panel.setBorder(BorderFactory.createEmptyBorder(0,24,0,15));
this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.NORTH);
filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
JPanel pane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane);
pane.setBorder(getSidesBorder());
filterPane.setBorder(getFilterPaneBorder());
this.add(pane, BorderLayout.CENTER);
}
protected String getCateNameString() {
return CATENAME;
}
protected String getNValueString() {
return NVALUE;
}
public void populateBean(ChartCollection collection) {
TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition();
if(definition instanceof MeterReportDefinition) {
MeterReportDefinition meterDefinition = (MeterReportDefinition)definition;
if (meterDefinition.getName() != null) {
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {p, f};
double[] rowSize = getRowSize();
Component[][] components = getShowComponents();
JPanel panel = TableLayoutHelper.createGapTableLayoutPane(components, rowSize, columnSize, 24, 6);
panel.setBorder(BorderFactory.createEmptyBorder(0, 24, 5, 15));
this.setLayout(new BorderLayout());
this.add(panel, BorderLayout.NORTH);
filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
JPanel pane = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), filterPane);
pane.setBorder(getSidesBorder());
filterPane.setBorder(getFilterPaneBorder());
this.add(pane, BorderLayout.CENTER);
}
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
new Component[]{new UILabel(TARGET_VALUE), customPane = new TinyFormulaPane()}
};
}
protected String getCateNameString() {
return CATENAME;
}
protected String getNValueString() {
return NVALUE;
}
public void populateBean(ChartCollection collection) {
TopDefinitionProvider definition = collection.getSelectedChart().getFilterDefinition();
if (definition instanceof MeterReportDefinition) {
MeterReportDefinition meterDefinition = (MeterReportDefinition) definition;
if (meterDefinition.getName() != null) {
populateSingCatePane(meterDefinition.getName().toString());
}
if (meterDefinition.getValue() != null) {
singValuePane.getUITextField().setText(meterDefinition.getValue().toString());
}
}
filterPane.populateBean(collection);
}
}
if (meterDefinition.getValue() != null) {
singValuePane.getUITextField().setText(meterDefinition.getValue().toString());
}
if (meterDefinition.getTarget() != null) {
populateCustomPane(meterDefinition.getTarget().toString());
}
}
filterPane.populateBean(collection);
}
protected void populateCustomPane(String target) {
customPane.getUITextField().setText(target);
}
protected void populateSingCatePane(String name) {
singCatePane.getUITextField().setText(name);
}
public void updateBean(ChartCollection collection) {
if (collection != null) {
MeterReportDefinition meterDefinition = new MeterReportDefinition();
if (collection != null) {
MeterReportDefinition meterDefinition = new MeterReportDefinition();
updateSingCatePane(meterDefinition);
meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText()));
collection.getSelectedChart().setFilterDefinition(meterDefinition);
filterPane.updateBean(collection);
}
}
meterDefinition.setValue(canBeFormula(singValuePane.getUITextField().getText()));
updateCustomPane(meterDefinition);
collection.getSelectedChart().setFilterDefinition(meterDefinition);
filterPane.updateBean(collection);
}
}
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
meterDefinition.setTarget(canBeFormula(customPane.getUITextField().getText()));
}
protected void updateSingCatePane(MeterReportDefinition meterDefinition) {
@ -116,9 +143,9 @@ public class MeterPlotReportDataContentPane extends AbstractReportDataContentPan
}
@Override
protected String[] columnNames() {
return new String[]{"", ""};
}
protected String[] columnNames() {
return new String[]{"", ""};
}
protected Component getSingCatePane() {
return singCatePane = new TinyFormulaPane();

210
designer-chart/src/main/java/com/fr/design/mainframe/chart/gui/data/table/MeterPlotTableDataContentPane.java

@ -4,117 +4,183 @@ import com.fr.base.Utils;
import com.fr.chart.chartattr.ChartCollection;
import com.fr.chart.chartattr.MeterPlot;
import com.fr.chart.chartdata.MeterTableDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.ilable.BoldFontTextLabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.ChartDataFilterPane;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.extended.chart.StringFormula;
import com.fr.extended.chart.UIComboBoxWithNone;
import com.fr.general.GeneralUtils;
import com.fr.stable.StringUtils;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import javax.swing.BorderFactory;
import javax.swing.BoxLayout;
import javax.swing.JPanel;
import java.util.List;
import java.awt.BorderLayout;
import java.awt.Component;
import java.util.List;
import java.awt.Dimension;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
/**
* 仪表盘, 属性表, 数据集数据界面.
*
* @author kunsnat E-mail:kunsnat@gmail.com
* @version 创建时间2012-12-21 下午04:51:50
*/
public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane {
private static final String METER_NAME = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name");
private static final String METER_VALUE = com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private UIComboBox nameBox;
private UIComboBox valueBox;
private ChartDataFilterPane filterPane;
public MeterPlotTableDataContentPane(ChartDataPane parent) {
this.setLayout(new BorderLayout());
nameBox = new UIComboBox();
valueBox = new UIComboBox();
filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f, COMPONENT_WIDTH};
double[] rowSize = {p, p};
Component[][] components = createComponents();
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"),filterPane);
JPanel panel = TableLayoutHelper.createTableLayoutPane(components,rowSize,columnSize);
filterPane.setBorder(BorderFactory.createEmptyBorder(0,10,0,15));
panel.setBorder(BorderFactory.createEmptyBorder(10,24,10,15));
jPanel.setBorder(BorderFactory.createEmptyBorder(0,12,0,5));
this.add(getJSeparator(),BorderLayout.NORTH);
this.add(panel,BorderLayout.CENTER);
this.add(jPanel,BorderLayout.SOUTH);
private static final String METER_NAME = Toolkit.i18nText("Fine-Design_Chart_Style_Format_Category_Name");
private static final String METER_VALUE = Toolkit.i18nText("Fine-Design_Chart_Pointer_Value");
private static final String TARGET_VALUE = Toolkit.i18nText("Fine-Design_Chart_Target_Value");
private static final int COMBOBOX_WIDTH = 115;
private static final int COMBOBOX_HEIGHT = 20;
private static final int LABEL_WIDTH = 85;
private UIComboBox nameBox;
private UIComboBox valueBox;
private UIComboBox targetBox;
private TinyFormulaPane custom;
private ChartDataFilterPane filterPane;
private JPanel boxPane;
public MeterPlotTableDataContentPane(ChartDataPane parent) {
this.setLayout(new BorderLayout());
nameBox = new UIComboBoxWithNone();
valueBox = new UIComboBox();
targetBox = new UIComboBox();
custom = new TinyFormulaPane();
filterPane = new ChartDataFilterPane(new MeterPlot(), parent);
boxPane = new JPanel();
boxPane.setLayout(new BoxLayout(boxPane, BoxLayout.Y_AXIS));
JPanel namePane = createPaneWithLabel(Toolkit.i18nText(METER_NAME), getNameComponent());
boxPane.add(namePane);
JPanel valuePane = createPaneWithLabel(Toolkit.i18nText(METER_VALUE), valueBox);
boxPane.add(valuePane);
JPanel targetPane = createPaneWithLabel(Toolkit.i18nText(TARGET_VALUE), targetBox);
boxPane.add(targetPane);
final JPanel customPane = createPaneWithLabel(StringUtils.EMPTY, custom);
boxPane.add(customPane);
customPane.setVisible(false);
initTargetBoxValue();
targetBox.addItemListener(new ItemListener() {
@Override
public void itemStateChanged(ItemEvent e) {
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
customPane.setVisible(true);
} else {
customPane.setVisible(false);
}
}
});
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Data_Filter"), filterPane);
filterPane.setBorder(BorderFactory.createEmptyBorder(0, 10, 0, 15));
boxPane.setBorder(BorderFactory.createEmptyBorder(7, 24, 7, 15));
jPanel.setBorder(BorderFactory.createEmptyBorder(0, 12, 0, 5));
this.add(getJSeparator(), BorderLayout.NORTH);
this.add(boxPane, BorderLayout.CENTER);
this.add(jPanel, BorderLayout.SOUTH);
nameBox.addItemListener(tooltipListener);
valueBox.addItemListener(tooltipListener);
}
targetBox.addItemListener(tooltipListener);
}
private Component[][] createComponents() {
return new Component[][]{
new Component[]{new BoldFontTextLabel(METER_NAME), getNameComponent()},
new Component[]{new BoldFontTextLabel(METER_VALUE), valueBox},
};
private JPanel createPaneWithLabel(String labelName, Component component) {
component.setPreferredSize(new Dimension(COMBOBOX_WIDTH, COMBOBOX_HEIGHT));
UILabel label = new BoldFontTextLabel(labelName);
label.setPreferredSize(new Dimension(LABEL_WIDTH, COMBOBOX_HEIGHT));
JPanel paneWithLabel = GUICoreUtils.createBorderLayoutPane(new Component[]{component, null, null, label, null});
paneWithLabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 0));
return paneWithLabel;
}
protected void refreshBoxListWithSelectTableData(List list) {
refreshBoxItems(nameBox, list);
refreshBoxItems(valueBox, list);
}
refreshBoxItems(nameBox, list);
refreshBoxItems(valueBox, list);
refreshBoxItems(targetBox, list);
initTargetBoxValue();
}
/**
* 清空所有的box设置
*/
public void clearAllBoxList(){
public void clearAllBoxList() {
clearBoxItems(nameBox);
clearBoxItems(valueBox);
}
/**
* 更新仪表盘数据界面
*/
public void populateBean(ChartCollection ob) {
if(ob != null && ob.getSelectedChart().getFilterDefinition() instanceof MeterTableDefinition) {
MeterTableDefinition meter = (MeterTableDefinition)ob.getSelectedChart().getFilterDefinition();
private void initTargetBoxValue() {
targetBox.addItem(Toolkit.i18nText("Fine-Design_Chart_Custom"));
targetBox.setSelectedItem(null);
}
/**
* 更新仪表盘数据界面
*/
public void populateBean(ChartCollection ob) {
if (ob != null && ob.getSelectedChart().getFilterDefinition() instanceof MeterTableDefinition) {
MeterTableDefinition meter = (MeterTableDefinition) ob.getSelectedChart().getFilterDefinition();
populateNameComponent(meter);
valueBox.setSelectedItem(meter.getValue());
filterPane.populateBean(ob);
}
}
valueBox.setSelectedItem(meter.getValue());
custom.getUITextField().setText(meter.getCustomTarget().getContent());
if (meter.isCustom()) {
targetBox.setSelectedIndex(targetBox.getItemCount() - 1);
} else {
targetBox.setSelectedItem(meter.getTargetValue());
}
filterPane.populateBean(ob);
}
}
protected void populateNameComponent(MeterTableDefinition meter) {
nameBox.setSelectedItem(meter.getName());
}
/**
* 保存界面属性.
*/
public void updateBean(ChartCollection ob) {
if(ob != null) {
MeterTableDefinition meter = getMeterTableDefinition();
ob.getSelectedChart().setFilterDefinition(meter);
* 保存界面属性.
*/
public void updateBean(ChartCollection ob) {
if (ob != null) {
MeterTableDefinition meter = getMeterTableDefinition();
ob.getSelectedChart().setFilterDefinition(meter);
updateNameComponent(meter);
meter.setValue(Utils.objectToString(valueBox.getSelectedItem()));
filterPane.updateBean(ob);
}
}
meter.setValue(Utils.objectToString(valueBox.getSelectedItem()));
if (targetBox.getSelectedIndex() == targetBox.getItemCount() - 1) {
meter.setCustom(true);
meter.setCustomTarget(new StringFormula(custom.getUITextField().getText()));
} else {
meter.setCustom(false);
meter.setTargetValue(GeneralUtils.objectToString(targetBox.getSelectedItem()));
}
filterPane.updateBean(ob);
}
}
protected MeterTableDefinition getMeterTableDefinition(){
protected MeterTableDefinition getMeterTableDefinition() {
return new MeterTableDefinition();
}
@ -125,9 +191,9 @@ public class MeterPlotTableDataContentPane extends AbstractTableDataContentPane
/**
* 重新布局整个面板
*/
public void redoLayoutPane(){
filterPane.relayoutPane(this.isNeedSummaryCaculateMethod());
}
public void redoLayoutPane() {
filterPane.relayoutPane(this.isNeedSummaryCaculateMethod());
}
protected Component getNameComponent() {

92
designer-chart/src/main/java/com/fr/design/module/ChartEmptyDataStylePane.java

@ -2,11 +2,13 @@ package com.fr.design.module;
import com.fr.base.BaseUtils;
import com.fr.base.ChartEmptyDataStyleConf;
import com.fr.base.Style;
import com.fr.design.gui.frpane.AbstractAttrNoScrollPane;
import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.ibutton.UIButtonGroup;
import com.fr.design.gui.ibutton.UIRadioButton;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.i18n.Toolkit;
import com.fr.design.layout.FRGUIPaneFactory;
import com.fr.design.style.background.image.ImageFileChooser;
import com.fr.design.style.background.image.ImagePreviewPane;
@ -14,7 +16,7 @@ import com.fr.design.utils.ImageUtils;
import com.fr.design.utils.gui.GUICoreUtils;
import com.fr.general.GeneralContext;
import com.fr.general.IOUtils;
import com.fr.stable.Constants;
import com.fr.stable.CoreGraphHelper;
import com.fr.stable.StringUtils;
@ -24,6 +26,7 @@ import javax.swing.JFileChooser;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.SwingWorker;
import java.io.File;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
@ -32,7 +35,6 @@ import java.awt.GridLayout;
import java.awt.Image;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
/**
* Created by mengao on 2017/11/23.
@ -47,8 +49,10 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private UIButtonGroup emptyData;
private UILabel imageContent;
private UIButtonGroup imageData;
private UIRadioButton defaultRadioButton;
private UIRadioButton customRadioButton;
private UIRadioButton adjustRadioButton;
private UIButton selectPictureButton;
private ImagePreviewPane previewPane;
@ -72,7 +76,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
}
private JPanel creatNorthPane() {
emptyData = new UIButtonGroup(new String[]{com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Open"), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Close")});
emptyData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Open"), Toolkit.i18nText("Fine-Design_Chart_Close")});
emptyData.setSelectedIndex(0);
emptyData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
emptyData.addActionListener(new ActionListener() {
@ -83,8 +87,24 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
}
});
UILabel promptContent = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Tip_Content"));
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0);
imageData = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Mode_Auto"), Toolkit.i18nText("Fine-Design_Chart_Mode_Custom")});
imageData.setSelectedIndex(0);
imageData.setPreferredSize(new Dimension(WIDTH, HEIGHT));
imageData.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
emptyDataImage = null;
checkIsCustom();
repaintPreviewPane();
}
});
UILabel promptContent = new UILabel(Toolkit.i18nText("Fine-Design_Chart_Tip_Content"));
imageContent = new UILabel(Toolkit.i18nText("Fine-Design_Report_Image"));
JPanel emptyPane = GUICoreUtils.createFlowPane(new Component[]{promptContent, emptyData}, FlowLayout.LEFT, TEN, 0);
JPanel imagePane = GUICoreUtils.createFlowPane(new Component[]{imageContent, imageData}, FlowLayout.LEFT, TEN, 0);
imagePane.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0));
JPanel northPane = GUICoreUtils.createFlowPane(new Component[]{emptyPane, imagePane}, FlowLayout.LEFT, 0, 0);
northPane.setBorder(BorderFactory.createEmptyBorder(0, FIVE, 0, 0));
return northPane;
}
@ -96,7 +116,7 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
JPanel previewContainerPane = FRGUIPaneFactory.createBorderLayout_L_Pane();
centerPane.add(previewContainerPane, BorderLayout.CENTER);
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Preview"));
JPanel previewOwnerPane = FRGUIPaneFactory.createTitledBorderPane(Toolkit.i18nText("Fine-Design_Basic_Preview"));
previewOwnerPane.setLayout(new BorderLayout());
previewContainerPane.add(previewOwnerPane, BorderLayout.CENTER);
previewContainerPane.add(initSelectFilePane(), BorderLayout.EAST);
@ -116,25 +136,27 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
selectFilePane.setBorder(BorderFactory.createEmptyBorder(TEN, FIVE, 0, THIRTY));
defaultRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Default"));
customRadioButton = new UIRadioButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Widget_Style_Custom"));
defaultRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Default"));
adjustRadioButton = new UIRadioButton(Toolkit.i18nText("Fine-Design_Report_Image_Adjust"));
ButtonGroup buttonGroup = new ButtonGroup();
defaultRadioButton.setSelected(true);
buttonGroup.add(defaultRadioButton);
buttonGroup.add(customRadioButton);
buttonGroup.add(adjustRadioButton);
defaultRadioButton.setEnabled(false);
adjustRadioButton.setEnabled(false);
defaultRadioButton.addActionListener(getLayoutActionListener());
customRadioButton.addActionListener(getLayoutActionListener());
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(defaultRadioButton);
jp.add(customRadioButton);
adjustRadioButton.addActionListener(getLayoutActionListener());
selectPictureButton = new UIButton(
com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select"));
Toolkit.i18nText("Fine-Design_Basic_Background_Image_Select"));
selectPictureButton.setEnabled(false);
selectPictureButton.addActionListener(getSelectPictureActionListener());
jp.add(selectPictureButton);
JPanel jp = new JPanel(new GridLayout(3, 1, 0, TEN));
jp.add(selectPictureButton);
jp.add(defaultRadioButton);
jp.add(adjustRadioButton);
selectFilePane.add(jp, BorderLayout.NORTH);
return selectFilePane;
@ -142,10 +164,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private ActionListener getLayoutActionListener() {
return new ActionListener() {
public void actionPerformed(ActionEvent evt) {
emptyDataImage = null;
checkCustomImage();
setImageStyle();
repaintPreviewPane();
}
};
@ -188,17 +208,30 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
private void checkEmptyDataStyle() {
boolean b = emptyData.getSelectedIndex() == 0;
defaultRadioButton.setVisible(b);
adjustRadioButton.setVisible(b);
selectPictureButton.setVisible(b);
imageContent.setVisible(b);
imageData.setVisible(b);
}
private void checkIsCustom() {
boolean b = imageData.getSelectedIndex() == 1;
defaultRadioButton.setEnabled(b);
customRadioButton.setEnabled(b);
adjustRadioButton.setEnabled(b);
selectPictureButton.setEnabled(b);
}
private void checkCustomImage() {
selectPictureButton.setVisible(customRadioButton.isSelected());
private void setImageStyle() {
if (adjustRadioButton.isSelected()) {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_ADJUST));
} else {
previewPane.setImageStyle(Style.DEFAULT_STYLE.deriveImageLayout(Constants.IMAGE_CENTER));
}
}
private void repaintPreviewPane() {
emptyDataImage = customRadioButton.isSelected() ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE;
emptyDataImage = imageData.getSelectedIndex() == 1 ? emptyDataImage : DEFAULT_EMPTY_DATA_IMAGE;
previewPane.setImage(emptyData.getSelectedIndex() == 0 ? emptyDataImage : null);
previewPane.repaint();
}
@ -215,12 +248,14 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
public void populateBean() {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() == true ? 0 : 1);
customRadioButton.setSelected(manager.isCustomEmptyDataStyle());
emptyData.setSelectedIndex(manager.isOpenEmptyDataStyle() ? 0 : 1);
imageData.setSelectedIndex(manager.isCustomEmptyDataStyle() ? 1 : 0);
adjustRadioButton.setSelected(manager.isAdjust());
emptyDataImage = manager.getEmptyDataImage();
checkEmptyDataStyle();
checkCustomImage();
checkIsCustom();
setImageStyle();
repaintPreviewPane();
}
@ -228,7 +263,8 @@ public class ChartEmptyDataStylePane extends AbstractAttrNoScrollPane {
ChartEmptyDataStyleConf manager = ChartEmptyDataStyleConf.getInstance();
manager.setOpenEmptyDataStyle(emptyData.getSelectedIndex() == 0);
manager.setCustomEmptyDataStyle(customRadioButton.isSelected());
manager.setCustomEmptyDataStyle(imageData.getSelectedIndex() == 1);
manager.setAdjust(adjustRadioButton.isSelected());
manager.setEmptyDataImage(emptyDataImage);
}
}

27
designer-chart/src/main/java/com/fr/van/chart/designer/data/OneDimensionalPlotReportDataContentPane.java

@ -1,15 +1,20 @@
package com.fr.van.chart.designer.data;
import com.fr.chart.chartdata.MeterReportDefinition;
import com.fr.design.formula.TinyFormulaPane;
import com.fr.design.gui.ilable.UILabel;
import com.fr.design.layout.TableLayout;
import com.fr.design.mainframe.chart.gui.ChartDataPane;
import com.fr.design.mainframe.chart.gui.data.report.MeterPlotReportDataContentPane;
import java.awt.Component;
/**
* Created by Mitisky on 16/10/25.
* 一维 单元格数据配置界面.系列名,.
*/
public class OneDimensionalPlotReportDataContentPane extends MeterPlotReportDataContentPane{
public class OneDimensionalPlotReportDataContentPane extends MeterPlotReportDataContentPane {
public OneDimensionalPlotReportDataContentPane(ChartDataPane parent) {
super(parent);
}
@ -23,4 +28,24 @@ public class OneDimensionalPlotReportDataContentPane extends MeterPlotReportData
protected String getNValueString() {
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Chart_Series_Value");
}
@Override
protected double[] getRowSize() {
double p = TableLayout.PREFERRED;
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents() {
return new Component[][]{
new Component[]{new UILabel(getCateNameString()), getSingCatePane()},
new Component[]{new UILabel(getNValueString()), singValuePane = new TinyFormulaPane()},
};
}
protected void populateCustomPane(String target) {
}
protected void updateCustomPane(MeterReportDefinition meterDefinition) {
}
}

18
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartPlotLegendPane.java

@ -253,23 +253,15 @@ public class VanChartPlotLegendPane extends BasicPane {
});
customFloatPositionButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if(!customFloatPositionButton.isSelected()){
customFloatPositionButton.setSelected(true);
checkLayoutPaneVisible();
checkDisplayStrategyUse();
}
}
@Override
public void mousePressed(MouseEvent e) {
location.setSelectedIndex(-1);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
location.setSelectedIndex(-1);
customFloatPositionButton.setSelected(true);
checkLayoutPaneVisible();
checkDisplayStrategyUse();
if(customFloatPositionPane == null) {
customFloatPositionPane = new VanChartFloatPositionPane();
}

17
designer-chart/src/main/java/com/fr/van/chart/designer/style/VanChartTitlePane.java

@ -214,23 +214,14 @@ public class VanChartTitlePane extends AbstractVanChartScrollPane<VanChart> {
});
customFloatPositionButton.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
if (!customFloatPositionButton.isSelected()) {
customFloatPositionButton.setSelected(true);
checkDisplayStrategyUse();
}
}
@Override
public void mousePressed(MouseEvent e) {
alignmentPane.setSelectedIndex(-1);
}
@Override
public void mouseReleased(MouseEvent e) {
super.mouseReleased(e);
alignmentPane.setSelectedIndex(-1);
customFloatPositionButton.setSelected(true);
checkDisplayStrategyUse();
if (customFloatPositionPane == null) {
customFloatPositionPane = new VanChartFloatPositionPane();
}

77
designer-chart/src/main/java/com/fr/van/chart/designer/style/axis/gauge/VanChartGaugeDetailAxisPane.java

@ -9,7 +9,6 @@ import com.fr.design.mainframe.chart.PaneTitleConstants;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane;
import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPaneWithAuto;
import com.fr.design.style.color.ColorSelectBox;
import com.fr.plugin.chart.attr.axis.VanChartAxis;
import com.fr.plugin.chart.attr.axis.VanChartGaugeAxis;
import com.fr.plugin.chart.gauge.VanChartGaugePlot;
@ -18,7 +17,6 @@ import com.fr.plugin.chart.type.GaugeStyle;
import com.fr.van.chart.designer.TableLayout4VanChartHelper;
import com.fr.van.chart.designer.style.VanChartStylePane;
import com.fr.van.chart.designer.style.axis.VanChartValueAxisPane;
import com.fr.van.chart.designer.style.axis.component.MinMaxValuePaneWithOutTick;
import com.fr.van.chart.designer.style.axis.component.VanChartMinMaxValuePane;
import javax.swing.BorderFactory;
@ -43,19 +41,19 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
public VanChartGaugeDetailAxisPane() {
}
protected JPanel createContentPane(boolean isXAxis){
if(gaugeStyle == null){
protected JPanel createContentPane(boolean isXAxis) {
if (gaugeStyle == null) {
gaugeStyle = GaugeStyle.POINTER;
}
double p = TableLayout.PREFERRED;
double f = TableLayout.FILL;
double[] columnSize = {f, p};
double[] rowSize = {p,p,p,p,p,p,p,p};
double[] rowSize = {p, p, p, p, p, p, p, p};
return TableLayoutHelper.createTableLayoutPane(getPanelComponents(p, f, columnSize), rowSize, columnSize);
}
private Component[][] getPanelComponents(double p, double f, double[] columnSize) {
switch (gaugeStyle){
switch (gaugeStyle) {
case THERMOMETER:
return new Component[][]{
new Component[]{createLabelPane(new double[]{p, p}, columnSize), null},
@ -80,12 +78,12 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
}
}
protected JPanel createLabelPane(double[] row, double[] col){
protected JPanel createLabelPane(double[] row, double[] col) {
showLabel = new UIButtonGroup(new String[]{Toolkit.i18nText("Fine-Design_Chart_Use_Show"), Toolkit.i18nText("Fine-Design_Chart_Hidden")});
labelTextAttrPane = getChartTextAttrPane();
labelPanel = new JPanel(new BorderLayout());
labelPanel.add(labelTextAttrPane);
labelPanel.setBorder(BorderFactory.createEmptyBorder(0,15,0,0));
labelPanel.setBorder(BorderFactory.createEmptyBorder(0, 15, 0, 0));
JPanel panel = new JPanel(new BorderLayout(0, 6));
panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Axis_Label"), showLabel), BorderLayout.NORTH);
panel.add(labelPanel, BorderLayout.CENTER);
@ -96,7 +94,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
}
});
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(PaneTitleConstants.CHART_STYLE_LABEL_TITLE, panel);
panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 15));
return jPanel;
}
@ -108,11 +106,40 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
}
}
private JPanel createValueDefinition(){
switch (gaugeStyle){
private JPanel createValueDefinition() {
switch (gaugeStyle) {
case RING:
case SLOT:
minMaxValuePane = new MinMaxValuePaneWithOutTick();
minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
};
}
};
break;
case THERMOMETER:
minMaxValuePane = new VanChartMinMaxValuePane() {
@Override
protected double[] getRowSize(double p) {
return new double[]{p, p, p};
}
@Override
protected Component[][] getShowComponents(JPanel minPaneWithCheckBox, JPanel maxPaneWithCheckBox, JPanel mainPaneWithCheckBox, JPanel secPaneWithCheckBox) {
return new Component[][]{
{minPaneWithCheckBox},
{mainPaneWithCheckBox},
{secPaneWithCheckBox},
};
}
};
break;
default:
minMaxValuePane = new VanChartMinMaxValuePane();
@ -121,7 +148,7 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Value_Definition"), minMaxValuePane);
}
private JPanel createTickColorPane(double[] row, double[] col){
private JPanel createTickColorPane(double[] row, double[] col) {
mainTickColor = new ColorSelectBox(100);
secTickColor = new ColorSelectBox(100);
Component[][] components = new Component[][]{
@ -130,20 +157,20 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
};
JPanel panel = TableLayoutHelper.createTableLayoutPane(components, row, col);
JPanel jPanel = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_TickColor"), panel);
panel.setBorder(BorderFactory.createEmptyBorder(10,10,0,15));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 0, 15));
return jPanel;
}
private boolean isMulti(GaugeStyle style){
private boolean isMulti(GaugeStyle style) {
return style == GaugeStyle.POINTER || style == GaugeStyle.POINTER_SEMI;
}
private boolean samePane(GaugeStyle style1, GaugeStyle style2){
private boolean samePane(GaugeStyle style1, GaugeStyle style2) {
return style1 == style2 || (isMulti(style1) && isMulti(style2));
}
public void populateBean(VanChartGaugePlot gaugePlot, VanChartStylePane parent){
if(!samePane(gaugePlot.getGaugeStyle(), gaugeStyle)){
public void populateBean(VanChartGaugePlot gaugePlot, VanChartStylePane parent) {
if (!samePane(gaugePlot.getGaugeStyle(), gaugeStyle)) {
gaugeStyle = gaugePlot.getGaugeStyle();
reLayoutPane(false);
parent.initAllListeners();
@ -151,23 +178,23 @@ public class VanChartGaugeDetailAxisPane extends VanChartValueAxisPane {
populateBean(gaugePlot.getGaugeAxis());
}
public void populateBean(VanChartAxis axis){
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis)axis;
if(mainTickColor != null){
public void populateBean(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
if (mainTickColor != null) {
mainTickColor.setSelectObject(gaugeAxis.getMainTickColor());
}
if(secTickColor != null){
if (secTickColor != null) {
secTickColor.setSelectObject(gaugeAxis.getSecTickColor());
}
super.populateBean(gaugeAxis);
}
public void updateBean(VanChartAxis axis) {
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis)axis;
if(mainTickColor != null){
VanChartGaugeAxis gaugeAxis = (VanChartGaugeAxis) axis;
if (mainTickColor != null) {
gaugeAxis.setMainTickColor(mainTickColor.getSelectObject());
}
if(secTickColor != null){
if (secTickColor != null) {
gaugeAxis.setSecTickColor(secTickColor.getSelectObject());
}
super.updateBean(gaugeAxis);

3
designer-form/build.gradle

@ -0,0 +1,3 @@
dependencies {
compile project(':designer-base')
}

11
designer-form/src/main/java/com/fr/design/designer/beans/models/AddingModel.java

@ -26,9 +26,8 @@ public class AddingModel {
private boolean added;
public AddingModel(FormDesigner designer, XCreator xCreator) {
String creatorName = getXCreatorName(designer, xCreator);
this.creator = xCreator;
instantiateCreator(designer, creatorName);
instantiateCreator(designer);
// 初始的时候隐藏该组件的图标
currentY = -this.creator.getWidth();
currentX = -this.creator.getHeight();
@ -37,11 +36,11 @@ public class AddingModel {
/**
* 待说明
*
* @param designer 设计器
* @param creatorName 组件名
* @param designer 设计器
*/
public void instantiateCreator(FormDesigner designer, String creatorName) {
creator.toData().setWidgetName(creatorName);
public void instantiateCreator(FormDesigner designer) {
ModelUtil.renameWidgetName(designer.getTarget(), creator);
ComponentAdapter adapter = new CompositeComponentAdapter(designer, creator);
adapter.initialize();
creator.addNotify();

55
designer-form/src/main/java/com/fr/design/designer/beans/models/ModelUtil.java

@ -0,0 +1,55 @@
package com.fr.design.designer.beans.models;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XWParameterLayout;
import com.fr.form.main.Form;
import com.fr.form.ui.Widget;
import com.fr.stable.StringUtils;
import java.util.HashSet;
import java.util.Set;
/**
* created by Harrison on 2020/06/05
**/
abstract class ModelUtil {
public static void renameWidgetName(Form form, XCreator xCreator) {
Set<String> duplicated = new HashSet<>();
recursiveRenameWidgetName(form, xCreator, duplicated);
}
private static void recursiveRenameWidgetName(Form form, XCreator xCreator, Set<String> duplicated) {
Set<XCreator> nameRelatedCreators = new HashSet<>();
//直接遍历出来目标值,然后按需处理
xCreator.traversalNameRelatedXCreators(nameRelatedCreators);
for (XCreator target : nameRelatedCreators) {
String uniqueName = uniqueName(form, target, duplicated);
target.resetCreatorName(uniqueName);
}
}
private static String uniqueName(Form form, XCreator xCreator, Set<String> duplicated) {
if (xCreator.acceptType(XWParameterLayout.class)) {
return xCreator.createDefaultName();
}
Widget widget = xCreator.toData();
String widgetName = widget.getWidgetName();
if (StringUtils.isEmpty(widgetName)) {
widgetName = xCreator.createDefaultName();
}
String raw = widgetName;
int i = 0;
while (form.isNameExist(widgetName) || duplicated.contains(widgetName)) {
widgetName = raw + i;
i++;
}
//将名字加入重复集合中
duplicated.add(widgetName);
return widgetName;
}
}

11
designer-form/src/main/java/com/fr/design/designer/creator/DedicateLayoutContainer.java

@ -9,6 +9,7 @@ import java.awt.Component;
import java.awt.Dimension;
import java.beans.IntrospectionException;
import java.util.List;
import java.util.Set;
/**
* 一些控件专属的容器如标题容器sclae容器
@ -69,13 +70,19 @@ public abstract class DedicateLayoutContainer extends XLayoutContainer {
//实现WTitleLayout的SetWidgetName
child.toData().setWidgetName(name);
}
@Override
public void traversalNameRelatedXCreators(Set<XCreator> xCreators) {
xCreators.add(this);
}
/**
* 重置组件的可见性
*
* @param visible 可见性
*/
@Override
public void resetVisible(boolean visible){
public void resetVisible(boolean visible) {
super.resetVisible(visible);
XCreator child = getXCreator(XWScaleLayout.INDEX);
child.toData().setVisible(visible);

32
designer-form/src/main/java/com/fr/design/designer/creator/XCreator.java

@ -41,6 +41,7 @@ import java.awt.event.MouseEvent;
import java.beans.IntrospectionException;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author richer
@ -407,24 +408,47 @@ public abstract class XCreator extends JPanel implements XComponent, XCreatorToo
public Component getParentShow(){
return this.getParent();
}
/**
* 重置组件的名称
*
* @param name 名称
*/
@Override
public void resetCreatorName(String name) {
toData().setWidgetName(name);
}
/**
* 遍历所有命名相关的组件到集合中
*
* @param xCreators 集合
*/
public void traversalNameRelatedXCreators(Set<XCreator> xCreators) {
xCreators.add(this);
int componentCount = getComponentCount();
for (int i = 0; i < componentCount; i++) {
Component component = getComponent(i);
if (component instanceof XCreator) {
XCreator xCreator = (XCreator) component;
//获取真实的 creator
XCreator realCreator = xCreator.getXCreator();
realCreator.traversalNameRelatedXCreators(xCreators);
}
}
}
/**
* 重置组件的可见性
*
* @param visible 可见性
*/
public void resetVisible(boolean visible){
public void resetVisible(boolean visible) {
toData().setVisible(visible);
}
/**
* 返回编辑的子组件scale为其内部组件
* @return 组件

17
designer-form/src/main/java/com/fr/design/designer/creator/cardlayout/XWCardLayout.java

@ -433,13 +433,16 @@ public class XWCardLayout extends XLayoutContainer {
//修改相关SwitchButton所绑定的cardLayout控件名
private void changeRelateSwitchCardName(String cardLayoutName) {
XWCardMainBorderLayout borderLayout = (XWCardMainBorderLayout) this.getBackupParent();
WCardMainBorderLayout border = borderLayout.toData();
WCardTitleLayout titleLayout = border.getTitlePart();
titleLayout.setCardName(cardLayoutName);
WCardTagLayout tagLayout = titleLayout.getTagPart();
for (int i = 0, len = tagLayout.getWidgetCount(); i < len; i++) {
CardSwitchButton button = tagLayout.getSwitchButton(i);
button.setCardLayoutName(cardLayoutName);
//可能为空
if (borderLayout != null) {
WCardMainBorderLayout border = borderLayout.toData();
WCardTitleLayout titleLayout = border.getTitlePart();
titleLayout.setCardName(cardLayoutName);
WCardTagLayout tagLayout = titleLayout.getTagPart();
for (int i = 0, len = tagLayout.getWidgetCount(); i < len; i++) {
CardSwitchButton button = tagLayout.getSwitchButton(i);
button.setCardLayoutName(cardLayoutName);
}
}
}

206
designer-form/src/test/java/com/fr/design/designer/beans/models/AddingModelTest.java

@ -0,0 +1,206 @@
package com.fr.design.designer.beans.models;
import com.fr.base.chart.BaseChartCollection;
import com.fr.config.dao.DaoContext;
import com.fr.config.dao.impl.LocalClassHelperDao;
import com.fr.config.dao.impl.LocalEntityDao;
import com.fr.config.dao.impl.LocalXmlEntityDao;
import com.fr.design.designer.creator.CRPropertyDescriptor;
import com.fr.design.designer.creator.XChartEditor;
import com.fr.design.designer.creator.XCreator;
import com.fr.design.designer.creator.XLayoutContainer;
import com.fr.design.designer.creator.XWTitleLayout;
import com.fr.design.designer.creator.cardlayout.XWCardLayout;
import com.fr.design.gui.chart.MiddleChartComponent;
import com.fr.design.mainframe.FormDesigner;
import com.fr.design.module.DesignModuleFactory;
import com.fr.form.main.Form;
import com.fr.form.ui.ChartEditor;
import com.fr.form.ui.Widget;
import com.fr.form.ui.container.WAbsoluteLayout;
import com.fr.form.ui.container.WCardLayout;
import com.fr.form.ui.container.WTitleLayout;
import com.fr.stable.core.PropertyChangeListener;
import org.easymock.EasyMock;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import javax.swing.JComponent;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.beans.IntrospectionException;
@PrepareForTest({DesignModuleFactory.class})
@PowerMockIgnore({"com.sun.*", "javax.*", "com.fr.jvm.assist.*"})
@RunWith(PowerMockRunner.class)
public class AddingModelTest {
@Before
public void setUp() {
DaoContext.setXmlEntityDao(new LocalXmlEntityDao());
DaoContext.setClassHelperDao(new LocalClassHelperDao());
DaoContext.setEntityDao(new LocalEntityDao());
}
@After
public void tearDown() {
DaoContext.setXmlEntityDao(null);
DaoContext.setClassHelperDao(null);
DaoContext.setEntityDao(null);
}
@Test
public void testInstantiateCreator() throws Exception {
Dimension dimension = new Dimension(20, 20);
ChartEditor chartEditor1 = new ChartEditor();
XCreator xCreator1 = new DemoCreator(chartEditor1, dimension, "test");
ChartEditor chartEditor2 = new ChartEditor();
chartEditor2.setWidgetName("test02");
XCreator xCreator2 = new DemoCreator(chartEditor2, dimension, "test02");
xCreator1.add(xCreator2);
ChartEditor chartEditor3 = new ChartEditor();
chartEditor3.setWidgetName("test03");
WAbsoluteLayout.BoundsWidget boundsWidget = new WAbsoluteLayout.BoundsWidget(chartEditor3, new Rectangle(dimension));
WTitleLayout wTitleLayout03 = new WTitleLayout();
wTitleLayout03.addWidget(boundsWidget);
//需要和内部的 widget 一样
wTitleLayout03.setWidgetName("test03");
XWTitleLayout xCreator3 = new XWTitleLayout(wTitleLayout03, dimension);
xCreator1.add(xCreator3);
AddingModel addingModel = new AddingModel(xCreator1, 20, 20);
Form form = EasyMock.mock(Form.class);
EasyMock.expect(form.isNameExist("test")).andReturn(true).once();
EasyMock.expect(form.isNameExist("test03")).andReturn(true).once();
EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes();
EasyMock.replay(form);
FormDesigner mock = EasyMock.mock(FormDesigner.class);
EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes();
EasyMock.replay(mock);
addingModel.instantiateCreator(mock);
//没有默认参数, 但已经存在 test
Assert.assertEquals("test0", xCreator1.toData().getWidgetName());
//直接返回
Assert.assertEquals("test02", xCreator2.toData().getWidgetName());
//已经存在,后接0
Assert.assertEquals("test030", xCreator3.toData().getWidgetName());
}
@Test
public void testInstantiateCreator_cardLayout() throws Exception {
Form form = EasyMock.mock(Form.class);
EasyMock.expect(form.isNameExist("cardlayout")).andReturn(true).once();
EasyMock.expect(form.isNameExist("cardlayout0")).andReturn(true).once();
EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes();
EasyMock.replay(form);
FormDesigner mock = EasyMock.mock(FormDesigner.class);
EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes();
EasyMock.replay(mock);
WCardLayout wCardLayout = new WCardLayout(20, 20);
XWCardLayout xwCardLayout = new XWCardLayout(wCardLayout, new Dimension(40, 40));
AddingModel addingModel = new AddingModel(mock, xwCardLayout);
Assert.assertEquals("cardlayout1", xwCardLayout.toData().getWidgetName());
//依赖于 cardlayout 创建 container
XLayoutContainer parentLayOut = xwCardLayout.initCreatorWrapper(80);
AddingModel parentModel = new AddingModel(mock, parentLayOut);
Assert.assertEquals("tablayout1", parentLayOut.toData().getWidgetName());
Assert.assertEquals("tabpane1", ((XCreator) (parentLayOut.getComponent(0))).getXCreator().toData().getWidgetName());
}
@Test
public void testInstantiateCreator_containsNotXCreator() throws Exception {
Form form = EasyMock.mock(Form.class);
EasyMock.expect(form.isNameExist("cardlayout")).andReturn(true).once();
EasyMock.expect(form.isNameExist("cardlayout0")).andReturn(true).once();
EasyMock.expect(form.isNameExist(EasyMock.anyString())).andReturn(false).anyTimes();
EasyMock.replay(form);
FormDesigner mock = EasyMock.mock(FormDesigner.class);
EasyMock.expect(mock.getTarget()).andReturn(form).anyTimes();
EasyMock.replay(mock);
PowerMock.mockStaticPartial(DesignModuleFactory.class, "getChartComponent");
EasyMock.expect(DesignModuleFactory.getChartComponent(EasyMock.anyObject(BaseChartCollection.class))).andReturn(new MiddleChartComponent() {
@Override
public void populate(BaseChartCollection cc) {
}
@Override
public BaseChartCollection update() {
return null;
}
@Override
public void reset() {
}
@Override
public void addStopEditingListener(PropertyChangeListener list) {
}
}).anyTimes();
PowerMock.replayAll();
Dimension dimension = new Dimension(20, 20);
ChartEditor chartEditor1 = new ChartEditor();
XCreator xCreator1 = new XChartEditor(chartEditor1, dimension);
AddingModel chartModel = new AddingModel(mock, xCreator1);
Assert.assertEquals("chart", xCreator1.toData().getWidgetName());
}
private static class DemoCreator extends XCreator {
private String widgetName;
public DemoCreator(Widget ob, Dimension initSize, String widgetName) {
super(ob, initSize);
this.widgetName = widgetName;
}
@Override
public CRPropertyDescriptor[] supportedDescriptor() throws IntrospectionException {
return new CRPropertyDescriptor[0];
}
@Override
protected JComponent initEditor() {
return null;
}
@Override
protected void initXCreatorProperties() {
}
@Override
public String createDefaultName() {
return this.widgetName;
}
}
}

4
designer-realize/build.gradle

@ -0,0 +1,4 @@
dependencies {
compile project(':designer-form')
compile project(':designer-chart')
}

2
designer-realize/src/main/java/com/fr/design/mainframe/alphafine/listener/ComponentHandler.java

@ -1,6 +1,6 @@
package com.fr.design.mainframe.alphafine.listener;
import com.sun.awt.AWTUtilities;
import com.fr.design.utils.AWTUtilities;
import java.awt.*;
import java.awt.event.ComponentAdapter;

29
globalConfigHook.gradle

@ -0,0 +1,29 @@
def getRootGradle() {
def currentGradle = gradle
while (currentGradle.parent) {
currentGradle = currentGradle.parent
}
return currentGradle
}
def findHookIncludedBuild() {
def rootGradle = getRootGradle()
def hookProject = rootGradle.getIncludedBuilds()
.find({ build -> build.name == 'hook' })
return hookProject
}
def findGlobalConfig() {
def hookProject = findHookIncludedBuild()
if (hookProject) {
def path = hookProject.projectDir.parent + '/globalConfig.gradle'
if (file(path).exists()) {
return path
}
}
}
def globalConfigPath = findGlobalConfig()
if (globalConfigPath) {
apply from: globalConfigPath
}

BIN
gradle/wrapper/gradle-wrapper.jar vendored

Binary file not shown.

6
gradle/wrapper/gradle-wrapper.properties vendored

@ -0,0 +1,6 @@
#Wed Apr 22 15:17:12 CST 2020
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME

172
gradlew vendored

@ -0,0 +1,172 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"

84
gradlew.bat vendored

@ -0,0 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega

12
settings.gradle

@ -0,0 +1,12 @@
pluginManagement {
repositories {
maven {
url 'http://mvn.finedevelop.com/repository/maven-public/'
}
gradlePluginPortal()
}
}
rootProject.name = 'design'
include 'designer-base', 'designer-chart', 'designer-form', 'designer-realize'
Loading…
Cancel
Save