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.jface.wizard.IWizard;
14: import org.eclipse.jface.wizard.IWizardPage;
15: import org.eclipse.jface.wizard.WizardDialog;
16: import org.eclipse.osgi.util.NLS;
17: import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
18: import org.eclipse.pde.internal.runtime.PDERuntimePlugin;
19: import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit;
20: import org.eclipse.swt.widgets.Shell;
21: import org.eclipse.ui.forms.widgets.ExpandableComposite;
22: import org.eclipse.ui.forms.widgets.FormText;
23: import org.eclipse.ui.forms.widgets.ScrolledForm;
24: import org.eclipse.ui.forms.widgets.Section;
25: import org.eclipse.ui.forms.widgets.TableWrapData;
26: import org.eclipse.ui.handlers.HandlerUtil;
27: import org.osgi.framework.Bundle;
28: import org.osgi.service.packageadmin.PackageAdmin;
29:
30: public class ActiveWizardSection implements ISpySection {
31:
32: public void build(ScrolledForm form, SpyFormToolkit toolkit,
33: ExecutionEvent event) {
34: final Shell shell = HandlerUtil.getActiveShell(event);
35: Object object = shell.getData();
36: if (object == null)
37: return;
38: Class clazz = object.getClass();
39:
40: if (object instanceof WizardDialog) {
41: WizardDialog dialog = (WizardDialog) object;
42: IWizardPage page = dialog.getCurrentPage();
43: IWizard wizard = page.getWizard();
44: clazz = wizard.getClass();
45:
46: Section section = toolkit.createSection(form.getBody(),
47: ExpandableComposite.TITLE_BAR);
48:
49: // the active wizard
50: FormText text = toolkit.createFormText(section, true);
51: section.setClient(text);
52: TableWrapData td = new TableWrapData();
53: td.align = TableWrapData.FILL;
54: td.grabHorizontal = true;
55: section.setLayoutData(td);
56:
57: StringBuffer buffer = new StringBuffer();
58: buffer.append("<form>"); //$NON-NLS-1$
59: section.setText(NLS.bind(
60: PDERuntimeMessages.SpyDialog_activeWizard_title,
61: wizard.getWindowTitle()));
62:
63: buffer.append(toolkit.createClassSection(text,
64: PDERuntimeMessages.SpyDialog_activeWizard_desc,
65: new Class[] { clazz }));
66:
67: PackageAdmin admin = PDERuntimePlugin.getDefault()
68: .getPackageAdmin();
69: Bundle bundle = admin.getBundle(clazz);
70: toolkit.generatePluginDetailsText(bundle, null,
71: "wizard", buffer, text); //$NON-NLS-1$
72:
73: buffer.append(toolkit.createClassSection(text,
74: PDERuntimeMessages.SpyDialog_activeWizardPage_desc,
75: new Class[] { page.getClass() }));
76: buffer.append("</form>"); //$NON-NLS-1$
77:
78: text.setText(buffer.toString(), true, false);
79: }
80: }
81:
82: }
|