1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 09:16: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:
Yannick Mayeur 2017-04-19 13:48:29 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent 546a5a6c91
commit 65c9e08d68

View file

@ -43,22 +43,25 @@ import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.debug.core.sourcelookup.containers.LocalFileStorage;
import org.eclipse.debug.ui.sourcelookup.CommonSourceNotFoundEditor;
import org.eclipse.debug.ui.sourcelookup.ISourceDisplay;
import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.osgi.util.NLS;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
/**
* Editor that lets you select a replacement for the missing source file
* and modifies the source locator accordingly.
* Editor that lets you select a replacement for the missing source file and
* modifies the source locator accordingly.
*/
public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
public final String foundMappingsContainerName = "Found Mappings"; //$NON-NLS-1$
@ -80,6 +83,7 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
private Button editLookupButton;
private boolean isDebugElement;
private boolean isTranslationUnit;
private Text fText;
public CSourceNotFoundEditor() {
super();
@ -87,10 +91,38 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
@Override
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);
}
@Override
public void setFocus() {
if (fText != null) {
fText.setFocus();
}
}
@Override
public void setInput(IEditorInput input) {
if (input instanceof CSourceNotFoundEditorInput) {
@ -114,7 +146,11 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
}
super.setInput(input);
if (fText != null) {
fText.setText(getText());
}
syncButtons();
}
private void syncButtons() {
@ -206,8 +242,10 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
}
private void addSourceMappingToDirector(String missingPath, IPath newSourcePath, AbstractSourceLookupDirector director) throws CoreException {
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(Arrays.asList(director.getSourceContainers()));
private void addSourceMappingToDirector(String missingPath, IPath newSourcePath,
AbstractSourceLookupDirector director) throws CoreException {
ArrayList<ISourceContainer> containerList = new ArrayList<ISourceContainer>(
Arrays.asList(director.getSourceContainers()));
MappingSourceContainer foundMappings = null;
for (ISourceContainer container : containerList) {
if (container instanceof MappingSourceContainer) {
@ -271,12 +309,13 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
}
}
protected void locateFile() {
FileDialog dialog = new FileDialog(getEditorSite().getShell(), SWT.NONE);
dialog.setFilterNames(new String[] { SourceLookupUIMessages.CSourceNotFoundEditor_2 });
// We cannot use IPaths when manipulating the missingFile (aka compilation file name) otherwise
// we end up converting windows paths to Linux and/or other canonicalisation of the names
// We cannot use IPaths when manipulating the missingFile (aka
// 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);
dialog.setFilterExtensions(new String[] { "*." + missingFileParts.getExtension() }); //$NON-NLS-1$
String res = dialog.open();
@ -316,7 +355,8 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
if (tuPath != null) {
String filePath = tuPath.toOSString();
try {
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector().findSourceElements(filePath);
Object[] foundElements = CDebugCorePlugin.getDefault().getCommonSourceLookupDirector()
.findSourceElements(filePath);
if (foundElements.length == 1 && foundElements[0] instanceof IFile) {
EditorUtility.openInEditor(foundElements[0]);
return true;
@ -325,8 +365,10 @@ public class CSourceNotFoundEditor extends CommonSourceNotFoundEditor {
if (newLocation.getFullPath().toFile().exists()) {
ITranslationUnit remappedTU = tu;
if (tu instanceof ExternalTranslationUnit)
// TODO: source lookup needs to be modified to use URIs
remappedTU = new ExternalTranslationUnit(tu.getParent(), URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
// TODO: source lookup needs to be modified to
// use URIs
remappedTU = new ExternalTranslationUnit(tu.getParent(),
URIUtil.toURI(newLocation.getFullPath()), tu.getContentTypeId());
EditorUtility.openInEditor(remappedTU);
return true;
}