Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 270626 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/pde/internal/core/plugin/PluginObject.java (-16 / +13 lines)
Lines 13-32 Link Here
13
import java.io.PrintWriter;
13
import java.io.PrintWriter;
14
import java.io.Serializable;
14
import java.io.Serializable;
15
import java.util.Vector;
15
import java.util.Vector;
16
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.pde.core.*;
18
import org.eclipse.core.runtime.IStatus;
18
import org.eclipse.pde.core.plugin.*;
19
import org.eclipse.core.runtime.PlatformObject;
20
import org.eclipse.core.runtime.Status;
21
import org.eclipse.pde.core.IModel;
22
import org.eclipse.pde.core.IModelChangeProvider;
23
import org.eclipse.pde.core.IModelChangedEvent;
24
import org.eclipse.pde.core.ISourceObject;
25
import org.eclipse.pde.core.ModelChangedEvent;
26
import org.eclipse.pde.core.plugin.IPluginBase;
27
import org.eclipse.pde.core.plugin.IPluginModelBase;
28
import org.eclipse.pde.core.plugin.IPluginObject;
29
import org.eclipse.pde.core.plugin.ISharedPluginModel;
30
import org.eclipse.pde.internal.core.PDECore;
19
import org.eclipse.pde.internal.core.PDECore;
31
import org.eclipse.pde.internal.core.PDECoreMessages;
20
import org.eclipse.pde.internal.core.PDECoreMessages;
32
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
21
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelProvider;
Lines 184-191 Link Here
184
	}
173
	}
185
174
186
	public String toString() {
175
	public String toString() {
187
		if (fName != null)
176
		String result = null;
188
			return fName;
177
		if (fName != null) {
178
			result = fName;
179
		}
180
		if ((result == null || result.indexOf('%') >= 0) && fModel != null) {
181
			result = fModel.toString();
182
		}
183
		if (result != null) {
184
			return result;
185
		}
189
		return super.toString();
186
		return super.toString();
190
	}
187
	}
191
188
(-)META-INF/MANIFEST.MF (-1 / +5 lines)
Lines 58-64 Link Here
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
58
 org.eclipse.ant.core;bundle-version="[3.1.0,4.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
59
 org.eclipse.equinox.simpleconfigurator.manipulator;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
60
 org.eclipse.equinox.frameworkadmin;bundle-version="[1.0.100,2.0.0)",
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)"
61
 org.eclipse.debug.core;bundle-version="[3.5.0,4.0.0)",
62
 org.eclipse.equinox.p2.metadata;bundle-version="[1.0.0,2.0.0)",
63
 org.eclipse.equinox.p2.director;bundle-version="[1.0.100,2.0.0)",
64
 org.eclipse.equinox.p2.core;bundle-version="[1.0.100,2.0.0)",
65
 org.eclipse.equinox.p2.repository.tools;bundle-version="[1.0.0,2.0.0)"
62
Eclipse-LazyStart: true
66
Eclipse-LazyStart: true
63
Bundle-RequiredExecutionEnvironment: J2SE-1.4
67
Bundle-RequiredExecutionEnvironment: J2SE-1.4
64
Import-Package: com.ibm.icu.util
68
Import-Package: com.ibm.icu.util
(-)src/org/eclipse/pde/internal/core/target/impl/ProfileBundleContainer.java (-1 / +6 lines)
Lines 89-99 Link Here
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
89
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
90
	 */
90
	 */
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
91
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
92
		URL configUrl = getConfigurationArea();
93
		String home = resolveHomeLocation().toOSString();
92
		String home = resolveHomeLocation().toOSString();
94
		if (!new File(home).isDirectory()) {
93
		if (!new File(home).isDirectory()) {
95
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
94
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind(Messages.ProfileBundleContainer_0, home)));
96
		}
95
		}
96
97
		URL configUrl = getConfigurationArea();
98
		if (!new File(configUrl.getFile()).isDirectory()) {
99
			throw new CoreException(new Status(IStatus.ERROR, PDECore.PLUGIN_ID, NLS.bind("Configuration directory does not exist: {0}", home)));
100
		}
101
97
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
102
		BundleInfo[] infos = P2Utils.readBundles(home, configUrl);
98
		if (infos == null) {
103
		if (infos == null) {
99
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
104
			IResolvedBundle[] platformXML = resolvePlatformXML(definition, home, monitor);
(-)src/org/eclipse/pde/internal/core/target/impl/P2BundleContainer.java (+92 lines)
Added Link Here
1
package org.eclipse.pde.internal.core.target.impl;
2
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.equinox.internal.p2.director.PermissiveSlicer;
6
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
7
import org.eclipse.equinox.p2.internal.repository.tools.Repo2Runnable;
8
import org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor;
9
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
10
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
11
12
public class P2BundleContainer extends AbstractBundleContainer {
13
14
	/**
15
	 * Constant describing the type of bundle container 
16
	 */
17
	public static final String TYPE = "P2Repo"; //$NON-NLS-1$
18
19
	private IInstallableUnit[] fUnits;
20
	private String fDownloadDir;
21
	private String[] fSourceRepos = null;
22
23
	public P2BundleContainer() {
24
		fDownloadDir = "/home/cwindatt/Desktop/Export";
25
	}
26
27
	/* (non-Javadoc)
28
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getLocation(boolean)
29
	 */
30
	public String getLocation(boolean resolve) throws CoreException {
31
		// TODO We are breaking getVMArguments and other places this method is used
32
		return fDownloadDir;
33
	}
34
35
	public String[] getSourceRepos() {
36
		return fSourceRepos;
37
	}
38
39
	public void setSourceRepos(String[] sourceRepos) {
40
		fSourceRepos = sourceRepos;
41
	}
42
43
	public IInstallableUnit[] getRequiredUnits() {
44
		return fUnits;
45
	}
46
47
	public void setRequiredUnits(IInstallableUnit[] units) {
48
		fUnits = units;
49
	}
50
51
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#getType()
53
	 */
54
	public String getType() {
55
		return TYPE;
56
	}
57
58
	/* (non-Javadoc)
59
	 * @see org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer#resolveBundles(org.eclipse.pde.internal.core.target.provisional.ITargetDefinition, org.eclipse.core.runtime.IProgressMonitor)
60
	 */
61
	protected IResolvedBundle[] resolveBundles(ITargetDefinition definition, IProgressMonitor monitor) throws CoreException {
62
		// Create queryable for all source repos
63
64
		// Use the slicer to get the complete list of ius to grab
65
		PermissiveSlicer slicer = new PermissiveSlicer(null, null, true, true, true, true);
66
		slicer.slice(fUnits, monitor);
67
68
		// We need to get the features as well'
69
//		org.eclipse.update.install.features=true
70
71
		// Download artifacts to the folder
72
		Repo2Runnable runnable = new Repo2Runnable();
73
		runnable.addDestination(new RepositoryDescriptor());
74
		runnable.run(monitor);
75
76
//		try {
77
//			Repo2Runnable tool = new Repo2Runnable();
78
//			tool.setDestinationArtifactRepository(fInstallDir.toString());
79
//			tool.setDestinationMetadataRepository(fInstallDir.toString());
80
//			tool.setSourceIUs(Arrays.asList(fUnits));
81
//			IStatus result = tool.run(SubMonitor.convert(monitor, 1));
82
//			if (result.matches(IStatus.ERROR))
83
//				throw new ProvisionException(result);
84
//			fLocations = new File[] {fInstallDir};
85
//		} catch (ProvisionException e) {
86
//			throw new InvocationTargetException(e);
87
//		}
88
89
		// Use the iu's to create resolved bundles
90
		return new IResolvedBundle[0];
91
	}
92
}
(-)src/org/eclipse/pde/internal/ui/shared/target/EditBundleContainerWizard.java (-7 / +5 lines)
Lines 4-20 Link Here
4
import org.eclipse.jface.wizard.Wizard;
4
import org.eclipse.jface.wizard.Wizard;
5
import org.eclipse.pde.internal.core.target.impl.*;
5
import org.eclipse.pde.internal.core.target.impl.*;
6
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
6
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
7
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
8
import org.eclipse.pde.internal.ui.PDEPlugin;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
9
8
10
public class EditBundleContainerWizard extends Wizard {
9
public class EditBundleContainerWizard extends Wizard {
11
10
12
	private ITargetDefinition fTarget;
13
	private IBundleContainer fContainer;
11
	private IBundleContainer fContainer;
14
	private EditDirectoryContainerPage fPage;
12
	private EditDirectoryContainerPage fPage;
15
13
16
	public EditBundleContainerWizard(ITargetDefinition target, IBundleContainer container) {
14
	public EditBundleContainerWizard(IBundleContainer container) {
17
		fTarget = target;
18
		fContainer = container;
15
		fContainer = container;
19
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
16
		IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(AddBundleContainerSelectionPage.SETTINGS_SECTION);
20
		if (settings == null) {
17
		if (settings == null) {
Lines 26-44 Link Here
26
23
27
	public void addPages() {
24
	public void addPages() {
28
		if (fContainer instanceof DirectoryBundleContainer) {
25
		if (fContainer instanceof DirectoryBundleContainer) {
29
			fPage = new EditDirectoryContainerPage(fTarget, fContainer);
26
			fPage = new EditDirectoryContainerPage(fContainer);
30
			addPage(fPage);
27
			addPage(fPage);
31
		} else if (fContainer instanceof ProfileBundleContainer) {
28
		} else if (fContainer instanceof ProfileBundleContainer) {
32
			fPage = new EditProfileContainerPage(fTarget, fContainer);
29
			fPage = new EditProfileContainerPage(fContainer);
33
			addPage(fPage);
30
			addPage(fPage);
34
		} else if (fContainer instanceof FeatureBundleContainer) {
31
		} else if (fContainer instanceof FeatureBundleContainer) {
35
			fPage = new EditFeatureContainerPage(fTarget, fContainer);
32
			fPage = new EditFeatureContainerPage(fContainer);
36
			addPage(fPage);
33
			addPage(fPage);
37
		}
34
		}
38
	}
35
	}
39
36
40
	public boolean performFinish() {
37
	public boolean performFinish() {
41
		if (fPage != null) {
38
		if (fPage != null) {
39
			fPage.storeSettings();
42
			fContainer = fPage.getBundleContainer();
40
			fContainer = fPage.getBundleContainer();
43
			return true;
41
			return true;
44
		}
42
		}
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerLabelProvider.java (-11 lines)
Lines 51-59 Link Here
51
		} catch (CoreException e) {
51
		} catch (CoreException e) {
52
			return MessageFormat.format(Messages.BundleContainerTable_4, new String[] {e.getMessage()});
52
			return MessageFormat.format(Messages.BundleContainerTable_4, new String[] {e.getMessage()});
53
		}
53
		}
54
		if (element instanceof IStatus) {
55
			return ((IStatus) element).getMessage();
56
		}
57
		return super.getText(element);
54
		return super.getText(element);
58
	}
55
	}
59
56
Lines 80-94 Link Here
80
			} else if (element instanceof ProfileBundleContainer) {
77
			} else if (element instanceof ProfileBundleContainer) {
81
				return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION, flag);
78
				return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION, flag);
82
			}
79
			}
83
		} else if (element instanceof IStatus) {
84
			int severity = ((IStatus) element).getSeverity();
85
			if (severity == IStatus.WARNING) {
86
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
87
			} else if (severity == IStatus.ERROR) {
88
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
89
			}
90
		}
80
		}
91
92
		return super.getImage(element);
81
		return super.getImage(element);
93
	}
82
	}
94
83
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerTable.java (-525 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.jface.operation.IRunnableWithProgress;
18
import org.eclipse.jface.viewers.*;
19
import org.eclipse.jface.window.Window;
20
import org.eclipse.jface.wizard.WizardDialog;
21
import org.eclipse.pde.internal.core.target.provisional.*;
22
import org.eclipse.pde.internal.ui.PDEPlugin;
23
import org.eclipse.pde.internal.ui.SWTFactory;
24
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
25
import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor;
26
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.SelectionAdapter;
28
import org.eclipse.swt.events.SelectionEvent;
29
import org.eclipse.swt.layout.GridData;
30
import org.eclipse.swt.layout.GridLayout;
31
import org.eclipse.swt.widgets.*;
32
import org.eclipse.ui.forms.widgets.FormToolkit;
33
import org.eclipse.ui.progress.UIJob;
34
35
/**
36
 * UI part that can be added to a dialog or to a form editor.  Contains a table displaying
37
 * the bundle containers of a target definition.  Also has buttons to add, edit and remove
38
 * bundle containers of varying types.
39
 * 
40
 * @see TargetEditor
41
 * @see ITargetDefinition
42
 * @see IBundleContainer
43
 */
44
public class BundleContainerTable {
45
46
	private TreeViewer fTreeViewer;
47
	private Button fAddButton;
48
	private Button fEditButton;
49
	private Button fRemoveButton;
50
	private Button fRemoveAllButton;
51
	private Label fShowLabel;
52
	private Button fShowPluginsButton;
53
	private Button fShowSourceButton;
54
	private ViewerFilter fPluginFilter;
55
	private ViewerFilter fSourceFilter;
56
57
	private ITargetDefinition fTarget;
58
	private IBundleContainerTableReporter fReporter;
59
60
	/**
61
	 * Creates this part using the form toolkit and adds it to the given composite.
62
	 * 
63
	 * @param parent parent composite
64
	 * @param toolkit toolkit to create the widgets with
65
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
66
	 * @return generated instance of the table part
67
	 */
68
	public static BundleContainerTable createTableInForm(Composite parent, FormToolkit toolkit, IBundleContainerTableReporter reporter) {
69
		BundleContainerTable contentTable = new BundleContainerTable(reporter);
70
		contentTable.createFormContents(parent, toolkit);
71
		return contentTable;
72
	}
73
74
	/**
75
	 * Creates this part using standard dialog widgets and adds it to the given composite.
76
	 * 
77
	 * @param parent parent composite
78
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
79
	 * @return generated instance of the table part
80
	 */
81
	public static BundleContainerTable createTableInDialog(Composite parent, IBundleContainerTableReporter reporter) {
82
		BundleContainerTable contentTable = new BundleContainerTable(reporter);
83
		contentTable.createDialogContents(parent);
84
		return contentTable;
85
	}
86
87
	/**
88
	 * Private constructor, use one of {@link #createTableInDialog(Composite, IBundleContainerTableReporter)}
89
	 * or {@link #createTableInForm(Composite, FormToolkit, IBundleContainerTableReporter)}.
90
	 * 
91
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
92
	 */
93
	private BundleContainerTable(IBundleContainerTableReporter reporter) {
94
		fReporter = reporter;
95
	}
96
97
	/**
98
	 * Creates the part contents from a toolkit
99
	 * @param parent parent composite
100
	 * @param toolkit form toolkit to create widgets
101
	 */
102
	private void createFormContents(Composite parent, FormToolkit toolkit) {
103
		Composite comp = toolkit.createComposite(parent);
104
		comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
105
		comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
106
107
		Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL);
108
		atree.setLayout(new GridLayout());
109
		GridData gd = new GridData(GridData.FILL_BOTH);
110
		atree.setLayoutData(gd);
111
112
		Composite buttonComp = toolkit.createComposite(comp);
113
		GridLayout layout = new GridLayout();
114
		layout.marginWidth = layout.marginHeight = 0;
115
		buttonComp.setLayout(layout);
116
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
117
118
		fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH);
119
		fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH);
120
		fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH);
121
		fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH);
122
123
		Composite filterComp = toolkit.createComposite(buttonComp);
124
		layout = new GridLayout();
125
		layout.marginWidth = layout.marginHeight = 0;
126
		filterComp.setLayout(layout);
127
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
128
129
		fShowLabel = toolkit.createLabel(filterComp, Messages.BundleContainerTable_9);
130
		fShowPluginsButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_14, SWT.CHECK);
131
		fShowSourceButton = toolkit.createButton(filterComp, Messages.BundleContainerTable_15, SWT.CHECK);
132
133
		initializeTreeViewer(atree);
134
		initializeButtons();
135
		initializeFilters();
136
137
		toolkit.paintBordersFor(comp);
138
	}
139
140
	/**
141
	 * Creates the part contents using SWTFactory
142
	 * @param parent parent composite
143
	 */
144
	private void createDialogContents(Composite parent) {
145
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
146
147
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
148
		atree.setLayout(new GridLayout());
149
		GridData gd = new GridData(GridData.FILL_BOTH);
150
		gd.widthHint = 200;
151
		atree.setLayoutData(gd);
152
153
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
154
		GridLayout layout = new GridLayout();
155
		layout.marginHeight = 0;
156
		layout.marginWidth = 0;
157
		buttonComp.setLayout(layout);
158
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
159
160
		fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null);
161
		fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null);
162
		fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null);
163
		fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null);
164
165
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, GridData.BEGINNING, 0, 0);
166
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
167
168
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
169
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
170
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
171
172
		initializeTreeViewer(atree);
173
		initializeButtons();
174
		initializeFilters();
175
	}
176
177
	/**
178
	 * Sets up the tree viewer using the given tree
179
	 * @param tree
180
	 */
181
	private void initializeTreeViewer(Tree tree) {
182
		fTreeViewer = new TreeViewer(tree);
183
		fTreeViewer.setContentProvider(new BundleContainerContentProvider());
184
		fTreeViewer.setLabelProvider(new BundleContainerLabelProvider());
185
		fTreeViewer.setComparator(new ViewerComparator());
186
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
187
			public void selectionChanged(SelectionChangedEvent event) {
188
				updateButtons();
189
			}
190
		});
191
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
192
			public void doubleClick(DoubleClickEvent event) {
193
				if (!event.getSelection().isEmpty()) {
194
					handleEdit();
195
				}
196
			}
197
		});
198
		fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
199
	}
200
201
	/**
202
	 * Sets up the buttons, the button fields must already be created before calling this method
203
	 */
204
	private void initializeButtons() {
205
		fAddButton.addSelectionListener(new SelectionAdapter() {
206
			public void widgetSelected(SelectionEvent e) {
207
				handleAdd();
208
			}
209
		});
210
		fAddButton.setLayoutData(new GridData());
211
		SWTFactory.setButtonDimensionHint(fAddButton);
212
213
		fEditButton.addSelectionListener(new SelectionAdapter() {
214
			public void widgetSelected(SelectionEvent e) {
215
				handleEdit();
216
			}
217
		});
218
		fEditButton.setLayoutData(new GridData());
219
		fEditButton.setEnabled(false);
220
		SWTFactory.setButtonDimensionHint(fEditButton);
221
222
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
223
			public void widgetSelected(SelectionEvent e) {
224
				handleRemove();
225
			}
226
		});
227
		fRemoveButton.setLayoutData(new GridData());
228
		fRemoveButton.setEnabled(false);
229
		SWTFactory.setButtonDimensionHint(fRemoveButton);
230
231
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
232
			public void widgetSelected(SelectionEvent e) {
233
				handleRemoveAll();
234
			}
235
		});
236
		fRemoveAllButton.setLayoutData(new GridData());
237
		SWTFactory.setButtonDimensionHint(fRemoveAllButton);
238
239
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
240
			public void widgetSelected(SelectionEvent e) {
241
				if (!fShowPluginsButton.getSelection()) {
242
					fTreeViewer.addFilter(fPluginFilter);
243
				} else {
244
					fTreeViewer.removeFilter(fPluginFilter);
245
				}
246
			}
247
		});
248
		fShowPluginsButton.setSelection(true);
249
		GridData gd = new GridData();
250
		gd.horizontalIndent = 10;
251
		fShowPluginsButton.setLayoutData(gd);
252
253
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
254
			public void widgetSelected(SelectionEvent e) {
255
				if (!fShowSourceButton.getSelection()) {
256
					fTreeViewer.addFilter(fSourceFilter);
257
				} else {
258
					fTreeViewer.removeFilter(fSourceFilter);
259
				}
260
			}
261
		});
262
		fShowSourceButton.setSelection(true);
263
		gd = new GridData();
264
		gd.horizontalIndent = 10;
265
		fShowSourceButton.setLayoutData(gd);
266
	}
267
268
	private void initializeFilters() {
269
		fSourceFilter = new ViewerFilter() {
270
			public boolean select(Viewer viewer, Object parentElement, Object element) {
271
				if (element instanceof IResolvedBundle) {
272
					if (((IResolvedBundle) element).isSourceBundle()) {
273
						return false;
274
					}
275
				}
276
				return true;
277
			}
278
		};
279
		fPluginFilter = new ViewerFilter() {
280
			public boolean select(Viewer viewer, Object parentElement, Object element) {
281
				if (element instanceof IResolvedBundle) {
282
					if (!((IResolvedBundle) element).isSourceBundle()) {
283
						return false;
284
					}
285
				}
286
				return true;
287
			}
288
		};
289
	}
290
291
	/**
292
	 * Sets the target definition model to use as input for the tree, can be called with different
293
	 * models to change the tree's input.
294
	 * @param target target model
295
	 */
296
	public void setInput(ITargetDefinition target) {
297
		fTarget = target;
298
		refresh();
299
	}
300
301
	/**
302
	 * Refreshes the contents of the table
303
	 */
304
	public void refresh() {
305
		if (!fTarget.isResolved()) {
306
			fReporter.runResolveOperation(new ResolveContainersOperation());
307
		} else {
308
			fTreeViewer.setInput(fTarget);
309
			fTreeViewer.refresh();
310
			updateButtons();
311
		}
312
	}
313
314
	private void setEnabled(boolean enablement) {
315
		fTreeViewer.getControl().setEnabled(enablement);
316
		fAddButton.setEnabled(enablement);
317
318
		fShowLabel.setEnabled(enablement);
319
		fShowPluginsButton.setEnabled(enablement);
320
		fShowSourceButton.setEnabled(enablement);
321
322
		if (enablement) {
323
			updateButtons();
324
		} else {
325
			fRemoveButton.setEnabled(enablement);
326
			fRemoveAllButton.setEnabled(enablement);
327
			fEditButton.setEnabled(enablement);
328
		}
329
	}
330
331
	private void handleAdd() {
332
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
333
		Shell parent = fTreeViewer.getTree().getShell();
334
		WizardDialog dialog = new WizardDialog(parent, wizard);
335
		if (dialog.open() != Window.CANCEL) {
336
			refresh();
337
			contentsChanged();
338
		}
339
	}
340
341
	private void handleEdit() {
342
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
343
		if (!selection.isEmpty()) {
344
			Object selected = selection.getFirstElement();
345
			IBundleContainer oldContainer = null;
346
			if (selected instanceof IBundleContainer) {
347
				oldContainer = (IBundleContainer) selected;
348
			} else if (selected instanceof IResolvedBundle) {
349
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
350
				if (treeSelection.length > 0) {
351
					Object parent = treeSelection[0].getParentItem().getData();
352
					if (parent instanceof IBundleContainer) {
353
						oldContainer = (IBundleContainer) parent;
354
					}
355
				}
356
			}
357
			if (oldContainer != null) {
358
				Shell parent = fTreeViewer.getTree().getShell();
359
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(fTarget, oldContainer);
360
				WizardDialog dialog = new WizardDialog(parent, wizard);
361
				if (dialog.open() == Window.OK) {
362
					// Replace the old container with the new one
363
					IBundleContainer newContainer = wizard.getBundleContainer();
364
					if (newContainer != null) {
365
						IBundleContainer[] containers = fTarget.getBundleContainers();
366
						java.util.List newContainers = new ArrayList(containers.length);
367
						for (int i = 0; i < containers.length; i++) {
368
							if (!containers[i].equals(oldContainer)) {
369
								newContainers.add(containers[i]);
370
							}
371
						}
372
						newContainers.add(newContainer);
373
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
374
375
						// Update the table
376
						refresh();
377
						contentsChanged();
378
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
379
					}
380
				}
381
			}
382
		}
383
	}
384
385
	private void handleRemove() {
386
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
387
		if (!selection.isEmpty()) {
388
			Object selected = selection.getFirstElement();
389
			IBundleContainer container = null;
390
			if (selected instanceof IBundleContainer) {
391
				container = (IBundleContainer) selected;
392
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
393
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
394
				for (int i = 0; i < currentContainers.length; i++) {
395
					if (!currentContainers[i].equals(container)) {
396
						newBundleContainers.add(currentContainers[i]);
397
					}
398
				}
399
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
400
				contentsChanged();
401
				refresh();
402
			}
403
		}
404
	}
405
406
	private void handleRemoveAll() {
407
		fTarget.setBundleContainers(null);
408
		contentsChanged();
409
		refresh();
410
	}
411
412
	private void updateButtons() {
413
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
414
		fEditButton.setEnabled(!selection.isEmpty() && (selection.getFirstElement() instanceof IBundleContainer || selection.getFirstElement() instanceof IResolvedBundle));
415
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
416
		fRemoveAllButton.setEnabled(fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
417
	}
418
419
	/**
420
	 * Informs the reporter for this table that something has changed
421
	 * and is dirty.
422
	 */
423
	private void contentsChanged() {
424
		fReporter.contentsChanged();
425
	}
426
427
	/**
428
	 * Runnable that resolves the target.  Disables the table while running
429
	 */
430
	class ResolveContainersOperation implements IRunnableWithProgress {
431
432
		/* (non-Javadoc)
433
		 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
434
		 */
435
		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
436
			Job job = new UIJob(Messages.BundleContainerTable_16) {
437
				public IStatus runInUIThread(IProgressMonitor monitor) {
438
					if (!fTreeViewer.getControl().isDisposed()) {
439
						setEnabled(false);
440
						fTreeViewer.setInput(Messages.BundleContainerTable_17);
441
						fTreeViewer.refresh();
442
					}
443
					return Status.OK_STATUS;
444
				}
445
			};
446
			job.setSystem(true);
447
			job.schedule();
448
			fTarget.resolve(monitor);
449
			if (!monitor.isCanceled()) {
450
				job = new UIJob(Messages.BundleContainerTable_18) {
451
					public IStatus runInUIThread(IProgressMonitor monitor) {
452
						if (!fTreeViewer.getControl().isDisposed()) {
453
							setEnabled(true);
454
							fTreeViewer.setInput(fTarget);
455
							fTreeViewer.refresh();
456
							updateButtons();
457
						}
458
						return Status.OK_STATUS;
459
					}
460
				};
461
				job.setSystem(true);
462
				job.schedule();
463
			}
464
		}
465
	}
466
467
	/**
468
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
469
	 */
470
	class BundleContainerContentProvider implements ITreeContentProvider {
471
472
		public Object[] getChildren(Object parentElement) {
473
			if (parentElement instanceof ITargetDefinition) {
474
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
475
				return containers != null ? containers : new Object[0];
476
			} else if (parentElement instanceof IBundleContainer) {
477
				IBundleContainer container = (IBundleContainer) parentElement;
478
				if (container.isResolved()) {
479
					IStatus status = container.getBundleStatus();
480
					if (!status.isOK() && !status.isMultiStatus()) {
481
						return new Object[] {status};
482
					}
483
					return container.getBundles();
484
				}
485
				// We should only be populating the table if the containers are resolved, but just in case
486
				return new Object[] {new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19)};
487
			} else if (parentElement instanceof IResolvedBundle) {
488
				IStatus status = ((IResolvedBundle) parentElement).getStatus();
489
				if (!status.isOK()) {
490
					return new Object[] {status};
491
				}
492
			}
493
			return new Object[0];
494
		}
495
496
		public Object getParent(Object element) {
497
			return null;
498
		}
499
500
		public boolean hasChildren(Object element) {
501
			// Since we are already resolved we can't be more efficient
502
			return getChildren(element).length > 0;
503
		}
504
505
		public Object[] getElements(Object inputElement) {
506
			if (inputElement instanceof ITargetDefinition) {
507
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
508
				if (containers != null) {
509
					return containers;
510
				}
511
			} else if (inputElement instanceof String) {
512
				return new Object[] {inputElement};
513
			}
514
			return new Object[0];
515
		}
516
517
		public void dispose() {
518
		}
519
520
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
521
		}
522
523
	}
524
525
}
(-)src/org/eclipse/pde/internal/ui/shared/target/messages.properties (-8 lines)
Lines 15-21 Link Here
15
AddDirectoryContainerPage_4=Directory
15
AddDirectoryContainerPage_4=Directory
16
AddDirectoryContainerPage_5=Select a directory containing one or more plug-ins.
16
AddDirectoryContainerPage_5=Select a directory containing one or more plug-ins.
17
AddDirectoryContainerPage_6=Location directory does not exist
17
AddDirectoryContainerPage_6=Location directory does not exist
18
AddDirectoryContainerPage_7=< no plug-ins found in the current location >
19
AddDirectoryContainerPage_9=Could not acquire the target platform service to create the new container.
18
AddDirectoryContainerPage_9=Could not acquire the target platform service to create the new container.
20
AddFeatureContainerPage_0=Add Features
19
AddFeatureContainerPage_0=Add Features
21
AddFeatureContainerPage_1=Select features from a directory.
20
AddFeatureContainerPage_1=Select features from a directory.
Lines 61-75 Link Here
61
BundleContainerTable_16=Disable Target Contents
60
BundleContainerTable_16=Disable Target Contents
62
BundleContainerTable_17=Resolving the contents of the target...
61
BundleContainerTable_17=Resolving the contents of the target...
63
BundleContainerTable_18=Enable Target Contents
62
BundleContainerTable_18=Enable Target Contents
64
BundleContainerTable_19=Container has not been resolved
65
# label provider error messages
66
# {0} is the error message
67
BundleContainerTable_4=Error creating label: {0}
63
BundleContainerTable_4=Error creating label: {0}
68
BundleContainerTable_9=Show:
64
BundleContainerTable_9=Show:
69
EditBundleContainerWizard_0=Edit Content
65
EditBundleContainerWizard_0=Edit Content
70
EditDirectoryContainerPage_0=Edit Directory
66
EditDirectoryContainerPage_0=Edit Directory
71
EditDirectoryContainerPage_1=&Variables...
67
EditDirectoryContainerPage_1=&Variables...
72
EditDirectoryContainerPage_2=Included Plug-ins
73
EditDirectoryContainerPage_3=Resolve Container Job
68
EditDirectoryContainerPage_3=Resolve Container Job
74
EditFeatureContainerPage_0=Edit Feature
69
EditFeatureContainerPage_0=Edit Feature
75
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
70
EditFeatureContainerPage_1=Edit the plug-ins included in this feature
Lines 77-83 Link Here
77
EditFeatureContainerPage_3=Feature Version:
72
EditFeatureContainerPage_3=Feature Version:
78
EditFeatureContainerPage_4=Unspecified
73
EditFeatureContainerPage_4=Unspecified
79
EditFeatureContainerPage_5=Location:
74
EditFeatureContainerPage_5=Location:
80
EditProfileContainerPage_0=Configuration Location
81
EditProfileContainerPage_1=Var&iables...
75
EditProfileContainerPage_1=Var&iables...
82
EditProfileContainerPage_2=Select a configuration directory
76
EditProfileContainerPage_2=Select a configuration directory
83
EditProfileContainerPage_3=Edit Installation
77
EditProfileContainerPage_3=Edit Installation
Lines 91-98 Link Here
91
IncludedBundlesTree_3=Dese&lect All
85
IncludedBundlesTree_3=Dese&lect All
92
IncludedBundlesTree_4=Select Re&quired
86
IncludedBundlesTree_4=Select Re&quired
93
# {0}: count of checked plug-ins {1}: total number of plug-ins  example: 12 of 15 included
87
# {0}: count of checked plug-ins {1}: total number of plug-ins  example: 12 of 15 included
94
IncludedBundlesTree_5={0} of {1} selected
95
IncludedBundlesTree_6=Group Plug-ins by location
96
RestrictionsListSelectionDialog_0=Select the plug-ins to include in the target:
88
RestrictionsListSelectionDialog_0=Select the plug-ins to include in the target:
97
RestrictionsListSelectionDialog_1=Plug-in Selection
89
RestrictionsListSelectionDialog_1=Plug-in Selection
98
RestrictionsListSelectionDialog_2=Use specific plug-in version (versus highest available version)
90
RestrictionsListSelectionDialog_2=Use specific plug-in version (versus highest available version)
(-)src/org/eclipse/pde/internal/ui/shared/target/AddFeatureContainersPage.java (-5 / +10 lines)
Lines 21-27 Link Here
21
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
21
import org.eclipse.pde.internal.core.feature.ExternalFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
22
import org.eclipse.pde.internal.core.ifeature.IFeatureModel;
23
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
23
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
24
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
25
import org.eclipse.pde.internal.ui.*;
24
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.events.SelectionAdapter;
26
import org.eclipse.swt.events.SelectionAdapter;
Lines 44-53 Link Here
44
	private Button fIncludeVersionButton;
43
	private Button fIncludeVersionButton;
45
	private CheckboxTableViewer fFeatureTable;
44
	private CheckboxTableViewer fFeatureTable;
46
45
47
	protected AddFeatureContainersPage(ITargetDefinition target) {
48
		super(target);
49
	}
50
51
	/* (non-Javadoc)
46
	/* (non-Javadoc)
52
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
47
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#getDefaultTitle()
53
	 */
48
	 */
Lines 63-73 Link Here
63
	}
58
	}
64
59
65
	/* (non-Javadoc)
60
	/* (non-Javadoc)
61
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#createLocationArea(org.eclipse.swt.widgets.Composite)
62
	 */
63
	protected void createLocationArea(Composite parent) {
64
		super.createLocationArea(parent);
65
		createTableArea(parent);
66
	}
67
68
	/* (non-Javadoc)
66
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createTableArea(org.eclipse.swt.widgets.Composite)
69
	 * @see org.eclipse.pde.internal.ui.shared.target.AddDirectoryContainerPage#createTableArea(org.eclipse.swt.widgets.Composite)
67
	 */
70
	 */
68
	protected void createTableArea(Composite parent) {
71
	protected void createTableArea(Composite parent) {
69
		Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
72
		Composite tableComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
70
73
74
		SWTFactory.createLabel(tableComp, "Features:", 2);
75
71
		fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER);
76
		fFeatureTable = CheckboxTableViewer.newCheckList(tableComp, SWT.BORDER);
72
		// Connect the label provider
77
		// Connect the label provider
73
		PDEPlugin.getDefault().getLabelProvider().connect(this);
78
		PDEPlugin.getDefault().getLabelProvider().connect(this);
(-)src/org/eclipse/pde/internal/ui/shared/target/EditProfileContainerPage.java (-12 / +7 lines)
Lines 20-26 Link Here
20
import org.eclipse.jface.dialogs.IMessageProvider;
20
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.pde.internal.core.target.impl.ProfileBundleContainer;
21
import org.eclipse.pde.internal.core.target.impl.ProfileBundleContainer;
22
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
22
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
23
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
24
import org.eclipse.pde.internal.ui.SWTFactory;
23
import org.eclipse.pde.internal.ui.SWTFactory;
25
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.SWT;
26
import org.eclipse.swt.events.*;
25
import org.eclipse.swt.events.*;
Lines 57-68 Link Here
57
	 */
56
	 */
58
	private static final String SETTINGS_CONFIG_3 = "config3"; //$NON-NLS-1$
57
	private static final String SETTINGS_CONFIG_3 = "config3"; //$NON-NLS-1$
59
58
60
	public EditProfileContainerPage(ITargetDefinition target) {
59
	public EditProfileContainerPage() {
61
		super(target);
60
		super();
62
	}
61
	}
63
62
64
	public EditProfileContainerPage(ITargetDefinition target, IBundleContainer container) {
63
	public EditProfileContainerPage(IBundleContainer container) {
65
		super(target, container);
64
		super(container);
66
	}
65
	}
67
66
68
	/* (non-Javadoc)
67
	/* (non-Javadoc)
Lines 88-94 Link Here
88
	protected void createLocationArea(Composite parent) {
87
	protected void createLocationArea(Composite parent) {
89
		super.createLocationArea(parent);
88
		super.createLocationArea(parent);
90
89
91
		Group configComp = SWTFactory.createGroup(parent, Messages.EditProfileContainerPage_0, 2, 1, GridData.FILL_HORIZONTAL);
90
		Composite configComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
92
91
93
		fUseDefaultConfig = new Button(configComp, SWT.CHECK | SWT.RIGHT);
92
		fUseDefaultConfig = new Button(configComp, SWT.CHECK | SWT.RIGHT);
94
		GridData gd = new GridData();
93
		GridData gd = new GridData();
Lines 103-108 Link Here
103
		});
102
		});
104
103
105
		fConfigLabel = SWTFactory.createLabel(configComp, Messages.AddProfileContainerPage_3, 1);
104
		fConfigLabel = SWTFactory.createLabel(configComp, Messages.AddProfileContainerPage_3, 1);
105
		((GridData) fConfigLabel.getLayoutData()).horizontalIndent = 15;
106
106
107
		fConfigLocation = SWTFactory.createCombo(configComp, SWT.BORDER, 1, getConfigComboItems());
107
		fConfigLocation = SWTFactory.createCombo(configComp, SWT.BORDER, 1, getConfigComboItems());
108
		fConfigLocation.addModifyListener(new ModifyListener() {
108
		fConfigLocation.addModifyListener(new ModifyListener() {
Lines 241-249 Link Here
241
			if (fConfigLocation.isEnabled()) {
241
			if (fConfigLocation.isEnabled()) {
242
				// Check if the text field is blank
242
				// Check if the text field is blank
243
				if (fConfigLocation.getText().trim().length() == 0) {
243
				if (fConfigLocation.getText().trim().length() == 0) {
244
					fBundleTree.setInput(null);
245
					setMessage(Messages.EditProfileContainerPage_2);
244
					setMessage(Messages.EditProfileContainerPage_2);
246
					setPageComplete(false);
247
					return false;
245
					return false;
248
				}
246
				}
249
247
Lines 253-264 Link Here
253
251
254
				// Check that the directory exists
252
				// Check that the directory exists
255
				if (!configLocation.isDirectory()) {
253
				if (!configLocation.isDirectory()) {
256
					fBundleTree.setInput(null);
257
					setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING);
254
					setMessage(Messages.AddProfileContainerPage_8, IMessageProvider.WARNING);
258
					setPageComplete(true);
259
				} else {
255
				} else {
260
					setMessage(getDefaultMessage());
256
					setMessage(getDefaultMessage());
261
					setPageComplete(true);
262
				}
257
				}
263
			}
258
			}
264
		}
259
		}
Lines 268-274 Link Here
268
	/* (non-Javadoc)
263
	/* (non-Javadoc)
269
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
264
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
270
	 */
265
	 */
271
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
266
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
272
		IBundleContainer container = getTargetPlatformService().newProfileContainer(fInstallLocation.getText(), fConfigLocation.isEnabled() ? fConfigLocation.getText() : null);
267
		IBundleContainer container = getTargetPlatformService().newProfileContainer(fInstallLocation.getText(), fConfigLocation.isEnabled() ? fConfigLocation.getText() : null);
273
		if (previous instanceof ProfileBundleContainer) {
268
		if (previous instanceof ProfileBundleContainer) {
274
			container.setIncludedBundles(previous.getIncludedBundles());
269
			container.setIncludedBundles(previous.getIncludedBundles());
(-)src/org/eclipse/pde/internal/ui/shared/target/EditFeatureContainerPage.java (-4 / +3 lines)
Lines 3-9 Link Here
3
import org.eclipse.core.runtime.CoreException;
3
import org.eclipse.core.runtime.CoreException;
4
import org.eclipse.pde.internal.core.target.impl.FeatureBundleContainer;
4
import org.eclipse.pde.internal.core.target.impl.FeatureBundleContainer;
5
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
5
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
6
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
7
import org.eclipse.pde.internal.ui.PDEPlugin;
6
import org.eclipse.pde.internal.ui.PDEPlugin;
8
import org.eclipse.pde.internal.ui.SWTFactory;
7
import org.eclipse.pde.internal.ui.SWTFactory;
9
import org.eclipse.swt.SWT;
8
import org.eclipse.swt.SWT;
Lines 13-20 Link Here
13
12
14
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
13
public class EditFeatureContainerPage extends EditDirectoryContainerPage {
15
14
16
	public EditFeatureContainerPage(ITargetDefinition target, IBundleContainer container) {
15
	public EditFeatureContainerPage(IBundleContainer container) {
17
		super(target, container);
16
		super(container);
18
	}
17
	}
19
18
20
	/* (non-Javadoc)
19
	/* (non-Javadoc)
Lines 80-86 Link Here
80
	/* (non-Javadoc)
79
	/* (non-Javadoc)
81
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
80
	 * @see org.eclipse.pde.internal.ui.shared.target.EditDirectoryContainerPage#refreshContainer(org.eclipse.pde.internal.core.target.provisional.IBundleContainer)
82
	 */
81
	 */
83
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
82
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
84
		return getBundleContainer();
83
		return getBundleContainer();
85
	}
84
	}
86
85
(-)src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerWizard.java (-1 / +1 lines)
Lines 18-24 Link Here
18
 * Wizard for adding a bundle container to a target.  Provides a selection page
18
 * Wizard for adding a bundle container to a target.  Provides a selection page
19
 * where the user can choose the type of container to create.
19
 * where the user can choose the type of container to create.
20
 * 
20
 * 
21
 * @see BundleContainerTable
21
 * @see BundleContainerGroup
22
 * @see IBundleContainer
22
 * @see IBundleContainer
23
 */
23
 */
24
public class AddBundleContainerWizard extends Wizard {
24
public class AddBundleContainerWizard extends Wizard {
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleInfoLabelProvider.java (+11 lines)
Lines 18-23 Link Here
18
import org.eclipse.pde.internal.ui.PDEPluginImages;
18
import org.eclipse.pde.internal.ui.PDEPluginImages;
19
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
19
import org.eclipse.pde.internal.ui.util.SharedLabelProvider;
20
import org.eclipse.swt.graphics.Image;
20
import org.eclipse.swt.graphics.Image;
21
import org.eclipse.ui.ISharedImages;
22
import org.eclipse.ui.PlatformUI;
21
23
22
/**
24
/**
23
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
25
 * Provides text and image labels for BundleInfo and IResolveBundle objects.
Lines 58-63 Link Here
58
			return buf.toString();
60
			return buf.toString();
59
		} else if (element instanceof IResolvedBundle) {
61
		} else if (element instanceof IResolvedBundle) {
60
			return getText(((IResolvedBundle) element).getBundleInfo());
62
			return getText(((IResolvedBundle) element).getBundleInfo());
63
		} else if (element instanceof IStatus) {
64
			return ((IStatus) element).getMessage();
61
		}
65
		}
62
		return super.getText(element);
66
		return super.getText(element);
63
	}
67
	}
Lines 84-89 Link Here
84
			}
88
			}
85
		} else if (element instanceof BundleInfo) {
89
		} else if (element instanceof BundleInfo) {
86
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
90
			return PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PLUGIN_OBJ);
91
		} else if (element instanceof IStatus) {
92
			int severity = ((IStatus) element).getSeverity();
93
			if (severity == IStatus.WARNING) {
94
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_WARN_TSK);
95
			} else if (severity == IStatus.ERROR) {
96
				return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK);
97
			}
87
		}
98
		}
88
		return super.getImage(element);
99
		return super.getImage(element);
89
	}
100
	}
(-)src/org/eclipse/pde/internal/ui/shared/target/Messages.java (-6 lines)
Lines 21-27 Link Here
21
	public static String AddDirectoryContainerPage_4;
21
	public static String AddDirectoryContainerPage_4;
22
	public static String AddDirectoryContainerPage_5;
22
	public static String AddDirectoryContainerPage_5;
23
	public static String AddDirectoryContainerPage_6;
23
	public static String AddDirectoryContainerPage_6;
24
	public static String AddDirectoryContainerPage_7;
25
	public static String AddDirectoryContainerPage_9;
24
	public static String AddDirectoryContainerPage_9;
26
	public static String AddFeatureContainerPage_0;
25
	public static String AddFeatureContainerPage_0;
27
	public static String AddFeatureContainerPage_1;
26
	public static String AddFeatureContainerPage_1;
Lines 52-58 Link Here
52
	public static String BundleContainerTable_16;
51
	public static String BundleContainerTable_16;
53
	public static String BundleContainerTable_17;
52
	public static String BundleContainerTable_17;
54
	public static String BundleContainerTable_18;
53
	public static String BundleContainerTable_18;
55
	public static String BundleContainerTable_19;
56
	public static String BundleContainerTable_2;
54
	public static String BundleContainerTable_2;
57
	public static String BundleContainerTable_3;
55
	public static String BundleContainerTable_3;
58
	public static String BundleContainerTable_4;
56
	public static String BundleContainerTable_4;
Lines 63-69 Link Here
63
	public static String EditBundleContainerWizard_0;
61
	public static String EditBundleContainerWizard_0;
64
	public static String EditDirectoryContainerPage_0;
62
	public static String EditDirectoryContainerPage_0;
65
	public static String EditDirectoryContainerPage_1;
63
	public static String EditDirectoryContainerPage_1;
66
	public static String EditDirectoryContainerPage_2;
67
	public static String EditDirectoryContainerPage_3;
64
	public static String EditDirectoryContainerPage_3;
68
	public static String EditFeatureContainerPage_0;
65
	public static String EditFeatureContainerPage_0;
69
	public static String EditFeatureContainerPage_1;
66
	public static String EditFeatureContainerPage_1;
Lines 71-77 Link Here
71
	public static String EditFeatureContainerPage_3;
68
	public static String EditFeatureContainerPage_3;
72
	public static String EditFeatureContainerPage_4;
69
	public static String EditFeatureContainerPage_4;
73
	public static String EditFeatureContainerPage_5;
70
	public static String EditFeatureContainerPage_5;
74
	public static String EditProfileContainerPage_0;
75
	public static String EditProfileContainerPage_1;
71
	public static String EditProfileContainerPage_1;
76
	public static String EditProfileContainerPage_2;
72
	public static String EditProfileContainerPage_2;
77
	public static String EditProfileContainerPage_3;
73
	public static String EditProfileContainerPage_3;
Lines 84-91 Link Here
84
	public static String IncludedBundlesTree_2;
80
	public static String IncludedBundlesTree_2;
85
	public static String IncludedBundlesTree_3;
81
	public static String IncludedBundlesTree_3;
86
	public static String IncludedBundlesTree_4;
82
	public static String IncludedBundlesTree_4;
87
	public static String IncludedBundlesTree_5;
88
	public static String IncludedBundlesTree_6;
89
	public static String RestrictionsListSelectionDialog_0;
83
	public static String RestrictionsListSelectionDialog_0;
90
	public static String RestrictionsListSelectionDialog_1;
84
	public static String RestrictionsListSelectionDialog_1;
91
	public static String RestrictionsListSelectionDialog_2;
85
	public static String RestrictionsListSelectionDialog_2;
(-)src/org/eclipse/pde/internal/ui/shared/target/IncludedBundlesTree.java (-598 lines)
Removed Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import com.ibm.icu.text.MessageFormat;
4
import java.io.File;
5
import java.util.*;
6
import org.eclipse.core.runtime.IStatus;
7
import org.eclipse.core.runtime.Status;
8
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
9
import org.eclipse.jface.viewers.*;
10
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
12
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
13
import org.eclipse.pde.internal.ui.PDEPlugin;
14
import org.eclipse.pde.internal.ui.SWTFactory;
15
import org.eclipse.swt.SWT;
16
import org.eclipse.swt.events.SelectionAdapter;
17
import org.eclipse.swt.events.SelectionEvent;
18
import org.eclipse.swt.layout.GridData;
19
import org.eclipse.swt.widgets.*;
20
import org.eclipse.ui.dialogs.FilteredTree;
21
import org.eclipse.ui.dialogs.PatternFilter;
22
23
public class IncludedBundlesTree extends FilteredTree {
24
25
	private CheckboxTreeViewer fTree;
26
	private Button fSelectButton;
27
	private Button fDeselectButton;
28
	private Button fSelectAllButton;
29
	private Button fDeselectAllButton;
30
//	private Button fSelectRequiredButton;
31
	private Label fShowLabel;
32
	private Button fShowSourceButton;
33
	private Button fShowPluginsButton;
34
	private Label fCountLabel;
35
	private ViewerFilter fSourceFilter;
36
	private ViewerFilter fPluginFilter;
37
	private IResolvedBundle[] fAllBundles;
38
	private Button fGroupPlugins;
39
	private HashMap fTreeViewerContents;
40
	private boolean fIsGroupedByLocation;
41
42
	public IncludedBundlesTree(Composite parent) {
43
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
44
	}
45
46
	protected Control createTreeControl(Composite parent, int style) {
47
		fIsGroupedByLocation = false;
48
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
49
		super.createTreeControl(treeComp, style);
50
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
51
		createButtons(treeComp);
52
		fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$
53
		updateButtons();
54
		initializeFilters();
55
		initializeTreeContents(fAllBundles);
56
		return treeComp;
57
	}
58
59
	protected void createButtons(Composite parent) {
60
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
61
62
		// TODO Add Mnemonics
63
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
64
		fSelectButton.addSelectionListener(new SelectionAdapter() {
65
			public void widgetSelected(SelectionEvent e) {
66
				if (!fTree.getSelection().isEmpty()) {
67
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
68
					for (int i = 0; i < selected.length; i++) {
69
						if (fIsGroupedByLocation) {
70
							handleCheck(selected[i], true);
71
						} else {
72
							fTree.setChecked(selected[i], true);
73
						}
74
					}
75
					updateButtons();
76
				}
77
			}
78
		});
79
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
80
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
81
			public void widgetSelected(SelectionEvent e) {
82
				if (!fTree.getSelection().isEmpty()) {
83
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
84
					for (int i = 0; i < selected.length; i++) {
85
						if (fIsGroupedByLocation) {
86
							handleCheck(selected[i], false);
87
						} else {
88
							fTree.setChecked(selected[i], false);
89
						}
90
					}
91
					updateButtons();
92
				}
93
			}
94
		});
95
96
		createEmptySpace(buttonComp);
97
98
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
99
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
100
			public void widgetSelected(SelectionEvent e) {
101
				if (fIsGroupedByLocation) {
102
					Iterator iter = fTreeViewerContents.keySet().iterator();
103
					while (iter.hasNext()) {
104
						handleCheck(iter.next(), true);
105
					}
106
107
				} else {
108
					// We only want to check visible
109
					fTree.setAllChecked(true);
110
				}
111
112
				updateButtons();
113
			}
114
		});
115
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
116
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
117
			public void widgetSelected(SelectionEvent e) {
118
119
				if (fIsGroupedByLocation) {
120
					Iterator iter = fTreeViewerContents.keySet().iterator();
121
					while (iter.hasNext()) {
122
						handleCheck(iter.next(), false);
123
					}
124
125
				} else {
126
					// We only want to uncheck visible
127
					fTree.setAllChecked(false);
128
				}
129
				updateButtons();
130
			}
131
		});
132
133
		createEmptySpace(buttonComp);
134
135
		// TODO Support selecting required.
136
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
137
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
138
//			public void widgetSelected(SelectionEvent e) {
139
//				updateButtons();
140
//			}
141
//		});
142
143
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
144
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
145
146
		fGroupPlugins = SWTFactory.createCheckButton(filterComp, Messages.IncludedBundlesTree_6, null, false, 1);
147
		fGroupPlugins.addSelectionListener(new SelectionAdapter() {
148
			public void widgetSelected(SelectionEvent e) {
149
				setEnabled(false);
150
				fIsGroupedByLocation = fGroupPlugins.getSelection();
151
				Object[] checkedElements = fTree.getCheckedElements();
152
				fTree.setContentProvider(getContentProviderForTree());
153
154
				if (fIsGroupedByLocation) {
155
					fTree.expandAll();
156
					fTree.setCheckedElements(checkedElements);
157
					Iterator iter = fTreeViewerContents.keySet().iterator();
158
					HashMap bundles = null;
159
					Object key = null;
160
161
					while (iter.hasNext()) {
162
						key = iter.next();
163
						bundles = (HashMap) fTreeViewerContents.get(key);
164
165
						Iterator childIter = bundles.keySet().iterator();
166
						boolean allChilrenSelected = true;
167
						boolean noneChildrenSelected = true;
168
						while (childIter.hasNext()) {
169
							Object bundle = childIter.next();
170
							boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
171
							allChilrenSelected = allChilrenSelected && checkedState;
172
							noneChildrenSelected = noneChildrenSelected && !checkedState;
173
174
						}
175
						fTree.setChecked(key, !noneChildrenSelected);
176
						fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
177
					}
178
				}
179
				updateButtons();
180
				setEnabled(true);
181
			}
182
		});
183
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
184
185
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
186
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
187
			public void widgetSelected(SelectionEvent e) {
188
				if (!fShowPluginsButton.getSelection()) {
189
					fTree.addFilter(fPluginFilter);
190
				} else {
191
					fTree.removeFilter(fPluginFilter);
192
				}
193
				updateButtons();
194
			}
195
		});
196
		fShowPluginsButton.setSelection(true);
197
		GridData gd = new GridData();
198
		gd.horizontalIndent = 10;
199
		fShowPluginsButton.setLayoutData(gd);
200
201
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
202
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
203
			public void widgetSelected(SelectionEvent e) {
204
				if (!fShowSourceButton.getSelection()) {
205
					fTree.addFilter(fSourceFilter);
206
				} else {
207
					fTree.removeFilter(fSourceFilter);
208
				}
209
				updateButtons();
210
			}
211
		});
212
		fShowSourceButton.setSelection(true);
213
		gd = new GridData();
214
		gd.horizontalIndent = 10;
215
		fShowSourceButton.setLayoutData(gd);
216
217
	}
218
219
	/**
220
	 * returns a HashMap which contains all the new File objects representing a new location
221
	 */
222
	protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) {
223
		HashMap parents = new HashMap();
224
		if (allBundles == null)
225
			return null;
226
227
		if (fTreeViewerContents == null)
228
			fTreeViewerContents = new HashMap();
229
		else
230
			fTreeViewerContents.clear();
231
232
		for (int i = 0; i < allBundles.length; i++) {
233
			IResolvedBundle bundle = allBundles[i];
234
235
			String path = bundle.getBundleInfo().getLocation().getRawPath();
236
			if (path != null) {
237
				File installFile = new File(path);
238
				File parentFile = installFile.getParentFile();
239
				HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile);
240
				if (bundles == null) {
241
					bundles = new HashMap();
242
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
243
					fTreeViewerContents.put(parentFile, bundles);
244
					parents.put(parentFile, Boolean.FALSE);
245
				} else {
246
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
247
				}
248
			}
249
		}
250
251
		return parents;
252
	}
253
254
	private void initializeFilters() {
255
		fSourceFilter = new ViewerFilter() {
256
			public boolean select(Viewer viewer, Object parentElement, Object element) {
257
				if (element instanceof IResolvedBundle) {
258
					if (((IResolvedBundle) element).isSourceBundle()) {
259
						return false;
260
					}
261
				}
262
				return true;
263
			}
264
		};
265
		fPluginFilter = new ViewerFilter() {
266
			public boolean select(Viewer viewer, Object parentElement, Object element) {
267
				if (element instanceof IResolvedBundle) {
268
					if (!((IResolvedBundle) element).isSourceBundle()) {
269
						return false;
270
					}
271
				}
272
				return true;
273
			}
274
		};
275
	}
276
277
	private Label createEmptySpace(Composite parent) {
278
		Label label = new Label(parent, SWT.NONE);
279
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
280
		gd.widthHint = gd.heightHint = 5;
281
		label.setLayoutData(gd);
282
		return label;
283
	}
284
285
	private void updateButtons() {
286
		if (fAllBundles != null && !fTree.getSelection().isEmpty()) {
287
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
288
			boolean allSelected = true;
289
			boolean noneSelected = true;
290
			for (int i = 0; i < selection.length; i++) {
291
				boolean checked = fTree.getChecked(selection[i]);
292
				if (checked) {
293
					noneSelected = false;
294
				} else {
295
					allSelected = false;
296
				}
297
			}
298
			fSelectButton.setEnabled(!allSelected);
299
			fDeselectButton.setEnabled(!noneSelected);
300
//			fSelectRequiredButton.setEnabled(true);
301
		} else {
302
			fSelectButton.setEnabled(false);
303
			fDeselectButton.setEnabled(false);
304
//			fSelectRequiredButton.setEnabled(false);
305
		}
306
307
		int checked;
308
		if (fIsGroupedByLocation) {
309
			checked = fTree.getCheckedElements().length;
310
			Iterator iter = fTreeViewerContents.keySet().iterator();
311
			while (iter.hasNext()) {
312
				if (fTree.getChecked(iter.next())) {
313
					--checked;
314
				}
315
			}
316
		} else {
317
			checked = fTree.getCheckedElements().length;
318
		}
319
		fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount());
320
		fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0);
321
322
		if (fAllBundles != null) {
323
			fCountLabel.setText(MessageFormat.format(Messages.IncludedBundlesTree_5, new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)}));
324
		} else {
325
			fCountLabel.setText(""); //$NON-NLS-1$
326
		}
327
	}
328
329
	/**
330
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
331
	 * @param input bundle container or <code>null</code>
332
	 */
333
	public void setInput(IBundleContainer input) {
334
		fAllBundles = null;
335
336
		// Check that the input is a container with valid, resolved bundles
337
		if (!(input instanceof AbstractBundleContainer)) {
338
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
339
			setEnabled(false);
340
			return;
341
		}
342
		if (!input.isResolved()) {
343
			fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), Messages.BundleContainerTable_19));
344
			setEnabled(false);
345
			return;
346
		}
347
		IStatus status = input.getBundleStatus();
348
		if (!status.isOK() && !status.isMultiStatus()) {
349
			fTree.setInput(status);
350
			setEnabled(false);
351
			return;
352
		}
353
		IResolvedBundle[] allResolvedBundles = ((AbstractBundleContainer) input).getAllBundles();
354
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
355
			fTree.setInput(Messages.AddDirectoryContainerPage_7);
356
			setEnabled(false);
357
			return;
358
		}
359
360
		// Input is valid, setup the tree
361
		fAllBundles = allResolvedBundles;
362
		fTree.setInput(allResolvedBundles);
363
364
		// Check the included bundles
365
		BundleInfo[] included = input.getIncludedBundles();
366
		if (included == null) {
367
			fTree.setCheckedElements(fAllBundles);
368
		} else {
369
			Set includedBundles = new HashSet();
370
			for (int i = 0; i < included.length; i++) {
371
				includedBundles.add(included[i].getSymbolicName());
372
			}
373
			java.util.List toCheck = new ArrayList(includedBundles.size());
374
			for (int i = 0; i < allResolvedBundles.length; i++) {
375
				if (includedBundles.contains(allResolvedBundles[i].getBundleInfo().getSymbolicName())) {
376
					toCheck.add(allResolvedBundles[i]);
377
				}
378
			}
379
			fTree.setCheckedElements(toCheck.toArray());
380
		}
381
382
		// Enable the tree and update the buttons
383
		setEnabled(true);
384
	}
385
386
	/* (non-Javadoc)
387
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
388
	 */
389
	public void setEnabled(boolean enabled) {
390
		super.setEnabled(enabled);
391
		if (enabled) {
392
			updateButtons();
393
		} else {
394
			fSelectButton.setEnabled(false);
395
			fSelectAllButton.setEnabled(false);
396
			fDeselectButton.setEnabled(false);
397
			fDeselectAllButton.setEnabled(false);
398
//			fSelectRequiredButton.setEnabled(false);
399
			fCountLabel.setText(""); //$NON-NLS-1$
400
		}
401
		fShowLabel.setEnabled(enabled);
402
		fShowPluginsButton.setEnabled(enabled);
403
		fShowSourceButton.setEnabled(enabled);
404
		super.setEnabled(enabled);
405
	}
406
407
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
408
		fTree = new CheckboxTreeViewer(parent, style) {
409
			public void refresh(boolean updateLabels) {
410
				super.refresh(updateLabels);
411
				if (updateLabels) {
412
					// We want to update the labels and buttons as users change the filtering
413
					updateButtons();
414
				}
415
			}
416
		};
417
		fTree.setContentProvider(getContentProviderForTree());
418
		fTree.setLabelProvider(new BundleInfoLabelProvider(false));
419
		fTree.addDoubleClickListener(new IDoubleClickListener() {
420
			public void doubleClick(DoubleClickEvent event) {
421
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
422
				fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement()));
423
				updateButtons();
424
			}
425
		});
426
		fTree.addCheckStateListener(new ICheckStateListener() {
427
428
			public void checkStateChanged(CheckStateChangedEvent event) {
429
				if (fIsGroupedByLocation) {
430
					handleCheck(event.getElement(), event.getChecked());
431
					updateButtons();
432
				}
433
			}
434
		});
435
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
436
			public void selectionChanged(SelectionChangedEvent event) {
437
				updateButtons();
438
			}
439
		});
440
		fTree.setSorter(new ViewerSorter());
441
		return fTree;
442
	}
443
444
	/**
445
	 * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location 
446
	 */
447
	private void handleCheck(Object element, boolean state) {
448
		if (fTreeViewerContents.containsKey(element)) {
449
450
			HashMap bundles = (HashMap) fTreeViewerContents.get(element);
451
			Iterator iter = bundles.keySet().iterator();
452
			while (iter.hasNext()) {
453
				Object key = iter.next();
454
				bundles.put(key, new Boolean(state));
455
				fTree.setChecked(key, state);
456
			}
457
			fTree.setChecked(element, state);
458
			fTree.setGrayed(element, false);
459
			return;
460
		}
461
		Iterator iter = fTreeViewerContents.keySet().iterator();
462
		HashMap bundles = null;
463
		Object key = null;
464
		while (iter.hasNext()) {
465
			key = iter.next();
466
			bundles = (HashMap) fTreeViewerContents.get(key);
467
			if (bundles.containsKey(element)) {
468
				bundles.put(element, new Boolean(state));
469
				break;
470
			}
471
		}
472
		iter = bundles.keySet().iterator();
473
		boolean allChilrenSelected = true;
474
		boolean noneChildrenSelected = true;
475
		while (iter.hasNext()) {
476
			Object bundle = iter.next();
477
			boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
478
			allChilrenSelected = allChilrenSelected && checkedState;
479
			noneChildrenSelected = noneChildrenSelected && !checkedState;
480
		}
481
		fTree.setChecked(element, state);
482
		fTree.setChecked(key, !noneChildrenSelected);
483
		fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
484
	}
485
486
	private ITreeContentProvider getContentProviderForTree() {
487
		if (fIsGroupedByLocation) {
488
489
			//Content provider for grouped by location
490
			return (new ITreeContentProvider() {
491
492
				public Object[] getChildren(Object parentElement) {
493
					if (parentElement instanceof File) {
494
						HashMap files = (HashMap) fTreeViewerContents.get(parentElement);
495
						if (files != null) {
496
							Object[] result = files.keySet().toArray();
497
							return result;
498
						}
499
					}
500
					return new Object[0];
501
				}
502
503
				public Object getParent(Object element) {
504
					if (element instanceof IResolvedBundle) {
505
						IResolvedBundle bundle = (IResolvedBundle) element;
506
						String installPath = bundle.getBundleInfo().getLocation().getPath();
507
						if (installPath != null)
508
							return new File(installPath).getParentFile();
509
					}
510
					return null;
511
				}
512
513
				public boolean hasChildren(Object element) {
514
					if (element instanceof File)
515
						return fTreeViewerContents.containsKey(element);
516
					return false;
517
				}
518
519
				public Object[] getElements(Object inputElement) {
520
					if (fTreeViewerContents == null)
521
						return initializeTreeContents(fAllBundles).keySet().toArray();
522
					return fTreeViewerContents.keySet().toArray();
523
				}
524
525
				public void dispose() {
526
				}
527
528
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
529
				}
530
			});
531
		}
532
533
		//ungrouped content provider
534
		return (new ITreeContentProvider() {
535
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
536
			}
537
538
			public void dispose() {
539
			}
540
541
			public Object[] getElements(Object inputElement) {
542
				if (inputElement instanceof IResolvedBundle[]) {
543
					return (IResolvedBundle[]) inputElement;
544
				}
545
				return new Object[] {inputElement};
546
			}
547
548
			public boolean hasChildren(Object element) {
549
				return false;
550
			}
551
552
			public Object getParent(Object element) {
553
				return null;
554
			}
555
556
			public Object[] getChildren(Object parentElement) {
557
				return new Object[0];
558
			}
559
		});
560
	}
561
562
	/**
563
	 * Return the set of bundles to include in this bundle container based on what is
564
	 * checked in the tree.  If all bundles in the container are checked or there was
565
	 * a problem getting the bundles from the container, this method will return 
566
	 * <code>null</code>
567
	 * 
568
	 * @return set of bundles to include or <code>null</code>
569
	 */
570
	public BundleInfo[] getIncludedBundles() {
571
		if (fTree.getControl().isEnabled() && fAllBundles != null) {
572
			Object[] checked = fTree.getCheckedElements();
573
			if (fIsGroupedByLocation) {
574
				int count = fTree.getCheckedElements().length;
575
				Iterator iter = fTreeViewerContents.keySet().iterator();
576
				while (iter.hasNext()) {
577
					if (fTree.getChecked(iter.next())) {
578
						--count;
579
					}
580
				}
581
				if (count == fAllBundles.length)
582
					return null;
583
584
			} else if (checked.length == fAllBundles.length) {
585
				return null;
586
			}
587
588
			java.util.List included = new ArrayList(checked.length);
589
			for (int i = 0; i < checked.length; i++) {
590
				if (checked[i] instanceof IResolvedBundle) {
591
					included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
592
				}
593
			}
594
			return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]);
595
		}
596
		return null;
597
	}
598
}
(-)src/org/eclipse/pde/internal/ui/shared/target/IBundleContainerTableReporter.java (-40 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import org.eclipse.jface.operation.IRunnableWithProgress;
14
15
/**
16
 * Does container specific actions for the BundleContainerTable.  Allows the resolve
17
 * operation to run differently (job or dialog) if the table is being used in an editor
18
 * or a wizard page.  Allows changes to the bundle containers to be reported properly.
19
 *
20
 * @see BundleContainerTable
21
 */
22
public interface IBundleContainerTableReporter {
23
24
	/**
25
	 * Runs the given operation in a container appropriate fashion.
26
	 * <p>
27
	 * This method may be called from the UI thread so implementors should
28
	 * not block.
29
	 * </p>
30
	 * @param operation the operation to run
31
	 */
32
	public void runResolveOperation(IRunnableWithProgress operation);
33
34
	/**
35
	 * Informs the container that the contents of the target's bundle 
36
	 * containers have changed.  Used to mark the editor dirty.
37
	 */
38
	public void contentsChanged();
39
40
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddBundleContainerSelectionPage.java (-4 / +50 lines)
Lines 163-180 Link Here
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
163
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_3, Messages.AddBundleContainerSelectionPage_4, PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER)) {
164
			public IWizard createWizard() {
164
			public IWizard createWizard() {
165
				Wizard wizard = new Wizard() {
165
				Wizard wizard = new Wizard() {
166
					private EditDirectoryContainerPage fPage1;
167
166
					public void addPages() {
168
					public void addPages() {
167
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
169
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
168
						if (settings == null) {
170
						if (settings == null) {
169
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
171
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
170
						}
172
						}
171
						setDialogSettings(settings);
173
						setDialogSettings(settings);
172
						addPage(new EditDirectoryContainerPage(fTarget));
174
						fPage1 = new EditDirectoryContainerPage();
175
						addPage(fPage1);
176
						addPage(new PreviewContainerPage(fTarget, fPage1));
177
						setNeedsProgressMonitor(true);
173
					}
178
					}
174
179
175
					public boolean performFinish() {
180
					public boolean performFinish() {
176
						IBundleContainer container = ((EditDirectoryContainerPage) getPages()[0]).getBundleContainer();
181
						IBundleContainer container = fPage1.getBundleContainer();
177
						if (container != null) {
182
						if (container != null) {
183
							fPage1.storeSettings();
178
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
184
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
179
							if (oldContainers == null) {
185
							if (oldContainers == null) {
180
								fTarget.setBundleContainers(new IBundleContainer[] {container});
186
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 195-212 Link Here
195
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
201
		standardChoices.add(new AbstractBundleContainerNode(Messages.AddBundleContainerSelectionPage_6, Messages.AddBundleContainerSelectionPage_7, PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_PRODUCT_DEFINITION)) {
196
			public IWizard createWizard() {
202
			public IWizard createWizard() {
197
				Wizard wizard = new Wizard() {
203
				Wizard wizard = new Wizard() {
204
					private EditDirectoryContainerPage fPage1;
205
198
					public void addPages() {
206
					public void addPages() {
199
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
207
						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
200
						if (settings == null) {
208
						if (settings == null) {
201
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
209
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
202
						}
210
						}
203
						setDialogSettings(settings);
211
						setDialogSettings(settings);
204
						addPage(new EditProfileContainerPage(fTarget));
212
						setDialogSettings(settings);
213
						fPage1 = new EditProfileContainerPage();
214
						addPage(fPage1);
215
						addPage(new PreviewContainerPage(fTarget, fPage1));
216
						setNeedsProgressMonitor(true);
205
					}
217
					}
206
218
207
					public boolean performFinish() {
219
					public boolean performFinish() {
208
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
220
						IBundleContainer container = ((EditProfileContainerPage) getPages()[0]).getBundleContainer();
209
						if (container != null) {
221
						if (container != null) {
222
							((EditProfileContainerPage) getPages()[0]).storeSettings();
210
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
223
							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
211
							if (oldContainers == null) {
224
							if (oldContainers == null) {
212
								fTarget.setBundleContainers(new IBundleContainer[] {container});
225
								fTarget.setBundleContainers(new IBundleContainer[] {container});
Lines 233-245 Link Here
233
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
246
							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
234
						}
247
						}
235
						setDialogSettings(settings);
248
						setDialogSettings(settings);
236
						addPage(new AddFeatureContainersPage(fTarget));
249
						addPage(new AddFeatureContainersPage());
237
					}
250
					}
238
251
239
					public boolean performFinish() {
252
					public boolean performFinish() {
240
						try {
253
						try {
241
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
254
							IBundleContainer[] containers = ((AddFeatureContainersPage) getPages()[0]).getBundleContainers();
242
							if (containers != null) {
255
							if (containers != null) {
256
								((AddFeatureContainersPage) getPages()[0]).storeSettings();
243
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
257
								IBundleContainer[] oldContainers = fTarget.getBundleContainers();
244
								// TODO: show progress as resolving
258
								// TODO: show progress as resolving
245
								for (int i = 0; i < containers.length; i++) {
259
								for (int i = 0; i < containers.length; i++) {
Lines 266-271 Link Here
266
				return wizard;
280
				return wizard;
267
			}
281
			}
268
		});
282
		});
283
//		standardChoices.add(new AbstractBundleContainerNode("Repository or Update Site", "Download plug-ins from a p2 repository or update site.", PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_REPOSITORY_OBJ)) {
284
//			public IWizard createWizard() {
285
//				Wizard wizard = new Wizard() {
286
//					public void addPages() {
287
//						IDialogSettings settings = PDEPlugin.getDefault().getDialogSettings().getSection(SETTINGS_SECTION);
288
//						if (settings == null) {
289
//							settings = PDEPlugin.getDefault().getDialogSettings().addNewSection(SETTINGS_SECTION);
290
//						}
291
//						setDialogSettings(settings);
292
//						addPage(new AddP2ContainerPage());
293
//					}
294
//
295
//					public boolean performFinish() {
296
//						IBundleContainer container = ((AddP2ContainerPage) getPages()[0]).getBundleContainer();
297
//						if (container != null) {
298
//							IBundleContainer[] oldContainers = fTarget.getBundleContainers();
299
//							if (oldContainers == null) {
300
//								fTarget.setBundleContainers(new IBundleContainer[] {container});
301
//							} else {
302
//								IBundleContainer[] newContainers = new IBundleContainer[oldContainers.length + 1];
303
//								System.arraycopy(oldContainers, 0, newContainers, 0, oldContainers.length);
304
//								newContainers[newContainers.length - 1] = container;
305
//								fTarget.setBundleContainers(newContainers);
306
//							}
307
//						}
308
//						return true;
309
//					}
310
//				};
311
//				wizard.setWindowTitle(Messages.AddBundleContainerSelectionPage_1);
312
//				return wizard;
313
//			}
314
//		});
269
		return standardChoices;
315
		return standardChoices;
270
	}
316
	}
271
317
(-)src/org/eclipse/pde/internal/ui/shared/target/EditDirectoryContainerPage.java (-69 / +26 lines)
Lines 23-33 Link Here
23
import org.eclipse.pde.internal.core.PDECore;
23
import org.eclipse.pde.internal.core.PDECore;
24
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
24
import org.eclipse.pde.internal.core.target.impl.AbstractBundleContainer;
25
import org.eclipse.pde.internal.core.target.impl.DirectoryBundleContainer;
25
import org.eclipse.pde.internal.core.target.impl.DirectoryBundleContainer;
26
import org.eclipse.pde.internal.core.target.provisional.*;
26
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
27
import org.eclipse.pde.internal.core.target.provisional.ITargetPlatformService;
27
import org.eclipse.pde.internal.ui.PDEPlugin;
28
import org.eclipse.pde.internal.ui.PDEPlugin;
28
import org.eclipse.pde.internal.ui.SWTFactory;
29
import org.eclipse.pde.internal.ui.SWTFactory;
29
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.SWT;
30
import org.eclipse.swt.custom.BusyIndicator;
31
import org.eclipse.swt.events.*;
31
import org.eclipse.swt.events.*;
32
import org.eclipse.swt.layout.GridData;
32
import org.eclipse.swt.layout.GridData;
33
import org.eclipse.swt.widgets.*;
33
import org.eclipse.swt.widgets.*;
Lines 42-53 Link Here
42
 */
42
 */
43
public class EditDirectoryContainerPage extends WizardPage {
43
public class EditDirectoryContainerPage extends WizardPage {
44
44
45
	protected static final int TYPING_DELAY = 600;
45
	/**
46
	 * How long to wait before validating the directory
47
	 */
48
	protected static final int TYPING_DELAY = 200;
49
46
	private static ITargetPlatformService fTargetService;
50
	private static ITargetPlatformService fTargetService;
47
	protected Combo fInstallLocation;
51
	protected Combo fInstallLocation;
48
	protected IncludedBundlesTree fBundleTree;
49
	protected IBundleContainer fContainer;
52
	protected IBundleContainer fContainer;
50
	private ITargetDefinition fTarget;
51
	private Job fTextChangedJob;
53
	private Job fTextChangedJob;
52
54
53
	/**
55
	/**
Lines 65-78 Link Here
65
	 */
67
	 */
66
	private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$
68
	private static final String SETTINGS_LOCATION_3 = "location3"; //$NON-NLS-1$
67
69
68
	protected EditDirectoryContainerPage(ITargetDefinition target, IBundleContainer container) {
70
	protected EditDirectoryContainerPage(IBundleContainer container) {
69
		this(target);
71
		this();
70
		fContainer = container;
72
		fContainer = container;
71
	}
73
	}
72
74
73
	protected EditDirectoryContainerPage(ITargetDefinition target) {
75
	protected EditDirectoryContainerPage() {
74
		super("EditDirectoryContainer"); //$NON-NLS-1$
76
		super("EditDirectoryContainer"); //$NON-NLS-1$
75
		fTarget = target;
76
	}
77
	}
77
78
78
	/* (non-Javadoc)
79
	/* (non-Javadoc)
Lines 81-89 Link Here
81
	public void createControl(Composite parent) {
82
	public void createControl(Composite parent) {
82
		setMessage(getDefaultMessage());
83
		setMessage(getDefaultMessage());
83
		setTitle(getDefaultTitle());
84
		setTitle(getDefaultTitle());
85
		setPageComplete(false);
84
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
86
		Composite comp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
85
		createLocationArea(comp);
87
		createLocationArea(comp);
86
		createTableArea(comp);
87
		setControl(comp);
88
		setControl(comp);
88
		initializeInputFields(fContainer);
89
		initializeInputFields(fContainer);
89
	}
90
	}
Lines 171-188 Link Here
171
	}
172
	}
172
173
173
	/**
174
	/**
174
	 * Creates the area at the bottom of the page.  Contains a table intended to display
175
	 * the current resolved bundles.  This class may be overridden by subclasses to 
176
	 * provide custom widgets.
177
	 * @param parent parent composite
178
	 */
179
	protected void createTableArea(Composite parent) {
180
		Group tableGroup = SWTFactory.createGroup(parent, Messages.EditDirectoryContainerPage_2, 2, 1, GridData.FILL_BOTH);
181
		fBundleTree = new IncludedBundlesTree(tableGroup);
182
		fBundleTree.setInput(null);
183
	}
184
185
	/**
186
	 * Initializes the fields use to describe the container.  They should be filled in using
175
	 * Initializes the fields use to describe the container.  They should be filled in using
187
	 * the given container or set to default values if the container is <code>null</code>.
176
	 * the given container or set to default values if the container is <code>null</code>.
188
	 * @param container bundle container being edited, possibly <code>null</code>
177
	 * @param container bundle container being edited, possibly <code>null</code>
Lines 246-251 Link Here
246
235
247
	/**
236
	/**
248
	 * Store all of the dialog settings for this page
237
	 * Store all of the dialog settings for this page
238
	 * Should be explicitly called during the perform finish call of the wizard
249
	 */
239
	 */
250
	protected void storeSettings() {
240
	protected void storeSettings() {
251
		String newLocation = fInstallLocation.getText().trim();
241
		String newLocation = fInstallLocation.getText().trim();
Lines 275-280 Link Here
275
	}
265
	}
276
266
277
	/**
267
	/**
268
	 * @return bundle container created/edited in this wizard or <code>null</code>
269
	 */
270
	public IBundleContainer getBundleContainer() {
271
		return fContainer;
272
	}
273
274
	/**
278
	 * Called whenever the location or another aspect of the container has changed
275
	 * Called whenever the location or another aspect of the container has changed
279
	 * in the UI.  Will schedule a UIJob to verify and resolve the container 
276
	 * in the UI.  Will schedule a UIJob to verify and resolve the container 
280
	 * reporting any problems to the user.  If a previous job is running or sleeping
277
	 * reporting any problems to the user.  If a previous job is running or sleeping
Lines 284-290 Link Here
284
	 */
281
	 */
285
	protected void containerChanged(long delay) {
282
	protected void containerChanged(long delay) {
286
		if (fTextChangedJob == null) {
283
		if (fTextChangedJob == null) {
287
			fTextChangedJob = new ResolveJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3);
284
			fTextChangedJob = new CreateContainerJob(getShell().getDisplay(), Messages.EditDirectoryContainerPage_3);
288
		} else {
285
		} else {
289
			fTextChangedJob.cancel();
286
			fTextChangedJob.cancel();
290
		}
287
		}
Lines 301-309 Link Here
301
	protected boolean validateInput() throws CoreException {
298
	protected boolean validateInput() throws CoreException {
302
		// Check if the text field is blank
299
		// Check if the text field is blank
303
		if (fInstallLocation.getText().trim().length() == 0) {
300
		if (fInstallLocation.getText().trim().length() == 0) {
304
			fBundleTree.setInput(null);
305
			setMessage(getDefaultMessage());
301
			setMessage(getDefaultMessage());
306
			setPageComplete(false);
307
			return false;
302
			return false;
308
		}
303
		}
309
304
Lines 313-324 Link Here
313
308
314
		// Check if directory exists
309
		// Check if directory exists
315
		if (!location.isDirectory()) {
310
		if (!location.isDirectory()) {
316
			fBundleTree.setInput(null);
317
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
311
			setMessage(Messages.AddDirectoryContainerPage_6, IMessageProvider.WARNING);
318
			setPageComplete(true);
319
		} else {
312
		} else {
320
			setMessage(getDefaultMessage());
313
			setMessage(getDefaultMessage());
321
			setPageComplete(true);
322
		}
314
		}
323
		return true;
315
		return true;
324
	}
316
	}
Lines 332-338 Link Here
332
	 * @return a new or modified bundle container
324
	 * @return a new or modified bundle container
333
	 * @throws CoreException
325
	 * @throws CoreException
334
	 */
326
	 */
335
	protected IBundleContainer refreshContainer(IBundleContainer previous) throws CoreException {
327
	protected IBundleContainer createContainer(IBundleContainer previous) throws CoreException {
336
		IBundleContainer container = getTargetPlatformService().newDirectoryContainer(fInstallLocation.getText());
328
		IBundleContainer container = getTargetPlatformService().newDirectoryContainer(fInstallLocation.getText());
337
		if (previous instanceof DirectoryBundleContainer) {
329
		if (previous instanceof DirectoryBundleContainer) {
338
			container.setIncludedBundles(previous.getIncludedBundles());
330
			container.setIncludedBundles(previous.getIncludedBundles());
Lines 356-379 Link Here
356
		return fTargetService;
348
		return fTargetService;
357
	}
349
	}
358
350
359
	/**
351
	private class CreateContainerJob extends UIJob {
360
	 * Returns the bundle container created by this wizard page with the
352
		public CreateContainerJob(Display jobDisplay, String name) {
361
	 * included bundles set on it based on what is checked in the tree.
362
	 * Will return <code>null</code> if there was a problem creating the
363
	 * bundle container.
364
	 * 
365
	 * @return bundle container or <code>null</code>
366
	 * 
367
	 */
368
	public IBundleContainer getBundleContainer() {
369
		if (fBundleTree != null) {
370
			fContainer.setIncludedBundles(fBundleTree.getIncludedBundles());
371
		}
372
		return fContainer;
373
	}
374
375
	private class ResolveJob extends UIJob {
376
		public ResolveJob(Display jobDisplay, String name) {
377
			super(jobDisplay, name);
353
			super(jobDisplay, name);
378
		}
354
		}
379
355
Lines 386-419 Link Here
386
				// Validate the location and any other text fields
362
				// Validate the location and any other text fields
387
				if (validateInput()) {
363
				if (validateInput()) {
388
					// Create a container from the input
364
					// Create a container from the input
389
					fContainer = refreshContainer(fContainer);
365
					fContainer = createContainer(fContainer);
390
					if (fContainer != null) {
366
					setPageComplete(true);
391
						// Resolve the container
392
						BusyIndicator.showWhile(getDisplay(), new Runnable() {
393
							public void run() {
394
								IStatus result = fContainer.isResolved() ? Status.OK_STATUS : fContainer.resolve(fTarget, null);
395
396
								if (!result.isOK() && !result.isMultiStatus()) {
397
									// There was a specific problem preventing the resolution, warn the user
398
									fBundleTree.setInput(null);
399
									setMessage(result.getMessage(), IMessageProvider.WARNING);
400
								} else {
401
									// Resolution was successful
402
									fBundleTree.setInput(fContainer);
403
									setPageComplete(true);
404
								}
405
							}
406
						});
407
						// Store the input into dialog settings as it is valid
408
						storeSettings();
409
					}
410
				} else {
367
				} else {
411
					fContainer = null;
368
					fContainer = null;
369
					setPageComplete(false);
412
				}
370
				}
413
				return Status.OK_STATUS;
371
				return Status.OK_STATUS;
414
			} catch (CoreException e) {
372
			} catch (CoreException e) {
415
				fContainer = null;
373
				fContainer = null;
416
				fBundleTree.setInput(null);
417
				setErrorMessage(e.getMessage());
374
				setErrorMessage(e.getMessage());
418
				setPageComplete(false);
375
				setPageComplete(false);
419
				return e.getStatus();
376
				return e.getStatus();
(-)src/org/eclipse/pde/internal/ui/pderesources.properties (-8 / +3 lines)
Lines 686-692 Link Here
686
ContentPage_fGroup = Fragment Properties
686
ContentPage_fGroup = Fragment Properties
687
ContentPage_parentPluginGroup = Host Plug-in
687
ContentPage_parentPluginGroup = Host Plug-in
688
ContentSection_0=Content
688
ContentSection_0=Content
689
ContentSection_1=This table lists the plug-ins and source bundles that will be included in the target.  Locations to look for plug-ins can be added, edited and removed.  In addition, a location can be modified to only include a subset of bundles.
689
ContentSection_1=List of plug-ins to include in this target.  Only the plug-ins checked below will be included in the target platform.
690
ContentSection_selectedOnly=Include only plug-ins designated below
690
ContentSection_selectedOnly=Include only plug-ins designated below
691
ContentSection_targetContent=Target Content
691
ContentSection_targetContent=Target Content
692
ContentPage_pClassGroup = Plug-in Options
692
ContentPage_pClassGroup = Plug-in Options
Lines 1687-1697 Link Here
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1687
OverviewPage_extensionPageMessageTitle=Extension pages hidden
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1688
OverviewPage_extensionPageMessageBody=The Extension and Extension Point pages are currently hidden, would you like to display them now?
1689
OverviewPage_environmentDescription=<form>\
1689
OverviewPage_environmentDescription=<form>\
1690
<p>The <a href="environment">Environment</a> section contains the following environment and setup information:</p>\
1690
<p>The <a href="environment">Environment</a> section contains additional settings including: locale, operating system, java runtime, arguments and implicit dependencies.</p>\
1691
<li>Environment settings including locale, processor architecture, operating system and windowing system.</li>\
1692
<li>Java runtime environment.</li>\
1693
<li>Program and VM arguments.</li>\
1694
<li>Implicit plug-ins, which should always be taken into account when calculating dependencies.</li>\
1695
</form>
1691
</form>
1696
OverviewPage_fExtensionContent=<form>\
1692
OverviewPage_fExtensionContent=<form>\
1697
<p>This fragment may define extensions and extension points:</p>\
1693
<p>This fragment may define extensions and extension points:</p>\
Lines 1699-1706 Link Here
1699
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1695
<li style="image" value="page" bindent="5"><a href="ex-points">Extension Points</a>: declares new function points this fragment adds to the platform.</li>\
1700
</form>
1696
</form>
1701
OverviewPage_contentDescription=<form>\
1697
OverviewPage_contentDescription=<form>\
1702
<p>The <a href="content">Content</a> section specifies the make-up of the target platform in terms of plug-ins, features or both.</p>\
1698
<p>The <a href="content">Content</a> section specifies the set of plug-ins that will be included in the target platform.</p>\
1703
<p>An option is also available to simply include all plug-ins from the specified locations into the target platform.</p>\
1704
</form>
1699
</form>
1705
OverviewPage_buildTitle=Build Configuration
1700
OverviewPage_buildTitle=Build Configuration
1706
ClassAttributeRow_dialogTitle=Select Type
1701
ClassAttributeRow_dialogTitle=Select Type
(-)src/org/eclipse/pde/internal/ui/PDEPluginImages.java (+2 lines)
Lines 128-133 Link Here
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
128
	public static final ImageDescriptor DESC_COMGROUP_OBJ = create(PATH_OBJ, "keygroups_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
129
	public static final ImageDescriptor DESC_GENCOM_OBJ = create(PATH_OBJ, "command_obj.gif"); //$NON-NLS-1$
130
130
131
	public static final ImageDescriptor DESC_REPOSITORY_OBJ = create(PATH_OBJ, "metadata_repo_obj.gif"); //$NON-NLS-1$
132
131
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_PLUGIN_OBJ = create(PATH_OBJ, "plugin_obj.gif"); //$NON-NLS-1$
132
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
134
	public static final ImageDescriptor DESC_PLUGIN_DIS_OBJ = create(PATH_OBJ, "plugin_dis_obj.gif"); //$NON-NLS-1$
133
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
135
	public static final ImageDescriptor DESC_OPERATING_SYSTEM_OBJ = create(PATH_OBJ, "operating_system_obj.gif"); //$NON-NLS-1$
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/TargetEditor.java (+67 lines)
Lines 14-19 Link Here
14
import java.util.List;
14
import java.util.List;
15
import org.eclipse.core.resources.*;
15
import org.eclipse.core.resources.*;
16
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.*;
17
import org.eclipse.core.runtime.jobs.Job;
18
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
17
import org.eclipse.jface.action.Action;
19
import org.eclipse.jface.action.Action;
18
import org.eclipse.jface.action.ControlContribution;
20
import org.eclipse.jface.action.ControlContribution;
19
import org.eclipse.jface.dialogs.IMessageProvider;
21
import org.eclipse.jface.dialogs.IMessageProvider;
Lines 21-26 Link Here
21
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
23
import org.eclipse.pde.internal.core.target.impl.WorkspaceFileTargetHandle;
22
import org.eclipse.pde.internal.core.target.provisional.*;
24
import org.eclipse.pde.internal.core.target.provisional.*;
23
import org.eclipse.pde.internal.ui.*;
25
import org.eclipse.pde.internal.ui.*;
26
import org.eclipse.pde.internal.ui.shared.target.*;
24
import org.eclipse.swt.SWT;
27
import org.eclipse.swt.SWT;
25
import org.eclipse.swt.custom.BusyIndicator;
28
import org.eclipse.swt.custom.BusyIndicator;
26
import org.eclipse.swt.widgets.*;
29
import org.eclipse.swt.widgets.*;
Lines 32-37 Link Here
32
import org.eclipse.ui.forms.events.IHyperlinkListener;
35
import org.eclipse.ui.forms.events.IHyperlinkListener;
33
import org.eclipse.ui.forms.widgets.*;
36
import org.eclipse.ui.forms.widgets.*;
34
import org.eclipse.ui.part.FileEditorInput;
37
import org.eclipse.ui.part.FileEditorInput;
38
import org.eclipse.ui.progress.UIJob;
35
39
36
/**
40
/**
37
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
41
 * Editor for target definition (*.target) files.  Interacts with the ITargetDefinition model
Lines 46-51 Link Here
46
	private ITargetDefinition fTarget;
50
	private ITargetDefinition fTarget;
47
	private List fManagedFormPages = new ArrayList(2);
51
	private List fManagedFormPages = new ArrayList(2);
48
	private FileInputListener fInputListener;
52
	private FileInputListener fInputListener;
53
	private TargetChangedListener fTargetChangedListener;
49
54
50
	/* (non-Javadoc)
55
	/* (non-Javadoc)
51
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
56
	 * @see org.eclipse.ui.forms.editor.FormEditor#createToolkit(org.eclipse.swt.widgets.Display)
Lines 62-67 Link Here
62
			setActiveEditor(this);
67
			setActiveEditor(this);
63
			setPartName(getEditorInput().getName());
68
			setPartName(getEditorInput().getName());
64
			addPage(new DefinitionPage(this));
69
			addPage(new DefinitionPage(this));
70
			addPage(new ContentPage(this));
65
			addPage(new EnvironmentPage(this));
71
			addPage(new EnvironmentPage(this));
66
		} catch (PartInitException e) {
72
		} catch (PartInitException e) {
67
			PDEPlugin.log(e);
73
			PDEPlugin.log(e);
Lines 198-203 Link Here
198
	}
204
	}
199
205
200
	/**
206
	/**
207
	 * @return a shared listener that will refresh UI components when the target is modified
208
	 */
209
	public TargetChangedListener getTargetChangedListener() {
210
		if (fTargetChangedListener == null) {
211
			fTargetChangedListener = new TargetChangedListener();
212
		}
213
		return fTargetChangedListener;
214
	}
215
216
	/**
201
	 * Handles the revert action
217
	 * Handles the revert action
202
	 */
218
	 */
203
	public void doRevert() {
219
	public void doRevert() {
Lines 303-306 Link Here
303
		}
319
		}
304
	}
320
	}
305
321
322
	class TargetChangedListener implements ITargetChangedListener {
323
		private BundleContainerGroup fLocationTree;
324
		private TargetContentsGroup fContentTree;
325
326
		public void setLocationTree(BundleContainerGroup locationTree) {
327
			fLocationTree = locationTree;
328
		}
329
330
		public void setContentTree(TargetContentsGroup contentTree) {
331
			fContentTree = contentTree;
332
		}
333
334
		public void contentsChanged(ITargetDefinition definition) {
335
			editorDirtyStateChanged();
336
			if (fContentTree != null && fLocationTree != null) {
337
				if (definition.isResolved()) {
338
					fContentTree.setInput(getTarget());
339
					fLocationTree.setInput(getTarget());
340
				} else {
341
					fContentTree.setEnabled(false);
342
					fLocationTree.setInput(null);
343
					// TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes
344
					Job resolveJob = new Job("Resolving Target") {
345
						protected IStatus run(IProgressMonitor monitor) {
346
							getTarget().resolve(monitor);
347
							if (monitor.isCanceled()) {
348
								return Status.CANCEL_STATUS;
349
							}
350
							// Don't return any problems because we don't want an error dialog
351
							return Status.OK_STATUS;
352
						}
353
					};
354
					resolveJob.addJobChangeListener(new JobChangeAdapter() {
355
						public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
356
							UIJob job = new UIJob("Refresh UI") {
357
								public IStatus runInUIThread(IProgressMonitor monitor) {
358
									fContentTree.setInput(getTarget());
359
									fLocationTree.setInput(getTarget());
360
									return Status.OK_STATUS;
361
								}
362
							};
363
							job.setSystem(true);
364
							job.schedule();
365
						}
366
					});
367
					resolveJob.schedule();
368
				}
369
			}
370
		}
371
	}
372
306
}
373
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentSection.java (-32 / +6 lines)
Lines 10-25 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
12
13
import java.lang.reflect.InvocationTargetException;
14
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.jobs.Job;
16
import org.eclipse.jface.operation.IRunnableWithProgress;
17
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
18
import org.eclipse.pde.internal.ui.PDEPlugin;
19
import org.eclipse.pde.internal.ui.PDEUIMessages;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
20
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
21
import org.eclipse.pde.internal.ui.shared.target.BundleContainerTable;
16
import org.eclipse.pde.internal.ui.shared.target.TargetContentsGroup;
22
import org.eclipse.pde.internal.ui.shared.target.IBundleContainerTableReporter;
23
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridData;
24
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.swt.widgets.Composite;
25
import org.eclipse.ui.forms.SectionPart;
19
import org.eclipse.ui.forms.SectionPart;
Lines 33-39 Link Here
33
 */
27
 */
34
public class ContentSection extends SectionPart {
28
public class ContentSection extends SectionPart {
35
29
36
	private BundleContainerTable fTable;
30
	private TargetContentsGroup fContentGroup;
37
	private TargetEditor fEditor;
31
	private TargetEditor fEditor;
38
32
39
	public ContentSection(FormPage page, Composite parent) {
33
	public ContentSection(FormPage page, Composite parent) {
Lines 67-95 Link Here
67
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
61
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
68
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
62
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
69
63
70
		fTable = BundleContainerTable.createTableInForm(client, toolkit, new IBundleContainerTableReporter() {
64
		fContentGroup = TargetContentsGroup.createInForm(client, toolkit);
71
			public void runResolveOperation(final IRunnableWithProgress operation) {
65
		fEditor.getTargetChangedListener().setContentTree(fContentGroup);
72
				Job job = new Job(PDEUIMessages.TargetDefinitionContentPage_0) {
66
		fContentGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
73
					protected IStatus run(IProgressMonitor monitor) {
74
						try {
75
76
							operation.run(monitor);
77
							return Status.OK_STATUS;
78
						} catch (InvocationTargetException e) {
79
							return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
80
						} catch (InterruptedException e) {
81
							return Status.CANCEL_STATUS;
82
						}
83
					}
84
				};
85
				job.setUser(true);
86
				job.schedule();
87
			}
88
89
			public void contentsChanged() {
90
				markDirty();
91
			}
92
		});
93
67
94
		toolkit.paintBordersFor(client);
68
		toolkit.paintBordersFor(client);
95
69
Lines 100-106 Link Here
100
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
74
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
101
	 */
75
	 */
102
	public void refresh() {
76
	public void refresh() {
103
		fTable.setInput(getTarget());
77
		fContentGroup.setInput(getTarget());
104
		super.refresh();
78
		super.refresh();
105
	}
79
	}
106
80
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/DefinitionPage.java (-6 / +72 lines)
Lines 10-35 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
12
13
import org.eclipse.jface.action.IStatusLineManager;
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.*;
15
import org.eclipse.pde.internal.ui.*;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.pde.internal.ui.editor.target.ContentPage;
18
import org.eclipse.pde.internal.ui.editor.target.EnvironmentPage;
19
import org.eclipse.swt.SWT;
20
import org.eclipse.swt.SWTException;
21
import org.eclipse.swt.layout.GridData;
16
import org.eclipse.swt.widgets.Composite;
22
import org.eclipse.swt.widgets.Composite;
17
import org.eclipse.ui.PlatformUI;
23
import org.eclipse.ui.PlatformUI;
18
import org.eclipse.ui.forms.IManagedForm;
24
import org.eclipse.ui.forms.IManagedForm;
19
import org.eclipse.ui.forms.editor.FormPage;
25
import org.eclipse.ui.forms.editor.FormPage;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
26
import org.eclipse.ui.forms.events.HyperlinkEvent;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
27
import org.eclipse.ui.forms.events.IHyperlinkListener;
28
import org.eclipse.ui.forms.widgets.*;
22
29
23
/**
30
/**
24
 * First page in the target definition editor.  Allows for editing of the name,
31
 * First page in the target definition editor.  Allows for editing of the name,
25
 * description and content of the target.
32
 * description and content of the target.
26
 * @see TargetEditor
33
 * @see TargetEditor
27
 * @see InformationSection
34
 * @see InformationSection
28
 * @see ContentSection
35
 * @see LocationSection
29
 */
36
 */
30
public class DefinitionPage extends FormPage {
37
public class DefinitionPage extends FormPage implements IHyperlinkListener {
31
38
32
	public static final String PAGE_ID = "overview"; //$NON-NLS-1$
39
	public static final String PAGE_ID = "definition"; //$NON-NLS-1$
33
40
34
	public DefinitionPage(TargetEditor editor) {
41
	public DefinitionPage(TargetEditor editor) {
35
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
42
		super(editor, PAGE_ID, PDEUIMessages.DefinitionPage_0);
Lines 73-79 Link Here
73
		Composite body = managedForm.getForm().getBody();
80
		Composite body = managedForm.getForm().getBody();
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
81
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
75
		managedForm.addPart(new InformationSection(this, body));
82
		managedForm.addPart(new InformationSection(this, body));
76
		managedForm.addPart(new ContentSection(this, body));
83
		managedForm.addPart(new LocationSection(this, body));
84
		Composite linkComposite = toolkit.createComposite(body);
85
		linkComposite.setLayout(FormLayoutFactory.createFormGridLayout(true, 2));
86
		linkComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
87
		createContentsSection(linkComposite, toolkit);
88
		createEnvironmentSection(linkComposite, toolkit);
89
	}
90
91
	private void createContentsSection(Composite parent, FormToolkit toolkit) {
92
		Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_contentTitle);
93
		createText(section, PDEUIMessages.OverviewPage_contentDescription, toolkit);
94
	}
95
96
	private void createEnvironmentSection(Composite parent, FormToolkit toolkit) {
97
		Section section = createSection(parent, toolkit, PDEUIMessages.OverviewPage_environmentTitle);
98
		createText(section, PDEUIMessages.OverviewPage_environmentDescription, toolkit);
99
	}
100
101
	private Section createSection(Composite parent, FormToolkit toolkit, String title) {
102
		Section section = toolkit.createSection(parent, ExpandableComposite.TITLE_BAR);
103
		section.clientVerticalSpacing = FormLayoutFactory.SECTION_HEADER_VERTICAL_SPACING;
104
		section.setText(title);
105
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
106
		section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING));
107
		return section;
108
	}
109
110
	private FormText createText(Section section, String content, FormToolkit toolkit) {
111
		Composite container = toolkit.createComposite(section, SWT.NONE);
112
		container.setLayout(FormLayoutFactory.createSectionClientTableWrapLayout(false, 1));
113
		section.setClient(container);
114
		FormText text = toolkit.createFormText(container, true);
115
		try {
116
			text.setText(content, true, false);
117
		} catch (SWTException e) {
118
			text.setText(e.getMessage(), false, false);
119
		}
120
		TableWrapData data = new TableWrapData(TableWrapData.FILL_GRAB);
121
		data.maxWidth = 250;
122
		text.setLayoutData(data);
123
		text.addHyperlinkListener(this);
124
		return text;
125
	}
126
127
	public void linkActivated(HyperlinkEvent e) {
128
		String href = (String) e.getHref();
129
		if (href.equals("content")) //$NON-NLS-1$
130
			getEditor().setActivePage(ContentPage.PAGE_ID);
131
		else if (href.equals("environment")) //$NON-NLS-1$
132
			getEditor().setActivePage(EnvironmentPage.PAGE_ID);
133
	}
134
135
	public void linkEntered(HyperlinkEvent e) {
136
		IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager();
137
		mng.setMessage(e.getLabel());
138
	}
139
140
	public void linkExited(HyperlinkEvent e) {
141
		IStatusLineManager mng = getEditor().getEditorSite().getActionBars().getStatusLineManager();
142
		mng.setMessage(null);
77
	}
143
	}
78
144
79
	// TODO Hook up help toolbar action
145
	// TODO Hook up help toolbar action
(-)src/org/eclipse/pde/internal/ui/wizards/target/TargetDefinitionContentPage.java (-41 / +58 lines)
Lines 10-21 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.wizards.target;
11
package org.eclipse.pde.internal.ui.wizards.target;
12
12
13
import org.eclipse.pde.internal.ui.PDEUIMessages;
14
15
import java.lang.reflect.InvocationTargetException;
16
import java.util.*;
13
import java.util.*;
17
import java.util.List;
14
import java.util.List;
18
import org.eclipse.core.runtime.*;
15
import org.eclipse.core.runtime.*;
16
import org.eclipse.core.runtime.jobs.Job;
17
import org.eclipse.core.runtime.jobs.JobChangeAdapter;
19
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
18
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
20
import org.eclipse.core.runtime.preferences.InstanceScope;
19
import org.eclipse.core.runtime.preferences.InstanceScope;
21
import org.eclipse.debug.ui.StringVariableSelectionDialog;
20
import org.eclipse.debug.ui.StringVariableSelectionDialog;
Lines 23-29 Link Here
23
import org.eclipse.jdt.launching.JavaRuntime;
22
import org.eclipse.jdt.launching.JavaRuntime;
24
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
23
import org.eclipse.jdt.launching.environments.IExecutionEnvironment;
25
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
24
import org.eclipse.jdt.launching.environments.IExecutionEnvironmentsManager;
26
import org.eclipse.jface.operation.IRunnableWithProgress;
27
import org.eclipse.jface.viewers.*;
25
import org.eclipse.jface.viewers.*;
28
import org.eclipse.jface.window.Window;
26
import org.eclipse.jface.window.Window;
29
import org.eclipse.pde.internal.core.ICoreConstants;
27
import org.eclipse.pde.internal.core.ICoreConstants;
Lines 55-61 Link Here
55
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
53
	private static final String EMPTY_STRING = ""; //$NON-NLS-1$
56
54
57
	private Text fNameText;
55
	private Text fNameText;
58
	private BundleContainerTable fTable;
56
	private BundleContainerGroup fLocationTree;
57
	private TargetContentsGroup fContentTree;
59
58
60
	// Environment pull-downs
59
	// Environment pull-downs
61
	private Combo fOSCombo;
60
	private Combo fOSCombo;
Lines 126-170 Link Here
126
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
125
		tabs.setLayoutData(new GridData(GridData.FILL_BOTH));
127
126
128
		TabItem pluginsTab = new TabItem(tabs, SWT.NONE);
127
		TabItem pluginsTab = new TabItem(tabs, SWT.NONE);
129
		pluginsTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
128
		pluginsTab.setText("Locations");
130
129
131
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
130
		Composite pluginTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
132
131
		SWTFactory.createWrapLabel(pluginTabContainer, "List of locations to look for plug-ins to add to this target.", 2, 400);
133
		SWTFactory.createWrapLabel(pluginTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
132
		fLocationTree = BundleContainerGroup.createInDialog(pluginTabContainer);
134
135
		fTable = BundleContainerTable.createTableInDialog(pluginTabContainer, new IBundleContainerTableReporter() {
136
			public void runResolveOperation(final IRunnableWithProgress operation) {
137
				if (isControlCreated()) {
138
					try {
139
						getContainer().run(true, false, operation);
140
					} catch (InvocationTargetException e) {
141
						PDEPlugin.log(e);
142
					} catch (InterruptedException e) {
143
						// TODO Cancel the wizard?
144
					}
145
				} else {
146
					// If the page isn't open yet, try running a UI job so the dialog has time to finish opening
147
					new UIJob(PDEUIMessages.TargetDefinitionContentPage_0) {
148
						public IStatus runInUIThread(IProgressMonitor monitor) {
149
							try {
150
								getContainer().run(true, false, operation);
151
								return Status.OK_STATUS;
152
							} catch (InvocationTargetException e) {
153
								return new Status(IStatus.ERROR, PDEPlugin.getPluginId(), PDEUIMessages.TargetDefinitionContentPage_5, e);
154
							} catch (InterruptedException e) {
155
								return Status.CANCEL_STATUS;
156
							}
157
						}
158
					}.schedule();
159
				}
160
			}
161
162
			public void contentsChanged() {
163
				// Do nothing, as wizard will always save when finish is pressed
164
			}
165
		});
166
		pluginsTab.setControl(pluginTabContainer);
133
		pluginsTab.setControl(pluginTabContainer);
167
134
135
		TabItem contentTab = new TabItem(tabs, SWT.NONE);
136
		contentTab.setText(PDEUIMessages.TargetDefinitionContentPage_6);
137
		Composite contentTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
138
		SWTFactory.createWrapLabel(contentTabContainer, PDEUIMessages.ContentSection_1, 2, 400);
139
		fContentTree = TargetContentsGroup.createInDialog(contentTabContainer);
140
		contentTab.setControl(contentTabContainer);
141
168
		TabItem envTab = new TabItem(tabs, SWT.NONE);
142
		TabItem envTab = new TabItem(tabs, SWT.NONE);
169
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
143
		envTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_3);
170
		Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
144
		Composite envTabContainer = SWTFactory.createComposite(tabs, 1, 1, GridData.FILL_BOTH);
Lines 180-189 Link Here
180
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
154
		depTab.setText(PDEUIMessages.TargetDefinitionEnvironmentPage_5);
181
		depTab.setControl(createImplicitTabContents(tabs));
155
		depTab.setControl(createImplicitTabContents(tabs));
182
156
157
		initializeListeners();
183
		targetChanged(getTargetDefinition());
158
		targetChanged(getTargetDefinition());
184
		setControl(comp);
159
		setControl(comp);
185
	}
160
	}
186
161
162
	private void initializeListeners() {
163
		ITargetChangedListener listener = new ITargetChangedListener() {
164
			public void contentsChanged(ITargetDefinition definition) {
165
				if (definition.isResolved()) {
166
					fContentTree.setInput(getTargetDefinition());
167
					fLocationTree.setInput(getTargetDefinition());
168
				} else {
169
					fContentTree.setEnabled(false);
170
					fLocationTree.setInput(null);
171
					// TODO Cancel any other started jobs? Bad if we do this every time a checkbox changes
172
					Job resolveJob = new Job("Resolving Target") {
173
						protected IStatus run(IProgressMonitor monitor) {
174
							getTargetDefinition().resolve(monitor);
175
							if (monitor.isCanceled()) {
176
								return Status.CANCEL_STATUS;
177
							}
178
							// Don't return any problems because we don't want an error dialog
179
							return Status.OK_STATUS;
180
						}
181
					};
182
					resolveJob.addJobChangeListener(new JobChangeAdapter() {
183
						public void done(org.eclipse.core.runtime.jobs.IJobChangeEvent event) {
184
							UIJob job = new UIJob("Refresh UI") {
185
								public IStatus runInUIThread(IProgressMonitor monitor) {
186
									fContentTree.setInput(getTargetDefinition());
187
									fLocationTree.setInput(getTargetDefinition());
188
									return Status.OK_STATUS;
189
								}
190
							};
191
							job.setSystem(true);
192
							job.schedule();
193
						};
194
					});
195
					resolveJob.schedule();
196
				}
197
			}
198
		};
199
		fContentTree.addTargetChangedListener(listener);
200
		fLocationTree.addTargetChangedListener(listener);
201
	}
202
187
	/* (non-Javadoc)
203
	/* (non-Javadoc)
188
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
204
	 * @see org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionPage#targetChanged()
189
	 */
205
	 */
Lines 200-206 Link Here
200
			else
216
			else
201
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
217
				setMessage(PDEUIMessages.TargetDefinitionContentPage_8);
202
218
203
			fTable.setInput(definition);
219
			fLocationTree.setInput(definition);
220
			fContentTree.setInput(definition);
204
221
205
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
222
			String presetValue = (definition.getOS() == null) ? EMPTY_STRING : definition.getOS();
206
			fOSCombo.setText(presetValue);
223
			fOSCombo.setText(presetValue);
(-)src/org/eclipse/pde/internal/ui/shared/target/ITargetChangedListener.java (+33 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.wizards.target.TargetDefinitionContentPage;
15
16
/**
17
 * Listener for UI components that modify the contents of target definitions.
18
 * Whenever the contents of the target changes the listener will be called so
19
 * the target can be resolved and the UI updated.
20
 * 
21
 * @see BundleContainerGroup
22
 * @see TargetContentsGroup
23
 * @see TargetDefinitionContentPage
24
 */
25
public interface ITargetChangedListener {
26
27
	/**
28
	 * Informs the listener that the contents of the target have changed
29
	 * and UI elements may need to be refreshed. 
30
	 */
31
	public void contentsChanged(ITargetDefinition definition);
32
33
}
(-)src/org/eclipse/pde/internal/ui/shared/target/AddP2ContainerPage.java (+177 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import java.net.URI;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.Status;
16
import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
17
import org.eclipse.equinox.internal.provisional.p2.ui.actions.PropertyDialogAction;
18
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.AvailableIUGroup;
19
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup;
20
import org.eclipse.equinox.internal.provisional.p2.ui.dialogs.RepositorySelectionGroup.IRepositorySelectionListener;
21
import org.eclipse.equinox.internal.provisional.p2.ui.policy.IUViewQueryContext;
22
import org.eclipse.equinox.internal.provisional.p2.ui.policy.Policy;
23
import org.eclipse.jface.action.IAction;
24
import org.eclipse.jface.viewers.CheckStateChangedEvent;
25
import org.eclipse.jface.viewers.ICheckStateListener;
26
import org.eclipse.jface.window.SameShellProvider;
27
import org.eclipse.jface.wizard.WizardPage;
28
import org.eclipse.pde.internal.core.target.impl.P2BundleContainer;
29
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
30
import org.eclipse.pde.internal.ui.*;
31
import org.eclipse.pde.internal.ui.wizards.provisioner.p2.ProvisionerMessages;
32
import org.eclipse.swt.SWT;
33
import org.eclipse.swt.events.SelectionAdapter;
34
import org.eclipse.swt.events.SelectionEvent;
35
import org.eclipse.swt.layout.GridData;
36
import org.eclipse.swt.widgets.*;
37
import org.eclipse.ui.PlatformUI;
38
39
/**
40
 * Wizard page allowing users to select which IUs they would like to download
41
 * 
42
 * @since 3.5
43
 */
44
public class AddP2ContainerPage extends WizardPage {
45
46
	static final IStatus BAD_IU_SELECTION = new Status(IStatus.ERROR, PDEPlugin.getPluginId(), ProvisionerMessages.P2TargetProvisionerWizardPage_1);
47
	IStatus fSelectedIUStatus = BAD_IU_SELECTION;
48
49
	P2BundleContainer fContainer;
50
	IUViewQueryContext fQueryContext;
51
52
	RepositorySelectionGroup fRepoSelector;
53
	AvailableIUGroup fAvailableIUGroup;
54
55
	Button fPropertiesButton;
56
	private IAction fPropertyAction;
57
58
	protected AddP2ContainerPage() {
59
		super("AddP2Container"); //$NON-NLS-1$
60
		// TODO Use the target service to create?
61
		fContainer = new P2BundleContainer();
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
66
	 */
67
	public void createControl(Composite parent) {
68
		setMessage("Select content from a repository to be downloaded and added to your target");
69
		setTitle("Add Repository or Update Site");
70
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH, 0, 0);
71
72
		createQueryContext();
73
		createRepositoryComboArea(composite);
74
		createAvailableIUArea(composite);
75
		createDetailsArea(composite);
76
		createCheckboxArea(composite);
77
78
		setPageComplete(false);
79
		restoreWidgetState();
80
		setControl(composite);
81
		PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.P2_PROVISIONING_PAGE);
82
	}
83
84
	private void createCheckboxArea(Composite parent) {
85
		// Categories, provisioning context/store sites/
86
		Composite checkComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_HORIZONTAL, 0, 0);
87
		// TODO Update labels with mnemonics
88
		SWTFactory.createCheckButton(checkComp, "Group by Category", null, true, 1);
89
		SWTFactory.createCheckButton(checkComp, "Show only the latest version", null, true, 1);
90
		SWTFactory.createCheckButton(checkComp, "Download all dependencies", null, true, 1);
91
		SWTFactory.createCheckButton(checkComp, "Include the repo location in the target", null, true, 1);
92
93
	}
94
95
	private void createQueryContext() {
96
		fQueryContext = Policy.getDefault().getQueryContext();
97
	}
98
99
	private void createRepositoryComboArea(Composite parent) {
100
		RepositorySelectionGroup repoSelector = new RepositorySelectionGroup(getContainer(), parent, Policy.getDefault().getRepositoryManipulator(), fQueryContext);
101
		repoSelector.addRepositorySelectionListener(new IRepositorySelectionListener() {
102
			public void repositorySelectionChanged(int repoChoice, URI repoLocation) {
103
				fAvailableIUGroup.setRepositoryFilter(repoChoice, repoLocation);
104
			}
105
		});
106
	}
107
108
	/**
109
	 * Create the UI area where the user will be able to select which IUs they
110
	 * would like to download.  There will also be buttons to see properties for
111
	 * the selection and open the manage sites dialog.
112
	 * 
113
	 * @param parent parent composite
114
	 */
115
	private void createAvailableIUArea(Composite parent) {
116
		fAvailableIUGroup = new AvailableIUGroup(parent);
117
		fAvailableIUGroup.getCheckboxTreeViewer().addCheckStateListener(new ICheckStateListener() {
118
			public void checkStateChanged(CheckStateChangedEvent event) {
119
				IInstallableUnit[] units = fAvailableIUGroup.getCheckedLeafIUs();
120
				fPropertiesButton.setEnabled(units.length > 0);
121
				if (units.length > 0) {
122
					fSelectedIUStatus = Status.OK_STATUS;
123
					fContainer.setRequiredUnits(units);
124
				} else {
125
					fSelectedIUStatus = BAD_IU_SELECTION;
126
					fContainer.setRequiredUnits(null);
127
				}
128
				pageChanged();
129
			}
130
		});
131
		fAvailableIUGroup.setUseBoldFontForFilteredItems(true);
132
		GridData data = (GridData) fAvailableIUGroup.getStructuredViewer().getControl().getLayoutData();
133
		data.heightHint = 200;
134
	}
135
136
	private void createDetailsArea(Composite parent) {
137
		Group detailsGroup = SWTFactory.createGroup(parent, "Details", 1, 1, GridData.FILL_HORIZONTAL);
138
139
		fPropertiesButton = new Button(detailsGroup, SWT.PUSH);
140
		fPropertiesButton.setText(ProvisionerMessages.P2TargetProvisionerWizardPage_10);
141
		fPropertiesButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
142
		fPropertiesButton.addSelectionListener(new SelectionAdapter() {
143
			public void widgetSelected(SelectionEvent event) {
144
				fPropertyAction.run();
145
			}
146
		});
147
		fPropertyAction = new PropertyDialogAction(new SameShellProvider(getShell()), fAvailableIUGroup.getStructuredViewer());
148
	}
149
150
	/**
151
	 * Checks if the page is complete, updating messages and finish button.
152
	 */
153
	void pageChanged() {
154
		if (fSelectedIUStatus.getSeverity() == IStatus.ERROR) {
155
			setErrorMessage(fSelectedIUStatus.getMessage());
156
			setPageComplete(false);
157
		} else {
158
			setErrorMessage(null);
159
			setPageComplete(true);
160
		}
161
	}
162
163
	/**
164
	 * Restores the state of the wizard from previous invocations
165
	 */
166
	private void restoreWidgetState() {
167
		// TODO Init check boxes
168
	}
169
170
	/**
171
	 * @return bundle container created by this wizard or <code>null</code>
172
	 */
173
	public IBundleContainer getBundleContainer() {
174
		return fContainer;
175
	}
176
177
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/ContentPage.java (+83 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEPlugin;
15
import org.eclipse.pde.internal.ui.PDEPluginImages;
16
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
17
import org.eclipse.swt.widgets.Composite;
18
import org.eclipse.ui.forms.IManagedForm;
19
import org.eclipse.ui.forms.editor.FormPage;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
import org.eclipse.ui.forms.widgets.ScrolledForm;
22
23
/**
24
 * First page in the target definition editor.  Allows for editing of the name,
25
 * description and content of the target.
26
 * @see TargetEditor
27
 * @see InformationSection
28
 * @see LocationSection
29
 */
30
public class ContentPage extends FormPage {
31
32
	public static final String PAGE_ID = "content"; //$NON-NLS-1$
33
34
	public ContentPage(TargetEditor editor) {
35
		super(editor, PAGE_ID, "Content");
36
	}
37
38
	/**
39
	 * @return The target model backing this editor
40
	 */
41
	public ITargetDefinition getTarget() {
42
		return ((TargetEditor) getEditor()).getTarget();
43
	}
44
45
	/* (non-Javadoc)
46
	 * @see org.eclipse.pde.internal.ui.editor.PDEFormPage#createFormContent(org.eclipse.ui.forms.IManagedForm)
47
	 */
48
	protected void createFormContent(IManagedForm managedForm) {
49
		super.createFormContent(managedForm);
50
		ScrolledForm form = managedForm.getForm();
51
		FormToolkit toolkit = managedForm.getToolkit();
52
		form.setText("Target Content");
53
		PDEPlugin.getDefault().getLabelProvider().connect(this);
54
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_TARGET_DEFINITION));
55
		toolkit.decorateFormHeading(form.getForm());
56
		fillBody(managedForm, toolkit);
57
		// TODO Finish help
58
		((TargetEditor) getEditor()).contributeToToolbar(managedForm.getForm(), ""); //$NON-NLS-1$
59
		((TargetEditor) getEditor()).addForm(managedForm);
60
		form.updateToolBar();
61
//		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.TARGET_OVERVIEW_PAGE);
62
	}
63
64
	/* (non-Javadoc)
65
	 * @see org.eclipse.ui.forms.editor.FormPage#dispose()
66
	 */
67
	public void dispose() {
68
		PDEPlugin.getDefault().getLabelProvider().disconnect(this);
69
		super.dispose();
70
	}
71
72
	private void fillBody(IManagedForm managedForm, FormToolkit toolkit) {
73
		Composite body = managedForm.getForm().getBody();
74
		body.setLayout(FormLayoutFactory.createFormGridLayout(true, 1));
75
		managedForm.addPart(new ContentSection(this, body));
76
	}
77
78
	// TODO Hook up help toolbar action
79
//	protected String getHelpResource() {
80
//		return "/org.eclipse.pde.doc.user/guide/tools/editors/target_definition_editor/overview.htm"; //$NON-NLS-1$
81
//	}
82
83
}
(-)src/org/eclipse/pde/internal/ui/editor/targetdefinition/LocationSection.java (+80 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.targetdefinition;
12
13
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
14
import org.eclipse.pde.internal.ui.PDEUIMessages;
15
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
16
import org.eclipse.pde.internal.ui.shared.target.BundleContainerGroup;
17
import org.eclipse.swt.layout.GridData;
18
import org.eclipse.swt.widgets.Composite;
19
import org.eclipse.ui.forms.SectionPart;
20
import org.eclipse.ui.forms.editor.FormPage;
21
import org.eclipse.ui.forms.widgets.*;
22
23
/**
24
 * Section for editing the content of the target (bundle containers) in the target definition editor
25
 * @see DefinitionPage
26
 * @see TargetEditor
27
 */
28
public class LocationSection extends SectionPart {
29
30
	private BundleContainerGroup fContainerGroup;
31
	private TargetEditor fEditor;
32
33
	public LocationSection(FormPage page, Composite parent) {
34
		super(parent, page.getManagedForm().getToolkit(), Section.DESCRIPTION | ExpandableComposite.TITLE_BAR);
35
		fEditor = (TargetEditor) page.getEditor();
36
		createClient(getSection(), page.getEditor().getToolkit());
37
	}
38
39
	/**
40
	 * @return The target model backing this editor
41
	 */
42
	private ITargetDefinition getTarget() {
43
		return fEditor.getTarget();
44
	}
45
46
	/**
47
	 * Creates the UI for this section.
48
	 * 
49
	 * @param section section the UI is being added to
50
	 * @param toolkit form toolkit used to create the widgets
51
	 */
52
	protected void createClient(Section section, FormToolkit toolkit) {
53
		section.setLayout(FormLayoutFactory.createClearTableWrapLayout(false, 1));
54
		GridData sectionData = new GridData(GridData.FILL_BOTH);
55
		sectionData.horizontalSpan = 2;
56
		section.setLayoutData(sectionData);
57
		section.setText("Locations");
58
59
		section.setDescription(PDEUIMessages.ContentSection_1);
60
		Composite client = toolkit.createComposite(section);
61
		client.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 1));
62
		client.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
63
64
		fContainerGroup = BundleContainerGroup.createInForm(client, toolkit);
65
		fEditor.getTargetChangedListener().setLocationTree(fContainerGroup);
66
		fContainerGroup.addTargetChangedListener(fEditor.getTargetChangedListener());
67
68
		toolkit.paintBordersFor(client);
69
		section.setClient(client);
70
	}
71
72
	/* (non-Javadoc)
73
	 * @see org.eclipse.ui.forms.AbstractFormPart#refresh()
74
	 */
75
	public void refresh() {
76
		fContainerGroup.setInput(getTarget());
77
		super.refresh();
78
	}
79
80
}
(-)src/org/eclipse/pde/internal/ui/shared/target/PreviewContainerPage.java (+95 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import java.lang.reflect.InvocationTargetException;
4
import org.eclipse.core.runtime.IProgressMonitor;
5
import org.eclipse.core.runtime.IStatus;
6
import org.eclipse.jface.operation.IRunnableWithProgress;
7
import org.eclipse.jface.viewers.ArrayContentProvider;
8
import org.eclipse.jface.viewers.TableViewer;
9
import org.eclipse.jface.wizard.WizardPage;
10
import org.eclipse.pde.internal.core.target.provisional.IBundleContainer;
11
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
12
import org.eclipse.pde.internal.ui.PDEPlugin;
13
import org.eclipse.pde.internal.ui.SWTFactory;
14
import org.eclipse.swt.layout.GridData;
15
import org.eclipse.swt.widgets.Composite;
16
17
public class PreviewContainerPage extends WizardPage {
18
19
	private ITargetDefinition fTarget;
20
	private EditDirectoryContainerPage fPage1;
21
	protected TableViewer fPreviewTable;
22
	protected Object fInput;
23
24
	protected PreviewContainerPage(ITargetDefinition definition, EditDirectoryContainerPage page1) {
25
		super("ContainerPreviewPage");
26
		setTitle("Preview Contents");
27
		setMessage("The plug-ins found in the container are visible below");
28
		fTarget = definition;
29
		fPage1 = page1;
30
	}
31
32
	/* (non-Javadoc)
33
	 * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
34
	 */
35
	public void createControl(Composite parent) {
36
		Composite composite = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_BOTH);
37
		SWTFactory.createLabel(composite, "Plug-ins:", 1);
38
		fPreviewTable = new TableViewer(composite);
39
		fPreviewTable.setLabelProvider(new BundleInfoLabelProvider(true));
40
		fPreviewTable.setContentProvider(ArrayContentProvider.getInstance());
41
		fPreviewTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
42
		setControl(composite);
43
	}
44
45
	/**
46
	 * Refreshes the contents of the preview table, possible resolving the container
47
	 * @param resolve whether the current container should be resolved if it hasn't been already
48
	 */
49
	protected void setInput(final IBundleContainer container) {
50
		if (container == null) {
51
			fInput = null;
52
			fPreviewTable.setInput(null);
53
			return;
54
		}
55
56
		if (container.isResolved()) {
57
			fInput = container.getAllBundles();
58
			fPreviewTable.setInput(fInput);
59
			return;
60
		}
61
62
		try {
63
			getContainer().run(true, true, new IRunnableWithProgress() {
64
				public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
65
					IStatus result = container.resolve(fTarget, monitor);
66
					if (monitor.isCanceled()) {
67
						fInput = null;
68
					} else if (!result.isOK() && !result.isMultiStatus()) {
69
						fInput = new Object[] {result};
70
					} else {
71
						fInput = container.getAllBundles();
72
					}
73
74
				}
75
			});
76
			fPreviewTable.setInput(fInput);
77
		} catch (InvocationTargetException e) {
78
			PDEPlugin.log(e);
79
			setErrorMessage(e.getMessage());
80
		} catch (InterruptedException e) {
81
		}
82
83
	}
84
85
	/* (non-Javadoc)
86
	 * @see org.eclipse.jface.dialogs.DialogPage#setVisible(boolean)
87
	 */
88
	public void setVisible(boolean visible) {
89
		super.setVisible(visible);
90
		if (visible) {
91
			setInput(fPage1.getBundleContainer());
92
		}
93
	}
94
95
}
(-)src/org/eclipse/pde/internal/ui/shared/target/TargetContentsGroup.java (+594 lines)
Added Link Here
1
package org.eclipse.pde.internal.ui.shared.target;
2
3
import com.ibm.icu.text.MessageFormat;
4
import java.io.File;
5
import java.util.*;
6
import org.eclipse.core.runtime.*;
7
import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
8
import org.eclipse.jface.viewers.*;
9
import org.eclipse.pde.internal.core.target.provisional.IResolvedBundle;
10
import org.eclipse.pde.internal.core.target.provisional.ITargetDefinition;
11
import org.eclipse.pde.internal.ui.PDEPlugin;
12
import org.eclipse.pde.internal.ui.SWTFactory;
13
import org.eclipse.swt.SWT;
14
import org.eclipse.swt.events.SelectionAdapter;
15
import org.eclipse.swt.events.SelectionEvent;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.widgets.*;
18
import org.eclipse.ui.dialogs.FilteredTree;
19
import org.eclipse.ui.dialogs.PatternFilter;
20
import org.eclipse.ui.forms.widgets.FormToolkit;
21
22
public class TargetContentsGroup extends FilteredTree {
23
24
	private CheckboxTreeViewer fTree;
25
	private Button fSelectButton;
26
	private Button fDeselectButton;
27
	private Button fSelectAllButton;
28
	private Button fDeselectAllButton;
29
//	private Button fSelectRequiredButton;
30
	private Label fShowLabel;
31
	private Button fShowSourceButton;
32
	private Button fShowPluginsButton;
33
	private Label fCountLabel;
34
	private ViewerFilter fSourceFilter;
35
	private ViewerFilter fPluginFilter;
36
	private IResolvedBundle[] fAllBundles;
37
	private Button fGroupPlugins;
38
39
	private HashMap fTreeViewerContents;
40
	private boolean fIsGroupedByLocation;
41
	private ListenerList fChangeListeners = new ListenerList();
42
43
	public static TargetContentsGroup createInForm(Composite parent, FormToolkit toolkit) {
44
		// TODO Should we be using the tooklit to create the controls?
45
		TargetContentsGroup control = new TargetContentsGroup(parent);
46
		return control;
47
	}
48
49
	public static TargetContentsGroup createInDialog(Composite parent) {
50
		TargetContentsGroup control = new TargetContentsGroup(parent);
51
		return control;
52
	}
53
54
	private TargetContentsGroup(Composite parent) {
55
		super(parent, SWT.BORDER | SWT.MULTI, new PatternFilter(), true);
56
	}
57
58
	/**
59
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
60
	 * are modified.  This method has no effect if the listener has already been added. 
61
	 * 
62
	 * @param listener target changed listener to add
63
	 */
64
	public void addTargetChangedListener(ITargetChangedListener listener) {
65
		fChangeListeners.add(listener);
66
	}
67
68
	protected Control createTreeControl(Composite parent, int style) {
69
		fIsGroupedByLocation = false;
70
		Composite treeComp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
71
		super.createTreeControl(treeComp, style);
72
		((GridData) fTree.getControl().getLayoutData()).heightHint = 300;
73
		createButtons(treeComp);
74
		fCountLabel = SWTFactory.createLabel(treeComp, "", 2); //$NON-NLS-1$
75
		updateButtons();
76
		initializeFilters();
77
		initializeTreeContents(fAllBundles);
78
		return treeComp;
79
	}
80
81
	protected void createButtons(Composite parent) {
82
		Composite buttonComp = SWTFactory.createComposite(parent, 1, 1, GridData.FILL_VERTICAL, 0, 0);
83
84
		// TODO Add Mnemonics
85
		fSelectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_0, null);
86
		fSelectButton.addSelectionListener(new SelectionAdapter() {
87
			public void widgetSelected(SelectionEvent e) {
88
				if (!fTree.getSelection().isEmpty()) {
89
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
90
					for (int i = 0; i < selected.length; i++) {
91
						if (fIsGroupedByLocation) {
92
							handleCheck(selected[i], true);
93
						} else {
94
							fTree.setChecked(selected[i], true);
95
						}
96
					}
97
					updateButtons();
98
				}
99
			}
100
		});
101
		fDeselectButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_1, null);
102
		fDeselectButton.addSelectionListener(new SelectionAdapter() {
103
			public void widgetSelected(SelectionEvent e) {
104
				if (!fTree.getSelection().isEmpty()) {
105
					Object[] selected = ((IStructuredSelection) fTree.getSelection()).toArray();
106
					for (int i = 0; i < selected.length; i++) {
107
						if (fIsGroupedByLocation) {
108
							handleCheck(selected[i], false);
109
						} else {
110
							fTree.setChecked(selected[i], false);
111
						}
112
					}
113
					updateButtons();
114
				}
115
			}
116
		});
117
118
		createEmptySpace(buttonComp);
119
120
		fSelectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_2, null);
121
		fSelectAllButton.addSelectionListener(new SelectionAdapter() {
122
			public void widgetSelected(SelectionEvent e) {
123
				if (fIsGroupedByLocation) {
124
					Iterator iter = fTreeViewerContents.keySet().iterator();
125
					while (iter.hasNext()) {
126
						handleCheck(iter.next(), true);
127
					}
128
129
				} else {
130
					// We only want to check visible
131
					fTree.setAllChecked(true);
132
				}
133
134
				updateButtons();
135
			}
136
		});
137
		fDeselectAllButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_3, null);
138
		fDeselectAllButton.addSelectionListener(new SelectionAdapter() {
139
			public void widgetSelected(SelectionEvent e) {
140
141
				if (fIsGroupedByLocation) {
142
					Iterator iter = fTreeViewerContents.keySet().iterator();
143
					while (iter.hasNext()) {
144
						handleCheck(iter.next(), false);
145
					}
146
147
				} else {
148
					// We only want to uncheck visible
149
					fTree.setAllChecked(false);
150
				}
151
				updateButtons();
152
			}
153
		});
154
155
		createEmptySpace(buttonComp);
156
157
		// TODO Support selecting required.
158
//		fSelectRequiredButton = SWTFactory.createPushButton(buttonComp, Messages.IncludedBundlesTree_4, null);
159
//		fSelectRequiredButton.addSelectionListener(new SelectionAdapter() {
160
//			public void widgetSelected(SelectionEvent e) {
161
//				updateButtons();
162
//			}
163
//		});
164
165
		Composite filterComp = SWTFactory.createComposite(buttonComp, 1, 1, SWT.NONE, 0, 0);
166
		filterComp.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true, true));
167
168
		fGroupPlugins = SWTFactory.createCheckButton(filterComp, "Group by location", null, false, 1);
169
		fGroupPlugins.addSelectionListener(new SelectionAdapter() {
170
			public void widgetSelected(SelectionEvent e) {
171
				setEnabled(false);
172
				fIsGroupedByLocation = fGroupPlugins.getSelection();
173
				Object[] checkedElements = fTree.getCheckedElements();
174
				fTree.setContentProvider(getContentProviderForTree());
175
176
				if (fIsGroupedByLocation) {
177
					fTree.expandAll();
178
					fTree.setCheckedElements(checkedElements);
179
					Iterator iter = fTreeViewerContents.keySet().iterator();
180
					HashMap bundles = null;
181
					Object key = null;
182
183
					while (iter.hasNext()) {
184
						key = iter.next();
185
						bundles = (HashMap) fTreeViewerContents.get(key);
186
187
						Iterator childIter = bundles.keySet().iterator();
188
						boolean allChilrenSelected = true;
189
						boolean noneChildrenSelected = true;
190
						while (childIter.hasNext()) {
191
							Object bundle = childIter.next();
192
							boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
193
							allChilrenSelected = allChilrenSelected && checkedState;
194
							noneChildrenSelected = noneChildrenSelected && !checkedState;
195
196
						}
197
						fTree.setChecked(key, !noneChildrenSelected);
198
						fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
199
					}
200
				}
201
				updateButtons();
202
				setEnabled(true);
203
			}
204
		});
205
		fShowLabel = SWTFactory.createLabel(filterComp, Messages.BundleContainerTable_9, 1);
206
207
		fShowPluginsButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_14, null, true, 1);
208
		fShowPluginsButton.addSelectionListener(new SelectionAdapter() {
209
			public void widgetSelected(SelectionEvent e) {
210
				if (!fShowPluginsButton.getSelection()) {
211
					fTree.addFilter(fPluginFilter);
212
				} else {
213
					fTree.removeFilter(fPluginFilter);
214
				}
215
				updateButtons();
216
			}
217
		});
218
		fShowPluginsButton.setSelection(true);
219
		GridData gd = new GridData();
220
		gd.horizontalIndent = 10;
221
		fShowPluginsButton.setLayoutData(gd);
222
223
		fShowSourceButton = SWTFactory.createCheckButton(filterComp, Messages.BundleContainerTable_15, null, true, 1);
224
		fShowSourceButton.addSelectionListener(new SelectionAdapter() {
225
			public void widgetSelected(SelectionEvent e) {
226
				if (!fShowSourceButton.getSelection()) {
227
					fTree.addFilter(fSourceFilter);
228
				} else {
229
					fTree.removeFilter(fSourceFilter);
230
				}
231
				updateButtons();
232
			}
233
		});
234
		fShowSourceButton.setSelection(true);
235
		gd = new GridData();
236
		gd.horizontalIndent = 10;
237
		fShowSourceButton.setLayoutData(gd);
238
239
	}
240
241
	/**
242
	 * returns a HashMap which contains all the new File objects representing a new location
243
	 */
244
	protected HashMap initializeTreeContents(IResolvedBundle[] allBundles) {
245
		HashMap parents = new HashMap();
246
		if (allBundles == null)
247
			return null;
248
249
		if (fTreeViewerContents == null)
250
			fTreeViewerContents = new HashMap();
251
		else
252
			fTreeViewerContents.clear();
253
254
		for (int i = 0; i < allBundles.length; i++) {
255
			IResolvedBundle bundle = allBundles[i];
256
257
			String path = bundle.getBundleInfo().getLocation().getRawPath();
258
			if (path != null) {
259
				File installFile = new File(path);
260
				File parentFile = installFile.getParentFile();
261
				HashMap bundles = (HashMap) fTreeViewerContents.get(parentFile);
262
				if (bundles == null) {
263
					bundles = new HashMap();
264
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
265
					fTreeViewerContents.put(parentFile, bundles);
266
					parents.put(parentFile, Boolean.FALSE);
267
				} else {
268
					bundles.put(bundle, new Boolean(fTree.getChecked(bundle)));
269
				}
270
			}
271
		}
272
273
		return parents;
274
	}
275
276
	private void initializeFilters() {
277
		fSourceFilter = new ViewerFilter() {
278
			public boolean select(Viewer viewer, Object parentElement, Object element) {
279
				if (element instanceof IResolvedBundle) {
280
					if (((IResolvedBundle) element).isSourceBundle()) {
281
						return false;
282
					}
283
				}
284
				return true;
285
			}
286
		};
287
		fPluginFilter = new ViewerFilter() {
288
			public boolean select(Viewer viewer, Object parentElement, Object element) {
289
				if (element instanceof IResolvedBundle) {
290
					if (!((IResolvedBundle) element).isSourceBundle()) {
291
						return false;
292
					}
293
				}
294
				return true;
295
			}
296
		};
297
	}
298
299
	private Label createEmptySpace(Composite parent) {
300
		Label label = new Label(parent, SWT.NONE);
301
		GridData gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
302
		gd.widthHint = gd.heightHint = 5;
303
		label.setLayoutData(gd);
304
		return label;
305
	}
306
307
	private void updateButtons() {
308
		if (fAllBundles != null && !fTree.getSelection().isEmpty()) {
309
			Object[] selection = ((IStructuredSelection) fTree.getSelection()).toArray();
310
			boolean allSelected = true;
311
			boolean noneSelected = true;
312
			for (int i = 0; i < selection.length; i++) {
313
				boolean checked = fTree.getChecked(selection[i]);
314
				if (checked) {
315
					noneSelected = false;
316
				} else {
317
					allSelected = false;
318
				}
319
			}
320
			fSelectButton.setEnabled(!allSelected);
321
			fDeselectButton.setEnabled(!noneSelected);
322
//			fSelectRequiredButton.setEnabled(true);
323
		} else {
324
			fSelectButton.setEnabled(false);
325
			fDeselectButton.setEnabled(false);
326
//			fSelectRequiredButton.setEnabled(false);
327
		}
328
329
		int checked;
330
		if (fIsGroupedByLocation) {
331
			checked = fTree.getCheckedElements().length;
332
			Iterator iter = fTreeViewerContents.keySet().iterator();
333
			while (iter.hasNext()) {
334
				if (fTree.getChecked(iter.next())) {
335
					--checked;
336
				}
337
			}
338
		} else {
339
			checked = fTree.getCheckedElements().length;
340
		}
341
		fSelectAllButton.setEnabled(fAllBundles != null && checked != fTree.getTree().getItemCount());
342
		fDeselectAllButton.setEnabled(fAllBundles != null && checked != 0);
343
344
		if (fAllBundles != null) {
345
			fCountLabel.setText(MessageFormat.format("{0} of {1} selected", new String[] {Integer.toString(checked), Integer.toString(fAllBundles.length)}));
346
		} else {
347
			fCountLabel.setText(""); //$NON-NLS-1$
348
		}
349
	}
350
351
	/**
352
	 * Set the container to display in the tree or <code>null</code> to disable the tree 
353
	 * @param input bundle container or <code>null</code>
354
	 */
355
	public void setInput(ITargetDefinition input) {
356
		fAllBundles = null;
357
358
		if (input == null || !input.isResolved()) {
359
			fTree.setInput(new Status(IStatus.ERROR, PDEPlugin.getPluginId(), "Target has not been resolved"));
360
			setEnabled(false);
361
			return;
362
		}
363
		IResolvedBundle[] allResolvedBundles = input.getAllBundles();
364
		if (allResolvedBundles == null || allResolvedBundles.length == 0) {
365
			fTree.setInput("< no plug-ins found in the target >");
366
			setEnabled(false);
367
			return;
368
		}
369
370
		// Input is valid, setup the tree
371
		fAllBundles = allResolvedBundles;
372
		fTree.setInput(allResolvedBundles);
373
374
		// Check the included bundles
375
		IResolvedBundle[] included = input.getBundles();
376
		fTree.setCheckedElements(included);
377
378
		// Enable the tree and update the buttons
379
		setEnabled(true);
380
	}
381
382
	/* (non-Javadoc)
383
	 * @see org.eclipse.swt.widgets.Control#setEnabled(boolean)
384
	 */
385
	public void setEnabled(boolean enabled) {
386
		super.setEnabled(enabled);
387
		if (enabled) {
388
			updateButtons();
389
		} else {
390
			fSelectButton.setEnabled(false);
391
			fSelectAllButton.setEnabled(false);
392
			fDeselectButton.setEnabled(false);
393
			fDeselectAllButton.setEnabled(false);
394
//			fSelectRequiredButton.setEnabled(false);
395
			fCountLabel.setText(""); //$NON-NLS-1$
396
		}
397
		fShowLabel.setEnabled(enabled);
398
		fShowPluginsButton.setEnabled(enabled);
399
		fShowSourceButton.setEnabled(enabled);
400
		super.setEnabled(enabled);
401
	}
402
403
	protected TreeViewer doCreateTreeViewer(Composite parent, int style) {
404
		fTree = new CheckboxTreeViewer(parent, style) {
405
			public void refresh(boolean updateLabels) {
406
				super.refresh(updateLabels);
407
				if (updateLabels) {
408
					// We want to update the labels and buttons as users change the filtering
409
					updateButtons();
410
				}
411
			}
412
		};
413
		fTree.setContentProvider(getContentProviderForTree());
414
		fTree.setLabelProvider(new BundleInfoLabelProvider(true));
415
		fTree.addDoubleClickListener(new IDoubleClickListener() {
416
			public void doubleClick(DoubleClickEvent event) {
417
				IStructuredSelection selection = (IStructuredSelection) event.getSelection();
418
				fTree.setChecked(selection.getFirstElement(), !fTree.getChecked(selection.getFirstElement()));
419
				updateButtons();
420
			}
421
		});
422
		fTree.addCheckStateListener(new ICheckStateListener() {
423
424
			public void checkStateChanged(CheckStateChangedEvent event) {
425
				if (fIsGroupedByLocation) {
426
					handleCheck(event.getElement(), event.getChecked());
427
					updateButtons();
428
				}
429
			}
430
		});
431
		fTree.addSelectionChangedListener(new ISelectionChangedListener() {
432
			public void selectionChanged(SelectionChangedEvent event) {
433
				updateButtons();
434
			}
435
		});
436
		fTree.setSorter(new ViewerSorter());
437
		return fTree;
438
	}
439
440
	/**
441
	 * Marks the check state of <code>element</code> to <code>state</code> when plug-ins are grouped by location 
442
	 */
443
	private void handleCheck(Object element, boolean state) {
444
		if (fTreeViewerContents.containsKey(element)) {
445
446
			HashMap bundles = (HashMap) fTreeViewerContents.get(element);
447
			Iterator iter = bundles.keySet().iterator();
448
			while (iter.hasNext()) {
449
				Object key = iter.next();
450
				bundles.put(key, new Boolean(state));
451
				fTree.setChecked(key, state);
452
			}
453
			fTree.setChecked(element, state);
454
			fTree.setGrayed(element, false);
455
			return;
456
		}
457
		Iterator iter = fTreeViewerContents.keySet().iterator();
458
		HashMap bundles = null;
459
		Object key = null;
460
		while (iter.hasNext()) {
461
			key = iter.next();
462
			bundles = (HashMap) fTreeViewerContents.get(key);
463
			if (bundles.containsKey(element)) {
464
				bundles.put(element, new Boolean(state));
465
				break;
466
			}
467
		}
468
		iter = bundles.keySet().iterator();
469
		boolean allChilrenSelected = true;
470
		boolean noneChildrenSelected = true;
471
		while (iter.hasNext()) {
472
			Object bundle = iter.next();
473
			boolean checkedState = ((Boolean) bundles.get(bundle)).booleanValue();
474
			allChilrenSelected = allChilrenSelected && checkedState;
475
			noneChildrenSelected = noneChildrenSelected && !checkedState;
476
		}
477
		fTree.setChecked(element, state);
478
		fTree.setChecked(key, !noneChildrenSelected);
479
		fTree.setGrayed(key, !allChilrenSelected && !noneChildrenSelected);
480
	}
481
482
	private ITreeContentProvider getContentProviderForTree() {
483
		if (fIsGroupedByLocation) {
484
485
			//Content provider for grouped by location
486
			return (new ITreeContentProvider() {
487
488
				public Object[] getChildren(Object parentElement) {
489
					if (parentElement instanceof File) {
490
						HashMap files = (HashMap) fTreeViewerContents.get(parentElement);
491
						if (files != null) {
492
							Object[] result = files.keySet().toArray();
493
							return result;
494
						}
495
					}
496
					return new Object[0];
497
				}
498
499
				public Object getParent(Object element) {
500
					if (element instanceof IResolvedBundle) {
501
						IResolvedBundle bundle = (IResolvedBundle) element;
502
						String installPath = bundle.getBundleInfo().getLocation().getPath();
503
						if (installPath != null)
504
							return new File(installPath).getParentFile();
505
					}
506
					return null;
507
				}
508
509
				public boolean hasChildren(Object element) {
510
					if (element instanceof File)
511
						return fTreeViewerContents.containsKey(element);
512
					return false;
513
				}
514
515
				public Object[] getElements(Object inputElement) {
516
					if (fTreeViewerContents == null)
517
						return initializeTreeContents(fAllBundles).keySet().toArray();
518
					return fTreeViewerContents.keySet().toArray();
519
				}
520
521
				public void dispose() {
522
				}
523
524
				public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
525
				}
526
			});
527
		}
528
529
		//ungrouped content provider
530
		return (new ITreeContentProvider() {
531
			public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
532
			}
533
534
			public void dispose() {
535
			}
536
537
			public Object[] getElements(Object inputElement) {
538
				if (inputElement instanceof IResolvedBundle[]) {
539
					return (IResolvedBundle[]) inputElement;
540
				}
541
				return new Object[] {inputElement};
542
			}
543
544
			public boolean hasChildren(Object element) {
545
				return false;
546
			}
547
548
			public Object getParent(Object element) {
549
				return null;
550
			}
551
552
			public Object[] getChildren(Object parentElement) {
553
				return new Object[0];
554
			}
555
		});
556
	}
557
558
	/**
559
	 * Return the set of bundles to include in this bundle container based on what is
560
	 * checked in the tree.  If all bundles in the container are checked or there was
561
	 * a problem getting the bundles from the container, this method will return 
562
	 * <code>null</code>
563
	 * 
564
	 * @return set of bundles to include or <code>null</code>
565
	 */
566
	public BundleInfo[] getIncludedBundles() {
567
		if (fTree.getControl().isEnabled() && fAllBundles != null) {
568
			Object[] checked = fTree.getCheckedElements();
569
			if (fIsGroupedByLocation) {
570
				int count = fTree.getCheckedElements().length;
571
				Iterator iter = fTreeViewerContents.keySet().iterator();
572
				while (iter.hasNext()) {
573
					if (fTree.getChecked(iter.next())) {
574
						--count;
575
					}
576
				}
577
				if (count == fAllBundles.length)
578
					return null;
579
580
			} else if (checked.length == fAllBundles.length) {
581
				return null;
582
			}
583
584
			java.util.List included = new ArrayList(checked.length);
585
			for (int i = 0; i < checked.length; i++) {
586
				if (checked[i] instanceof IResolvedBundle) {
587
					included.add(new BundleInfo(((IResolvedBundle) checked[i]).getBundleInfo().getSymbolicName(), null, null, BundleInfo.NO_LEVEL, false));
588
				}
589
			}
590
			return (BundleInfo[]) included.toArray(new BundleInfo[included.size()]);
591
		}
592
		return null;
593
	}
594
}
(-)src/org/eclipse/pde/internal/ui/shared/target/BundleContainerGroup.java (+461 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2009 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.ui.shared.target;
12
13
import java.util.ArrayList;
14
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.ListenerList;
16
import org.eclipse.jface.viewers.*;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.jface.wizard.WizardDialog;
19
import org.eclipse.pde.internal.core.target.provisional.*;
20
import org.eclipse.pde.internal.ui.SWTFactory;
21
import org.eclipse.pde.internal.ui.editor.FormLayoutFactory;
22
import org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor;
23
import org.eclipse.swt.SWT;
24
import org.eclipse.swt.events.SelectionAdapter;
25
import org.eclipse.swt.events.SelectionEvent;
26
import org.eclipse.swt.layout.GridData;
27
import org.eclipse.swt.layout.GridLayout;
28
import org.eclipse.swt.widgets.*;
29
import org.eclipse.ui.forms.widgets.FormToolkit;
30
31
/**
32
 * UI part that can be added to a dialog or to a form editor.  Contains a table displaying
33
 * the bundle containers of a target definition.  Also has buttons to add, edit and remove
34
 * bundle containers of varying types.
35
 * 
36
 * @see TargetEditor
37
 * @see ITargetDefinition
38
 * @see IBundleContainer
39
 */
40
public class BundleContainerGroup {
41
42
	private TreeViewer fTreeViewer;
43
	private Button fAddButton;
44
	private Button fEditButton;
45
	private Button fRemoveButton;
46
	private Button fRemoveAllButton;
47
	private Button fShowContentButton;
48
49
	private ITargetDefinition fTarget;
50
	private ListenerList fChangeListeners = new ListenerList();
51
52
	/**
53
	 * Creates this part using the form toolkit and adds it to the given composite.
54
	 * 
55
	 * @param parent parent composite
56
	 * @param toolkit toolkit to create the widgets with
57
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
58
	 * @return generated instance of the table part
59
	 */
60
	public static BundleContainerGroup createInForm(Composite parent, FormToolkit toolkit) {
61
		BundleContainerGroup contentTable = new BundleContainerGroup();
62
		contentTable.createFormContents(parent, toolkit);
63
		return contentTable;
64
	}
65
66
	/**
67
	 * Creates this part using standard dialog widgets and adds it to the given composite.
68
	 * 
69
	 * @param parent parent composite
70
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
71
	 * @return generated instance of the table part
72
	 */
73
	public static BundleContainerGroup createInDialog(Composite parent) {
74
		BundleContainerGroup contentTable = new BundleContainerGroup();
75
		contentTable.createDialogContents(parent);
76
		return contentTable;
77
	}
78
79
	/**
80
	 * Private constructor, use one of {@link #createTableInDialog(Composite, ITargetChangedListener)}
81
	 * or {@link #createTableInForm(Composite, FormToolkit, ITargetChangedListener)}.
82
	 * 
83
	 * @param reporter reporter implementation that will handle resolving and changes to the containers
84
	 */
85
	private BundleContainerGroup() {
86
87
	}
88
89
	/**
90
	 * Adds a listener to the set of listeners that will be notified when the bundle containers
91
	 * are modified.  This method has no effect if the listener has already been added. 
92
	 * 
93
	 * @param listener target changed listener to add
94
	 */
95
	public void addTargetChangedListener(ITargetChangedListener listener) {
96
		fChangeListeners.add(listener);
97
	}
98
99
	/**
100
	 * Creates the part contents from a toolkit
101
	 * @param parent parent composite
102
	 * @param toolkit form toolkit to create widgets
103
	 */
104
	private void createFormContents(Composite parent, FormToolkit toolkit) {
105
		Composite comp = toolkit.createComposite(parent);
106
		comp.setLayout(FormLayoutFactory.createSectionClientGridLayout(false, 2));
107
		comp.setLayoutData(new GridData(GridData.FILL_BOTH | GridData.GRAB_VERTICAL));
108
109
		Tree atree = toolkit.createTree(comp, SWT.V_SCROLL | SWT.H_SCROLL);
110
		atree.setLayout(new GridLayout());
111
		GridData gd = new GridData(GridData.FILL_BOTH);
112
		atree.setLayoutData(gd);
113
114
		Composite buttonComp = toolkit.createComposite(comp);
115
		GridLayout layout = new GridLayout();
116
		layout.marginWidth = layout.marginHeight = 0;
117
		buttonComp.setLayout(layout);
118
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
119
120
		fAddButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_0, SWT.PUSH);
121
		fEditButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_1, SWT.PUSH);
122
		fRemoveButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_2, SWT.PUSH);
123
		fRemoveAllButton = toolkit.createButton(buttonComp, Messages.BundleContainerTable_3, SWT.PUSH);
124
125
		fShowContentButton = toolkit.createButton(comp, "Show plug-in content", SWT.CHECK);
126
127
		initializeTreeViewer(atree);
128
		initializeButtons();
129
130
		toolkit.paintBordersFor(comp);
131
	}
132
133
	/**
134
	 * Creates the part contents using SWTFactory
135
	 * @param parent parent composite
136
	 */
137
	private void createDialogContents(Composite parent) {
138
		Composite comp = SWTFactory.createComposite(parent, 2, 1, GridData.FILL_BOTH, 0, 0);
139
140
		Tree atree = new Tree(comp, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
141
		atree.setLayout(new GridLayout());
142
		GridData gd = new GridData(GridData.FILL_BOTH);
143
		gd.widthHint = 200;
144
		atree.setLayoutData(gd);
145
146
		Composite buttonComp = SWTFactory.createComposite(comp, 2, 1, GridData.FILL_BOTH);
147
		GridLayout layout = new GridLayout();
148
		layout.marginHeight = 0;
149
		layout.marginWidth = 0;
150
		buttonComp.setLayout(layout);
151
		buttonComp.setLayoutData(new GridData(GridData.FILL_VERTICAL));
152
153
		fAddButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_0, null);
154
		fEditButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_1, null);
155
		fRemoveButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_2, null);
156
		fRemoveAllButton = SWTFactory.createPushButton(buttonComp, Messages.BundleContainerTable_3, null);
157
158
		fShowContentButton = SWTFactory.createCheckButton(comp, "Show Plug-in Content", null, false, 2);
159
160
		initializeTreeViewer(atree);
161
		initializeButtons();
162
	}
163
164
	/**
165
	 * Sets up the tree viewer using the given tree
166
	 * @param tree
167
	 */
168
	private void initializeTreeViewer(Tree tree) {
169
		fTreeViewer = new TreeViewer(tree);
170
		fTreeViewer.setContentProvider(new BundleContainerContentProvider());
171
		fTreeViewer.setLabelProvider(new BundleContainerLabelProvider());
172
		fTreeViewer.setComparator(new ViewerComparator());
173
		fTreeViewer.addSelectionChangedListener(new ISelectionChangedListener() {
174
			public void selectionChanged(SelectionChangedEvent event) {
175
				updateButtons();
176
			}
177
		});
178
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
179
			public void doubleClick(DoubleClickEvent event) {
180
				if (!event.getSelection().isEmpty()) {
181
					handleEdit();
182
				}
183
			}
184
		});
185
		fTreeViewer.setAutoExpandLevel(AbstractTreeViewer.ALL_LEVELS);
186
	}
187
188
	/**
189
	 * Sets up the buttons, the button fields must already be created before calling this method
190
	 */
191
	private void initializeButtons() {
192
		fAddButton.addSelectionListener(new SelectionAdapter() {
193
			public void widgetSelected(SelectionEvent e) {
194
				handleAdd();
195
			}
196
		});
197
		fAddButton.setLayoutData(new GridData());
198
		SWTFactory.setButtonDimensionHint(fAddButton);
199
200
		fEditButton.addSelectionListener(new SelectionAdapter() {
201
			public void widgetSelected(SelectionEvent e) {
202
				handleEdit();
203
			}
204
		});
205
		fEditButton.setLayoutData(new GridData());
206
		fEditButton.setEnabled(false);
207
		SWTFactory.setButtonDimensionHint(fEditButton);
208
209
		fRemoveButton.addSelectionListener(new SelectionAdapter() {
210
			public void widgetSelected(SelectionEvent e) {
211
				handleRemove();
212
			}
213
		});
214
		fRemoveButton.setLayoutData(new GridData());
215
		fRemoveButton.setEnabled(false);
216
		SWTFactory.setButtonDimensionHint(fRemoveButton);
217
218
		fRemoveAllButton.addSelectionListener(new SelectionAdapter() {
219
			public void widgetSelected(SelectionEvent e) {
220
				handleRemoveAll();
221
			}
222
		});
223
		fRemoveAllButton.setLayoutData(new GridData());
224
		SWTFactory.setButtonDimensionHint(fRemoveAllButton);
225
226
		fShowContentButton.addSelectionListener(new SelectionAdapter() {
227
			public void widgetSelected(SelectionEvent e) {
228
				fTreeViewer.refresh();
229
				fTreeViewer.expandAll();
230
			}
231
		});
232
		fShowContentButton.setLayoutData(new GridData());
233
		SWTFactory.setButtonDimensionHint(fShowContentButton);
234
	}
235
236
	/**
237
	 * Sets the target definition model to use as input for the tree, can be called with different
238
	 * models to change the tree's input.
239
	 * @param target target model
240
	 */
241
	public void setInput(ITargetDefinition target) {
242
		fTarget = target;
243
		refresh();
244
	}
245
246
	/**
247
	 * Refreshes the contents of the table
248
	 */
249
	public void refresh() {
250
		fTreeViewer.setInput(fTarget);
251
		updateButtons();
252
	}
253
254
//	private void setEnabled(boolean enablement) {
255
//		fTreeViewer.getControl().setEnabled(enablement);
256
//		fAddButton.setEnabled(enablement);
257
//
258
//		if (enablement) {
259
//			updateButtons();
260
//		} else {
261
//			fRemoveButton.setEnabled(enablement);
262
//			fRemoveAllButton.setEnabled(enablement);
263
//			fEditButton.setEnabled(enablement);
264
//		}
265
//	}
266
267
	private void handleAdd() {
268
		AddBundleContainerWizard wizard = new AddBundleContainerWizard(fTarget);
269
		Shell parent = fTreeViewer.getTree().getShell();
270
		WizardDialog dialog = new WizardDialog(parent, wizard);
271
		if (dialog.open() != Window.CANCEL) {
272
			contentsChanged();
273
		}
274
	}
275
276
	private void handleEdit() {
277
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
278
		if (!selection.isEmpty()) {
279
			Object selected = selection.getFirstElement();
280
			IBundleContainer oldContainer = null;
281
			if (selected instanceof IBundleContainer) {
282
				oldContainer = (IBundleContainer) selected;
283
			} else if (selected instanceof IResolvedBundle) {
284
				TreeItem[] treeSelection = fTreeViewer.getTree().getSelection();
285
				if (treeSelection.length > 0) {
286
					Object parent = treeSelection[0].getParentItem().getData();
287
					if (parent instanceof IBundleContainer) {
288
						oldContainer = (IBundleContainer) parent;
289
					}
290
				}
291
			}
292
			if (oldContainer != null) {
293
				Shell parent = fTreeViewer.getTree().getShell();
294
				EditBundleContainerWizard wizard = new EditBundleContainerWizard(oldContainer);
295
				WizardDialog dialog = new WizardDialog(parent, wizard);
296
				if (dialog.open() == Window.OK) {
297
					// Replace the old container with the new one
298
					IBundleContainer newContainer = wizard.getBundleContainer();
299
					if (newContainer != null) {
300
						IBundleContainer[] containers = fTarget.getBundleContainers();
301
						java.util.List newContainers = new ArrayList(containers.length);
302
						for (int i = 0; i < containers.length; i++) {
303
							if (!containers[i].equals(oldContainer)) {
304
								newContainers.add(containers[i]);
305
							}
306
						}
307
						newContainers.add(newContainer);
308
						fTarget.setBundleContainers((IBundleContainer[]) newContainers.toArray(new IBundleContainer[newContainers.size()]));
309
310
						// Update the table
311
						contentsChanged();
312
						fTreeViewer.setSelection(new StructuredSelection(newContainer), true);
313
					}
314
				}
315
			}
316
		}
317
	}
318
319
	private void handleRemove() {
320
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
321
		if (!selection.isEmpty()) {
322
			Object selected = selection.getFirstElement();
323
			IBundleContainer container = null;
324
			if (selected instanceof IBundleContainer) {
325
				container = (IBundleContainer) selected;
326
				IBundleContainer[] currentContainers = fTarget.getBundleContainers();
327
				ArrayList newBundleContainers = new ArrayList(currentContainers.length);
328
				for (int i = 0; i < currentContainers.length; i++) {
329
					if (!currentContainers[i].equals(container)) {
330
						newBundleContainers.add(currentContainers[i]);
331
					}
332
				}
333
				fTarget.setBundleContainers((IBundleContainer[]) newBundleContainers.toArray(new IBundleContainer[newBundleContainers.size()]));
334
				contentsChanged();
335
			}
336
		}
337
	}
338
339
	private void handleRemoveAll() {
340
		fTarget.setBundleContainers(null);
341
		contentsChanged();
342
	}
343
344
	private void updateButtons() {
345
		IStructuredSelection selection = (IStructuredSelection) fTreeViewer.getSelection();
346
		fEditButton.setEnabled(!selection.isEmpty() && (selection.getFirstElement() instanceof IBundleContainer || selection.getFirstElement() instanceof IResolvedBundle));
347
		fRemoveButton.setEnabled(!selection.isEmpty() && selection.getFirstElement() instanceof IBundleContainer);
348
		fRemoveAllButton.setEnabled(fTarget != null && fTarget.getBundleContainers() != null && fTarget.getBundleContainers().length > 0);
349
	}
350
351
	/**
352
	 * Informs the reporter for this table that something has changed
353
	 * and is dirty.
354
	 */
355
	private void contentsChanged() {
356
		Object[] listeners = fChangeListeners.getListeners();
357
		for (int i = 0; i < listeners.length; i++) {
358
			((ITargetChangedListener) listeners[i]).contentsChanged(fTarget);
359
		}
360
		refresh();
361
	}
362
363
//	/**
364
//	 * Runnable that resolves the target.  Disables the table while running
365
//	 */
366
//	class ResolveContainersOperation implements IRunnableWithProgress {
367
//
368
//		/* (non-Javadoc)
369
//		 * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
370
//		 */
371
//		public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
372
//			Job job = new UIJob(Messages.BundleContainerTable_16) {
373
//				public IStatus runInUIThread(IProgressMonitor monitor) {
374
//					if (!fTreeViewer.getControl().isDisposed()) {
375
//						setEnabled(false);
376
//						fTreeViewer.setInput(Messages.BundleContainerTable_17);
377
//						fTreeViewer.refresh();
378
//					}
379
//					return Status.OK_STATUS;
380
//				}
381
//			};
382
//			job.setSystem(true);
383
//			job.schedule();
384
//			fTarget.resolve(monitor);
385
//			if (!monitor.isCanceled()) {
386
//				job = new UIJob(Messages.BundleContainerTable_18) {
387
//					public IStatus runInUIThread(IProgressMonitor monitor) {
388
//						if (!fTreeViewer.getControl().isDisposed()) {
389
//							setEnabled(true);
390
//							fTreeViewer.setInput(fTarget);
391
//							fTreeViewer.refresh();
392
//							updateButtons();
393
//						}
394
//						return Status.OK_STATUS;
395
//					}
396
//				};
397
//				job.setSystem(true);
398
//				job.schedule();
399
//			}
400
//		}
401
//	}
402
403
	/**
404
	 * Content provider for the tree, primary input is a ITargetDefinition, children are IBundleContainers
405
	 */
406
	class BundleContainerContentProvider implements ITreeContentProvider {
407
408
		public Object[] getChildren(Object parentElement) {
409
			if (parentElement instanceof ITargetDefinition) {
410
				IBundleContainer[] containers = ((ITargetDefinition) parentElement).getBundleContainers();
411
				return containers != null ? containers : new Object[0];
412
			} else if (parentElement instanceof IBundleContainer) {
413
				if (fShowContentButton.getSelection()) {
414
					IBundleContainer container = (IBundleContainer) parentElement;
415
					if (container.isResolved()) {
416
						IStatus status = container.getBundleStatus();
417
						if (!status.isOK() && !status.isMultiStatus()) {
418
							return new Object[] {status};
419
						}
420
						return container.getBundles();
421
					}
422
				}
423
			} else if (parentElement instanceof IResolvedBundle) {
424
				IStatus status = ((IResolvedBundle) parentElement).getStatus();
425
				if (!status.isOK()) {
426
					return new Object[] {status};
427
				}
428
			}
429
			return new Object[0];
430
		}
431
432
		public Object getParent(Object element) {
433
			return null;
434
		}
435
436
		public boolean hasChildren(Object element) {
437
			// Since we are already resolved we can't be more efficient
438
			return getChildren(element).length > 0;
439
		}
440
441
		public Object[] getElements(Object inputElement) {
442
			if (inputElement instanceof ITargetDefinition) {
443
				IBundleContainer[] containers = ((ITargetDefinition) inputElement).getBundleContainers();
444
				if (containers != null) {
445
					return containers;
446
				}
447
			} else if (inputElement instanceof String) {
448
				return new Object[] {inputElement};
449
			}
450
			return new Object[0];
451
		}
452
453
		public void dispose() {
454
		}
455
456
		public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
457
		}
458
459
	}
460
461
}

Return to bug 270626