Yuan.Wang
4 years ago
77 changed files with 1092 additions and 762 deletions
@ -0,0 +1,38 @@
|
||||
package com.fr.design.jdk; |
||||
|
||||
import com.fr.stable.StableUtils; |
||||
|
||||
/** |
||||
* 设计器运行jdk版本 |
||||
* |
||||
* @author hades |
||||
* @version 10.0 |
||||
* Created by hades on 2020/9/27 |
||||
*/ |
||||
public enum JdkVersion { |
||||
|
||||
/** |
||||
* 小于或等于jdk 8 |
||||
*/ |
||||
LE_8 { |
||||
|
||||
@Override |
||||
public boolean support() { |
||||
return StableUtils.getMajorJavaVersion() <= 8; |
||||
} |
||||
}, |
||||
|
||||
/** |
||||
* 大于或等于jdk 9 |
||||
*/ |
||||
GE_9 { |
||||
|
||||
@Override |
||||
public boolean support() { |
||||
return StableUtils.getMajorJavaVersion() >= 9; |
||||
} |
||||
}; |
||||
|
||||
|
||||
abstract public boolean support(); |
||||
} |
@ -1,129 +0,0 @@
|
||||
package com.fr.design.update.factory; |
||||
|
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.ArrayUtils; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import java.io.BufferedInputStream; |
||||
import java.io.BufferedOutputStream; |
||||
import java.io.DataInputStream; |
||||
import java.io.DataOutputStream; |
||||
import java.io.File; |
||||
import java.io.FileFilter; |
||||
import java.io.FileInputStream; |
||||
import java.io.FileOutputStream; |
||||
import java.io.IOException; |
||||
import java.util.Arrays; |
||||
|
||||
/** |
||||
* Created by XINZAI on 2018/8/21. |
||||
*/ |
||||
public class DirectoryOperationFactory { |
||||
/** |
||||
* 新建一个目录 |
||||
* |
||||
* @param dirPath 目录路径 |
||||
*/ |
||||
public static void createNewDirectory(String dirPath) { |
||||
try { |
||||
File newDirPath = new File(dirPath); |
||||
if (!newDirPath.exists()) { |
||||
StableUtils.mkdirs(newDirPath); |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 删除目录 |
||||
* |
||||
* @param dirPath 目录路径 |
||||
*/ |
||||
public static void deleteDirectory(String dirPath) { |
||||
try { |
||||
File dir = new File(dirPath); |
||||
if (dir.isDirectory()) { |
||||
File[] file = dir.listFiles(); |
||||
for (File fileTemp : file) { |
||||
deleteDirectory(fileTemp.toString()); |
||||
fileTemp.delete(); |
||||
} |
||||
} else { |
||||
dir.delete(); |
||||
} |
||||
dir.delete(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 复制目录 |
||||
* |
||||
* @param oldDirPath 被复制目录 |
||||
* @param newDirPath 新目录 |
||||
*/ |
||||
public static void copyDirectory(String oldDirPath, String newDirPath) { |
||||
File oldDir = new File(oldDirPath); |
||||
if (oldDir.isDirectory()) { |
||||
StableUtils.mkdirs(new File(newDirPath)); |
||||
File[] files = oldDir.listFiles(); |
||||
for (File fileTemp : files) { |
||||
copyDirectory(fileTemp.toString(), newDirPath + "/" + fileTemp.getName()); |
||||
} |
||||
} else { |
||||
try { |
||||
copy(oldDirPath, newDirPath); |
||||
} catch (IOException e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage()); |
||||
} |
||||
} |
||||
} |
||||
|
||||
private static void copy(String path1, String path2) throws IOException { |
||||
try (DataInputStream in = new DataInputStream(new BufferedInputStream(new FileInputStream(path1))); |
||||
DataOutputStream out = new DataOutputStream(new BufferedOutputStream(new FileOutputStream(path2)))) { |
||||
byte[] date = new byte[in.available()]; |
||||
in.read(date); |
||||
out.write(date); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* 移动目录 |
||||
* |
||||
* @param oldDirPath 被移动目录 |
||||
* @param newDirPath 新目录 |
||||
*/ |
||||
public static void moveDirectory(String oldDirPath, String newDirPath) { |
||||
copyDirectory(oldDirPath, newDirPath); |
||||
deleteDirectory(oldDirPath); |
||||
} |
||||
|
||||
/** |
||||
* 列出过滤后的文件 |
||||
* |
||||
* @param installHome 安装目录 |
||||
* @param backupdir 备份目录 |
||||
* @return String数组 |
||||
*/ |
||||
public static String[] listFilteredFiles(String installHome, String backupdir) { |
||||
File backupDir = new File(StableUtils.pathJoin(installHome, backupdir)); |
||||
StableUtils.mkdirs(backupDir); |
||||
File[] fileNames = backupDir.listFiles(new FileFilter() { |
||||
@Override |
||||
public boolean accept(File pathname) { |
||||
return pathname.isDirectory(); |
||||
} |
||||
}); |
||||
String[] jarFileName = new String[fileNames.length]; |
||||
int j = 0; |
||||
for (File fileName : fileNames) { |
||||
if ((fileName.isDirectory()) && (ArrayUtils.getLength(fileName.listFiles()) > 0)) {//判断备份文件夹中是否为空,为空不显示
|
||||
jarFileName[j++] = fileName.getName(); |
||||
} |
||||
} |
||||
return Arrays.copyOf(jarFileName, j); |
||||
} |
||||
} |
@ -0,0 +1,50 @@
|
||||
package com.fr.design.update.factory; |
||||
|
||||
import com.fr.decision.update.data.UpdateConstants; |
||||
import com.fr.log.FineLoggerFactory; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import java.io.File;; |
||||
|
||||
/** |
||||
* @author Bryant |
||||
* @version 10.0 |
||||
* Created by Bryant on 2020-09-29 |
||||
*/ |
||||
public class UpdateFileFactory { |
||||
|
||||
private UpdateFileFactory() { |
||||
} |
||||
|
||||
public static File[] getBackupVersions() { |
||||
File[] versions = null; |
||||
try { |
||||
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||
StableUtils.mkdirs(backupDir); |
||||
versions = backupDir.listFiles(); |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return versions; |
||||
} |
||||
|
||||
public static boolean isBackupVersionsValid(String version) { |
||||
boolean designerValid = false; |
||||
boolean envValid = false; |
||||
try { |
||||
File designerLib = new File(StableUtils.pathJoin(version, UpdateConstants.DESIGNERBACKUPPATH)); |
||||
File[] jars = designerLib.listFiles(); |
||||
if (jars != null && jars.length > 0) { |
||||
designerValid = true; |
||||
} |
||||
File envLib = new File(StableUtils.pathJoin(version, UpdateConstants.BACKUPPATH)); |
||||
jars = envLib.listFiles(); |
||||
if (jars != null && jars.length > 0) { |
||||
envValid = true; |
||||
} |
||||
} catch (Exception e) { |
||||
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
||||
} |
||||
return designerValid && envValid; |
||||
} |
||||
} |
@ -0,0 +1,36 @@
|
||||
package com.fr.design.update.utils; |
||||
|
||||
import com.fr.design.update.factory.UpdateFileFactory; |
||||
import com.fr.stable.StableUtils; |
||||
|
||||
import java.io.File; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @author Bryant |
||||
* @version 10.0 |
||||
* Created by Bryant on 2020-09-25 |
||||
*/ |
||||
public class UpdateFileUtils { |
||||
/** |
||||
* 列出过滤后的文件 |
||||
* |
||||
* @return String数组 |
||||
*/ |
||||
public static String[] listBackupVersions() { |
||||
File[] versionBackup = UpdateFileFactory.getBackupVersions(); |
||||
List<String> versions = new ArrayList<>(); |
||||
if (versionBackup != null) { |
||||
for (File file : versionBackup) { |
||||
if (UpdateFileFactory.isBackupVersionsValid(file.getAbsolutePath())) { |
||||
versions.add(file.getName()); |
||||
} else { |
||||
StableUtils.deleteFile(file); |
||||
} |
||||
} |
||||
} |
||||
String[] result = new String[versions.size()]; |
||||
return versions.toArray(result); |
||||
} |
||||
} |
@ -0,0 +1,24 @@
|
||||
package com.fr.design.data.datapane; |
||||
|
||||
import org.junit.Test; |
||||
|
||||
import java.util.Map; |
||||
|
||||
import static org.junit.Assert.*; |
||||
|
||||
/** |
||||
* @author Yyming |
||||
* @version 10.0 |
||||
* Created by Yyming on 2020/9/29 |
||||
*/ |
||||
public class TableDataPaneListPaneTest { |
||||
|
||||
@Test |
||||
public void rename() { |
||||
TableDataPaneListPane listPane = new TableDataPaneListPane(); |
||||
listPane.rename("111", "222"); |
||||
listPane.rename("222", "333"); |
||||
Map<String, String> dsNameChangedMap = listPane.getDsNameChangedMap(); |
||||
assertEquals(1, dsNameChangedMap.size()); |
||||
} |
||||
} |
@ -0,0 +1,28 @@
|
||||
package com.fr.design.update.factory; |
||||
|
||||
import com.fr.decision.update.data.UpdateConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.io.File; |
||||
|
||||
public class UpdateFileFactoryTest { |
||||
|
||||
@Test |
||||
public void testGetBackupVersions() { |
||||
Assert.assertEquals(0, UpdateFileFactory.getBackupVersions().length); |
||||
File backupDir = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR)); |
||||
StableUtils.deleteFile(backupDir); |
||||
} |
||||
|
||||
@Test |
||||
public void testIsBackupVersionsValid() { |
||||
File des = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.BACKUPPATH, "test")); |
||||
File env = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.DESIGNERBACKUPPATH, "test")); |
||||
StableUtils.mkdirs(des); |
||||
StableUtils.mkdirs(env); |
||||
Assert.assertTrue(UpdateFileFactory.isBackupVersionsValid(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test"))); |
||||
StableUtils.deleteFile(new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR))); |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.design.update.utils; |
||||
|
||||
import com.fr.decision.update.data.UpdateConstants; |
||||
import com.fr.stable.StableUtils; |
||||
import org.junit.Assert; |
||||
import org.junit.Test; |
||||
|
||||
import java.io.File; |
||||
|
||||
/** |
||||
* @author Bryant |
||||
* @version 10.0 |
||||
* Created by Bryant on 2020-09-25 |
||||
*/ |
||||
public class UpdateFileUtilsTest { |
||||
|
||||
@Test |
||||
public void testListFilteredFiles() { |
||||
File des = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.BACKUPPATH, "test")); |
||||
File env = new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR, "test", UpdateConstants.DESIGNERBACKUPPATH, "test")); |
||||
StableUtils.mkdirs(des); |
||||
StableUtils.mkdirs(env); |
||||
String[] result = UpdateFileUtils.listBackupVersions(); |
||||
Assert.assertEquals(1, result.length); |
||||
StableUtils.deleteFile(new File(StableUtils.pathJoin(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR))); |
||||
} |
||||
} |
@ -0,0 +1,27 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
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.van.chart.designer.TableLayout4VanChartHelper; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.Component; |
||||
|
||||
public class VanChartHtmlLabelPaneWithBackGroundLabel extends VanChartHtmlLabelPane { |
||||
|
||||
protected JPanel createWidthAndHeightPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double d = TableLayout4VanChartHelper.DESCRIPTION_AREA_WIDTH; |
||||
|
||||
JPanel panel = super.createWidthAndHeightPane(); |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Background")), panel}, |
||||
}; |
||||
|
||||
return TableLayoutHelper.createTableLayoutPane(components, new double[]{p}, new double[]{d, f}); |
||||
} |
||||
} |
@ -1,361 +0,0 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.design.beans.BasicBeanPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
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.style.ChartTextAttrPane; |
||||
import com.fr.plugin.chart.base.AttrTooltipContent; |
||||
import com.fr.van.chart.designer.TableLayout4VanChartHelper; |
||||
import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.component.format.ChangedPercentFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.component.format.ChangedValueFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; |
||||
import com.fr.van.chart.designer.style.VanChartStylePane; |
||||
|
||||
import javax.swing.JPanel; |
||||
import java.awt.BorderLayout; |
||||
import java.awt.CardLayout; |
||||
import java.awt.Component; |
||||
import java.awt.Dimension; |
||||
import java.awt.event.ActionEvent; |
||||
import java.awt.event.ActionListener; |
||||
|
||||
public class VanChartLabelContentPaneWithoutRichText extends BasicBeanPane<AttrTooltipContent> { |
||||
|
||||
private UIButtonGroup<Integer> content; |
||||
|
||||
private ValueFormatPaneWithCheckBox valueFormatPane; |
||||
private PercentFormatPaneWithCheckBox percentFormatPane; |
||||
private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; |
||||
private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; |
||||
|
||||
//监控刷新时,自动数据点提示使用
|
||||
private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; |
||||
private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; |
||||
private UIButtonGroup<Integer> styleButton; |
||||
private ChartTextAttrPane textAttrPane; |
||||
private JPanel centerPane; |
||||
private JPanel commonPanel; |
||||
private JPanel stylePanel; |
||||
private VanChartHtmlLabelPane htmlLabelPane; |
||||
|
||||
private VanChartStylePane parent; |
||||
private JPanel showOnPane; |
||||
|
||||
public VanChartLabelContentPaneWithoutRichText(VanChartStylePane parent, JPanel showOnPane) { |
||||
this.parent = parent; |
||||
this.showOnPane = showOnPane; |
||||
|
||||
this.setLayout(new BorderLayout()); |
||||
this.add(createLabelContentPane(), BorderLayout.CENTER); |
||||
} |
||||
|
||||
public ValueFormatPaneWithCheckBox getValueFormatPane() { |
||||
return valueFormatPane; |
||||
} |
||||
|
||||
public void setValueFormatPane(ValueFormatPaneWithCheckBox valueFormatPane) { |
||||
this.valueFormatPane = valueFormatPane; |
||||
} |
||||
|
||||
public PercentFormatPaneWithCheckBox getPercentFormatPane() { |
||||
return percentFormatPane; |
||||
} |
||||
|
||||
public void setPercentFormatPane(PercentFormatPaneWithCheckBox percentFormatPane) { |
||||
this.percentFormatPane = percentFormatPane; |
||||
} |
||||
|
||||
public CategoryNameFormatPaneWithCheckBox getCategoryNameFormatPane() { |
||||
return categoryNameFormatPane; |
||||
} |
||||
|
||||
public void setCategoryNameFormatPane(CategoryNameFormatPaneWithCheckBox categoryNameFormatPane) { |
||||
this.categoryNameFormatPane = categoryNameFormatPane; |
||||
} |
||||
|
||||
public SeriesNameFormatPaneWithCheckBox getSeriesNameFormatPane() { |
||||
return seriesNameFormatPane; |
||||
} |
||||
|
||||
public void setSeriesNameFormatPane(SeriesNameFormatPaneWithCheckBox seriesNameFormatPane) { |
||||
this.seriesNameFormatPane = seriesNameFormatPane; |
||||
} |
||||
|
||||
private JPanel createLabelContentPane() { |
||||
content = new UIButtonGroup<>(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Common"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom") |
||||
}); |
||||
|
||||
initFormatPane(parent, showOnPane); |
||||
|
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
commonPanel = createCommonPanel(); |
||||
htmlLabelPane = createHtmlLabelPane(); |
||||
htmlLabelPane.setParent(parent); |
||||
stylePanel = createTextStylePane(); |
||||
centerPane = new JPanel(new CardLayout()) { |
||||
@Override |
||||
public Dimension getPreferredSize() { |
||||
if (content.getSelectedIndex() == 0) { |
||||
return commonPanel.getPreferredSize(); |
||||
} else { |
||||
return new Dimension(commonPanel.getPreferredSize().width, htmlLabelPane.getPreferredSize().height); |
||||
} |
||||
} |
||||
}; |
||||
centerPane.add(htmlLabelPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); |
||||
centerPane.add(commonPanel, Toolkit.i18nText("Fine-Design_Chart_Common")); |
||||
|
||||
double[] column = {f, e}; |
||||
double[] row = {p, p, p}; |
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(getLabelContentTitle()), content}, |
||||
new Component[]{null, centerPane}, |
||||
}; |
||||
initContentListener(); |
||||
JPanel paramsPanel = TableLayout4VanChartHelper.createGapTableLayoutPane(components, row, column); |
||||
|
||||
JPanel contentPane = new JPanel(new BorderLayout()); |
||||
contentPane.add(paramsPanel, BorderLayout.CENTER); |
||||
contentPane.add(stylePanel, BorderLayout.SOUTH); |
||||
|
||||
return getLabelContentPane(contentPane); |
||||
} |
||||
|
||||
protected boolean hasTextStylePane() { |
||||
return true; |
||||
} |
||||
|
||||
private JPanel createTextStylePane() { |
||||
styleButton = new UIButtonGroup<>(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Automatic"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom") |
||||
}); |
||||
|
||||
textAttrPane = new ChartTextAttrPane() { |
||||
protected Component[][] getComponents(JPanel buttonPane) { |
||||
return new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{null, getFontNameComboBox()}, |
||||
new Component[]{null, buttonPane} |
||||
}; |
||||
} |
||||
}; |
||||
|
||||
JPanel buttonPane = TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Widget_Style"), styleButton); |
||||
|
||||
JPanel stylePanel = new JPanel(new BorderLayout()); |
||||
stylePanel.add(buttonPane, BorderLayout.CENTER); |
||||
stylePanel.add(textAttrPane, BorderLayout.SOUTH); |
||||
|
||||
initStyleButtonListener(); |
||||
|
||||
return stylePanel; |
||||
} |
||||
|
||||
private void initStyleButtonListener() { |
||||
styleButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkStylePane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkStylePane() { |
||||
if (hasTextStylePane()) { |
||||
stylePanel.setVisible(true); |
||||
textAttrPane.setVisible(styleButton.getSelectedIndex() == 1); |
||||
} else { |
||||
stylePanel.setVisible(false); |
||||
} |
||||
} |
||||
|
||||
protected String getLabelContentTitle() { |
||||
return Toolkit.i18nText("Fine-Design_Report_Text"); |
||||
} |
||||
|
||||
protected JPanel getLabelContentPane(JPanel contentPane) { |
||||
return createTableLayoutPaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Content"), contentPane); |
||||
} |
||||
|
||||
protected VanChartHtmlLabelPane createHtmlLabelPane() { |
||||
return new VanChartHtmlLabelPane(); |
||||
} |
||||
|
||||
protected JPanel createCommonPanel() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
|
||||
double[] columnSize = {f, p}; |
||||
double[] rowSize = getRowSize(p); |
||||
|
||||
return TableLayoutHelper.createTableLayoutPane(getPaneComponents(), rowSize, columnSize); |
||||
} |
||||
|
||||
protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { |
||||
categoryNameFormatPane = new CategoryNameFormatPaneWithCheckBox(parent, showOnPane); |
||||
seriesNameFormatPane = new SeriesNameFormatPaneWithCheckBox(parent, showOnPane); |
||||
valueFormatPane = new ValueFormatPaneWithCheckBox(parent, showOnPane); |
||||
percentFormatPane = new PercentFormatPaneWithCheckBox(parent, showOnPane); |
||||
} |
||||
|
||||
protected JPanel createTableLayoutPaneWithTitle(String title, JPanel panel) { |
||||
return TableLayout4VanChartHelper.createExpandablePaneWithTitle(title, panel); |
||||
} |
||||
|
||||
protected double[] getRowSize(double p) { |
||||
return new double[]{p, p, p, p}; |
||||
} |
||||
|
||||
protected Component[][] getPaneComponents() { |
||||
return new Component[][]{ |
||||
new Component[]{categoryNameFormatPane, null}, |
||||
new Component[]{seriesNameFormatPane, null}, |
||||
new Component[]{valueFormatPane, null}, |
||||
new Component[]{percentFormatPane, null}, |
||||
}; |
||||
} |
||||
|
||||
private void initContentListener() { |
||||
content.addActionListener(new ActionListener() { |
||||
@Override |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkCardPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
|
||||
private void checkCardPane() { |
||||
CardLayout cardLayout = (CardLayout) centerPane.getLayout(); |
||||
if (content.getSelectedIndex() == 1) { |
||||
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Custom")); |
||||
if (isDirty()) { |
||||
setCustomFormatterText(); |
||||
setDirty(false); |
||||
} |
||||
} else { |
||||
cardLayout.show(centerPane, Toolkit.i18nText("Fine-Design_Chart_Common")); |
||||
} |
||||
} |
||||
|
||||
protected void setCustomFormatterText() { |
||||
htmlLabelPane.setCustomFormatterText(updateBean().getFormatterTextFromCommon()); |
||||
} |
||||
|
||||
public boolean isDirty() { |
||||
return categoryNameFormatPane.isDirty() || seriesNameFormatPane.isDirty() || valueFormatPane.isDirty() || percentFormatPane.isDirty() |
||||
|| (changedValueFormatPane != null && changedValueFormatPane.isDirty()) || (changedValueFormatPane != null && changedPercentFormatPane.isDirty()); |
||||
} |
||||
|
||||
public void setDirty(boolean isDirty) { |
||||
categoryNameFormatPane.setDirty(isDirty); |
||||
seriesNameFormatPane.setDirty(isDirty); |
||||
valueFormatPane.setDirty(isDirty); |
||||
percentFormatPane.setDirty(isDirty); |
||||
|
||||
if (changedValueFormatPane != null) { |
||||
changedValueFormatPane.setDirty(isDirty); |
||||
} |
||||
if (changedPercentFormatPane != null) { |
||||
changedPercentFormatPane.setDirty(isDirty); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
protected String title4PopupWindow() { |
||||
return ""; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public void populateBean(AttrTooltipContent attrTooltipContent) { |
||||
if (attrTooltipContent == null) { |
||||
return; |
||||
} |
||||
|
||||
content.setSelectedIndex(attrTooltipContent.isCommon() ? 0 : 1); |
||||
|
||||
populateFormatPane(attrTooltipContent); |
||||
|
||||
htmlLabelPane.populate(attrTooltipContent.getHtmlLabel()); |
||||
if (!attrTooltipContent.isCommon()) { |
||||
setDirty(false); |
||||
} |
||||
if (hasTextStylePane()) { |
||||
this.styleButton.setSelectedIndex(attrTooltipContent.isCustom() ? 1 : 0); |
||||
this.textAttrPane.populate(attrTooltipContent.getTextAttr()); |
||||
} |
||||
checkCardPane(); |
||||
checkStylePane(); |
||||
} |
||||
|
||||
protected void populateFormatPane(AttrTooltipContent attrTooltipContent) { |
||||
categoryNameFormatPane.populate(attrTooltipContent.getCategoryFormat()); |
||||
seriesNameFormatPane.populate(attrTooltipContent.getSeriesFormat()); |
||||
valueFormatPane.populate(attrTooltipContent.getValueFormat()); |
||||
percentFormatPane.populate(attrTooltipContent.getPercentFormat()); |
||||
|
||||
if (changedValueFormatPane != null) { |
||||
changedValueFormatPane.populate(attrTooltipContent.getChangedValueFormat()); |
||||
} |
||||
if (changedPercentFormatPane != null) { |
||||
changedPercentFormatPane.populate(attrTooltipContent.getChangedPercentFormat()); |
||||
} |
||||
} |
||||
|
||||
public AttrTooltipContent updateBean() { |
||||
AttrTooltipContent attrTooltipContent = createAttrTooltip(); |
||||
|
||||
attrTooltipContent.setCommon(content.getSelectedIndex() == 0); |
||||
|
||||
updateFormatPane(attrTooltipContent); |
||||
|
||||
updateFormatsWithPaneWidth(attrTooltipContent); |
||||
|
||||
htmlLabelPane.update(attrTooltipContent.getHtmlLabel()); |
||||
|
||||
if (hasTextStylePane()) { |
||||
attrTooltipContent.setCustom(styleButton.getSelectedIndex() == 1); |
||||
attrTooltipContent.setTextAttr(this.textAttrPane.update()); |
||||
} |
||||
|
||||
return attrTooltipContent; |
||||
} |
||||
|
||||
protected AttrTooltipContent createAttrTooltip() { |
||||
return new AttrTooltipContent(); |
||||
} |
||||
|
||||
protected void updateFormatPane(AttrTooltipContent attrTooltipContent) { |
||||
categoryNameFormatPane.update(attrTooltipContent.getCategoryFormat()); |
||||
seriesNameFormatPane.update(attrTooltipContent.getSeriesFormat()); |
||||
valueFormatPane.update(attrTooltipContent.getValueFormat()); |
||||
percentFormatPane.update(attrTooltipContent.getPercentFormat()); |
||||
|
||||
if (changedValueFormatPane != null) { |
||||
changedValueFormatPane.update(attrTooltipContent.getChangedValueFormat()); |
||||
} |
||||
if (changedPercentFormatPane != null) { |
||||
changedPercentFormatPane.update(attrTooltipContent.getChangedPercentFormat()); |
||||
} |
||||
} |
||||
|
||||
private void updateFormatsWithPaneWidth(AttrTooltipContent attrTooltipContent) { |
||||
int paneWidth = seriesNameFormatPane.getWidth(); |
||||
if (paneWidth == 0) { |
||||
attrTooltipContent.getSeriesFormat().setEnable(false); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
|
||||
package com.fr.van.chart.designer.component; |
||||
|
||||
import com.fr.design.dialog.BasicDialog; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.utils.gui.GUICoreUtils; |
||||
|
||||
import java.awt.Dimension; |
||||
import java.awt.Frame; |
||||
|
||||
public class VanChartRichEditorDialog extends BasicDialog { |
||||
|
||||
public static final Dimension DEFAULT = new Dimension(660, 600); |
||||
|
||||
public VanChartRichEditorDialog(Frame parent, BasicPane pane) { |
||||
super(parent, pane); |
||||
|
||||
this.setTitle(Toolkit.i18nText("Fine-Design_Report_RichTextEditor")); |
||||
this.setBasicDialogSize(DEFAULT); |
||||
GUICoreUtils.centerWindow(this); |
||||
this.setResizable(true); |
||||
this.setModal(true); |
||||
} |
||||
|
||||
protected void applyEnterAction() { |
||||
|
||||
} |
||||
|
||||
public void checkValid() { |
||||
|
||||
} |
||||
} |
@ -1,58 +1,210 @@
|
||||
package com.fr.van.chart.designer.component.border; |
||||
|
||||
import com.fr.chart.base.AttrBorder; |
||||
import com.fr.chart.chartglyph.Marker; |
||||
import com.fr.chart.chartglyph.MarkerFactory; |
||||
import com.fr.design.dialog.BasicPane; |
||||
import com.fr.design.gui.ibutton.UIButtonGroup; |
||||
import com.fr.design.gui.icombobox.LineComboBox; |
||||
import com.fr.design.gui.ilable.UILabel; |
||||
import com.fr.design.gui.ispinner.UISpinner; |
||||
import com.fr.design.gui.xcombox.MarkerComboBox; |
||||
import com.fr.design.i18n.Toolkit; |
||||
import com.fr.design.layout.TableLayout; |
||||
import com.fr.design.style.color.ColorSelectBox; |
||||
import com.fr.design.utils.gui.UIComponentUtils; |
||||
import com.fr.design.widget.FRWidgetFactory; |
||||
import com.fr.plugin.chart.base.AttrBorderWithShape; |
||||
import com.fr.plugin.chart.marker.type.MarkerType; |
||||
import com.fr.stable.Constants; |
||||
import com.fr.stable.CoreConstants; |
||||
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 VanChartBorderWithShapePane extends VanChartBorderWithRadiusPane { |
||||
public class VanChartBorderWithShapePane extends BasicPane { |
||||
private static final int RECTANGULAR_INDEX = 0; |
||||
private static final int DIALOG_INDEX = 1; |
||||
|
||||
private MarkerComboBox shapePane; |
||||
private static final int AUTO_COLOR = 0; |
||||
private static final int CUSTOM_COLOR = 1; |
||||
|
||||
protected void initComponents() { |
||||
shapePane = new MarkerComboBox(MarkerFactory.getLabelShapeMarkers()); |
||||
super.initComponents(); |
||||
private LineComboBox lineTypeBox; |
||||
private UIButtonGroup<Integer> lineColorButton; |
||||
private ColorSelectBox lineColorBox; |
||||
private MarkerComboBox borderShape; |
||||
private UISpinner borderRadius; |
||||
|
||||
private JPanel detailPane; |
||||
private JPanel colorBoxPane; |
||||
|
||||
public VanChartBorderWithShapePane() { |
||||
initComponents(); |
||||
createBorderPane(); |
||||
} |
||||
|
||||
private void initComponents() { |
||||
lineTypeBox = new LineComboBox(CoreConstants.STRIKE_LINE_STYLE_ARRAY_4_CHART); |
||||
lineColorButton = new UIButtonGroup<>(new String[]{ |
||||
Toolkit.i18nText("Fine-Design_Chart_Automatic"), |
||||
Toolkit.i18nText("Fine-Design_Chart_Custom") |
||||
}); |
||||
lineColorBox = new ColorSelectBox(100); |
||||
borderShape = new MarkerComboBox(MarkerFactory.getLabelShapeMarkers()); |
||||
borderRadius = new UISpinner(0, 1000, 1, 0); |
||||
} |
||||
|
||||
private void createBorderPane() { |
||||
this.setLayout(new BorderLayout()); |
||||
|
||||
detailPane = createDetailPane(); |
||||
|
||||
this.add(createLineTypePane(), BorderLayout.CENTER); |
||||
this.add(detailPane, BorderLayout.SOUTH); |
||||
|
||||
initLineTypeListener(); |
||||
initLineColorListener(); |
||||
initShapeListener(); |
||||
} |
||||
|
||||
private void initLineTypeListener() { |
||||
lineTypeBox.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkDetailPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkDetailPane() { |
||||
detailPane.setVisible(lineTypeBox.getSelectedLineStyle() != Constants.LINE_NONE); |
||||
} |
||||
|
||||
protected Component[][] getUseComponent() { |
||||
return new Component[][]{ |
||||
private void initLineColorListener() { |
||||
lineColorButton.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkColorPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkColorPane() { |
||||
colorBoxPane.setVisible(lineColorButton.getSelectedIndex() == CUSTOM_COLOR); |
||||
} |
||||
|
||||
private void initShapeListener() { |
||||
borderShape.addActionListener(new ActionListener() { |
||||
public void actionPerformed(ActionEvent e) { |
||||
checkRadiusPane(); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
private void checkRadiusPane() { |
||||
borderRadius.setEnabled(borderShape.getSelectedIndex() == RECTANGULAR_INDEX || borderShape.getSelectedIndex() == DIALOG_INDEX); |
||||
} |
||||
|
||||
private JPanel createLineTypePane() { |
||||
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[]{FRWidgetFactory.createLineWrapLabel(Toolkit.i18nText("Fine-Design_Chart_Line_Style")), |
||||
UIComponentUtils.wrapWithBorderLayoutPane(currentLineCombo)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), currentLineColorPane}, |
||||
UIComponentUtils.wrapWithBorderLayoutPane(lineTypeBox)}}; |
||||
|
||||
return TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
} |
||||
|
||||
private JPanel createDetailPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p, p}; |
||||
|
||||
Component[][] components = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Shape")), |
||||
UIComponentUtils.wrapWithBorderLayoutPane(shapePane)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")), getRadius()} |
||||
UIComponentUtils.wrapWithBorderLayoutPane(borderShape)}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Report_Radius")), borderRadius} |
||||
}; |
||||
|
||||
JPanel center = createLineColorPane(); |
||||
JPanel south = TableLayout4VanChartHelper.createGapTableLayoutPane(components, rowSize, columnSize); |
||||
|
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
|
||||
panel.add(center, BorderLayout.CENTER); |
||||
panel.add(south, BorderLayout.SOUTH); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
protected double[] getRowSize() { |
||||
private JPanel createLineColorPane() { |
||||
double p = TableLayout.PREFERRED; |
||||
return new double[]{p, p, p, p, p}; |
||||
double f = TableLayout.FILL; |
||||
double e = TableLayout4VanChartHelper.EDIT_AREA_WIDTH; |
||||
|
||||
double[] columnSize = {f, e}; |
||||
double[] rowSize = {p, p}; |
||||
|
||||
Component[][] center = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{new UILabel(Toolkit.i18nText("Fine-Design_Chart_Color")), lineColorButton} |
||||
}; |
||||
|
||||
Component[][] south = new Component[][]{ |
||||
new Component[]{null, null}, |
||||
new Component[]{null, lineColorBox} |
||||
}; |
||||
|
||||
colorBoxPane = TableLayout4VanChartHelper.createGapTableLayoutPane(south, rowSize, columnSize); |
||||
|
||||
JPanel panel = new JPanel(new BorderLayout()); |
||||
|
||||
panel.add(TableLayout4VanChartHelper.createGapTableLayoutPane(center, rowSize, columnSize), BorderLayout.CENTER); |
||||
panel.add(colorBoxPane, BorderLayout.SOUTH); |
||||
|
||||
return panel; |
||||
} |
||||
|
||||
public void populate(AttrBorder border) { |
||||
super.populate(border); |
||||
protected String title4PopupWindow() { |
||||
return null; |
||||
} |
||||
|
||||
if (border instanceof AttrBorderWithShape) { |
||||
shapePane.setSelectedMarker((Marker.createMarker(((AttrBorderWithShape) border).getShape()))); |
||||
public void populate(AttrBorderWithShape border) { |
||||
if (border == null) { |
||||
return; |
||||
} |
||||
} |
||||
|
||||
public void update(AttrBorder border) { |
||||
super.update(border); |
||||
lineTypeBox.setSelectedLineStyle(border.getBorderStyle()); |
||||
lineColorButton.setSelectedIndex(border.isAutoColor() ? AUTO_COLOR : CUSTOM_COLOR); |
||||
lineColorBox.setSelectObject(border.getBorderColor()); |
||||
borderShape.setSelectedMarker((Marker.createMarker(border.getShape()))); |
||||
borderRadius.setValue(border.getRoundRadius()); |
||||
|
||||
if (border instanceof AttrBorderWithShape) { |
||||
((AttrBorderWithShape) border).setShape(MarkerType.parse(shapePane.getSelectedMarkder().getMarkerType())); |
||||
checkDetailPane(); |
||||
checkColorPane(); |
||||
checkRadiusPane(); |
||||
} |
||||
|
||||
public void update(AttrBorderWithShape border) { |
||||
if (border == null) { |
||||
return; |
||||
} |
||||
|
||||
border.setBorderStyle(lineTypeBox.getSelectedLineStyle()); |
||||
border.setAutoColor(lineColorButton.getSelectedIndex() == AUTO_COLOR); |
||||
border.setBorderColor(lineColorBox.getSelectObject()); |
||||
border.setShape(MarkerType.parse(borderShape.getSelectedMarkder().getMarkerType())); |
||||
border.setRoundRadius((int) borderRadius.getValue()); |
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue