mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 09:46:02 +02:00
Bug 515296: changed the color of the error message
Change-Id: I04990deaef456df125d448d19372dd32c20859f6 Signed-off-by: Yannick Mayeur <yannick.mayeur@gmail.com>
This commit is contained in:
parent
546a5a6c91
commit
65c9e08d68
1 changed files with 76 additions and 34 deletions
|
@ -43,30 +43,33 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainer;
|
||||||
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
|
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
|
||||||
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
|
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
|
||||||
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
|
||||||
|
import org.eclipse.jface.dialogs.Dialog;
|
||||||
import org.eclipse.osgi.util.NLS;
|
import org.eclipse.osgi.util.NLS;
|
||||||
import org.eclipse.swt.SWT;
|
import org.eclipse.swt.SWT;
|
||||||
import org.eclipse.swt.events.SelectionAdapter;
|
import org.eclipse.swt.events.SelectionAdapter;
|
||||||
import org.eclipse.swt.events.SelectionEvent;
|
import org.eclipse.swt.events.SelectionEvent;
|
||||||
import org.eclipse.swt.layout.GridData;
|
import org.eclipse.swt.layout.GridData;
|
||||||
|
import org.eclipse.swt.layout.GridLayout;
|
||||||
import org.eclipse.swt.widgets.Button;
|
import org.eclipse.swt.widgets.Button;
|
||||||
import org.eclipse.swt.widgets.Composite;
|
import org.eclipse.swt.widgets.Composite;
|
||||||
import org.eclipse.swt.widgets.FileDialog;
|
import org.eclipse.swt.widgets.FileDialog;
|
||||||
|
import org.eclipse.swt.widgets.Text;
|
||||||
import org.eclipse.ui.IEditorInput;
|
import org.eclipse.ui.IEditorInput;
|
||||||
import org.eclipse.ui.IWorkbenchPage;
|
import org.eclipse.ui.IWorkbenchPage;
|
||||||
import org.eclipse.ui.PartInitException;
|
import org.eclipse.ui.PartInitException;
|
||||||
import org.eclipse.ui.PlatformUI;
|
import org.eclipse.ui.PlatformUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editor that lets you select a replacement for the missing source file
|
* Editor that lets you select a replacement for the missing source file and
|
||||||
* and modifies the source locator accordingly.
|
* modifies the source locator accordingly.
|
||||||
*/
|
*/
|
||||||
public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
|
public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
|
||||||
private static final String UID_KEY = ".uid"; //$NON-NLS-1$
|
private static final String UID_KEY = ".uid"; //$NON-NLS-1$
|
||||||
private static final String UID_CLASS_NAME = CSourceNotFoundEditor.class.getName();
|
private static final String UID_CLASS_NAME = CSourceNotFoundEditor.class.getName();
|
||||||
public static final String UID_DISASSEMBLY_BUTTON = UID_CLASS_NAME+ "disassemblyButton"; //$NON-NLS-1$
|
public static final String UID_DISASSEMBLY_BUTTON = UID_CLASS_NAME + "disassemblyButton"; //$NON-NLS-1$
|
||||||
public static final String UID_LOCATE_FILE_BUTTON = UID_CLASS_NAME+ "locateFileButton"; //$NON-NLS-1$
|
public static final String UID_LOCATE_FILE_BUTTON = UID_CLASS_NAME + "locateFileButton"; //$NON-NLS-1$
|
||||||
public static final String UID_EDIT_LOOKUP_BUTTON = UID_CLASS_NAME+ "editLookupButton"; //$NON-NLS-1$
|
public static final String UID_EDIT_LOOKUP_BUTTON = UID_CLASS_NAME + "editLookupButton"; //$NON-NLS-1$
|
||||||
|
|
||||||
private String missingFile = ""; //$NON-NLS-1$
|
private String missingFile = ""; //$NON-NLS-1$
|
||||||
private ILaunchConfiguration launch;
|
private ILaunchConfiguration launch;
|
||||||
|
@ -80,6 +83,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
private Button editLookupButton;
|
private Button editLookupButton;
|
||||||
private boolean isDebugElement;
|
private boolean isDebugElement;
|
||||||
private boolean isTranslationUnit;
|
private boolean isTranslationUnit;
|
||||||
|
private Text fText;
|
||||||
|
|
||||||
public CSourceNotFoundEditor() {
|
public CSourceNotFoundEditor() {
|
||||||
super();
|
super();
|
||||||
|
@ -87,10 +91,38 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void createPartControl(Composite parent) {
|
public void createPartControl(Composite parent) {
|
||||||
super.createPartControl(parent);
|
GridLayout topLayout = new GridLayout();
|
||||||
|
GridData data = new GridData();
|
||||||
|
topLayout.numColumns = 1;
|
||||||
|
topLayout.verticalSpacing = 10;
|
||||||
|
parent.setLayout(topLayout);
|
||||||
|
parent.setLayoutData(data);
|
||||||
|
parent.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
|
||||||
|
|
||||||
|
fText = new Text(parent, SWT.READ_ONLY | SWT.WRAP);
|
||||||
|
data = new GridData(GridData.FILL_HORIZONTAL);
|
||||||
|
data.grabExcessHorizontalSpace = true;
|
||||||
|
fText.setLayoutData(data);
|
||||||
|
fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_BLACK));
|
||||||
|
fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_WHITE));
|
||||||
|
if (getEditorInput() != null) {
|
||||||
|
setInput(getEditorInput());
|
||||||
|
}
|
||||||
|
|
||||||
|
createButtons(parent);
|
||||||
|
|
||||||
|
Dialog.applyDialogFont(parent);
|
||||||
|
|
||||||
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICDebugHelpContextIds.SOURCE_NOT_FOUND);
|
PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, ICDebugHelpContextIds.SOURCE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFocus() {
|
||||||
|
if (fText != null) {
|
||||||
|
fText.setFocus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setInput(IEditorInput input) {
|
public void setInput(IEditorInput input) {
|
||||||
if (input instanceof CSourceNotFoundEditorInput) {
|
if (input instanceof CSourceNotFoundEditorInput) {
|
||||||
|
@ -114,7 +146,11 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.setInput(input);
|
super.setInput(input);
|
||||||
|
if (fText != null) {
|
||||||
|
fText.setText(getText());
|
||||||
|
}
|
||||||
syncButtons();
|
syncButtons();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void syncButtons() {
|
private void syncButtons() {
|
||||||
|
@ -206,8 +242,10 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addSourceMappingToDirector(String missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException {
|
private void addSourceMappingToDirector(String missingPath, IPath newSourcePath,
|
||||||
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(Arrays.asList(director.getSourceContainers()));
|
AbstractSourceLookupDirector director) throws CoreException {
|
||||||
|
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(
|
||||||
|
Arrays.asList(director.getSourceContainers()));
|
||||||
MappingSourceContainer foundMappings = null;
|
MappingSourceContainer foundMappings = null;
|
||||||
for (ISourceContainer container : containerList) {
|
for (ISourceContainer container : containerList) {
|
||||||
if (container instanceof MappingSourceContainer) {
|
if (container instanceof MappingSourceContainer) {
|
||||||
|
@ -271,14 +309,15 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void locateFile() {
|
protected void locateFile() {
|
||||||
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
|
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
|
||||||
dialog.setFilterNames(new String[] {SourceLookupUIMessages.CSourceNotFoundEditor_2});
|
dialog.setFilterNames(new String[] { SourceLookupUIMessages.CSourceNotFoundEditor_2 });
|
||||||
// We cannot use IPaths when manipulating the missingFile (aka compilation file name) otherwise
|
// We cannot use IPaths when manipulating the missingFile (aka
|
||||||
// we end up converting windows paths to Linux and/or other canonicalisation of the names
|
// compilation file name) otherwise
|
||||||
|
// we end up converting windows paths to Linux and/or other
|
||||||
|
// canonicalisation of the names
|
||||||
CDebugUtils.FileParts missingFileParts = CDebugUtils.getFileParts(missingFile);
|
CDebugUtils.FileParts missingFileParts = CDebugUtils.getFileParts(missingFile);
|
||||||
dialog.setFilterExtensions(new String[] {"*." + missingFileParts.getExtension()}); //$NON-NLS-1$
|
dialog.setFilterExtensions(new String[] { "*." + missingFileParts.getExtension() }); //$NON-NLS-1$
|
||||||
String res = dialog.open();
|
String res = dialog.open();
|
||||||
if (res != null) {
|
if (res != null) {
|
||||||
CDebugUtils.FileParts resParts = CDebugUtils.getFileParts(res);
|
CDebugUtils.FileParts resParts = CDebugUtils.getFileParts(res);
|
||||||
|
@ -310,14 +349,15 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean reopenTranslationUnit(ITranslationUnit tu){
|
private boolean reopenTranslationUnit(ITranslationUnit tu) {
|
||||||
if (tu != null){
|
if (tu != null) {
|
||||||
IPath tuPath = tu.getLocation();
|
IPath tuPath = tu.getLocation();
|
||||||
if (tuPath != null){
|
if (tuPath != null) {
|
||||||
String filePath = tuPath.toOSString();
|
String filePath = tuPath.toOSString();
|
||||||
try {
|
try {
|
||||||
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath);
|
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector()
|
||||||
if (foundElements.length == 1 && foundElements[0] instanceof IFile){
|
.findSourceElements(filePath);
|
||||||
|
if (foundElements.length == 1 && foundElements[0] instanceof IFile) {
|
||||||
EditorUtility.openInEditor(foundElements[0]);
|
EditorUtility.openInEditor(foundElements[0]);
|
||||||
return true;
|
return true;
|
||||||
} else if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage) {
|
} else if (foundElements.length == 1 && foundElements[0] instanceof LocalFileStorage) {
|
||||||
|
@ -325,8 +365,10 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
|
||||||
if (newLocation.getFullPath().toFile().exists()) {
|
if (newLocation.getFullPath().toFile().exists()) {
|
||||||
ITranslationUnit remappedTU = tu;
|
ITranslationUnit remappedTU = tu;
|
||||||
if (tu instanceof ExternalTranslationUnit)
|
if (tu instanceof ExternalTranslationUnit)
|
||||||
// TODO: source lookup needs to be modified to use URIs
|
// TODO: source lookup needs to be modified to
|
||||||
remappedTU = new ExternalTranslationUnit(tu.getParent(), URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
|
// use URIs
|
||||||
|
remappedTU = new ExternalTranslationUnit(tu.getParent(),
|
||||||
|
URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
|
||||||
EditorUtility.openInEditor(remappedTU);
|
EditorUtility.openInEditor(remappedTU);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue