From 76434782badb619bd60c30501f5e2d013173b92e Mon Sep 17 00:00:00 2001 From: hzzz Date: Thu, 25 May 2017 14:53:59 +0800 Subject: [PATCH] PMD --- .../autocomplete/AutoCompletePopupWindow.java | 9 ++-- .../gui/itabpane/UITabsHeaderIconPane.java | 44 ++++++------------- .../widget/editors/DataTableConfigPane.java | 8 ++-- 3 files changed, 24 insertions(+), 37 deletions(-) diff --git a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java index ec303ee44..22bb4edf7 100644 --- a/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java +++ b/designer_base/src/com/fr/design/gui/autocomplete/AutoCompletePopupWindow.java @@ -41,6 +41,7 @@ import java.util.List; class AutoCompletePopupWindow extends JWindow implements CaretListener, ListSelectionListener, MouseListener { + private final static int DIS = 5; /** * The parent AutoCompletion instance. */ @@ -388,14 +389,14 @@ class AutoCompletePopupWindow extends JWindow implements CaretListener, // Try to position to the right first (LTR) int x; if (ac.getTextComponentOrientation().isLeftToRight()) { - x = getX() + getWidth() + 5; + x = getX() + getWidth() + DIS; if (x + descWindow.getWidth() > screenBounds.x + screenBounds.width) { // doesn't fit - x = getX() - 5 - descWindow.getWidth(); + x = getX() - DIS - descWindow.getWidth(); } } else { // RTL - x = getX() - 5 - descWindow.getWidth(); + x = getX() - DIS - descWindow.getWidth(); if (x < screenBounds.x) { // Doesn't fit - x = getX() + getWidth() + 5; + x = getX() + getWidth() + DIS; } } diff --git a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java index 8bb2f7b05..84f0cd35f 100644 --- a/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java +++ b/designer_base/src/com/fr/design/gui/itabpane/UITabsHeaderIconPane.java @@ -1,38 +1,22 @@ package com.fr.design.gui.itabpane; -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.GradientPaint; -import java.awt.Graphics2D; -import java.awt.GridLayout; +import com.fr.base.BaseUtils; +import com.fr.design.constants.UIConstants; +import com.fr.design.gui.core.UITabComponent; +import com.fr.design.gui.ibutton.UITabButton; +import com.fr.design.gui.ilable.UILabel; +import com.fr.stable.StringUtils; + +import javax.swing.*; +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; +import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.KeyEvent; import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import javax.swing.AbstractAction; -import javax.swing.ActionMap; -import javax.swing.BorderFactory; -import javax.swing.Icon; -import javax.swing.InputMap; -import javax.swing.JComponent; - -import com.fr.design.constants.UIConstants; -import com.fr.design.gui.ilable.UILabel; -import javax.swing.JPanel; -import javax.swing.KeyStroke; -import javax.swing.SwingConstants; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import com.fr.base.BaseUtils; -import com.fr.design.gui.core.UITabComponent; -import com.fr.design.gui.ibutton.UITabButton; -import com.fr.stable.StringUtils; - import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; /** @@ -43,6 +27,7 @@ import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_M */ public class UITabsHeaderIconPane extends JPanel implements UITabComponent { private static final long serialVersionUID = 1L; + private static final int DIS = 30; private UILabel nameLabel; @@ -160,11 +145,11 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent { int height = centerPane.getHeight(); int width = centerPane.getWidth(); int y = -height; - for (int i = 0; i <= height; i += 30) { + for (int i = 0; i <= height; i += DIS) { // 设置面板位置 currentPanel.setBounds(0, i, width, height); panel.setBounds(0, y, width, height); - y += 30; + y += DIS; try { Thread.sleep(3); } catch (InterruptedException e) { @@ -174,7 +159,6 @@ public class UITabsHeaderIconPane extends JPanel implements UITabComponent { centerPane.remove(currentPanel);// 移除当前面板 } panel.setBounds(0, 0, width, height); - } }.start(); break; diff --git a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java index a45d9fa25..00d70bd1e 100644 --- a/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java +++ b/designer_form/src/com/fr/design/mainframe/widget/editors/DataTableConfigPane.java @@ -157,6 +157,8 @@ public class DataTableConfigPane extends JComponent implements PropertyChangeLis } class MouseAdapterListener extends MouseAdapter { + private final static int DIS = 30; + private final static int SMALL_DIS = 3; private JTable table; int oldY = 0; int newY = 0; @@ -205,7 +207,7 @@ public class DataTableConfigPane extends JComponent implements PropertyChangeLis height = height + table.getRowHeight(i); } - if (height - e.getY() < 3) { + if (height - e.getY() < SMALL_DIS) { drag = true; table.setCursor(new Cursor(Cursor.N_RESIZE_CURSOR)); } else { @@ -223,8 +225,8 @@ public class DataTableConfigPane extends JComponent implements PropertyChangeLis public void mouseDragged(MouseEvent e) { if (drag) { int value = oldHeight + e.getY() - oldY; - if (value < 30) { - table.setRowHeight(row, 30); + if (value < DIS) { + table.setRowHeight(row, DIS); } else { table.setRowHeight(row, oldHeight + e.getY() - oldY); }