summaryrefslogtreecommitdiff
path: root/src/main/java/com/c2kernel/gui/lifecycle/chooser/LDAPEntryChooser.java
blob: 724561867ce635463be36789afcb9d37ad98f8ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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<String> allItems = new ArrayList<String>();

    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();
    }

}