@Override public void onDocumentComplete(NetworkEvent ne) { l.debug("onDocumentComplete " + ne.getURL()); try { context.setReference(ne.getURL()); progress.setValue(progress.getMaximum()); progress.setVisible(false); addressTextField.setText(ne.getURL()); String title = null != context.getBrowser().getDocument() ? context.getBrowser().getDocument().getTitle() : ""; context.getConsole().log("title: " + title); context.getSimpleBrowser().getAnalyzerFrame().setTitle(title); // 更新页面信息 context.getSimpleBrowser().getPageInfoPanel().update(); // 显示源代码 IDocument doc = context.getBrowser().getDocument(); if (null != doc) { context.getSimpleBrowser().setSource(doc.getBody().getParentElement().getInnerHTML()); } timer.cancel(); timer = null; if (couldProcess()) { process(); } } catch (Exception ex) { } }
@Override public void onProgressChange(NetworkEvent ne) { l.debug( "onProgressChange" + ((float) ne.getCurrentProgress() / (float) ne.getMaximumProgress())); float f = ((float) ne.getCurrentProgress() / (float) ne.getMaximumProgress()); progress.setValue((int) (progress.getMaximum() * f)); }
@Override public void onHTTPInterceptHeaders(NetworkEvent ne) { l.debug("onHTTPInterceptHeaders " + ne.getURL()); l.trace("Send Request Header:\n" + ne.getMutableRequestHeaders()); String userAgent = BrowserContext.getConfigure().getProperty("Browser", "User-Agent"); if (null != userAgent) { ne.getMutableRequestHeaders().addHeader("User-Agent", userAgent, true); } context.addRequestHeader(ne.getURL(), ne.getMutableRequestHeaders().toString()); }
@Override public void onHTTPResponse(NetworkEvent ne) { // l.debug("onHTTPResponse\n" + ne.getResponseHeaders()); l.debug("onHTTPResponse\n" + ne.getURL() + " : " + ne.getStatus() + " : " + ne.getStatusText()); l.debug("onHTTPResponse\n" + ne.getFrame()); context.addResponseHeader(ne.getURL(), ne.getResponseHeaders()); }
@Override public void onNetworkError(NetworkEvent ne) { l.debug("onNetworkError " + ne.getFailure()); }
@Override public void onNetworkStatus(NetworkEvent ne) { l.debug("onNetworkStatus " + ne.getStatus()); }