|
Lines 11-35
Link Here
|
| 11 |
|
11 |
|
| 12 |
package org.eclipse.ui.internal.about; |
12 |
package org.eclipse.ui.internal.about; |
| 13 |
|
13 |
|
|
|
14 |
import org.eclipse.core.expressions.Expression; |
| 14 |
import org.eclipse.core.runtime.CoreException; |
15 |
import org.eclipse.core.runtime.CoreException; |
| 15 |
import org.eclipse.core.runtime.IConfigurationElement; |
16 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 16 |
import org.eclipse.core.runtime.IExtensionPoint; |
17 |
import org.eclipse.core.runtime.IExtensionPoint; |
|
|
18 |
import org.eclipse.core.runtime.IProduct; |
| 17 |
import org.eclipse.core.runtime.Platform; |
19 |
import org.eclipse.core.runtime.Platform; |
| 18 |
import org.eclipse.jface.action.ContributionManager; |
20 |
import org.eclipse.jface.action.ContributionManager; |
| 19 |
import org.eclipse.jface.action.IContributionItem; |
21 |
import org.eclipse.jface.action.IContributionItem; |
| 20 |
import org.eclipse.jface.action.ToolBarManager; |
|
|
| 21 |
import org.eclipse.jface.dialogs.Dialog; |
22 |
import org.eclipse.jface.dialogs.Dialog; |
| 22 |
import org.eclipse.jface.dialogs.IDialogConstants; |
23 |
import org.eclipse.jface.dialogs.IDialogConstants; |
| 23 |
import org.eclipse.jface.resource.ColorRegistry; |
24 |
import org.eclipse.jface.dialogs.IDialogSettings; |
| 24 |
import org.eclipse.jface.resource.JFaceResources; |
25 |
import org.eclipse.osgi.util.NLS; |
| 25 |
import org.eclipse.swt.SWT; |
26 |
import org.eclipse.swt.SWT; |
| 26 |
import org.eclipse.swt.custom.CTabFolder; |
|
|
| 27 |
import org.eclipse.swt.custom.CTabItem; |
| 28 |
import org.eclipse.swt.events.DisposeEvent; |
27 |
import org.eclipse.swt.events.DisposeEvent; |
| 29 |
import org.eclipse.swt.events.DisposeListener; |
28 |
import org.eclipse.swt.events.DisposeListener; |
| 30 |
import org.eclipse.swt.events.SelectionAdapter; |
29 |
import org.eclipse.swt.events.SelectionAdapter; |
| 31 |
import org.eclipse.swt.events.SelectionEvent; |
30 |
import org.eclipse.swt.events.SelectionEvent; |
| 32 |
import org.eclipse.swt.graphics.Color; |
|
|
| 33 |
import org.eclipse.swt.graphics.FontMetrics; |
31 |
import org.eclipse.swt.graphics.FontMetrics; |
| 34 |
import org.eclipse.swt.graphics.GC; |
32 |
import org.eclipse.swt.graphics.GC; |
| 35 |
import org.eclipse.swt.graphics.Point; |
33 |
import org.eclipse.swt.graphics.Point; |
|
Lines 39-77
Link Here
|
| 39 |
import org.eclipse.swt.widgets.Control; |
37 |
import org.eclipse.swt.widgets.Control; |
| 40 |
import org.eclipse.swt.widgets.Label; |
38 |
import org.eclipse.swt.widgets.Label; |
| 41 |
import org.eclipse.swt.widgets.Shell; |
39 |
import org.eclipse.swt.widgets.Shell; |
| 42 |
import org.eclipse.swt.widgets.ToolBar; |
40 |
import org.eclipse.swt.widgets.TabFolder; |
| 43 |
import org.eclipse.ui.IWorkbenchPreferenceConstants; |
41 |
import org.eclipse.swt.widgets.TabItem; |
| 44 |
import org.eclipse.ui.PlatformUI; |
42 |
import org.eclipse.ui.about.ActiveInstallationPageExpression; |
| 45 |
import org.eclipse.ui.about.IInstallationPageContainer; |
43 |
import org.eclipse.ui.about.IInstallationPageContainer; |
| 46 |
import org.eclipse.ui.about.InstallationPage; |
44 |
import org.eclipse.ui.about.InstallationPage; |
| 47 |
import org.eclipse.ui.internal.IWorkbenchThemeConstants; |
45 |
import org.eclipse.ui.internal.ConfigurationInfo; |
| 48 |
import org.eclipse.ui.internal.menus.InternalMenuService; |
46 |
import org.eclipse.ui.internal.WorkbenchMessages; |
| 49 |
import org.eclipse.ui.internal.menus.SlaveMenuService; |
47 |
import org.eclipse.ui.internal.WorkbenchPlugin; |
| 50 |
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; |
48 |
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants; |
|
|
49 |
import org.eclipse.ui.internal.services.IServiceLocatorCreator; |
| 51 |
import org.eclipse.ui.menus.IMenuService; |
50 |
import org.eclipse.ui.menus.IMenuService; |
|
|
51 |
import org.eclipse.ui.services.AbstractServiceFactory; |
| 52 |
import org.eclipse.ui.services.IDisposable; |
| 52 |
import org.eclipse.ui.services.IServiceLocator; |
53 |
import org.eclipse.ui.services.IServiceLocator; |
|
|
54 |
import org.eclipse.ui.services.ISourceProviderService; |
| 53 |
|
55 |
|
| 54 |
/** |
56 |
/** |
| 55 |
* @since 3.5 |
57 |
* @since 3.5 |
| 56 |
* |
58 |
* |
| 57 |
*/ |
59 |
*/ |
| 58 |
public class InstallationDialog extends Dialog { |
60 |
public class InstallationDialog extends Dialog implements |
| 59 |
private static final String ID = "ID"; //$NON-NLS-1$ |
61 |
IInstallationPageContainer { |
|
|
62 |
class ButtonManager extends ContributionManager { |
| 60 |
|
63 |
|
| 61 |
private CTabFolder folder; |
64 |
private Composite composite; |
|
|
65 |
|
| 66 |
public ButtonManager(Composite composite) { |
| 67 |
this.composite = composite; |
| 68 |
} |
| 69 |
|
| 70 |
public Composite getParent() { |
| 71 |
return composite; |
| 72 |
} |
| 73 |
|
| 74 |
/* |
| 75 |
* (non-Javadoc) |
| 76 |
* |
| 77 |
* @see org.eclipse.jface.action.IContributionManager#update(boolean) |
| 78 |
*/ |
| 79 |
public void update(boolean force) { |
| 80 |
if (composite == null || composite.isDisposed()) |
| 81 |
return; |
| 82 |
GC metricsGC = new GC(composite); |
| 83 |
FontMetrics metrics = metricsGC.getFontMetrics(); |
| 84 |
metricsGC.dispose(); |
| 85 |
IContributionItem[] items = getItems(); |
| 86 |
Control[] children = composite.getChildren(); |
| 87 |
|
| 88 |
int visibleChildren = 0; |
| 89 |
for (int i = 0; i < children.length; i++) { |
| 90 |
Control control = children[i]; |
| 91 |
control.dispose(); |
| 92 |
} |
| 93 |
|
| 94 |
for (int i = 0; i < items.length; i++) { |
| 95 |
IContributionItem item = items[i]; |
| 96 |
if (item.isVisible()) { |
| 97 |
item.fill(composite); |
| 98 |
children = composite.getChildren(); |
| 99 |
Control itemControl = children[children.length - 1]; |
| 100 |
setButtonLayoutData(metrics, itemControl); |
| 101 |
visibleChildren++; |
| 102 |
} |
| 103 |
} |
| 104 |
GridLayout compositeLayout = (GridLayout) composite.getLayout(); |
| 105 |
compositeLayout.numColumns = visibleChildren; |
| 106 |
composite.layout(true); |
| 107 |
} |
| 108 |
|
| 109 |
protected void setButtonLayoutData(FontMetrics metrics, Control button) { |
| 110 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
| 111 |
int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics, |
| 112 |
IDialogConstants.BUTTON_WIDTH); |
| 113 |
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
| 114 |
data.widthHint = Math.max(widthHint, minSize.x); |
| 115 |
button.setLayoutData(data); |
| 116 |
} |
| 117 |
|
| 118 |
} |
| 119 |
|
| 120 |
protected static final String ID = "ID"; //$NON-NLS-1$ |
| 121 |
private static final String DIALOG_SETTINGS_SECTION = "InstallationDialogSettings"; //$NON-NLS-1$ |
| 122 |
private static final String URI = "toolbar:org.eclipse.ui.installationDialog.buttonbar"; //$NON-NLS-1$ |
| 123 |
private TabFolder folder; |
| 62 |
private IServiceLocator serviceLocator; |
124 |
private IServiceLocator serviceLocator; |
| 63 |
private ToolBarManager toolbarManager; |
|
|
| 64 |
private ButtonManager buttonManager; |
125 |
private ButtonManager buttonManager; |
| 65 |
private IMenuService menuService = null; |
126 |
private InstallationDialogSourceProvider sourceProvider = null; |
| 66 |
|
127 |
|
| 67 |
/** |
128 |
/** |
| 68 |
* @param parentShell |
129 |
* @param parentShell |
|
|
130 |
* @param locator |
| 69 |
*/ |
131 |
*/ |
| 70 |
protected InstallationDialog(Shell parentShell, IServiceLocator locator) { |
132 |
public InstallationDialog(Shell parentShell, IServiceLocator locator) { |
| 71 |
super(parentShell); |
133 |
super(parentShell); |
| 72 |
this.serviceLocator = locator; |
134 |
IServiceLocatorCreator slc = (IServiceLocatorCreator) locator |
| 73 |
menuService = new SlaveMenuService((InternalMenuService) serviceLocator |
135 |
.getService(IServiceLocatorCreator.class); |
| 74 |
.getService(IMenuService.class), serviceLocator, null); |
136 |
createDialogServiceLocator(slc, locator); |
|
|
137 |
ISourceProviderService sps = (ISourceProviderService) serviceLocator |
| 138 |
.getService(ISourceProviderService.class); |
| 139 |
sourceProvider = (InstallationDialogSourceProvider) sps |
| 140 |
.getSourceProvider(InstallationDialogSourceProvider.ACTIVE_PRODUCT_DIALOG_PAGE); |
| 75 |
|
141 |
|
| 76 |
} |
142 |
} |
| 77 |
|
143 |
|
|
Lines 84-101
Link Here
|
| 84 |
*/ |
150 |
*/ |
| 85 |
protected void configureShell(Shell newShell) { |
151 |
protected void configureShell(Shell newShell) { |
| 86 |
super.configureShell(newShell); |
152 |
super.configureShell(newShell); |
| 87 |
// TODO |
153 |
String productName = ""; //$NON-NLS-1$ |
| 88 |
// This should use the title of the about dialog, this |
154 |
IProduct product = Platform.getProduct(); |
| 89 |
// is a temporary hack so that p2 can launch the dialog |
155 |
if (product != null && product.getName() != null) |
| 90 |
// with a proper title until this is actually hooked into |
156 |
productName = product.getName(); |
| 91 |
// the about dialog. |
157 |
newShell.setText(NLS.bind( |
| 92 |
newShell.setText("Installation Information"); //$NON-NLS-1$ |
158 |
WorkbenchMessages.InstallationDialog_ShellTitle, productName)); |
| 93 |
newShell.setSize(600, 768); |
|
|
| 94 |
|
| 95 |
} |
159 |
} |
| 96 |
|
160 |
|
| 97 |
/* |
161 |
/* |
| 98 |
* (non-Javadoc) |
162 |
* (non-Javadoc) |
|
|
163 |
* |
| 99 |
* @see org.eclipse.jface.dialogs.Dialog#isResizable() |
164 |
* @see org.eclipse.jface.dialogs.Dialog#isResizable() |
| 100 |
*/ |
165 |
*/ |
| 101 |
protected boolean isResizable() { |
166 |
protected boolean isResizable() { |
|
Lines 112-214
Link Here
|
| 112 |
protected Control createDialogArea(Composite parent) { |
177 |
protected Control createDialogArea(Composite parent) { |
| 113 |
Composite composite = (Composite) super.createDialogArea(parent); |
178 |
Composite composite = (Composite) super.createDialogArea(parent); |
| 114 |
|
179 |
|
| 115 |
createToolbar(composite); |
180 |
folder = new TabFolder(composite, SWT.NONE); |
| 116 |
|
|
|
| 117 |
folder = new CTabFolder(composite, SWT.MULTI | SWT.BORDER); |
| 118 |
configureFolder(); |
181 |
configureFolder(); |
|
|
182 |
createFolderItems(folder); |
| 183 |
|
| 119 |
GridData folderData = new GridData(SWT.FILL, SWT.FILL, true, true); |
184 |
GridData folderData = new GridData(SWT.FILL, SWT.FILL, true, true); |
| 120 |
folderData.widthHint = SWT.DEFAULT; |
185 |
folderData.widthHint = SWT.DEFAULT; |
| 121 |
folderData.heightHint = SWT.DEFAULT; |
186 |
folderData.heightHint = SWT.DEFAULT; |
| 122 |
folder.setLayoutData(folderData); |
187 |
folder.setLayoutData(folderData); |
|
|
188 |
folder.addSelectionListener(createFolderSelectionListener()); |
| 189 |
folder.addDisposeListener(new DisposeListener() { |
| 190 |
public void widgetDisposed(DisposeEvent e) { |
| 191 |
releaseContributions(); |
| 192 |
resetVariables(sourceProvider); |
| 193 |
} |
| 194 |
}); |
| 195 |
return composite; |
| 196 |
} |
| 123 |
|
197 |
|
| 124 |
IConfigurationElement[] elements = loadElements(); |
198 |
protected void createFolderItems(TabFolder folder) { |
|
|
199 |
IConfigurationElement[] elements = ConfigurationInfo |
| 200 |
.getSortedExtensions(loadElements()); |
| 125 |
for (int i = 0; i < elements.length; i++) { |
201 |
for (int i = 0; i < elements.length; i++) { |
| 126 |
IConfigurationElement element = elements[i]; |
202 |
IConfigurationElement element = elements[i]; |
| 127 |
CTabItem item = new CTabItem(folder, SWT.NONE); |
203 |
TabItem item = new TabItem(folder, SWT.NONE); |
| 128 |
item.setText(element |
204 |
item.setText(element |
| 129 |
.getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); |
205 |
.getAttribute(IWorkbenchRegistryConstants.ATT_NAME)); |
| 130 |
item.setData(element); |
206 |
item.setData(element); |
| 131 |
Composite control = new Composite(folder, SWT.BORDER); |
207 |
Composite control = new Composite(folder, SWT.BORDER); |
| 132 |
control.setLayout(new GridLayout()); |
208 |
control.setLayout(new GridLayout()); |
| 133 |
item.setControl(control); |
209 |
item.setControl(control); |
| 134 |
|
|
|
| 135 |
} |
210 |
} |
| 136 |
folder.addSelectionListener(createFolderSelectionListener()); |
211 |
} |
| 137 |
return composite; |
212 |
|
|
|
213 |
protected Control createContents(Composite parent) { |
| 214 |
Control control = super.createContents(parent); |
| 215 |
if (folder.getItemCount() > 0) |
| 216 |
tabSelected(folder.getItem(0)); |
| 217 |
return control; |
| 138 |
} |
218 |
} |
| 139 |
|
219 |
|
| 140 |
private SelectionAdapter createFolderSelectionListener() { |
220 |
private SelectionAdapter createFolderSelectionListener() { |
| 141 |
return new SelectionAdapter() { |
221 |
return new SelectionAdapter() { |
| 142 |
|
222 |
|
| 143 |
public void widgetSelected(SelectionEvent e) { |
223 |
public void widgetSelected(SelectionEvent e) { |
| 144 |
final CTabItem item = (CTabItem) e.item; |
224 |
tabSelected((TabItem) e.item); |
| 145 |
String id = null; |
|
|
| 146 |
if (item.getData() instanceof IConfigurationElement) { |
| 147 |
final IConfigurationElement element = (IConfigurationElement) item |
| 148 |
.getData(); |
| 149 |
|
| 150 |
id = element |
| 151 |
.getAttribute(IWorkbenchRegistryConstants.ATT_ID); |
| 152 |
item.setData(ID, id); |
| 153 |
|
| 154 |
Composite pageComposite = (Composite) item.getControl(); |
| 155 |
try { |
| 156 |
final InstallationPage page = (InstallationPage) element |
| 157 |
.createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS); |
| 158 |
page.createControl(pageComposite); |
| 159 |
page.init(createDialogServiceLocator(item)); |
| 160 |
item.setData(page); |
| 161 |
item.addDisposeListener(new DisposeListener() { |
| 162 |
|
| 163 |
public void widgetDisposed(DisposeEvent e) { |
| 164 |
page.dispose(); |
| 165 |
} |
| 166 |
}); |
| 167 |
pageComposite.layout(true, true); |
| 168 |
|
| 169 |
} catch (CoreException e1) { |
| 170 |
Label label = new Label(pageComposite, SWT.NONE); |
| 171 |
label.setText(e1.getMessage()); |
| 172 |
item.setData(null); |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
} else { |
| 177 |
id = (String) item.getData(ID); |
| 178 |
} |
| 179 |
|
| 180 |
menuService.releaseContributions(toolbarManager); |
| 181 |
menuService.populateContributionManager(toolbarManager, |
| 182 |
InstallationDialog.this.getToolbarURI(id)); |
| 183 |
toolbarManager.update(true); |
| 184 |
|
| 185 |
menuService.releaseContributions(buttonManager); |
| 186 |
menuService.populateContributionManager(buttonManager, |
| 187 |
InstallationDialog.this.getButtonBarURI(id)); |
| 188 |
buttonManager.update(true); |
| 189 |
createButton(buttonManager.getParent(), IDialogConstants.OK_ID, |
| 190 |
IDialogConstants.OK_LABEL, true); |
| 191 |
// Layout the button manager again now that the OK button is there. |
| 192 |
// Must do this before we layout the button bar or else the button |
| 193 |
// manager will not know about the OK button |
| 194 |
buttonManager.getParent().layout(); |
| 195 |
// Now we layout the button bar itself so it will accommodate the |
| 196 |
// button manager's buttons |
| 197 |
getButtonBar().getParent().layout(); |
| 198 |
} |
225 |
} |
| 199 |
}; |
226 |
}; |
| 200 |
} |
227 |
} |
| 201 |
|
228 |
|
| 202 |
private void createToolbar(Composite composite) { |
229 |
/* |
| 203 |
toolbarManager = new ToolBarManager(SWT.NONE); |
230 |
* Must be called after contributions and button manager are created. |
| 204 |
toolbarManager.createControl(composite); |
231 |
*/ |
| 205 |
ToolBar toolbar = toolbarManager.getControl(); |
232 |
private void tabSelected(TabItem item) { |
| 206 |
{ |
233 |
String id = null; |
| 207 |
GridData toolbarData = new GridData(SWT.FILL, SWT.FILL, true, false); |
234 |
if (item.getData() instanceof IConfigurationElement) { |
| 208 |
toolbarData.widthHint = SWT.DEFAULT; |
235 |
final IConfigurationElement element = (IConfigurationElement) item |
| 209 |
toolbarData.heightHint = SWT.DEFAULT; |
236 |
.getData(); |
| 210 |
toolbar.setLayoutData(toolbarData); |
237 |
|
|
|
238 |
id = element.getAttribute(IWorkbenchRegistryConstants.ATT_ID); |
| 239 |
item.setData(ID, id); |
| 240 |
|
| 241 |
Composite pageComposite = (Composite) item.getControl(); |
| 242 |
try { |
| 243 |
final InstallationPage page = (InstallationPage) element |
| 244 |
.createExecutableExtension(IWorkbenchRegistryConstants.ATT_CLASS); |
| 245 |
page.createControl(pageComposite); |
| 246 |
page.init(serviceLocator); |
| 247 |
item.setData(page); |
| 248 |
item.addDisposeListener(new DisposeListener() { |
| 249 |
|
| 250 |
public void widgetDisposed(DisposeEvent e) { |
| 251 |
page.dispose(); |
| 252 |
} |
| 253 |
}); |
| 254 |
pageComposite.layout(true, true); |
| 255 |
|
| 256 |
} catch (CoreException e1) { |
| 257 |
Label label = new Label(pageComposite, SWT.NONE); |
| 258 |
label.setText(e1.getMessage()); |
| 259 |
item.setData(null); |
| 260 |
} |
| 261 |
|
| 262 |
} else { |
| 263 |
id = (String) item.getData(ID); |
| 211 |
} |
264 |
} |
|
|
265 |
updateContributions(id, (InstallationPage) item.getData()); |
| 266 |
createButton(buttonManager.getParent(), IDialogConstants.OK_ID, |
| 267 |
IDialogConstants.OK_LABEL, true); |
| 268 |
// Layout the button manager again now that the OK button is there. |
| 269 |
// Must do this before we layout the button bar or else the button |
| 270 |
// manager will not know about the OK button |
| 271 |
buttonManager.getParent().layout(); |
| 272 |
// Now we layout the button bar itself so it will accommodate the |
| 273 |
// button manager's buttons |
| 274 |
getButtonBar().getParent().layout(); |
| 275 |
} |
| 276 |
|
| 277 |
protected void updateContributions(String id, InstallationPage page) { |
| 278 |
// Changing the source provider will cause the contributions and the |
| 279 |
// button manager to be updated. If for some reason we don't have a |
| 280 |
// source provider, update it ourselves. |
| 281 |
if (sourceProvider != null) |
| 282 |
sourceProvider.setCurrentPage(id, page); |
| 283 |
else |
| 284 |
buttonManager.update(true); |
| 285 |
} |
| 286 |
|
| 287 |
protected InstallationDialogSourceProvider getSourceProvider() { |
| 288 |
return sourceProvider; |
| 212 |
} |
289 |
} |
| 213 |
|
290 |
|
| 214 |
/* |
291 |
/* |
|
Lines 220-359
Link Here
|
| 220 |
*/ |
297 |
*/ |
| 221 |
protected void createButtonsForButtonBar(Composite parent) { |
298 |
protected void createButtonsForButtonBar(Composite parent) { |
| 222 |
buttonManager = new ButtonManager(parent); |
299 |
buttonManager = new ButtonManager(parent); |
|
|
300 |
((IMenuService) serviceLocator.getService(IMenuService.class)) |
| 301 |
.populateContributionManager(buttonManager, getButtonBarURI()); |
| 223 |
} |
302 |
} |
| 224 |
|
303 |
|
| 225 |
/** |
|
|
| 226 |
* @param folder2 |
| 227 |
*/ |
| 228 |
private void configureFolder() { |
304 |
private void configureFolder() { |
| 229 |
ColorRegistry reg = JFaceResources.getColorRegistry(); |
|
|
| 230 |
Color c1 = reg.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_START), c2 = reg |
| 231 |
.get(IWorkbenchThemeConstants.ACTIVE_TAB_BG_END); |
| 232 |
folder.setSelectionBackground(new Color[] { c1, c2 }, new int[] { 50 }, |
| 233 |
true); |
| 234 |
folder.setSelectionForeground(reg |
| 235 |
.get(IWorkbenchThemeConstants.ACTIVE_TAB_TEXT_COLOR)); |
| 236 |
folder.setSimple(PlatformUI.getPreferenceStore().getBoolean( |
| 237 |
IWorkbenchPreferenceConstants.SHOW_TRADITIONAL_STYLE_TABS)); |
| 238 |
|
| 239 |
} |
305 |
} |
| 240 |
|
306 |
|
| 241 |
/** |
|
|
| 242 |
* @return |
| 243 |
*/ |
| 244 |
private IConfigurationElement[] loadElements() { |
307 |
private IConfigurationElement[] loadElements() { |
| 245 |
IExtensionPoint point = Platform.getExtensionRegistry() |
308 |
IExtensionPoint point = Platform.getExtensionRegistry() |
| 246 |
.getExtensionPoint("org.eclipse.ui", "installationPages"); //$NON-NLS-1$ //$NON-NLS-2$ |
309 |
.getExtensionPoint("org.eclipse.ui", "installationPages"); //$NON-NLS-1$ //$NON-NLS-2$ |
| 247 |
return point.getConfigurationElements(); |
310 |
return point.getConfigurationElements(); |
| 248 |
} |
311 |
} |
| 249 |
|
312 |
|
| 250 |
private String getButtonBarURI(String id) { |
313 |
protected void createDialogServiceLocator(IServiceLocatorCreator slc, |
| 251 |
return "toolbar:org.eclipse.ui.installationDialog.buttonbar/" + id; //$NON-NLS-1$ |
314 |
IServiceLocator locator) { |
| 252 |
} |
315 |
AbstractServiceFactory localFactory = new AbstractServiceFactory() { |
| 253 |
|
316 |
public Object create(Class serviceInterface, |
| 254 |
protected String getToolbarURI(String id) { |
317 |
IServiceLocator parentLocator, IServiceLocator locator) { |
| 255 |
return "toolbar:org.eclipse.ui.installationDialog/" + id; //$NON-NLS-1$ |
318 |
if (serviceInterface == IInstallationPageContainer.class) { |
| 256 |
} |
319 |
return InstallationDialog.this; |
| 257 |
|
|
|
| 258 |
private IServiceLocator createDialogServiceLocator(final CTabItem item) { |
| 259 |
return new IServiceLocator() { |
| 260 |
|
| 261 |
public Object getService(Class api) { |
| 262 |
if (api == IInstallationPageContainer.class) |
| 263 |
return new IInstallationPageContainer() { |
| 264 |
|
| 265 |
public String getButtonBarURI() { |
| 266 |
return InstallationDialog.this |
| 267 |
.getButtonBarURI((String) item.getData(ID)); |
| 268 |
} |
| 269 |
|
| 270 |
public String getToolbarURI() { |
| 271 |
return InstallationDialog.this |
| 272 |
.getToolbarURI((String) item.getData(ID)); |
| 273 |
} |
| 274 |
|
| 275 |
public void updateMessage() { |
| 276 |
// TBD |
| 277 |
|
| 278 |
} |
| 279 |
|
| 280 |
public void close() { |
| 281 |
InstallationDialog.this.close(); |
| 282 |
} |
| 283 |
}; |
| 284 |
else if (api == IMenuService.class) { |
| 285 |
return menuService; |
| 286 |
} |
320 |
} |
| 287 |
return serviceLocator.getService(api); |
321 |
return parentLocator.getService(serviceInterface); |
| 288 |
} |
|
|
| 289 |
|
| 290 |
public boolean hasService(Class api) { |
| 291 |
if (api == IInstallationPageContainer.class) |
| 292 |
return true; |
| 293 |
return serviceLocator.hasService(api); |
| 294 |
} |
322 |
} |
| 295 |
}; |
323 |
}; |
|
|
324 |
this.serviceLocator = slc.createServiceLocator(locator, localFactory, |
| 325 |
new IDisposable() { |
| 326 |
public void dispose() { |
| 327 |
close(); |
| 328 |
} |
| 329 |
}); |
| 296 |
} |
330 |
} |
| 297 |
} |
|
|
| 298 |
|
331 |
|
| 299 |
class ButtonManager extends ContributionManager { |
332 |
protected IDialogSettings getDialogBoundsSettings() { |
|
|
333 |
IDialogSettings settings = WorkbenchPlugin.getDefault() |
| 334 |
.getDialogSettings(); |
| 335 |
IDialogSettings section = settings.getSection(DIALOG_SETTINGS_SECTION); |
| 336 |
if (section == null) { |
| 337 |
section = settings.addNewSection(DIALOG_SETTINGS_SECTION); |
| 338 |
} |
| 339 |
return section; |
| 340 |
} |
| 300 |
|
341 |
|
| 301 |
private Composite composite; |
342 |
protected void releaseContributions() { |
|
|
343 |
((IMenuService) serviceLocator.getService(IMenuService.class)) |
| 344 |
.releaseContributions(buttonManager); |
| 345 |
buttonManager.removeAll(); |
| 346 |
} |
| 302 |
|
347 |
|
| 303 |
/** |
348 |
/* |
|
|
349 |
* (non-Javadoc) |
| 304 |
* |
350 |
* |
|
|
351 |
* @see org.eclipse.ui.about.IInstallationPageContainer#getButtonBarURI() |
| 305 |
*/ |
352 |
*/ |
| 306 |
public ButtonManager(Composite composite) { |
353 |
public String getButtonBarURI() { |
| 307 |
this.composite = composite; |
354 |
return URI; |
| 308 |
} |
355 |
} |
| 309 |
|
356 |
|
| 310 |
/** |
357 |
public void closeContainer() { |
| 311 |
* @return |
358 |
close(); |
| 312 |
*/ |
359 |
} |
| 313 |
public Composite getParent() { |
360 |
|
| 314 |
return composite; |
361 |
protected IServiceLocator getDialogServiceLocator() { |
|
|
362 |
return serviceLocator; |
| 363 |
} |
| 364 |
|
| 365 |
protected ButtonManager getButtonManager() { |
| 366 |
return buttonManager; |
| 315 |
} |
367 |
} |
| 316 |
|
368 |
|
| 317 |
/* |
369 |
/* |
| 318 |
* (non-Javadoc) |
370 |
* (non-Javadoc) |
| 319 |
* |
371 |
* |
| 320 |
* @see org.eclipse.jface.action.IContributionManager#update(boolean) |
372 |
* @see |
|
|
373 |
* org.eclipse.ui.about.IInstallationPageContainer#getActivePageExpression |
| 374 |
* (org.eclipse.ui.about.InstallationPage) |
| 321 |
*/ |
375 |
*/ |
| 322 |
public void update(boolean force) { |
376 |
public Expression getActivePageExpression(InstallationPage page) { |
| 323 |
if (composite == null || composite.isDisposed()) |
377 |
return new ActiveInstallationPageExpression(page); |
| 324 |
return; |
|
|
| 325 |
GC metricsGC = new GC(composite); |
| 326 |
FontMetrics metrics = metricsGC.getFontMetrics(); |
| 327 |
metricsGC.dispose(); |
| 328 |
IContributionItem[] items = getItems(); |
| 329 |
Control[] children = composite.getChildren(); |
| 330 |
|
| 331 |
int visibleChildren = 0; |
| 332 |
for (int i = 0; i < children.length; i++) { |
| 333 |
Control control = children[i]; |
| 334 |
control.dispose(); |
| 335 |
} |
| 336 |
|
| 337 |
for (int i = 0; i < items.length; i++) { |
| 338 |
IContributionItem item = items[i]; |
| 339 |
if (item.isVisible()) { |
| 340 |
item.fill(composite); |
| 341 |
children = composite.getChildren(); |
| 342 |
Control itemControl = children[children.length - 1]; |
| 343 |
setButtonLayoutData(metrics, itemControl); |
| 344 |
visibleChildren++; |
| 345 |
} |
| 346 |
} |
| 347 |
GridLayout compositeLayout = (GridLayout) composite.getLayout(); |
| 348 |
compositeLayout.numColumns = visibleChildren; |
| 349 |
composite.layout(true); |
| 350 |
} |
378 |
} |
| 351 |
|
379 |
|
| 352 |
protected void setButtonLayoutData(FontMetrics metrics, Control button) { |
380 |
protected void resetVariables(InstallationDialogSourceProvider sp) { |
| 353 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
381 |
sp.resetAll(); |
| 354 |
int widthHint = Dialog.convertHorizontalDLUsToPixels(metrics, IDialogConstants.BUTTON_WIDTH); |
|
|
| 355 |
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
| 356 |
data.widthHint = Math.max(widthHint, minSize.x); |
| 357 |
button.setLayoutData(data); |
| 358 |
} |
382 |
} |
| 359 |
} |
383 |
} |