1 /******************************************************************************* 2 * Copyright (c) 2005, 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.core.runtime.CoreException; 18 import org.eclipse.osgi.util.NLS; 19 import org.eclipse.pde.internal.core.builders.PDEMarkerFactory; 20 import org.eclipse.pde.internal.core.text.build.*; 21 import org.eclipse.pde.internal.ui.PDEUIMessages; 22 23 public class AddBuildEntryResolution extends BuildEntryMarkerResolution { 24 AddBuildEntryResolution(int type, IMarker marker)25 public AddBuildEntryResolution(int type, IMarker marker) { 26 super(type, marker); 27 } 28 AddBuildEntryResolution(int type, IMarker marker, String entry, String value)29 public AddBuildEntryResolution(int type, IMarker marker, String entry, String value) { 30 super(type, marker); 31 fEntry = entry; 32 fToken = value; 33 } 34 35 @Override getLabel()36 public String getLabel() { 37 return NLS.bind(PDEUIMessages.AddBuildEntryResolution_add, fToken, fEntry); 38 } 39 40 @Override createChange(Build build)41 protected void createChange(Build build) { 42 try { 43 fEntry = (String) marker.getAttribute(PDEMarkerFactory.BK_BUILD_ENTRY); 44 fToken = (String) marker.getAttribute(PDEMarkerFactory.BK_BUILD_TOKEN); 45 } catch (CoreException e) { 46 } 47 try { 48 BuildModel buildModel = build.getModel(); 49 if (buildModel.isStale()) { 50 buildModel.reconciled(buildModel.getDocument()); 51 } 52 BuildEntry buildEntry = (BuildEntry) build.getEntry(fEntry); 53 if (buildEntry == null) 54 buildEntry = new BuildEntry(fEntry, buildModel); 55 56 if (fToken != null) 57 buildEntry.addToken(fToken); 58 } catch (CoreException e) { 59 } 60 } 61 } 62