Browse Source

无JIRA任务,代码规范

master
plough 7 years ago
parent
commit
017941a4ab
  1. 9
      designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java
  2. 14
      designer_base/src/com/fr/design/web/CustomIconPane.java

9
designer_base/src/com/fr/design/gui/icontainer/UIScrollPane.java

@ -13,12 +13,13 @@ import java.awt.*;
public class UIScrollPane extends JScrollPane { public class UIScrollPane extends JScrollPane {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
private static final int INCREAMENT = 30;
public UIScrollPane(Component c) { public UIScrollPane(Component c) {
super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); super(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
this.setHorizontalScrollBar(createHorizontalScrollBar()); this.setHorizontalScrollBar(createHorizontalScrollBar());
this.getVerticalScrollBar().setUnitIncrement(30); this.getVerticalScrollBar().setUnitIncrement(INCREAMENT);
this.getVerticalScrollBar().setBlockIncrement(30); this.getVerticalScrollBar().setBlockIncrement(INCREAMENT);
this.getHorizontalScrollBar().setOpaque(true); this.getHorizontalScrollBar().setOpaque(true);
this.getHorizontalScrollBar().setBackground(Color.WHITE); this.getHorizontalScrollBar().setBackground(Color.WHITE);
this.getVerticalScrollBar().setOpaque(true); this.getVerticalScrollBar().setOpaque(true);
@ -29,7 +30,7 @@ public class UIScrollPane extends JScrollPane {
/** /**
* 生成水平滚动条 * 生成水平滚动条
*/ */
public JScrollBar createHorizontalScrollBar() { public UIScrollBar createHorizontalScrollBar() {
UIScrollBar sbr = new UIScrollBar(JScrollBar.HORIZONTAL); UIScrollBar sbr = new UIScrollBar(JScrollBar.HORIZONTAL);
sbr.setBackground(UIConstants.NORMAL_BACKGROUND); sbr.setBackground(UIConstants.NORMAL_BACKGROUND);
return sbr; return sbr;
@ -39,7 +40,7 @@ public class UIScrollPane extends JScrollPane {
/** /**
* 生成垂直滚动条 * 生成垂直滚动条
*/ */
public JScrollBar createVerticalScrollBar() { public UIScrollBar createVerticalScrollBar() {
UIScrollBar sbr = new UIScrollBar(JScrollBar.VERTICAL); UIScrollBar sbr = new UIScrollBar(JScrollBar.VERTICAL);
sbr.setBackground(UIConstants.NORMAL_BACKGROUND); sbr.setBackground(UIConstants.NORMAL_BACKGROUND);
return sbr; return sbr;

14
designer_base/src/com/fr/design/web/CustomIconPane.java

@ -9,6 +9,7 @@ import com.fr.design.dialog.DialogActionAdapter;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icontainer.UIScrollPane; import com.fr.design.gui.icontainer.UIScrollPane;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.iscrollbar.UIScrollBar;
import com.fr.design.gui.itextarea.DescriptionTextArea; import com.fr.design.gui.itextarea.DescriptionTextArea;
import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itextfield.UITextField;
import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.FRGUIPaneFactory;
@ -133,7 +134,7 @@ public class CustomIconPane extends BasicPane {
if (iconManager.addIcon(icon, false)) { if (iconManager.addIcon(icon, false)) {
IconButton iconButton = null;//初始化 IconButton iconButton = null;//初始化
addIcon(icon,iconButton); addIcon(icon, iconButton);
}else { }else {
// add failed // add failed
@ -209,7 +210,7 @@ public class CustomIconPane extends BasicPane {
iconPane.remove(iconButton); iconPane.remove(iconButton);
bg.remove(iconButton); bg.remove(iconButton);
addIcon(icon,iconButton); addIcon(icon, iconButton);
} else { } else {
// 失败了再弄回去 // 失败了再弄回去
@ -270,7 +271,7 @@ public class CustomIconPane extends BasicPane {
// 不知道怎么动态布局,就这么傻傻的调一下大小 // 不知道怎么动态布局,就这么傻傻的调一下大小
private void refreshIconPane(boolean down) { private void refreshIconPane(boolean down) {
iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP)); iconPane.setPreferredSize(new Dimension(THE_WIDTH, (iconButtonMap.size() / HORIZONTAL_COUNT + 1) * HEIGHT_PER + GAP));
JScrollBar jsBar = jsPane.createVerticalScrollBar(); UIScrollBar jsBar = jsPane.createVerticalScrollBar();
try { try {
if (down) { if (down) {
// 将滚动条滚到最后 // 将滚动条滚到最后
@ -287,6 +288,8 @@ public class CustomIconPane extends BasicPane {
private String iconName; private String iconName;
private Image iconImage = null; private Image iconImage = null;
private static final int ICON_BUTTON_SIZE = 24; private static final int ICON_BUTTON_SIZE = 24;
private static final int ICON_X = 4;
private static final int ICON_Y = 4;
public IconButton(String name) { public IconButton(String name) {
this.iconName = name; this.iconName = name;
this.addActionListener(this); this.addActionListener(this);
@ -311,7 +314,7 @@ public class CustomIconPane extends BasicPane {
Graphics2D g2d = (Graphics2D) g; Graphics2D g2d = (Graphics2D) g;
// carl:这里缩放显示 16 × 16 // carl:这里缩放显示 16 × 16
if (iconImage != null) { if (iconImage != null) {
g2d.drawImage(iconImage, 4, 4, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null); g2d.drawImage(iconImage, ICON_X, ICON_Y, IconManager.DEFAULT_ICONWIDTH, IconManager.DEFAULT_ICONHEIGHT, null);
} }
if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) { if (this.iconName != null && ComparatorUtils.equals(this.iconName, selectedIconName)) {
g2d.setPaint(Color.RED); g2d.setPaint(Color.RED);
@ -378,6 +381,7 @@ public class CustomIconPane extends BasicPane {
// 焦点丢失时看看名称是否已经存在 // 焦点丢失时看看名称是否已经存在
nameTextField.addFocusListener(new FocusListener() { nameTextField.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent e) { public void focusGained(FocusEvent e) {
// do nothing
} }
public void focusLost(FocusEvent e) { public void focusLost(FocusEvent e) {
if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) { if (oldName != null && ComparatorUtils.equals(oldName, nameTextField.getText())) {
@ -401,7 +405,7 @@ public class CustomIconPane extends BasicPane {
Component[][] components = {{new UILabel(Inter.getLocText("FR-Designer_Name") + ":"), nameTextField}, {new UILabel(Inter.getLocText("FR-Designer_Icon") + ":"), imagePane}}; Component[][] components = {{new UILabel(Inter.getLocText("FR-Designer_Name") + ":"), nameTextField}, {new UILabel(Inter.getLocText("FR-Designer_Icon") + ":"), imagePane}};
JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize); JPanel centerPane = TableLayoutHelper.createTableLayoutPane(components, rowSize, columnSize);
this.add(centerPane,BorderLayout.CENTER); this.add(centerPane, BorderLayout.CENTER);
} }
private void onBrowseButtonClicked() { private void onBrowseButtonClicked() {

Loading…
Cancel
Save