KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > internal > ui > correction > CreateManifestClassResolution


1 /*******************************************************************************
2  * Copyright (c) 2005, 2007 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.correction;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.osgi.util.NLS;
15 import org.eclipse.pde.core.plugin.IPluginModelBase;
16 import org.eclipse.pde.core.plugin.PluginRegistry;
17 import org.eclipse.pde.internal.core.ibundle.IManifestHeader;
18 import org.eclipse.pde.internal.core.text.bundle.BundleModel;
19 import org.eclipse.pde.internal.ui.PDEUIMessages;
20 import org.eclipse.pde.internal.ui.editor.plugin.JavaAttributeValue;
21 import org.eclipse.pde.internal.ui.util.PDEJavaHelperUI;
22 import org.eclipse.pde.internal.ui.util.TextUtil;
23
24 public class CreateManifestClassResolution extends AbstractManifestMarkerResolution {
25
26     private String JavaDoc fHeader;
27     
28     public CreateManifestClassResolution(int type, String JavaDoc headerName) {
29         super(type);
30         fHeader = headerName;
31     }
32
33     protected void createChange(BundleModel model) {
34         IManifestHeader header = model.getBundle().getManifestHeader(fHeader);
35         
36         String JavaDoc name = TextUtil.trimNonAlphaChars(header.getValue()).replace('$', '.');
37         IProject project = model.getUnderlyingResource().getProject();
38         
39         IPluginModelBase modelBase = PluginRegistry.findModel(project);
40         if (modelBase == null)
41             return;
42         
43         JavaAttributeValue value = new JavaAttributeValue(project, modelBase, null, name);
44         name = PDEJavaHelperUI.createClass(name, project, value, true);
45         if (name != null && !name.equals(header.getValue()))
46             header.setValue(name);
47     }
48
49     public String JavaDoc getLabel() {
50         return NLS.bind(PDEUIMessages.CreateManifestClassResolution_label, fHeader);
51     }
52
53 }
54
Popular Tags