001/*
002 * (C) Copyright 2006-2010 Nuxeo SAS (http://nuxeo.com/) and contributors.
003 *
004 * All rights reserved. This program and the accompanying materials
005 * are made available under the terms of the GNU Lesser General Public License
006 * (LGPL) version 2.1 which accompanies this distribution, and is available at
007 * http://www.gnu.org/licenses/lgpl.html
008 *
009 * This library is distributed in the hope that it will be useful,
010 * but WITHOUT ANY WARRANTY; without even the implied warranty of
011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012 * Lesser General Public License for more details.
013 *
014 * Contributors:
015 *     bstefanescu
016 */
017package org.nuxeo.shell.swing;
018
019import java.awt.BorderLayout;
020
021import javax.swing.JFrame;
022import javax.swing.JPanel;
023import javax.swing.WindowConstants;
024
025import org.nuxeo.shell.Shell;
026import org.nuxeo.shell.cmds.Interactive;
027
028/**
029 * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
030 */
031@SuppressWarnings("serial")
032public class ShellFrame extends JFrame {
033
034    protected Console console;
035
036    public ShellFrame() throws Exception {
037        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
038        setTitle("Nuxeo Shell");
039        JPanel content = (JPanel) getContentPane();
040        ConsolePanel panel = new ConsolePanel();
041        console = panel.getConsole();
042        // Set the window's bounds, centering the window
043        content.add(panel, BorderLayout.CENTER);
044        // content.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
045        setResizable(true);
046    }
047
048    public static void main(String[] args) throws Exception {
049        Shell shell = Shell.get();
050        ShellFrame term = new ShellFrame();
051        term.pack();
052        term.setSize(800, 600);
053        // term.setExtendedState(Frame.MAXIMIZED_BOTH);
054        term.setLocationRelativeTo(null);
055        term.setVisible(true);
056        term.console.requestFocus();
057        Interactive.setConsoleReaderFactory(term.console);
058        shell.main(args);
059    }
060
061}