private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args) throws DebuggerException { if (bndlPrefix != null) { if (connector.transport().name().equals("dt_shmem")) { Argument a = (Argument) args.get("name"); if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_shmem")) .format(new Object[] {a.value()}), ERR_OUT); } else if (connector.transport().name().equals("dt_socket")) { Argument name = (Argument) args.get("hostname"); Argument port = (Argument) args.get("port"); if ((name == null) || (port == null)) println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT); else println( new MessageFormat(bundle.getString(bndlPrefix + "_socket")) .format(new Object[] {name.value(), port.value()}), ERR_OUT); } else println(bundle.getString(bndlPrefix), ERR_OUT); } // launch VM try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N return connector.attach(args); } catch (Exception e) { finishDebugger(); throw new DebuggerException( new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee")) .format(new Object[] {e.toString()}), e); } }
/** @return name of proces for given DebuggerInfo. */ public String getProcessName(DebuggerInfo info) { if (info instanceof RemoteDebuggerInfo) { if (((RemoteDebuggerInfo) info).getConnector().transport().name().equals("dt_shmem")) { Argument a = (Argument) ((RemoteDebuggerInfo) info).getArgs().get("name"); if (a == null) return "localhost:???"; else return "localhost:" + a.value(); } else if (((RemoteDebuggerInfo) info) .getConnector() .transport() .name() .equals("dt_socket")) { Argument name = (Argument) ((RemoteDebuggerInfo) info).getArgs().get("hostname"); Argument port = (Argument) ((RemoteDebuggerInfo) info).getArgs().get("port"); return ((name == null) ? "???:" : (name.value() + ":")) + ((port == null) ? "???" : (port.value())); } else return "???"; } else return (info.getStopClassName() != null) ? info.getStopClassName() : info.getClassName(); }
/** @return name of location for given DebuggerInfo. */ public String getLocationName(DebuggerInfo info) { if (info instanceof RemoteDebuggerInfo) { if (((RemoteDebuggerInfo) info).getConnector().transport().name().equals("dt_shmem")) { return "localhost"; } else if (((RemoteDebuggerInfo) info) .getConnector() .transport() .name() .equals("dt_socket")) { Argument name = (Argument) ((RemoteDebuggerInfo) info).getArgs().get("hostname"); return name == null ? "localhost" : name.value(); } else return "localhost"; } else return "localhost"; }
private void refresh(int index) { GridBagConstraints c = new GridBagConstraints(); // No connector ................ if (acs.size() == 0) { add(new JLabel(bundle.getString("CTL_No_Connector")), c); return; } // Connector switch ................ if (acs.size() > 1) { c.insets = new Insets(0, 0, 3, 3); add(new JLabel(bundle.getString("CTL_Connector")), c); cbConnectors = new JComboBox(); int i, k = acs.size(); for (i = 0; i < k; i++) { AttachingConnector ac = (AttachingConnector) acs.get(i); int jj = ac.name().lastIndexOf('.'); String s = (jj < 0) ? ac.name() : ac.name().substring(jj + 1); cbConnectors.addItem(s + " (" + ac.description() + ")"); } c = new GridBagConstraints(); c.insets = new Insets(0, 3, 3, 0); c.weightx = 1.0; c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.gridwidth = 0; cbConnectors.setSelectedIndex(index); cbConnectors.setActionCommand("SwitchMe!"); cbConnectors.addActionListener(this); add(cbConnectors, c); } ac = (AttachingConnector) acs.get(index); // Transport ................ c = new GridBagConstraints(); c.insets = new Insets(3, 0, 0, 3); add(new JLabel(bundle.getString("CTL_Transport")), c); JTextField tfTransport = new JTextField(ac.transport().name()); tfTransport.setEnabled(false); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(3, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfTransport, c); // Other params ................ args = ac.defaultArguments(); tfParams = new JTextField[args.size()]; Iterator it = args.keySet().iterator(); int i = 0; while (it.hasNext()) { String name = (String) it.next(); Argument a = (Argument) args.get(name); c = new GridBagConstraints(); c.insets = new Insets(6, 0, 0, 3); c.anchor = GridBagConstraints.WEST; add(new JLabel(a.label() + ": "), c); JTextField tfParam = new JTextField(a.value()); tfParams[i++] = tfParam; tfParam.setName(name); c = new GridBagConstraints(); c.gridwidth = 0; c.insets = new Insets(6, 3, 0, 0); c.fill = java.awt.GridBagConstraints.HORIZONTAL; c.weightx = 1.0; add(tfParam, c); } c = new GridBagConstraints(); c.weighty = 1.0; JPanel p = new JPanel(); p.setPreferredSize(new Dimension(1, 1)); add(p, c); }