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 2a856f159d..a994711ebc 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 @@ -1,6 +1,6 @@ package com.fr.design.actions.file; -import com.fr.base.BaseUtils; +import com.fr.cluster.engine.base.FineClusterConfig; import com.fr.config.Configuration; import com.fr.config.ServerPreferenceConfig; import com.fr.design.DesignerEnvManager; @@ -18,12 +18,14 @@ import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIDictionaryComboBox; import com.fr.design.gui.ilable.ActionLabel; 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.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; +import com.fr.design.layout.VerticalFlowLayout; import com.fr.design.mainframe.DesignerContext; import com.fr.design.mainframe.vcs.VcsConfigManager; import com.fr.design.mainframe.vcs.common.VcsHelper; @@ -36,22 +38,39 @@ import com.fr.general.IOUtils; import com.fr.general.Inter; 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.StringUtils; import com.fr.third.apache.log4j.Level; import com.fr.transaction.Configurations; import com.fr.transaction.Worker; +import com.fr.workspace.WorkContext; +import com.fr.workspace.server.vcs.VcsOperator; +import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.BorderFactory; import javax.swing.JFileChooser; import javax.swing.JOptionPane; +import javax.swing.BoxLayout; import javax.swing.JPanel; +import javax.swing.JProgressBar; +import javax.swing.JDialog; + +import javax.swing.Timer; +import javax.swing.SwingWorker; +import javax.swing.UIManager; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; import java.awt.BorderLayout; import java.awt.Component; +import java.awt.Dialog; +import java.awt.Color; import java.awt.Dimension; import java.awt.Font; +import java.awt.FlowLayout; + import java.awt.Window; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; @@ -59,9 +78,15 @@ import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import java.awt.event.MouseAdapter; import java.awt.event.MouseEvent; +import java.awt.event.WindowEvent; + +import java.awt.event.WindowAdapter; import java.io.File; +import java.text.DecimalFormat; import java.util.Locale; import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ExecutionException; /** * 选项对话框 @@ -148,9 +173,17 @@ public class PreferencePane extends BasicPane { private UICheckBox saveCommitCheckBox; private UICheckBox useIntervalCheckBox; private IntegerEditor saveIntervalEditor; + private UICheckBox gcEnableCheckBox; + private UIButton gcButton; private UILabel remindVcsLabel; - + private JDialog gcDialog; + private UILabel gcMessage = new UILabel(); + private JPanel gcDialogDownPane = new JPanel(); + private JPanel gcProgressBarPanel = new JPanel(); + private JProgressBar gcProgressBar; + private Timer gcProgressTimer; + private UIButton gcOkButton = new UIButton(Toolkit.i18nText("Fine-Design_Report_OK")); public PreferencePane() { this.initComponents(); @@ -230,6 +263,10 @@ public class PreferencePane extends BasicPane { saveCommitCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_No_Delete")); saveIntervalEditor = new IntegerEditor(60); useIntervalCheckBox = new UICheckBox(); + + //gc面板 + JPanel gcControlPane = createGcControlPane(); + JPanel enableVcsPanel = new JPanel(FRGUIPaneFactory.createLeftZeroLayout()); enableVcsPanel.add(vcsEnableCheckBox); enableVcsPanel.add(remindVcsLabel); @@ -262,6 +299,42 @@ public class PreferencePane extends BasicPane { vcsPane.add(enableVcsPanel); vcsPane.add(intervalPanel); vcsPane.add(saveCommitCheckBox); + vcsPane.add(gcControlPane); + } + + /** + * 模创建板版本gc 配置操作面板 + * + * @return 面板 + */ + private JPanel createGcControlPane() { + //gc面板 + JPanel gcControlPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0)); + JPanel gcButtonPane = new JPanel(new FlowLayout(FlowLayout.LEFT, 40, 0)); + gcEnableCheckBox = new UICheckBox(Toolkit.i18nText("Fine-Design_Vcs_Storage_Optimization")); + gcButton = initGcButton(); + gcButtonPane.add(gcButton); + gcControlPane.add(gcEnableCheckBox); + gcControlPane.add(gcButtonPane); + gcButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent evt) { + tryGc(); + } + }); + gcEnableCheckBox.addChangeListener(new ChangeListener() { + @Override + public void stateChanged(ChangeEvent e) { + gcButton.setEnabled(gcEnableCheckBox.isSelected()); + } + }); + + //集群下禁用 + if (FineClusterConfig.getInstance().isCluster()) { + gcEnableCheckBox.setEnabled(false); + gcButton.setEnabled(false); + } + return gcControlPane; } private void createFunctionPane(JPanel generalPane) { @@ -629,7 +702,8 @@ public class PreferencePane extends BasicPane { saveIntervalEditor.setValue(vcsConfigManager.getSaveInterval()); saveCommitCheckBox.setSelected(vcsConfigManager.isSaveCommit()); useIntervalCheckBox.setSelected(vcsConfigManager.isUseInterval()); - + gcEnableCheckBox.setSelected(GcConfig.getInstance().isGcEnable()); + gcButton.setEnabled(gcEnableCheckBox.isSelected()); supportCellEditorDefCheckBox.setSelected(designerEnvManager.isSupportCellEditorDef()); isDragPermitedCheckBox.setSelected(designerEnvManager.isDragPermited()); @@ -726,6 +800,18 @@ public class PreferencePane extends BasicPane { vcsConfigManager.setVcsEnable(this.vcsEnableCheckBox.isSelected()); vcsConfigManager.setSaveCommit(this.saveCommitCheckBox.isSelected()); vcsConfigManager.setUseInterval(this.useIntervalCheckBox.isSelected()); + Configurations.update(new Worker() { + @Override + public void run() { + GcConfig.getInstance().setGcEnable(gcEnableCheckBox.isSelected()); + } + + @Override + public Class[] targets() { + return new Class[]{GcConfig.class}; + } + }); + if (this.autoPushUpdateCheckBox != null) { designerEnvManager.setAutoPushUpdateEnabled(this.autoPushUpdateCheckBox.isSelected()); } @@ -762,7 +848,6 @@ public class PreferencePane extends BasicPane { } - // 如果语言设置改变了,则显示重启对话框 public void showRestartDialog() { if (!languageChanged) { @@ -797,4 +882,191 @@ public class PreferencePane extends BasicPane { public BasicDialog showWindow(Window window, DialogActionListener l) { return showWindowWithCustomSize(window, l, new Dimension(BasicDialog.DEFAULT.width, this.getPreferredSize().height + OFFSET_HEIGHT)); } + + private void tryGc() { + final SwingWorker worker = new SwingWorker() { + private long size = 0; + + @Override + protected Boolean doInBackground() { + size = WorkContext.getCurrent().get(VcsOperator.class).immediatelyGc(); + return true; + } + + @Override + protected void done() { + try { + get(); + } catch (InterruptedException | ExecutionException e) { + FineLoggerFactory.getLogger().error(e, e.getMessage()); + } + stopGcProgressTimer(); + gcMessage.setText(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_Reduce_File_Size") + fileSizeConvert(size)); + if (null != gcProgressBar) { + gcProgressBarPanel.remove(gcProgressBar); + } + if (null != gcDialog) { + gcDialog.setTitle(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Form_Joption_News")); + } + gcDialogDownPane.revalidate(); + gcDialogDownPane.repaint(); + gcDialogDownPane.add(gcOkButton); + } + }; + worker.execute(); + initGcDialog(); + gcOkButton.addActionListener(new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + gcDialog.dispose(); + } + }); + gcDialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + stopGcProgressTimer(); + worker.cancel(true); + } + }); + gcDialog.setVisible(true); + gcDialog.dispose(); + } + + /** + * 初始化 gc 对话框 + */ + private void initGcDialog() { + gcDialog = new JDialog((Dialog) SwingUtilities.getWindowAncestor(PreferencePane.this), com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_Clean_Progress") + "...", true); + gcDialog.setSize(new Dimension(340, 140)); + + JPanel jp = new JPanel(); + //中上 + JPanel gcUpPane = new JPanel(); + gcUpPane.setLayout(new FlowLayout(FlowLayout.LEFT, 10, 10)); + gcUpPane.add(new UILabel(UIManager.getIcon("OptionPane.informationIcon"))); + gcProgressBarPanel = createProgressBarPane(); + gcUpPane.add(gcProgressBarPanel); + + //中下 + gcDialogDownPane = new JPanel(); + gcDialogDownPane.setLayout(new FlowLayout(FlowLayout.CENTER, 6, 0)); + + jp.setLayout(new BoxLayout(jp, BoxLayout.Y_AXIS)); + jp.add(gcUpPane); + jp.add(gcDialogDownPane); + gcDialog.add(jp); + gcDialog.setResizable(false); + gcDialog.setLocationRelativeTo(SwingUtilities.getWindowAncestor(PreferencePane.this)); + } + + /** + * gc 进度条面板 + * + * @return + */ + private JPanel createProgressBarPane() { + JPanel jp = new JPanel(); + VerticalFlowLayout layout = new VerticalFlowLayout(); + layout.setAlignLeft(true); + jp.setLayout(layout); + + //提示 + gcMessage = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Vcs_Cleaning")); + // 创建一个进度条 + gcProgressBar = createGcProgressBar(0, 30, 240, 15, Color.GREEN); + gcProgressTimer = createGcProgressTimer(500, gcProgressBar); + gcProgressTimer.start(); + jp.add(gcMessage); + jp.add(gcProgressBar); + return jp; + } + + /** + * 创建 gc 进度条 + * + * @param min 最小值 + * @param max 最大值 + * @param width 宽度 + * @param height 高度 + * @param color 填充的图片颜色 + * @return + */ + private JProgressBar createGcProgressBar(int min, int max, int width, int height, Color color) { + // 创建一个进度条 + JProgressBar progressBar = new JProgressBar(min, max); + UIProgressBarUI progressBarUI = new UIProgressBarUI(); + progressBar.setUI(progressBarUI); + + //颜色(进度条里的小方块) + progressBar.setForeground(color); + + progressBar.setOpaque(false); + progressBar.setPreferredSize(new Dimension(width, height)); + return progressBar; + } + + /** + * @param delay 每隔 delay 毫秒更新进度 + * @param progressBar 要更新的进度条 + * @return + */ + private Timer createGcProgressTimer(int delay, final JProgressBar progressBar) { + if (null == progressBar) { + return null; + } + // 模拟延时操作进度, 每隔 delay / 1000 秒更新进度 + Timer timer = new Timer(delay, new ActionListener() { + @Override + public void actionPerformed(ActionEvent e) { + int currentProgress = progressBar.getValue() + 1; + if (currentProgress > progressBar.getMaximum()) { + currentProgress = progressBar.getMinimum(); + } + progressBar.setValue(currentProgress); + } + }); + + return timer; + } + + /** + * 停止进度条模拟计时器 + */ + private void stopGcProgressTimer() { + if (null == gcProgressTimer) { + return; + } + gcProgressTimer.stop(); + } + + /** + * 将字节转换成 KB or MB or GB 保留两位小数 + * + * @param size + * @return + */ + private String fileSizeConvert(long size) { + DecimalFormat df = new DecimalFormat("0.00"); + double n = 1024d; + if (size > Math.pow(n, 3)) { + return df.format(size / Math.pow(n, 3)) + "GB"; + } + if (size > Math.pow(n, 2)) { + return df.format(size / Math.pow(n, 2)) + "MB"; + } + return new StringBuilder().append(df.format(size / n)).append("KB").toString(); + } + + /** + * 立即清理的Button + * + * @return + */ + private UIButton initGcButton() { + UIButton gcButton = new UIButton(Toolkit.i18nText("Fine-Design_Vcs_Clean")); + gcButton.setPreferredSize(new Dimension(100, 15)); + gcButton.setRoundBorder(true, Constants.LEFT); + return gcButton; + } + } diff --git a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java index 01d9e7dd32..8269b8d05d 100644 --- a/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java +++ b/designer-base/src/main/java/com/fr/design/gui/chart/MiddleChartComponent.java @@ -1,7 +1,6 @@ package com.fr.design.gui.chart; import com.fr.base.chart.BaseChartCollection; -import com.fr.chartx.attr.ChartProvider; import com.fr.stable.core.PropertyChangeListener; import javax.swing.JComponent; @@ -18,7 +17,5 @@ public abstract class MiddleChartComponent extends JComponent { public abstract void reset(); - public abstract ChartProvider getEditingChart(); - public abstract void addStopEditingListener(PropertyChangeListener list); } \ No newline at end of file diff --git a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java index 8054a29eac..d3393054ae 100644 --- a/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java +++ b/designer-base/src/main/java/com/fr/design/gui/iscrollbar/UIScrollBarUI.java @@ -1326,9 +1326,9 @@ public class UIScrollBarUI extends ScrollBarUI implements LayoutManager, SwingCo newModel.addChangeListener(modelListener); scrollbar.repaint(); scrollbar.revalidate(); - } else if ("orientation" == propertyName) { + } else if (StringUtils.equals("orientation", propertyName)) { updateButtonDirections(); - } else if ("componentOrientation" == propertyName) { + } else if (StringUtils.equals("componentOrientation", propertyName)) { updateButtonDirections(); InputMap inputMap = getInputMap(JComponent.WHEN_FOCUSED); SwingUtilities.replaceUIInputMap(scrollbar, JComponent.WHEN_FOCUSED, inputMap); diff --git a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java index ba6913a38a..66a9a75755 100644 --- a/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java +++ b/designer-base/src/main/java/com/fr/design/gui/ispinner/UISpinner.java @@ -9,9 +9,11 @@ import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButtonUI; import com.fr.design.gui.itextfield.UINumberField; import com.fr.design.utils.gui.GUIPaintUtils; +import com.fr.stable.CommonUtils; import com.fr.stable.Constants; import com.fr.stable.StringUtils; +import com.fr.stable.collections.utils.MathUtils; import javax.swing.*; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -109,7 +111,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver } value = value < minValue ? minValue : value; value = value > maxValue ? maxValue : value; - if (value == this.value) { + if (CommonUtils.equals(value, this.value)) { return; } this.value = value; @@ -132,7 +134,7 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver value = value < minValue ? minValue : value; value = value > maxValue ? maxValue : value; - if (value == this.value) { + if (CommonUtils.equals(value, this.value)) { return; } this.value = value; @@ -371,4 +373,4 @@ public class UISpinner extends JPanel implements UIObserver, GlobalNameObserver // jf.setSize(400, 400); // jf.setVisible(true); } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java index f556cc5b77..30b4b6d859 100644 --- a/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java +++ b/designer-base/src/main/java/com/fr/design/gui/syntax/ui/rsyntaxtextarea/modes/MakefileTokenMaker.java @@ -10,12 +10,13 @@ */ package com.fr.design.gui.syntax.ui.rsyntaxtextarea.modes; -import java.io.*; +import com.fr.design.gui.syntax.ui.rsyntaxtextarea.AbstractJFlexTokenMaker; +import com.fr.design.gui.syntax.ui.rsyntaxtextarea.Token; +import com.fr.design.gui.syntax.ui.rsyntaxtextarea.TokenImpl; +import java.io.IOException; import java.util.Stack; import javax.swing.text.Segment; -import com.fr.design.gui.syntax.ui.rsyntaxtextarea.*; - /** * Scanner for makefiles.

@@ -762,8 +763,8 @@ public final void yybegin(int newState) { { addToken(Token.LITERAL_CHAR); } case 25: break; - case 12: - { if (!varDepths.empty() && varDepths.peek()==Boolean.TRUE) { + case 12: + { if (!varDepths.empty() && Boolean.TRUE.equals(varDepths.peek())) { varDepths.pop(); if (varDepths.empty()) { addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL); @@ -771,8 +772,8 @@ public final void yybegin(int newState) { } } case 26: break; - case 11: - { if (!varDepths.empty() && varDepths.peek()==Boolean.FALSE) { + case 11: + { if (!varDepths.empty() && Boolean.FALSE.equals(varDepths.peek())) { varDepths.pop(); if (varDepths.empty()) { addToken(start,zzStartRead, Token.VARIABLE); yybegin(YYINITIAL); @@ -864,4 +865,4 @@ public final void yybegin(int newState) { } -} \ No newline at end of file +} diff --git a/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java b/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java index 9d5e713051..3afc423be1 100644 --- a/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/BorderIcon.java @@ -1,5 +1,6 @@ package com.fr.design.icon; +import com.fr.stable.AssistUtils; import java.awt.Color; import java.awt.Component; import java.awt.Graphics; @@ -43,13 +44,13 @@ public class BorderIcon implements Icon { if (lineStyle == Constants.LINE_MEDIUM || lineStyle == Constants.LINE_THICK) { lineStyle = Constants.LINE_MEDIUM; - if (x1 == x2) { - if (x1 == y1) { + if (AssistUtils.equals(x1, x2)) { + if (AssistUtils.equals(x1, y1)) { GraphHelper.drawLine(g, x1, y1 - 1, x2, y2 + 1, lineStyle); } else { GraphHelper.drawLine(g, x1, y1, x2, y2 + 1, lineStyle); } - } else if (y1 == y2) { + } else if (AssistUtils.equals(y1, y2)) { GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle); } } else if (lineStyle == Constants.LINE_THIN @@ -57,7 +58,7 @@ public class BorderIcon implements Icon { GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle); } else { lineStyle = Constants.LINE_DOT; - if (y1 == x2 && x2 == y2) { + if (AssistUtils.equals(y1, x2) && AssistUtils.equals(x2, y2)) { GraphHelper.drawLine(g, x1, y1, x2 + 1, y2, lineStyle); } else { GraphHelper.drawLine(g, x1, y1, x2, y2, lineStyle); diff --git a/designer-base/src/main/java/com/fr/design/icon/LockIcon.java b/designer-base/src/main/java/com/fr/design/icon/LockIcon.java index ee54b6ea86..7ebffbdb79 100644 --- a/designer-base/src/main/java/com/fr/design/icon/LockIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/LockIcon.java @@ -35,7 +35,7 @@ public class LockIcon extends ImageIcon { } @Override - public void paintIcon(Component c, Graphics g, int x, int y) { + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { if (mainImage != null) { g.drawImage(mainImage, x, y, c); } diff --git a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java index d70d62225d..50b70cceca 100644 --- a/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java +++ b/designer-base/src/main/java/com/fr/design/icon/WarningIcon.java @@ -37,7 +37,7 @@ public class WarningIcon extends ImageIcon { } @Override - public void paintIcon(Component c, Graphics g, int x, int y) { + public synchronized void paintIcon(Component c, Graphics g, int x, int y) { if (mainImage != null) { g.drawImage(mainImage, x, y, c); } diff --git a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java index 38097c2d91..90a5bc9586 100644 --- a/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java +++ b/designer-base/src/main/java/com/fr/design/layout/FRGUIPaneFactory.java @@ -3,6 +3,7 @@ package com.fr.design.layout; import com.fr.design.border.UITitledBorder; import com.fr.design.gui.ilable.UILabel; +import com.fr.stable.AssistUtils; import javax.swing.BorderFactory; import javax.swing.BoxLayout; import javax.swing.Icon; @@ -562,9 +563,9 @@ public class FRGUIPaneFactory { float i = Math.abs((((int) m + (int) (m + 1)) / WIDTHABS_PARA_F) - m); float j = Math.abs((((int) n + (int) (n + 1)) / WIDTHABS_PARA_F) - n); float x = i > j ? i : j; - if (x == i) { + if (AssistUtils.equals(x, i)) { w = Math.round(m) * WIDTH_PARA_INT - WIDTH_OFFSET_M; - } else if (x == j) { + } else if (AssistUtils.equals(x, j)) { w = Math.round(n) * WIDTH_PARA_INT - WIDTH_OFFSET_N; } return w; diff --git a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java index 5cb1b79cba..961d3e23e3 100644 --- a/designer-base/src/main/java/com/fr/design/layout/TableLayout.java +++ b/designer-base/src/main/java/com/fr/design/layout/TableLayout.java @@ -1,9 +1,9 @@ package com.fr.design.layout; +import com.fr.stable.AssistUtils; import com.fr.general.GeneralUtils; import com.fr.stable.CommonUtils; - import java.awt.Component; import java.awt.ComponentOrientation; import java.awt.Container; @@ -322,7 +322,7 @@ public class TableLayout implements LayoutManager2, Serializable { this row/column. */ public static final double MINIMUM = -3.0; - + public static final double EPSILON = 0.0000001; //****************************************************************************** //** Constructors *** @@ -400,17 +400,17 @@ public class TableLayout implements LayoutManager2, Serializable { // Make sure rows and columns are valid for (int counter = 0; counter < crSpec[C].length; counter++) if ((crSpec[C][counter] < 0.0) && - (crSpec[C][counter] != FILL) && - (crSpec[C][counter] != PREFERRED) && - (crSpec[C][counter] != MINIMUM)) { + !AssistUtils.equals(crSpec[C][counter], FILL) && + !AssistUtils.equals(crSpec[C][counter], PREFERRED) && + !AssistUtils.equals(crSpec[C][counter], MINIMUM)) { crSpec[C][counter] = 0.0; } for (int counter = 0; counter < crSpec[R].length; counter++) if ((crSpec[R][counter] < 0.0) && - (crSpec[R][counter] != FILL) && - (crSpec[R][counter] != PREFERRED) && - (crSpec[R][counter] != MINIMUM)) { + !AssistUtils.equals(crSpec[R][counter], FILL) && + !AssistUtils.equals(crSpec[R][counter], PREFERRED) && + !AssistUtils.equals(crSpec[R][counter], MINIMUM)) { crSpec[R][counter] = 0.0; } @@ -557,9 +557,9 @@ public class TableLayout implements LayoutManager2, Serializable { // Make sure rows are valid for (int counter = 0; counter < crSpec[z].length; counter++) if ((crSpec[z][counter] < 0.0) && - (crSpec[z][counter] != FILL) && - (crSpec[z][counter] != PREFERRED) && - (crSpec[z][counter] != MINIMUM)) { + !AssistUtils.equals(crSpec[z][counter], FILL) && + !AssistUtils.equals(crSpec[z][counter], PREFERRED) && + !AssistUtils.equals(crSpec[z][counter], MINIMUM)) { crSpec[z][counter] = 0.0; } @@ -642,9 +642,9 @@ public class TableLayout implements LayoutManager2, Serializable { protected void setCr(int z, int i, double size) { // Make sure size is valid if ((size < 0.0) && - (size != FILL) && - (size != PREFERRED) && - (size != MINIMUM)) { + !AssistUtils.equals(size, FILL) && + !AssistUtils.equals(size, PREFERRED) && + !AssistUtils.equals(size, MINIMUM)) { size = 0.0; } @@ -1808,8 +1808,8 @@ public class TableLayout implements LayoutManager2, Serializable { for (counter = entry.cr1[z]; counter <= entry.cr2[z]; counter++) if (crSpec[z][counter] >= 1.0) scalableSize -= crSpec[z][counter]; - else if ((crSpec[z][counter] == PREFERRED) || - (crSpec[z][counter] == MINIMUM)) { + else if (Math.abs(crSpec[z][counter] - PREFERRED) < EPSILON || + Math.abs(crSpec[z][counter] - MINIMUM) < EPSILON) { scalableSize -= crPrefMin[counter]; } @@ -1825,13 +1825,13 @@ public class TableLayout implements LayoutManager2, Serializable { // Add scaled size to relativeWidth relativeSize += crSpec[z][counter]; // Cr is fill - else if ((crSpec[z][counter] == FILL) && (fillSizeRatio != 0.0)) + else if (Math.abs(crSpec[z][counter] - FILL) < EPSILON && Math.abs(fillSizeRatio - 0.0) >= EPSILON) // Add fill size to relativeWidth relativeSize += fillSizeRatio; } // Determine the total scaled size as estimated by this component - if (relativeSize == 0) + if (Math.abs(relativeSize - 0) < EPSILON) temp = 0; else temp = (int) (scalableSize / relativeSize + 0.5); @@ -1852,8 +1852,8 @@ public class TableLayout implements LayoutManager2, Serializable { if (crSpec[z][counter] >= 1.0) totalSize += (int) (crSpec[z][counter] + 0.5); // Is the current cr a preferred/minimum size - else if ((crSpec[z][counter] == PREFERRED) || - (crSpec[z][counter] == MINIMUM)) { + else if (Math.abs(crSpec[z][counter] - PREFERRED) < EPSILON|| + Math.abs(crSpec[z][counter] - MINIMUM) < EPSILON) { // Add preferred/minimum width totalSize += crPrefMin[counter]; } diff --git a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java index 0b3213ac52..4f447eaef0 100644 --- a/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java +++ b/designer-base/src/main/java/com/fr/design/mainframe/vcs/common/VcsHelper.java @@ -20,6 +20,7 @@ import com.fr.stable.project.ProjectConstants; import com.fr.workspace.WorkContext; import com.fr.workspace.server.vcs.VcsOperator; import com.fr.workspace.server.vcs.filesystem.VcsFileSystem; +import com.fr.workspace.server.vcs.git.config.GcConfig; import javax.swing.Icon; import javax.swing.border.EmptyBorder; @@ -146,6 +147,9 @@ public class VcsHelper implements JTemplateActionListener { if (needDeleteVersion(oldEntity)) { operator.deleteVersion(oldEntity.getFilename(), oldEntity.getVersion()); } + if (GcConfig.getInstance().isGcEnable()) { + operator.gc(); + } } }).start(); diff --git a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java index 40fe942d23..a7f78e1170 100644 --- a/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java +++ b/designer-base/src/main/java/com/fr/design/report/WatermarkPane.java @@ -113,8 +113,8 @@ public class WatermarkPane extends BasicPane { formulaPane = new TinyFormulaPane(); fontSizeComboBox = new UIComboBox(FRFontPane.FONT_SIZES); fontSizeComboBox.setEditable(true); - horizontalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 200); - verticalGapSpinner = new UnsignedIntUISpinner(0, Integer.MAX_VALUE, 1, 100); + horizontalGapSpinner = new UnsignedIntUISpinner(100, Integer.MAX_VALUE, 1, 200); + verticalGapSpinner = new UnsignedIntUISpinner(50, Integer.MAX_VALUE, 1, 100); horizontalGapSpinner.setPreferredSize(SPINNER_DIMENSION); verticalGapSpinner.setPreferredSize(SPINNER_DIMENSION); JPanel fontSizeTypePane = new JPanel(new BorderLayout(10,0)); diff --git a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java index 42bcfae0aa..72a199a5b2 100644 --- a/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java +++ b/designer-base/src/main/java/com/fr/design/widget/component/NumberEditorValidatePane.java @@ -9,6 +9,7 @@ import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; import com.fr.form.ui.NumberEditor; +import com.fr.stable.AssistUtils; import com.fr.stable.StringUtils; import javax.swing.BorderFactory; @@ -226,7 +227,7 @@ public class NumberEditorValidatePane extends JPanel { } allowNegativeCheckBox.setSelected(e.isAllowNegative()); - if (e.getMaxValue() == Double.MAX_VALUE) { + if (AssistUtils.equals(e.getMaxValue(),Double.MAX_VALUE)) { setMaxValueCheckBox.setSelected(false); maxValueSpinner.setValue(Double.MAX_VALUE); maxValueSpinner.setEnabled(false); @@ -236,7 +237,7 @@ public class NumberEditorValidatePane extends JPanel { maxValueSpinner.setValue(e.getMaxValue()); } - if (e.getMinValue() == -Double.MAX_VALUE) { + if (AssistUtils.equals(e.getMinValue(),-Double.MAX_VALUE)) { setMinValueCheckBox.setSelected(false); minValueSpinner.setValue(-Double.MAX_VALUE); minValueSpinner.setEnabled(false); diff --git a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java index 6692155dce..c28f70e5fd 100644 --- a/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java +++ b/designer-base/src/main/java/com/fr/design/write/submit/DBManipulationPane.java @@ -633,9 +633,6 @@ public class DBManipulationPane extends BasicBeanPane { for (int i = 0; i < len; i++) { currentColumnNames[i] = new ColumnName(colNames[i]); } - if (currentColumnNames == null) { - currentColumnNames = new ColumnName[0]; - } return currentColumnNames; } @@ -701,7 +698,7 @@ public class DBManipulationPane extends BasicBeanPane { } else { dmlConfigComboBox.setSelectedIndex(0); } - jobs = new NameSubmitJob[dmlConfig == null ? 0 : dmlConfig.getSubmitJobCount()]; + jobs = new NameSubmitJob[dmlConfig.getSubmitJobCount()]; for (int i = 0; i < jobs.length; i++) { jobs[i] = dmlConfig.getSubmitJob(i); } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java index d5d15af7c8..e3d6a52101 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartComponent.java @@ -2,21 +2,21 @@ package com.fr.design.chart.gui; import com.fr.base.ScreenResolution; import com.fr.base.chart.BaseChartCollection; +import com.fr.base.chart.BaseChartPainter; import com.fr.base.chart.chartdata.CallbackEvent; -import com.fr.chart.ChartWebPara; +import com.fr.base.chart.result.WebChartIDInfo; import com.fr.chart.base.ChartConstants; import com.fr.chart.chartattr.ChartCollection; -import com.fr.chartx.attr.ChartProvider; import com.fr.design.file.HistoryTemplateListPane; import com.fr.design.gui.chart.MiddleChartComponent; import com.fr.log.FineLoggerFactory; +import com.fr.script.Calculator; import com.fr.stable.core.PropertyChangeListener; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Graphics2D; -import java.awt.Image; import java.awt.Paint; import java.awt.RenderingHints; import java.awt.event.MouseEvent; @@ -35,7 +35,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene private static final long serialVersionUID = 744164838619052097L; private final List listeners = new ArrayList(); private ChartCollection chartCollection4Design; - private ChartProvider editingChart; private int chartWidth = -1; private int chartHeight = -1; @@ -91,11 +90,8 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene public void reset() { fireStopEditing(); - this.editingChart = null; this.chartHeight = this.chartWidth = -1; - this.editingChart = this.chartCollection4Design.getSelectedChartProvider(); - refreshChartGlyph(); repaint(); @@ -138,11 +134,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene return (this.chartCollection4Design == null) ? 0 : this.chartCollection4Design.getChartCount(); } - public ChartProvider getEditingChart() { - return editingChart; - } - - public void paintComponent(Graphics g) { // super.paintComponent(g); @@ -180,7 +171,6 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene */ private void refreshChartGlyph() { Dimension d = getBounds().getSize(); - this.editingChart = this.chartCollection4Design.getSelectedChartProvider();// kunsnat: 切换选中时 同步切换Plot this.chartWidth = d.width - ChartConstants.PREGAP4BOUNDS; this.chartHeight = d.height - ChartConstants.PREGAP4BOUNDS; } @@ -240,20 +230,20 @@ public class ChartComponent extends MiddleChartComponent implements MouseListene } private boolean needRefreshChartGlyph() { - return editingChart == null || chartWidth != this.getBounds().width || chartHeight != this.getBounds().height; + return chartWidth != this.getBounds().width || chartHeight != this.getBounds().height; } private void drawChart(Graphics2D g2d) { - if (editingChart != null) { + if (chartCollection4Design != null) { + BaseChartPainter painter = chartCollection4Design.createResultChartPainter(Calculator.createCalculator(), + WebChartIDInfo.createEmptyDesignerInfo(), chartWidth, chartHeight); int resolution = HistoryTemplateListPane.getInstance().getCurrentEditingTemplate().getJTemplateResolution(); if (resolution == 0){ resolution = ScreenResolution.getScreenResolution(); } - Image chartImage = editingChart.toImage(chartWidth, chartHeight, resolution, new ChartWebPara()); - - g2d.drawImage(chartImage, 0, 0, null); + painter.paint(g2d, chartWidth, chartHeight, resolution, null); } } diff --git a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java index 753bb47cd3..42eabf93e1 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java +++ b/designer-chart/src/main/java/com/fr/design/chart/gui/ChartWidgetOption.java @@ -37,7 +37,7 @@ public class ChartWidgetOption extends WidgetOption { Class clz = widgetClass(); try { ChartEditor widget = clz.newInstance(); - widget.setChartCollection(BaseChartGetter.createChartCollection(this.chartID)); + widget.resetChangeChartCollection(BaseChartGetter.createChartCollection(this.chartID)); return widget; } catch (InstantiationException e) { FineLoggerFactory.getLogger().error(e.getMessage(), e); diff --git a/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java b/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java index b35f40c552..6b646ce83c 100644 --- a/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java +++ b/designer-chart/src/main/java/com/fr/design/chart/report/GisMapReportDataContentPane.java @@ -182,11 +182,7 @@ public class GisMapReportDataContentPane extends FurtherBasicBeanPane= (min+max)/2) { x -= offset; x = setOffset(x, index, offset+OFFSETSTEP); diff --git a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java index 10f2ab2a3a..b2d6be16e2 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/scatter/VanChartScatterPlotPane.java @@ -33,6 +33,9 @@ public class VanChartScatterPlotPane extends AbstractVanChartTypePane { } } Plot cloned = null; + if (null == newPlot) { + return cloned; + } try { cloned = (Plot)newPlot.clone(); } catch (CloneNotSupportedException e) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java index 82c09e515b..1674c850c7 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/structure/desinger/type/VanChartStructureTypePane.java @@ -32,6 +32,9 @@ public class VanChartStructureTypePane extends AbstractVanChartTypePane { } Plot cloned = null; + if (null == newPlot) { + return cloned; + } try { cloned = (Plot)newPlot.clone(); } catch (CloneNotSupportedException e) { diff --git a/designer-chart/src/main/java/com/fr/van/chart/treemap/VanChartTreeMapPlotPane.java b/designer-chart/src/main/java/com/fr/van/chart/treemap/VanChartTreeMapPlotPane.java index f3de2350a4..73a59d0571 100644 --- a/designer-chart/src/main/java/com/fr/van/chart/treemap/VanChartTreeMapPlotPane.java +++ b/designer-chart/src/main/java/com/fr/van/chart/treemap/VanChartTreeMapPlotPane.java @@ -37,6 +37,9 @@ public class VanChartTreeMapPlotPane extends VanChartMultiPiePlotPane { } Plot cloned = null; + if (null == newPlot) { + return cloned; + } try { cloned = (Plot)newPlot.clone(); } catch (CloneNotSupportedException e) { diff --git a/designer-form/src/main/java/com/fr/design/designer/beans/AdapterBus.java b/designer-form/src/main/java/com/fr/design/designer/beans/AdapterBus.java index 0133c7a9e2..a34d2afa1d 100644 --- a/designer-form/src/main/java/com/fr/design/designer/beans/AdapterBus.java +++ b/designer-form/src/main/java/com/fr/design/designer/beans/AdapterBus.java @@ -41,6 +41,9 @@ public class AdapterBus { */ public static ComponentAdapter getComponentAdapter(FormDesigner designer, JComponent creator) { JComponent jcomponent = getJComponent(creator); + if (null == jcomponent) { + return null; + } ComponentAdapter adapter = (ComponentAdapter) jcomponent.getClientProperty("component.adapter"); if (adapter == null) { adapter = new CompositeComponentAdapter(designer, creator); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java index 14a5e3c969..ecf6234776 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XChartEditor.java @@ -176,16 +176,21 @@ public class XChartEditor extends XBorderStyleWidgetCreator { * @return 控件. */ public JComponent createToolPane(final BaseJForm jform, final FormDesigner formDesigner) { - getDesignerEditorTarget().addStopEditingListener(new PropertyChangeAdapter() { - public void propertyChange() { - JComponent pane = jform.getEditingPane(); - if (pane instanceof BaseChartPropertyPane) { - ((BaseChartPropertyPane) pane).setSupportCellData(true); - ((BaseChartPropertyPane) pane).populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner); + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + middleChartComponent.addStopEditingListener(new PropertyChangeAdapter() { + public void propertyChange() { + JComponent pane = jform.getEditingPane(); + if (pane instanceof BaseChartPropertyPane) { + ((BaseChartPropertyPane) pane).setSupportCellData(true); + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + ((BaseChartPropertyPane) pane).populateChartPropertyPane(middleChartComponent.update(), formDesigner); + } + } } - } - }); - + }); + } if (isEditing){ final BaseChartPropertyPane propertyPane = DesignModuleFactory.getChartPropertyPane(); SwingUtilities.invokeLater(new Runnable() { @@ -193,7 +198,10 @@ public class XChartEditor extends XBorderStyleWidgetCreator { public void run() { if (getDesignerEditor().getEditorTarget() != null) { propertyPane.setSupportCellData(true); - propertyPane.populateChartPropertyPane(getDesignerEditorTarget().update(), formDesigner); + MiddleChartComponent middleChartComponent = getDesignerEditorTarget(); + if (null != middleChartComponent) { + propertyPane.populateChartPropertyPane(middleChartComponent.update(), formDesigner); + } } } }); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java index b219530f7f..56fcf64866 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWAbsoluteLayout.java @@ -31,6 +31,7 @@ import com.fr.general.FRScreen; import com.fr.general.IOUtils; import com.fr.share.ShareConstants; +import com.fr.stable.AssistUtils; import com.fr.stable.Constants; import javax.swing.Icon; @@ -108,7 +109,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); double screenValue = FRScreen.getByDimension(scrnsize).getValue(); - if (screenValue != FormArea.DEFAULT_SLIDER) { + if (!AssistUtils.equals(screenValue, FormArea.DEFAULT_SLIDER)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } } @@ -167,7 +168,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { * 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 */ private Rectangle dealWidgetBound(Rectangle rec) { - if (containerPercent == 1.0) { + if (AssistUtils.equals(1.0, containerPercent)) { return rec; } rec.x = (int) (rec.x / containerPercent); @@ -244,7 +245,7 @@ public class XWAbsoluteLayout extends XLayoutContainer { @Override public void updateChildBound(int minHeight) { double prevContainerPercent = FRScreen.getByDimension(toData().getDesigningResolution()).getValue() / FormArea.DEFAULT_SLIDER; - if (toData().getCompState() == 0 && prevContainerPercent != containerPercent) { + if (toData().getCompState() == 0 && !AssistUtils.equals(containerPercent, prevContainerPercent)) { for (int i = 0; i < this.getComponentCount(); i++) { XCreator creator = getXCreator(i); Rectangle rec = new Rectangle(creator.getBounds()); diff --git a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java index 8d3d75a358..714bd0a2ea 100644 --- a/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java +++ b/designer-form/src/main/java/com/fr/design/designer/creator/XWFitLayout.java @@ -21,6 +21,7 @@ import com.fr.form.ui.container.WLayout; import com.fr.general.FRLogger; import com.fr.general.FRScreen; import com.fr.stable.ArrayUtils; +import com.fr.stable.AssistUtils; import edu.emory.mathcs.backport.java.util.Arrays; import javax.swing.JOptionPane; @@ -72,7 +73,7 @@ public class XWFitLayout extends XLayoutContainer { Toolkit toolkit = Toolkit.getDefaultToolkit(); Dimension scrnsize = toolkit.getScreenSize(); double screenValue = FRScreen.getByDimension(scrnsize).getValue(); - if(screenValue != FormArea.DEFAULT_SLIDER){ + if (!AssistUtils.equals(FormArea.DEFAULT_SLIDER, screenValue)) { this.setContainerPercent(screenValue / FormArea.DEFAULT_SLIDER); } } @@ -717,7 +718,7 @@ public class XWFitLayout extends XLayoutContainer { * 界面容器大小不是默认的时,处理控件的BoundsWidget,且避免出现空隙 */ private Rectangle dealWidgetBound(Rectangle rec) { - if (containerPercent == 1.0) { + if (AssistUtils.equals(1.0, containerPercent)) { return rec; } rec.x = (int) (rec.x/containerPercent); @@ -731,7 +732,7 @@ public class XWFitLayout extends XLayoutContainer { * 界面容器大小不是默认的时,恢复组件实际大小 */ private Rectangle dealWgtBound(Rectangle rec) { - if (containerPercent == 1.0) { + if (AssistUtils.equals(1.0, containerPercent)) { return rec; } rec.x = (int) (rec.x * containerPercent); diff --git a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java index 44f1fe8749..a0245a3d86 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridRowUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridRowUI.java @@ -7,7 +7,7 @@ import java.awt.geom.Rectangle2D; import javax.swing.JComponent; import javax.swing.UIManager; import javax.swing.plaf.ComponentUI; - +import com.fr.stable.AssistUtils; import com.fr.base.BaseUtils; import com.fr.base.DynamicUnitList; import com.fr.base.GraphHelper; @@ -106,7 +106,7 @@ public class GridRowUI extends ComponentUI { tmpHeight1 += tmpIncreaseHeight; tmpIncreaseHeight = rowHeightList.get(i).toPixD(resolution); // check these row wich height is zero. - tmpHeight2 = tmpIncreaseHeight == 0 ? tmpHeight1 + 1 : tmpHeight1 + tmpIncreaseHeight; + tmpHeight2 = AssistUtils.equals(tmpIncreaseHeight,0d) ? tmpHeight1 + 1 : tmpHeight1 + tmpIncreaseHeight; // check selection bound. Selection sel = reportPane.getSelection(); int[] selectedRows = sel.getSelectedRows(); diff --git a/designer-realize/src/main/java/com/fr/grid/GridUI.java b/designer-realize/src/main/java/com/fr/grid/GridUI.java index c7ea413687..0ccff309f6 100644 --- a/designer-realize/src/main/java/com/fr/grid/GridUI.java +++ b/designer-realize/src/main/java/com/fr/grid/GridUI.java @@ -47,6 +47,7 @@ import com.fr.stable.ColumnRow; import com.fr.stable.Constants; import com.fr.stable.script.CalculatorUtils; import com.fr.stable.unit.FU; +import com.fr.stable.AssistUtils; import com.fr.third.antlr.ANTLRException; import javax.swing.JComponent; @@ -617,10 +618,10 @@ public class GridUI extends ComponentUI { tmpLine2D = (Line2D) paginateLineList.get(j);// 直接强制转换,因为List中肯定都是Line2D型的 for (int k = j + 1; k < paginateLineList.size(); k++) { tmpLine2D2 = (Line2D) paginateLineList.get(k); - if (tmpLine2D2.getX1() == tmpLine2D.getX1() - && tmpLine2D2.getX2() == tmpLine2D.getX2() - && tmpLine2D2.getY1() == tmpLine2D.getY1() - && tmpLine2D2.getY2() == tmpLine2D.getY2()) { + if (AssistUtils.equals(tmpLine2D2.getX1() ,tmpLine2D.getX1()) + && AssistUtils.equals(tmpLine2D2.getX2() , tmpLine2D.getX2()) + && AssistUtils.equals(tmpLine2D2.getY1() , tmpLine2D.getY1()) + && AssistUtils.equals(tmpLine2D2.getY2() , tmpLine2D.getY2())) { paginateLineList.remove(k); } } diff --git a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java index 2bf55e5a07..d12920bfdc 100644 --- a/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java +++ b/designer-realize/src/main/java/com/fr/poly/PolyDesignUI.java @@ -47,7 +47,7 @@ import java.util.ArrayList; */ public class PolyDesignUI extends ComponentUI { private static final Color PAGINATE_LINE_COLOR = Color.GRAY; - + private static final double SCROLL_POINT = 50; private static final int SCROLL_DISTANCE = 15; private static final int TEN = 10; @@ -65,11 +65,11 @@ public class PolyDesignUI extends ComponentUI { /** * 从组件中获取设计器, 并赋值 - * + * * @param c 组件对象 - * + * * @date 2015-2-12-下午2:38:05 - * + * */ public void installUI(JComponent c) { designer = ((PolyArea) c).getPolyDesigner(); @@ -137,7 +137,7 @@ public class PolyDesignUI extends ComponentUI { } } } - + private void changeForbiddenWindowVisibility(BlockCreator creator){ Rectangle pixRec = creator.getBounds(); boolean intersected = designer.intersectsAllBlock(creator); @@ -145,12 +145,12 @@ public class PolyDesignUI extends ComponentUI { creator.getEditor().hideForbiddenWindow(); return; } - + int x = (int) (designer.getAreaLocationX() + pixRec.getCenterX()*time - designer.getHorizontalValue()); int y = (int) (designer.getAreaLocationY() + pixRec.getCenterY()*time - designer.getVerticalValue()); creator.getEditor().showForbiddenWindow(x, y); } - + private Rectangle getCreatorPixRectangle(BlockCreator creator, Point location){ int width = creator.getWidth(); int height = creator.getHeight(); @@ -158,21 +158,22 @@ public class PolyDesignUI extends ComponentUI { int resy = location.y - height / 2 + designer.getVerticalValue(); return new Rectangle(resx, resy, width, height); } - + + @SuppressWarnings("squid:S2142") private void scrollWhenCreatorAtCorner(final BlockCreator creator){ Thread scrollThread = new Thread(new Runnable() { - + @Override public void run() { try { Thread.sleep(100); - + int rightCornerX = creator.getX() + creator.getWidth(); int rightCornerY = creator.getY() + creator.getHeight(); JScrollBar horizonBar = designer.getHorizontalScrollBar(); JScrollBar verticalBar = designer.getVerticalScrollBar(); - + int scrollX = designer.getWidth() + horizonBar.getValue(); int scrollY = designer.getHeight() + verticalBar.getValue(); @@ -180,7 +181,7 @@ public class PolyDesignUI extends ComponentUI { if(rightCornerX > scrollX - SCROLL_POINT){ horizonBar.setValue(horizonBar.getValue() + SCROLL_DISTANCE); } - + if(rightCornerY > scrollY - SCROLL_POINT){ verticalBar.setValue(verticalBar.getValue() + SCROLL_DISTANCE); } @@ -200,7 +201,7 @@ public class PolyDesignUI extends ComponentUI { GraphHelper.drawString(g, convertUnit(y), 0, resy); GraphHelper.drawString(g, convertUnit(x), resx, 10); } - + private String convertUnit(int i) { short unit = designer.getRulerLengthUnit(); // int resolution = ScreenResolution.getScreenResolution(); diff --git a/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java b/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java index 1d11a783d6..5b581f8f15 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/BlockCreator.java @@ -54,6 +54,9 @@ public abstract class BlockCreator extends JComponent i @Override public boolean equals(Object o) { + if (o == null) { + return false; + } return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); } }); @@ -81,7 +84,7 @@ public abstract class BlockCreator extends JComponent i //默认大小, 报表块默认3列6行, 图表块默认330*240 public abstract UnitRectangle getDefaultBlockBounds(); - + // 不同的Block有不同的显示器 protected abstract JComponent initMonitor(); @@ -97,9 +100,9 @@ public abstract class BlockCreator extends JComponent i /** * 检测按钮状态 - * + * * @date 2015-2-5-上午11:33:46 - * + * */ public abstract void checkButtonEnable(); @@ -134,31 +137,31 @@ public abstract class BlockCreator extends JComponent i /** * 获取当前工具栏组 - * + * * @return 工具栏组 - * + * * @date 2015-2-5-上午11:29:07 - * + * */ public abstract ToolBarDef[] toolbars4Target(); /** * 在Form的工具栏组 - * + * * @return 组件数组 - * + * * @date 2015-2-5-上午11:31:46 - * + * */ public abstract JComponent[] toolBarButton4Form(); - + /** * 获取当前菜单栏组 - * + * * @return 菜单栏组 - * + * * @date 2015-2-5-上午11:29:07 - * + * */ public abstract MenuDef[] menus4Target(); @@ -167,12 +170,12 @@ public abstract class BlockCreator extends JComponent i /** * 获取菜单里的快捷方式数组 - * + * * @return 菜单里的快捷方式数组 - * + * * @date 2015-2-5-上午11:27:08 - * + * */ public abstract ShortCut[] shortcut4TemplateMenu(); -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java b/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java index 6860841779..cac1a0e226 100644 --- a/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java +++ b/designer-realize/src/main/java/com/fr/poly/creator/BlockEditor.java @@ -30,20 +30,20 @@ import com.fr.stable.unit.UnitRectangle; * @since 6.5.4 创建于2011-5-5 聚合报表块编辑器 */ public abstract class BlockEditor extends JComponent{ - + protected PolyDesigner designer; protected BlockCreator creator; protected int resolution = ScreenResolution.getScreenResolution(); protected T editComponent; - + private JComponent addHeightTool;// 改变高度的组件 private JComponent addWidthTool; // 改变宽度的组件 private JComponent moveTool; // 拖动聚合块的组件 - + private boolean isDragging; private Absorptionline lineInX; private Absorptionline lineInY; - + private BlockForbiddenWindow forbiddenWindow; public BlockEditor(PolyDesigner designer, BlockCreator creator) { @@ -74,16 +74,16 @@ public abstract class BlockEditor this.moveTool = new BlockControlButton(); this.add(BlockEditorLayout.BOTTOMCORNER, this.moveTool); - + this.forbiddenWindow = new BlockForbiddenWindow(); } - + /** * 重置当前鼠标选中状态 - * + * */ public abstract void resetSelectionAndChooseState(); - + protected abstract T createEffective(); protected abstract Dimension getAddHeigthPreferredSize(); @@ -91,9 +91,9 @@ public abstract class BlockEditor protected abstract Dimension getAddWidthPreferredSize(); protected abstract void initDataChangeListener(); - + protected abstract RowOperationMouseHandler createRowOperationMouseHandler(); - + protected abstract ColumnOperationMouseHandler createColumnOperationMouseHandler(); protected void addColumnRowListeners() { @@ -122,28 +122,31 @@ public abstract class BlockEditor initSize(); LayoutUtils.layoutRootContainer(BlockEditor.this); } - + @Override public boolean equals(Object o) { + if (o == null) { + return false; + } return ComparatorUtils.equals(o.getClass().getName(), this.getClass().getName()); } }); } - + public void setDragging(boolean isDragging) { this.isDragging = isDragging; } - + /** * 当前是否处于拖动状态 - * + * * @return 是否处于拖动状态 - * + * */ public boolean isDragging() { return this.isDragging; } - + public void setXAbsorptionline(Absorptionline line) { this.lineInX = line; } @@ -151,27 +154,27 @@ public abstract class BlockEditor public void setYAbsorptionline(Absorptionline line) { this.lineInY = line; } - - + + /** * 显示禁止重叠窗口 - * + * * @param x x坐标 * @param y y坐标 - * + * */ public void showForbiddenWindow(int x, int y){ this.forbiddenWindow.showWindow(x, y); } - + /** * 隐藏禁止重叠窗口 - * + * */ public void hideForbiddenWindow(){ this.forbiddenWindow.hideWindow(); } - + public void paintAbsorptionline(Graphics g) { if(lineInX != null) { lineInX.paint(g,designer); @@ -202,7 +205,7 @@ public abstract class BlockEditor public Dimension getCornerSize() { return new Dimension(); } - + private class BlockControlButton extends UIButton { @Override public ButtonUI getUI() { @@ -220,4 +223,4 @@ public abstract class BlockEditor }; } } -} \ No newline at end of file +} diff --git a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java index 470b382c93..e262e917e9 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java +++ b/designer-realize/src/main/java/com/fr/start/fx/PrismImageLoader2.java @@ -1,6 +1,7 @@ package com.fr.start.fx; import com.fr.concurrent.NamedThreadFactory; +import com.fr.log.FineLoggerFactory; import com.sun.javafx.iio.ImageFrame; import com.sun.javafx.iio.ImageLoadListener; import com.sun.javafx.iio.ImageLoader; @@ -79,6 +80,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { } @Override + @SuppressWarnings("squid:S2142") public PlatformImage getFrame(int index) { while (images[index] == null) { synchronized (this) { @@ -86,7 +88,7 @@ class PrismImageLoader2 implements com.sun.javafx.tk.ImageLoader { try { this.wait(); } catch (InterruptedException e) { - e.printStackTrace(); + FineLoggerFactory.getLogger().error(e.getMessage(), e); } } } diff --git a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java index 073cee7ae4..00ad512939 100644 --- a/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java +++ b/designer-realize/src/main/java/com/fr/start/fx/SplashFxWindow.java @@ -55,6 +55,7 @@ public class SplashFxWindow extends Application { * * @return 运行实例 */ + @SuppressWarnings("squid:S2142") public static SplashFxWindow waitForStartUpTest() { try { LATCH.await();