Browse Source

Pull request #5480: REPORT-57643 调整combobox的大小(feature没有合并到realease,手动合并一波)

Merge in DESIGN/design from ~XIQIU/design:release/10.0 to release/10.0

* commit '912084ccfb0cbb32270b88277ba121429f4f7ed5':
  REPORT-57643  调整combobox的大小(feature没有合并到realease,手动合并一波)
zheng-1641779399395
Xiqiu 3 years ago
parent
commit
71e424f565
  1. 26
      designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java
  2. 34
      designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java
  3. 13
      designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java

26
designer-base/src/main/java/com/fr/design/data/datapane/connect/JDBCDefPane.java

@ -7,6 +7,7 @@ import com.fr.data.impl.JDBCDatabaseConnection;
import com.fr.design.border.UITitledBorder; import com.fr.design.border.UITitledBorder;
import com.fr.design.gui.ibutton.UIButton; import com.fr.design.gui.ibutton.UIButton;
import com.fr.design.gui.icombobox.UIComboBox; import com.fr.design.gui.icombobox.UIComboBox;
import com.fr.design.gui.icombobox.UIComboBoxUI;
import com.fr.design.gui.ilable.ActionLabel; import com.fr.design.gui.ilable.ActionLabel;
import com.fr.design.gui.ilable.UILabel; import com.fr.design.gui.ilable.UILabel;
import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength; import com.fr.design.gui.ipasswordfield.UIPasswordFieldWithFixedLength;
@ -32,6 +33,8 @@ import javax.swing.JPanel;
import javax.swing.JPasswordField; import javax.swing.JPasswordField;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener; import javax.swing.event.DocumentListener;
import javax.swing.plaf.ComboBoxUI;
import javax.swing.plaf.basic.ComboPopup;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component; import java.awt.Component;
@ -275,8 +278,9 @@ public class JDBCDefPane extends JPanel {
} }
dbtypeComboBox.addActionListener(dbtypeActionListener); dbtypeComboBox.addActionListener(dbtypeActionListener);
dbtypeComboBox.setMaximumRowCount(10); dbtypeComboBox.setMaximumRowCount(10);
driverLoaderBox = new UIComboBox(); driverLoaderBox = new SpecialUIComboBox();
refreshDriverLoader(); refreshDriverLoader();
driverLoaderBox.setPreferredSize(new Dimension(200, driverLoaderBox.getPreferredSize().height));
driverLoaderBox.setEditable(false); driverLoaderBox.setEditable(false);
driverManageBox = new UIComboBox(); driverManageBox = new UIComboBox();
refreshDriverManage(true); refreshDriverManage(true);
@ -350,7 +354,7 @@ public class JDBCDefPane extends JPanel {
odbcTipsPane.add(driverManageLabel); odbcTipsPane.add(driverManageLabel);
odbcTipsPane.add(odbcTipsLink); odbcTipsPane.add(odbcTipsLink);
JPanel driverComboBoxAndTips = new JPanel(new BorderLayout()); JPanel driverComboBoxAndTips = new JPanel(new BorderLayout());
JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createNormalFlowInnerContainer_S_Pane(); JPanel normalFlowInnerContainer_s_pane = FRGUIPaneFactory.createBoxFlowInnerContainer_S_Pane(0, 5, 0);
normalFlowInnerContainer_s_pane.add(driverManageBox); normalFlowInnerContainer_s_pane.add(driverManageBox);
normalFlowInnerContainer_s_pane.add(driverComboBox); normalFlowInnerContainer_s_pane.add(driverComboBox);
normalFlowInnerContainer_s_pane.add(driverLoaderBox); normalFlowInnerContainer_s_pane.add(driverLoaderBox);
@ -717,4 +721,22 @@ public class JDBCDefPane extends JPanel {
private String driver; private String driver;
private String url; private String url;
} }
private static class SpecialUIComboBox extends UIComboBox {
@Override
public ComboBoxUI getUIComboBoxUI() {
return new SpecialUIComboBoxUI();
}
}
private static class SpecialUIComboBoxUI extends UIComboBoxUI {
@Override
public ComboPopup createPopup() {
return createHorizontalNeverUIComboPopUp();
}
}
} }

34
designer-base/src/main/java/com/fr/design/gui/icombobox/UIComboBoxUI.java

@ -10,12 +10,26 @@ import com.fr.stable.Constants;
import com.fr.stable.StringUtils; import com.fr.stable.StringUtils;
import sun.swing.DefaultLookup; import sun.swing.DefaultLookup;
import javax.swing.*; import javax.swing.AbstractButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.ListCellRenderer;
import javax.swing.ScrollPaneConstants;
import javax.swing.UIManager;
import javax.swing.plaf.ButtonUI; import javax.swing.plaf.ButtonUI;
import javax.swing.plaf.basic.BasicComboBoxUI; import javax.swing.plaf.basic.BasicComboBoxUI;
import javax.swing.plaf.basic.BasicComboPopup; import javax.swing.plaf.basic.BasicComboPopup;
import javax.swing.plaf.basic.ComboPopup; import javax.swing.plaf.basic.ComboPopup;
import java.awt.*; import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent; import java.awt.event.MouseEvent;
import java.awt.event.MouseListener; import java.awt.event.MouseListener;
@ -159,6 +173,10 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener {
return new UIComboPopup(comboBox); return new UIComboPopup(comboBox);
} }
protected ComboPopup createHorizontalNeverUIComboPopUp() {
return new HorizontalNeverUIComboPopup(comboBox);
}
private void setRollover(boolean isRollover) { private void setRollover(boolean isRollover) {
if (this.isRollover != isRollover) { if (this.isRollover != isRollover) {
this.isRollover = isRollover; this.isRollover = isRollover;
@ -270,4 +288,16 @@ public class UIComboBoxUI extends BasicComboBoxUI implements MouseListener {
} }
} }
private class HorizontalNeverUIComboPopup extends UIComboPopup {
public HorizontalNeverUIComboPopup(JComboBox comboBox) {
super(comboBox);
}
@Override
protected JScrollPane createScroller() {
return new UIScrollPane(list, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}
}
} }

13
designer-base/src/main/java/com/fr/design/gui/icontainer/UIScrollPane.java

@ -3,8 +3,11 @@ package com.fr.design.gui.icontainer;
import com.fr.design.constants.UIConstants; import com.fr.design.constants.UIConstants;
import com.fr.design.gui.iscrollbar.UIScrollBar; import com.fr.design.gui.iscrollbar.UIScrollBar;
import javax.swing.*; import javax.swing.JScrollBar;
import java.awt.*; import javax.swing.JScrollPane;
import javax.swing.ScrollPaneConstants;
import java.awt.Color;
import java.awt.Component;
/** /**
* @author zhou * @author zhou
@ -16,7 +19,11 @@ public class UIScrollPane extends JScrollPane {
private static final int INCREAMENT = 30; 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); this(c, ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED, ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
}
public UIScrollPane(Component c, int vertical, int horizontal) {
super(c, vertical, horizontal);
this.setHorizontalScrollBar(createHorizontalScrollBar()); this.setHorizontalScrollBar(createHorizontalScrollBar());
this.getVerticalScrollBar().setUnitIncrement(INCREAMENT); this.getVerticalScrollBar().setUnitIncrement(INCREAMENT);
this.getVerticalScrollBar().setBlockIncrement(INCREAMENT); this.getVerticalScrollBar().setBlockIncrement(INCREAMENT);

Loading…
Cancel
Save