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 244088
Collapse All | Expand All

(-)src/org/eclipse/pde/internal/ds/ui/wizards/DSCreationOperation.java (-6 / +53 lines)
Lines 20-27 Link Here
20
import org.eclipse.core.resources.IProjectDescription;
20
import org.eclipse.core.resources.IProjectDescription;
21
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.CoreException;
22
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.IProgressMonitor;
23
import org.eclipse.core.runtime.SubProgressMonitor;
23
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.ISelection;
24
import org.eclipse.jface.viewers.StructuredSelection;
25
import org.eclipse.jface.viewers.StructuredSelection;
26
import org.eclipse.pde.core.IBaseModel;
27
import org.eclipse.pde.internal.core.ibundle.IBundleModel;
28
import org.eclipse.pde.internal.core.ibundle.IBundleModelFactory;
29
import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
25
import org.eclipse.pde.internal.core.util.CoreUtility;
30
import org.eclipse.pde.internal.core.util.CoreUtility;
26
import org.eclipse.pde.internal.ds.core.IDSComponent;
31
import org.eclipse.pde.internal.ds.core.IDSComponent;
27
import org.eclipse.pde.internal.ds.core.IDSDocumentFactory;
32
import org.eclipse.pde.internal.ds.core.IDSDocumentFactory;
Lines 31-36 Link Here
31
import org.eclipse.pde.internal.ds.ui.Activator;
36
import org.eclipse.pde.internal.ds.ui.Activator;
32
import org.eclipse.pde.internal.ds.ui.IConstants;
37
import org.eclipse.pde.internal.ds.ui.IConstants;
33
import org.eclipse.pde.internal.ds.ui.Messages;
38
import org.eclipse.pde.internal.ds.ui.Messages;
39
import org.eclipse.pde.internal.ui.util.ModelModification;
40
import org.eclipse.pde.internal.ui.util.PDEModelUtility;
34
import org.eclipse.swt.widgets.Display;
41
import org.eclipse.swt.widgets.Display;
35
import org.eclipse.ui.IWorkbenchPage;
42
import org.eclipse.ui.IWorkbenchPage;
36
import org.eclipse.ui.IWorkbenchPart;
43
import org.eclipse.ui.IWorkbenchPart;
Lines 46-51 Link Here
46
	private String fComponentName;
53
	private String fComponentName;
47
	private String fImplementationClass;
54
	private String fImplementationClass;
48
55
56
49
	/**
57
	/**
50
	 * 
58
	 * 
51
	 */
59
	 */
Lines 67-73 Link Here
67
		createContent();
75
		createContent();
68
		monitor.worked(1);
76
		monitor.worked(1);
69
		openFile();
77
		openFile();
78
		writeDSPropIntoManifest(fFile.getProject(), new SubProgressMonitor(
79
				monitor, 1));
80
		monitor.done();
81
	}
82
83
	private void writeDSPropIntoManifest(IProject project,
84
			SubProgressMonitor monitor) {
85
		
86
		PDEModelUtility.modifyModel(new ModelModification(project) {
87
			
88
			protected void modifyModel(IBaseModel model,
89
					IProgressMonitor monitor) throws CoreException {
90
				
91
				if (model instanceof IBundlePluginModelBase)
92
					updateManifest((IBundlePluginModelBase) model, monitor);
93
			}
94
		}, monitor);
70
		monitor.done();
95
		monitor.done();
96
97
	}
98
99
100
	private void updateManifest(IBundlePluginModelBase model,
101
			IProgressMonitor monitor) throws CoreException {
102
		IBundleModel bundleModel = model.getBundleModel();
103
104
		IFile manifestFile = (IFile) bundleModel
105
				.getUnderlyingResource();
106
		
107
		IBundleModelFactory factory = bundleModel.getFactory();
108
		
109
		String filePath = fFile.getFullPath().toOSString();
110
		
111
		// gets the second index of "\" (the first is index=0)
112
		filePath = filePath.substring(1);
113
		int index = filePath.indexOf("\\"); //$NON-NLS-1$
114
		if (index > -1) {
115
			// dsFilePath = "OSGI-INF/dsFile.xml";
116
			String dsFilePath = filePath.substring(index + 1);
117
			bundleModel.getBundle().setHeader(
118
					IConstants.DS_Manifest_Header_Key, dsFilePath);
119
		}
120
71
	}
121
	}
72
122
73
	protected void createContent() throws CoreException {
123
	protected void createContent() throws CoreException {
Lines 92-100 Link Here
92
		component.setImplementation(implementation);
142
		component.setImplementation(implementation);
93
143
94
		// Component Attributes
144
		// Component Attributes
95
		
145
96
		component.setAttributeName(fComponentName);
146
		component.setAttributeName(fComponentName);
97
		
98
147
99
		try {
148
		try {
100
			// Add builder
149
			// Add builder
Lines 103-110 Link Here
103
			ICommand[] commands = description.getBuildSpec();
152
			ICommand[] commands = description.getBuildSpec();
104
153
105
			for (int i = 0; i < commands.length; ++i) {
154
			for (int i = 0; i < commands.length; ++i) {
106
				if (commands[i].getBuilderName().equals(
155
				if (commands[i].getBuilderName().equals(IConstants.ID_BUILDER)) {
107
						IConstants.ID_BUILDER)) {
108
					return;
156
					return;
109
				}
157
				}
110
			}
158
			}
Lines 120-127 Link Here
120
		} catch (CoreException e) {
168
		} catch (CoreException e) {
121
			Activator.logException(e, null, null);
169
			Activator.logException(e, null, null);
122
		}
170
		}
123
		
171
124
		
125
	}
172
	}
126
173
127
	/**
174
	/**

Return to bug 244088