}
public void consolesAdded(IConsole[] consoles) {
for (IConsole c : consoles) {
if (c instanceof IOConsole) {
final IOConsole p = (IOConsole) c;
Object attribute = p
.getAttribute("org.eclipse.debug.ui.ATTR_CONSOLE_PROCESS");
if (attribute != null) {
IProcess pr = (IProcess) attribute;
ILaunch launch = pr.getLaunch();
ILaunchConfiguration launchConfiguration = launch
.getLaunchConfiguration();
Map<?, ?> attributes = null;
try {
attributes = launchConfiguration
.getAttributes();
} catch (CoreException e1) {
Activator.log(e1);
return;
}
final String project = (String) attributes
.get(ORG_ECLIPSE_JDT_LAUNCHING_PROJECT_ATTR);
try {
ILaunchConfigurationType type = launchConfiguration
.getType();
String identifier = type.getIdentifier();
if (identifier
.equals(COM_GOOGLE_GDT_ECLIPSE_SUITE_WEBAPP)) {
p.getDocument().addDocumentListener(
new IDocumentListener() {
public void documentChanged(
DocumentEvent event) {
String mark = "The server is running at ";
int indexOf = event
.getText().indexOf(
mark);
if (indexOf != -1) {
String substring = event
.getText()
.substring(
indexOf
+ mark.length());
int lastIndexOf = substring
.lastIndexOf(':');
if (lastIndexOf != -1) {
String substring2 = substring
.substring(lastIndexOf + 1);
int lastIndexOf2 = substring2
.indexOf('/');
if (lastIndexOf2 != -1) {
substring2 = substring2
.substring(
0,
lastIndexOf2);
}
int port = Integer
.parseInt(substring2);
knownLaucnhes.put(
project,
port);
p.getDocument()
.removeDocumentListener(
this);
}
}