~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to rpm/org.eclipse.linuxtools.rpm.rpmlint/src/org/eclipse/linuxtools/internal/rpm/rpmlint/resolutions/ARpmlintResolution.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
7
 *
 
8
 * Contributors:
 
9
 *    Red Hat - initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.linuxtools.internal.rpm.rpmlint.resolutions;
 
12
 
 
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;
 
23
 
 
24
/**
 
25
 * Base class providing common functionality for rpmlint resolution.
 
26
 * 
 
27
 */
 
28
public abstract class ARpmlintResolution implements IMarkerResolution2 {
 
29
 
 
30
        
 
31
        /**
 
32
         * No image for rpmlint resolutions for now. 
 
33
         * 
 
34
         * @see org.eclipse.ui.IMarkerResolution2#getImage()
 
35
         */
 
36
        public Image getImage() {
 
37
                return null;
 
38
        }
 
39
        
 
40
        /**
 
41
         * Returns the SpecfileEditor for the given IMarker if any.
 
42
         * 
 
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.
 
45
         */
 
46
        protected SpecfileEditor getEditor(IMarker marker) {
 
47
                // Open or activate the editor.
 
48
                IWorkbenchPage page = PlatformUI.getWorkbench()
 
49
                                .getActiveWorkbenchWindow().getActivePage();
 
50
                IEditorPart part;
 
51
                try {
 
52
                        part = IDE.openEditor(page, marker);
 
53
                } catch (PartInitException e) {
 
54
                        RpmlintLog.logError(e);
 
55
                        return null;
 
56
                }
 
57
                // Get the editor's document.
 
58
                if (!(part instanceof SpecfileEditor)) {
 
59
                        return null;
 
60
                }
 
61
                SpecfileEditor editor = (SpecfileEditor) part;
 
62
                return editor;
 
63
        }
 
64
}
 
 
b'\\ No newline at end of file'