xref: /illumos-gate/usr/src/lib/libslp/javalib/com/sun/slp/SLPDgui.java (revision 9a70fc3be3b1e966bf78825cdb8d509963a6f0a1)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5*9a70fc3bSMark J. Nelson  * Common Development and Distribution License (the "License").
6*9a70fc3bSMark J. Nelson  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
227c478bd9Sstevel@tonic-gate  * Copyright (c) 1999 by Sun Microsystems, Inc.
237c478bd9Sstevel@tonic-gate  * All rights reserved.
247c478bd9Sstevel@tonic-gate  *
257c478bd9Sstevel@tonic-gate  */
267c478bd9Sstevel@tonic-gate 
27*9a70fc3bSMark J. Nelson //  SLDPgui.java : The service location daemon GUI.
287c478bd9Sstevel@tonic-gate //  Author:           Erik Guttman
297c478bd9Sstevel@tonic-gate //
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate package com.sun.slp;
327c478bd9Sstevel@tonic-gate 
337c478bd9Sstevel@tonic-gate /**
347c478bd9Sstevel@tonic-gate  * This GUI will allow the user of the slpd to monitor the daemon,
357c478bd9Sstevel@tonic-gate  * shut it off, manually enter services and stuff like that.
367c478bd9Sstevel@tonic-gate  *
377c478bd9Sstevel@tonic-gate  * @author Erik Guttman
387c478bd9Sstevel@tonic-gate  */
397c478bd9Sstevel@tonic-gate 
407c478bd9Sstevel@tonic-gate import java.awt.*;
417c478bd9Sstevel@tonic-gate import java.util.*;
427c478bd9Sstevel@tonic-gate 
437c478bd9Sstevel@tonic-gate class SLPDgui extends Frame {
SLPDgui(String configFile)447c478bd9Sstevel@tonic-gate     public SLPDgui(String configFile) {
457c478bd9Sstevel@tonic-gate 
467c478bd9Sstevel@tonic-gate         super("slpd");
477c478bd9Sstevel@tonic-gate 
487c478bd9Sstevel@tonic-gate 	Font font = new Font("SansSerif", Font.BOLD, 12);
497c478bd9Sstevel@tonic-gate 
507c478bd9Sstevel@tonic-gate 	setFont(font);
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate 	configFilename = configFile;
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate 	setLayout(new BorderLayout());
557c478bd9Sstevel@tonic-gate 
567c478bd9Sstevel@tonic-gate 	// Set up a panel displaying config file.
577c478bd9Sstevel@tonic-gate 	Panel configPanel = new Panel();
587c478bd9Sstevel@tonic-gate 	configPanel.setLayout(new FlowLayout());
597c478bd9Sstevel@tonic-gate 
607c478bd9Sstevel@tonic-gate 	configPanel.add(new Label("Configuration file:", Label.CENTER));
617c478bd9Sstevel@tonic-gate 	configPanel.add(new Label(configFile == null ? "":configFile));
627c478bd9Sstevel@tonic-gate 	add("North", configPanel);
637c478bd9Sstevel@tonic-gate 
647c478bd9Sstevel@tonic-gate 	taLog = new TextArea();
657c478bd9Sstevel@tonic-gate 	taLog.setEditable(false);
667c478bd9Sstevel@tonic-gate 	add("Center", taLog);
677c478bd9Sstevel@tonic-gate 
687c478bd9Sstevel@tonic-gate 	Panel pS = new Panel();
697c478bd9Sstevel@tonic-gate 	pS.setLayout(new FlowLayout());
707c478bd9Sstevel@tonic-gate 	pS.add(new Button("Quit"));
717c478bd9Sstevel@tonic-gate 
727c478bd9Sstevel@tonic-gate 	add("South", pS);
737c478bd9Sstevel@tonic-gate 
747c478bd9Sstevel@tonic-gate 	// Use JDK 1.1 event model in compatibility mode w. 1.0.
757c478bd9Sstevel@tonic-gate 
767c478bd9Sstevel@tonic-gate 	enableEvents(AWTEvent.WINDOW_EVENT_MASK);
777c478bd9Sstevel@tonic-gate 
787c478bd9Sstevel@tonic-gate 	setSize(WIDTH, HEIGHT);
797c478bd9Sstevel@tonic-gate     }
807c478bd9Sstevel@tonic-gate 
processEvent(AWTEvent evt)817c478bd9Sstevel@tonic-gate     public void processEvent(AWTEvent evt) {
827c478bd9Sstevel@tonic-gate 	if (evt.getID() == Event.WINDOW_DESTROY) {
837c478bd9Sstevel@tonic-gate 	  try {
847c478bd9Sstevel@tonic-gate 	    slpd.stop();
857c478bd9Sstevel@tonic-gate 
867c478bd9Sstevel@tonic-gate 	  } catch (ServiceLocationException ex) {
877c478bd9Sstevel@tonic-gate 	    SLPConfig conf = SLPConfig.getSLPConfig();
887c478bd9Sstevel@tonic-gate 	    ResourceBundle bundle = conf.getMessageBundle(conf.getLocale());
897c478bd9Sstevel@tonic-gate 
907c478bd9Sstevel@tonic-gate 	    slpd.errorExit(bundle, ex);
917c478bd9Sstevel@tonic-gate 
927c478bd9Sstevel@tonic-gate 	  }
937c478bd9Sstevel@tonic-gate 	}
947c478bd9Sstevel@tonic-gate 
957c478bd9Sstevel@tonic-gate 	super.processEvent(evt);
967c478bd9Sstevel@tonic-gate     }
977c478bd9Sstevel@tonic-gate 
getTALog()987c478bd9Sstevel@tonic-gate     TextArea getTALog() {
997c478bd9Sstevel@tonic-gate 
1007c478bd9Sstevel@tonic-gate 	return taLog;
1017c478bd9Sstevel@tonic-gate 
1027c478bd9Sstevel@tonic-gate     }
1037c478bd9Sstevel@tonic-gate 
1047c478bd9Sstevel@tonic-gate     // Size of main window.
1057c478bd9Sstevel@tonic-gate 
1067c478bd9Sstevel@tonic-gate     static private int WIDTH = 780;
1077c478bd9Sstevel@tonic-gate     static private int HEIGHT = 750;
1087c478bd9Sstevel@tonic-gate 
1097c478bd9Sstevel@tonic-gate     private String configFilename;
1107c478bd9Sstevel@tonic-gate     private TextArea taLog;
1117c478bd9Sstevel@tonic-gate 
1127c478bd9Sstevel@tonic-gate }
113