Changeset 8169


Ignore:
Timestamp:
2004-09-28T16:04:55+12:00 (20 years ago)
Author:
mdewsnip
Message:

Removed a ton of crap (hopefully this doesn't break anything). Also fixed a couple of bugs, including (I hope) the nasty NPE in BasicComboBoxUI.getDisplaySize (1291) caused irregularly by the call to updateUI().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/gui/GComboBox.java

    r8003 r8169  
    5050    extends JComboBox {
    5151
    52     private boolean editable = true;
    53 
    5452    private Color background = null;
    5553    private Color foreground = null;
     
    6664    public GComboBox(boolean editable) {
    6765    super();
    68     this.editable = editable;
    69     super.setEditable(editable);
     66    setEditable(editable);
    7067    init();
    7168    }
     
    7875    public GComboBox(ArrayList data, boolean editable) {
    7976    super(data.toArray());
    80     this.editable = editable;
    81     super.setEditable(editable);
     77    setEditable(editable);
    8278    init();
    8379    }
     
    9086    public GComboBox(ComboBoxModel model, boolean editable) {
    9187    super(model);
    92     this.editable = editable;
    93     super.setEditable(editable);
     88    setEditable(editable);
    9489    init();
    9590    }
     
    9994    super();
    10095    init();
    101     }
     96   }
    10297
    10398    public GComboBox(Object data[]) {
     
    108103    public GComboBox(Object data[], boolean editable) {
    109104    super(data);
    110     this.editable = editable;
    111     super.setEditable(editable);
     105    setEditable(editable);
    112106    init();
    113107    }
     
    120114    public GComboBox(Vector data, boolean editable) {
    121115    super(data);
    122     this.editable = editable;
    123     super.setEditable(editable);
     116    setEditable(editable);
    124117    init();
    125118    }
    126119
    127120    public int add(Object object) {
    128     if(dataModel instanceof Model) {
    129         return ((Model)dataModel).add(object);
     121    if (dataModel instanceof Model) {
     122        return ((Model) dataModel).add(object);
    130123    }
    131124    else {
     
    139132
    140133    public void clear() {
    141     if(dataModel instanceof Model) {
    142         ((Model)dataModel).clear();
    143     }
    144     }
    145 
    146     /** Overridden to do nothing.
    147      * @param background
    148      */
    149     public void setBackground(Color background) {
    150     }
    151 
    152 //      public void setBackgroundEditableColor(Color editable_background) {
    153 //      this.editable_background = editable_background;
    154 //      setEditor(new Editor());
    155 //      setRenderer(new Renderer());
    156 //      }
    157 
    158     public void setBackgroundNonSelectionColor(Color background) {
    159     this.background = background;
    160     setEditor(new Editor());
    161     setRenderer(new Renderer());
    162     }
    163 
    164     public void setBackgroundSelectionColor(Color selection_background) {
    165     this.selection_background = selection_background;
    166     setEditor(new Editor());
    167     setRenderer(new Renderer());
    168     }
    169 
    170     public void setEditable(boolean editable) {
    171     super.setEditable(editable);
    172     this.editable = editable;
    173     if(editable) {
    174         this.setBackground(editable_background);
    175         this.setForeground(editable_foreground);
    176     }
    177     else {
    178         this.setBackground(background);
    179         this.setForeground(foreground);
    180     }
    181     setEditor(new Editor());
    182     setRenderer(new Renderer());
    183     updateUI();
    184     }
    185 
    186 //      public void setTextEditableColor(Color editable_foreground) {
    187 //      this.editable_foreground = editable_foreground;
    188 //      setEditor(new Editor());
    189 //      setRenderer(new Renderer());
    190 //      }
    191 
    192     public void setTextNonSelectionColor(Color foreground) {
    193     this.foreground = foreground;
    194     setEditor(new Editor());
    195     setRenderer(new Renderer());
    196     }
    197 
    198     public void setTextSelectionColor(Color selection_foreground) {
    199     this.selection_foreground = selection_foreground;
    200     setEditor(new Editor());
    201     setRenderer(new Renderer());
     134    if (dataModel instanceof Model) {
     135        ((Model) dataModel).clear();
     136    }
    202137    }
    203138
     
    207142    setModel(model);
    208143    setOpaque(true);
     144
    209145    // Restore any data given into our model
    210146    for(int i = 0; i < old_model.getSize(); i++) {
    211147        model.add(old_model.getElementAt(i));
    212148    }
     149
    213150    // Change component
    214151    UI ui = new UI();
    215152    setUI(ui);
    216153    ui.setButtonBackground();
     154
    217155    // Initialization
    218156    this.background = Gatherer.config.getColor("coloring.collection_tree_background", false);
     
    222160    this.selection_background = Gatherer.config.getColor("coloring.collection_selection_background", false);
    223161    this.selection_foreground = Gatherer.config.getColor("coloring.collection_selection_foreground", false);
    224     if(editable) {
     162    if (isEditable()) {
    225163        this.setBackground(editable_background);
    226164        this.setForeground(editable_foreground);
     
    231169    }
    232170    setBorder(BorderFactory.createLoweredBevelBorder());
     171    setRenderer(new Renderer());
     172    }
     173
     174    /** Overridden to do nothing.
     175     * @param background
     176     */
     177    public void setBackground(Color background) {
     178    }
     179
     180    public void setBackgroundEditableColor(Color editable_background) {
     181    this.editable_background = editable_background;
     182    }
     183
     184    public void setBackgroundNonSelectionColor(Color background) {
     185    this.background = background;
     186    }
     187
     188    public void setBackgroundSelectionColor(Color selection_background) {
     189    this.selection_background = selection_background;
     190    }
     191
     192    public void setEditable(boolean editable) {
    233193    setEditor(new Editor());
    234     setRenderer(new Renderer());
    235     }
     194    super.setEditable(editable);
     195    if (isEditable()) {
     196        this.setBackground(editable_background);
     197        this.setForeground(editable_foreground);
     198    }
     199    else {
     200        this.setBackground(background);
     201        this.setForeground(foreground);
     202    }
     203    }
     204
     205    public void setTextEditableColor(Color editable_foreground) {
     206    this.editable_foreground = editable_foreground;
     207    }
     208
     209    public void setTextNonSelectionColor(Color foreground) {
     210    this.foreground = foreground;
     211    }
     212
     213    public void setTextSelectionColor(Color selection_foreground) {
     214    this.selection_foreground = selection_foreground;
     215    }
     216
    236217
    237218    private class Editor
     
    240221    public Editor() {
    241222        setOpaque(true);
    242         if(editable) {
     223        if (isEditable()) {
    243224        setBackground(editable_background);
    244225        setForeground(editable_foreground);
     
    323304        this.setForeground(selection_foreground);
    324305        }
    325         else if(editable) {
     306        else if (isEditable()) {
    326307        this.setBackground(editable_background);
    327308        this.setForeground(editable_foreground);
Note: See TracChangeset for help on using the changeset viewer.