jdk/src/share/classes/com/sun/tools/example/debug/gui/LaunchTool.java
author xdono
Wed, 02 Jul 2008 12:55:45 -0700
changeset 715 f16baef3a20e
parent 51 6fe31bc95bbc
child 5506 202f599c92aa
permissions -rw-r--r--
6719955: Update copyright year Summary: Update copyright year for files that have been modified in 2008 Reviewed-by: ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
715
f16baef3a20e 6719955: Update copyright year
xdono
parents: 51
diff changeset
     2
 * Copyright 1999-2008 Sun Microsystems, Inc.  All Rights Reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package com.sun.tools.example.debug.gui;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.List;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
import java.util.ArrayList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import java.util.Map;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
import java.util.HashMap;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
import java.util.Iterator;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
import java.io.IOException;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
import java.awt.BorderLayout;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
import java.awt.Color;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
import java.awt.Container;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
import java.awt.event.ActionEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
import java.awt.event.ActionListener;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
import java.awt.event.WindowAdapter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
import java.awt.event.WindowEvent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
import javax.swing.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
import javax.swing.border.Border;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
import javax.swing.border.TitledBorder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
import com.sun.jdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
import com.sun.jdi.connect.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
import com.sun.tools.example.debug.bdi.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
class LaunchTool {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    private final ExecutionManager runtime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    private abstract class ArgRep {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
        final Connector.Argument arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
        final JPanel panel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
        ArgRep(Connector.Argument arg) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
            this.arg = arg;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
            panel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
            Border etched = BorderFactory.createEtchedBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
            Border titled = BorderFactory.createTitledBorder(etched,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                                      arg.description(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                                      TitledBorder.LEFT, TitledBorder.TOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
            panel.setBorder(titled);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
        abstract String getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
        boolean isValid() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
            return arg.isValid(getText());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        boolean isSpecified() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
            String value = getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
            return (value != null && value.length() > 0) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
                !arg.mustSpecify();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
        void install() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
            arg.setValue(getText());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    private class StringArgRep extends ArgRep {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
        final JTextField textField;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        StringArgRep(Connector.Argument arg, JPanel comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
            super(arg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
            textField = new JTextField(arg.value(), 50 );
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
            textField.setBorder(BorderFactory.createLoweredBevelBorder());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
            panel.add(new JLabel(arg.label(), SwingConstants.RIGHT));
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
            panel.add(textField); // , BorderLayout.CENTER);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
            comp.add(panel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        String getText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
            return textField.getText();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
    private class BooleanArgRep extends ArgRep {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        final JCheckBox check;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
        BooleanArgRep(Connector.BooleanArgument barg, JPanel comp) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            super(barg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
            check = new JCheckBox(barg.label());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            check.setSelected(barg.booleanValue());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
            panel.add(check);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
            comp.add(panel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
        String getText() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
            return ((Connector.BooleanArgument)arg)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
                           .stringValueOf(check.getModel().isSelected());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
    private LaunchTool(ExecutionManager runtime) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
        this.runtime = runtime;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    private Connector selectConnector() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
        final JDialog dialog = new JDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
        Container content = dialog.getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
        final JPanel radioPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
        final ButtonGroup radioGroup = new ButtonGroup();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
        VirtualMachineManager manager = Bootstrap.virtualMachineManager();
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   134
        List<Connector> all = manager.allConnectors();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
        Map<ButtonModel, Connector> modelToConnector = new HashMap<ButtonModel, Connector>(all.size(), 0.5f);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
        dialog.setModal(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
        dialog.setTitle("Select Connector Type");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
        radioPanel.setLayout(new BoxLayout(radioPanel, BoxLayout.Y_AXIS));
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   140
        for (Connector connector : all) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
            JRadioButton radio = new JRadioButton(connector.description());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            modelToConnector.put(radio.getModel(), connector);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            radioPanel.add(radio);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            radioGroup.add(radio);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        content.add(radioPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        final boolean[] oked = {false};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
        JPanel buttonPanel = okCancel( dialog, new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
            public void actionPerformed(ActionEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                if (radioGroup.getSelection() == null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
                    JOptionPane.showMessageDialog(dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
                                    "Please select a connector type",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
                                    "No Selection",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
                                     JOptionPane.ERROR_MESSAGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
                } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
                    oked[0] = true;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
                    dialog.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
                    dialog.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
        } );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
        content.add(BorderLayout.SOUTH, buttonPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
        dialog.pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
        dialog.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        return oked[0] ?
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   168
            modelToConnector.get(radioGroup.getSelection()) :
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
            null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
    private void configureAndConnect(final Connector connector) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
        final JDialog dialog = new JDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
        final Map<String, Connector.Argument> args = connector.defaultArguments();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
        dialog.setModal(true);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        dialog.setTitle("Connector Arguments");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        Container content = dialog.getContentPane();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        JPanel guts = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
        Border etched = BorderFactory.createEtchedBorder();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
        Border titled = BorderFactory.createTitledBorder(etched,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
                                connector.description(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
                                TitledBorder.LEFT, TitledBorder.TOP);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
        guts.setBorder(etched);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
        guts.setLayout(new BoxLayout(guts, BoxLayout.Y_AXIS));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
        //        guts.add(new JLabel(connector.description()));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
        final List<ArgRep> argReps = new ArrayList<ArgRep>(args.size());
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   190
        for (Connector.Argument arg : args.values()) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
            ArgRep ar;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
            if (arg instanceof Connector.BooleanArgument) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
                ar = new BooleanArgRep((Connector.BooleanArgument)arg, guts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
            } else {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   195
                ar = new StringArgRep(arg, guts);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
            argReps.add(ar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        content.add(guts);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        JPanel buttonPanel = okCancel( dialog, new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
            public void actionPerformed(ActionEvent event) {
51
6fe31bc95bbc 6600143: Remove another 450 unnecessary casts
martin
parents: 2
diff changeset
   203
                for (ArgRep ar : argReps) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
                    if (!ar.isSpecified()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
                        JOptionPane.showMessageDialog(dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
                                    ar.arg.label() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
                                         ": Argument must be specified",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
                                    "No argument", JOptionPane.ERROR_MESSAGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
                    if (!ar.isValid()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
                        JOptionPane.showMessageDialog(dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
                                    ar.arg.label() +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
                                         ": Bad argument value: " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
                                         ar.getText(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
                                    "Bad argument", JOptionPane.ERROR_MESSAGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
                        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
                    ar.install();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
                try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
                    if (runtime.explictStart(connector, args)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
                        dialog.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
                        dialog.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
                    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
                        JOptionPane.showMessageDialog(dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
                           "Bad arguments values: See diagnostics window.",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
                           "Bad arguments", JOptionPane.ERROR_MESSAGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
                } catch (VMLaunchFailureException exc) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
                        JOptionPane.showMessageDialog(dialog,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
                           "Launch Failure: " + exc,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
                           "Launch Failed",JOptionPane.ERROR_MESSAGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
        } );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
        content.add(BorderLayout.SOUTH, buttonPanel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        dialog.pack();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
        dialog.show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    private JPanel okCancel(final JDialog dialog, ActionListener okListener) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
        JPanel buttonPanel = new JPanel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
        JButton ok = new JButton("OK");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
        JButton cancel = new JButton("Cancel");
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
        buttonPanel.add(ok);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
        buttonPanel.add(cancel);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        ok.addActionListener(okListener);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        cancel.addActionListener( new ActionListener() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
            public void actionPerformed(ActionEvent event) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
                dialog.setVisible(false);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
                dialog.dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
        } );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
        return buttonPanel;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
    static void queryAndLaunchVM(ExecutionManager runtime)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
                                         throws VMLaunchFailureException {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        LaunchTool lt = new LaunchTool(runtime);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        Connector connector = lt.selectConnector();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
        if (connector != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            lt.configureAndConnect(connector);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
}