View | Details | Raw Unified | Return to bug 383795
Collapse All | Expand All

(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/isite/ISite.java (+6 lines)
Lines 54-71 public interface ISite extends ISiteObject { Link Here
54
54
55
	void addFeatures(ISiteFeature[] features) throws CoreException;
55
	void addFeatures(ISiteFeature[] features) throws CoreException;
56
56
57
	void addBundles(ISiteBundle[] added) throws CoreException;
58
57
	void addArchives(ISiteArchive[] archives) throws CoreException;
59
	void addArchives(ISiteArchive[] archives) throws CoreException;
58
60
59
	void addCategoryDefinitions(ISiteCategoryDefinition[] defs) throws CoreException;
61
	void addCategoryDefinitions(ISiteCategoryDefinition[] defs) throws CoreException;
60
62
61
	void removeFeatures(ISiteFeature[] features) throws CoreException;
63
	void removeFeatures(ISiteFeature[] features) throws CoreException;
62
64
65
	void removeBundles(ISiteBundle[] bundles) throws CoreException;
66
63
	void removeArchives(ISiteArchive[] archives) throws CoreException;
67
	void removeArchives(ISiteArchive[] archives) throws CoreException;
64
68
65
	void removeCategoryDefinitions(ISiteCategoryDefinition[] defs) throws CoreException;
69
	void removeCategoryDefinitions(ISiteCategoryDefinition[] defs) throws CoreException;
66
70
67
	ISiteFeature[] getFeatures();
71
	ISiteFeature[] getFeatures();
68
72
73
	ISiteBundle[] getBundles();
74
69
	ISiteArchive[] getArchives();
75
	ISiteArchive[] getArchives();
70
76
71
	ISiteCategoryDefinition[] getCategoryDefinitions();
77
	ISiteCategoryDefinition[] getCategoryDefinitions();
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/isite/ISiteBundle.java (+23 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2000, 2008 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
 *     Red Hat Inc. - Copied from IFeatureBundle
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.core.isite;
13
14
import org.eclipse.core.runtime.CoreException;
15
import org.eclipse.pde.internal.core.ifeature.IVersionable;
16
17
public interface ISiteBundle extends IVersionable, ISiteObject {
18
	void addCategories(ISiteCategory[] categories) throws CoreException;
19
20
	void removeCategories(ISiteCategory[] categories) throws CoreException;
21
22
	ISiteCategory[] getCategories();
23
}
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/isite/ISiteModelFactory.java (+16 lines)
Lines 7-12 Link Here
7
 * 
7
 * 
8
 *  Contributors:
8
 *  Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Red Hat Inc. - Support for <bundle...> in category.xml
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.isite;
12
package org.eclipse.pde.internal.core.isite;
12
13
Lines 30-35 public interface ISiteModelFactory { Link Here
30
	ISiteFeature createFeature();
31
	ISiteFeature createFeature();
31
32
32
	/**
33
	/**
34
	 * Creates a new bundle model object.
35
	 *
36
	 * @return new instance of the bundle data object
37
	 */
38
	ISiteBundle createBundle();
39
40
	/**
33
	 * Creates a new feature child object.
41
	 * Creates a new feature child object.
34
	 *
42
	 *
35
	 * @return new instance of the feature child object
43
	 * @return new instance of the feature child object
Lines 37-42 public interface ISiteModelFactory { Link Here
37
	ISiteCategory createCategory(ISiteFeature feature);
45
	ISiteCategory createCategory(ISiteFeature feature);
38
46
39
	/**
47
	/**
48
	 * Creates a new feature child object.
49
	 *
50
	 * @return new instance of the feature child object
51
	 */
52
	ISiteCategory createCategory(ISiteBundle feature);
53
54
	/**
40
	 * Creates a new import model object.
55
	 * Creates a new import model object.
41
	 *
56
	 *
42
	 * @return new instance of the feature import object
57
	 * @return new instance of the feature import object
Lines 56-59 public interface ISiteModelFactory { Link Here
56
	 * @return a new feature install handler.
71
	 * @return a new feature install handler.
57
	 */
72
	 */
58
	ISiteArchive createArchive();
73
	ISiteArchive createArchive();
74
59
}
75
}
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/site/Site.java (+47 lines)
Lines 7-12 Link Here
7
 *
7
 *
8
 * Contributors:
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
9
 *     IBM Corporation - initial API and implementation
10
 *     Red Hat Inc. - Support for <bundle...> tag
10
 *******************************************************************************/
11
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.site;
12
package org.eclipse.pde.internal.core.site;
12
13
Lines 24-29 public class Site extends SiteObject implements ISite { Link Here
24
	private static final long serialVersionUID = 1L;
25
	private static final long serialVersionUID = 1L;
25
	final static String INDENT = "   "; //$NON-NLS-1$
26
	final static String INDENT = "   "; //$NON-NLS-1$
26
	private Vector features = new Vector();
27
	private Vector features = new Vector();
28
	private Vector bundles = new Vector();
27
	private Vector archives = new Vector();
29
	private Vector archives = new Vector();
28
	private Vector categoryDefs = new Vector();
30
	private Vector categoryDefs = new Vector();
29
	private String type;
31
	private String type;
Lines 149-154 public class Site extends SiteObject implements ISite { Link Here
149
	}
151
	}
150
152
151
	/**
153
	/**
154
	 * @see org.eclipse.pde.internal.core.isite.ISite#addBundles(org.eclipse.pde.internal.core.isite.ISiteBundle)
155
	 */
156
	public void addBundles(ISiteBundle[] newBundles) throws CoreException {
157
		ensureModelEditable();
158
		for (int i = 0; i < newBundles.length; i++) {
159
			ISiteBundle bundle = newBundles[i];
160
			((SiteBundle) bundle).setInTheModel(true);
161
			bundles.add(bundle);
162
		}
163
		fireStructureChanged(newBundles, IModelChangedEvent.INSERT);
164
	}
165
166
	/**
152
	 * @see org.eclipse.pde.internal.core.isite.ISite#addArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
167
	 * @see org.eclipse.pde.internal.core.isite.ISite#addArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
153
	 */
168
	 */
154
	public void addArchives(ISiteArchive[] archs) throws CoreException {
169
	public void addArchives(ISiteArchive[] archs) throws CoreException {
Lines 188-193 public class Site extends SiteObject implements ISite { Link Here
188
	}
203
	}
189
204
190
	/**
205
	/**
206
	 * @see org.eclipse.pde.internal.core.isite.ISite#removeBundles(org.eclipse.pde.internal.core.isite.ISiteBundle)
207
	 */
208
	public void removeBundles(ISiteBundle[] newBundles) throws CoreException {
209
		ensureModelEditable();
210
		for (int i = 0; i < newBundles.length; i++) {
211
			ISiteBundle bundle = newBundles[i];
212
			((SiteFeature) bundle).setInTheModel(false);
213
			bundles.remove(bundle);
214
		}
215
		fireStructureChanged(newBundles, IModelChangedEvent.REMOVE);
216
	}
217
218
	/**
191
	 * @see org.eclipse.pde.internal.core.isite.ISite#removeArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
219
	 * @see org.eclipse.pde.internal.core.isite.ISite#removeArchives(org.eclipse.pde.internal.core.isite.ISiteArchive)
192
	 */
220
	 */
193
	public void removeArchives(ISiteArchive[] archs) throws CoreException {
221
	public void removeArchives(ISiteArchive[] archs) throws CoreException {
Lines 221-226 public class Site extends SiteObject implements ISite { Link Here
221
	}
249
	}
222
250
223
	/**
251
	/**
252
	 * @see org.eclipse.pde.internal.core.isite.ISite#getBundles()
253
	 */
254
	public ISiteBundle[] getBundles() {
255
		return (ISiteBundle[]) bundles.toArray(new ISiteBundle[bundles.size()]);
256
	}
257
258
	/**
224
	 * @see org.eclipse.pde.internal.core.isite.ISite#getArchives()
259
	 * @see org.eclipse.pde.internal.core.isite.ISite#getArchives()
225
	 */
260
	 */
226
	public ISiteArchive[] getArchives() {
261
	public ISiteArchive[] getArchives() {
Lines 238-243 public class Site extends SiteObject implements ISite { Link Here
238
		archives.clear();
273
		archives.clear();
239
		categoryDefs.clear();
274
		categoryDefs.clear();
240
		features.clear();
275
		features.clear();
276
		bundles.clear();
241
		description = null;
277
		description = null;
242
		type = null;
278
		type = null;
243
		url = null;
279
		url = null;
Lines 268-273 public class Site extends SiteObject implements ISite { Link Here
268
			((SiteFeature) feature).parse(child);
304
			((SiteFeature) feature).parse(child);
269
			((SiteFeature) feature).setInTheModel(true);
305
			((SiteFeature) feature).setInTheModel(true);
270
			features.add(feature);
306
			features.add(feature);
307
		} else if (tag.equals("bundle")) { //$NON-NLS-1$
308
			ISiteBundle bundle = getModel().getFactory().createBundle();
309
			((SiteBundle) bundle).parse(child);
310
			((SiteBundle) bundle).setInTheModel(true);
311
			bundles.add(bundle);
271
		} else if (tag.equals("archive")) { //$NON-NLS-1$
312
		} else if (tag.equals("archive")) { //$NON-NLS-1$
272
			ISiteArchive archive = getModel().getFactory().createArchive();
313
			ISiteArchive archive = getModel().getFactory().createArchive();
273
			((SiteArchive) archive).parse(child);
314
			((SiteArchive) archive).parse(child);
Lines 319-324 public class Site extends SiteObject implements ISite { Link Here
319
			description.write(indent2, writer);
360
			description.write(indent2, writer);
320
		}
361
		}
321
		writeChildren(indent2, features, writer);
362
		writeChildren(indent2, features, writer);
363
		writeChildren(indent2, bundles, writer);
322
		writeChildren(indent2, archives, writer);
364
		writeChildren(indent2, archives, writer);
323
		writeChildren(indent2, categoryDefs, writer);
365
		writeChildren(indent2, categoryDefs, writer);
324
		writer.println(indent + "</site>"); //$NON-NLS-1$
366
		writer.println(indent + "</site>"); //$NON-NLS-1$
Lines 330-335 public class Site extends SiteObject implements ISite { Link Here
330
			if (!feature.isValid())
372
			if (!feature.isValid())
331
				return false;
373
				return false;
332
		}
374
		}
375
		for (int i = 0; i < bundles.size(); i++) {
376
			ISiteBundle bundle = (ISiteBundle) bundles.get(i);
377
			if (!bundle.isValid())
378
				return false;
379
		}
333
		for (int i = 0; i < archives.size(); i++) {
380
		for (int i = 0; i < archives.size(); i++) {
334
			ISiteArchive archive = (ISiteArchive) archives.get(i);
381
			ISiteArchive archive = (ISiteArchive) archives.get(i);
335
			if (!archive.isValid())
382
			if (!archive.isValid())
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/site/SiteBundle.java (+112 lines)
Added Link Here
1
/*******************************************************************************
2
 *  Copyright (c) 2000, 20012 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
 *     Red Hat Inc. - <bundle...> in category.xml (copied from SiteFeature)
11
 *******************************************************************************/
12
package org.eclipse.pde.internal.core.site;
13
14
import java.io.PrintWriter;
15
import java.util.Vector;
16
import org.eclipse.core.runtime.CoreException;
17
import org.eclipse.pde.core.IModelChangedEvent;
18
import org.eclipse.pde.internal.core.isite.ISiteBundle;
19
import org.eclipse.pde.internal.core.isite.ISiteCategory;
20
import org.w3c.dom.Node;
21
import org.w3c.dom.NodeList;
22
23
public class SiteBundle extends VersionableObject implements ISiteBundle {
24
	private static final long serialVersionUID = 1L;
25
	private Vector fCategories = new Vector();
26
27
	public boolean isValid() {
28
		for (int i = 0; i < fCategories.size(); i++) {
29
			ISiteCategory category = (ISiteCategory) fCategories.get(i);
30
			if (!category.isValid())
31
				return false;
32
		}
33
		return true;
34
	}
35
36
	/**
37
	 * @see org.eclipse.pde.internal.core.isite.ISiteFeature#addCategories(org.eclipse.pde.internal.core.isite.ISiteCategory)
38
	 */
39
	public void addCategories(ISiteCategory[] newCategories) throws CoreException {
40
		ensureModelEditable();
41
		for (int i = 0; i < newCategories.length; i++) {
42
			ISiteCategory category = newCategories[i];
43
			((SiteCategory) category).setInTheModel(true);
44
			fCategories.add(newCategories[i]);
45
		}
46
		fireStructureChanged(newCategories, IModelChangedEvent.INSERT);
47
	}
48
49
	/**
50
	 * @see org.eclipse.pde.internal.core.isite.ISiteFeature#removeCategories(org.eclipse.pde.internal.core.isite.ISiteCategory)
51
	 */
52
	public void removeCategories(ISiteCategory[] newCategories) throws CoreException {
53
		ensureModelEditable();
54
		for (int i = 0; i < newCategories.length; i++) {
55
			ISiteCategory category = newCategories[i];
56
			((SiteCategory) category).setInTheModel(false);
57
			fCategories.remove(newCategories[i]);
58
		}
59
		fireStructureChanged(newCategories, IModelChangedEvent.REMOVE);
60
	}
61
62
	/**
63
	 * @see org.eclipse.pde.internal.core.isite.ISiteFeature#getCategories()
64
	 */
65
	public ISiteCategory[] getCategories() {
66
		return (ISiteCategory[]) fCategories.toArray(new ISiteCategory[fCategories.size()]);
67
	}
68
69
	protected void parse(Node node) {
70
		super.parse(node);
71
		NodeList children = node.getChildNodes();
72
		for (int i = 0; i < children.getLength(); i++) {
73
			Node child = children.item(i);
74
			if (child.getNodeType() == Node.ELEMENT_NODE && child.getNodeName().equalsIgnoreCase("category")) { //$NON-NLS-1$
75
				SiteCategory category = (SiteCategory) getModel().getFactory().createCategory(this);
76
				category.parse(child);
77
				category.setInTheModel(true);
78
				fCategories.add(category);
79
			}
80
		}
81
	}
82
83
	protected void reset() {
84
		super.reset();
85
		fCategories.clear();
86
	}
87
88
	/**
89
	 * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
90
	 */
91
	public void write(String indent, PrintWriter writer) {
92
		writer.print(indent);
93
		writer.print("<bundle"); //$NON-NLS-1$
94
		if (id != null)
95
			writer.print(" id=\"" + getId() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
96
		if (version != null)
97
			writer.print(" version=\"" + getVersion() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
98
		if (label != null)
99
			writer.print(" label=\"" + getLabel() + "\""); //$NON-NLS-1$ //$NON-NLS-2$
100
		if (fCategories.size() > 0) {
101
			writer.println(">"); //$NON-NLS-1$
102
			String indent2 = indent + "   "; //$NON-NLS-1$
103
			for (int i = 0; i < fCategories.size(); i++) {
104
				ISiteCategory category = (ISiteCategory) fCategories.get(i);
105
				category.write(indent2, writer);
106
			}
107
			writer.println(indent + "</bundle>"); //$NON-NLS-1$
108
		} else
109
			writer.println("/>"); //$NON-NLS-1$
110
	}
111
112
}
(-)a/ui/org.eclipse.pde.core/src/org/eclipse/pde/internal/core/site/SiteModelFactory.java (-9 / +21 lines)
Lines 10-24 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.pde.internal.core.site;
11
package org.eclipse.pde.internal.core.site;
12
12
13
import org.eclipse.pde.internal.core.isite.ISite;
13
import org.eclipse.pde.internal.core.isite.*;
14
import org.eclipse.pde.internal.core.isite.ISiteArchive;
15
import org.eclipse.pde.internal.core.isite.ISiteCategory;
16
import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
17
import org.eclipse.pde.internal.core.isite.ISiteDescription;
18
import org.eclipse.pde.internal.core.isite.ISiteFeature;
19
import org.eclipse.pde.internal.core.isite.ISiteModel;
20
import org.eclipse.pde.internal.core.isite.ISiteModelFactory;
21
import org.eclipse.pde.internal.core.isite.ISiteObject;
22
14
23
public class SiteModelFactory implements ISiteModelFactory {
15
public class SiteModelFactory implements ISiteModelFactory {
24
	private ISiteModel model;
16
	private ISiteModel model;
Lines 48-53 public class SiteModelFactory implements ISiteModelFactory { Link Here
48
	}
40
	}
49
41
50
	/**
42
	/**
43
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createBundle()
44
	 */
45
	public ISiteBundle createBundle() {
46
		SiteBundle bundle = new SiteBundle();
47
		bundle.model = model;
48
		bundle.parent = model.getSite();
49
		return bundle;
50
	}
51
52
	/**
51
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createCategory()
53
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createCategory()
52
	 */
54
	 */
53
	public ISiteCategory createCategory(ISiteFeature feature) {
55
	public ISiteCategory createCategory(ISiteFeature feature) {
Lines 58-63 public class SiteModelFactory implements ISiteModelFactory { Link Here
58
	}
60
	}
59
61
60
	/**
62
	/**
63
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createCategory()
64
	 */
65
	public ISiteCategory createCategory(ISiteBundle bundle) {
66
		SiteCategory category = new SiteCategory();
67
		category.model = model;
68
		category.parent = bundle;
69
		return category;
70
	}
71
72
	/**
61
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createCategoryDefinition()
73
	 * @see org.eclipse.pde.internal.core.isite.ISiteModelFactory#createCategoryDefinition()
62
	 */
74
	 */
63
	public ISiteCategoryDefinition createCategoryDefinition() {
75
	public ISiteCategoryDefinition createCategoryDefinition() {
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDELabelProvider.java (+6 lines)
Lines 311-316 public class PDELabelProvider extends SharedLabelProvider { Link Here
311
		return preventNull(obj.getURL());
311
		return preventNull(obj.getURL());
312
	}
312
	}
313
313
314
	public String getObjectText(ISiteBundle obj) {
315
		IPluginModelBase modelBase = PluginRegistry.findModel(obj.getId(), obj.getVersion(), IMatchRules.COMPATIBLE, null);
316
		return getObjectText(modelBase.getPluginBase());
317
	}
318
314
	public String getObjectText(ISiteArchive obj) {
319
	public String getObjectText(ISiteArchive obj) {
315
		return preventNull(obj.getPath());
320
		return preventNull(obj.getPath());
316
	}
321
	}
Lines 829-832 public class PDELabelProvider extends SharedLabelProvider { Link Here
829
		}
834
		}
830
		return versionRange;
835
		return versionRange;
831
	}
836
	}
837
832
}
838
}
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/PDEUIMessages.java (+1 lines)
Lines 1722-1727 public class PDEUIMessages extends NLS { Link Here
1722
	public static String CategorySection_new;
1722
	public static String CategorySection_new;
1723
	public static String CategorySection_desc;
1723
	public static String CategorySection_desc;
1724
	public static String CategorySection_add;
1724
	public static String CategorySection_add;
1725
	public static String CategorySection_addBundle;
1725
	public static String CategorySection_remove;
1726
	public static String CategorySection_remove;
1726
	public static String CategorySection_environment;
1727
	public static String CategorySection_environment;
1727
	public static String CategorySection_buildAll;
1728
	public static String CategorySection_buildAll;
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategoryEditor.java (-2 / +2 lines)
Lines 80-93 public class CategoryEditor extends PDEFormEditor { Link Here
80
80
81
	protected void addEditorPages() {
81
	protected void addEditorPages() {
82
		try {
82
		try {
83
			addPage(new FeaturesPage(this));
83
			addPage(new IUsPage(this));
84
		} catch (PartInitException e) {
84
		} catch (PartInitException e) {
85
			PDEPlugin.logException(e);
85
			PDEPlugin.logException(e);
86
		}
86
		}
87
	}
87
	}
88
88
89
	protected String computeInitialPageId() {
89
	protected String computeInitialPageId() {
90
		return FeaturesPage.PAGE_ID;
90
		return IUsPage.PAGE_ID;
91
	}
91
	}
92
92
93
	protected ISortableContentOutlinePage createContentOutline() {
93
	protected ISortableContentOutlinePage createContentOutline() {
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategoryLabelProvider.java (-2 / +19 lines)
Lines 6-18 Link Here
6
*
6
*
7
* Contributors:
7
* Contributors:
8
*   EclipseSource - initial API and implementation
8
*   EclipseSource - initial API and implementation
9
*   Mickael Istria (Red Hat Inc.) - 383795: <bundle...> support
9
******************************************************************************/
10
******************************************************************************/
10
package org.eclipse.pde.internal.ui.editor.category;
11
package org.eclipse.pde.internal.ui.editor.category;
11
12
12
import org.eclipse.jface.viewers.LabelProvider;
13
import org.eclipse.jface.viewers.LabelProvider;
14
import org.eclipse.pde.core.plugin.IMatchRules;
15
import org.eclipse.pde.core.plugin.PluginRegistry;
13
import org.eclipse.pde.internal.core.PDECore;
16
import org.eclipse.pde.internal.core.PDECore;
14
import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
17
import org.eclipse.pde.internal.core.isite.*;
15
import org.eclipse.pde.internal.core.isite.ISiteFeature;
16
import org.eclipse.pde.internal.ui.*;
18
import org.eclipse.pde.internal.ui.*;
17
import org.eclipse.swt.graphics.Image;
19
import org.eclipse.swt.graphics.Image;
18
import org.eclipse.ui.forms.editor.IFormPage;
20
import org.eclipse.ui.forms.editor.IFormPage;
Lines 23-34 class CategoryLabelProvider extends LabelProvider { Link Here
23
25
24
	private Image fSiteFeatureImage;
26
	private Image fSiteFeatureImage;
25
	private Image fMissingSiteFeatureImage;
27
	private Image fMissingSiteFeatureImage;
28
	private Image fSiteBundleImage;
29
	private Image fMissingSiteBundleImage;
26
	private Image fPageImage;
30
	private Image fPageImage;
27
	private Image fCatDefImage;
31
	private Image fCatDefImage;
28
32
29
	public CategoryLabelProvider() {
33
	public CategoryLabelProvider() {
30
		fSiteFeatureImage = PDEPluginImages.DESC_FEATURE_OBJ.createImage();
34
		fSiteFeatureImage = PDEPluginImages.DESC_FEATURE_OBJ.createImage();
31
		fMissingSiteFeatureImage = PDEPluginImages.DESC_NOREF_FEATURE_OBJ.createImage();
35
		fMissingSiteFeatureImage = PDEPluginImages.DESC_NOREF_FEATURE_OBJ.createImage();
36
		fSiteBundleImage = PDEPluginImages.DESC_PLUGIN_OBJ.createImage();
37
		fMissingSiteBundleImage = PDEPluginImages.DESC_PLUGIN_DIS_OBJ.createImage();
32
		fCatDefImage = PDEPluginImages.DESC_CATEGORY_OBJ.createImage();
38
		fCatDefImage = PDEPluginImages.DESC_CATEGORY_OBJ.createImage();
33
		fPageImage = PDEPluginImages.DESC_PAGE_OBJ.createImage();
39
		fPageImage = PDEPluginImages.DESC_PAGE_OBJ.createImage();
34
		fSharedProvider = PDEPlugin.getDefault().getLabelProvider();
40
		fSharedProvider = PDEPlugin.getDefault().getLabelProvider();
Lines 43-48 class CategoryLabelProvider extends LabelProvider { Link Here
43
				return fMissingSiteFeatureImage;
49
				return fMissingSiteFeatureImage;
44
			return fSiteFeatureImage;
50
			return fSiteFeatureImage;
45
		}
51
		}
52
		if (element instanceof SiteBundleAdapter) {
53
			ISiteBundle bundle = ((SiteBundleAdapter) element).bundle;
54
			if (PluginRegistry.findModel(bundle.getId(), bundle.getVersion(), IMatchRules.COMPATIBLE, null) == null) {
55
				return this.fMissingSiteBundleImage;
56
			}
57
			return this.fSiteBundleImage;
58
		}
46
		if (element instanceof IFormPage)
59
		if (element instanceof IFormPage)
47
			return fPageImage;
60
			return fPageImage;
48
		return fSharedProvider.getImage(element);
61
		return fSharedProvider.getImage(element);
Lines 55-60 class CategoryLabelProvider extends LabelProvider { Link Here
55
			ISiteFeature feature = ((SiteFeatureAdapter) element).feature;
68
			ISiteFeature feature = ((SiteFeatureAdapter) element).feature;
56
			return fSharedProvider.getObjectText(feature);
69
			return fSharedProvider.getObjectText(feature);
57
		}
70
		}
71
		if (element instanceof SiteBundleAdapter) {
72
			ISiteBundle bundle = ((SiteBundleAdapter) element).bundle;
73
			return fSharedProvider.getObjectText(bundle);
74
		}
58
		if (element instanceof IFormPage)
75
		if (element instanceof IFormPage)
59
			return ((IFormPage) element).getTitle();
76
			return ((IFormPage) element).getTitle();
60
		return fSharedProvider.getText(element);
77
		return fSharedProvider.getText(element);
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategoryOutlinePage.java (-3 / +18 lines)
Lines 32-38 public class CategoryOutlinePage extends FormOutlinePage { Link Here
32
			ISiteModel model = (ISiteModel) page.getModel();
32
			ISiteModel model = (ISiteModel) page.getModel();
33
			if (model.isValid()) {
33
			if (model.isValid()) {
34
				ISite site = model.getSite();
34
				ISite site = model.getSite();
35
				if (page.getId().equals(FeaturesPage.PAGE_ID)) {
35
				if (page.getId().equals(IUsPage.PAGE_ID)) {
36
					ArrayList result = new ArrayList();
36
					ArrayList result = new ArrayList();
37
					ISiteCategoryDefinition[] catDefs = site.getCategoryDefinitions();
37
					ISiteCategoryDefinition[] catDefs = site.getCategoryDefinitions();
38
					for (int i = 0; i < catDefs.length; i++) {
38
					for (int i = 0; i < catDefs.length; i++) {
Lines 43-48 public class CategoryOutlinePage extends FormOutlinePage { Link Here
43
						if (features[i].getCategories().length == 0)
43
						if (features[i].getCategories().length == 0)
44
							result.add(new SiteFeatureAdapter(null, features[i]));
44
							result.add(new SiteFeatureAdapter(null, features[i]));
45
					}
45
					}
46
					ISiteBundle[] bundles = site.getBundles();
47
					for (int i = 0; i < bundles.length; i++) {
48
						if (bundles[i].getCategories().length == 0) {
49
							result.add(new SiteBundleAdapter(null, bundles[i]));
50
						}
51
					}
46
					return result.toArray();
52
					return result.toArray();
47
				}
53
				}
48
			}
54
			}
Lines 52-59 public class CategoryOutlinePage extends FormOutlinePage { Link Here
52
			ISiteModel model = catDef.getModel();
58
			ISiteModel model = catDef.getModel();
53
			if (model.isValid()) {
59
			if (model.isValid()) {
54
				ISite site = model.getSite();
60
				ISite site = model.getSite();
55
				ISiteFeature[] features = site.getFeatures();
56
				HashSet result = new HashSet();
61
				HashSet result = new HashSet();
62
				ISiteFeature[] features = site.getFeatures();
57
				for (int i = 0; i < features.length; i++) {
63
				for (int i = 0; i < features.length; i++) {
58
					ISiteCategory[] cats = features[i].getCategories();
64
					ISiteCategory[] cats = features[i].getCategories();
59
					for (int j = 0; j < cats.length; j++) {
65
					for (int j = 0; j < cats.length; j++) {
Lines 62-67 public class CategoryOutlinePage extends FormOutlinePage { Link Here
62
						}
68
						}
63
					}
69
					}
64
				}
70
				}
71
				ISiteBundle[] bundles = site.getBundles();
72
				for (int i = 0; i < bundles.length; i++) {
73
					ISiteCategory[] cats = bundles[i].getCategories();
74
					for (int j = 0; j < cats.length; j++) {
75
						if (cats[j].getDefinition() != null && cats[j].getDefinition().equals(catDef)) {
76
							result.add(new SiteBundleAdapter(cats[j].getName(), bundles[i]));
77
						}
78
					}
79
				}
65
				return result.toArray();
80
				return result.toArray();
66
			}
81
			}
67
		}
82
		}
Lines 71-77 public class CategoryOutlinePage extends FormOutlinePage { Link Here
71
	protected String getParentPageId(Object item) {
86
	protected String getParentPageId(Object item) {
72
		String pageId = null;
87
		String pageId = null;
73
		if (item instanceof ISiteCategoryDefinition || item instanceof SiteFeatureAdapter)
88
		if (item instanceof ISiteCategoryDefinition || item instanceof SiteFeatureAdapter)
74
			pageId = FeaturesPage.PAGE_ID;
89
			pageId = IUsPage.PAGE_ID;
75
		if (pageId != null)
90
		if (pageId != null)
76
			return pageId;
91
			return pageId;
77
		return super.getParentPageId(item);
92
		return super.getParentPageId(item);
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategorySection.java (-3 / +190 lines)
Lines 17-28 import org.eclipse.jface.viewers.*; Link Here
17
import org.eclipse.jface.window.Window;
17
import org.eclipse.jface.window.Window;
18
import org.eclipse.osgi.util.NLS;
18
import org.eclipse.osgi.util.NLS;
19
import org.eclipse.pde.core.IModelChangedEvent;
19
import org.eclipse.pde.core.IModelChangedEvent;
20
import org.eclipse.pde.core.plugin.*;
20
import org.eclipse.pde.internal.core.*;
21
import org.eclipse.pde.internal.core.*;
21
import org.eclipse.pde.internal.core.ifeature.*;
22
import org.eclipse.pde.internal.core.ifeature.*;
22
import org.eclipse.pde.internal.core.isite.*;
23
import org.eclipse.pde.internal.core.isite.*;
23
import org.eclipse.pde.internal.ui.PDEPlugin;
24
import org.eclipse.pde.internal.ui.PDEPlugin;
24
import org.eclipse.pde.internal.ui.PDEUIMessages;
25
import org.eclipse.pde.internal.ui.PDEUIMessages;
25
import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog;
26
import org.eclipse.pde.internal.ui.dialogs.FeatureSelectionDialog;
27
import org.eclipse.pde.internal.ui.dialogs.PluginSelectionDialog;
26
import org.eclipse.pde.internal.ui.editor.*;
28
import org.eclipse.pde.internal.ui.editor.*;
27
import org.eclipse.pde.internal.ui.editor.feature.FeatureEditor;
29
import org.eclipse.pde.internal.ui.editor.feature.FeatureEditor;
28
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
30
import org.eclipse.pde.internal.ui.elements.DefaultContentProvider;
Lines 42-47 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
42
44
43
	private static final int BUTTON_ADD_CATEGORY = 0;
45
	private static final int BUTTON_ADD_CATEGORY = 0;
44
	private static final int BUTTON_ADD_FEATURE = 1;
46
	private static final int BUTTON_ADD_FEATURE = 1;
47
	private static final int BUTTON_ADD_BUNDLE = 2;
45
	private static int fCounter;
48
	private static int fCounter;
46
	private ISiteModel fModel;
49
	private ISiteModel fModel;
47
	private TreePart fCategoryTreePart;
50
	private TreePart fCategoryTreePart;
Lines 61-74 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
61
				if (features[i].getCategories().length == 0)
64
				if (features[i].getCategories().length == 0)
62
					result.add(new SiteFeatureAdapter(null, features[i]));
65
					result.add(new SiteFeatureAdapter(null, features[i]));
63
			}
66
			}
67
			ISiteBundle[] bundles = fModel.getSite().getBundles();
68
			for (int i = 0; i < bundles.length; i++) {
69
				if (bundles[i].getCategories().length == 0) {
70
					result.add(new SiteBundleAdapter(null, bundles[i]));
71
				}
72
			}
64
			return result.toArray();
73
			return result.toArray();
65
		}
74
		}
66
75
67
		public Object[] getChildren(Object parent) {
76
		public Object[] getChildren(Object parent) {
68
			if (parent instanceof ISiteCategoryDefinition) {
77
			if (parent instanceof ISiteCategoryDefinition) {
69
				ISiteCategoryDefinition catDef = (ISiteCategoryDefinition) parent;
78
				ISiteCategoryDefinition catDef = (ISiteCategoryDefinition) parent;
70
				ISiteFeature[] features = fModel.getSite().getFeatures();
71
				HashSet result = new HashSet();
79
				HashSet result = new HashSet();
80
				ISiteFeature[] features = fModel.getSite().getFeatures();
72
				for (int i = 0; i < features.length; i++) {
81
				for (int i = 0; i < features.length; i++) {
73
					ISiteCategory[] cats = features[i].getCategories();
82
					ISiteCategory[] cats = features[i].getCategories();
74
					for (int j = 0; j < cats.length; j++) {
83
					for (int j = 0; j < cats.length; j++) {
Lines 77-82 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
77
						}
86
						}
78
					}
87
					}
79
				}
88
				}
89
				ISiteBundle[] bundles = fModel.getSite().getBundles();
90
				for (int i = 0; i < bundles.length; i++) {
91
					ISiteCategory[] cats = bundles[i].getCategories();
92
					for (int j = 0; j < cats.length; j++) {
93
						if (cats[j].getDefinition() != null && cats[j].getDefinition().equals(catDef)) {
94
							result.add(new SiteBundleAdapter(cats[j].getName(), bundles[i]));
95
						}
96
					}
97
				}
80
				return result.toArray();
98
				return result.toArray();
81
			}
99
			}
82
			return new Object[0];
100
			return new Object[0];
Lines 98-110 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
98
						}
116
						}
99
					}
117
					}
100
				}
118
				}
119
				ISiteBundle[] bundles = fModel.getSite().getBundles();
120
				for (int i = 0; i < bundles.length; i++) {
121
					ISiteCategory[] cats = bundles[i].getCategories();
122
					for (int j = 0; j < cats.length; j++) {
123
						if (cats[j].getDefinition() != null && cats[j].getDefinition().equals(catDef)) {
124
							return true;
125
						}
126
					}
127
				}
101
			}
128
			}
102
			return false;
129
			return false;
103
		}
130
		}
104
	}
131
	}
105
132
106
	public CategorySection(PDEFormPage formPage, Composite parent) {
133
	public CategorySection(PDEFormPage formPage, Composite parent) {
107
		super(formPage, parent, Section.DESCRIPTION, new String[] {PDEUIMessages.CategoryDefinitionCategorySection_new, PDEUIMessages.CategorySection_add});
134
		super(formPage, parent, Section.DESCRIPTION, new String[] {PDEUIMessages.CategoryDefinitionCategorySection_new, PDEUIMessages.CategorySection_add, PDEUIMessages.CategorySection_addBundle});
108
		getSection().setText(PDEUIMessages.CategoryDefinitionCategorySection_title);
135
		getSection().setText(PDEUIMessages.CategoryDefinitionCategorySection_title);
109
		getSection().setDescription(PDEUIMessages.CategoryDefinitionCategorySection_desc);
136
		getSection().setDescription(PDEUIMessages.CategoryDefinitionCategorySection_desc);
110
	}
137
	}
Lines 208-213 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
208
						}
235
						}
209
						return true;
236
						return true;
210
					}
237
					}
238
					if (objects.length > 0 && objects[0] instanceof SiteBundleAdapter) {
239
						if (op == DND.DROP_COPY && target != null) {
240
							copyBundle((SiteBundleAdapter) objects[0], target);
241
						} else {
242
							moveBundle((SiteBundleAdapter) objects[0], target);
243
						}
244
						return true;
245
					}
211
					return false;
246
					return false;
212
				}
247
				}
213
248
Lines 221-227 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
221
		fCategoryViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, new DragSourceListener() {
256
		fCategoryViewer.addDragSupport(DND.DROP_MOVE | DND.DROP_COPY, transfers, new DragSourceListener() {
222
			public void dragStart(DragSourceEvent event) {
257
			public void dragStart(DragSourceEvent event) {
223
				IStructuredSelection ssel = (IStructuredSelection) fCategoryViewer.getSelection();
258
				IStructuredSelection ssel = (IStructuredSelection) fCategoryViewer.getSelection();
224
				if (ssel == null || ssel.isEmpty() || !(ssel.getFirstElement() instanceof SiteFeatureAdapter)) {
259
				if (ssel == null || ssel.isEmpty() || !(ssel.getFirstElement() instanceof SiteFeatureAdapter || ssel.getFirstElement() instanceof SiteBundleAdapter)) {
225
					event.doit = false;
260
					event.doit = false;
226
				}
261
				}
227
			}
262
			}
Lines 237-242 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
237
272
238
		fCategoryTreePart.setButtonEnabled(BUTTON_ADD_CATEGORY, isEditable());
273
		fCategoryTreePart.setButtonEnabled(BUTTON_ADD_CATEGORY, isEditable());
239
		fCategoryTreePart.setButtonEnabled(BUTTON_ADD_FEATURE, isEditable());
274
		fCategoryTreePart.setButtonEnabled(BUTTON_ADD_FEATURE, isEditable());
275
		fCategoryTreePart.setButtonEnabled(BUTTON_ADD_BUNDLE, isEditable());
240
276
241
		// fCategoryViewer.expandAll();
277
		// fCategoryViewer.expandAll();
242
		toolkit.paintBordersFor(container);
278
		toolkit.paintBordersFor(container);
Lines 267-272 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
267
		}
303
		}
268
	}
304
	}
269
305
306
	private void copyBundle(SiteBundleAdapter adapter, Object target) {
307
		ISiteBundle bundle = findRealBundle(adapter);
308
		if (bundle == null) {
309
			return;
310
		}
311
		if (target != null && target instanceof ISiteCategoryDefinition) {
312
			addCategory(bundle, ((ISiteCategoryDefinition) target).getName());
313
		}
314
	}
315
270
	private void addCategory(ISiteFeature aFeature, String catName) {
316
	private void addCategory(ISiteFeature aFeature, String catName) {
271
		try {
317
		try {
272
			if (aFeature == null)
318
			if (aFeature == null)
Lines 284-289 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
284
		}
330
		}
285
	}
331
	}
286
332
333
	private void addCategory(ISiteBundle aBundle, String catName) {
334
		try {
335
			if (aBundle == null)
336
				return;
337
			ISiteCategory[] cats = aBundle.getCategories();
338
			for (int j = 0; j < cats.length; j++) {
339
				if (cats[j].getName().equals(catName))
340
					return;
341
			}
342
			ISiteCategory cat = fModel.getFactory().createCategory(aBundle);
343
			cat.setName(catName);
344
			expandCategory(catName);
345
			aBundle.addCategories(new ISiteCategory[] {cat});
346
		} catch (CoreException e) {
347
		}
348
	}
349
287
	private void moveFeature(SiteFeatureAdapter adapter, Object target) {
350
	private void moveFeature(SiteFeatureAdapter adapter, Object target) {
288
		ISiteFeature feature = findRealFeature(adapter);
351
		ISiteFeature feature = findRealFeature(adapter);
289
		if (feature == null) {
352
		if (feature == null) {
Lines 297-302 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
297
		}
360
		}
298
	}
361
	}
299
362
363
	private void moveBundle(SiteBundleAdapter adapter, Object target) {
364
		ISiteBundle bundle = findRealBundle(adapter);
365
		if (bundle == null) {
366
			return;
367
		}
368
		if (adapter.category != null) {
369
			removeCategory(bundle, adapter.category);
370
		}
371
		if (target != null && target instanceof ISiteCategoryDefinition) {
372
			addCategory(bundle, ((ISiteCategoryDefinition) target).getName());
373
		}
374
	}
375
300
	protected void buttonSelected(int index) {
376
	protected void buttonSelected(int index) {
301
		switch (index) {
377
		switch (index) {
302
			case BUTTON_ADD_CATEGORY :
378
			case BUTTON_ADD_CATEGORY :
Lines 305-310 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
305
			case BUTTON_ADD_FEATURE :
381
			case BUTTON_ADD_FEATURE :
306
				handleNewFeature();
382
				handleNewFeature();
307
				break;
383
				break;
384
			case BUTTON_ADD_BUNDLE :
385
				handleNewBundle();
386
				break;
308
		}
387
		}
309
	}
388
	}
310
389
Lines 415-420 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
415
		}
494
		}
416
	}
495
	}
417
496
497
	private void removeCategory(ISiteBundle aBundle, String catName) {
498
		try {
499
			if (aBundle == null)
500
				return;
501
			ISiteCategory[] cats = aBundle.getCategories();
502
			for (int i = 0; i < cats.length; i++) {
503
				if (catName.equals(cats[i].getName()))
504
					aBundle.removeCategories(new ISiteCategory[] {cats[i]});
505
			}
506
		} catch (CoreException e) {
507
		}
508
	}
509
418
	private ISiteFeature findRealFeature(SiteFeatureAdapter adapter) {
510
	private ISiteFeature findRealFeature(SiteFeatureAdapter adapter) {
419
		ISiteFeature featureCopy = adapter.feature;
511
		ISiteFeature featureCopy = adapter.feature;
420
		ISiteFeature[] features = fModel.getSite().getFeatures();
512
		ISiteFeature[] features = fModel.getSite().getFeatures();
Lines 426-431 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
426
		return null;
518
		return null;
427
	}
519
	}
428
520
521
	private ISiteBundle findRealBundle(SiteBundleAdapter adapter) {
522
		ISiteBundle featureCopy = adapter.bundle;
523
		ISiteBundle[] bundles = fModel.getSite().getBundles();
524
		for (int i = 0; i < bundles.length; i++) {
525
			if (bundles[i].getId().equals(featureCopy.getId()) && bundles[i].getVersion().equals(featureCopy.getVersion())) {
526
				return bundles[i];
527
			}
528
		}
529
		return null;
530
	}
531
429
	public void dispose() {
532
	public void dispose() {
430
		super.dispose();
533
		super.dispose();
431
		FeatureModelManager mng = PDECore.getDefault().getFeatureModelManager();
534
		FeatureModelManager mng = PDECore.getDefault().getFeatureModelManager();
Lines 565-570 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
565
		});
668
		});
566
	}
669
	}
567
670
671
	private void handleNewBundle() {
672
		final Control control = fCategoryViewer.getControl();
673
		BusyIndicator.showWhile(control.getDisplay(), new Runnable() {
674
			public void run() {
675
				IPluginModelBase[] allModels = PluginRegistry.getAllModels();
676
				ArrayList newModels = new ArrayList();
677
				for (int i = 0; i < allModels.length; i++) {
678
					if (canAdd(allModels[i]))
679
						newModels.add(allModels[i]);
680
				}
681
				IPluginModelBase[] candidateModels = (IPluginModelBase[]) newModels.toArray(new IPluginModelBase[newModels.size()]);
682
				PluginSelectionDialog dialog = new PluginSelectionDialog(fCategoryViewer.getTree().getShell(), candidateModels, true);
683
				if (dialog.open() == Window.OK) {
684
					Object[] models = dialog.getResult();
685
					try {
686
						doAddBundles(models);
687
					} catch (CoreException e) {
688
						PDEPlugin.log(e);
689
					}
690
				}
691
			}
692
		});
693
	}
694
568
	private boolean canAdd(IFeatureModel candidate) {
695
	private boolean canAdd(IFeatureModel candidate) {
569
		ISiteFeature[] features = fModel.getSite().getFeatures();
696
		ISiteFeature[] features = fModel.getSite().getFeatures();
570
		IFeature cfeature = candidate.getFeature();
697
		IFeature cfeature = candidate.getFeature();
Lines 577-582 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
577
		return true;
704
		return true;
578
	}
705
	}
579
706
707
	private boolean canAdd(IPluginModelBase candidate) {
708
		ISiteBundle[] currentBundles = fModel.getSite().getBundles();
709
		IPluginBase candidateBundle = candidate.getPluginBase();
710
711
		for (int i = 0; i < currentBundles.length; i++) {
712
			ISiteBundle currentBundle = currentBundles[i];
713
			if (currentBundle.getId().equals(candidateBundle.getId()) && currentBundle.getVersion().equals(candidateBundle.getVersion()))
714
				return false;
715
		}
716
		return true;
717
	}
718
580
	public static ISiteFeature createSiteFeature(ISiteModel model, IFeatureModel featureModel) throws CoreException {
719
	public static ISiteFeature createSiteFeature(ISiteModel model, IFeatureModel featureModel) throws CoreException {
581
		IFeature feature = featureModel.getFeature();
720
		IFeature feature = featureModel.getFeature();
582
		ISiteFeature sfeature = model.getFactory().createFeature();
721
		ISiteFeature sfeature = model.getFactory().createFeature();
Lines 594-599 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
594
		return sfeature;
733
		return sfeature;
595
	}
734
	}
596
735
736
	private ISiteBundle createSiteBundle(ISiteModel model, IPluginModelBase candidate) throws CoreException {
737
		ISiteBundle newBundle = model.getFactory().createBundle();
738
		newBundle.setId(candidate.getPluginBase().getId());
739
		newBundle.setVersion(candidate.getPluginBase().getVersion());
740
		return newBundle;
741
	}
742
597
	private static String formatVersion(String version) {
743
	private static String formatVersion(String version) {
598
		try {
744
		try {
599
			Version v = new Version(version);
745
			Version v = new Version(version);
Lines 657-662 public class CategorySection extends TreeSection implements IFeatureModelListene Link Here
657
		}
803
		}
658
	}
804
	}
659
805
806
	/**
807
	 * 
808
	 * @param candidates
809
	 *            Array of IPluginModelBase
810
	 * @param monitor
811
	 * @throws CoreException
812
	 */
813
	public void doAddBundles(Object[] candidates) throws CoreException {
814
		// Category to add features to
815
		String categoryName = null;
816
		ISelection selection = fCategoryViewer.getSelection();
817
		if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
818
			Object element = ((IStructuredSelection) selection).getFirstElement();
819
			if (element instanceof ISiteCategoryDefinition) {
820
				categoryName = ((ISiteCategoryDefinition) element).getName();
821
			} else if (element instanceof SiteFeatureAdapter) {
822
				categoryName = ((SiteFeatureAdapter) element).category;
823
			}
824
		}
825
		//
826
		ISiteBundle[] added = new ISiteBundle[candidates.length];
827
		for (int i = 0; i < candidates.length; i++) {
828
			IPluginModelBase candidate = (IPluginModelBase) candidates[i];
829
			ISiteBundle child = createSiteBundle(fModel, candidate);
830
			if (categoryName != null) {
831
				addCategory(child, categoryName);
832
			}
833
			added[i] = child;
834
		}
835
836
		// Update model
837
		fModel.getSite().addBundles(added);
838
		// Select last added feature
839
		if (added.length > 0) {
840
			if (categoryName != null) {
841
				expandCategory(categoryName);
842
			}
843
			fCategoryViewer.setSelection(new StructuredSelection(new SiteBundleAdapter(categoryName, added[added.length - 1])), true);
844
		}
845
	}
846
660
	void fireSelection() {
847
	void fireSelection() {
661
		fCategoryViewer.setSelection(fCategoryViewer.getSelection());
848
		fCategoryViewer.setSelection(fCategoryViewer.getSelection());
662
	}
849
	}
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/CategoryUndoManager.java (-1 / +1 lines)
Lines 25-31 public class CategoryUndoManager extends ModelUndoManager { Link Here
25
25
26
	protected String getPageId(Object obj) {
26
	protected String getPageId(Object obj) {
27
		if (obj instanceof ISiteFeature || obj instanceof ISiteCategory || obj instanceof ISiteCategoryDefinition) {
27
		if (obj instanceof ISiteFeature || obj instanceof ISiteCategory || obj instanceof ISiteCategoryDefinition) {
28
			return FeaturesPage.PAGE_ID;
28
			return IUsPage.PAGE_ID;
29
		}
29
		}
30
		// site elements and attributes are on different pages, stay on the
30
		// site elements and attributes are on different pages, stay on the
31
		// current page
31
		// current page
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/FeaturesPage.java (-98 lines)
Lines 1-98 Link Here
1
/******************************************************************************* 
2
* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
3
* program and the accompanying materials are made available under the terms of
4
* the Eclipse Public License v1.0 which accompanies this distribution, and is
5
* available at http://www.eclipse.org/legal/epl-v10.html
6
*
7
* Contributors:
8
*   EclipseSource - initial API and implementation
9
******************************************************************************/
10
package org.eclipse.pde.internal.ui.editor.category;
11
12
import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
13
import org.eclipse.pde.internal.ui.*;
14
import org.eclipse.pde.internal.ui.editor.*;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.forms.*;
18
import org.eclipse.ui.forms.widgets.ScrolledForm;
19
20
public class FeaturesPage extends PDEFormPage {
21
	public static final String PAGE_ID = "features"; //$NON-NLS-1$
22
	private CategorySection fCategorySection;
23
	private SiteFeaturesBlock fBlock;
24
25
	public class SiteFeaturesBlock extends PDEMasterDetailsBlock {
26
		public SiteFeaturesBlock() {
27
			super(FeaturesPage.this);
28
		}
29
30
		protected PDESection createMasterSection(IManagedForm managedForm, Composite parent) {
31
			fCategorySection = new CategorySection(getPage(), parent);
32
			return fCategorySection;
33
		}
34
35
		protected void registerPages(DetailsPart detailsPart) {
36
			detailsPart.setPageProvider(new IDetailsPageProvider() {
37
				public Object getPageKey(Object object) {
38
					if (object instanceof SiteFeatureAdapter)
39
						return SiteFeatureAdapter.class;
40
					if (object instanceof ISiteCategoryDefinition)
41
						return ISiteCategoryDefinition.class;
42
					return object.getClass();
43
				}
44
45
				public IDetailsPage getPage(Object key) {
46
					if (key.equals(SiteFeatureAdapter.class))
47
						return createFeatureDetails();
48
					if (key.equals(ISiteCategoryDefinition.class))
49
						return createCategoryDetails();
50
					return null;
51
				}
52
			});
53
		}
54
	}
55
56
	public FeaturesPage(PDEFormEditor editor) {
57
		super(editor, PAGE_ID, PDEUIMessages.CategoryPage_header);
58
		fBlock = new SiteFeaturesBlock();
59
	}
60
61
	protected void createFormContent(IManagedForm managedForm) {
62
		super.createFormContent(managedForm);
63
		ScrolledForm form = managedForm.getForm();
64
		form.setText(PDEUIMessages.CategoryPage_header);
65
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_CATEGORY_OBJ));
66
		fBlock.createContent(managedForm);
67
		fCategorySection.fireSelection();
68
		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.CATEGORY_EDITOR);
69
	}
70
71
	private IDetailsPage createFeatureDetails() {
72
		return new PDEDetailsSections() {
73
			protected PDESection[] createSections(PDEFormPage page, Composite parent) {
74
				return new PDESection[] {};//new FeatureDetailsSection(getPage(), parent), new PortabilitySection(getPage(), parent)};
75
			}
76
77
			public String getContextId() {
78
				return CategoryInputContext.CONTEXT_ID;
79
			}
80
		};
81
	}
82
83
	private IDetailsPage createCategoryDetails() {
84
		return new PDEDetailsSections() {
85
			protected PDESection[] createSections(PDEFormPage page, Composite parent) {
86
				return new PDESection[] {new CategoryDetailsSection(getPage(), parent)};
87
			}
88
89
			public String getContextId() {
90
				return CategoryInputContext.CONTEXT_ID;
91
			}
92
		};
93
	}
94
95
	protected String getHelpResource() {
96
		return IHelpContextIds.CATEGORY_EDITOR;
97
	}
98
}
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/IUsPage.java (+116 lines)
Added Link Here
1
/******************************************************************************* 
2
* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
3
* program and the accompanying materials are made available under the terms of
4
* the Eclipse Public License v1.0 which accompanies this distribution, and is
5
* available at http://www.eclipse.org/legal/epl-v10.html
6
*
7
* Contributors:
8
*   EclipseSource - initial API and implementation
9
******************************************************************************/
10
package org.eclipse.pde.internal.ui.editor.category;
11
12
import org.eclipse.pde.internal.core.isite.ISiteCategoryDefinition;
13
import org.eclipse.pde.internal.ui.*;
14
import org.eclipse.pde.internal.ui.editor.*;
15
import org.eclipse.swt.widgets.Composite;
16
import org.eclipse.ui.PlatformUI;
17
import org.eclipse.ui.forms.*;
18
import org.eclipse.ui.forms.widgets.ScrolledForm;
19
20
public class IUsPage extends PDEFormPage {
21
	public static final String PAGE_ID = "ius"; //$NON-NLS-1$
22
	private CategorySection fCategorySection;
23
	private SiteFeaturesBlock fBlock;
24
25
	public class SiteFeaturesBlock extends PDEMasterDetailsBlock {
26
		public SiteFeaturesBlock() {
27
			super(IUsPage.this);
28
		}
29
30
		protected PDESection createMasterSection(IManagedForm managedForm, Composite parent) {
31
			fCategorySection = new CategorySection(getPage(), parent);
32
			return fCategorySection;
33
		}
34
35
		protected void registerPages(DetailsPart detailsPart) {
36
			detailsPart.setPageProvider(new IDetailsPageProvider() {
37
				public Object getPageKey(Object object) {
38
					if (object instanceof SiteFeatureAdapter)
39
						return SiteFeatureAdapter.class;
40
					if (object instanceof SiteBundleAdapter) {
41
						return SiteBundleAdapter.class;
42
					}
43
					if (object instanceof ISiteCategoryDefinition)
44
						return ISiteCategoryDefinition.class;
45
					return object.getClass();
46
				}
47
48
				public IDetailsPage getPage(Object key) {
49
					if (key.equals(SiteFeatureAdapter.class))
50
						return createFeatureDetails();
51
					if (key.equals(SiteBundleAdapter.class)) {
52
						return createBundleDetails();
53
					}
54
					if (key.equals(ISiteCategoryDefinition.class))
55
						return createCategoryDetails();
56
					return null;
57
				}
58
			});
59
		}
60
	}
61
62
	public IUsPage(PDEFormEditor editor) {
63
		super(editor, PAGE_ID, PDEUIMessages.CategoryPage_header);
64
		fBlock = new SiteFeaturesBlock();
65
	}
66
67
	protected void createFormContent(IManagedForm managedForm) {
68
		super.createFormContent(managedForm);
69
		ScrolledForm form = managedForm.getForm();
70
		form.setText(PDEUIMessages.CategoryPage_header);
71
		form.setImage(PDEPlugin.getDefault().getLabelProvider().get(PDEPluginImages.DESC_CATEGORY_OBJ));
72
		fBlock.createContent(managedForm);
73
		fCategorySection.fireSelection();
74
		PlatformUI.getWorkbench().getHelpSystem().setHelp(form.getBody(), IHelpContextIds.CATEGORY_EDITOR);
75
	}
76
77
	private IDetailsPage createFeatureDetails() {
78
		return new PDEDetailsSections() {
79
			protected PDESection[] createSections(PDEFormPage page, Composite parent) {
80
				return new PDESection[] {};//new FeatureDetailsSection(getPage(), parent), new PortabilitySection(getPage(), parent)};
81
			}
82
83
			public String getContextId() {
84
				return CategoryInputContext.CONTEXT_ID;
85
			}
86
		};
87
	}
88
89
	private IDetailsPage createBundleDetails() {
90
		return new PDEDetailsSections() {
91
			protected PDESection[] createSections(PDEFormPage page, Composite parent) {
92
				return new PDESection[] {};//new BundleDetailsSection(getPage(), parent), new PortabilitySection(getPage(), parent)};
93
			}
94
95
			public String getContextId() {
96
				return CategoryInputContext.CONTEXT_ID;
97
			}
98
		};
99
	}
100
101
	private IDetailsPage createCategoryDetails() {
102
		return new PDEDetailsSections() {
103
			protected PDESection[] createSections(PDEFormPage page, Composite parent) {
104
				return new PDESection[] {new CategoryDetailsSection(getPage(), parent)};
105
			}
106
107
			public String getContextId() {
108
				return CategoryInputContext.CONTEXT_ID;
109
			}
110
		};
111
	}
112
113
	protected String getHelpResource() {
114
		return IHelpContextIds.CATEGORY_EDITOR;
115
	}
116
}
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/editor/category/SiteBundleAdapter.java (+76 lines)
Added Link Here
1
/******************************************************************************* 
2
* Copyright (c) 2009 EclipseSource and others. All rights reserved. This
3
* program and the accompanying materials are made available under the terms of
4
* the Eclipse Public License v1.0 which accompanies this distribution, and is
5
* available at http://www.eclipse.org/legal/epl-v10.html
6
*
7
* Contributors:
8
*   EclipseSource - initial API and implementation
9
*   Mickael Istria (Red Hat Inc.) - 383795: <bundle...> support
10
******************************************************************************/
11
package org.eclipse.pde.internal.ui.editor.category;
12
13
import java.io.PrintWriter;
14
import java.io.Serializable;
15
import org.eclipse.pde.core.IWritable;
16
import org.eclipse.pde.internal.core.isite.ISiteBundle;
17
18
public class SiteBundleAdapter implements Serializable, IWritable {
19
20
	private static final long serialVersionUID = 1L;
21
22
	String category;
23
	ISiteBundle bundle;
24
25
	public SiteBundleAdapter(String category, ISiteBundle bundle) {
26
		this.category = category;
27
		this.bundle = bundle;
28
	}
29
30
	/* (non-Javadoc)
31
	 * @see org.eclipse.pde.core.IWritable#write(java.lang.String, java.io.PrintWriter)
32
	 */
33
	public void write(String indent, PrintWriter writer) {
34
		bundle.write(indent, writer);
35
	}
36
37
	/*
38
	 * For retaining selectiong in the tree, when modyfing or moving features,
39
	 * SiteFeatureAdapter are equal if features are equal (same ID and version)
40
	 * 
41
	 * @see java.lang.Object#equals(java.lang.Object)
42
	 */
43
	public boolean equals(Object obj) {
44
		if (obj instanceof SiteBundleAdapter) {
45
			SiteBundleAdapter adapter = (SiteBundleAdapter) obj;
46
			String id = bundle.getId();
47
			String id2 = adapter.bundle.getId();
48
			boolean sameBundle = id != null && id2 != null && id.equals(id2);
49
			if (sameBundle) {
50
				String version = bundle.getVersion();
51
				String version2 = adapter.bundle.getVersion();
52
				sameBundle = version != null && version2 != null && version.equals(version2);
53
			}
54
			boolean sameCategory = adapter.category != null && category != null ? adapter.category.equals(category) : true;
55
			return sameBundle && sameCategory;
56
		}
57
		return super.equals(obj);
58
	}
59
60
	/* (non-Javadoc)
61
	 * @see java.lang.Object#hashCode()
62
	 */
63
	public int hashCode() {
64
		if (bundle.getId() == null) {
65
			return super.hashCode();
66
		}
67
		int code = bundle.getId().hashCode();
68
		if (bundle.getVersion() != null) {
69
			code += bundle.getVersion().hashCode();
70
		}
71
		if (category != null) {
72
			code += category.hashCode();
73
		}
74
		return code;
75
	}
76
}
(-)a/ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/pderesources.properties (-1 / +1 lines)
Lines 1575-1580 CategorySection_desc=1. Add the features to be published on the site.\n\ Link Here
1575
2. For easier browsing of the site, categorize the features by dragging.\n\
1575
2. For easier browsing of the site, categorize the features by dragging.\n\
1576
3. Build the features.
1576
3. Build the features.
1577
CategorySection_add = Add Feature...
1577
CategorySection_add = Add Feature...
1578
CategorySection_addBundle = Add Bundle...
1578
CategorySection_remove = Remove
1579
CategorySection_remove = Remove
1579
CategorySection_environment = Synchronize...
1580
CategorySection_environment = Synchronize...
1580
CategorySection_buildAll = Build All
1581
CategorySection_buildAll = Build All
1581
- 

Return to bug 383795