|
From: Michal P. <mic...@us...> - 2002-09-12 14:39:50
|
Update of /cvsroot/javaprofiler/module/net/sourceforge/javaprofiler/module/wizards In directory usw-pr-cvs1:/tmp/cvs-serv25787/net/sourceforge/javaprofiler/module/wizards Added Files: ConnectorWizardFinishPanel.java ConnectorWizardPanel.java Log Message: Initial import. --- NEW FILE: ConnectorWizardFinishPanel.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.wizards; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.event.*; import org.openide.*; import org.openide.util.*; import net.sourceforge.javaprofiler.jpi.*; import net.sourceforge.javaprofiler.jpi.connect.*; public class ConnectorWizardFinishPanel implements WizardDescriptor.FinishPanel { private final JPanel panel = new JPanel(); private Connector connector; private boolean isValid = false; private Thread thread; public ConnectorWizardFinishPanel () { panel.setName( "Connector"); panel.setPreferredSize( new Dimension( 400, 200)); panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS)); panel.add( new JLabel( "Connecting, please wait...")); } public HelpCtx getHelp() { return new HelpCtx (ConnectorWizardFinishPanel.class); } public void storeSettings( Object settings) { } public void readSettings( Object settings) { final Connector connector = (Connector)((Map)settings).get( "connector"); final Map arguments = (Map)((Map)settings).get( "arguments"); // hourglass thread = new Thread() { public void run() { try { connector.connect( arguments); } catch ( ConnectingException e) { connectFailed( e.getMessage()); } connectSucceeded(); } }; thread.start(); // no hourglass } private void connectSucceeded() { } private void connectFailed( String reason) { } public void addChangeListener( ChangeListener l) {} public void removeChangeListener( ChangeListener l) {} public boolean isValid() { return isValid; } public Component getComponent() { return panel; } } --- NEW FILE: ConnectorWizardPanel.java --- /* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License Version * 1.0 (the "License"). You may not use this file except in compliance with * the License. A copy of the License is available at http://www.sun.com/ * * The Original Code is the Java Profiler module. * The Initial Developers of the Original Code are Jan Stola, Pavel Vacha, * Michal Pise, Petr Luner, Lukas Petru and Marek Przeczek. * Portions created by Jan Stola are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Pavel Vacha are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Michal Pise are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Petr Luner are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Lukas Petru are Copyright (C) 2000-2001. All Rights Reserved. * Portions created by Marek Przeczek are Copyright (C) 2000-2001. All Rights Reserved. * * Contributors: Jan Stola, Pavel Vacha, Michal Pise, Petr Luner, * Lukas Petru and Marek Przeczek. */ package net.sourceforge.javaprofiler.module.wizards; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import javax.swing.event.*; import org.openide.*; import org.openide.util.*; import net.sourceforge.javaprofiler.jpi.*; import net.sourceforge.javaprofiler.jpi.connect.*; public class ConnectorWizardPanel implements WizardDescriptor.Panel, ActionListener { private final JPanel panel = new JPanel(); private final JComboBox typeCombo = new JComboBox( types); private final JComboBox connectorCombo = new JComboBox(); private final ConnectorManager cm = Bootstrap.connectorManager(); private final JTextArea descriptionArea = new JTextArea(); private Connector[] connectors; private boolean eraseArguments = false; private static final String[] types = new String[] { "Launching connectors", "Attaching connectors", "Listening connectors"}; public ConnectorWizardPanel() { panel.setName( "Connector"); panel.setLayout( new BoxLayout( panel, BoxLayout.Y_AXIS)); Dimension d = new Dimension( 400, 200); panel.setPreferredSize( d); JLabel label = new JLabel( "Select a type of connector"); panel.add( label); typeCombo.addActionListener( this); panel.add( typeCombo); panel.add( new JLabel( "Select a connector")); connectorCombo.addActionListener( this); panel.add( connectorCombo); descriptionArea.setRows( 3); descriptionArea.setBorder( BorderFactory.createLineBorder( Color.BLACK)); descriptionArea.setLineWrap( true); descriptionArea.setWrapStyleWord( true); panel.add( descriptionArea); loadConnectors( cm.connectors( Connector.LAUNCHING_CONNECTOR)); } public void actionPerformed( ActionEvent event) { if ( event.getSource() == connectorCombo) { descriptionArea.setText( connectors[ connectorCombo.getSelectedIndex()].description()); eraseArguments = true; return; } java.util.List conns; switch ( typeCombo.getSelectedIndex()) { case 0: conns = cm.connectors( Connector.LAUNCHING_CONNECTOR); break; case 1: conns = cm.connectors( Connector.ATTACHING_CONNECTOR); break; default: conns = cm.connectors( Connector.LISTENING_CONNECTOR); } connectorCombo.removeAllItems(); loadConnectors( conns); } private void loadConnectors( java.util.List conns) { connectors = new Connector[ conns.size()]; for ( int i = 0; i < connectors.length; ++i) { Connector connector = (Connector) conns.get( i); connectors[ i] = connector; connectorCombo.addItem( connector.label()); } connectorCombo.setSelectedIndex( 0); descriptionArea.setText( connectors[ 0].description()); eraseArguments = true; } public HelpCtx getHelp() { return new HelpCtx (ConnectorWizardPanel.class); } public void storeSettings( Object settings) { ((Map)settings).put( "connector", connectors[ connectorCombo.getSelectedIndex()]); if ( eraseArguments) ((Map)settings).remove( "arguments"); } public void readSettings( Object settings) { eraseArguments = false; } public void addChangeListener( ChangeListener l) {} public void removeChangeListener( ChangeListener l) {} public boolean isValid() { return true; } public Component getComponent() { return panel; } } |