01: /*
02: * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
03: *
04: * See the file "LICENSE.txt" for information on usage and redistribution of
05: * this file, and for a DISCLAIMER OF ALL WARRANTIES.
06: */
07: package org.pnuts.tools;
08:
09: import java.awt.BorderLayout;
10: import java.awt.Dimension;
11: import java.awt.Font;
12: import javax.swing.JList;
13: import javax.swing.JPanel;
14: import javax.swing.JScrollPane;
15: import pnuts.lang.Context;
16: import pnuts.lang.PnutsFunction;
17: import pnuts.tools.ContextEvent;
18: import pnuts.tools.ContextListener;
19:
20: public class ImportsView extends JPanel implements ContextListener {
21: private final static Font monospaced = Font.getFont("monospaced");
22: JList importList;
23:
24: public ImportsView() {
25: setLayout(new BorderLayout());
26: this .importList = new JList();
27: importList.setFont(monospaced);
28: importList.setFocusable(false);
29: importList.setSelectionBackground(importList.getBackground());
30: JScrollPane p = new JScrollPane(importList);
31: p.setPreferredSize(new Dimension(300, 70));
32: add(p);
33: }
34:
35: public void update(ContextEvent event) {
36: Context context = event.getContext();
37: importList.setListData((String[]) PnutsFunction.IMPORT.call(
38: new Object[] {}, context));
39: }
40: }
|