use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.
the class MonitorTreeContentProvider method getChildren.
/**
* Returns an iterator over the child elements of the given element.
* <p>
* Note: The difference between this method and
* <code>IStructuredContentProvider.getElements</code> is
* that <code>getElements</code> is called to obtain the
* tree viewer's root elements, whereas <code>getChildren</code> is used
* to obtain the children of a given node in the tree
* (including a root).
* </p>
* <p>
* [Issue: Don't know what above is trying to say.
* See IStructuredContentProvider.getElements.
* ]
* </p>
*
* @param element the element
* @return an iterator over the child elements
* (element type: <code>Object</code>)
*/
public Object[] getChildren(Object element) {
if (element instanceof Integer) {
Integer in = (Integer) element;
List<Request> list = new ArrayList<Request>();
Request[] requests = MonitorUIPlugin.getInstance().getRequests();
if (requests != null) {
for (Request req : requests) {
if ((req.getLocalPort() == in.intValue()) && !(req instanceof ResendHTTPRequest))
list.add(req);
}
}
return list.toArray();
} else if (element instanceof Request) {
Request req = (Request) element;
ResendHTTPRequest[] rr = MonitorManager.getInstance().getResendRequests(req);
List<Request> list = new ArrayList<Request>();
if (rr != null) {
for (ResendHTTPRequest r : rr) list.add(r);
}
return list.toArray();
}
return null;
}
use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.
the class MonitorTreeContentProvider method getElements.
/*
* Returns an iterator over the elements belonging to the
* given element. These elements can be presented as rows in a table,
* items in a list, etc.
*/
public Object[] getElements(Object element) {
if (ROOT.equals(element)) {
List<Integer> list = new ArrayList<Integer>();
Request[] requests = MonitorUIPlugin.getInstance().getRequests();
if (requests != null) {
for (Request req : requests) {
Integer in = new Integer(req.getLocalPort());
if (!list.contains(in))
list.add(in);
}
}
return list.toArray();
}
return getChildren(element);
}
use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.
the class TCPIPProtocolAdapter method connect.
/**
* @see ProtocolAdapterDelegate#connect(IMonitor, Socket, Socket)
*/
public void connect(IMonitor monitor, Socket in, Socket out) throws IOException {
Request request = new Request((Monitor) monitor, IProtocolAdapter.TCPIP_PROTOCOL_ID, monitor.getLocalPort(), monitor.getRemoteHost(), monitor.getRemotePort());
Connection conn = new Connection(in, out);
map.put(monitor, conn);
TCPIPThread requestThread = new TCPIPThread(conn, request, in.getInputStream(), out.getOutputStream(), true);
requestThread.start();
new TCPIPThread(conn, request, out.getInputStream(), in.getOutputStream(), false).start();
}
use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.
the class MonitorView method createPartControl.
/**
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
*/
public void createPartControl(Composite parent) {
SashForm sashFparent = new SashForm(parent, SWT.VERTICAL);
sashFparent.setBackground(sashFparent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
GridLayout layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 4;
layout.verticalSpacing = 4;
sashFparent.setLayout(layout);
sashFparent.setLayoutData(new GridData(GridData.FILL_BOTH));
PlatformUI.getWorkbench().getHelpSystem().setHelp(sashFparent, ContextIds.VIEW);
// create tree panel
Composite treePanel = new Composite(sashFparent, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
treePanel.setLayout(layout);
GridData data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
data.heightHint = 110;
data.horizontalSpan = 2;
treePanel.setLayoutData(data);
tree = new Tree(treePanel, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL | SWT.SINGLE);
data = new GridData(GridData.FILL_BOTH);
// data.widthHint = 120;
tree.setLayoutData(data);
treeViewer = new TreeViewer(tree);
contentProvider = new MonitorTreeContentProvider();
treeViewer.setContentProvider(contentProvider);
treeViewer.setInput(MonitorTreeContentProvider.ROOT);
treeViewer.setLabelProvider(new TreeLabelProvider());
PlatformUI.getWorkbench().getHelpSystem().setHelp(tree, ContextIds.VIEW_TREE);
Composite detailsPanel = new Composite(treePanel, SWT.NONE);
layout = new GridLayout();
layout.numColumns = 1;
layout.marginHeight = 2;
layout.marginWidth = 0;
detailsPanel.setLayout(layout);
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
data.widthHint = 350;
detailsPanel.setLayoutData(data);
final Text detailsTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsTimeText.setText(NLS.bind(Messages.viewTime, ""));
detailsTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
final Text detailsResponseTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
detailsResponseTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
final Text detailsViewTimeText = new Text(detailsPanel, SWT.READ_ONLY);
detailsViewTimeText.setText(NLS.bind(Messages.viewType, ""));
detailsViewTimeText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
// create center and right panels
SashForm sashFchild = new SashForm(sashFparent, SWT.HORIZONTAL);
layout = new GridLayout();
layout.numColumns = 2;
layout.horizontalSpacing = 2;
layout.verticalSpacing = 4;
sashFchild.setLayout(layout);
sashFparent.setWeights(new int[] { 30, 70 });
// request panel
Composite request = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.marginHeight = 0;
layout.marginWidth = 0;
request.setLayout(layout);
request.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite requestHeader = new Composite(request, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
requestHeader.setLayout(layout);
requestHeader.setLayoutData(data);
final Label requestViewerComboLabel = new Label(requestHeader, SWT.NONE);
requestViewerComboLabel.setText(NLS.bind(Messages.viewRequestType, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalIndent = 3;
requestViewerComboLabel.setLayoutData(data);
final Combo requestViewerCombo = new Combo(requestHeader, SWT.DROP_DOWN | SWT.READ_ONLY);
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
requestViewerCombo.setLayoutData(data);
final Text requestLabel = new Text(requestHeader, SWT.READ_ONLY);
requestLabel.setText(NLS.bind(Messages.viewRequest, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestLabel.setLayoutData(data);
final Text requestSizeLabel = new Text(requestHeader, SWT.READ_ONLY);
requestSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestSizeLabel.setLayoutData(data);
// response panel
Composite response = new Composite(sashFchild, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 3;
layout.marginHeight = 0;
layout.marginWidth = 0;
response.setLayout(layout);
response.setLayoutData(new GridData(GridData.FILL_BOTH));
Composite responseHeader = new Composite(response, SWT.NONE);
layout = new GridLayout();
layout.verticalSpacing = 1;
layout.numColumns = 2;
layout.marginHeight = 0;
layout.marginWidth = 0;
layout.marginLeft = 0;
data = new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
responseHeader.setLayout(layout);
responseHeader.setLayoutData(data);
final Label responseViewerComboLabel = new Label(responseHeader, SWT.NONE);
responseViewerComboLabel.setText(NLS.bind(Messages.viewResponseType, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalIndent = 3;
responseViewerComboLabel.setLayoutData(data);
final Combo responseViewerCombo = new Combo(responseHeader, SWT.DROP_DOWN | SWT.READ_ONLY);
data = new GridData(GridData.HORIZONTAL_ALIGN_END);
data.verticalSpan = 1;
responseViewerCombo.setLayoutData(data);
final Text responseLabel = new Text(responseHeader, SWT.READ_ONLY);
responseLabel.setText(NLS.bind(Messages.viewResponse, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
requestLabel.setLayoutData(data);
final Text responseSizeLabel = new Text(responseHeader, SWT.READ_ONLY);
responseSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
data = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
data.verticalSpan = 1;
data.horizontalSpan = 2;
responseSizeLabel.setLayoutData(data);
// viewer manager
vm = new ViewerManager(request, response);
requestViewers = vm.getRequestViewers();
responseViewers = vm.getResponseViewers();
// set up the viewer combo boxes
Iterator iterator = requestViewers.iterator();
int ctr = 0;
while (iterator.hasNext()) {
Viewer viewer = (Viewer) iterator.next();
requestViewerCombo.add(viewer.getLabel(), ctr);
if (viewer.getId().equals(DEFAULT_VIEWER)) {
requestViewerCombo.select(ctr);
vm.setRequestViewer(viewer);
}
ctr++;
}
requestViewerCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Viewer viewer = (Viewer) requestViewers.get(requestViewerCombo.getSelectionIndex());
if (currentRequest != null && viewer != null)
currentRequest.setProperty("request-viewer", viewer.getId());
vm.setRequestViewer(viewer);
}
public void widgetDefaultSelected(SelectionEvent e) {
// ignore
}
});
requestHeader.layout(true);
iterator = responseViewers.iterator();
ctr = 0;
while (iterator.hasNext()) {
Viewer viewer = (Viewer) iterator.next();
responseViewerCombo.add(viewer.getLabel(), ctr);
if (viewer.getId().equals(DEFAULT_VIEWER)) {
responseViewerCombo.select(ctr);
vm.setResponseViewer(viewer);
}
ctr++;
}
responseViewerCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
Viewer viewer = (Viewer) responseViewers.get(responseViewerCombo.getSelectionIndex());
if (currentRequest != null && viewer != null)
currentRequest.setProperty("response-viewer", viewer.getId());
vm.setResponseViewer(viewer);
}
public void widgetDefaultSelected(SelectionEvent e) {
// ignore
}
});
responseHeader.layout(true);
// selection listener
treeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
public void selectionChanged(SelectionChangedEvent event) {
ISelection selection = event.getSelection();
currentRequest = null;
if (selection != null && !selection.isEmpty()) {
StructuredSelection sel = (StructuredSelection) selection;
currentSelection = sel;
Object obj = sel.iterator().next();
if (obj instanceof Request)
currentRequest = (Request) obj;
}
if (currentRequest != null) {
detailsTimeText.setText(NLS.bind(Messages.viewTime, format.format(currentRequest.getDate())));
if (currentRequest.getResponseTime() == -1)
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
else {
String time = NLS.bind(Messages.viewResponseTimeFormat, currentRequest.getResponseTime() + "");
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, time));
}
detailsViewTimeText.setText(NLS.bind(Messages.viewType, currentRequest.getProtocol()));
// request information
requestLabel.setText(NLS.bind(Messages.viewRequest, "localhost:" + currentRequest.getLocalPort()));
requestSizeLabel.setText(getSizeString(currentRequest.getRequest(Request.CONTENT), currentRequest.getRequest(Request.ALL)));
// response information
responseLabel.setText(NLS.bind(Messages.viewResponse, currentRequest.getRemoteHost() + ":" + currentRequest.getRemotePort()));
responseSizeLabel.setText(getSizeString(currentRequest.getResponse(Request.CONTENT), currentRequest.getResponse(Request.ALL)));
vm.setRequest(currentRequest);
Viewer viewer = vm.findViewer((String) currentRequest.getProperty("request-viewer"));
if (viewer == null)
viewer = vm.findViewer(DEFAULT_VIEWER);
if (viewer != null) {
vm.setRequestViewer(viewer);
requestViewerCombo.select(requestViewers.indexOf(viewer));
}
viewer = vm.findViewer((String) currentRequest.getProperty("response-viewer"));
if (viewer == null && currentRequest.getName() != null)
viewer = vm.getDefaultViewer(currentRequest.getName());
if (viewer != null) {
vm.setResponseViewer(viewer);
responseViewerCombo.select(responseViewers.indexOf(viewer));
}
} else {
detailsTimeText.setText(NLS.bind(Messages.viewTime, ""));
detailsResponseTimeText.setText(NLS.bind(Messages.viewResponseTime, ""));
requestLabel.setText(NLS.bind(Messages.viewRequest, ""));
requestSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
responseLabel.setText(NLS.bind(Messages.viewResponse, ""));
responseSizeLabel.setText(NLS.bind(Messages.viewSize, ""));
vm.setRequest(currentRequest);
}
}
});
treeViewer.expandToLevel(2);
// create a menu manager for a context menu
MenuManager menuManager = new MenuManager();
menuManager.setRemoveAllWhenShown(true);
menuManager.addMenuListener(new IMenuListener() {
public void menuAboutToShow(IMenuManager menu) {
menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
menu.add(preferenceAction);
}
});
// create the menu
Menu menu = menuManager.createContextMenu(treeViewer.getControl());
treeViewer.getControl().setMenu(menu);
// register the menu with the platform
getSite().registerContextMenu(menuManager, treeViewer);
initializeActions();
}
use of org.eclipse.wst.internet.monitor.core.internal.provisional.Request in project webtools.servertools by eclipse.
the class HTTPConnection method addProperty.
/**
* Add a property.
*
* @param key
* @param value
*/
public void addProperty(String key, Object value) {
Request request = getRequestResponse(req);
request.setProperty(key, value);
}
Aggregations