diff --git a/designer-base/src/main/java/com/fr/design/style/FormatPane.java b/designer-base/src/main/java/com/fr/design/style/FormatPane.java index 255efe78c5..d1679561d7 100644 --- a/designer-base/src/main/java/com/fr/design/style/FormatPane.java +++ b/designer-base/src/main/java/com/fr/design/style/FormatPane.java @@ -45,7 +45,7 @@ import java.util.Date; */ public class FormatPane extends BasicPane { private static final long serialVersionUID = 724330854437726751L; - + private Format format; private UILabel sampleLabel; //preview label. private UIRadioButton nullRadioButton; @@ -59,14 +59,14 @@ public class FormatPane extends BasicPane { //content pane. private UITextField patternTextField = null; private JList patternList = null; - + /** * Constructor. */ public FormatPane() { this.initComponents(); } - + public UILabel getSampleLabel() { return sampleLabel; } @@ -74,7 +74,7 @@ public class FormatPane extends BasicPane { public void setSampleLabel(UILabel sampleLabel) { this.sampleLabel = sampleLabel; } - + protected void initComponents() { this.setLayout(FRGUIPaneFactory.createM_BorderLayout()); @@ -172,7 +172,7 @@ public class FormatPane extends BasicPane { protected String title4PopupWindow() { return com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Style"); } - + /** * Populate */ @@ -185,17 +185,17 @@ public class FormatPane extends BasicPane { } else { if (format instanceof DecimalFormat) { checkDecimalFormat(); - } else if (format instanceof SimpleDateFormat) { + } else if (format instanceof SimpleDateFormat) { //date and time - checkDateFormat(); - } else if (format instanceof TextFormat) { + checkDateFormat(); + } else if (format instanceof TextFormat) { //Text this.textRadioButton.setSelected(true); this.applyRadioActionListener(this.textRadioButton); } } } - + private void checkDateFormat() { String pattern = ((SimpleDateFormat) format).toPattern(); if(pattern == null) { @@ -276,7 +276,7 @@ public class FormatPane extends BasicPane { } } } - + /** * 百分比面板 */ @@ -296,7 +296,7 @@ public class FormatPane extends BasicPane { /** * 是否属于数组中的列表样式 - * + * * @param stringArray 格式数组 * @param pattern 输入的格式 * @return 返回在数组中的位置 @@ -323,7 +323,7 @@ public class FormatPane extends BasicPane { } return FormatField.getInstance().getFormat(getFormatContents(), text); } - + private int getFormatContents(){ if (nullRadioButton.isSelected()) return FormatContents.NULL; @@ -335,7 +335,7 @@ public class FormatPane extends BasicPane { return FormatContents.PERCENT; else if (scientificRadioButton.isSelected()) return FormatContents.SCIENTIFIC; - else if (dateRadioButton.isSelected()) + else if (dateRadioButton.isSelected()) return FormatContents.DATE; else if (timeRadioButton.isSelected()) return FormatContents.TIME; @@ -380,7 +380,7 @@ public class FormatPane extends BasicPane { ActionEvent evt = new ActionEvent(radioButton, 100, ""); this.radioActionListener.actionPerformed(evt); } - + /** * Radio selection listener. */ @@ -393,6 +393,7 @@ public class FormatPane extends BasicPane { patternTextField.setEditable(true); patternList.setEnabled(true); + int contents = getContents(source); String[] patternArray = FormatField.getInstance().getFormatArray(contents); @@ -407,6 +408,7 @@ public class FormatPane extends BasicPane { //maybe need to select the first item. String text = patternTextField.getText(); + if (hasPattenText(text, patternModel)) { String pattern = null; if (format instanceof DecimalFormat) { @@ -418,6 +420,10 @@ public class FormatPane extends BasicPane { if (pattern != null) { patternList.setSelectedValue(pattern, true); + if (patternList.getSelectedIndex() == -1) { + //patten不在下拉框里面 + patternList.setSelectedIndex(0); + } } else { patternList.setSelectedIndex(0); } @@ -426,13 +432,13 @@ public class FormatPane extends BasicPane { }; private boolean hasPattenText (String text, DefaultListModel patternModel) { - return (text == null || text.length() <= 0) && patternModel.size() > 0; + return StringUtils.isEmpty(text) && patternModel.size() > 0; } - + private void setPatternTextEnable() { patternTextField.setEnabled(false); patternTextField.setEditable(false); - patternTextField.setText(""); + patternTextField.setText(StringUtils.EMPTY); patternList.setEnabled(false); } @@ -459,7 +465,7 @@ public class FormatPane extends BasicPane { } return contents; } - + /** * text pattern document listener. */ @@ -477,7 +483,7 @@ public class FormatPane extends BasicPane { refreshPreviewLabel(); } }; - + /** * Pattern list selection listener. */ @@ -487,5 +493,5 @@ public class FormatPane extends BasicPane { patternTextField.setText((String) patternList.getSelectedValue()); } }; - + } diff --git a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java b/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java deleted file mode 100644 index 48c151488a..0000000000 --- a/designer-base/src/main/java/com/fr/design/update/factory/DirectoryOperationFactory.java +++ /dev/null @@ -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); - } -} diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java index 8ffe8d4a41..f54b811852 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/RestoreDialog.java @@ -4,7 +4,7 @@ import com.fr.decision.update.data.UpdateConstants; import com.fr.design.gui.ibutton.UIButton; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.mainframe.DesignerContext; -import com.fr.design.update.factory.DirectoryOperationFactory; +import com.fr.design.update.utils.UpdateFileUtils; import com.fr.design.update.ui.widget.ColorfulCellRender; import com.fr.design.utils.gui.GUICoreUtils; import com.fr.stable.ArrayUtils; @@ -86,7 +86,7 @@ public class RestoreDialog extends JDialog { JPanel jarListPane = new JPanel(); jarListPane.setLayout(new BoxLayout(jarListPane, BoxLayout.Y_AXIS)); - String[] jarBackupFiles = DirectoryOperationFactory.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); + String[] jarBackupFiles = UpdateFileUtils.listFilteredFiles(StableUtils.getInstallHome(), UpdateConstants.DESIGNER_BACKUP_DIR); ArrayUtils.reverse(jarBackupFiles); String[] jarFilesList = ((jarBackupFiles.length < NUMOFCELL_LEAST) ? Arrays.copyOf(jarBackupFiles, NUMOFCELL_LEAST) : jarBackupFiles); diff --git a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java index 05608c62e6..6163d44b55 100644 --- a/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java +++ b/designer-base/src/main/java/com/fr/design/update/ui/dialog/UpdateMainDialog.java @@ -17,7 +17,7 @@ import com.fr.design.layout.TableLayoutHelper; import com.fr.design.mainframe.DesignerContext; import com.fr.design.update.actions.FileProcess; import com.fr.design.update.domain.UpdateInfoCachePropertyManager; -import com.fr.design.update.factory.DirectoryOperationFactory; +import com.fr.design.update.utils.UpdateFileUtils; import com.fr.design.update.ui.widget.LoadingLabel; import com.fr.design.update.ui.widget.UpdateActionLabel; import com.fr.design.update.ui.widget.UpdateInfoTable; @@ -320,7 +320,7 @@ public class UpdateMainDialog extends UIDialog { } }); //choose RestoreLabel to show - boolean isNeedRestore = ArrayUtils.isNotEmpty(DirectoryOperationFactory.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); + boolean isNeedRestore = ArrayUtils.isNotEmpty(UpdateFileUtils.listFilteredFiles(StableUtils.getInstallHome(), getBackupDirectory())); jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : noJarPreviousRevision; } diff --git a/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java b/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java new file mode 100644 index 0000000000..b2149be8f0 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java @@ -0,0 +1,40 @@ +package com.fr.design.update.utils; + +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 { + + /** + * 列出过滤后的文件 + * + * @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[] versionBackup = backupDir.listFiles(); + List versions = new ArrayList<>(); + if (versionBackup != null) { + for (File file : versionBackup) { + if (file.isDirectory() && file.length() > 0) { + versions.add(file.getName()); + } else { + StableUtils.deleteFile(file); + } + } + } + String[] result = new String[versions.size()]; + return versions.toArray(result); + } +} diff --git a/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java b/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java new file mode 100644 index 0000000000..0e91e9d684 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java @@ -0,0 +1,22 @@ +package com.fr.design.update.utils; + +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() { + String[] result = UpdateFileUtils.listFilteredFiles("home", "backup"); + Assert.assertEquals(0, result.length); + StableUtils.deleteFile(new File(StableUtils.pathJoin("home"))); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java index 4659faaa84..c23a5c921e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/box/VanChartBoxTooltipContentPane.java @@ -5,6 +5,7 @@ import com.fr.design.i18n.Toolkit; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipCategoryFormat; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipSeriesFormat; @@ -276,6 +277,7 @@ public class VanChartBoxTooltipContentPane extends VanChartTooltipContentPane { } protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + setRichTextAttr(new AttrTooltipRichText()); Map params = getRichTextAttr().getParams(); AttrTooltipCategoryFormat categoryFormat = attrTooltipContent.getRichTextCategoryFormat(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java index ca96165119..fcbe91a5e0 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartTooltipContentPane.java @@ -195,6 +195,10 @@ public class VanChartTooltipContentPane extends BasicBeanPane params = getRichTextAttr().getParams(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java index 569d0850cb..127ad29893 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/VanMapAreaPointAndLineGroupPane.java @@ -1,10 +1,7 @@ package com.fr.van.chart.map.designer; - -import javax.swing.BorderFactory; import javax.swing.JPanel; -import javax.swing.border.Border; /** * Created by Mitisky on 16/5/20. @@ -19,9 +16,4 @@ public class VanMapAreaPointAndLineGroupPane extends VanChartGroupPane { public VanMapAreaPointAndLineGroupPane(final JPanel areaPane, final JPanel pointPane, final JPanel linePane){ super(new String[]{AREA_MAP_STRING, POINT_MAP_STRING, LINE_MAP_STRING}, new JPanel[]{areaPane, pointPane, linePane}); } - - @Override - protected Border getButtonGroupBorder () { - return BorderFactory.createEmptyBorder(0,8,0,18); - } -} +} \ No newline at end of file diff --git a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html index 1f50c2ddfd..95cf3cf3ba 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html +++ b/designer-chart/src/main/resources/com/fr/design/editor/rich_editor.html @@ -41,19 +41,24 @@ var isAuto = Pool.data.isAuto(); var params = Pool.data.getParams(); - var dimensionIds = []; + var getDimensionIds = function (params) { + var result = []; + var paramGroup = params.split("-"); - var paramGroup = params.split("-"); + for (var i = 0, len = paramGroup.length; i < len; i++) { + var [key, value] = paramGroup[i].split(":"); + var param = {}; - for (var i = 0, len = paramGroup.length; i < len; i++) { - var [key, value] = paramGroup[i].split(":"); - var param = {}; + param[key] = value; - param[key] = value; + result.push(param); + } - dimensionIds.push(param); + return result; } + var dimensionIds = getDimensionIds(params); + var rich_editor = BI.createWidget({ type: "bi.design.chart.common.editor", element: "body", @@ -86,8 +91,12 @@ } }); - Pool.dispatch = function(){ - rich_editor.setValue({content: Pool.data.getContent(), isAuto: Pool.data.isAuto()}); + Pool.dispatch = function () { + rich_editor.setValue({ + content: Pool.data.getContent(), + isAuto: Pool.data.isAuto(), + dimensionIds: getDimensionIds(Pool.data.getParams()) + }); } Pool.update = function () { diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js index d0e49dd5f9..d42f978cd8 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.js @@ -170,6 +170,9 @@ this.store.changeIsAuto(obj.isAuto); this.fontStyleGroup.setValue(obj.isAuto); } + if (BI.contains(keys, "dimensionIds")) { + this.store.changeDimensionIds(obj.dimensionIds); + } }, _formatContent: function (content) { diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js index dbe2784463..f430fea6c5 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/editor.model.js @@ -42,6 +42,10 @@ this.model.isAuto = isAuto; }, + changeDimensionIds: function (dimensionIds) { + this.model.dimensionIds = dimensionIds; + }, + setEditorBlurState: function (isBlur) { this.model.isEditorBlur = isBlur; } diff --git a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js index 841860fc02..7efb49c0c9 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.js @@ -16,13 +16,16 @@ this.addParam(this.model.param, editorService.encode); this.combo.hideView(); // this._restorePosition(); + }, + items: function () { + this.adapter.populate(this.model.items); } }, render: function () { var self = this; - var adapter = BI.createWidget({ + this.adapter = BI.createWidget({ type: "bi.button_group", items: this.model.items, chooseType: BI.ButtonGroup.CHOOSE_TYPE_SINGLE, @@ -47,7 +50,7 @@ bgap: 10, items: [{ type: "bi.searcher", - adapter: adapter, + adapter: this.adapter, width: 210, height: 24, listeners: [{ @@ -56,7 +59,7 @@ self.store.changeParam(this.getValue()[0]); } }] - }, adapter] + }, this.adapter] }; return { diff --git a/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java index 89b261bb9a..2bc126f5b9 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/TopXCreators.java @@ -30,7 +30,7 @@ public class TopXCreators extends JComponent { setBackground(null); setOpaque(false); designer.addDesignerEditListener(e -> { - if (e.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED) { + if (e.getCreatorEventID() == DesignerEvent.CREATOR_SELECTED || e.getCreatorEventID() == DesignerEvent.CREATOR_CUTED) { refresh(); } }); diff --git a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java index 2fdf1e5a6c..f1f916e05f 100644 --- a/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java +++ b/designer-realize/src/main/java/com/fr/design/mainframe/cell/settingpane/style/StylePane.java @@ -61,7 +61,7 @@ public class StylePane extends UIComboBoxPane