PageRenderTime 65ms CodeModel.GetById 60ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-0-pre5/bsh/commands/desktop.bsh

#
Unknown | 142 lines | 121 code | 21 blank | 0 comment | 0 complexity | 525ee96940f31d972cc246a923b69c3a MD5 | raw file
  1import javax.swing.*;
  2import bsh.util.JConsole;
  3import bsh.util.Util;
  4import bsh.Interpreter;
  5import java.awt.Component;
  6import bsh.Capabilities;
  7
  8desktop() {
  9	// need a way to set things to void again
 10	if ( bsh.system.desktop != void ) {
 11		print("There is	already	a desktop running...");
 12		return;
 13	} else
 14		bsh.system.desktop = this;   // race condition (hah!)
 15
 16	// Ignore unhandled method invocations from listeners.
 17	invoke( method, args ) { }
 18
 19	makeFontMenu( Component	component ) {
 20		menu = new JMenu("Font");
 21		mi = new JMenuItem("Normal");
 22		mi.addActionListener(this);
 23		menu.add(mi);
 24		mi = new JMenuItem("Big");
 25		mi.addActionListener(this);
 26		menu.add(mi);
 27		mi = new JMenuItem("Bigger");
 28		mi.addActionListener(this);
 29		menu.add(mi);
 30
 31		actionPerformed(e) {
 32			com = e.getActionCommand();
 33			if ( com.equals("Normal") )
 34				setFont( component, 12 );
 35			else if	( com.equals("Big") )
 36				setFont( component, 16 );
 37			else if	( com.equals("Bigger") )
 38				setFont( component, 20 );
 39		}
 40
 41		return menu;
 42	}
 43
 44	makeInternalFrame( String name ) {
 45		// Closable by default
 46		frame = new JInternalFrame(	name, true, true, true, true);
 47		frame.setVisible( true );
 48		return frame;
 49	}
 50
 51	addInternalFrame( frame ) {
 52		bsh.system.desktop.pane.add( frame	);
 53		/*
 54		frame.pack();
 55		frame.show();
 56		frame.toFront();
 57		*/
 58	}
 59
 60	windowCount=0;
 61
 62	mousePressed( e	) {
 63		popup.show( pane, e.getX(), e.getY() );
 64	}
 65
 66	shutdown() {
 67		/*
 68		ret = JOptionPane.showInternalConfirmDialog( pane,
 69			"This workspace	has not	been saved. Do you really want to exit?" );
 70		if ( ret == JOptionPane.YES_OPTION )
 71				exit();
 72		*/
 73		frame.dispose();
 74		exit();
 75	}
 76
 77	actionPerformed( e ) {
 78		com = e.getActionCommand();
 79		if ( com.equals("New Bsh Workspace") )
 80			makeWorkspace( ""+ super.windowCount++);
 81		if ( com.equals("New Class Browser") )
 82			classBrowser();
 83		else if	( com.equals("Save Workspace") )
 84			JOptionPane.showInternalMessageDialog( pane, "Unimplemented" );
 85		else if	( com.equals("Exit") )
 86			shutdown();
 87	}
 88
 89	pane=new JDesktopPane();
 90
 91	popup=new JPopupMenu("Root Menu");
 92	mi=new JMenuItem("New Bsh Workspace");
 93	mi.addActionListener(this);
 94	popup.add( mi );
 95	mi=new JMenuItem("New Class Browser");
 96	mi.addActionListener(this);
 97	popup.add( mi );
 98	mi=new JMenuItem("Save Workspace");
 99	mi.addActionListener(this);
100	popup.add( mi );
101	mi=new JMenuItem("Exit");
102	mi.addActionListener(this);
103	popup.add( mi );
104
105	pane.addMouseListener( this );
106
107	frame=new JFrame("BeanShell Desktop 1.0");
108	frame.getContentPane().add("Center", pane);
109
110	windowClosing( e ) {
111		bsh.system.desktop = null;
112		shutdown();
113	}
114
115	frame.addWindowListener( this );
116
117	/*
118		If available, add a listener for classpath mapping
119		I'm planning to implement a GUI progress indicator here
120
121	if ( Capabilities.canGenerateInterfaces() ) 
122	{
123		import bsh.classpath.BshClassPath;
124		classFeedbackListener = new BshClassPath.MappingFeedback() 
125		{
126			startClassMapping() { }
127			classMapping( msg ) { }
128			errorWhileMapping( msg ) { }
129			endClassMapping() { }
130		};
131		BshClassPath.addMappingFeedback( classFeedbackListener );
132	}
133	*/
134
135	// start one terminal
136	makeWorkspace( ""+windowCount++	);
137
138	frame.setSize(800,600);
139	frame.show();
140	frame.toFront();
141	Util.endSplashScreen();
142}