Exemple #1
0
 public void replaceItem(String newValue, int index) {
   toolkit.lockAWT();
   try {
     items.set(index, newValue);
     updatePrefWidth();
     doRepaint();
   } catch (IndexOutOfBoundsException e) {
     throw new ArrayIndexOutOfBoundsException(e.getMessage());
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #2
0
 public void removeAll() {
   toolkit.lockAWT();
   try {
     items.clear();
     selection.clear();
     currentIndex = 0;
     scrollable.setLocation(new Point());
     doRepaint();
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #3
0
 public void deselect(int index) {
   toolkit.lockAWT();
   try {
     int oldFocusedIdx = currentIndex;
     currentIndex = index;
     selection.remove(new Integer(index));
     // repaint only deselected item's Rectangle &
     // previously "focused" item's Rectangle
     doRepaint(getMinRect(index, oldFocusedIdx));
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #4
0
 public void add(String item, int index) {
   toolkit.lockAWT();
   try {
     String str = (item != null ? item : ""); // $NON-NLS-1$
     int pos = index;
     int size = items.size();
     if ((pos < 0) || (pos > size)) {
       pos = size;
     }
     items.add(pos, str);
     updatePrefWidth();
     doRepaint();
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #5
0
 public void setMultipleMode(boolean multipleMode) {
   toolkit.lockAWT();
   try {
     if (!multipleMode && (this.multipleMode != multipleMode)) {
       selection.clear();
       int curIdx = getCurrentIndex();
       if (curIdx >= 0) {
         selection.add(new Integer(curIdx));
       }
     }
     this.multipleMode = multipleMode;
     doRepaint();
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #6
0
 public void select(int index) {
   toolkit.lockAWT();
   try {
     // if an item was already selected -
     // do nothing
     if (isIndexSelected(index)) {
       return;
     }
     if (!multipleMode && (selection.size() == 1)) {
       deselect(getSelectedIndex());
     }
     selection.add(new Integer(index));
     // repaint only item's rectangle & old "focused" item's rect
     doRepaint(getMinRect(index, currentIndex));
     currentIndex = index;
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #7
0
 public void remove(int position) {
   toolkit.lockAWT();
   try {
     selection.remove(new Integer(position));
     items.remove(position);
     // decrease all selected indices greater than position
     // by 1, because items list is shifted to the left
     for (int i = 0; i < selection.size(); i++) {
       Integer idx = selection.get(i);
       int val = idx.intValue();
       if (val > position) {
         selection.set(i, new Integer(val - 1));
       }
     }
     updatePrefWidth();
     doRepaint();
   } catch (IndexOutOfBoundsException e) {
     throw new ArrayIndexOutOfBoundsException(e.getMessage());
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #8
0
 public void makeVisible(int index) {
   toolkit.lockAWT();
   try {
     visibleIndex = index;
     if (!isDisplayable() || !isIdxValid(index)) {
       return;
     }
     // scroll if necessary
     Rectangle itemRect = getItemBounds(index);
     Rectangle clientRect = getClient();
     int dy = itemRect.y - clientRect.y;
     if (dy < 0) {
       stateController.updateAdjValue(vAdjustable, dy);
     }
     dy = itemRect.y + itemRect.height - (clientRect.y + clientRect.height);
     if (dy > 0) {
       stateController.updateAdjValue(vAdjustable, dy);
     }
     doRepaint(getMinRect(currentIndex, visibleIndex));
     currentIndex = visibleIndex;
   } finally {
     toolkit.unlockAWT();
   }
 }
Exemple #9
0
 private void doRepaint() {
   stateController.layoutScrollbars();
   doRepaint(new Rectangle(new Point(), getSize()));
 }