Browse Source
Merge in DESIGN/design from release/10.0 to final/10.0 * commit 'a1d3ac858418bf370cc80600b0fff34430a019d3': (51 commits) REPORT-35387 参数面板已有控件的时候,点击右侧全部添加,控件重叠 代码格式调整 REPORT-35387 参数面板已有控件的时候,点击右侧全部添加,控件重叠 删除打印语句 REPORT-35387 参数面板已有控件的时候,点击右侧全部添加,控件重叠 REPORT-35205 fix REPORT-35379 && REPORT-35205 修改属性访问修饰符 REPORT-35253 切换远程到本地设计器的问题 REPORT-34780 && CHART-14441 CHART-14624 调整面积图系列面板不透明的enable属性的check REPORT-35381 && REPORT-35379 CHART-14598 雷达图增加线宽设置 CHART-14541 轴标题增加缩进 REPORT-34020 【国际化】非简中设计器-界面右侧面板选择超链接或悬浮元素后下拉框溢出 CHART-14120 英文设计器地图数据面板截断 REPORT-33236 REPORT-31546 公式面板的说明切换偶尔会失效 REPORT-34351 ""改为StringUtils.EMPTY REPORT-33500 日志面板清除日志后同时清除设计器右上角日志提示信息 REPORT-35016【组件生成】目前生成的组件,从组件库拖入模板中会变大 [场景] 从组件库拖入时,不会保持原有的大小。 [解决方案] 将原来的大小,在创建时一并初始化 CHART-14346 ...final/10.0 10.0.8.2020.07.16
Kara
4 years ago
46 changed files with 1317 additions and 689 deletions
@ -0,0 +1,25 @@
|
||||
package com.fr.design.env; |
||||
|
||||
import com.fr.workspace.connect.WorkspaceConnectionInfo; |
||||
import junit.framework.TestCase; |
||||
import org.junit.Assert; |
||||
|
||||
/** |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/7/15 |
||||
*/ |
||||
public class RemoteDesignerWorkspaceInfoTest extends TestCase { |
||||
|
||||
public void testCheckValid() { |
||||
RemoteDesignerWorkspaceInfo workspaceInfo0 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://localhost:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo1 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("http://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo2 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://127.0.0.1:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
RemoteDesignerWorkspaceInfo workspaceInfo3 = RemoteDesignerWorkspaceInfo.create(new WorkspaceConnectionInfo("https://localhost:8075/webroot/decision", "admin", "123", "", "", true)); |
||||
Assert.assertFalse(workspaceInfo0.checkValid()); |
||||
Assert.assertFalse(workspaceInfo1.checkValid()); |
||||
Assert.assertFalse(workspaceInfo2.checkValid()); |
||||
Assert.assertFalse(workspaceInfo3.checkValid()); |
||||
} |
||||
|
||||
} |
@ -0,0 +1,143 @@
|
||||
package com.fr.design.chart.auto; |
||||
|
||||
import com.fr.chart.auto.ColumnInfo; |
||||
import com.fr.chart.auto.strategy.AutoTypeStrategy; |
||||
import com.fr.chart.auto.strategy.imp.AvaStrategy; |
||||
import com.fr.chart.auto.strategy.imp.BubbleChartStrategy; |
||||
import com.fr.chart.auto.strategy.imp.SingleDimensionStrategy; |
||||
import com.fr.chart.auto.strategy.imp.SingleTargetStrategy; |
||||
import com.fr.data.TableDataSource; |
||||
import com.fr.data.TableDataSourceTailor; |
||||
import com.fr.data.impl.EmbeddedTableData; |
||||
import com.fr.data.impl.NameTableData; |
||||
import com.fr.design.data.DesignTableDataManager; |
||||
import com.fr.design.file.HistoryTemplateListCache; |
||||
import com.fr.general.ComparatorUtils; |
||||
import com.fr.general.GeneralUtils; |
||||
import com.fr.general.data.DataModel; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.plugin.chart.vanchart.VanChart; |
||||
import com.fr.script.Calculator; |
||||
import com.fr.stable.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Bjorn |
||||
* @version 10.0 |
||||
* Created by Bjorn on 2020-05-08 |
||||
*/ |
||||
public class AutoTypeCalculate { |
||||
|
||||
public static List<VanChart> calculateType(String tableName, List<String> columns) { |
||||
List<ColumnInfo> columnValue = calculateField(tableName, columns); |
||||
if (columnValue.isEmpty()) { |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
List<ColumnInfo> dimensions = new ArrayList<>(); |
||||
List<ColumnInfo> targets = new ArrayList<>(); |
||||
for (ColumnInfo field : columnValue) { |
||||
if (isTarget(field.getValues())) { |
||||
targets.add(field); |
||||
} else { |
||||
dimensions.add(field); |
||||
} |
||||
} |
||||
AutoTypeStrategy autoTypeStrategy = chooseStrategy(dimensions.size(), targets.size()); |
||||
return autoTypeStrategy.rankChart(tableName, dimensions, targets); |
||||
} |
||||
|
||||
private static AutoTypeStrategy chooseStrategy(int dimensionSize, int targetSize) { |
||||
if (dimensionSize == 0) { |
||||
//没有维度,并且只有一个指标,使用单指标匹配逻辑,大于1个指标,使用气泡图(散点图)匹配逻辑
|
||||
if (targetSize == 1) { |
||||
return new SingleTargetStrategy(); |
||||
} else { |
||||
return new BubbleChartStrategy(); |
||||
} |
||||
} else if (dimensionSize == 1) { |
||||
//1个维度,并且没有指标,使用单维度匹配,2~3个指标,使用气泡图(散点图)匹配逻辑,其余使用ava匹配
|
||||
if (targetSize == 0) { |
||||
return new SingleDimensionStrategy(); |
||||
} else if (targetSize == 2 || targetSize == 3) { |
||||
return new BubbleChartStrategy(); |
||||
} else { |
||||
return new AvaStrategy(); |
||||
} |
||||
} else { |
||||
//大与1个维度,并且没有指标,使用单维度匹配(循环),否则使用ava匹配
|
||||
if (targetSize == 0) { |
||||
return new SingleDimensionStrategy(); |
||||
} else { |
||||
return new AvaStrategy(); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static boolean isTarget(List<String> values) { |
||||
for (String value : values) { |
||||
if (StringUtils.isEmpty(value)) { |
||||
continue; |
||||
} |
||||
Number number = GeneralUtils.string2Number(value); |
||||
if (number == null) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
private static List<ColumnInfo> calculateField(String tableName, List<String> columns) { |
||||
NameTableData nameTableData = new NameTableData(tableName); |
||||
TableDataSource dataSource = TableDataSourceTailor.extractTableData(HistoryTemplateListCache.getInstance().getCurrentEditingTemplate().getTarget()); |
||||
Calculator calculator = Calculator.createCalculator(); |
||||
calculator.setAttribute(TableDataSource.KEY, dataSource); |
||||
nameTableData.createTableData(calculator); |
||||
|
||||
EmbeddedTableData tableData; |
||||
try { |
||||
tableData = DesignTableDataManager.previewTableDataNeedInputParameters(dataSource, nameTableData, Integer.MAX_VALUE, false); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
List<ColumnInfo> originalData = new ArrayList<>(); |
||||
for (String column : columns) { |
||||
List<String> columnData = getColumnData(tableData, column); |
||||
if (columnData != null && !columnData.isEmpty()) { |
||||
originalData.add(new ColumnInfo(column, columnData)); |
||||
} |
||||
} |
||||
return originalData; |
||||
} |
||||
|
||||
private static List<String> getColumnData(EmbeddedTableData tableData, String columnName) { |
||||
List<String> columnData = new ArrayList<>(); |
||||
|
||||
int colIndex = getColIndex(tableData, columnName); |
||||
if (colIndex == DataModel.COLUMN_NAME_NOT_FOUND) { |
||||
return columnData; |
||||
} |
||||
|
||||
int size = tableData.getRowCount(); |
||||
for (int i = 0; i < size; i++) { |
||||
Object valueAt = tableData.getValueAt(i, colIndex); |
||||
columnData.add(GeneralUtils.objectToString(valueAt)); |
||||
} |
||||
return columnData; |
||||
} |
||||
|
||||
private static int getColIndex(EmbeddedTableData tableData, String columnName) { |
||||
int colIndex = 0; |
||||
|
||||
for (int count = tableData.getColumnCount(); colIndex < count; ++colIndex) { |
||||
if (ComparatorUtils.tableDataColumnNameEquals(tableData.getColumnName(colIndex), columnName)) { |
||||
return colIndex; |
||||
} |
||||
} |
||||
return DataModel.COLUMN_NAME_NOT_FOUND; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
|
||||
package com.fr.design.mainframe; |
||||
|
||||
import com.fr.chart.chartattr.ChartCollection; |
||||
import com.fr.design.designer.creator.XCreator; |
||||
import com.fr.form.share.SharableWidgetProvider; |
||||
import com.fr.form.ui.ChartEditor; |
||||
import com.fr.general.ImageWithSuffix; |
||||
import com.fr.invoke.Reflect; |
||||
import org.easymock.EasyMock; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.powermock.core.classloader.annotations.PowerMockIgnore; |
||||
import org.powermock.modules.junit4.PowerMockRunner; |
||||
|
||||
@RunWith(PowerMockRunner.class) |
||||
@PowerMockIgnore({"com.fr.jvm.assist.*", "javax.swing.*"}) |
||||
public class ShareWidgetButtonTest { |
||||
|
||||
@Test |
||||
public void testCreateXCreator() throws Exception { |
||||
|
||||
SharableWidgetProvider provider = EasyMock.mock(SharableWidgetProvider.class); |
||||
EasyMock.expect(provider.getWidth()).andReturn(300).anyTimes(); |
||||
EasyMock.expect(provider.getHeight()).andReturn(400).anyTimes(); |
||||
EasyMock.expect(provider.getName()).andReturn("test-drag").anyTimes(); |
||||
EasyMock.expect(provider.getCover()).andReturn(new ImageWithSuffix("utf-8")).anyTimes(); |
||||
EasyMock.replay(provider); |
||||
|
||||
ShareWidgetButton.ShareWidgetUI ui = new ShareWidgetButton.ShareWidgetUI(); |
||||
|
||||
ChartEditor editor = new ChartEditor(); |
||||
Reflect.on(editor).set("chartCollection", new ChartCollection()); |
||||
XCreator xCreator = ui.createXCreator(editor, "333", provider); |
||||
Assert.assertEquals(300, xCreator.getWidth()); |
||||
Assert.assertEquals(400, xCreator.getHeight()); |
||||
} |
||||
} |
Loading…
Reference in new issue