From 1927cf14dac0893919530cdae9350f23d573cfc5 Mon Sep 17 00:00:00 2001 From: Leo Treggiari Date: Thu, 12 May 2005 22:55:55 +0000 Subject: [PATCH] Apply patch for PR 63973 Support of browseType for String options --- .../properties/BuildOptionSettingsPage.java | 43 ++++++++++++++++--- .../ui/properties/BuildSettingsPage.java | 22 +++++++--- 2 files changed, 54 insertions(+), 11 deletions(-) diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java index 3d5f40eb75f..831540185fe 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildOptionSettingsPage.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2003,2004 IBM Corporation and others. + * Copyright (c) 2003, 2005 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v0.5 * which accompanies this distribution, and is available at @@ -25,7 +25,10 @@ import org.eclipse.cdt.managedbuilder.core.ManagedBuildManager; import org.eclipse.jface.preference.BooleanFieldEditor; import org.eclipse.jface.preference.FieldEditor; import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FileFieldEditor; import org.eclipse.swt.graphics.Point; +import java.lang.AssertionError; public class BuildOptionSettingsPage extends BuildSettingsPage { private Map fieldsMap = new HashMap(); @@ -77,11 +80,39 @@ public class BuildOptionSettingsPage extends BuildSettingsPage { // editor for it switch (opt.getValueType()) { case IOption.STRING : - StringFieldEditor stringField = new StringFieldEditor( - opt.getId(), opt.getName(), getFieldEditorParent()); - addField(stringField); - fieldsMap.put(opt.getId(), stringField); - break; + // fix for PR 63973 + // Check browse type. + // If browsing is set, use a field editor that has a browse button of + // the appropriate type. + // Otherwise, use a regular text field. + switch(opt.getBrowseType()) + { + case IOption.BROWSE_DIR : + DirectoryFieldEditor dirFieldEditor = new DirectoryFieldEditor( + opt.getId(), opt.getName(), getFieldEditorParent()); + addField(dirFieldEditor); + fieldsMap.put(opt.getId(), dirFieldEditor); + break; + + case IOption.BROWSE_FILE: + FileFieldEditor fileFieldEditor = new FileFieldEditor( + opt.getId(), opt.getName(), getFieldEditorParent()); + addField(fileFieldEditor); + fieldsMap.put(opt.getId(), fileFieldEditor); + break; + + case IOption.BROWSE_NONE: + StringFieldEditor stringField = new StringFieldEditor( + opt.getId(), opt.getName(), getFieldEditorParent()); + addField(stringField); + fieldsMap.put(opt.getId(), stringField); + break; + + default: + // should not be possible + throw( new AssertionError()); } + // end fix for 63973 + break; case IOption.BOOLEAN : BooleanFieldEditor booleanField = new BooleanFieldEditor( opt.getId(), opt.getName(), getFieldEditorParent()); diff --git a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java index c9aa6233f0a..40001fc0c76 100644 --- a/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java +++ b/build/org.eclipse.cdt.managedbuilder.ui/src/org/eclipse/cdt/managedbuilder/ui/properties/BuildSettingsPage.java @@ -1,5 +1,5 @@ /********************************************************************** - * Copyright (c) 2004 IBM Rational Software Corporation and others. + * Copyright (c) 2004, 2005 IBM Rational Software Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Common Public License v0.5 * which accompanies this distribution, and is available at @@ -27,15 +27,27 @@ public abstract class BuildSettingsPage extends FieldEditorPreferencePage { * @param style */ protected BuildSettingsPage(IConfiguration config) { - // Must be a grid layout and we don't want another set of buttons - super(GRID); + // fix for PR 63973 + // If we use a grid layout then widgets that should be layed out horizontally, + // e.g. StringButtonFieldEditor, will have their component widgets + // arranged vertically. This looks terrible when you have for instance + // a StringButtonFieldEditor, which has a label, an edit box, and a "modify" button + // to the right because all three will be stacked vertically. + super(FLAT); + // end fix for 63973 noDefaultAndApplyButton(); configuration = config; } protected BuildSettingsPage(IResourceConfiguration resConfig) { - // Must be a grid layout and we don't want another set of buttons - super(GRID); + // fix for PR 63973 + // If we use a grid layout then widgets that should be layed out horizontally, + // e.g. StringButtonFieldEditor, will have their component widgets + // arranged vertically. This looks terrible when you have for instance + // a StringButtonFieldEditor, which has a label, an edit box, and a "modify" button + // to the right because all three will be stacked vertically. + super(FLAT); + // end fix for 63973 noDefaultAndApplyButton(); this.resConfig = resConfig; }