blob: acce5293863ebb3716b40c20233e3b66b36bd367 (
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
/*******************************************************************************
* Copyright (c) 2011 Wind River Systems, Inc. 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:
* Wind River Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.tcf.te.tcf.processes.ui.internal.explorer;
import org.eclipse.core.runtime.Assert;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.tcf.te.tcf.processes.ui.controls.ProcessesTreeControl;
import org.eclipse.tcf.te.tcf.processes.ui.internal.help.IContextHelpIds;
import org.eclipse.tcf.te.tcf.processes.ui.nls.Messages;
import org.eclipse.tcf.te.ui.forms.CustomFormToolkit;
import org.eclipse.tcf.te.ui.views.editor.AbstractEditorPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.forms.IManagedForm;
import org.eclipse.ui.forms.widgets.ExpandableComposite;
import org.eclipse.ui.forms.widgets.Section;
import org.eclipse.ui.forms.widgets.TableWrapData;
/**
* Processes editor page implementation.
*/
public class ProcessExplorerEditorPage extends AbstractEditorPage {
// The references to the pages subcontrol's (needed for disposal)
private ProcessesTreeControl treeControl;
// Reference to the form toolkit instance
private CustomFormToolkit toolkit = null;
/* (non-Javadoc)
* @see org.eclipse.ui.forms.editor.FormPage#dispose()
*/
@Override
public void dispose() {
if (treeControl != null) { treeControl.dispose(); treeControl = null; }
super.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.ui.forms.editor.FormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
*/
@Override
protected void createFormContent(IManagedForm managedForm) {
// Configure the managed form
configureManagedForm(managedForm);
// Get the form body
Composite body = managedForm.getForm().getBody();
// Create the toolkit instance
toolkit = new CustomFormToolkit(managedForm.getToolkit());
// Do create the content of the form now
doCreateFormContent(body, toolkit);
// Re-arrange the controls
managedForm.reflow(true);
}
/**
* Configure the managed form to be ready for usage.
*
* @param managedForm The managed form. Must be not <code>null</code>.
*/
protected void configureManagedForm(IManagedForm managedForm) {
Assert.isNotNull(managedForm);
// Configure main layout
Composite body = managedForm.getForm().getBody();
GridLayout layout = new GridLayout();
layout.marginHeight = 2; layout.marginWidth = 0;
body.setLayout(layout);
body.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
// Set context help id
PlatformUI.getWorkbench().getHelpSystem().setHelp(managedForm.getForm(), IContextHelpIds.PROCESS_EXPLORER_EDITOR_PAGE);
}
/**
* Do create the managed form content.
*
* @param parent The parent composite. Must be not <code>null</code>
* @param toolkit The {@link CustomFormToolkit} instance. Must be not <code>null</code>.
*/
protected void doCreateFormContent(Composite parent, CustomFormToolkit toolkit) {
Assert.isNotNull(parent);
Assert.isNotNull(toolkit);
Section section = toolkit.getFormToolkit().createSection(parent, ExpandableComposite.TITLE_BAR);
String title = Messages.ProcessExplorerTreeControl_section_title;
// Stretch to a length of 40 characters to make sure the title can be changed
// to hold and show text up to this length
while (title.length() < 40) {
title += " "; //$NON-NLS-1$
}
// Set the title to the section
section.setText(title);
section.setLayoutData(new GridData(GridData.FILL_BOTH));
// Create the client area
Composite client = toolkit.getFormToolkit().createComposite(section);
GridLayout layout = new GridLayout();
layout.marginWidth = 0; layout.marginHeight = 0;
client.setLayout(layout);
section.setClient(client);
// Setup the tree control
treeControl = doCreateTreeControl();
Assert.isNotNull(treeControl);
treeControl.setupFormPanel((Composite)section.getClient(), toolkit);
// Set the initial input
treeControl.getViewer().setInput(getEditorInputNode());
}
/**
* Creates and returns a tree control.
*
* @return The new tree control.
*/
protected ProcessesTreeControl doCreateTreeControl() {
return new ProcessesTreeControl(this);
}
/**
* Returns the associated tree control.
*
* @return The associated tree control or <code>null</code>.
*/
protected final ProcessesTreeControl getTreeControl() {
return treeControl;
}
}
|