Fixed: [Issue 116] Uneditable text boxes should be gray.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
index 74576fd..bf50a71 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/CompilerPreferencePage.java
@@ -14,6 +14,7 @@
import static com.google.eclipse.protobuf.ui.preferences.pages.compiler.BindingToCodeGeneration.bindCodeGeneration;
import static com.google.eclipse.protobuf.ui.preferences.pages.compiler.EnableProjectSettingsPreference.enableProjectSettings;
import static com.google.eclipse.protobuf.ui.preferences.pages.compiler.Messages.*;
+import static com.google.eclipse.protobuf.ui.swt.Colors.widgetBackground;
import static java.util.Arrays.asList;
import static org.eclipse.xtext.util.Strings.isEmpty;
@@ -92,24 +93,26 @@
btnUseProtocInCustomPath.setText(protocInCustomPath);
txtProtocFilePath = new Text(grpCompilerLocation, SWT.BORDER);
+ txtProtocFilePath.setBackground(widgetBackground());
txtProtocFilePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtProtocFilePath.setEditable(false);
btnProtocPathBrowse = new Button(grpCompilerLocation, SWT.NONE);
btnProtocPathBrowse.setText(browseCustomPath);
-
+
grpDescriptorLocation = new Group(cmpMain, SWT.NONE);
grpDescriptorLocation.setText(descriptorLocation);
grpDescriptorLocation.setLayout(new GridLayout(2, false));
grpDescriptorLocation.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
-
+
txtDescriptorFilePath = new Text(grpDescriptorLocation, SWT.BORDER);
+ txtDescriptorFilePath.setBackground(widgetBackground());
txtDescriptorFilePath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtDescriptorFilePath.setEditable(false);
-
+
btnDescriptorPathBrowse = new Button(grpDescriptorLocation, SWT.NONE);
btnDescriptorPathBrowse.setText(browseCustomPath);
-
+
grpCodeGeneration = new Group(cmpMain, SWT.NONE);
grpCodeGeneration.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
grpCodeGeneration.setText(codeGeneration);
@@ -220,7 +223,7 @@
}
pageIsNowValid();
}
-
+
private boolean isFileWithName(String filePath, String expectedFileName) {
File file = new File(filePath);
if (!file.isFile()) return false;
@@ -288,12 +291,12 @@
btnUseProtocInCustomPath.setEnabled(isEnabled);
enableCompilerCustomPathOptions(customPathOptionSelectedAndEnabled());
}
-
+
private void enableCompilerCustomPathOptions(boolean isEnabled) {
txtProtocFilePath.setEnabled(isEnabled);
btnProtocPathBrowse.setEnabled(isEnabled);
}
-
+
private void enableDescriptorPathOptions(boolean isEnabled) {
grpDescriptorLocation.setEnabled(isEnabled);
txtDescriptorFilePath.setEnabled(isEnabled);
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
index 26c3b60..b76af82 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/compiler/EditCodeGenerationDialog.java
@@ -9,6 +9,7 @@
package com.google.eclipse.protobuf.ui.preferences.pages.compiler;
import static com.google.eclipse.protobuf.ui.preferences.pages.compiler.Messages.*;
+import static com.google.eclipse.protobuf.ui.swt.Colors.widgetBackground;
import static com.google.eclipse.protobuf.ui.util.Paths.segmentsOf;
import static org.eclipse.core.resources.IResource.FOLDER;
import static org.eclipse.jface.dialogs.IDialogConstants.OK_ID;
@@ -71,7 +72,7 @@
GridData gridData = new GridData(GRAB_HORIZONTAL | HORIZONTAL_ALIGN_FILL);
gridData.horizontalSpan = 2;
txtError.setLayoutData(gridData);
- txtError.setBackground(txtError.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
+ txtError.setBackground(widgetBackground());
addEventListeners();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/numerictag/AddOrEditPatternDialog.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/numerictag/AddOrEditPatternDialog.java
index 330cafe..2dcfafd 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/numerictag/AddOrEditPatternDialog.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/editor/numerictag/AddOrEditPatternDialog.java
@@ -9,6 +9,7 @@
package com.google.eclipse.protobuf.ui.preferences.pages.editor.numerictag;
import static com.google.eclipse.protobuf.ui.preferences.pages.editor.numerictag.Messages.*;
+import static com.google.eclipse.protobuf.ui.swt.Colors.widgetBackground;
import static java.util.regex.Pattern.CASE_INSENSITIVE;
import static org.eclipse.jface.dialogs.IDialogConstants.OK_ID;
import static org.eclipse.swt.layout.GridData.*;
@@ -18,7 +19,6 @@
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.*;
@@ -69,8 +69,7 @@
txtPatternError = new Text(cmpDialogArea, SWT.READ_ONLY | SWT.WRAP);
txtPatternError.setLayoutData(new GridData(GRAB_HORIZONTAL | HORIZONTAL_ALIGN_FILL));
- Color readOnlyColor = txtPatternError.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- txtPatternError.setBackground(readOnlyColor);
+ txtPatternError.setBackground(widgetBackground());
Label lblSeparator = new Label(cmpDialogArea, SWT.SEPARATOR | SWT.HORIZONTAL);
lblSeparator.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
@@ -86,7 +85,7 @@
GridData gd_txtTestError = new GridData(GRAB_HORIZONTAL | HORIZONTAL_ALIGN_FILL);
gd_txtTestError.verticalAlignment = SWT.FILL;
txtTestError.setLayoutData(gd_txtTestError);
- txtTestError.setBackground(readOnlyColor);
+ txtTestError.setBackground(widgetBackground());
addEventListeners();
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java
index 934e0b7..61beda5 100644
--- a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/preferences/pages/paths/AddDirectoryDialog.java
@@ -11,19 +11,19 @@
import static com.google.eclipse.protobuf.ui.preferences.pages.paths.DirectorySelectionDialogs.*;
import static com.google.eclipse.protobuf.ui.preferences.pages.paths.Messages.*;
import static com.google.eclipse.protobuf.ui.preferences.pages.paths.ProjectVariable.useProjectVariable;
+import static com.google.eclipse.protobuf.ui.swt.Colors.widgetBackground;
import static org.eclipse.jface.dialogs.IDialogConstants.OK_ID;
import static org.eclipse.xtext.util.Strings.isEmpty;
-import com.google.eclipse.protobuf.ui.preferences.InputDialog;
-
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.IPath;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.widgets.*;
+import com.google.eclipse.protobuf.ui.preferences.InputDialog;
+
/**
* Dialog where users can select a path (in the workspace or file system) to be included in resolution of imports.
*
@@ -62,7 +62,7 @@
label.setText(directory);
txtPath = new Text(cmpDialogArea, SWT.BORDER);
- txtPath.setBackground(getColor(SWT.COLOR_WIDGET_BACKGROUND));
+ txtPath.setBackground(widgetBackground());
txtPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 2, 1));
txtPath.setEditable(false);
@@ -141,10 +141,6 @@
return txtPath.getText().trim();
}
- private static Color getColor(int systemColorID) {
- return Display.getCurrent().getSystemColor(systemColorID);
- }
-
/**
* Returns the path selected by the user.
* @return the path selected by the user.
diff --git a/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/swt/Colors.java b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/swt/Colors.java
new file mode 100644
index 0000000..48caa23
--- /dev/null
+++ b/com.google.eclipse.protobuf.ui/src/com/google/eclipse/protobuf/ui/swt/Colors.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2011 Google Inc.
+ *
+ * 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
+ *
+ * http://www.eclipse.org/legal/epl-v10.html
+ */
+package com.google.eclipse.protobuf.ui.swt;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Utility methods related to colors.
+ *
+ * @author alruiz@google.com (Alex Ruiz)
+ */
+public final class Colors {
+
+ public static Color widgetBackground() {
+ return getColor(SWT.COLOR_WIDGET_BACKGROUND);
+ }
+
+ public static Color getColor(int systemColorID) {
+ return Display.getCurrent().getSystemColor(systemColorID);
+ }
+
+ private Colors() {}
+}