package com.c2kernel.gui.lifecycle.chooser; /** * @version $Revision: 1.2 $ $Date: 2005/12/01 14:23:15 $ * @author $Author: abranson $ */ import java.awt.Dimension; import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import javax.swing.JComboBox; import com.c2kernel.gui.MainFrame; import com.c2kernel.lookup.DomainPath; import com.c2kernel.process.Gateway; public class LDAPEntryChooser extends JComboBox { DomainPath mDomainPath = null; ArrayList allItems = new ArrayList(); public LDAPEntryChooser(DomainPath domPath, boolean editable) { super(); setEditable(editable); mDomainPath = domPath; initialise(); } private void initialise() { try { Iterator children = Gateway.getLookup().search(mDomainPath, "*"); while (children.hasNext()) { DomainPath domPath = (DomainPath)children.next(); allItems.add(domPath.getName()); } } catch (Exception ex) { MainFrame.exceptionDialog(ex); } Collections.sort(allItems); addItem(""); for (String element : allItems) { addItem(element); } } public void reload() { removeAllItems(); initialise(); } @Override public synchronized Dimension getSize() { if (Gateway.getProperties().getInt("ResizeCombo") > 0) return new Dimension(super.getSize().width<400?400:super.getSize().width,super.getSize().height); return super.getSize(); } }