// File: ContentDialog.java // Classes: ContentDialog // Original Author: Kedar Patankar // Date 21 Jan 1997 package uci.graphedit; import java.awt.Button; import java.awt.Event; import java.awt.List; //import java.awt.Frame; import java.awt.Panel; import java.awt.Label; import java.awt.Color; import java.awt.BorderLayout; import java.util.Vector; import java.util.Enumeration; import gjt.DialogClient; import gjt.GJTDialog; import gjt.ButtonPanel; public class WindowDialog extends GJTDialog { private Button _show; private Button _close; private Button _cancel; private List _documentList; private String _name; private Editor _editor; private String actionRequested; public WindowDialog(Editor frame,DialogClient dialogClient,String title,Vector v) { super(frame,title,dialogClient,true); _editor=frame; _close = new Button("Close Window"); _cancel = new Button("Cancel"); _show = new Button("Activate"); _documentList = new List(); Panel topicPanel = new Panel(); topicPanel.setLayout(new BorderLayout()); Label l = new Label("Select the Window"); topicPanel.add("North",l); topicPanel.add("Center",_documentList ); topicPanel.setBackground(Color.lightGray); _documentList .setBackground(Color.white); ButtonPanel _buttonPanel= new ButtonPanel(); _buttonPanel.add(_show); _buttonPanel.add(_close); _buttonPanel.add(_cancel); _buttonPanel.setBackground(Color.lightGray); setLayout(new BorderLayout()); add("Center",topicPanel); add("South",_buttonPanel); fillList(v); pack(); resize( 350,150); if(_documentList.countItems()<1) { _show.disable(); _close.disable(); } else _documentList .select(0); } private void fillList(Vector v) { Enumeration items=v.elements(); while (items.hasMoreElements()) { String s=(String)items.nextElement(); if(_editor.get_outStanding().contains(s)) s+=" *"; _documentList.addItem(s); } } public void show() { _documentList .requestFocus(); super.show(); } public boolean handleEvent(Event e) { switch(e.id) { case Event.WINDOW_DESTROY: close(); return true; case Event.LIST_SELECT: return true; } return super.handleEvent(e); } public boolean action(Event e, Object what) { if (e.target == _cancel) { close(); return true; } else if (e.target == _close) { actionRequested="CLOSE"; executeCommand(); dispose(); return true; } else if (e.target == _show) { actionRequested="SHOW"; executeCommand(); dispose(); return true; } return false; } public void close() { hide(); dispose(); } private void executeCommand() { _name=_documentList.getSelectedItem(); hide(); int a = _name.lastIndexOf(" *"); if (a>0) _name = _name.substring(0,a); client.dialogDismissed(this); } public String getSelection(){return _name;} public String getRequest(){return actionRequested;} } /* end class ContentDialog */