10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License"). 6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 220Sstevel@tonic-gate * Copyright (c) 1999 by Sun Microsystems, Inc. 230Sstevel@tonic-gate * All rights reserved. 240Sstevel@tonic-gate * 250Sstevel@tonic-gate */ 260Sstevel@tonic-gate 27*7298SMark.J.Nelson@Sun.COM // SLDPgui.java : The service location daemon GUI. 280Sstevel@tonic-gate // Author: Erik Guttman 290Sstevel@tonic-gate // 300Sstevel@tonic-gate 310Sstevel@tonic-gate package com.sun.slp; 320Sstevel@tonic-gate 330Sstevel@tonic-gate /** 340Sstevel@tonic-gate * This GUI will allow the user of the slpd to monitor the daemon, 350Sstevel@tonic-gate * shut it off, manually enter services and stuff like that. 360Sstevel@tonic-gate * 370Sstevel@tonic-gate * @author Erik Guttman 380Sstevel@tonic-gate */ 390Sstevel@tonic-gate 400Sstevel@tonic-gate import java.awt.*; 410Sstevel@tonic-gate import java.util.*; 420Sstevel@tonic-gate 430Sstevel@tonic-gate class SLPDgui extends Frame { SLPDgui(String configFile)440Sstevel@tonic-gate public SLPDgui(String configFile) { 450Sstevel@tonic-gate 460Sstevel@tonic-gate super("slpd"); 470Sstevel@tonic-gate 480Sstevel@tonic-gate Font font = new Font("SansSerif", Font.BOLD, 12); 490Sstevel@tonic-gate 500Sstevel@tonic-gate setFont(font); 510Sstevel@tonic-gate 520Sstevel@tonic-gate configFilename = configFile; 530Sstevel@tonic-gate 540Sstevel@tonic-gate setLayout(new BorderLayout()); 550Sstevel@tonic-gate 560Sstevel@tonic-gate // Set up a panel displaying config file. 570Sstevel@tonic-gate Panel configPanel = new Panel(); 580Sstevel@tonic-gate configPanel.setLayout(new FlowLayout()); 590Sstevel@tonic-gate 600Sstevel@tonic-gate configPanel.add(new Label("Configuration file:", Label.CENTER)); 610Sstevel@tonic-gate configPanel.add(new Label(configFile == null ? "":configFile)); 620Sstevel@tonic-gate add("North", configPanel); 630Sstevel@tonic-gate 640Sstevel@tonic-gate taLog = new TextArea(); 650Sstevel@tonic-gate taLog.setEditable(false); 660Sstevel@tonic-gate add("Center", taLog); 670Sstevel@tonic-gate 680Sstevel@tonic-gate Panel pS = new Panel(); 690Sstevel@tonic-gate pS.setLayout(new FlowLayout()); 700Sstevel@tonic-gate pS.add(new Button("Quit")); 710Sstevel@tonic-gate 720Sstevel@tonic-gate add("South", pS); 730Sstevel@tonic-gate 740Sstevel@tonic-gate // Use JDK 1.1 event model in compatibility mode w. 1.0. 750Sstevel@tonic-gate 760Sstevel@tonic-gate enableEvents(AWTEvent.WINDOW_EVENT_MASK); 770Sstevel@tonic-gate 780Sstevel@tonic-gate setSize(WIDTH, HEIGHT); 790Sstevel@tonic-gate } 800Sstevel@tonic-gate processEvent(AWTEvent evt)810Sstevel@tonic-gate public void processEvent(AWTEvent evt) { 820Sstevel@tonic-gate if (evt.getID() == Event.WINDOW_DESTROY) { 830Sstevel@tonic-gate try { 840Sstevel@tonic-gate slpd.stop(); 850Sstevel@tonic-gate 860Sstevel@tonic-gate } catch (ServiceLocationException ex) { 870Sstevel@tonic-gate SLPConfig conf = SLPConfig.getSLPConfig(); 880Sstevel@tonic-gate ResourceBundle bundle = conf.getMessageBundle(conf.getLocale()); 890Sstevel@tonic-gate 900Sstevel@tonic-gate slpd.errorExit(bundle, ex); 910Sstevel@tonic-gate 920Sstevel@tonic-gate } 930Sstevel@tonic-gate } 940Sstevel@tonic-gate 950Sstevel@tonic-gate super.processEvent(evt); 960Sstevel@tonic-gate } 970Sstevel@tonic-gate getTALog()980Sstevel@tonic-gate TextArea getTALog() { 990Sstevel@tonic-gate 1000Sstevel@tonic-gate return taLog; 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate } 1030Sstevel@tonic-gate 1040Sstevel@tonic-gate // Size of main window. 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate static private int WIDTH = 780; 1070Sstevel@tonic-gate static private int HEIGHT = 750; 1080Sstevel@tonic-gate 1090Sstevel@tonic-gate private String configFilename; 1100Sstevel@tonic-gate private TextArea taLog; 1110Sstevel@tonic-gate 1120Sstevel@tonic-gate } 113