blob: 899fe75233aa9896eb04210ad5cf119ff6785214 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
/*******************************************************************************
* Copyright (c) 2008, 2012 Code 9 Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Code 9 Corporation - initial API and implementation
* Ketan Padegaonkar <KetanPadegaonkar@gmail.com> - bug 241912
* Tomasz Zarna <tomasz.zarna@tasktop.com> - bug 299298
*******************************************************************************/
package org.eclipse.pde.internal.runtime.spy.sections;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.osgi.util.NLS;
import org.eclipse.pde.internal.runtime.PDERuntimeMessages;
import org.eclipse.pde.internal.runtime.spy.SpyFormToolkit;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.forms.editor.FormEditor;
import org.eclipse.ui.forms.editor.IFormPage;
import org.eclipse.ui.forms.widgets.*;
import org.eclipse.ui.handlers.HandlerUtil;
public class ActiveFormEditorSection implements ISpySection {
public void build(ScrolledForm form, SpyFormToolkit toolkit, ExecutionEvent event) {
final IWorkbenchPart part = HandlerUtil.getActivePart(event);
if (!(part instanceof FormEditor))
return;
FormEditor multiEditor = (FormEditor) part;
Shell shell = HandlerUtil.getActiveShell(event);
Object object = shell.getData();
if (object == null)
return;
IFormPage activePage = multiEditor.getActivePageInstance();
if (activePage == null)
return;
Section section = toolkit.createSection(form.getBody(), ExpandableComposite.TITLE_BAR);
section.setText(PDERuntimeMessages.ActiveFormEditorSection_Active_Form_Page);
FormText text = toolkit.createFormText(section, true);
section.setClient(text);
TableWrapData td = new TableWrapData();
td.align = TableWrapData.FILL;
td.grabHorizontal = true;
section.setLayoutData(td);
StringBuffer buffer = new StringBuffer();
buffer.append("<form>"); //$NON-NLS-1$
buffer.append(toolkit.createClassSection(text, NLS.bind(PDERuntimeMessages.SpyDialog_activePart_desc, "editor tab"), new Class[] {activePage.getClass()})); //$NON-NLS-1$
buffer.append("</form>"); //$NON-NLS-1$
text.setText(buffer.toString(), true, false);
text.layout();
}
}
|