From f3bb6aa2dd8bc3dd1e4bb49f28c45783041fff6d Mon Sep 17 00:00:00 2001 From: Alena Laskavaia Date: Sun, 27 Feb 2011 01:58:43 +0000 Subject: [PATCH] added label to build prefs that they can be overriden by checker --- .../ui/preferences/BuildPropertyPage.java | 3 + .../cdt/codan/ui/LabelFieldEditor.java | 107 ++++++++++++++++++ 2 files changed, 110 insertions(+) create mode 100644 codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java index e11cfb89b0f..473222f9870 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java @@ -14,6 +14,7 @@ import org.eclipse.cdt.codan.core.PreferenceConstants; import org.eclipse.cdt.codan.internal.ui.CodanUIActivator; import org.eclipse.cdt.codan.internal.ui.CodanUIMessages; import org.eclipse.cdt.codan.internal.ui.actions.ToggleNatureAction; +import org.eclipse.cdt.codan.ui.LabelFieldEditor; import org.eclipse.core.resources.IProject; import org.eclipse.core.runtime.IAdaptable; import org.eclipse.jface.preference.BooleanFieldEditor; @@ -40,6 +41,8 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements IWor */ @Override protected void createFieldEditors() { + addField(new LabelFieldEditor("Set launch method for checkers, you can override this by editing individual problem settings", + getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_ON_BUILD, CodanUIMessages.BuildPropertyPage_RunWithBuild, getFieldEditorParent())); addField(new BooleanFieldEditor(PreferenceConstants.P_RUN_IN_EDITOR, CodanUIMessages.BuildPropertyPage_RunAsYouType, diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java new file mode 100644 index 00000000000..426a4a73170 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/LabelFieldEditor.java @@ -0,0 +1,107 @@ +/** ==================================================================== + * Copyright 2003-2004 Fabrizio Giustina. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ==================================================================== + */ +package org.eclipse.cdt.codan.ui; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +/*** + * A field editor for displaying labels not associated with other widgets. + * + * @author fgiust + * @version $Revision: 1.3 $ ($Author: fgiust $) + * @since 1.1 + */ +public class LabelFieldEditor extends FieldEditor { + /*** + * Label for this field editor. + */ + private Label label; + + /*** + * All labels can use the same preference name since they don't store any + * preference. + * + * @param labelText text for the label + * @param parent Composite + */ + public LabelFieldEditor(String labelText, Composite parent) { + super("label", labelText, parent); //$NON-NLS-1$ + } + + /*** + * Adjusts the field editor to be displayed correctly for the given number + * of columns. + * + * @param numColumns number of columns + */ + @Override + protected void adjustForNumColumns(int numColumns) { + ((GridData) this.label.getLayoutData()).horizontalSpan = numColumns; + } + + /*** + * Fills the field editor's controls into the given parent. + * + * @param parent Composite + * @param numColumns cumber of columns + */ + @Override + protected void doFillIntoGrid(Composite parent, int numColumns) { + this.label = getLabelControl(parent); + GridData gridData = new GridData(); + gridData.horizontalSpan = numColumns; + gridData.horizontalAlignment = GridData.FILL; + gridData.grabExcessHorizontalSpace = false; + gridData.verticalAlignment = GridData.CENTER; + gridData.grabExcessVerticalSpace = false; + this.label.setLayoutData(gridData); + } + + /*** + * Returns the number of controls in the field editor. + * + * @return 1 + */ + @Override + public int getNumberOfControls() { + return 1; + } + + /*** + * Labels do not persist any preferences, so this method is empty. + */ + @Override + protected void doLoad() { + } + + /*** + * Labels do not persist any preferences, so this method is empty. + */ + @Override + protected void doLoadDefault() { + } + + /*** + * Labels do not persist any preferences, so this method is empty. + */ + @Override + protected void doStore() { + } +}