diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties index c227a634a1a..460e24b66c6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginResources.properties @@ -29,7 +29,9 @@ ConsolePreferencePage.outputColor.label=Output text color ConsolePreferencePage.infoColor.label=Information message text color ConsolePreferencePage.errorColor.label=Error message text color ConsolePreferencePage.backgroundColor.label=Background color -ConsolePreferencePage.problemBackgroundColor.label=Background color for build problems +ConsolePreferencePage.problemBackgroundColor.label=Background color for build errors +ConsolePreferencePage.problemWarningBackgroundColor.label=Background color for build warnings +ConsolePreferencePage.problemInfoBackgroundColor.label=Background color for build informational messages ConsolePreferencePage.problemHighlightedColor.label=Highlighting color for build problems # ------- Project/Prefernces/Wizards COnfiguration blocks ------- diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java index ce411112aa8..b8301511df6 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleManager.java @@ -63,20 +63,43 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang public static final String KEY_LOG_LOCATION = "logLocation"; //$NON-NLS-1$ public static final boolean CONSOLE_KEEP_LOG_DEFAULT = true; - ListenerList listeners = new ListenerList(); - BuildConsole fConsole; + private ListenerList listeners = new ListenerList(); + private BuildConsole fConsole; private Map fConsoleMap = new HashMap(); - Color infoColor, outputColor, errorColor, backgroundColor, problemHighlightedColor, problemBackgroundColor; + private Color infoColor; + private Color outputColor; + private Color errorColor; + private Color backgroundColor; + private Color problemHighlightedColor; + private Color problemErrorBackgroundColor; + private Color problemInfoBackgroundColor; + private Color problemWarningBackgroundColor; + public Color getProblemHighlightedColor() { return problemHighlightedColor; } + /** + * This function returns background color for errors only now + */ public Color getProblemBackgroundColor() { - return problemBackgroundColor; + return problemErrorBackgroundColor; } - BuildConsoleStreamDecorator infoStream, outputStream, errorStream; - String fName, fContextMenuId; + public Color getWarningBackgroundColor() { + return problemWarningBackgroundColor; + } + + public Color getInfoBackgroundColor() { + return problemInfoBackgroundColor; + } + + private BuildConsoleStreamDecorator infoStream; + private BuildConsoleStreamDecorator outputStream; + private BuildConsoleStreamDecorator errorStream; + + private String fName; + private String fContextMenuId; static public final int BUILD_STREAM_TYPE_INFO = 0; static public final int BUILD_STREAM_TYPE_OUTPUT = 1; @@ -180,7 +203,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang outputColor.dispose(); errorColor.dispose(); backgroundColor.dispose(); - problemBackgroundColor.dispose(); + problemErrorBackgroundColor.dispose(); + problemWarningBackgroundColor.dispose(); + problemInfoBackgroundColor.dispose(); problemHighlightedColor.dispose(); } ConsolePlugin.getDefault().getConsoleManager().removeConsoles(new org.eclipse.ui.console.IConsole[]{fConsole}); @@ -229,7 +254,9 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang backgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_BACKGROUND_COLOR); fConsole.setBackground(backgroundColor); problemHighlightedColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_HIGHLIGHTED_COLOR); - problemBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); + problemErrorBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); + problemWarningBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); + problemInfoBackgroundColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); } }); CUIPlugin.getWorkspace().addResourceChangeListener(this); @@ -271,8 +298,18 @@ public class BuildConsoleManager implements IBuildConsoleManager, IResourceChang redrawTextViewer(); } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR)) { Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_BACKGROUND_COLOR); - problemBackgroundColor.dispose(); - problemBackgroundColor = newColor; + problemErrorBackgroundColor.dispose(); + problemErrorBackgroundColor = newColor; + redrawTextViewer(); + } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR)) { + Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_WARNING_BACKGROUND_COLOR); + problemWarningBackgroundColor.dispose(); + problemWarningBackgroundColor = newColor; + redrawTextViewer(); + } else if (property.equals(BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR)) { + Color newColor = createColor(CUIPlugin.getStandardDisplay(), BuildConsolePreferencePage.PREF_BUILDCONSOLE_PROBLEM_INFO_BACKGROUND_COLOR); + problemInfoBackgroundColor.dispose(); + problemInfoBackgroundColor = newColor; redrawTextViewer(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java index 07a92d25bde..8910664b673 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartition.java @@ -26,8 +26,10 @@ public class BuildConsolePartition extends TypedRegion { /** Partition type */ public static final String CONSOLE_PARTITION_TYPE = CUIPlugin.getPluginId() + ".CONSOLE_PARTITION_TYPE"; //$NON-NLS-1$ - /** Partition type to report errors in console */ + /** Partition types to report build problems in the console */ public static final String ERROR_PARTITION_TYPE = CUIPlugin.getPluginId() + ".ERROR_PARTITION_TYPE"; //$NON-NLS-1$ + public static final String INFO_PARTITION_TYPE = CUIPlugin.getPluginId() + ".INFO_PARTITION_TYPE"; //$NON-NLS-1$ + public static final String WARNING_PARTITION_TYPE = CUIPlugin.getPluginId() + ".WARNING_PARTITION_TYPE"; //$NON-NLS-1$ public BuildConsolePartition(BuildConsoleStreamDecorator stream, int offset, int length, String type) { super(offset, length, type); @@ -77,14 +79,17 @@ public class BuildConsolePartition extends TypedRegion { */ public boolean canBeCombinedWith(BuildConsolePartition partition) { // Error partitions never can be combined together - if ( getType() == ERROR_PARTITION_TYPE ) return false; + String type = getType(); + if (isProblemPartitionType(type)) { + return false; + } int start = getOffset(); int end = start + getLength(); int otherStart = partition.getOffset(); int otherEnd = otherStart + partition.getLength(); boolean overlap = (otherStart >= start && otherStart <= end) || (start >= otherStart && start <= otherEnd); - return getStream() != null && overlap && getType().equals(partition.getType()) && getStream().equals(partition.getStream()); + return getStream() != null && overlap && type.equals(partition.getType()) && getStream().equals(partition.getStream()); } /** @@ -117,4 +122,12 @@ public class BuildConsolePartition extends TypedRegion { public ProblemMarkerInfo getMarker() { return fMarker; } + + public static boolean isProblemPartitionType(String type) { + return type==BuildConsolePartition.ERROR_PARTITION_TYPE + || type==BuildConsolePartition.WARNING_PARTITION_TYPE + || type==BuildConsolePartition.INFO_PARTITION_TYPE; + } + + } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java index 35917f5b559..a6f79f721f2 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsolePartitioner.java @@ -23,6 +23,7 @@ import java.util.Vector; import org.eclipse.core.filesystem.EFS; import org.eclipse.core.filesystem.IFileStore; import org.eclipse.core.filesystem.URIUtil; +import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -327,7 +328,8 @@ public class BuildConsolePartitioner } private void addStreamEntryToDocument(StreamEntry entry) throws BadLocationException { - if ( entry.getMarker() == null ) { + ProblemMarkerInfo marker = entry.getMarker(); + if (marker==null) { // It is plain unmarkered console output addPartition(new BuildConsolePartition(fLastStream, fDocument.getLength(), @@ -336,10 +338,18 @@ public class BuildConsolePartitioner } else { // this text line in entry is markered with ProblemMarkerInfo, // create special partition for it. + String errorPartitionType; + if (marker.severity==IMarker.SEVERITY_INFO) { + errorPartitionType = BuildConsolePartition.INFO_PARTITION_TYPE; + } else if (marker.severity==IMarker.SEVERITY_WARNING) { + errorPartitionType = BuildConsolePartition.WARNING_PARTITION_TYPE; + } else { + errorPartitionType = BuildConsolePartition.ERROR_PARTITION_TYPE; + } addPartition(new BuildConsolePartition(fLastStream, fDocument.getLength(), entry.getText().length(), - BuildConsolePartition.ERROR_PARTITION_TYPE, entry.getMarker())); + errorPartitionType, marker)); } fDocument.replace(fDocument.getLength(), 0, entry.getText()); } @@ -479,21 +489,21 @@ public class BuildConsolePartitioner ITypedRegion newPartition = null; int offset = region.getOffset(); + String type = messageConsolePartition.getType(); if (offset < overflow) { int endOffset = offset + region.getLength(); - if (endOffset < overflow || - messageConsolePartition.getType() == BuildConsolePartition.ERROR_PARTITION_TYPE ) { + if (endOffset < overflow || BuildConsolePartition.isProblemPartitionType(type)) { // remove partition, // partitions with problem markers can't be split - remove them too } else { // split partition int length = endOffset - overflow; - newPartition = messageConsolePartition.createNewPartition(0, length, messageConsolePartition.getType()); + newPartition = messageConsolePartition.createNewPartition(0, length, type); } } else { // modify partition offset - newPartition = messageConsolePartition.createNewPartition(messageConsolePartition.getOffset() - - overflow, messageConsolePartition.getLength(), messageConsolePartition.getType()); + offset = messageConsolePartition.getOffset() - overflow; + newPartition = messageConsolePartition.createNewPartition(offset, messageConsolePartition.getLength(), type); } if (newPartition != null) { newParitions.add(newPartition); @@ -572,31 +582,35 @@ public class BuildConsolePartitioner return new BuildOutputStream(this, fManager.getStreamDecorator(BuildConsoleManager.BUILD_STREAM_TYPE_ERROR)); } - /** This method is useful for future debugging and bugfixing */ - @SuppressWarnings("unused") + /** This method is useful for future debugging and bug-fixing */ + @SuppressWarnings({ "unused", "nls" }) private void printDocumentPartitioning() { - System.out.println("Document partitioning: "); //$NON-NLS-1$ + System.out.println("Document partitioning: "); for (ITypedRegion tr : fPartitions) { BuildConsolePartition p = (BuildConsolePartition) tr; int start = p.getOffset(); int end = p.getOffset() + p.getLength(); String text; - String isError = "U"; //$NON-NLS-1$ - if (p.getType() == BuildConsolePartition.ERROR_PARTITION_TYPE) { - isError = "E"; //$NON-NLS-1$ - } else if (p.getType() == BuildConsolePartition.CONSOLE_PARTITION_TYPE) { - isError = "C"; //$NON-NLS-1$ + String isError = "U"; + String type = p.getType(); + if (type == BuildConsolePartition.ERROR_PARTITION_TYPE) { + isError = "E"; + } else if (type == BuildConsolePartition.WARNING_PARTITION_TYPE) { + isError = "W"; + } else if (type == BuildConsolePartition.INFO_PARTITION_TYPE) { + isError = "I"; + } else if (type == BuildConsolePartition.CONSOLE_PARTITION_TYPE) { + isError = "C"; } try { text = fDocument.get(p.getOffset(), p.getLength()); } catch (BadLocationException e) { - text = "N/A"; //$NON-NLS-1$ + text = "N/A"; } - if (text.endsWith("\n")) { //$NON-NLS-1$ + if (text.endsWith("\n")) { text = text.substring(0, text.length() - 1); } - System.out.println(" " + isError + " " + start + "-" + end + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - ":[" + text + "]"); //$NON-NLS-1$ //$NON-NLS-2$ + System.out.println(" " + isError + " " + start + "-" + end + ":[" + text + "]"); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java index 8e247cdaed9..014b5dc6423 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/BuildConsoleViewer.java @@ -258,8 +258,15 @@ public class BuildConsoleViewer extends TextViewer BuildConsolePartition partition = (BuildConsolePartition) partitioner.getPartition(event.lineOffset); // Set background for error partitions - if ( partition != null && partition.getType() == BuildConsolePartition.ERROR_PARTITION_TYPE ) { - event.lineBackground = partitioner.fManager.getProblemBackgroundColor(); + if (partition!=null) { + String type = partition.getType(); + if (type==BuildConsolePartition.ERROR_PARTITION_TYPE) { + event.lineBackground = partitioner.fManager.getProblemBackgroundColor(); + } else if (type==BuildConsolePartition.WARNING_PARTITION_TYPE) { + event.lineBackground = partitioner.fManager.getWarningBackgroundColor(); + } else if (type==BuildConsolePartition.INFO_PARTITION_TYPE) { + event.lineBackground = partitioner.fManager.getInfoBackgroundColor(); + } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java index 6f46c9a2c16..58199766698 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/buildconsole/DocumentMarkerManager.java @@ -42,7 +42,8 @@ class DocumentMarkerManager { if ( i == fPartitioner.fPartitions.size() ) { i = 0; } - if ( fPartitioner.fPartitions.get(i).getType() == BuildConsolePartition.ERROR_PARTITION_TYPE ) { + String type = fPartitioner.fPartitions.get(i).getType(); + if (BuildConsolePartition.isProblemPartitionType(type)) { highlightedPartitionIndex = i; return; } else { @@ -64,7 +65,8 @@ class DocumentMarkerManager { if ( i == -1 ) { i = fPartitioner.fPartitions.size() - 1; } - if ( fPartitioner.fPartitions.get(i).getType() == BuildConsolePartition.ERROR_PARTITION_TYPE ) { + String type = fPartitioner.fPartitions.get(i).getType(); + if (BuildConsolePartition.isProblemPartitionType(type)) { highlightedPartitionIndex = i; return; } else { @@ -75,7 +77,8 @@ class DocumentMarkerManager { void moveToFirstError() { for (int i=0; i