01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * Chris Aniszczyk <zx@us.ibm.com> - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.runtime.spy.sections;
11:
12: import org.eclipse.core.commands.ExecutionEvent;
13: import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
14: import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit;
15: import org.eclipse.swt.widgets.Shell;
16: import org.eclipse.ui.forms.widgets.ExpandableComposite;
17: import org.eclipse.ui.forms.widgets.FormText;
18: import org.eclipse.ui.forms.widgets.ScrolledForm;
19: import org.eclipse.ui.forms.widgets.Section;
20: import org.eclipse.ui.forms.widgets.TableWrapData;
21: import org.eclipse.ui.handlers.HandlerUtil;
22:
23: public class ActiveShellSection implements ISpySection {
24:
25: public void build(ScrolledForm form, SpyFormToolkit toolkit,
26: ExecutionEvent event) {
27: final Shell shell = HandlerUtil.getActiveShell(event);
28: Object object = shell.getData();
29: if (object == null)
30: return;
31: Class clazz = object.getClass();
32:
33: Section section = toolkit.createSection(form.getBody(),
34: ExpandableComposite.TITLE_BAR);
35:
36: section.setText(PDERuntimeMessages.SpyDialog_activeShell_title);
37:
38: FormText text = toolkit.createFormText(section, true);
39: section.setClient(text);
40: TableWrapData td = new TableWrapData();
41: td.align = TableWrapData.FILL;
42: td.grabHorizontal = true;
43: section.setLayoutData(td);
44:
45: StringBuffer buffer = new StringBuffer();
46: buffer.append("<form>"); //$NON-NLS-1$
47:
48: buffer.append(toolkit.createClassSection(text,
49: PDERuntimeMessages.SpyDialog_activeShell_desc,
50: new Class[] { clazz }));
51:
52: buffer.append("</form>"); //$NON-NLS-1$
53: text.setText(buffer.toString(), true, false);
54: }
55:
56: }
|