Browse Source
Merge in DESIGN/design from ~JEO/report-design:persist/10.0 to persist/10.0 * commit 'ca541bcfea535edc4eef51cb6275a349bf3f8fed': (135 commits) CHART-14399 坐标轴切换类型时,保留网格线类型和颜色 同步到final REPORT-34222 报表设计器给容器插件开个复制粘贴的接口 同步到final MOBILE-27698 移动端控件类插件设置边框不生效 REPORT-33599 设计器菜单栏导出txt,当修改导出的参数时模版会被刷新为待保存状态 && REPORT-33525 删除引用的Js或者css 有歧义 REPORT-33616 填报属性设置-智能添加单元格,确认和取消效果一样 CHART-14104 坐标轴切换前后,传递网格线属性 import设置不对 REPORT-33858 日志死循环的问题 CHART-13666 国际化修改 CHART-13666 CHART-13666 图表自动类型推荐 删除无用方法 代码简化 REPORT-31758【frm自适应重构05.25周】frm设计界面支持缩放 REPORT-33575 改下方法名称 REPORT-33575 远程连接启用https的环境,服务器关掉之后没有跳出切换工作目录的弹窗 && REPORT-33454 切换远程目录成功,弹窗提示切换失败 REPORT-33731 带参存储过程预览没有弹出参数输入框 MOBILE-27532 单选/复选按钮组自适应高度 REPORT-33459 启动后 设计器显示异常 CHART-14264 修改配色面板样式 ...persist/10.0 10.0.7.2020.06.25
Kara
4 years ago
134 changed files with 4205 additions and 1592 deletions
@ -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:6.23' |
||||
implementation 'com.fr.third:jxbrowser-swing:6.23' |
||||
implementation 'com.fr.third:jxbrowser-mac:6.23' |
||||
implementation 'com.fr.third:jxbrowser-win64:6.23' |
||||
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' |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
}); |
||||
} |
||||
} |
@ -0,0 +1,14 @@
|
||||
package com.fr.design.fun; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-06-12 |
||||
*/ |
||||
public interface ChartWidgetOptionProvider extends ParameterWidgetOptionProvider { |
||||
|
||||
String XML_TAG = "ChartWidgetOptionProvider"; |
||||
|
||||
//在图表区域的开头还是结尾插入
|
||||
boolean isBefore(); |
||||
} |
@ -0,0 +1,29 @@
|
||||
package com.fr.design.fun.impl; |
||||
|
||||
import com.fr.design.fun.ChartWidgetOptionProvider; |
||||
import com.fr.stable.fun.impl.AbstractProvider; |
||||
import com.fr.stable.fun.mark.API; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-06-12 |
||||
*/ |
||||
@API(level = ChartWidgetOptionProvider.CURRENT_LEVEL) |
||||
public abstract class AbstractChartWidgetOptionProvider extends AbstractProvider implements ChartWidgetOptionProvider { |
||||
|
||||
public int currentAPILevel() { |
||||
return CURRENT_LEVEL; |
||||
} |
||||
|
||||
@Override |
||||
public String mark4Provider() { |
||||
return getClass().getName(); |
||||
} |
||||
|
||||
@Override |
||||
public boolean isBefore() { |
||||
return false; |
||||
} |
||||
|
||||
} |
@ -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); |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
} |
After Width: | Height: | Size: 423 B |
@ -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()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,39 @@
|
||||
package com.fr.design.mainframe.mobile.ui; |
||||
|
||||
import com.fr.form.ui.container.cardlayout.WCardTagLayout; |
||||
import com.fr.general.cardtag.mobile.UniteStyle; |
||||
import com.fr.invoke.Reflect; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Test; |
||||
|
||||
import java.awt.*; |
||||
|
||||
public class UniteStyleDefinePaneTest extends TestCase { |
||||
|
||||
@Test |
||||
public void testDefaultConfig() { |
||||
UniteStyleDefinePane definePane = new UniteStyleDefinePane(new WCardTagLayout()); |
||||
Reflect.on(definePane).call("initDefaultConfig"); |
||||
|
||||
double paddingTop = Reflect.on(definePane).field("paddingTopSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingTop, UniteStyle.DEFAULT_PADDING_TOP); |
||||
double paddingBottom = Reflect.on(definePane).field("paddingBottomSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingBottom, UniteStyle.DEFAULT_PADDING_BOTTOM); |
||||
double paddingLeft = Reflect.on(definePane).field("paddingLeftSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingLeft, UniteStyle.DEFAULT_PADDING_LEFT); |
||||
double paddingRight = Reflect.on(definePane).field("paddingRightSpinner").call("getValue").get(); |
||||
assertEquals((int)paddingRight, UniteStyle.DEFAULT_PADDING_RIGHT); |
||||
|
||||
Color initialBackgroundColor = Reflect.on(definePane).field("initialBackgroundColorBox").call("getSelectObject").get(); |
||||
assertEquals(initialBackgroundColor, UniteStyle.DEFAULT_INITIAL_BACKGROUND_COLOR); |
||||
Color selectedBackgroundColor = Reflect.on(definePane).field("selectedBackgroundColorBox").call("getSelectObject").get(); |
||||
assertEquals(selectedBackgroundColor, UniteStyle.DEFAULT_SELECTED_BACKGROUND_COLOR); |
||||
|
||||
int lineStyle = Reflect.on(definePane).field("borderWidthComboBox").call("getSelectedLineStyle").get(); |
||||
assertEquals(lineStyle, UniteStyle.DEFAULT_BORDER_LINE.lineStyle); |
||||
Color borderColor = Reflect.on(definePane).field("borderColorBox").call("getSelectObject").get(); |
||||
assertEquals(borderColor, UniteStyle.DEFAULT_BORDER_LINE.color); |
||||
double borderRadius = Reflect.on(definePane).field("borderRadiusSpinner").call("getValue").get(); |
||||
assertEquals((int)borderRadius, UniteStyle.DEFAULT_BORDER_RADIUS); |
||||
} |
||||
} |
@ -0,0 +1,3 @@
|
||||
dependencies { |
||||
compile project(':designer-base') |
||||
} |
@ -0,0 +1,79 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.BaseChartCollection; |
||||
import com.fr.base.chart.chartdata.TopDefinitionProvider; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chartx.TwoTuple; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
|
||||
import java.awt.Component; |
||||
import java.awt.Dialog; |
||||
import java.awt.Frame; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-28 |
||||
*/ |
||||
public class AutoChartDialog extends ChartDialog { |
||||
|
||||
private AutoChartTypePane autoChartTypePane; |
||||
|
||||
public AutoChartDialog(Frame owner) { |
||||
super(owner); |
||||
} |
||||
|
||||
public AutoChartDialog(Dialog owner) { |
||||
super(owner); |
||||
} |
||||
|
||||
protected Component initCenterPane() { |
||||
autoChartTypePane = new AutoChartTypePane(); |
||||
|
||||
return autoChartTypePane; |
||||
} |
||||
|
||||
protected ActionListener getActionListener() { |
||||
return new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
ChartCollection chartCollection = (ChartCollection) getChartCollection(); |
||||
autoChartTypePane.update(chartCollection); |
||||
if (chartCollection.getChartCount() > 0) { |
||||
doOK(); |
||||
} else { |
||||
doCancel(); |
||||
} |
||||
} |
||||
}; |
||||
} |
||||
|
||||
protected String getDialogTitle() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Auto_Recommended_Chart"); |
||||
} |
||||
|
||||
/** |
||||
* 更新新建的图表 ChartCollection |
||||
*/ |
||||
public void populate(BaseChartCollection cc) { |
||||
super.populate(cc); |
||||
ChartCollection chartCollection = (ChartCollection) getChartCollection(); |
||||
VanChart vanChart = chartCollection.getSelectedChartProvider(VanChart.class); |
||||
if (vanChart == null) { |
||||
return; |
||||
} |
||||
TopDefinitionProvider filterDefinition = vanChart.getFilterDefinition(); |
||||
if (filterDefinition == null) { |
||||
return; |
||||
} |
||||
TwoTuple<String, String[]> tableNameAndDataFields = filterDefinition.getTableNameAndDataFields(); |
||||
if (tableNameAndDataFields == null) { |
||||
return; |
||||
} |
||||
String tableName = tableNameAndDataFields.getFirst(); |
||||
String[] dataFields = tableNameAndDataFields.getSecond(); |
||||
autoChartTypePane.populate(tableName, dataFields); |
||||
} |
||||
} |
@ -0,0 +1,104 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.BaseChartPainter; |
||||
import com.fr.base.chart.chartdata.CallbackEvent; |
||||
import com.fr.base.chart.result.WebChartIDInfo; |
||||
import com.fr.chart.chartattr.Chart; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.ChartTypeInterfaceManager; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.script.Calculator; |
||||
|
||||
import javax.swing.Icon; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import java.awt.Paint; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-29 |
||||
*/ |
||||
public class AutoChartIcon implements Icon { |
||||
|
||||
private static final int WIDTH = 500; |
||||
private static final int HEIGHT = 281; |
||||
|
||||
private ChartCollection chartCollection; |
||||
private CallbackEvent callbackEvent; |
||||
|
||||
private String chartName; |
||||
|
||||
public AutoChartIcon(ChartCollection chartCollection) { |
||||
this.chartCollection = chartCollection; |
||||
initChartName(); |
||||
} |
||||
|
||||
public ChartCollection getChartCollection() { |
||||
return chartCollection; |
||||
} |
||||
|
||||
public String getChartName() { |
||||
return chartName; |
||||
} |
||||
|
||||
private void initChartName() { |
||||
Chart chart = chartCollection.getSelectedChart(Chart.class); |
||||
String[] subName = ChartTypeInterfaceManager.getInstance().getSubName(chart.getPlot().getPlotID()); |
||||
chartName = subName[0]; |
||||
} |
||||
|
||||
public void registerCallBackEvent(CallbackEvent callbackEvent) { |
||||
this.callbackEvent = callbackEvent; |
||||
} |
||||
|
||||
/** |
||||
* 画出缩略图Icon |
||||
* |
||||
* @param g 图形的上下文 |
||||
* @param c 所在的Component |
||||
* @param x 缩略图的起始坐标x |
||||
* @param y 缩略图的起始坐标y |
||||
*/ |
||||
@Override |
||||
public void paintIcon(Component c, Graphics g, int x, int y) { |
||||
|
||||
BaseChartPainter painter = chartCollection.createResultChartPainterWithOutDealFormula(Calculator.createCalculator(), |
||||
WebChartIDInfo.createEmptyDesignerInfo(), getIconWidth(), getIconHeight()); |
||||
|
||||
int resolution = HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); |
||||
|
||||
Graphics2D g2d = (Graphics2D) g; |
||||
Paint oldPaint = g2d.getPaint(); |
||||
g.translate(x, y); |
||||
g2d.setPaint(Color.white); |
||||
g2d.fillRect(0, 0, getIconWidth(), getIconHeight()); |
||||
|
||||
painter.paint(g2d, getIconWidth(), getIconHeight(), resolution, null, callbackEvent); |
||||
|
||||
g.translate(-x, -y); |
||||
g2d.setPaint(oldPaint); |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的宽度 |
||||
* |
||||
* @return int 缩略图宽度 |
||||
*/ |
||||
@Override |
||||
public int getIconWidth() { |
||||
return WIDTH; |
||||
} |
||||
|
||||
/** |
||||
* 返回缩略图的高度 |
||||
* |
||||
* @return int 缩略图高度 |
||||
*/ |
||||
@Override |
||||
public int getIconHeight() { |
||||
return HEIGHT; |
||||
} |
||||
} |
@ -0,0 +1,199 @@
|
||||
package com.fr.design.chart; |
||||
|
||||
import com.fr.base.chart.chartdata.CallbackEvent; |
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.chartx.attr.ChartProvider; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.data.datapane.TableDataComboBox; |
||||
import com.fr.design.data.tabledata.wrapper.TableDataWrapper; |
||||
import com.fr.design.gui.ibutton.UIButton; |
||||
import com.fr.design.gui.icombocheckbox.UIComboCheckBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.FRGUIPaneFactory; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import javax.swing.BorderFactory; |
||||
import javax.swing.DefaultListCellRenderer; |
||||
import javax.swing.DefaultListModel; |
||||
import javax.swing.JList; |
||||
import javax.swing.JPanel; |
||||
import javax.swing.JScrollPane; |
||||
import javax.swing.JSplitPane; |
||||
import javax.swing.ListCellRenderer; |
||||
import java.util.HashMap; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
import java.awt.Color; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
import java.awt.event.ItemEvent; |
||||
import java.awt.event.ItemListener; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-29 |
||||
*/ |
||||
public class AutoChartTypePane extends ChartWizardPane implements CallbackEvent { |
||||
|
||||
private JList chartViewList; |
||||
private DefaultListModel chartResultModel; |
||||
private UIButton refreshButton; |
||||
|
||||
private TableDataComboBox tableNameComboBox; |
||||
private UIComboCheckBox dataFieldBox; |
||||
|
||||
public AutoChartTypePane() { |
||||
this.setLayout(FRGUIPaneFactory.createBorderLayout()); |
||||
initButtonGroup(); |
||||
initRefreshLabel(); |
||||
initDataFiledBox(); |
||||
JPanel contentPane = createContentPane(); |
||||
|
||||
chartViewList = new JList(); |
||||
|
||||
chartResultModel = new DefaultListModel(); |
||||
chartViewList.setModel(chartResultModel); |
||||
chartViewList.setVisibleRowCount(0); |
||||
chartViewList.setLayoutOrientation(JList.HORIZONTAL_WRAP); |
||||
chartViewList.setCellRenderer(iconCellRenderer); |
||||
|
||||
JScrollPane subListPane = new JScrollPane(chartViewList); |
||||
|
||||
JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, contentPane, subListPane); |
||||
splitPane.setDividerLocation(60); |
||||
splitPane.setBorder(BorderFactory.createTitledBorder(Toolkit.i18nText("Fine-Design_Chart_M_Popup_Auto_Chart_Type"))); |
||||
this.add(splitPane); |
||||
} |
||||
|
||||
ListCellRenderer iconCellRenderer = new DefaultListCellRenderer() { |
||||
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { |
||||
super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); |
||||
this.setText(""); |
||||
|
||||
AutoChartIcon chartIcon = (AutoChartIcon) value; |
||||
this.setIcon(chartIcon); |
||||
setHorizontalAlignment(UILabel.CENTER); |
||||
if (isSelected) { |
||||
// 深蓝色.
|
||||
this.setBackground(new Color(57, 107, 181)); |
||||
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName(), Color.WHITE)); |
||||
} else { |
||||
this.setBorder(GUICoreUtils.createTitledBorder(chartIcon.getChartName())); |
||||
} |
||||
return this; |
||||
} |
||||
}; |
||||
|
||||
private JPanel createContentPane() { |
||||
JPanel panel = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
|
||||
JPanel tableDataPane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
panel.add(tableDataPane); |
||||
tableDataPane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Table_Data") + ":")); |
||||
tableNameComboBox.setPreferredSize(new Dimension(96, 20)); |
||||
tableDataPane.add(tableNameComboBox); |
||||
|
||||
JPanel areaNamePane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); |
||||
panel.add(areaNamePane); |
||||
areaNamePane.add(new UILabel(Toolkit.i18nText("Fine-Design_Chart_Data_Field") + ":")); |
||||
areaNamePane.add(dataFieldBox); |
||||
panel.add(refreshButton); |
||||
return panel; |
||||
} |
||||
|
||||
private void initButtonGroup() { |
||||
dataFieldBox = new UIComboCheckBox(new Object[0]); |
||||
dataFieldBox.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkButtonState(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void initDataFiledBox() { |
||||
tableNameComboBox = new TableDataComboBox(DesignTableDataManager.getEditingTableDataSource()); |
||||
tableNameComboBox.addItemListener(new ItemListener() { |
||||
@Override |
||||
public void itemStateChanged(ItemEvent e) { |
||||
if (e.getStateChange() == ItemEvent.SELECTED) { |
||||
refreshBox(); |
||||
checkButtonState(); |
||||
} |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkButtonState() { |
||||
if (tableNameComboBox.getSelectedItem() != null && dataFieldBox.getSelectedValues().length > 0) { |
||||
refreshButton.setEnabled(true); |
||||
} else { |
||||
refreshButton.setEnabled(false); |
||||
} |
||||
} |
||||
|
||||
private void refreshBox() { |
||||
TableDataWrapper dataWrap = tableNameComboBox.getSelectedItem(); |
||||
|
||||
if (dataWrap == null) { |
||||
return; |
||||
} |
||||
dataFieldBox.clearText(); |
||||
|
||||
List<String> columnNameList = dataWrap.calculateColumnNameList(); |
||||
|
||||
dataFieldBox.refreshCombo(columnNameList.toArray()); |
||||
} |
||||
|
||||
private void initRefreshLabel() { |
||||
refreshButton = new UIButton(Toolkit.i18nText("Fine-Design_Chart_Recommend")); |
||||
refreshButton.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
calculateAutoChart(); |
||||
} |
||||
}); |
||||
refreshButton.setEnabled(false); |
||||
} |
||||
|
||||
private void calculateAutoChart() { |
||||
chartResultModel.clear(); |
||||
} |
||||
|
||||
@Override |
||||
public void populate(ChartCollection cc) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public void update(ChartCollection cc) { |
||||
if (chartViewList.getSelectedIndex() < 0) { |
||||
return; |
||||
} |
||||
AutoChartIcon chartIcon = (AutoChartIcon) chartViewList.getSelectedValue(); |
||||
ChartProvider chartProvider = chartIcon.getChartCollection().getSelectedChartProvider(ChartProvider.class); |
||||
if (cc.getChartCount() > 0) { |
||||
cc.setSelectChart(chartProvider); |
||||
} else { |
||||
cc.addChart(chartProvider); |
||||
} |
||||
} |
||||
|
||||
public void populate(String tableName, String[] dataFields) { |
||||
tableNameComboBox.setSelectedTableDataByName(tableName); |
||||
Map<Object, Boolean> map = new HashMap(); |
||||
for (String dataField : dataFields) { |
||||
map.put(dataField, true); |
||||
} |
||||
dataFieldBox.setSelectedValues(map); |
||||
} |
||||
|
||||
@Override |
||||
public void callback() { |
||||
this.repaint(); |
||||
} |
||||
} |
@ -0,0 +1,113 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.chart.base.GradientStyle; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.background.gradient.FixedGradientBar; |
||||
import com.fr.plugin.chart.type.GradientType; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartBeautyPaneWithGradientBar extends VanChartBeautyPane { |
||||
|
||||
private FixedGradientBar colorGradient; |
||||
private JPanel gradientBarPane; |
||||
|
||||
public VanChartBeautyPaneWithGradientBar() { |
||||
super(); |
||||
|
||||
this.add(initGradientBarPane(), BorderLayout.SOUTH); |
||||
|
||||
initListener(); |
||||
} |
||||
|
||||
private JPanel initGradientBarPane() { |
||||
colorGradient = new FixedGradientBar(4, 140); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{null, colorGradient}, |
||||
}; |
||||
|
||||
gradientBarPane = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
|
||||
return gradientBarPane; |
||||
} |
||||
|
||||
private void initListener() { |
||||
getGradientTypeBox().addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkGradientBarVisible(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkGradientBarVisible() { |
||||
if (colorGradient != null && gradientBarPane != null) { |
||||
gradientBarPane.setVisible(getGradientTypeBox().getSelectedIndex() == 1); |
||||
} |
||||
} |
||||
|
||||
protected String[] getNameArray() { |
||||
return new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Auto"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Off") |
||||
}; |
||||
} |
||||
|
||||
public void populateBean(GradientStyle gradientStyle) { |
||||
super.populateBean(gradientStyle); |
||||
|
||||
if (colorGradient != null) { |
||||
colorGradient.updateColor(gradientStyle.getStartColor(), gradientStyle.getEndColor()); |
||||
} |
||||
|
||||
checkGradientBarVisible(); |
||||
} |
||||
|
||||
@Override |
||||
public GradientStyle updateBean() { |
||||
GradientStyle gradientStyle = super.updateBean(); |
||||
|
||||
if (this.colorGradient != null && this.gradientBarPane != null) { |
||||
gradientStyle.setStartColor(colorGradient.getSelectColorPointBtnP1().getColorInner()); |
||||
gradientStyle.setEndColor(colorGradient.getSelectColorPointBtnP2().getColorInner()); |
||||
} |
||||
|
||||
return gradientStyle; |
||||
} |
||||
|
||||
protected int convertGradientTypeToIndex(GradientType gradientType) { |
||||
switch (gradientType) { |
||||
case CUSTOM: |
||||
return 1; |
||||
case NONE: |
||||
return 2; |
||||
default: |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
protected GradientType convertIndexToGradientType(int index) { |
||||
switch (index) { |
||||
case 1: |
||||
return GradientType.CUSTOM; |
||||
case 2: |
||||
return GradientType.NONE; |
||||
default: |
||||
return GradientType.AUTO; |
||||
} |
||||
} |
||||
|
||||
} |
@ -0,0 +1,153 @@
|
||||
package com.fr.van.chart.designer.other.condition.item; |
||||
|
||||
import com.fr.base.background.ColorBackground; |
||||
import com.fr.chart.base.AttrBackground; |
||||
import com.fr.chart.base.DataSeriesCondition; |
||||
import com.fr.design.condition.ConditionAttributesPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.background.gradient.FixedGradientBar; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.plugin.chart.type.GradientType; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.Component; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartColumnSeriesColorConditionPane extends AbstractNormalMultiLineConditionPane { |
||||
|
||||
private UIButtonGroup matchColorTypeBox; |
||||
|
||||
private ColorSelectBox colorSelectionBox; |
||||
private FixedGradientBar colorGradient; |
||||
|
||||
private JPanel colorSelectPane; |
||||
private JPanel colorGradientPane; |
||||
|
||||
public VanChartColumnSeriesColorConditionPane(ConditionAttributesPane conditionAttributesPane) { |
||||
super(conditionAttributesPane, null); |
||||
} |
||||
|
||||
protected String getItemLabelString() { |
||||
return nameForPopupMenuItem(); |
||||
} |
||||
|
||||
protected JPanel initContentPane() { |
||||
colorSelectionBox = new ColorSelectBox(80); |
||||
colorGradient = new FixedGradientBar(4, 150); |
||||
|
||||
colorSelectPane = createJPanelWithComponent(colorSelectionBox); |
||||
colorGradientPane = createJPanelWithComponent(colorGradient); |
||||
|
||||
JPanel panel = new JPanel(); |
||||
|
||||
panel.setLayout(new BorderLayout()); |
||||
|
||||
panel.add(initColorButtonPane(), BorderLayout.NORTH); |
||||
panel.add(colorSelectPane, BorderLayout.CENTER); |
||||
panel.add(colorGradientPane, BorderLayout.SOUTH); |
||||
|
||||
initListener(); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
private JPanel initColorButtonPane() { |
||||
String[] names = new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Solid_Color"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Style_TopDownShade") |
||||
}; |
||||
|
||||
matchColorTypeBox = new UIButtonGroup(names); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
Component[][] components = new Component[][]{new Component[]{matchColorTypeBox}}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p}, new double[]{e}); |
||||
} |
||||
|
||||
private void initListener() { |
||||
matchColorTypeBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkColorPaneVisible(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkColorPaneVisible() { |
||||
if (colorSelectPane != null) { |
||||
colorSelectPane.setVisible(matchColorTypeBox.getSelectedIndex() == 0); |
||||
} |
||||
if (colorGradientPane != null) { |
||||
colorGradientPane.setVisible(matchColorTypeBox.getSelectedIndex() == 1); |
||||
} |
||||
} |
||||
|
||||
public String nameForPopupMenuItem() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Match_Color"); |
||||
} |
||||
|
||||
protected String title4PopupWindow() { |
||||
return Toolkit.i18nText("Fine-Design_Chart_Match_Color"); |
||||
} |
||||
|
||||
public void populate(DataSeriesCondition condition) { |
||||
if (condition instanceof AttrBackground) { |
||||
AttrBackground matchColor = (AttrBackground) condition; |
||||
|
||||
if (matchColor.getGradient() == GradientType.NONE) { |
||||
this.matchColorTypeBox.setSelectedIndex(0); |
||||
} else { |
||||
this.matchColorTypeBox.setSelectedIndex(1); |
||||
} |
||||
|
||||
ColorBackground seriesColor = (ColorBackground) matchColor.getSeriesBackground(); |
||||
|
||||
if (seriesColor != null) { |
||||
this.colorSelectionBox.setSelectObject(seriesColor.getColor()); |
||||
} |
||||
|
||||
this.colorGradient.updateColor(matchColor.getGradientStartColor(), matchColor.getGradientEndColor()); |
||||
} |
||||
|
||||
checkColorPaneVisible(); |
||||
} |
||||
|
||||
public DataSeriesCondition update() { |
||||
AttrBackground matchColor = new AttrBackground(); |
||||
|
||||
if (this.matchColorTypeBox.getSelectedIndex() == 0) { |
||||
matchColor.setGradient(GradientType.NONE); |
||||
} else { |
||||
matchColor.setGradient(GradientType.CUSTOM); |
||||
} |
||||
|
||||
matchColor.setSeriesBackground(ColorBackground.getInstance(this.colorSelectionBox.getSelectObject())); |
||||
matchColor.setGradientStartColor(this.colorGradient.getSelectColorPointBtnP1().getColorInner()); |
||||
matchColor.setGradientEndColor(this.colorGradient.getSelectColorPointBtnP2().getColorInner()); |
||||
|
||||
return matchColor; |
||||
} |
||||
|
||||
public void setDefault() { |
||||
this.populate(new AttrBackground()); |
||||
} |
||||
|
||||
private JPanel createJPanelWithComponent(Component component) { |
||||
double p = TableLayout.PREFERRED; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null}, |
||||
new Component[]{component} |
||||
}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, new double[]{p, p}, new double[]{e}); |
||||
} |
||||
} |
After Width: | Height: | Size: 179 B |
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 15 KiB After Width: | Height: | Size: 25 KiB |
@ -0,0 +1,3 @@
|
||||
dependencies { |
||||
compile project(':designer-base') |
||||
} |
@ -0,0 +1,58 @@
|
||||
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; |
||||
//先初始化加上索引。
|
||||
widgetName = widgetName + i; |
||||
while (form.isNameExist(widgetName) || duplicated.contains(widgetName)) { |
||||
i++; |
||||
widgetName = raw + i; |
||||
} |
||||
//将名字加入重复集合中
|
||||
duplicated.add(widgetName); |
||||
return widgetName; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,121 @@
|
||||
package com.fr.design.designer.creator; |
||||
|
||||
import com.fr.base.GraphHelper; |
||||
import com.fr.base.chart.BaseChartCollection; |
||||
import com.fr.common.annotations.Open; |
||||
import com.fr.design.dialog.DialogActionAdapter; |
||||
import com.fr.design.gui.chart.MiddleChartComponent; |
||||
import com.fr.design.gui.chart.MiddleChartDialog; |
||||
import com.fr.design.mainframe.BaseJForm; |
||||
import com.fr.design.mainframe.DesignerContext; |
||||
import com.fr.design.mainframe.EditingMouseListener; |
||||
import com.fr.design.mainframe.FormDesigner; |
||||
import com.fr.design.module.DesignModuleFactory; |
||||
import com.fr.form.ui.ChartAutoEditor; |
||||
import com.fr.general.IOUtils; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.bridge.StableFactory; |
||||
|
||||
import javax.swing.JComponent; |
||||
import javax.swing.JPanel; |
||||
import java.awt.Dimension; |
||||
import java.awt.Graphics; |
||||
import java.awt.event.MouseEvent; |
||||
import java.awt.image.BufferedImage; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-26 |
||||
*/ |
||||
@Open |
||||
public class XAutoChartCreator extends XChartEditor { |
||||
|
||||
private MiddleChartDialog autoChartDialog; |
||||
|
||||
private EditingMouseListener editingMouseListener; |
||||
|
||||
public XAutoChartCreator(ChartAutoEditor editor, Dimension size) { |
||||
super(editor, size); |
||||
} |
||||
|
||||
/** |
||||
* 返回组件默认名 |
||||
* |
||||
* @return 组件类名(小写) |
||||
*/ |
||||
public String createDefaultName() { |
||||
return "auto_chart"; |
||||
} |
||||
|
||||
@Override |
||||
public ChartAutoEditor toData() { |
||||
return (ChartAutoEditor) data; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* 点击选中的时候, 刷新界面 |
||||
* 右键 reset之后, 触发事件 populate此方法 |
||||
* |
||||
* @param jform 表单 |
||||
* @param formDesigner 表单设计器 |
||||
* @return 控件. |
||||
*/ |
||||
public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) { |
||||
if (toData().isChartSelect()) { |
||||
return super.createToolPane(jform, formDesigner); |
||||
} |
||||
if (isEditing) { |
||||
if (autoChartDialog != null && autoChartDialog.isVisible()) { |
||||
return new JPanel(); |
||||
} |
||||
final BaseChartCollection chartCollection = (BaseChartCollection) StableFactory.createXmlObject(BaseChartCollection.XML_TAG); |
||||
autoChartDialog = DesignModuleFactory.getAutoChartDialog(DesignerContext.getDesignerFrame()); |
||||
autoChartDialog.populate(chartCollection); |
||||
autoChartDialog.addDialogActionListener(new DialogActionAdapter() { |
||||
@Override |
||||
public void doOk() { |
||||
initChart(autoChartDialog.getChartCollection()); |
||||
formDesigner.fireTargetModified(); |
||||
} |
||||
|
||||
@Override |
||||
public void doCancel() { |
||||
editingMouseListener.stopEditing(); |
||||
} |
||||
}); |
||||
autoChartDialog.setVisible(true); |
||||
} |
||||
return toData().isChartSelect() ? super.createToolPane(jform, formDesigner) : new JPanel(); |
||||
} |
||||
|
||||
/** |
||||
* 响应点击事件 |
||||
* |
||||
* @param editingMouseListener 鼠标点击,位置处理器 |
||||
* @param e 鼠标点击事件 |
||||
*/ |
||||
public void respondClick(EditingMouseListener editingMouseListener, MouseEvent e) { |
||||
this.editingMouseListener = editingMouseListener; |
||||
super.respondClick(editingMouseListener, e); |
||||
} |
||||
|
||||
|
||||
public void paint(Graphics g) { |
||||
BufferedImage bufferedImage = IOUtils.readImage("com/fr/design/form/images/auto_chart_preview.png"); |
||||
GraphHelper.paintImage( |
||||
g, this.getWidth(), this.getHeight(), bufferedImage, |
||||
Constants.IMAGE_ADJUST, |
||||
0, |
||||
0, -1, -1 |
||||
); |
||||
super.paint(g); |
||||
} |
||||
|
||||
private void initChart(BaseChartCollection chartCollection) { |
||||
((MiddleChartComponent) getDesignerEditor().getEditorTarget()).populate(chartCollection); |
||||
this.toData().resetChangeChartCollection(chartCollection); |
||||
this.toData().setChartSelect(true); |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.design.designer.properties.mobile; |
||||
|
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.design.designer.creator.XFieldEditor; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.fun.impl.AbstractWidgetPropertyUIProvider; |
||||
import com.fr.design.gui.itable.AbstractPropertyTable; |
||||
import com.fr.design.widget.ui.designer.mobile.ButtonGroupDefinePane; |
||||
|
||||
public class ButtonGroupPropertyUI extends AbstractWidgetPropertyUIProvider { |
||||
|
||||
private XCreator xCreator; |
||||
|
||||
public ButtonGroupPropertyUI(XFieldEditor xButtonGroupEditor) { |
||||
this.xCreator = xButtonGroupEditor; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractPropertyTable createWidgetAttrTable() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public BasicPane createWidgetAttrPane() { |
||||
return new ButtonGroupDefinePane(xCreator); |
||||
} |
||||
|
||||
@Override |
||||
public String tableTitle() { |
||||
return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Report_Mobile_Attr"); |
||||
} |
||||
} |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue