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: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.dialogs;
11:
12: import org.eclipse.jface.viewers.IStructuredSelection;
13: import org.eclipse.swt.SWT;
14: import org.eclipse.swt.layout.GridData;
15: import org.eclipse.swt.layout.GridLayout;
16: import org.eclipse.swt.widgets.Composite;
17: import org.eclipse.swt.widgets.Group;
18: import org.eclipse.ui.IWorkingSet;
19: import org.eclipse.ui.internal.WorkbenchMessages;
20: import org.eclipse.ui.internal.WorkbenchPlugin;
21:
22: /**
23: * Instances of this class provide a {@link WorkingSetConfigurationBlock}
24: * wrapped with an SWT Group container.
25: *
26: * <strong>Please note that this API is experimental and may change before 3.4
27: * ships.</strong>
28: *
29: * @since 3.4
30: */
31: public final class WorkingSetGroup {
32:
33: private WorkingSetConfigurationBlock workingSetBlock;
34:
35: /**
36: * Create a new instance of this class.
37: *
38: * @param composite
39: * parent composite
40: * @param currentSelection
41: * the initial working set selection to pass to the
42: * {@link WorkingSetConfigurationBlock}
43: * @param workingSetTypes
44: * the types of working sets that can be selected by the
45: * {@link WorkingSetConfigurationBlock}
46: */
47: public WorkingSetGroup(Composite composite,
48: IStructuredSelection currentSelection,
49: String[] workingSetTypes) {
50: Group workingSetGroup = new Group(composite, SWT.NONE);
51: workingSetGroup.setFont(composite.getFont());
52: workingSetGroup
53: .setText(WorkbenchMessages.WorkingSetGroup_WorkingSets_group);
54: workingSetGroup.setLayoutData(new GridData(SWT.FILL, SWT.TOP,
55: true, false));
56: workingSetGroup.setLayout(new GridLayout(1, false));
57:
58: workingSetBlock = new WorkingSetConfigurationBlock(
59: workingSetTypes, WorkbenchPlugin.getDefault()
60: .getDialogSettings());
61: workingSetBlock.setWorkingSets(workingSetBlock
62: .findApplicableWorkingSets(currentSelection));
63: workingSetBlock.createContent(workingSetGroup);
64: }
65:
66: /**
67: * Return the working sets selected by the contained
68: * {@link WorkingSetConfigurationBlock}.
69: *
70: * @return the selected working sets
71: */
72: public IWorkingSet[] getSelectedWorkingSets() {
73: return workingSetBlock.getSelectedWorkingSets();
74: }
75: }
|