home *** CD-ROM | disk | FTP | other *** search
- package com.sun.java.swing.plaf.basic;
-
- import com.sun.java.swing.BorderFactory;
- import com.sun.java.swing.BoxLayout;
- import com.sun.java.swing.CellRendererPane;
- import com.sun.java.swing.ComboBoxEditor;
- import com.sun.java.swing.ComboBoxModel;
- import com.sun.java.swing.JButton;
- import com.sun.java.swing.JComboBox;
- import com.sun.java.swing.JComponent;
- import com.sun.java.swing.JDialog;
- import com.sun.java.swing.JList;
- import com.sun.java.swing.JPopupMenu;
- import com.sun.java.swing.JRootPane;
- import com.sun.java.swing.JScrollPane;
- import com.sun.java.swing.KeyStroke;
- import com.sun.java.swing.ListCellRenderer;
- import com.sun.java.swing.LookAndFeel;
- import com.sun.java.swing.SwingUtilities;
- import com.sun.java.swing.Timer;
- import com.sun.java.swing.UIManager;
- import com.sun.java.swing.border.Border;
- import com.sun.java.swing.plaf.ComboBoxUI;
- import com.sun.java.swing.plaf.ComponentUI;
- import com.sun.java.swing.plaf.UIResource;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Dialog;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Insets;
- import java.awt.LayoutManager;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.Toolkit;
- import java.awt.Window;
- import java.awt.event.FocusEvent;
- import java.awt.event.FocusListener;
- import java.awt.event.InputEvent;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.awt.event.KeyEvent;
- import java.awt.event.KeyListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.awt.event.MouseMotionListener;
- import java.beans.PropertyChangeEvent;
- import java.beans.PropertyChangeListener;
- import java.io.Serializable;
- import java.util.EventObject;
-
- public class BasicComboBoxUI extends ComboBoxUI implements LayoutManager, MouseListener, MouseMotionListener, ItemListener, FocusListener, KeyListener, PropertyChangeListener, Serializable {
- protected static final Color selectionBackgroundColor = new Color(0, 0, 128);
- protected static final int BORDER_THICKNESS = 2;
- protected JComboBox comboBox;
- protected CellRendererPane currentValuePane = new CellRendererPane();
- protected JButton arrowButton;
- protected Component editor;
- protected JPopupMenu menu;
- protected JList listBox;
- protected JScrollPane scrollPane;
- protected Timer autoscrollTimer;
- protected Point lastMouseLocation;
- protected static JComboBox showingComboBox = null;
- protected Point popupLocation;
- protected boolean hasFocus = false;
-
- public static ComponentUI createUI(JComponent var0) {
- return new BasicComboBoxUI();
- }
-
- public void installUI(JComponent var1) {
- this.comboBox = (JComboBox)var1;
- this.addArrowButton();
- this.comboBox.add(this.currentValuePane);
- this.comboBox.setLayout(this);
- this.comboBox.addItemListener(this);
- this.comboBox.addFocusListener(this);
- this.comboBox.addMouseListener(this);
- this.comboBox.addMouseMotionListener(this);
- this.comboBox.addKeyListener(this);
- this.comboBox.addPropertyChangeListener(this);
- if (this.comboBox.getRenderer() == null) {
- this.comboBox.setRenderer((ListCellRenderer)UIManager.get("ComboBox.renderer"));
- }
-
- this.editablePropertyChanged();
- this.addKeyAccelerators(this.comboBox);
- this.configureComboBox();
- }
-
- public void uninstallUI(JComponent var1) {
- this.hidePopup();
- this.removeEditor();
- this.removeArrowButton();
- this.comboBox.setLayout((LayoutManager)null);
- this.comboBox.removeFocusListener(this);
- if (this.listBox != null) {
- this.listBox.removeMouseListener(this);
- this.listBox.removeMouseMotionListener(this);
- }
-
- this.comboBox.removeItemListener(this);
- this.comboBox.removeMouseListener(this);
- this.comboBox.removeMouseMotionListener(this);
- this.comboBox.removeKeyListener(this);
- this.comboBox.resetKeyboardActions();
- this.comboBox.remove(this.currentValuePane);
- this.comboBox.removePropertyChangeListener(this);
- if (this.comboBox.getRenderer() instanceof UIResource) {
- this.comboBox.setRenderer((ListCellRenderer)null);
- }
-
- if (this.comboBox.getEditor() instanceof UIResource) {
- this.comboBox.setEditor((ComboBoxEditor)null);
- }
-
- this.comboBox = null;
- this.unconfigureComboBox();
- }
-
- public boolean isFocusTraversable() {
- return !this.comboBox.isEditable();
- }
-
- protected void configureComboBox() {
- LookAndFeel.installColorsAndFont(this.comboBox, "ComboBox.background", "ComboBox.foreground", "ComboBox.font");
- }
-
- protected void unconfigureComboBox() {
- }
-
- public void editablePropertyChanged() {
- if (this.comboBox.isEditable()) {
- this.addEditor();
- } else {
- this.removeEditor();
- }
- }
-
- public void enablePropertyChanged() {
- boolean var1 = this.comboBox.isEnabled();
- if (var1) {
- if (this.editor != null) {
- this.editor.setEnabled(true);
- }
-
- if (this.arrowButton != null) {
- this.arrowButton.setEnabled(true);
- }
- } else {
- if (this.editor != null) {
- this.editor.setEnabled(false);
- }
-
- if (this.arrowButton != null) {
- this.arrowButton.setEnabled(false);
- }
- }
-
- this.comboBox.repaint();
- }
-
- public void addEditor() {
- if (this.editor != null) {
- this.removeEditor();
- }
-
- if (this.comboBox.getEditor() == null) {
- this.comboBox.setEditor((ComboBoxEditor)UIManager.get("ComboBox.editor"));
- }
-
- this.editor = this.comboBox.getEditor().getEditorComponent();
- this.comboBox.add(this.editor);
- this.editor.setFont(this.comboBox.getFont());
- this.editor.setBackground(this.comboBox.getBackground());
- this.editor.setForeground(this.comboBox.getForeground());
- this.comboBox.configureEditor(this.comboBox.getEditor(), this.comboBox.getSelectedItem());
- }
-
- public void removeEditor() {
- if (this.editor != null) {
- this.comboBox.remove(this.editor);
- this.editor = null;
- }
-
- }
-
- public void addArrowButton() {
- this.arrowButton = this.createArrowButton();
- this.arrowButton.setRequestFocusEnabled(false);
- this.arrowButton.addMouseListener(this);
- this.arrowButton.addMouseMotionListener(this);
- this.arrowButton.resetKeyboardActions();
- this.comboBox.add(this.arrowButton);
- }
-
- public void removeArrowButton() {
- if (this.arrowButton != null) {
- this.comboBox.remove(this.arrowButton);
- this.arrowButton.removeMouseListener(this);
- this.arrowButton.removeMouseMotionListener(this);
- this.arrowButton = null;
- }
-
- }
-
- protected JList createListBox(ComboBoxModel var1) {
- return new JList(var1);
- }
-
- public JList getList() {
- return this.listBox;
- }
-
- protected JButton createArrowButton() {
- return new BasicArrowButton(5);
- }
-
- public void paint(Graphics var1, JComponent var2) {
- Rectangle var3 = ((Component)var2).getBounds();
- BasicGraphicsUtils.drawEtchedRect(var1, 0, 0, var3.width, var3.height);
- boolean var4 = this.comboBox.hasFocus();
- if (!this.comboBox.isEditable()) {
- Rectangle var5 = this.rectangleForCurrentValue();
- this.paintCurrentValueBackground(var1, var5, var4);
- this.paintCurrentValue(var1, var5, var4);
- }
-
- }
-
- public void paintCurrentValue(Graphics var1, Rectangle var2, boolean var3) {
- ListCellRenderer var4 = this.comboBox.getRenderer();
- this.validateMenu();
- Component var5;
- if (var3 && !this.popupIsVisible()) {
- var5 = var4.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, true, false);
- } else {
- var5 = var4.getListCellRendererComponent(this.listBox, this.comboBox.getSelectedItem(), -1, false, false);
- var5.setBackground(UIManager.getColor("ComboBox.background"));
- }
-
- var5.setFont(this.comboBox.getFont());
- if (var3 && !this.popupIsVisible()) {
- var5.setForeground(this.listBox.getSelectionForeground());
- var5.setBackground(this.listBox.getSelectionBackground());
- } else if (this.comboBox.isEnabled()) {
- var5.setForeground(this.comboBox.getForeground());
- var5.setBackground(this.comboBox.getBackground());
- } else {
- var5.setForeground(UIManager.getColor("ComboBox.disabledForeground"));
- var5.setBackground(UIManager.getColor("ComboBox.disabledBackground"));
- }
-
- this.currentValuePane.paintComponent(var1, var5, this.comboBox, var2.x, var2.y, var2.width, var2.height);
- }
-
- public void paintCurrentValueBackground(Graphics var1, Rectangle var2, boolean var3) {
- Color var4 = var1.getColor();
- if (this.comboBox.isEnabled()) {
- var1.setColor(UIManager.getColor("ComboBox.background"));
- } else {
- var1.setColor(UIManager.getColor("ComboBox.disabledBackground"));
- }
-
- var1.fillRect(var2.x, var2.y, var2.width, var2.height);
- var1.setColor(var4);
- }
-
- protected Dimension getDefaultSize() {
- return new Dimension(100, 20);
- }
-
- protected Dimension getMaxPreferredSize() {
- Dimension var3 = new Dimension();
- ListCellRenderer var4 = this.comboBox.getRenderer();
- ComboBoxModel var5 = this.comboBox.getModel();
- this.validateMenu();
- if (var4 != null && var5.getSize() > 0) {
- int var1 = 0;
-
- for(int var2 = var5.getSize(); var1 < var2; ++var1) {
- Component var6 = var4.getListCellRendererComponent(this.listBox, var5.getElementAt(var1), -1, false, false);
- this.currentValuePane.add(var6);
- var6.setFont(this.comboBox.getFont());
- Dimension var7 = var6.getPreferredSize();
- this.currentValuePane.remove(var6);
- var3.width = Math.max(var3.width, var7.width);
- var3.height = Math.max(var3.height, var7.height);
- }
-
- if (this.comboBox.isEditable()) {
- Dimension var8 = this.editor.getPreferredSize();
- var3.width = Math.max(var3.width, var8.width);
- var3.height = Math.max(var3.height, var8.height);
- }
-
- return var3;
- } else {
- return this.getDefaultSize();
- }
- }
-
- protected Dimension getMaxMinimumSize() {
- Dimension var3 = new Dimension();
- ListCellRenderer var4 = this.comboBox.getRenderer();
- ComboBoxModel var5 = this.comboBox.getModel();
- this.validateMenu();
- if (var4 != null && var5.getSize() > 0) {
- int var1 = 0;
-
- for(int var2 = var5.getSize(); var1 < var2; ++var1) {
- Component var6 = var4.getListCellRendererComponent(this.listBox, var5.getElementAt(var1), -1, false, false);
- this.currentValuePane.add(var6);
- var6.setFont(this.comboBox.getFont());
- Dimension var7 = var6.getMinimumSize();
- this.currentValuePane.remove(var6);
- var3.width = Math.max(var3.width, var7.width);
- var3.height = Math.max(var3.height, var7.height);
- }
-
- if (this.comboBox.isEditable()) {
- Dimension var8 = this.editor.getMinimumSize();
- var3.width = Math.max(var3.width, var8.width);
- var3.height = Math.max(var3.height, var8.height);
- }
-
- return var3;
- } else {
- return this.getDefaultSize();
- }
- }
-
- protected Dimension getMaxMaximumSize() {
- Dimension var3 = new Dimension();
- ListCellRenderer var4 = this.comboBox.getRenderer();
- ComboBoxModel var5 = this.comboBox.getModel();
- this.validateMenu();
- if (var4 != null && var5.getSize() > 0) {
- int var1 = 0;
-
- for(int var2 = var5.getSize(); var1 < var2; ++var1) {
- Component var6 = var4.getListCellRendererComponent(this.listBox, var5.getElementAt(var1), -1, false, false);
- this.currentValuePane.add(var6);
- var6.setFont(this.comboBox.getFont());
- Dimension var7 = var6.getMaximumSize();
- this.currentValuePane.remove(var6);
- var3.width = Math.max(var3.width, var7.width);
- var3.height = Math.max(var3.height, var7.height);
- }
-
- if (this.comboBox.isEditable()) {
- Dimension var8 = this.editor.getMaximumSize();
- var3.width = Math.max(var3.width, var8.width);
- var3.height = Math.max(var3.height, var8.height);
- }
-
- return var3;
- } else {
- return this.getDefaultSize();
- }
- }
-
- public Dimension getPreferredSize(JComponent var1) {
- Dimension var2 = this.getMaxPreferredSize();
- var2.height += 4;
- int var3 = var2.height - 4;
- var2.width += 4 + var3;
- return var2;
- }
-
- public Dimension getMinimumSize(JComponent var1) {
- Dimension var2 = this.getMaxMinimumSize();
- var2.height += 4;
- int var3 = var2.height - 4;
- var2.width += 4 + var3;
- return var2;
- }
-
- public Dimension getMaximumSize(JComponent var1) {
- Dimension var2 = this.getMaxMaximumSize();
- var2.height += 4;
- var2.width = 32767;
- return var2;
- }
-
- public void addLayoutComponent(String var1, Component var2) {
- }
-
- public void removeLayoutComponent(Component var1) {
- }
-
- public Dimension preferredLayoutSize(Container var1) {
- JComboBox var10000 = (JComboBox)var1;
- return var1.getPreferredSize();
- }
-
- public Dimension minimumLayoutSize(Container var1) {
- JComboBox var10000 = (JComboBox)var1;
- return var1.getMinimumSize();
- }
-
- protected Rectangle rectangleForCurrentValue() {
- Dimension var1 = this.comboBox.getSize();
- int var2 = var1.height - 4;
- return new Rectangle(2, 2, var1.width - 4 - var2, var1.height - 4);
- }
-
- public void layoutContainer(Container var1) {
- JComboBox var2 = (JComboBox)var1;
- Dimension var3 = ((Component)var2).getSize();
- int var4 = var3.height - 4;
- if (this.editor != null) {
- Rectangle var5 = this.rectangleForCurrentValue();
- this.editor.setBounds(var5);
- }
-
- if (this.arrowButton != null) {
- this.arrowButton.setBounds(2 + var3.width - 4 - var4, 2, var4, var4);
- }
-
- }
-
- public void itemStateChanged(ItemEvent var1) {
- ComboBoxModel var2 = this.comboBox.getModel();
- Object var3 = var2.getSelectedItem();
- if (this.editor != null) {
- this.comboBox.configureEditor(this.comboBox.getEditor(), var3);
- } else {
- Rectangle var4 = this.rectangleForCurrentValue();
- this.comboBox.repaint(0L, var4.x, var4.y, var4.width, var4.height);
- }
-
- if (this.popupIsVisible()) {
- this.updateListBoxSelection();
- }
-
- }
-
- public void focusGained(FocusEvent var1) {
- if (!this.comboBox.isEditable()) {
- this.repaintCurrentValue();
- this.hasFocus = true;
- }
-
- }
-
- public void focusLost(FocusEvent var1) {
- if (!this.comboBox.isEditable()) {
- this.repaintCurrentValue();
- this.hasFocus = false;
- }
-
- }
-
- public void propertyChange(PropertyChangeEvent var1) {
- String var2 = var1.getPropertyName();
- if (var2.equals("model") && this.listBox != null) {
- this.listBox.setModel(this.comboBox.getModel());
- if (this.popupIsVisible()) {
- this.hidePopup();
- }
- }
-
- }
-
- void repaintCurrentValue() {
- Rectangle var1 = this.rectangleForCurrentValue();
- this.comboBox.repaint(var1.x, var1.y, var1.width, var1.height);
- }
-
- public void mouseClicked(MouseEvent var1) {
- }
-
- public void mouseEntered(MouseEvent var1) {
- }
-
- public void mouseExited(MouseEvent var1) {
- }
-
- public void mouseReleased(MouseEvent var1) {
- this.stopAutoscrolling();
- if (this.popupIsVisible()) {
- if (((EventObject)var1).getSource() == this.listBox) {
- this.updateListBoxSelectionForEvent(var1, true);
- this.comboBox.getModel().setSelectedItem(this.listBox.getSelectedValue());
- this.hidePopup();
- return;
- }
-
- if (((EventObject)var1).getSource() == this.arrowButton && !SwingUtilities.getLocalBounds(this.arrowButton).contains(var1.getPoint())) {
- MouseEvent var5 = this.convertEventToListBox(var1);
- this.updateListBoxSelectionForEvent(var5, true);
- Object var4 = this.listBox.getSelectedValue();
- if (var4 != null) {
- this.comboBox.getModel().setSelectedItem(var4);
- }
-
- this.hidePopup();
- return;
- }
-
- if (((EventObject)var1).getSource() == this.comboBox && !SwingUtilities.getLocalBounds(this.comboBox).contains(var1.getPoint())) {
- MouseEvent var3 = this.convertEventToListBox(var1);
- this.updateListBoxSelectionForEvent(var3, true);
- Object var2 = this.listBox.getSelectedValue();
- if (var2 != null) {
- this.comboBox.getModel().setSelectedItem(var2);
- }
-
- this.hidePopup();
- }
- }
-
- }
-
- protected boolean shouldActivatePopupForEvent(MouseEvent var1) {
- Rectangle var2 = this.rectangleForCurrentValue();
- return var2.contains(var1.getPoint());
- }
-
- public void mousePressed(MouseEvent var1) {
- if (SwingUtilities.isLeftMouseButton(var1)) {
- if (this.comboBox.isEnabled()) {
- if (((EventObject)var1).getSource() == this.arrowButton) {
- Rectangle var2 = SwingUtilities.getLocalBounds(this.arrowButton);
- if (var2.contains(var1.getX(), var1.getY())) {
- if (this.popupIsVisible()) {
- this.hidePopup();
- return;
- }
-
- this.showPopup();
- return;
- }
- } else if (((EventObject)var1).getSource() == this.comboBox && this.shouldActivatePopupForEvent(var1)) {
- if (this.popupIsVisible()) {
- this.hidePopup();
- return;
- }
-
- this.showPopup();
- }
-
- }
- }
- }
-
- public void mouseDragged(MouseEvent var1) {
- if (this.popupIsVisible() && (((EventObject)var1).getSource() == this.arrowButton && !SwingUtilities.getLocalBounds(this.arrowButton).contains(var1.getPoint()) || ((EventObject)var1).getSource() == this.comboBox && !SwingUtilities.getLocalBounds(this.comboBox).contains(var1.getPoint()))) {
- MouseEvent var3 = this.convertEventToListBox(var1);
- this.updateListBoxSelectionForEvent(var3, true);
- this.lastMouseLocation = SwingUtilities.convertPoint((Component)((EventObject)var1).getSource(), var1.getPoint(), (Component)null);
- Window var2 = SwingUtilities.windowForComponent((Component)((EventObject)var1).getSource());
- Point var10000 = this.lastMouseLocation;
- var10000.x += ((Component)var2).getBounds().x;
- var10000 = this.lastMouseLocation;
- var10000.y += ((Component)var2).getBounds().y;
- this.startAutoscrolling();
- }
-
- }
-
- public void mouseMoved(MouseEvent var1) {
- Object var2 = ((EventObject)var1).getSource();
- if (this.popupIsVisible() && var2 == this.listBox) {
- Point var3 = var1.getPoint();
- Rectangle var4 = new Rectangle();
- this.listBox.computeVisibleRect(var4);
- if (var4.contains(var3)) {
- this.updateListBoxSelectionForEvent(var1, false);
- }
- }
-
- }
-
- public void keyTyped(KeyEvent var1) {
- }
-
- public void keyReleased(KeyEvent var1) {
- }
-
- public void keyPressed(KeyEvent var1) {
- if ((((EventObject)var1).getSource() == this.comboBox && !this.comboBox.isEditable() || ((EventObject)var1).getSource() == this.listBox && !this.comboBox.isEditable()) && this.comboBox.selectWithKeyChar(var1.getKeyChar())) {
- ((InputEvent)var1).consume();
- }
-
- }
-
- public void validateMenu() {
- if (this.menu == null) {
- this.menu = new JPopupMenu();
- this.menu.setLayout(new BoxLayout(this.menu, 1));
- this.menu.setBorderPainted(true);
- this.menu.setBorder(BorderFactory.createLineBorder(Color.black));
- this.menu.setOpaque(false);
- this.listBox = this.createListBox(this.comboBox.getModel());
- this.listBox.setRequestFocusEnabled(false);
- this.listBox.setBorder((Border)null);
- this.listBox.setCellRenderer(this.comboBox.getRenderer());
- this.listBox.addMouseListener(this);
- this.listBox.addMouseMotionListener(this);
- this.listBox.addKeyListener(this);
- this.listBox.setBorder((Border)null);
- this.scrollPane = new JScrollPane(this.listBox, 20, 31);
- this.scrollPane.setRequestFocusEnabled(false);
- this.scrollPane.getVerticalScrollBar().setRequestFocusEnabled(false);
- this.scrollPane.setBorder((Border)null);
- this.menu.add(this.scrollPane);
- this.menu.setDoubleBuffered(true);
- this.menu.registerKeyboardAction(new 1(this), KeyStroke.getKeyStroke(27, 0), 1);
- this.menu.registerKeyboardAction(new 2(this), KeyStroke.getKeyStroke(10, 0), 1);
- this.addKeyAccelerators(this.menu);
- }
-
- }
-
- private Dialog getDialog() {
- Container var1;
- for(var1 = this.comboBox.getParent(); var1 != null && !(var1 instanceof Dialog) && !(var1 instanceof Window); var1 = ((Component)var1).getParent()) {
- }
-
- return var1 instanceof Dialog ? (Dialog)var1 : null;
- }
-
- private boolean inModalDialog() {
- return this.getDialog() != null;
- }
-
- protected Rectangle computePopupBounds(int var1, int var2, int var3, int var4) {
- Rectangle var6 = new Rectangle(var1, var2, var3, var4);
- boolean var7 = this.inModalDialog();
- Rectangle var5;
- if (var7) {
- Dialog var8 = this.getDialog();
- if (var8 instanceof JDialog) {
- JRootPane var10 = ((JDialog)var8).getRootPane();
- Point var9 = ((Component)var10).getLocationOnScreen();
- var5 = ((Component)var10).getBounds();
- var5.x = var9.x;
- var5.y = var9.y;
- } else {
- var5 = ((Component)var8).getBounds();
- }
-
- Point var13 = new Point(var5.x, var5.y);
- SwingUtilities.convertPointFromScreen(var13, this.comboBox);
- var5.x = var13.x;
- var5.y = var13.y;
- } else {
- Dimension var14 = Toolkit.getDefaultToolkit().getScreenSize();
- var5 = new Rectangle();
- Point var11 = new Point(0, 0);
- SwingUtilities.convertPointFromScreen(var11, this.comboBox);
- var5.x = var11.x;
- var5.y = var11.y;
- var5.width = var14.width;
- var5.height = var14.height;
- }
-
- if (SwingUtilities.isRectangleContainingRectangle(var5, var6)) {
- return var6;
- } else {
- Rectangle var12 = new Rectangle(0, -var6.height, var6.width, var6.height);
- if (SwingUtilities.isRectangleContainingRectangle(var5, var12)) {
- return var12;
- } else if (var7) {
- SwingUtilities.computeIntersection(var5.x, var5.y, var5.width, var5.height, var6);
- SwingUtilities.computeIntersection(var5.x, var5.y, var5.width, var5.height, var12);
- return var6.height > var12.height ? var6 : var12;
- } else {
- return var12;
- }
- }
- }
-
- public void showPopup() {
- Rectangle var3 = this.comboBox.getBounds();
- this.popupLocation = new Point(var3.x, var3.y);
- if (showingComboBox != null && showingComboBox != this.comboBox) {
- showingComboBox.getUI().hidePopup();
- showingComboBox = null;
- }
-
- this.validateMenu();
- this.comboBox.requestFocus();
- this.setupListBox(this.listBox, this.comboBox);
- Dimension var2 = new Dimension(var3.width, this.getPopupHeightForRowCount(this.comboBox.getMaximumRowCount()));
- Border var1 = this.menu.getBorder();
- if (var1 != null) {
- Insets var5 = var1.getBorderInsets(this.menu);
- var2.width -= var5.left + var5.right;
- var2.height -= var5.top + var5.bottom;
- }
-
- this.updateListBoxSelection();
- this.listBox.invalidate();
- Rectangle var4 = this.computePopupBounds(0, this.comboBox.getBounds().height, var2.width, var2.height);
- var2.width = var4.width;
- var2.height = var4.height;
- this.scrollPane.setMaximumSize(var2);
- this.scrollPane.setPreferredSize(var2);
- this.scrollPane.setMinimumSize(var2);
- this.menu.setLightWeightPopupEnabled(this.comboBox.isLightWeightPopupEnabled());
- this.menu.show(this.comboBox, var4.x, var4.y);
- this.menu.repaint();
- this.comboBox.registerKeyboardAction(new 3(this), KeyStroke.getKeyStroke(27, 0), 2);
- this.comboBox.registerKeyboardAction(new 4(this), KeyStroke.getKeyStroke(10, 0), 2);
- this.repaintCurrentValue();
- this.listBox.requestFocus();
- showingComboBox = this.comboBox;
- }
-
- protected void setupListBox(JList var1, JComboBox var2) {
- ((Component)var1).setFont(((Component)var2).getFont());
- ((Component)var1).setForeground(((Component)var2).getForeground());
- ((Component)var1).setBackground(((Component)var2).getBackground());
- }
-
- public void hidePopup() {
- if (this.menu != null && this.listBox != null) {
- if (this.popupIsVisible()) {
- this.menu.setVisible(false);
- this.requestFocusLater();
- this.comboBox.unregisterKeyboardAction(KeyStroke.getKeyStroke(27, 0));
- this.comboBox.unregisterKeyboardAction(KeyStroke.getKeyStroke(10, 0));
- }
- }
- }
-
- protected void requestFocusLater() {
- if (this.comboBox.isEditable()) {
- requestFocusLaterForComponent(this.comboBox.getEditor().getEditorComponent());
- } else {
- requestFocusLaterForComponent(this.comboBox);
- this.repaintCurrentValue();
- }
- }
-
- protected int getPopupHeightForRowCount(int var1) {
- int var2 = this.comboBox.getModel().getSize();
- if (var2 > 0) {
- Rectangle var3 = this.listBox.getCellBounds(0, 0);
- if (var3.height <= 2) {
- var3.height = 17;
- }
-
- return var1 < var2 ? var3.height * var1 + 2 : var3.height * var2 + 2;
- } else {
- return 100;
- }
- }
-
- public boolean popupIsVisible() {
- if (this.menu == null) {
- return false;
- } else {
- this.validateMenu();
- return this.menu.isVisible();
- }
- }
-
- public void maximumRowCountChanged() {
- if (this.popupIsVisible()) {
- this.hidePopup();
- this.showPopup();
- }
-
- }
-
- protected void updateListBoxSelection() {
- Object var1 = this.comboBox.getModel().getSelectedItem();
- if (var1 == null && this.listBox != null) {
- this.listBox.setSelectedIndex(-1);
- } else {
- this.listBox.setSelectedValue(var1, true);
- }
- }
-
- protected void startAutoscrolling() {
- if (this.autoscrollTimer == null) {
- this.autoscrollTimer = new Timer(100, new 5(this));
- }
-
- this.autoscrollTimer.start();
- }
-
- protected void stopAutoscrolling() {
- if (this.autoscrollTimer != null) {
- this.autoscrollTimer.stop();
- }
-
- this.lastMouseLocation = null;
- }
-
- protected void autoscroll() {
- if (this.listBox != null) {
- Window var1 = SwingUtilities.windowForComponent(this.listBox);
- if (this.lastMouseLocation != null && var1 != null) {
- Point var2 = new Point(this.lastMouseLocation.x - ((Component)var1).getBounds().x, this.lastMouseLocation.y - ((Component)var1).getBounds().y);
- var2 = SwingUtilities.convertPoint((Component)null, var2, this.listBox);
- int var3 = this.listBox.locationToIndex(var2);
- if (var3 == -1) {
- if (var2.y < 0) {
- var3 = 0;
- } else {
- var3 = this.comboBox.getModel().getSize() - 1;
- }
- }
-
- this.listBox.setSelectedIndex(var3);
- this.listBox.ensureIndexIsVisible(var3);
- }
-
- }
- }
-
- protected void updateListBoxSelectionForEvent(MouseEvent var1, boolean var2) {
- Point var3 = var1.getPoint();
- if (this.listBox != null) {
- int var4 = this.listBox.locationToIndex(var3);
- if (var4 == -1) {
- if (var3.y < 0) {
- var4 = 0;
- } else {
- var4 = this.comboBox.getModel().getSize() - 1;
- }
- }
-
- this.listBox.setSelectedIndex(var4);
- if (var2) {
- this.listBox.ensureIndexIsVisible(var4);
- }
-
- }
- }
-
- protected void selectNextPossibleValue() {
- this.validateMenu();
- int var1;
- if (this.popupIsVisible()) {
- var1 = this.listBox.getSelectedIndex();
- } else {
- var1 = this.comboBox.getSelectedIndex();
- }
-
- if (var1 < this.comboBox.getModel().getSize() - 1) {
- this.comboBox.setSelectedIndex(var1 + 1);
- }
-
- }
-
- protected void selectPreviousPossibleValue() {
- this.validateMenu();
- int var1;
- if (this.popupIsVisible()) {
- var1 = this.listBox.getSelectedIndex();
- } else {
- var1 = this.comboBox.getSelectedIndex();
- }
-
- if (var1 > 0) {
- this.comboBox.setSelectedIndex(var1 - 1);
- }
-
- }
-
- protected void toggleOpenClose() {
- if (this.popupIsVisible()) {
- this.hidePopup();
- } else {
- this.showPopup();
- }
- }
-
- protected MouseEvent convertEventToListBox(MouseEvent var1) {
- MouseEvent var5 = SwingUtilities.convertMouseEvent((Component)((EventObject)var1).getSource(), var1, (Component)null);
- Window var3 = SwingUtilities.windowForComponent((Component)((EventObject)var1).getSource());
- Rectangle var2 = ((Component)var3).getBounds();
- var5.translatePoint(var2.x, var2.y);
- Window var4 = SwingUtilities.windowForComponent(this.listBox);
- var2 = ((Component)var4).getBounds();
- var5.translatePoint(-var2.x, -var2.y);
- var5 = SwingUtilities.convertMouseEvent((Component)null, var5, this.listBox);
- return var5;
- }
-
- protected void addKeyAccelerators(JComponent var1) {
- var1.registerKeyboardAction(new 6(this), KeyStroke.getKeyStroke(40, 0), 1);
- var1.registerKeyboardAction(new 7(this), KeyStroke.getKeyStroke(38, 0), 1);
- var1.registerKeyboardAction(new 8(this), KeyStroke.getKeyStroke(38, 8), 1);
- var1.registerKeyboardAction(new 9(this), KeyStroke.getKeyStroke(40, 8), 1);
- }
-
- protected void removeKeyAccelerators(JComponent var1) {
- var1.unregisterKeyboardAction(KeyStroke.getKeyStroke(40, 0));
- var1.unregisterKeyboardAction(KeyStroke.getKeyStroke(38, 0));
- var1.unregisterKeyboardAction(KeyStroke.getKeyStroke(40, 8));
- var1.unregisterKeyboardAction(KeyStroke.getKeyStroke(38, 8));
- }
-
- protected static void requestFocusLaterForComponent(Component var0) {
- new FocusRequestHelper(var0);
- }
- }
-