Bug 389755 - Set SWT.COLOR_INFO_FOREGROUND
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java
index bb4f665..84aeb9f 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntClasspathLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* 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
@@ -99,14 +99,9 @@
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
public Color getBackground(Object element) {
- if (element instanceof GlobalClasspathEntries) {
- int type= ((GlobalClasspathEntries) element).getType();
- if (type == ClasspathModel.CONTRIBUTED) {
- Display display= Display.getCurrent();
- return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
- }
- } else if (element instanceof ClasspathEntry) {
- return getBackground(((ClasspathEntry) element).getParent());
+ if (isUnmodifiable(element)) {
+ Display display= Display.getCurrent();
+ return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
}
return null;
}
@@ -115,9 +110,25 @@
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
public Color getForeground(Object element) {
+ if (isUnmodifiable(element)) {
+ Display display= Display.getCurrent();
+ return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ }
return null;
}
+ private boolean isUnmodifiable(Object element) {
+ if (element instanceof GlobalClasspathEntries) {
+ int type= ((GlobalClasspathEntries) element).getType();
+ if (type == ClasspathModel.CONTRIBUTED) {
+ return true;
+ }
+ } else if (element instanceof ClasspathEntry) {
+ return isUnmodifiable(((ClasspathEntry) element).getParent());
+ }
+ return false;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(org.eclipse.jface.viewers.ILabelProviderListener)
*/
diff --git a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntObjectLabelProvider.java b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntObjectLabelProvider.java
index 5d7c070..6e3b49c 100644
--- a/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntObjectLabelProvider.java
+++ b/ant/org.eclipse.ant.ui/Ant Tools Support/org/eclipse/ant/internal/ui/preferences/AntObjectLabelProvider.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2011 IBM Corporation and others.
+ * Copyright (c) 2000, 2012 IBM Corporation and others.
* 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
@@ -118,6 +118,10 @@
* @see org.eclipse.jface.viewers.IColorProvider#getForeground(java.lang.Object)
*/
public Color getForeground(Object element) {
+ if (isUnmodifiable(element)) {
+ Display display= Display.getCurrent();
+ return display.getSystemColor(SWT.COLOR_INFO_FOREGROUND);
+ }
return null;
}
@@ -125,17 +129,23 @@
* @see org.eclipse.jface.viewers.IColorProvider#getBackground(java.lang.Object)
*/
public Color getBackground(Object element) {
+ if (isUnmodifiable(element)) {
+ Display display= Display.getCurrent();
+ return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ }
+ return null;
+ }
+
+ private boolean isUnmodifiable(Object element) {
if (element instanceof AntObject) {
if (((AntObject) element).isDefault()) {
- Display display= Display.getCurrent();
- return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ return true;
}
} else if (element instanceof Property) {
if (((Property) element).isDefault()) {
- Display display= Display.getCurrent();
- return display.getSystemColor(SWT.COLOR_INFO_BACKGROUND);
+ return true;
}
}
- return null;
+ return false;
}
}
\ No newline at end of file