blob: 3ba918d33939e088e18e5cd1d726ec118c77d927 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 IBM Corporation and others.
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// which accompanies this distribution, and is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// Contributors:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.authoring.ui.util;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.epf.authoring.ui.AuthoringUIPlugin;
import org.eclipse.epf.authoring.ui.AuthoringUIResources;
import org.eclipse.epf.authoring.ui.editors.ConfigurationEditor;
import org.eclipse.epf.uma.MethodConfiguration;
import org.eclipse.epf.uma.MethodElement;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
/**
* MarkerResolution for Configuration errors
* @author Jeff Hardy
* @author Jinhua Xi
*
*/
public class ConfigurationMarkerResolution implements IMarkerResolution {
protected MethodConfiguration config;
protected MethodElement errorElement;
protected MethodElement causeElement;
public ConfigurationMarkerResolution(MethodConfiguration config, MethodElement errorElement, MethodElement causeElement) {
this.config = config;
this.errorElement = errorElement;
this.causeElement = causeElement;
}
public String getLabel() {
return AuthoringUIResources.ConfigurationMarkerResolutionGenerator_resolveMissingReference;
}
public void run(IMarker marker) {
//System.out.println("quick fix me");
try {
// get the marker resource file
if ((marker.getResource() instanceof IFile)) {
IFile file = (IFile) marker.getResource();
IWorkbenchPage activePage = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
IEditorPart editor = IDE.openEditor(activePage, file);
if ( editor instanceof ConfigurationEditor ) {
((ConfigurationEditor)editor).doQuickFix(marker);
}
}
} catch (Exception ex ) {
//ex.printStackTrace();
AuthoringUIPlugin.getDefault().getLogger().logError(ex);
}
}
}