diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/LabelFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/LabelFieldEditor.java deleted file mode 100644 index dbe23b4b384..00000000000 --- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/LabelFieldEditor.java +++ /dev/null @@ -1,24 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008 QNX Software Systems 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 - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * QNX Software Systems - Initial API and implementation - *******************************************************************************/ -package org.eclipse.cdt.debug.ui.preferences; - -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Text; - -public class LabelFieldEditor extends StringFieldEditor{ - public LabelFieldEditor(String name, String labelText, Composite parent) { - super(name, labelText, parent); - Text textControl = getTextControl(); - textControl.setEditable(false); - textControl.setBackground(parent.getBackground()); - } -} diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java new file mode 100644 index 00000000000..d0e104b3c6b --- /dev/null +++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/ui/preferences/ReadOnlyFieldEditor.java @@ -0,0 +1,181 @@ +/******************************************************************************* + * Copyright (c) 2008 QNX Software Systems 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 + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * QNX Software Systems - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.debug.ui.preferences; + +import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContribution; +import org.eclipse.cdt.debug.ui.breakpoints.ICBreakpointsUIContributionUser; +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +public class ReadOnlyFieldEditor extends FieldEditor implements ICBreakpointsUIContributionUser { + protected Label textField; + protected ICBreakpointsUIContribution contribution; + + public ReadOnlyFieldEditor(String name, String labelText, Composite parent) { + init(name, labelText); + createControl(parent); + } + + /* (non-Javadoc) + * Method declared on FieldEditor. + */ + protected void adjustForNumColumns(int numColumns) { + GridData gd = (GridData) textField.getLayoutData(); + gd.horizontalSpan = numColumns - 1; + // We only grab excess space if we have to + // If another field editor has more columns then + // we assume it is setting the width. + gd.grabExcessHorizontalSpace = gd.horizontalSpan == 1; + } + + /** + * Fills this field editor's basic controls into the given parent. + *
+ * The string field implementation of this FieldEditor
+ * framework method contributes the text field. Subclasses may override
+ * but must call super.doFillIntoGrid
.
+ *
null
if no
+ * text field is created yet
+ */
+ protected Label getTextControl() {
+ return textField;
+ }
+
+ /**
+ * Returns this field editor's text control.
+ * + * The control is created if it does not yet exist + *
+ * + * @param parent the parent + * @return the text control + */ + public Label getTextControl(Composite parent) { + if (textField == null) { + textField = new Label(parent, SWT.WRAP); + textField.setFont(parent.getFont()); + textField.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + textField = null; + } + }); + } else { + checkParent(textField, parent); + } + return textField; + } + + /* (non-Javadoc) + * Method declared on FieldEditor. + */ + public boolean isValid() { + return true; + } + + /* (non-Javadoc) + * Method declared on FieldEditor. + */ + public void setFocus() { + if (textField != null) { + textField.setFocus(); + } + } + + /* + * @see FieldEditor.setEnabled(boolean,Composite). + */ + public void setEnabled(boolean enabled, Composite parent) { + super.setEnabled(enabled, parent); + getTextControl(parent).setEnabled(enabled); + } + + + @Override + protected void doStore() { + // nothing + } + + public ICBreakpointsUIContribution getContribution() { + return contribution; + } + + public void setContribution(ICBreakpointsUIContribution contribution) { + this.contribution = contribution; + } +}