1
/*******************************************************************************
2
* Copyright (c) 2007, 2009 Red Hat, Inc.
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
9
* Red Hat - initial API and implementation
10
*******************************************************************************/
11
package org.eclipse.linuxtools.internal.rpm.rpmlint.resolutions;
13
import org.eclipse.core.resources.IMarker;
14
import org.eclipse.linuxtools.internal.rpm.rpmlint.RpmlintLog;
15
import org.eclipse.linuxtools.rpm.ui.editor.SpecfileEditor;
16
import org.eclipse.swt.graphics.Image;
17
import org.eclipse.ui.IEditorPart;
18
import org.eclipse.ui.IMarkerResolution2;
19
import org.eclipse.ui.IWorkbenchPage;
20
import org.eclipse.ui.PartInitException;
21
import org.eclipse.ui.PlatformUI;
22
import org.eclipse.ui.ide.IDE;
25
* Base class providing common functionality for rpmlint resolution.
28
public abstract class ARpmlintResolution implements IMarkerResolution2 {
32
* No image for rpmlint resolutions for now.
34
* @see org.eclipse.ui.IMarkerResolution2#getImage()
36
public Image getImage() {
41
* Returns the SpecfileEditor for the given IMarker if any.
43
* @param marker The marker to use for retrieving the editor.
44
* @return The SpecfileEditor this marker is from or null if it's not a SpecfileEditor.
46
protected SpecfileEditor getEditor(IMarker marker) {
47
// Open or activate the editor.
48
IWorkbenchPage page = PlatformUI.getWorkbench()
49
.getActiveWorkbenchWindow().getActivePage();
52
part = IDE.openEditor(page, marker);
53
} catch (PartInitException e) {
54
RpmlintLog.logError(e);
57
// Get the editor's document.
58
if (!(part instanceof SpecfileEditor)) {
61
SpecfileEditor editor = (SpecfileEditor) part;
b'\\ No newline at end of file'