001/* 002 * (C) Copyright 2006-2010 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * bstefanescu 018 */ 019package org.nuxeo.shell.swing; 020 021import java.awt.BorderLayout; 022 023import javax.swing.JFrame; 024import javax.swing.JPanel; 025import javax.swing.WindowConstants; 026 027import org.nuxeo.shell.Shell; 028import org.nuxeo.shell.cmds.Interactive; 029 030/** 031 * @author <a href="mailto:[email protected]">Bogdan Stefanescu</a> 032 */ 033@SuppressWarnings("serial") 034public class ShellFrame extends JFrame { 035 036 protected Console console; 037 038 public ShellFrame() throws Exception { 039 setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); 040 setTitle("Nuxeo Shell"); 041 JPanel content = (JPanel) getContentPane(); 042 ConsolePanel panel = new ConsolePanel(); 043 console = panel.getConsole(); 044 // Set the window's bounds, centering the window 045 content.add(panel, BorderLayout.CENTER); 046 // content.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); 047 setResizable(true); 048 } 049 050 public static void main(String[] args) throws Exception { 051 Shell shell = Shell.get(); 052 ShellFrame term = new ShellFrame(); 053 term.pack(); 054 term.setSize(800, 600); 055 // term.setExtendedState(Frame.MAXIMIZED_BOTH); 056 term.setLocationRelativeTo(null); 057 term.setVisible(true); 058 term.console.requestFocus(); 059 Interactive.setConsoleReaderFactory(term.console); 060 shell.main(args); 061 } 062 063}