diff --git a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java index 0ccb5d3e7b..5afe58ad30 100644 --- a/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java +++ b/designer-base/src/main/java/com/fr/design/actions/file/PreferencePane.java @@ -20,6 +20,7 @@ import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.iprogressbar.UIProgressBarUI; import com.fr.design.gui.ispinner.UISpinner; import com.fr.design.gui.itextfield.UITextField; +import com.fr.design.jdk.JdkVersion; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -39,6 +40,7 @@ import com.fr.general.log.Log4jConfig; import com.fr.locale.InterProviderFactory; import com.fr.log.FineLoggerFactory; import com.fr.stable.Constants; +import com.fr.stable.StableUtils; import com.fr.stable.os.OperatingSystem; import com.fr.third.apache.log4j.Level; import com.fr.transaction.Configurations; @@ -216,7 +218,7 @@ public class PreferencePane extends BasicPane { oracleSpace = new UICheckBox(i18nText("Fine-Design_Basic_Show_All_Oracle_Tables")); oraclePane.add(oracleSpace); - if (!OperatingSystem.isLinux()) { + if (!OperatingSystem.isLinux() && JdkVersion.LE_8.support()) { JPanel upmSelectorPane = FRGUIPaneFactory.createTitledBorderPane(i18nText("Fine-Design_Basic_Update_Plugin_Manager")); useOptimizedUPMCheckbox = new UICheckBox(i18nText("Fine-Design_Basic_Use_New_Update_Plugin_Manager")); upmSelectorPane.add(useOptimizedUPMCheckbox); diff --git a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java index 15a7c87c08..93dc57a8f4 100644 --- a/designer-base/src/main/java/com/fr/design/constants/UIConstants.java +++ b/designer-base/src/main/java/com/fr/design/constants/UIConstants.java @@ -37,7 +37,7 @@ public interface UIConstants { public static final Image APPFIT_H3 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H3.png"); public static final Image APPFIT_H4 = IOUtils.readImage("/com/fr/design/images/dialog/appfit/H4.png"); - public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 0, 0, 0); + public static final Border CELL_ATTR_ZEROBORDER = BorderFactory.createEmptyBorder(0, 1, 0, 0); public static final Border CELL_ATTR_EMPTYBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 0); public static final Border CELL_ATTR_PRESENTBORDER = BorderFactory.createEmptyBorder(0, 5, 0, 0); public static final Border CELL_ATTR_NORMALBORDER = BorderFactory.createEmptyBorder(0, 10, 0, 15); diff --git a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java index bce63d6429..f1758f0689 100644 --- a/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java +++ b/designer-base/src/main/java/com/fr/design/data/DesignTableDataManager.java @@ -97,7 +97,7 @@ public abstract class DesignTableDataManager { */ private static void fireDsChanged() { fireDsChanged(globalDsListeners); - for (Iterator>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext();) { + for (Iterator>> entryIterator = dsListenersMap.entrySet().iterator(); entryIterator.hasNext(); ) { List dsListeners = entryIterator.next().getValue(); fireDsChanged(dsListeners); } @@ -190,6 +190,7 @@ public abstract class DesignTableDataManager { } dsListeners.add(l); } + /** * 获取数据源source中dsName的所有字段 * @@ -280,7 +281,7 @@ public abstract class DesignTableDataManager { Entry entry = entryIt.next(); list.add(entry.getKey()); } - return list.toArray(new String[list.size()]); + return list.toArray(new String[0]); } /** diff --git a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java index 8c09eb3035..29e704f481 100644 --- a/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java +++ b/designer-base/src/main/java/com/fr/design/data/datapane/TableDataPaneListPane.java @@ -7,6 +7,7 @@ import com.fr.data.impl.storeproc.StoreProcedure; import com.fr.design.data.BasicTableDataUtils; import com.fr.design.data.DesignTableDataManager; import com.fr.design.dialog.FineJOptionPane; +import com.fr.design.gui.NameInspector; import com.fr.design.gui.controlpane.JListControlPane; import com.fr.design.gui.controlpane.NameableCreator; import com.fr.design.gui.ilist.ListModelElement; @@ -34,7 +35,7 @@ import java.util.Map; */ public class TableDataPaneListPane extends JListControlPane implements TableDataPaneController { private boolean isNamePermitted = true; - private Map dsNameChangedMap = new HashMap(); + private Map dsNameChangedMap = new HashMap<>(); public TableDataPaneListPane() { super(); @@ -43,11 +44,16 @@ public class TableDataPaneListPane extends JListControlPane implements TableData @Override public void propertyChange() { isNamePermitted = true; + String tempName = getEditingName(); + if (ComparatorUtils.equals(tempName, selectedName)) { + //说明双击之后又取消了,啥也不用做 + return; + } TableDataSource source = DesignTableDataManager.getEditingTableDataSource(); String[] allDSNames = DesignTableDataManager.getAllDSNames(source); String[] allListNames = nameableList.getAllNames(); - allListNames[nameableList.getSelectedIndex()] = StringUtils.EMPTY; - String tempName = getEditingName(); + allListNames[editingIndex] = StringUtils.EMPTY; + Object editingType = getEditingType(); if (!BasicTableDataUtils.checkName(tempName)) { @@ -61,15 +67,14 @@ public class TableDataPaneListPane extends JListControlPane implements TableData isNamePermitted = false; nameableList.stopEditing(); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), - Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"), - Toolkit.i18nText("Fine-Design_Report_Alert"), - JOptionPane.WARNING_MESSAGE); + Toolkit.i18nText("Fine-Design_Basic_Table_Data_Empty_Name_Tips"), + Toolkit.i18nText("Fine-Design_Report_Alert"), + JOptionPane.WARNING_MESSAGE); setIllegalIndex(editingIndex); return; } - - if (!ComparatorUtils.equals(tempName, selectedName) - && isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { + boolean isRepeated = isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName); + if (isRepeated) { isNamePermitted = false; nameableList.stopEditing(); FineJOptionPane.showMessageDialog(SwingUtilities.getWindowAncestor(TableDataPaneListPane.this), Toolkit.i18nText("Fine-Design_Basic_Table_Data_Duplicate_Name_Tips", tempName)); @@ -81,11 +86,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData setIllegalIndex(editingIndex); } if (nameableList.getSelectedValue() instanceof ListModelElement) { - Nameable selected = ((ListModelElement) nameableList.getSelectedValue()).wrapper; - if (!ComparatorUtils.equals(tempName, selected.getName()) && !isNameRepeated(new List[]{Arrays.asList(allDSNames), Arrays.asList(allListNames)}, tempName)) { - rename(selected.getName(), tempName); - - } + rename(selectedName, isRepeated ? NameInspector.ILLEGAL_NAME_HOLDER : tempName); } } }); @@ -93,6 +94,13 @@ public class TableDataPaneListPane extends JListControlPane implements TableData @Override public void rename(String oldName, String newName) { + //如果a改成了b,b又被改成了c,就认为是a改成了c + for (Map.Entry entry : dsNameChangedMap.entrySet()) { + if (StringUtils.equals(oldName, entry.getValue())) { + oldName = entry.getKey(); + } + } + dsNameChangedMap.put(oldName, newName); } @@ -148,7 +156,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData String[] allDsNames = DesignTableDataManager.getAllDSNames(source); // richer:生成的名字从1开始. kunsnat: 添加属性从0开始. - int count = 1; + int count = 1; while (isDsNameRepeated(prefix + count, allDsNames)) { count++; } @@ -192,7 +200,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } } - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + populate(nameObjectList.toArray(new NameObject[0])); } /** @@ -209,10 +217,10 @@ public class TableDataPaneListPane extends JListControlPane implements TableData } while (procedurenameIt.hasNext()) { String name = procedurenameIt.next(); - nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name))); + nameObjectList.add(new NameObject(name, ProcedureConfig.getInstance().getProcedure(name))); } - populate(nameObjectList.toArray(new NameObject[nameObjectList.size()])); + populate(nameObjectList.toArray(new NameObject[0])); } @Override @@ -220,7 +228,7 @@ public class TableDataPaneListPane extends JListControlPane implements TableData tableDataConfig.removeAllTableData(); ProcedureConfig.getInstance().removeAllProcedure(); Nameable[] tableDataArray = this.update(); - Map tableDataMap = new LinkedHashMap(); + Map tableDataMap = new LinkedHashMap(); for (int i = 0; i < tableDataArray.length; i++) { NameObject nameObject = (NameObject) tableDataArray[i]; tableDataMap.put(nameObject.getName(), (TableData) nameObject.getObject()); diff --git a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java index 8f2021c696..dd3ddab3b9 100644 --- a/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java +++ b/designer-base/src/main/java/com/fr/design/dialog/UIDialog.java @@ -116,6 +116,11 @@ public abstract class UIDialog extends JDialog { doCancel(); } }); + + applyEnterAction(); + } + + protected void applyEnterAction() { JPanel defaultPane = (JPanel) this.getContentPane(); InputMap inputMapAncestor = defaultPane.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); ActionMap actionMap = defaultPane.getActionMap(); diff --git a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java index 0d12772d33..76255d96b7 100644 --- a/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java +++ b/designer-base/src/main/java/com/fr/design/gui/controlpane/ListControlPaneHelper.java @@ -65,7 +65,7 @@ class ListControlPaneHelper { res.add(((ListModelElement) listModel.getElementAt(i)).wrapper); } - return res.toArray(new Nameable[res.size()]); + return res.toArray(new Nameable[0]); } /** diff --git a/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java b/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java index 9ce63abe37..f806ded065 100644 --- a/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java +++ b/designer-base/src/main/java/com/fr/design/gui/style/FRFontPane.java @@ -25,10 +25,20 @@ import com.fr.general.FRFont; import com.fr.stable.Constants; -import javax.swing.*; +import javax.swing.BorderFactory; +import javax.swing.JFrame; +import javax.swing.JPanel; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; -import java.awt.*; +import java.awt.BorderLayout; +import java.awt.CardLayout; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.GridLayout; +import java.awt.RenderingHints; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; import java.util.Vector; @@ -67,11 +77,20 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private UIToggleButton subPane; private JPanel linePane; private int italic_bold; + /** + * LeftPane和RightPane之间的间隙,也是fontSizeStyleComboBox与fontSizeComboBox之间的间隙,之前的默认值为VGAP_LARGE + */ + private int hGapBetweenLeftPaneAndRightPane = LayoutConstants.VGAP_LARGE; public FRFontPane() { this.initComponents(); } + public FRFontPane(int hGapBetweenLeftPaneAndRightPane) { + this.hGapBetweenLeftPaneAndRightPane = hGapBetweenLeftPaneAndRightPane; + this.initComponents(); + } + public static void main(String[] args) { JFrame jf = new JFrame("test"); jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); @@ -345,7 +364,7 @@ public class FRFontPane extends AbstractBasicStylePane implements GlobalNameObse private JPanel createPane() { JPanel createPane = new JPanel(new BorderLayout()); createPane.add(fontNameComboBox, BorderLayout.NORTH); - JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, LayoutConstants.VGAP_LARGE, LayoutConstants.VGAP_LARGE); + JPanel jPanel = TableLayoutHelper.createGapTableLayoutPane(new Component[][]{new Component[]{createLeftPane(), createRightPane()}}, TableLayoutHelper.FILL_LASTCOLUMN, hGapBetweenLeftPaneAndRightPane, LayoutConstants.VGAP_LARGE); jPanel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0)); createPane.add(jPanel, BorderLayout.CENTER); return createPane; diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java index 47c4d35015..233fcd598c 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rtextarea/ConfigurableCaret.java @@ -12,6 +12,7 @@ import java.awt.*; import java.awt.event.*; import java.awt.datatransfer.*; import java.awt.event.ActionEvent; +import java.awt.geom.Line2D; import java.io.*; import javax.swing.*; import javax.swing.plaf.*; @@ -454,9 +455,10 @@ public class ConfigurableCaret extends DefaultCaret { // A thicker vertical line. case THICK_VERTICAL_LINE_STYLE: - g.drawLine(r.x,r.y, r.x,r.y+r.height); - r.x++; - g.drawLine(r.x,r.y, r.x,r.y+r.height); + Graphics2D g2 = (Graphics2D) g; + g2.setStroke(new BasicStroke(2)); + // 向右再移动一个位置 避免光标太接近文字内容 + g2.draw(new Line2D.Float(r.x + 1, r.y, r.x + 1, r.y + r.height)); break; } // End of switch (style). diff --git a/designer-base/src/main/java/com/fr/design/jdk/JdkVersion.java b/designer-base/src/main/java/com/fr/design/jdk/JdkVersion.java new file mode 100644 index 0000000000..be0c3da013 --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/jdk/JdkVersion.java @@ -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(); +} diff --git a/designer-base/src/main/java/com/fr/design/object/NameObject.java b/designer-base/src/main/java/com/fr/design/object/NameObject.java index 818de9d57a..c7dc3811c0 100644 --- a/designer-base/src/main/java/com/fr/design/object/NameObject.java +++ b/designer-base/src/main/java/com/fr/design/object/NameObject.java @@ -2,6 +2,7 @@ package com.fr.design.object; import com.fr.base.BaseUtils; import com.fr.general.ComparatorUtils; +import com.fr.stable.StableUtils; /** * @@ -60,10 +61,10 @@ public class NameObject { return "Name:" + this.getName() + "\tObject:" + this.getObject(); } - @SuppressWarnings({ "rawtypes", "unchecked" }) + @SuppressWarnings({ "rawtypes"}) public Object clone() throws CloneNotSupportedException { NameObject newNameObject = (NameObject)super.clone(); - newNameObject.object = BaseUtils.cloneObject(this.object); + newNameObject.object = StableUtils.cloneObject(this.object); return newNameObject; } diff --git a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java index 541e39601b..7e74e7651a 100644 --- a/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java +++ b/designer-base/src/main/java/com/fr/design/os/impl/PMDialogAction.java @@ -2,8 +2,10 @@ package com.fr.design.os.impl; import com.fr.config.ServerPreferenceConfig; import com.fr.design.extra.WebViewDlgHelper; +import com.fr.design.jdk.JdkVersion; import com.fr.design.upm.UpmFinder; import com.fr.design.utils.DesignUtils; +import com.fr.stable.StableUtils; import com.fr.stable.os.Arch; import com.fr.stable.os.OperatingSystem; import com.fr.stable.os.support.OSBasedAction; @@ -21,7 +23,7 @@ public class PMDialogAction implements OSBasedAction { DesignUtils.visitEnvServerByParameters( PLUGIN_MANAGER_ROUTE,null,null); return; } - if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM()) { + if (ServerPreferenceConfig.getInstance().isUseOptimizedUPM() && JdkVersion.LE_8.support()) { UpmFinder.showUPMDialog(); } else { WebViewDlgHelper.createPluginDialog(); 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/factory/UpdateFileFactory.java b/designer-base/src/main/java/com/fr/design/update/factory/UpdateFileFactory.java new file mode 100644 index 0000000000..cf992fe08b --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/factory/UpdateFileFactory.java @@ -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; + } +} 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..69f3f61604 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.listBackupVersions(); 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 3992be6a91..3c91ebf145 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.listBackupVersions()); jarRestoreLabel = isNeedRestore ? jarRestorePreviousRevision : noJarPreviousRevision; } @@ -544,7 +544,7 @@ public class UpdateMainDialog extends UIDialog { private void showDownLoadInfo() { //形如 Build#release-2018.07.31.03.03.52.80 String buildNO = downloadFileConfig.optString("buildNO"); - Date jarDate = (new SimpleDateFormat("yyyy.MM.dd")).parse(buildNO, new ParsePosition(buildNO.indexOf("-") + 1)); + Date jarDate = (new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss")).parse(buildNO, new ParsePosition(buildNO.indexOf("-") + 1)); String serverVersionNO = downloadFileConfig.optString("versionNO"); String currentVersionNO = ProductConstants.RELEASE_VERSION; String[] serverVersionSplitStr = serverVersionNO.split("\\."); @@ -556,8 +556,8 @@ public class UpdateMainDialog extends UIDialog { //形如 Build#release-2018.07.31.03.03.52.80 String currentNO = GeneralUtils.readBuildNO(); if (!".".equals(StableUtils.getInstallHome())) { - Date currentDate = (new SimpleDateFormat("yyyy.MM.dd")).parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); - if (DateUtils.subtractDate(jarDate, currentDate, DateUtils.DAY) > 0) { + Date currentDate = (new SimpleDateFormat("yyyy.MM.dd.HH.mm.ss")).parse(currentNO, new ParsePosition(currentNO.indexOf("-") + 1)); + if (DateUtils.subtractDate(jarDate, currentDate, DateUtils.SECOND) > 0) { updateButton.setEnabled(true); updateLabel.setVisible(true); loadingLabel.stopLoading(buildNO.contains("-") ? buildNO.substring(buildNO.lastIndexOf("-") + 1) : buildNO); 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..7a3c0a2a8a --- /dev/null +++ b/designer-base/src/main/java/com/fr/design/update/utils/UpdateFileUtils.java @@ -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 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); + } +} diff --git a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java index 12c72c5cd3..ef66fc039a 100644 --- a/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java +++ b/designer-base/src/main/java/com/fr/design/web/CustomIconPane.java @@ -4,6 +4,7 @@ import com.fr.base.BaseUtils; import com.fr.base.GraphHelper; import com.fr.base.Icon; import com.fr.base.IconManager; +import com.fr.design.designer.IntervalConstants; import com.fr.design.dialog.BasicPane; import com.fr.design.dialog.DialogActionAdapter; import com.fr.design.dialog.FineJOptionPane; @@ -401,9 +402,8 @@ public class CustomIconPane extends BasicPane { private void init() { this.setLayout(FRGUIPaneFactory.createBorderLayout()); double p = TableLayout.PREFERRED; - double rowSize[] = {p, p}; - double columnSize[] = {p, p, p}; - + double[] rowSize = {p, p}; + double[] columnSize = {p, p}; UIButton browseButton = new UIButton(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Custom_Icon_SelectIcon")); browseButton.setPreferredSize(new Dimension(80, 25)); browseButton.setToolTipText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Click_this_button")); diff --git a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java index 54cfddc8d3..515ce3690c 100644 --- a/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java +++ b/designer-base/src/main/java/com/fr/env/RemoteEnvPane.java @@ -1,7 +1,5 @@ package com.fr.env; -import com.fr.base.FRContext; -import com.fr.base.ServerConfig; import com.fr.design.DesignerEnvManager; import com.fr.design.ExtraDesignClassManager; import com.fr.design.beans.BasicBeanPane; @@ -444,38 +442,6 @@ public class RemoteEnvPane extends BasicBeanPane { new double[]{FILL} )); - setDefaultAppAndServlet(); - } - - /** - * 设置 app 和 servlet 默认值 - */ - private void setDefaultAppAndServlet() { - setWrap(webAppNameInput, () -> FRContext.getCommonOperator().getAppName(), RemoteWorkspaceURL.DEFAULT_WEB_APP_NAME); - setWrap(servletNameInput, () -> ServerConfig.getInstance().getServletName(), RemoteWorkspaceURL.DEFAULT_SERVLET_NAME); - } - - private void setWrap(final UITextField textField, final Supplier supplier, final String defaultName) { - new SwingWorker() { - - @Override - protected String doInBackground() throws Exception { - return supplier.get(); - } - - @Override - protected void done() { - String name = defaultName; - try { - name = get(); - } catch (Exception e) { - FineLoggerFactory.getLogger().error(e.getMessage() , e); - } - if (StringUtils.isEmpty(textField.getText())) { - textField.setText(name); - } - } - }.execute(); } diff --git a/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java b/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java new file mode 100644 index 0000000000..b47ea8e95a --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/data/datapane/TableDataPaneListPaneTest.java @@ -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 dsNameChangedMap = listPane.getDsNameChangedMap(); + assertEquals(1, dsNameChangedMap.size()); + } +} \ No newline at end of file diff --git a/designer-base/src/test/java/com/fr/design/update/factory/UpdateFileFactoryTest.java b/designer-base/src/test/java/com/fr/design/update/factory/UpdateFileFactoryTest.java new file mode 100644 index 0000000000..6c2211e76c --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/update/factory/UpdateFileFactoryTest.java @@ -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))); + } +} 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..8788675352 --- /dev/null +++ b/designer-base/src/test/java/com/fr/design/update/utils/UpdateFileUtilsTest.java @@ -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))); + } +} 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/VanChartHtmlLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPane.java index e6bee7c550..40f85dcb49 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPane.java @@ -148,11 +148,12 @@ public class VanChartHtmlLabelPane extends JPanel{ double p = TableLayout.PREFERRED; double f = TableLayout.FILL; double[] columnSize = { p, f }; - double[] rowSize = { p, p}; + double[] rowSize = {p, p, p}; Component[][] components = new Component[][]{ new Component[]{isCustomWidth, customWidth}, new Component[]{isCustomHeight, customHeight}, + new Component[] {null, null} }; return TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java new file mode 100644 index 0000000000..f9c9f7d490 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartHtmlLabelPaneWithBackGroundLabel.java @@ -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}); + } +} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java index 8586f21067..7fe05a3600 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPane.java @@ -13,6 +13,6 @@ public class VanChartLabelContentPane extends VanChartTooltipContentPane { } protected VanChartHtmlLabelPane createHtmlLabelPane() { - return new VanChartHtmlLabelPane(); + return new VanChartHtmlLabelPaneWithBackGroundLabel(); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java deleted file mode 100644 index dafaef060c..0000000000 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartLabelContentPaneWithoutRichText.java +++ /dev/null @@ -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 { - - private UIButtonGroup content; - - private ValueFormatPaneWithCheckBox valueFormatPane; - private PercentFormatPaneWithCheckBox percentFormatPane; - private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; - private SeriesNameFormatPaneWithCheckBox seriesNameFormatPane; - - //监控刷新时,自动数据点提示使用 - private ChangedValueFormatPaneWithCheckBox changedValueFormatPane; - private ChangedPercentFormatPaneWithCheckBox changedPercentFormatPane; - private UIButtonGroup 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); - } - } -} diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java index 09e208cc10..7ecb797d6a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRefreshTooltipContentPane.java @@ -22,6 +22,10 @@ public class VanChartRefreshTooltipContentPane extends VanChartTooltipContentPan return new double[]{p,p,p,p,p,p}; } + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java new file mode 100644 index 0000000000..e584ea5444 --- /dev/null +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/VanChartRichEditorDialog.java @@ -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() { + + } +} 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..847cd3891e 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 @@ -9,6 +9,7 @@ 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.DesignerContext; import com.fr.design.mainframe.chart.gui.style.ChartTextAttrPane; import com.fr.design.ui.ModernUIPane; import com.fr.plugin.chart.base.AttrTooltipContent; @@ -32,7 +33,6 @@ import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheck import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JComponent; -import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.SwingUtilities; import java.awt.BorderLayout; @@ -51,6 +51,15 @@ public class VanChartTooltipContentPane extends BasicBeanPane content; private CategoryNameFormatPaneWithCheckBox categoryNameFormatPane; @@ -83,7 +92,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ - Toolkit.i18nText("Fine-Design_Chart_Common"), - Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), - Toolkit.i18nText("Fine-Design_Chart_Custom") - }); + if (supportRichEditor()) { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Rich_Text"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + } else { + content = new UIButtonGroup<>(new String[]{ + Toolkit.i18nText("Fine-Design_Chart_Common"), + Toolkit.i18nText("Fine-Design_Chart_Custom") + }); + } Component[][] components = new Component[][]{ new Component[]{null, null}, @@ -279,7 +330,7 @@ public class VanChartTooltipContentPane extends BasicBeanPane(new String[]{ Toolkit.i18nText("Fine-Design_Chart_Automatic"), Toolkit.i18nText("Fine-Design_Chart_Custom") @@ -315,7 +366,12 @@ public class VanChartTooltipContentPane extends BasicBeanPane pane = VanChartRichEditorPane.createRichEditorPane(richText); - BasicDialog dialog = pane.showWindow(new JFrame()); + BasicDialog dialog = new VanChartRichEditorDialog(DesignerContext.getDesignerFrame(), pane); pane.populate(VanChartRichEditorPane.getRichEditorModel(richText)); @@ -418,8 +474,8 @@ public class VanChartTooltipContentPane extends BasicBeanPane 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()); } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java index 6459ef480b..690a6ab244 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/label/GaugeLabelContentPane.java @@ -2,7 +2,7 @@ package com.fr.van.chart.designer.component.label; import com.fr.design.i18n.Toolkit; -import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; +import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -10,7 +10,7 @@ import javax.swing.JPanel; /** * Created by mengao on 2017/8/13. */ -public class GaugeLabelContentPane extends VanChartLabelContentPaneWithoutRichText { +public class GaugeLabelContentPane extends VanChartLabelContentPane { public GaugeLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); @@ -24,6 +24,10 @@ public class GaugeLabelContentPane extends VanChartLabelContentPaneWithoutRichTe return contentPane; } + protected boolean supportRichEditor() { + return false; + } + protected boolean hasTextStylePane() { return false; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java index 309bf244a0..ca7479cc05 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/RefreshTooltipContentPaneWithOutSeries.java @@ -17,6 +17,10 @@ public class RefreshTooltipContentPaneWithOutSeries extends TooltipContentPaneWi super(null, showOnPane); } + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java index 25e0808102..5bab55e617 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/component/tooltip/TooltipContentPaneWithOutSeries.java @@ -1,6 +1,10 @@ package com.fr.van.chart.designer.component.tooltip; +import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -36,4 +40,22 @@ public class TooltipContentPaneWithOutSeries extends VanChartTooltipContentPane new Component[]{getRichTextPercentFormatPane(), null} }; } + + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextCategoryNameFormatPane(), + getRichTextValueFormatPane(), + getRichTextPercentFormatPane() + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + attrTooltipContent.getRichTextCategoryFormat(), + attrTooltipContent.getRichTextValueFormat(), + attrTooltipContent.getRichTextPercentFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } } \ No newline at end of file diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java index dfcd1a6443..96e2a7d24e 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartLabelPane.java @@ -64,11 +64,14 @@ public class VanChartLabelPane extends AbstractVanChartScrollPane { return; } ConditionAttr attrList = chart.getPlot().getConditionCollection().getDefaultAttr(); + + // labelPane中颜色选择器会触发listener.doChange(),导致style界面update两次, + // 为了避免递归updateBean时,remove与add不匹配,调整一下labelPane.update()的位置 + AttrLabel attrLabel = labelPane.update(); DataSeriesCondition attr = ((VanChartPlot)chart.getPlot()).getAttrLabelFromConditionCollection(); if(attr != null) { attrList.remove(attr); } - AttrLabel attrLabel = labelPane.update(); if (attrLabel != null) { attrList.addDataSeriesCondition(attrLabel); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java index 22f8ace786..fd387654ee 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/designer/style/label/VanChartPlotLabelDetailPane.java @@ -36,6 +36,8 @@ import java.awt.Component; public class VanChartPlotLabelDetailPane extends BasicPane { private static final long serialVersionUID = -22438250307946275L; + private static final int HORIZONTAL_INDEX = 0; + private BasicBeanPane dataLabelContentPane; private UIButtonGroup position; @@ -51,6 +53,9 @@ public class VanChartPlotLabelDetailPane extends BasicPane { private JPanel positionPane; private Integer[] oldPositionValues; + private JPanel borderPaneWithTitle; + private JPanel backgroundPaneWithTitle; + private VanChartStylePane parent; private Plot plot; @@ -125,8 +130,9 @@ public class VanChartPlotLabelDetailPane extends BasicPane { private JPanel createLabelBorderPane() { borderPane = new VanChartBorderWithShapePane(); + borderPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Border"), borderPane); + return borderPaneWithTitle; } private JPanel createLabelBackgroundPane() { @@ -142,7 +148,9 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } }; - return TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); + backgroundPaneWithTitle = TableLayout4VanChartHelper.createExpandablePaneWithTitle(Toolkit.i18nText("Fine-Design_Chart_Background"), backgroundPane); + + return backgroundPaneWithTitle; } protected double[] getLabelStyleRowSize(double p) { @@ -227,6 +235,12 @@ public class VanChartPlotLabelDetailPane extends BasicPane { Toolkit.i18nText("Fine-Design_Chart_Direction_Vertical"), }); + orientation.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + checkOrientation(); + } + }); + return TableLayout4VanChartHelper.createGapTableLayoutPane(Toolkit.i18nText("Fine-Design_Chart_Text_Orientation"), orientation); } @@ -309,6 +323,16 @@ public class VanChartPlotLabelDetailPane extends BasicPane { tractionLine.setSelected(position.getSelectedItem() == Constants.OUTSIDE); checkPositionEnabled(); } + + private void checkOrientation() { + if (orientation != null && borderPaneWithTitle != null && backgroundPaneWithTitle != null) { + boolean horizontal = orientation.getSelectedIndex() == HORIZONTAL_INDEX; + + borderPaneWithTitle.setVisible(horizontal); + backgroundPaneWithTitle.setVisible(horizontal); + } + } + private void checkPositionEnabled() { tractionLinePane.setVisible(position.getSelectedItem() == Constants.OUTSIDE); } @@ -344,6 +368,7 @@ public class VanChartPlotLabelDetailPane extends BasicPane { } checkAllUse(); + checkOrientation(); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java index 3df529fc3f..af29cddf39 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelLabelContentPane.java @@ -1,15 +1,17 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithoutCheckBox; -import com.fr.van.chart.designer.component.format.PercentFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -59,10 +61,29 @@ public class VanChartFunnelLabelContentPane extends VanChartLabelContentPane { setRichTextPercentFormatPane(new FunnelPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextSeriesNameFormatPane(), + getRichTextValueFormatPane(), + getRichTextPercentFormatPane() + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + attrTooltipContent.getRichTextSeriesFormat(), + attrTooltipContent.getRichTextValueFormat(), + attrTooltipContent.getRichTextPercentFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.getCategoryFormat().setEnable(false); attrTooltipContent.setSeriesFormat(new AttrTooltipNameFormat()); + attrTooltipContent.setRichTextSeriesFormat(new AttrTooltipNameFormat()); return attrTooltipContent; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java index 3b45d188bd..b7f817eb3c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelRefreshTooltipContentPane.java @@ -16,6 +16,11 @@ public class VanChartFunnelRefreshTooltipContentPane extends VanChartFunnelToolt public VanChartFunnelRefreshTooltipContentPane(VanChartStylePane parent, JPanel showOnPane) { super(null, showOnPane); } + + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java index 4c4ff52201..ef6fc82108 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/funnel/designer/style/VanChartFunnelTooltipContentPane.java @@ -1,6 +1,8 @@ package com.fr.van.chart.funnel.designer.style; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.base.format.AttrTooltipNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; @@ -9,6 +11,7 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckB import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -58,10 +61,29 @@ public class VanChartFunnelTooltipContentPane extends VanChartTooltipContentPane setRichTextPercentFormatPane(new FunnelPercentFormatPaneWithoutCheckBox(parent, showOnPane)); } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextSeriesNameFormatPane(), + getRichTextValueFormatPane(), + getRichTextPercentFormatPane() + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + attrTooltipContent.getRichTextSeriesFormat(), + attrTooltipContent.getRichTextValueFormat(), + attrTooltipContent.getRichTextPercentFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.getCategoryFormat().setEnable(false); attrTooltipContent.setSeriesFormat(new AttrTooltipNameFormat()); + attrTooltipContent.setRichTextSeriesFormat(new AttrTooltipNameFormat()); attrTooltipContent.getSeriesFormat().setEnable(true); attrTooltipContent.getValueFormat().setEnable(true); return attrTooltipContent; diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java index 54ab3fd1f1..cfb1e63a8a 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/label/VanChartGanttLabelContentPane.java @@ -3,7 +3,7 @@ package com.fr.van.chart.gantt.designer.style.label; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.gantt.attr.AttrGanttTooltipContent; -import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; +import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; @@ -16,7 +16,7 @@ import java.awt.Component; /** * Created by hufan on 2017/1/13. */ -public class VanChartGanttLabelContentPane extends VanChartLabelContentPaneWithoutRichText { +public class VanChartGanttLabelContentPane extends VanChartLabelContentPane { private VanChartFormatPaneWithCheckBox processesFormatPane; private VanChartDateFormatPaneWithCheckBox startTimeFormatPane; @@ -57,6 +57,10 @@ public class VanChartGanttLabelContentPane extends VanChartLabelContentPaneWitho }; } + protected boolean supportRichEditor() { + return false; + } + protected Component[][] getPaneComponents() { return new Component[][]{ new Component[]{processesFormatPane, null}, diff --git a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java index 3d3d87d10d..0d1cc22bae 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/gantt/designer/style/tooltip/VanChartGanttTooltipContentPane.java @@ -2,6 +2,7 @@ package com.fr.van.chart.gantt.designer.style.tooltip; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipDurationFormat; import com.fr.plugin.chart.base.format.AttrTooltipEndTimeFormat; import com.fr.plugin.chart.base.format.AttrTooltipProcessesFormat; @@ -136,6 +137,8 @@ public class VanChartGanttTooltipContentPane extends VanChartTooltipContentPane protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { if(attrTooltipContent instanceof AttrGanttTooltipContent){ + setRichTextAttr(new AttrTooltipRichText()); + AttrGanttTooltipContent ganttTooltipContent = (AttrGanttTooltipContent) attrTooltipContent; Map 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/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java index de2b9171c9..f73c32a48b 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/label/VanChartMapLabelContentPane.java @@ -45,6 +45,8 @@ public class VanChartMapLabelContentPane extends VanChartLabelContentPane { AttrTooltipContent content = new AttrTooltipContent(); content.setCategoryFormat(new AttrTooltipAreaNameFormat()); content.setValueFormat(new AttrTooltipMapValueFormat()); + content.setRichTextCategoryFormat(new AttrTooltipAreaNameFormat()); + content.setRichTextValueFormat(new AttrTooltipMapValueFormat()); return content; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java index 21b8995f30..7dca0fb3bc 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapRefreshTooltipContentPane.java @@ -23,6 +23,10 @@ public class VanChartMapRefreshTooltipContentPane extends VanChartMapTooltipCont return new double[]{p,p,p,p,p,p}; } + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java index cc4ca79828..12948b14dd 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/designer/style/tooltip/VanChartMapTooltipContentPane.java @@ -45,6 +45,8 @@ public class VanChartMapTooltipContentPane extends VanChartTooltipContentPane { AttrTooltipContent content = new AttrTooltipContent(); content.setCategoryFormat(new AttrTooltipAreaNameFormat()); content.setValueFormat(new AttrTooltipMapValueFormat()); + content.setRichTextCategoryFormat(new AttrTooltipAreaNameFormat()); + content.setRichTextValueFormat(new AttrTooltipMapValueFormat()); return content; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java index 1b3d31bee5..9dbc696a68 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/map/line/VanChartLineMapTooltipContentPane.java @@ -43,6 +43,8 @@ public class VanChartLineMapTooltipContentPane extends VanChartTooltipContentPan AttrTooltipContent content = new AttrTooltipContent(); content.setCategoryFormat(new AttrTooltipStartAndEndNameFormat()); content.setValueFormat(new AttrTooltipValueFormat()); + content.setRichTextCategoryFormat(new AttrTooltipStartAndEndNameFormat()); + content.setRichTextValueFormat(new AttrTooltipValueFormat()); return content; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java index 7fc9256bda..a3d8f3c576 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieLabelContentPane.java @@ -38,6 +38,7 @@ public class VanChartMultiPieLabelContentPane extends VanChartLabelContentPane { protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent content = new AttrTooltipContent(); content.setCategoryFormat(new AttrTooltipMultiLevelNameFormat()); + content.setRichTextCategoryFormat(new AttrTooltipMultiLevelNameFormat()); return content; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java index dab7a5043b..1fbe0870a5 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMultiPieTooltipContentPane.java @@ -39,6 +39,7 @@ public class VanChartMultiPieTooltipContentPane extends VanChartTooltipContentPa protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent content = new AttrTooltipContent(); content.setCategoryFormat(new AttrTooltipMultiLevelNameFormat()); + content.setRichTextCategoryFormat(new AttrTooltipMultiLevelNameFormat()); return content; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java index a38383306d..f375fa78fa 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/multilayer/style/VanChartMutiPieRefreshTooltipContentPane.java @@ -19,6 +19,10 @@ public class VanChartMutiPieRefreshTooltipContentPane extends VanChartMultiPieTo super(null, showOnPane); } + protected boolean supportRichEditor() { + return false; + } + @Override protected void initFormatPane(VanChartStylePane parent, JPanel showOnPane) { super.initFormatPane(parent, showOnPane); diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java index 43d70e0b66..db7ce4152f 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterRefreshTooltipContentPane.java @@ -41,6 +41,10 @@ public class VanChartScatterRefreshTooltipContentPane extends VanChartScatterToo setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } + protected boolean supportRichEditor() { + return false; + } + protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java index 9431b4ab76..cdc2b040e7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterTooltipContentPane.java @@ -1,6 +1,7 @@ package com.fr.van.chart.scatter; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.scatter.attr.ScatterAttrTooltipContent; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; @@ -107,21 +108,24 @@ public class VanChartScatterTooltipContentPane extends VanChartTooltipContentPa } protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { - super.populateRichEditor(attrTooltipContent); - if (attrTooltipContent instanceof ScatterAttrTooltipContent) { ScatterAttrTooltipContent scatterAttrTooltipContent = (ScatterAttrTooltipContent) attrTooltipContent; VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ - richTextXFormatPane, richTextYFormatPane, richTextSizeFormatPane + getRichTextSeriesNameFormatPane(), + richTextXFormatPane, + richTextYFormatPane, + richTextSizeFormatPane }; AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + scatterAttrTooltipContent.getRichTextSeriesFormat(), scatterAttrTooltipContent.getRichTextXFormat(), scatterAttrTooltipContent.getRichTextYFormat(), scatterAttrTooltipContent.getRichTextSizeFormat() }; + setRichTextAttr(new AttrTooltipRichText()); populateRichTextFormat(formatPaneGroup, formatGroup); populateRichText(attrTooltipContent.getRichTextAttr()); } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java index f380c8267a..bfe147ba60 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureLabelContentPane.java @@ -4,7 +4,7 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; -import com.fr.van.chart.designer.component.VanChartLabelContentPaneWithoutRichText; +import com.fr.van.chart.designer.component.VanChartLabelContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.PercentFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckBox; @@ -17,7 +17,7 @@ import java.awt.Component; /** * Created by shine on 2017/2/15. */ -public class VanChartStructureLabelContentPane extends VanChartLabelContentPaneWithoutRichText { +public class VanChartStructureLabelContentPane extends VanChartLabelContentPane { public VanChartStructureLabelContentPane(VanChartStylePane parent, JPanel showOnPane) { super(parent, showOnPane); } @@ -54,6 +54,10 @@ public class VanChartStructureLabelContentPane extends VanChartLabelContentPaneW setPercentFormatPane(percentFormatPane); } + protected boolean supportRichEditor() { + return false; + } + @Override protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java index 52295346bf..ea09ff3c83 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureRefreshTooltipContentPane.java @@ -38,6 +38,10 @@ public class VanChartStructureRefreshTooltipContentPane extends VanChartStructur setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } + protected boolean supportRichEditor() { + return false; + } + protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java index 2a72f6a09b..493da6934c 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/style/VanChartStructureTooltipContentPane.java @@ -3,6 +3,8 @@ package com.fr.van.chart.structure.desinger.style; import com.fr.design.i18n.Toolkit; import com.fr.plugin.chart.base.AttrTooltipContent; +import com.fr.plugin.chart.base.AttrTooltipRichText; +import com.fr.plugin.chart.base.format.AttrTooltipFormat; import com.fr.plugin.chart.multilayer.style.AttrTooltipMultiLevelNameFormat; import com.fr.van.chart.designer.component.VanChartTooltipContentPane; import com.fr.van.chart.designer.component.format.CategoryNameFormatPaneWithCheckBox; @@ -13,6 +15,7 @@ import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithCheckB import com.fr.van.chart.designer.component.format.SeriesNameFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithCheckBox; import com.fr.van.chart.designer.component.format.ValueFormatPaneWithoutCheckBox; +import com.fr.van.chart.designer.component.format.VanChartFormatPaneWithoutCheckBox; import com.fr.van.chart.designer.style.VanChartStylePane; import javax.swing.JPanel; @@ -87,10 +90,29 @@ public class VanChartStructureTooltipContentPane extends VanChartTooltipContentP setRichTextPercentFormatPane(richTextPercentFormatPane); } + protected void populateRichEditor(AttrTooltipContent attrTooltipContent) { + VanChartFormatPaneWithoutCheckBox[] formatPaneGroup = new VanChartFormatPaneWithoutCheckBox[]{ + getRichTextCategoryNameFormatPane(), + getRichTextSeriesNameFormatPane(), + getRichTextValueFormatPane() + }; + + AttrTooltipFormat[] formatGroup = new AttrTooltipFormat[]{ + attrTooltipContent.getRichTextCategoryFormat(), + attrTooltipContent.getRichTextSeriesFormat(), + attrTooltipContent.getRichTextValueFormat() + }; + + setRichTextAttr(new AttrTooltipRichText()); + populateRichTextFormat(formatPaneGroup, formatGroup); + populateRichText(attrTooltipContent.getRichTextAttr()); + } + @Override protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.setCategoryFormat(new AttrTooltipMultiLevelNameFormat()); + attrTooltipContent.setRichTextCategoryFormat(new AttrTooltipMultiLevelNameFormat()); return attrTooltipContent; } } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java index 30b754dd00..cab4d85584 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudRefreshTooltipContentPane.java @@ -51,6 +51,10 @@ public class VanChartWordCloudRefreshTooltipContentPane extends VanChartWordClou setRichTextChangedPercentFormatPane(richTextChangedPercentFormatPane); } + protected boolean supportRichEditor() { + return false; + } + protected double[] getRowSize(double p) { return new double[]{p, p, p, p, p, p}; } diff --git a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java index 850645c758..c0e9ac6c37 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/wordcloud/designer/style/VanChartWordCloudTooltipContentPane.java @@ -81,6 +81,7 @@ public class VanChartWordCloudTooltipContentPane extends VanChartTooltipContentP protected AttrTooltipContent createAttrTooltip() { AttrTooltipContent attrTooltipContent = new AttrTooltipContent(); attrTooltipContent.setSeriesFormat(new AttrTooltipNameFormat()); + attrTooltipContent.setRichTextSeriesFormat(new AttrTooltipNameFormat()); return attrTooltipContent; } } 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 2162430698..494be95259 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 @@ -107,6 +107,16 @@ _cleanHtml: function (value) { var editorService = BI.Services.getService("bi.service.design.chart.common.editor"); + var dimensionIds = this.model.dimensionIds; + var dataIdMap = {}; + + for (var i = 0, len = dimensionIds.length; i < len; i++) { + var dimensionId = dimensionIds[i]; + var key = BI.keys(dimensionId)[0]; + + dataIdMap[key] = dimensionId[key]; + } + var result = BI.replaceAll(value, "

", ""); // 去掉image的src属性,因为数据太大了 result = value.replaceAll("", function (imageStr) { @@ -117,6 +127,10 @@ return; } str += " " + key + "=\"" + value + "\""; + + if (key === "alt" && dataIdMap[value.trim()]) { + str += " " + "data-id" + "=\"" + dataIdMap[value.trim()] + "\""; + } }); return str + " />"; @@ -156,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) { @@ -215,7 +232,7 @@ content = this.editor.getValue(BI.NicEditor.FormatType.ESCAPE), origin = content; if (isAuto) { - content = this._switchToAutoStyle(); + // content = this._switchToAutoStyle(); this.setFocus(); } else if (editorService.isRichTextEqual(content, this.options.placeholder)) { 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-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js index d0a8f084ef..10db72cd0e 100644 --- a/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js +++ b/designer-chart/src/main/resources/com/fr/design/editor/script/insertcombo/combo.insert_param.model.js @@ -21,7 +21,7 @@ return { type: "bi.design.chart.common.editor.search", text: key, - value: dId[key] + value: key }; }); } diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java index b3215ede1c..0f673e30ae 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/models/SelectionModel.java @@ -15,6 +15,7 @@ import com.fr.design.designer.creator.XWAbsoluteBodyLayout; import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.designer.creator.XWParameterLayout; +import com.fr.design.designer.creator.cardlayout.XCardSwitchButton; import com.fr.design.designer.creator.cardlayout.XWCardLayout; import com.fr.design.designer.creator.cardlayout.XWCardMainBorderLayout; import com.fr.design.designer.creator.cardlayout.XWTabFitLayout; @@ -111,7 +112,7 @@ public class SelectionModel { if (comp != designer.getRootComponent() && comp != designer.getParaComponent()) { XCreator parentContainer = (XCreator) comp.getParent(); if (parentContainer != null) { - comp = parentContainer.isDedicateContainer() ? parentContainer : comp; + comp = parentContainer.isDedicateContainer() || comp instanceof XCardSwitchButton ? parentContainer : comp; } } if (selection.removeSelectedCreator(comp) || selection.addSelectedCreator(comp)) { diff --git a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java index 352aa80e54..3e248f3bae 100644 --- a/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java +++ b/designer-form/src/main/java/com/fr/design/form/util/FormDesignerUtils.java @@ -1,5 +1,8 @@ package com.fr.design.form.util; +import com.fr.design.designer.creator.XCreator; +import com.fr.design.designer.creator.XWAbsoluteBodyLayout; +import com.fr.design.designer.creator.XWAbsoluteLayout; import com.fr.design.designer.creator.XWFitLayout; import com.fr.design.file.HistoryTemplateListCache; import com.fr.design.mainframe.FormDesigner; @@ -8,6 +11,7 @@ import com.fr.design.mainframe.template.info.ComponentCreateOperate; import com.fr.design.mainframe.template.info.ComponentDeleteOperate; import com.fr.form.ui.Widget; import com.fr.form.ui.container.WFitLayout; +import java.awt.Container; public class FormDesignerUtils { @@ -46,4 +50,21 @@ public class FormDesignerUtils { jTemplate.getProcessInfo().updateTemplateOperationInfo(new ComponentDeleteOperate(widget)); } + /** + * 判断当前UI组件是否在绝对画布块中 + * + * @param xCreator + * @return + */ + public static boolean isInAbsoluteLayout(XCreator xCreator) { + Container parent = xCreator.getParent(); + while (parent != null) { + if (parent instanceof XWAbsoluteLayout && !(parent instanceof XWAbsoluteBodyLayout)) { + return true; + } + parent = parent.getParent(); + } + return false; + } + } diff --git a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java index 0e66964b43..089bafc592 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/EditingMouseListener.java @@ -166,7 +166,7 @@ public class EditingMouseListener extends MouseInputAdapter { // 获取焦点,以便获取热键 designer.requestFocus(); } - if (e.getButton() == MouseEvent.BUTTON1) { + if (e.getButton() == MouseEvent.BUTTON1 && !beyondValidArea(e)) { Direction dir = selectionModel.getDirectionAt(e); if (!DesignerMode.isAuthorityEditing()) { @@ -177,13 +177,10 @@ public class EditingMouseListener extends MouseInputAdapter { if (designer.isDrawLineMode()) { designer.updateDrawLineMode(e); } else { - int relativeX = Math.max(0, e.getX()); - int relativeY = Math.max(0, e.getY()); - if (selectionModel.hasSelectionComponent() && selectionModel.getSelection().getRelativeBounds().contains( - designer.getHorizontalScaleValue() + relativeX, - designer.getVerticalScaleValue() + relativeY)) { + designer.getHorizontalScaleValue() + e.getX(), + designer.getVerticalScaleValue() + e.getY())) { lastPressEvent = e; lastXCreator = selectionModel.getSelection().getSelectedCreator(); } else { @@ -197,6 +194,15 @@ public class EditingMouseListener extends MouseInputAdapter { e.translatePoint(oldX - e.getX(), oldY - e.getY()); } + private boolean beyondValidArea(MouseEvent e) { + if (e.getX() < 0 || e.getY() < 0 || + e.getX() > designer.getRootComponent().getWidth() || + e.getY() > (designer.getRootComponent().getHeight() + designer.getParaHeight())) { + return true; + } + return false; + } + private void offsetEventPoint(MouseEvent e){ int x = designer.getRelativeX(e.getX()); int y = designer.getRelativeY(e.getY()); diff --git a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java index c4fa2df8a1..a80032ed6f 100644 --- a/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java +++ b/designer-form/src/main/java/com/fr/design/mainframe/FormDesigner.java @@ -619,8 +619,9 @@ public class FormDesigner extends TargetComponent
implements TreeSelection if (paraComponent != null && paraComponent.acceptType(XWParameterLayout.class)) { return true; } else { - if (this.getSelectionModel().getSelection().getSelectedCreator().getParent() != null - && ((XLayoutContainer) this.getSelectionModel().getSelection().getSelectedCreator().getParent()).acceptType(XWAbsoluteLayout.class)) { + XCreator creator = this.getSelectionModel().getSelection().getSelectedCreator(); + if (creator != null && creator.getParent() != null + && ((XLayoutContainer) creator.getParent()).acceptType(XWAbsoluteLayout.class)) { return true; } } @@ -1337,6 +1338,9 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 当前选中控件可以上移一层吗? public boolean isCurrentComponentMovableUp() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); + if (null == creator) { + return false; + } XLayoutContainer container = (XLayoutContainer) creator.getParent(); if (container == null || !container.supportInnerOrderChangeActions()) { return false; @@ -1347,6 +1351,9 @@ public class FormDesigner extends TargetComponent implements TreeSelection // 当前选中控件可以下移一层吗? public boolean isCurrentComponentMovableDown() { XCreator creator = getSelectionModel().getSelection().getSelectedCreator(); + if (null == creator) { + return false; + } XLayoutContainer container = (XLayoutContainer) creator.getParent(); if (container == null || !container.supportInnerOrderChangeActions()) { return false; 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-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java index d4ebf74ee7..1c30b1a557 100644 --- a/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java +++ b/designer-form/src/main/java/com/fr/design/widget/ui/designer/LabelDefinePane.java @@ -1,6 +1,7 @@ package com.fr.design.widget.ui.designer; import com.fr.base.BaseUtils; +import com.fr.design.constants.LayoutConstants; import com.fr.design.designer.IntervalConstants; import com.fr.design.designer.creator.XCreator; import com.fr.design.foldablepane.UIExpandablePane; @@ -58,7 +59,8 @@ public class LabelDefinePane extends AbstractDataModify