diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF index e609e7c73bc..243dab8775f 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF @@ -8,10 +8,10 @@ Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.jface.text, org.eclipse.core.resources, - org.eclipse.cdt.codan.ui, org.eclipse.ui.ide, org.eclipse.cdt.core, - org.eclipse.cdt.codan.core.cxx + org.eclipse.cdt.codan.core.cxx, + org.eclipse.cdt.codan.ui.cxx Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Vendor: %Bundle-Vendor diff --git a/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF index e968c30a4f7..41872bf3ddb 100644 --- a/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.core.test/META-INF/MANIFEST.MF @@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.core.runtime, org.junit, org.eclipse.cdt.codan.checkers.ui;bundle-version="1.0.0", org.eclipse.cdt.codan.ui;bundle-version="1.1.0", - org.eclipse.ui.ide;bundle-version="3.6.0" + org.eclipse.ui.ide;bundle-version="3.6.0", + org.eclipse.cdt.codan.ui.cxx;bundle-version="2.0.0" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-Vendor: %Bundle-Vendor diff --git a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF index 8f08b1e859c..76e867c2d11 100644 --- a/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui.cxx/META-INF/MANIFEST.MF @@ -2,7 +2,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.cdt.codan.ui.cxx;singleton:=true -Bundle-Version: 1.0.0.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.eclipse.cdt.codan.internal.ui.cxx.Activator Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.ui, @@ -14,7 +14,9 @@ Require-Bundle: org.eclipse.ui, org.eclipse.cdt.ui, org.eclipse.core.resources, org.eclipse.cdt.codan.ui, - org.eclipse.jface.text + org.eclipse.jface.text, + org.eclipse.ui.ide Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy -Export-Package: org.eclipse.cdt.codan.internal.ui.cxx;x-internal:=true +Export-Package: org.eclipse.cdt.codan.internal.ui.cxx;x-internal:=true, + org.eclipse.cdt.codan.ui diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java similarity index 99% rename from codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java rename to codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java index 5be23e36be1..26cba42800f 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java +++ b/codan/org.eclipse.cdt.codan.ui.cxx/src/org/eclipse/cdt/codan/ui/AbstractCodanCMarkerResolution.java @@ -30,7 +30,6 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IMarkerResolution; import org.eclipse.ui.IMarkerResolution2; import org.eclipse.ui.PartInitException; import org.eclipse.ui.texteditor.ITextEditor; @@ -43,7 +42,7 @@ import org.eclipse.ui.texteditor.ITextEditor; * * @since 1.1 */ -public abstract class AbstractCodanCMarkerResolution implements IMarkerResolution { +public abstract class AbstractCodanCMarkerResolution implements ICodanMarkerResolution { private boolean codanProblem; /** diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF index b52921a0004..06f3f7a0852 100644 --- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF @@ -2,19 +2,18 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true -Bundle-Version: 1.1.0.qualifier +Bundle-Version: 2.0.0.qualifier Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator Bundle-Vendor: %Bundle-Vendor Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, org.eclipse.core.resources, org.eclipse.ui.workbench.texteditor, - org.eclipse.ui.editors, org.eclipse.cdt.codan.core, org.eclipse.jface.text, org.eclipse.ui.ide, org.eclipse.cdt.ui, - org.eclipse.cdt.core + org.eclipse.core.filesystem Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Export-Package: org.eclipse.cdt.codan.internal.ui;x-friends:="org.eclipse.cdt.codan.ui.cxx", diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java index 33caabceefe..9c9f68cc5fa 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanProblemMarkerResolutionGenerator.java @@ -21,7 +21,7 @@ import java.util.regex.Pattern; import org.eclipse.cdt.codan.core.model.ICodanProblemMarker; import org.eclipse.cdt.codan.internal.core.model.CodanProblemMarker; -import org.eclipse.cdt.codan.ui.AbstractCodanCMarkerResolution; +import org.eclipse.cdt.codan.ui.ICodanMarkerResolution; import org.eclipse.core.resources.IMarker; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; @@ -72,8 +72,8 @@ public class CodanProblemMarkerResolutionGenerator implements IMarkerResolutionG continue; } } - if (res.res instanceof AbstractCodanCMarkerResolution) { - if (!((AbstractCodanCMarkerResolution) res.res).isApplicable(marker)) + if (res.res instanceof ICodanMarkerResolution) { + if (!((ICodanMarkerResolution) res.res).isApplicable(marker)) continue; } list.add(res.res); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java deleted file mode 100644 index 599dc81ea50..00000000000 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstarctCodanCMarkerResolution.java +++ /dev/null @@ -1,19 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2009, 2010 Alena Laskavaia - * 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: - * Alena Laskavaia - initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.codan.ui; - -/** - * @deprecated class name was misspelled, use - * {@link AbstractCodanCMarkerResolution} - */ -@Deprecated -public abstract class AbstarctCodanCMarkerResolution extends AbstractCodanCMarkerResolution { -} diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java index 5f8b33969ed..6350530d997 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/AbstractCodanProblemDetailsProvider.java @@ -81,7 +81,7 @@ public abstract class AbstractCodanProblemDetailsProvider { * Returns problem arguments by index (set by checker when reporting * problem) * - * @since 1.1 + * @since 2.0 */ public String getProblemArgument(int index) { return CodanProblemMarker.getProblemArgument(marker, index); @@ -93,7 +93,7 @@ public abstract class AbstractCodanProblemDetailsProvider { * * @param marker - problem marker * @return problem arguments, can not be null. Can be 0 sized array. - * @since 1.1 + * @since 2.0 */ public String[] getProblemArguments() { return CodanProblemMarker.getProblemArguments(marker); @@ -120,7 +120,7 @@ public abstract class AbstractCodanProblemDetailsProvider { } /** - * @since 1.1 + * @since 2.0 */ protected String getLocation() { return CodanEditorUtility.getLocation(marker); diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java index e6062b89044..8c5c40e8c51 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanEditorUtility.java @@ -10,21 +10,24 @@ *******************************************************************************/ package org.eclipse.cdt.codan.ui; -import org.eclipse.cdt.core.model.CoreModel; -import org.eclipse.cdt.core.model.ICElement; -import org.eclipse.cdt.internal.ui.util.EditorUtility; +import java.io.File; + +import org.eclipse.core.filesystem.EFS; +import org.eclipse.core.filesystem.IFileStore; +import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; +import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorPart; import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.ide.IDE; import org.eclipse.ui.ide.ResourceUtil; +import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.ITextEditor; /** @@ -75,14 +78,30 @@ public class CodanEditorUtility { } } - @SuppressWarnings("restriction") public static IEditorPart openInEditor(String file, IResource markerResource) throws PartInitException { - IPath pfile = new Path(file); - ICElement element = null; - if (markerResource != null) - element = CoreModel.getDefault().create(markerResource); - IEditorPart part = EditorUtility.openInEditor(pfile, element); - return part; + // ICElement element = null; + // if (markerResource != null) + // element = CoreModel.getDefault().create(markerResource); + IFile efile = null; + if (markerResource instanceof IFile) + efile = (IFile) markerResource; + if (efile != null) { + IWorkbenchPage page = getActivePage(); + IEditorDescriptor desc = PlatformUI.getWorkbench().getEditorRegistry().getDefaultEditor(file); + IEditorPart part = page.openEditor(new FileEditorInput(efile), desc.getId()); + return part; + } + File fileToOpen = new File(file); + if (fileToOpen.exists() && fileToOpen.isFile()) { + IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI()); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + return IDE.openEditorOnFileStore(page, fileStore); + } catch (PartInitException e) { + //Put your exception handler here if you wish to + } + } + return null; } public static IEditorPart openInEditor(IMarker marker) throws PartInitException { @@ -105,7 +124,7 @@ public class CodanEditorUtility { /** * @param marker * @return - * @since 1.1 + * @since 2.0 */ public static String getLocation(IMarker marker) { String loc = marker.getResource().getFullPath().toPortableString(); @@ -116,26 +135,36 @@ public class CodanEditorUtility { } return loc + ":" + line; //$NON-NLS-1$ } - + /** - * @since 1.1 + * @since 2.0 */ - public static boolean isResourceOpenInEditor(IResource resource, - IEditorPart editor) { - if (editor == null) return false; + public static boolean isResourceOpenInEditor(IResource resource, IEditorPart editor) { + if (editor == null) + return false; IResource realResource = ResourceUtil.getResource(editor.getEditorInput()); return resource.equals(realResource); } - + /** - * @since 1.1 + * @since 2.0 */ public static IEditorPart getActiveEditor() { - IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (activeWorkbenchWindow==null) return null; - IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); - if (activePage==null) return null; + IWorkbenchPage activePage = getActivePage(); + if (activePage == null) + return null; IEditorPart e = activePage.getActiveEditor(); return e; } + + /** + * @return + */ + private static IWorkbenchPage getActivePage() { + IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); + if (activeWorkbenchWindow == null) + return null; + IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); + return activePage; + } } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/ICodanMarkerResolution.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/ICodanMarkerResolution.java new file mode 100644 index 00000000000..be93fdf4d97 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/ICodanMarkerResolution.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2009, 2011 Alena Laskavaia + * 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: + * Alena Laskavaia - initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.codan.ui; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.ui.IMarkerResolution; + +/** + * Interface for codan marker resolution + * + * @since 2.0 + */ +public interface ICodanMarkerResolution extends IMarkerResolution { + /** + * Override is extra checks is required to determine applicability of marker + * resolution + * + * @param marker + * @return + */ + public boolean isApplicable(IMarker marker); +} diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java index 426a4a73170..20383f4616c 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java @@ -25,8 +25,8 @@ import org.eclipse.swt.widgets.Label; * A field editor for displaying labels not associated with other widgets. * * @author fgiust - * @version $Revision: 1.3 $ ($Author: fgiust $) - * @since 1.1 + * @version $Revision: 1.1 $ ($Author: elaskavaia $) + * @since 2.0 */ public class LabelFieldEditor extends FieldEditor { /***