mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 10:15:39 +02:00
Added couple of utility methods
This commit is contained in:
parent
598b6fc042
commit
74cd26558e
1 changed files with 34 additions and 19 deletions
|
@ -1,24 +1,13 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* $QNXLicenseC:
|
* Copyright (c) 2009, 2010 Alena Laskavaia
|
||||||
* Copyright 2008, QNX Software Systems. All Rights Reserved.
|
* All rights reserved. This program and the accompanying materials
|
||||||
*
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* You must obtain a written license from and pay applicable license fees to QNX
|
* which accompanies this distribution, and is available at
|
||||||
* Software Systems before you may reproduce, modify or distribute this software,
|
* http://www.eclipse.org/legal/epl-v10.html
|
||||||
* or any work that includes all or part of this software. Free development
|
*
|
||||||
* licenses are available for evaluation and non-commercial purposes. For more
|
* Contributors:
|
||||||
* information visit http://licensing.qnx.com or email licensing@qnx.com.
|
* Alena Laskavaia - initial API and implementation
|
||||||
*
|
|
||||||
* This file may contain contributions from others. Please review this entire
|
|
||||||
* file for other proprietary rights or license notices, as well as the QNX
|
|
||||||
* Development Suite License Guide at http://licensing.qnx.com/license-guide/
|
|
||||||
* for other information.
|
|
||||||
* $
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
/*
|
|
||||||
* Created by: Elena Laskavaia
|
|
||||||
* Created on: 2010-05-05
|
|
||||||
* Last modified by: $Author: elaskavaia $
|
|
||||||
*/
|
|
||||||
package org.eclipse.cdt.codan.ui;
|
package org.eclipse.cdt.codan.ui;
|
||||||
|
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
|
@ -31,7 +20,11 @@ import org.eclipse.core.runtime.Path;
|
||||||
import org.eclipse.jface.text.BadLocationException;
|
import org.eclipse.jface.text.BadLocationException;
|
||||||
import org.eclipse.jface.text.IDocument;
|
import org.eclipse.jface.text.IDocument;
|
||||||
import org.eclipse.ui.IEditorPart;
|
import org.eclipse.ui.IEditorPart;
|
||||||
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
|
import org.eclipse.ui.IWorkbenchWindow;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
import org.eclipse.ui.ide.ResourceUtil;
|
||||||
import org.eclipse.ui.texteditor.ITextEditor;
|
import org.eclipse.ui.texteditor.ITextEditor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -123,4 +116,26 @@ public class CodanEditorUtility {
|
||||||
}
|
}
|
||||||
return loc + ":" + line; //$NON-NLS-1$
|
return loc + ":" + line; //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @since 1.1
|
||||||
|
*/
|
||||||
|
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
|
||||||
|
*/
|
||||||
|
public static IEditorPart getActiveEditor() {
|
||||||
|
IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
|
||||||
|
if (activeWorkbenchWindow==null) return null;
|
||||||
|
IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage();
|
||||||
|
if (activePage==null) return null;
|
||||||
|
IEditorPart e = activePage.getActiveEditor();
|
||||||
|
return e;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue