1 /*******************************************************************************
2  * Copyright (c) 2008, 2019 IBM Corporation and others.
3  *
4  * This program and the accompanying materials
5  * are made available under the terms of the Eclipse Public License 2.0
6  * which accompanies this distribution, and is available at
7  * https://www.eclipse.org/legal/epl-2.0/
8  *
9  * SPDX-License-Identifier: EPL-2.0
10  *
11  * Contributors:
12  *     IBM Corporation - initial API and implementation
13  *******************************************************************************/
14 package org.eclipse.pde.internal.ui.correction;
15 
16 import org.eclipse.core.resources.IMarker;
17 import org.eclipse.jface.wizard.WizardDialog;
18 import org.eclipse.pde.core.IBaseModel;
19 import org.eclipse.pde.internal.core.ibundle.IBundlePluginModelBase;
20 import org.eclipse.pde.internal.ui.PDEPlugin;
21 import org.eclipse.pde.internal.ui.PDEUIMessages;
22 import org.eclipse.pde.internal.ui.editor.plugin.ManifestEditor;
23 import org.eclipse.pde.internal.ui.util.SWTUtil;
24 import org.eclipse.pde.internal.ui.wizards.extension.NewExtensionWizard;
25 import org.eclipse.ui.IEditorPart;
26 
27 public class AddNewExtensionResolution extends AbstractPDEMarkerResolution {
28 
AddNewExtensionResolution(int type, IMarker marker)29 	public AddNewExtensionResolution(int type, IMarker marker) {
30 		super(type, marker);
31 	}
32 
33 	@Override
getLabel()34 	public String getLabel() {
35 		return PDEUIMessages.AddNewExtensionResolution_description;
36 	}
37 
38 	@Override
createChange(IBaseModel model)39 	protected void createChange(IBaseModel model) {
40 		IEditorPart part = PDEPlugin.getActivePage().getActiveEditor();
41 		if (part instanceof ManifestEditor) {
42 			ManifestEditor editor = (ManifestEditor) part;
43 			IBaseModel base = editor.getAggregateModel();
44 			if (base instanceof IBundlePluginModelBase) {
45 				IBundlePluginModelBase pluginModel = (IBundlePluginModelBase) base;
46 				NewExtensionWizard wizard = new NewExtensionWizard(pluginModel.getUnderlyingResource().getProject(), pluginModel, editor) {
47 					@Override
48 					public boolean performFinish() {
49 						return super.performFinish();
50 					}
51 				};
52 				WizardDialog dialog = new WizardDialog(PDEPlugin.getActiveWorkbenchShell(), wizard);
53 				dialog.create();
54 				SWTUtil.setDialogSize(dialog, 500, 500);
55 				dialog.open();
56 			}
57 		}
58 	}
59 
60 }