Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Managed Builder UI Patch

Hi All,
This patch contains a fix for bug 41274 in the core; library entries in 
the build property pages were not being saved by the build model manager.

It also contains a bunch of fixes for minor problems in the UI. I added a 
new target for building DLLs on Cygwin. The zip file adds a new icon for 
configurations in the tree view of the build property page for managed 
builds. Now the tool uses the tool icon and the category uses the new 
category icon.

The list editor will better fit a page with space-grabbing widgets in 
different columns. For example, the default list field editor puts the 
list in the left column and allows it to grab all excess space. Entry 
fields put the label in the left and the space-grabbing entry field/combo 
box in the right. The layout manager then gives both left and right 
columns equal space in that case. By wrapping the list field editor in a 
group control that spans both columns, the layout manager allocates enough 
space for controls in the right-hand column. It also lays out the contents 
of the list field editor inside the group control independently of the 
outer container, so it looks right too. Also added a double-click event 
handler so users  can edit list elements. All in all, this makes the list 
widget work better.

I re-activated the summary field editor class (it's alive!). It still does 
not behave quite right in terms of showing the command line summary, but 
that functionality will be added shortly.

Finally, the build property page is being resized for large pages. It is 
still possible to specify categories with too many options to display, 
even with the new resize. This will have to be a documented limitation, or 
we will have to add a vertical scroll bar for pages that are too large.

Sean Evoy
Rational Software - IBM Software Group
Ottawa, Ontario, Canada

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.120
diff -u -r1.120 ChangeLog
--- ChangeLog	31 Jul 2003 13:20:37 -0000	1.120
+++ ChangeLog	11 Aug 2003 15:09:10 -0000
@@ -1,3 +1,8 @@
+2003-08-10 Sean Evoy
+	Fix for Bug 41274. Was not saving the library option properly because the value type 
+	of the option was not recognized.
+	* build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
+
 2003-07-30 Hoda Amer
 	The C Model recognizes pointers to functions.
 
Index: build/org/eclipse/cdt/internal/core/build/managed/Configuration.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/build/org/eclipse/cdt/internal/core/build/managed/Configuration.java,v
retrieving revision 1.12
diff -u -r1.12 Configuration.java
--- build/org/eclipse/cdt/internal/core/build/managed/Configuration.java	31 Jul 2003 13:20:37 -0000	1.12
+++ build/org/eclipse/cdt/internal/core/build/managed/Configuration.java	11 Aug 2003 15:09:10 -0000
@@ -283,6 +283,9 @@
 			case IOption.PREPROCESSOR_SYMBOLS :
 				oldValue = option.getDefinedSymbols();
 				break;
+			case IOption.LIBRARIES :
+				oldValue = option.getLibraries();
+				break;
 			default :
 				oldValue = new String[0];
 				break;
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.135
diff -u -r1.135 ChangeLog
--- ChangeLog	11 Aug 2003 13:48:39 -0000	1.135
+++ ChangeLog	11 Aug 2003 15:41:10 -0000
@@ -1,3 +1,47 @@
+2003-08-10 Sean Evoy
+	Added a new target for building DLLs on Cygwin.
+	* plugin.xml
+	
+	Added a new icon for configurations in the tree view of the build 
+	property page for managed builds.
+	* icons/full/build16/config-category.gif
+	* src/org/eclipse/cdt/internal/ui/CPluginImages.java
+	
+	Changed the icons used to display tools and categories in the tree view 
+	of the managed build property page. Now the tool uses the tool icon and 
+	the category uses the new category icon.
+	* build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java
+	
+	Changed the list field editor so that it will better fit a page with 
+	space-grabbing widgets in different columns. For example, the default list
+	field editor puts the list in the left column and allows it to garab all 
+	excess space. Entry fields put the label in the left and the space-grabbing 
+	entry field/combo box in the right. The layout manager then gives both left 
+	and right columns equal space. By wrapping the list field editor in a group 
+	control that spans both columns, the layout manager allocates enough space for 
+	controls in the right-hand column. It also lays out the contents of the list 
+	field editor inside the group control independently of the outer container, so 
+	it looks right too. Also added a double-click event handler so users can edit
+	list elements. Mondo happy with this!
+	* build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java
+
+	Re-activated the summary field editor class. It still does not behave quite right, 
+	but it is there.
+	* build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java
+	* build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
+	
+	Changed the combo-box field editor to lay itself out in the grid more like the other
+	field editors. This has not made the widget behave differently in any way, but should
+	insure that it lay itself out correctly on any page with any combination of
+	field editors.
+	* build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java
+
+	Fixed the resize behaviour of the build property page; at least in terms of resizing up 
+	to its constrained size. There is the issue of size-creep (each time you reselect the 
+	category, the property page control resizes up a bit until it hits some limit). But,
+	this is a better situation than what was there before.
+	* build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java
+
 2003-08-08 Bogdan Gheorghe
 	- Filled out CSearchScopeFactory to translate working sets
 	  into CElements
Index: plugin.xml
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/plugin.xml,v
retrieving revision 1.38
diff -u -r1.38 plugin.xml
--- plugin.xml	31 Jul 2003 13:20:21 -0000	1.38
+++ plugin.xml	11 Aug 2003 15:41:10 -0000
@@ -26,9 +26,9 @@
    <extension-point id="CCompletionContributor" name="%completionContributorName"/>
    <extension-point id="CElementFilters" name="%elementFiltersName"/>
 <!-- =========================================================================== -->
-<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover  -->
-<!-- Purpose: Provide a perspective specific text hovering for CEditor files     -->
 <!-- Extension point: org.eclipse.cdt.ui.textHovers                        -->
+<!-- Purpose: Provide a perspective specific text hovering for CEditor files     -->
+<!-- Extension Implementation: must implement org.eclipse.jface.text.ITextHover  -->
 <!-- =========================================================================== -->
    <extension-point id="textHovers" name="%textHoversName"/>
    <extension-point id="CToolTabGroup" name="C/C++ Tool Configuration Tabs" schema="schema/CToolTabGroup.exsd"/>
@@ -137,8 +137,8 @@
             id="org.eclipse.cdt.ui.MakeView">
       </view>
    </extension>
-<!-- The wizards -->
 <!-- For C Wizards -->
+<!-- The wizards -->
    <extension
          point="org.eclipse.ui.newWizards">
       <category
@@ -808,10 +808,10 @@
          </tool>
       </target>
       <target
-            isTest="true"
+            isTest="false"
             name="Cygwin Shared Library"
             parent="cygwin"
-            defaultExtension="dll.a"
+            defaultExtension="dll"
             isAbstract="false"
             id="cygwin.so">
          <configuration
@@ -825,7 +825,8 @@
          <tool
                name="%ToolName.linker"
                outputFlag="-o"
-               outputs="dll.a"
+               command="g++ -shared"
+               outputs="dll"
                id="org.eclipse.cdt.build.tool.cygwin.solink">
             <optionCategory
                   owner="org.eclipse.cdt.build.tool.cygwin.solink"
@@ -833,7 +834,7 @@
                   id="cygwin.solink.category.general">
             </optionCategory>
             <option
-                  defaultValue="-shared"
+                  defaultValue=""
                   name="Linker Flags"
                   category="cygwin.solink.category.general"
                   valueType="string"
@@ -852,6 +853,56 @@
                   command="-l"
                   valueType="libs"
                   id="cygwin.solink.libs">
+            </option>
+         </tool>
+      </target>
+      <target
+            isTest="true"
+            name="Cygwin Export Library (DLL)"
+            parent="cygwin"
+            defaultExtension="dll.a"
+            isAbstract="false"
+            id="cygwin.exp">
+         <configuration
+               name="Release"
+               id="cygwin.exp.release">
+         </configuration>
+         <configuration
+               name="Debug"
+               id="cygwin.exp.debug">
+         </configuration>
+         <tool
+               name="%ToolName.linker"
+               outputFlag="-o"
+               outputPrefix="cyg"
+               command="g++ -shared"
+               outputs="dll"
+               id="org.eclipse.cdt.build.tool.cygwin.explink">
+            <optionCategory
+                  owner="org.eclipse.cdt.build.tool.cygwin.explink"
+                  name="General"
+                  id="cygwin.explink.category.general">
+            </optionCategory>
+            <option
+                  defaultValue="-Wl,--export-all-symbols -Wl,--enable-auto-import"
+                  name="Linker Flags"
+                  category="cygwin.explink.category.general"
+                  valueType="string"
+                  id="cygwin.explink.ld.flags">
+            </option>
+            <option
+                  name="Library Paths"
+                  category="cygwin.explink.category.general"
+                  command="-L"
+                  valueType="stringList"
+                  id="cygwin.explink.ld.paths">
+            </option>
+            <option
+                  name="Libraries"
+                  category="cygwin.explink.category.general"
+                  command="-l"
+                  valueType="libs"
+                  id="cygwin.explink.libs">
             </option>
          </tool>
       </target>
Index: build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java,v
retrieving revision 1.1
diff -u -r1.1 BuildOptionComboFieldEditor.java
--- build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java	9 Jun 2003 19:22:19 -0000	1.1
+++ build/org/eclipse/cdt/ui/build/properties/BuildOptionComboFieldEditor.java	11 Aug 2003 15:41:10 -0000
@@ -16,6 +16,7 @@
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Combo;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
 
 public class BuildOptionComboFieldEditor extends FieldEditor {
 
@@ -23,7 +24,7 @@
 	private Combo optionSelector;
 	private String [] options = new String[0];
 	private String selected; 
-
+	
 	/**
 	 * @param name
 	 * @param label
@@ -52,13 +53,23 @@
 	 * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
 	 */
 	protected void doFillIntoGrid(Composite parent, int numColumns) {
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = numColumns;
+		parent.setLayoutData(gd);
+		
 		// Add the label
-		getLabelControl(parent);
+		Label label = getLabelControl(parent);
+		GridData labelData = new GridData();
+		labelData.horizontalSpan = 1;
+		labelData.grabExcessHorizontalSpace = false;
+		label.setLayoutData(labelData);
 		
 		// Now add the combo selector
 		optionSelector = ControlFactory.createSelectCombo(parent, options, selected);
-		GridData gd = (GridData) optionSelector.getLayoutData();
-		gd.horizontalSpan = numColumns - 1;
+		GridData selectorData = (GridData) optionSelector.getLayoutData();
+		selectorData.horizontalSpan = numColumns - 1;
+		selectorData.grabExcessHorizontalSpace = true;
+		optionSelector.setLayoutData(selectorData);
 	}
 
 	/* (non-Javadoc)
Index: build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java,v
retrieving revision 1.2
diff -u -r1.2 BuildOptionListFieldEditor.java
--- build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java	26 Jun 2003 17:43:36 -0000	1.2
+++ build/org/eclipse/cdt/ui/build/properties/BuildOptionListFieldEditor.java	11 Aug 2003 15:41:10 -0000
@@ -12,37 +12,304 @@
  * **********************************************************************/
 
 import org.eclipse.cdt.ui.CUIPlugin;
+import org.eclipse.cdt.utils.ui.controls.ControlFactory;
+import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.preference.ListEditor;
+import org.eclipse.jface.preference.FieldEditor;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.MouseAdapter;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Widget;
 
-public class BuildOptionListFieldEditor extends ListEditor {
+public class BuildOptionListFieldEditor extends FieldEditor {
+	// Label constants
 	private static final String TITLE = "BuildPropertyCommon.label.title";	//$NON-NLS-1$
+	private static final String NEW = "BuildPropertyCommon.label.new"; //$NON-NLS-1$
+	private static final String REMOVE = "BuildPropertyCommon.label.remove"; //$NON-NLS-1$
+	private static final String UP = "BuildPropertyCommon.label.up"; //$NON-NLS-1$
+	private static final String DOWN = "BuildPropertyCommon.label.down"; //$NON-NLS-1$
 
-	private boolean browse;
+	// UI constants
+	private static final int VERTICAL_DIALOG_UNITS_PER_CHAR = 8;
+	private static final int HORIZONTAL_DIALOG_UNITS_PER_CHAR = 4;
+	private static final int LIST_HEIGHT_IN_CHARS = 10;
+	private static final int LIST_HEIGHT_IN_DLUS = 
+		LIST_HEIGHT_IN_CHARS * VERTICAL_DIALOG_UNITS_PER_CHAR;
+
+	// The top-level control for the field editor.
+	private Composite top;
+	// The list of tags.
+	private List list;
+
+	// The group control for the list and button composite
+	private Group controlGroup;
+	
 	private String fieldName;
-		
+	private SelectionListener selectionListener;
+
+	// The button for adding the contents of the text field to the list
+	private Button addButton;
+	// The button for removing the currently-selected list item.
+	private Button removeButton;
+	// The button for swapping the currently selected item up
+	private Button upButton;
+	// The button for swapping the currently-selected list item down
+	private Button downButton;
+
 	/**
- 	* @param name the name of the preference this field editor works on
- 	* @param labelText the label text of the field editor
- 	* @param parent the parent of the field editor's control
- 	*/
+	* @param name the name of the preference this field editor works on
+	* @param labelText the label text of the field editor
+	* @param parent the parent of the field editor's control
+	*/
 	public BuildOptionListFieldEditor (String name, String labelText, Composite parent) {
 		super(name, labelText, parent);
 		this.fieldName = labelText;
-		createControl(parent);
 	}
-	
+
 	/* (non-Javadoc)
-	 * @see org.eclipse.jface.preference.ListEditor#createList(java.lang.String[])
+	 * Event handler for the addButton widget
+	 */
+	protected void addPressed() {
+		setPresentsDefaultValue(false);
+		// Prompt user for a new item
+		String input = getNewInputObject();
+		
+		// Add it to the list
+		if (input != null) {
+			int index = list.getSelectionIndex();
+			if (index >= 0)
+				list.add(input, index + 1);
+			else
+				list.add(input, 0);
+			selectionChanged();
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
+	 */
+	protected void adjustForNumColumns(int numColumns) {
+		((GridData)top.getLayoutData()).horizontalSpan = numColumns;
+	}
+
+	/* (non-Javadoc)
+	 * Creates the Add, Remove, Up, and Down button in the button composite.
+	 *
+	 * @param container the box for the buttons
+	 */
+	private void createButtons(Composite container) {
+		addButton = createPushButton(container, CUIPlugin.getResourceString(NEW));
+		removeButton = createPushButton(container, CUIPlugin.getResourceString(REMOVE));
+		upButton = createPushButton(container, CUIPlugin.getResourceString(UP));
+		downButton = createPushButton(container, CUIPlugin.getResourceString(DOWN));
+	}
+
+	/**
+	 * @param items
+	 * @return
 	 */
 	protected String createList(String[] items) {
 		return BuildToolsSettingsStore.createList(items);
 	}
 
 	/* (non-Javadoc)
-	 * @see org.eclipse.jface.preference.ListEditor#getNewInputObject()
+	 * Rather than using the ControlFactory helper methods, this field
+	 * editor is using this helper method. Other field editors use a similar
+	 * set of method calls, so this seems like the safest approach 
+	 * 
+	 * @param parent the button composite
+	 * @param label the label to place in the button
+	 * @return
+	 */
+	private Button createPushButton(Composite parent, String label) {
+		Button button = new Button(parent, SWT.PUSH);
+		button.setText(label);
+		button.setFont(parent.getFont());
+		GridData data = new GridData(GridData.FILL_HORIZONTAL);
+		data.heightHint = convertVerticalDLUsToPixels(button, IDialogConstants.BUTTON_HEIGHT);
+		int widthHint = convertHorizontalDLUsToPixels(button, IDialogConstants.BUTTON_WIDTH);
+		data.widthHint = Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+		button.setLayoutData(data);
+		button.addSelectionListener(getSelectionListener());
+		return button;
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
+	 */
+	protected void doFillIntoGrid(Composite parent, int numColumns) {
+		top = parent;
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = numColumns;
+		top.setLayoutData(gd);
+
+		controlGroup = ControlFactory.createGroup(top, getLabelText(), 2);
+		GridData groupData = new GridData(GridData.FILL_HORIZONTAL);
+		groupData.horizontalSpan = numColumns;
+		controlGroup.setLayoutData(groupData);
+
+		// Make the list
+		list = new List(controlGroup, SWT.BORDER);
+	
+		// Create a grid data that takes up the extra space in the dialog and spans one column.
+		GridData listData = new GridData(GridData.FILL_HORIZONTAL);
+		listData.heightHint = 
+			convertVerticalDLUsToPixels(list, LIST_HEIGHT_IN_DLUS);
+		listData.horizontalSpan = 1;
+		
+		list.setLayoutData(listData);
+		list.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent e) {
+				selectionChanged();
+			}
+		});
+
+		list.addDisposeListener(new DisposeListener() {
+			public void widgetDisposed(DisposeEvent event) {
+				list = null;
+			}
+		});
+		list.addMouseListener(new MouseAdapter() {
+			public void mouseDoubleClick(MouseEvent e) {
+				// Popup the editor on the selected item from the list
+				editSelection();
+			}
+		});
+
+		// Create a composite for the buttons
+		Composite buttonGroup = new Composite(controlGroup, SWT.NONE);
+		GridData buttonData = new GridData();
+		buttonData.horizontalSpan = 1;
+		buttonData.verticalAlignment = GridData.BEGINNING;
+		buttonGroup.setLayoutData(buttonData);
+	
+		GridLayout buttonLayout = new GridLayout();
+		buttonLayout.numColumns = 1;
+		buttonLayout.marginHeight = 0;
+		buttonLayout.marginWidth = 0;
+		buttonGroup.setLayout(buttonLayout);
+		
+		buttonGroup.addDisposeListener(new DisposeListener() {
+			public void widgetDisposed(DisposeEvent event) {
+				addButton = null;
+				removeButton = null;
+				upButton = null;
+				downButton = null;
+			}
+		});
+	
+		// Create the buttons
+		createButtons(buttonGroup);
+	}
+
+	/* (non-Javadoc)
+	 * Creates a selection listener that handles the selection events
+	 * for the button controls and single-click events in the list to 
+	 * trigger a selection change.
+	 */
+	public void createSelectionListener() {
+		selectionListener = new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				Widget widget = event.widget;
+				if (widget == addButton) {
+					addPressed();
+				} else
+					if (widget == removeButton) {
+						removePressed();
+					} else
+						if (widget == upButton) {
+							upPressed();
+						} else
+							if (widget == downButton) {
+								downPressed();
+							} else
+								if (widget == list) {
+									selectionChanged();
+								}
+			}
+		};
+	}
+
+
+
+	/* (non-Javadoc)
+	 * Event handler for the down button
+	 */
+	protected void downPressed() {
+		swap(false);		
+	}
+
+	/* (non-Javadoc)
+	 * 
 	 */
+	protected void editSelection() {
+		// Edit the selection index
+		int index = list.getSelectionIndex();
+		if (index != -1) {
+			String selItem = list.getItem(index);
+			if (selItem != null) {
+				InputDialog dialog = new InputDialog(getShell(), CUIPlugin.getResourceString(TITLE), fieldName, selItem, null);
+				String newItem = null;
+				if (dialog.open() == InputDialog.OK) {
+					newItem = dialog.getValue();
+					if (newItem != null && !newItem.equals(selItem)) {
+						list.setItem(index, newItem);
+						selectionChanged();
+					}
+				}
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditor#doLoad()
+	 */
+	protected void doLoad() {
+		if (list != null) {
+			String s = getPreferenceStore().getString(getPreferenceName());
+			String[] array = parseString(s);
+			for (int i = 0; i < array.length; i++){
+				list.add(array[i]);
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
+	 */
+	protected void doLoadDefault() {
+		if (list != null) {
+			list.removeAll();
+			String s = getPreferenceStore().getDefaultString(getPreferenceName());
+			String[] array = parseString(s);
+			for (int i = 0; i < array.length; i++){
+				list.add(array[i]);
+			}
+		}
+	}
+
+	/* (non-Javadoc)
+	 * @see org.eclipse.jface.preference.FieldEditor#doStore()
+	 */
+	protected void doStore() {
+		String s = createList(list.getItems());
+		if (s != null)
+			getPreferenceStore().setValue(getPreferenceName(), s);
+	}
+
 	protected String getNewInputObject() {
 		// Create a dialog to prompt for a new symbol or path
 		InputDialog dialog = new InputDialog(getShell(), CUIPlugin.getResourceString(TITLE), fieldName, new String(), null);
@@ -54,9 +321,101 @@
 	}
 
 	/* (non-Javadoc)
-	 * @see org.eclipse.jface.preference.ListEditor#parseString(java.lang.String)
+	 * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
+	 */
+	public int getNumberOfControls() {
+		// The group control has a list and buttons so we want it to get at
+		// least 2 columns to display in.
+		return 2;
+	}
+
+	/* (non-Javadoc)
+	 * Returns this field editor's selection listener.
+	 * The listener is created if nessessary.
+	 *
+	 * @return the selection listener
+	 */
+	private SelectionListener getSelectionListener() {
+		if (selectionListener == null)
+			createSelectionListener();
+		return selectionListener;
+	}
+
+	/* (non-Javadoc)
+	 * Returns this field editor's shell.
+	 * 
+	 * @return the shell
+	 */
+	protected Shell getShell() {
+		if (addButton == null)
+			return null;
+		return addButton.getShell();
+	}
+
+	/* (non-Javadoc)
+	 * @param stringList
+	 * @return
 	 */
 	protected String[] parseString(String stringList) {
 		return BuildToolsSettingsStore.parseString(stringList);
+	}
+
+	/* (non-Javadoc)
+	 * Event handler for the removeButton selected event
+	 */
+	protected void removePressed() {
+		// Remove the selected item from the list
+		setPresentsDefaultValue(false);
+		int index = list.getSelectionIndex();
+		if (index >= 0) {
+			list.remove(index);
+			selectionChanged();
+		}
+	}
+
+	/* (non-Javadoc)
+	 * Clean up the list and button control states after the event 
+	 * handlers fire. 
+	 */
+	protected void selectionChanged() {
+		int index = list.getSelectionIndex();
+		int size = list.getItemCount();
+
+		// Enable the remove button if there is at least one item in the list
+		removeButton.setEnabled(index >= 0);
+		// Enable the up button IFF there is more than 1 item and selection index is not first item
+		upButton.setEnabled(size > 1 && index > 0);
+		// Enable the down button IFF there is more than 1 item and selection index not last item
+		downButton.setEnabled(size > 1 && index >= 0 && index < size - 1);
+	}
+
+	/* (non-Javadoc)
+	 * Swaps the location of two list elements. If the argument is <code>true</code> 
+	 * the list item is swapped with the item preceeding it in the list. Otherwise 
+	 *  it is swapped with the item following it.
+	 * 
+	 * @param moveUp
+	 */
+	private void swap(boolean moveUp) {
+		setPresentsDefaultValue(false);
+		int index = list.getSelectionIndex();
+		int target = moveUp ? index - 1 : index + 1;
+
+		if (index >= 0) {
+			String[] selection = list.getSelection();
+			Assert.isTrue(selection.length == 1);
+			list.remove(index);
+			list.add(selection[0], target);
+			list.setSelection(target);
+		}
+		selectionChanged();
+	}
+
+	/* (non-Javadoc)
+	 * Event handler for the up button. It simply swaps the selected 
+	 * item with the list item above it.
+	 */
+	protected void upPressed() {
+		swap(true);
 	}
 }
Index: build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java,v
retrieving revision 1.1
diff -u -r1.1 BuildPropertyPage.java
--- build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java	9 Jun 2003 19:22:19 -0000	1.1
+++ build/org/eclipse/cdt/ui/build/properties/BuildPropertyPage.java	11 Aug 2003 15:41:10 -0000
@@ -340,7 +340,7 @@
 			int vdiff = contentSize.y - containerSize.y;
 
 			if (hdiff > 0 || vdiff > 0) {
-				if (shellSize.equals(lastShellSize)) {
+				if (shellSize.equals(getLastShellSize())) {
 					hdiff = Math.max(0, hdiff);
 					vdiff = Math.max(0, vdiff);
 					setShellSize(shellSize.x + hdiff, shellSize.y + vdiff);
@@ -377,6 +377,18 @@
 		return names;
 	}
 	
+	/**
+	 * @return
+	 */
+	protected Point getLastShellSize() {
+		if (lastShellSize == null) {
+			Shell shell = getShell();
+			if (shell != null)
+				lastShellSize = shell.getSize();
+		}
+		return lastShellSize;
+	}
+
 	private List getPagesForConfig() {
 		List pages = (List) configToPageListMap.get(selectedConfiguration.getId());
 		if (pages == null) {
@@ -550,7 +562,4 @@
 	 */
 	public void updateTitle() {
 	}
-	
-
-
 }
Index: build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java,v
retrieving revision 1.3
diff -u -r1.3 BuildToolSettingsPage.java
--- build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java	25 Jul 2003 17:30:57 -0000	1.3
+++ build/org/eclipse/cdt/ui/build/properties/BuildToolSettingsPage.java	11 Aug 2003 15:41:11 -0000
@@ -84,12 +84,12 @@
 					BuildOptionListFieldEditor listField = new BuildOptionListFieldEditor(opt.getId(), opt.getName(), getFieldEditorParent());
 					addField(listField); 
 					break;
-//				case IOption.SUMMARY :
-//				SummaryFieldEditor summaryField = new SummaryFieldEditor(opt.getId(), opt.getName(), category.getTool(), getFieldEditorParent());
-//				addField(summaryField);
-//				break;
 				default :
+					SummaryFieldEditor summaryField = new SummaryFieldEditor(opt.getId(), opt.getName(), category.getTool(), getFieldEditorParent());
+					addField(summaryField);
 					break;
+//				default :
+//					break;
 			}
 		}
 	}
Index: build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java,v
retrieving revision 1.1
diff -u -r1.1 SummaryFieldEditor.java
--- build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java	9 Jun 2003 19:22:19 -0000	1.1
+++ build/org/eclipse/cdt/ui/build/properties/SummaryFieldEditor.java	11 Aug 2003 15:41:11 -0000
@@ -11,22 +11,24 @@
  * IBM Rational Software - Initial API and implementation
 ***********************************************************************/
 
-import org.eclipse.cdt.core.build.managed.IOption;
 import org.eclipse.cdt.core.build.managed.ITool;
 import org.eclipse.jface.preference.FieldEditor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
 import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
 import org.eclipse.swt.widgets.Text;
 
 public class SummaryFieldEditor extends FieldEditor {
+	// Whitespace character
+	private static final String WHITESPACE = " ";
 
+	// The top level composite
+	protected Composite parent;
 	// The tool this category belongs to
-	ITool tool;
+	protected ITool tool;
 	// The text widget to hold summary of all commands for the tool
-	Text summary;
-	// Whitespace character
-	private static final String WHITESPACE = " ";
+	protected Text summary;
 	
 	/**
 	 * @param name 
@@ -53,18 +55,22 @@
 	 * @see org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt.widgets.Composite, int)
 	 */
 	protected void doFillIntoGrid(Composite parent, int numColumns) {
+		this.parent = parent;
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = numColumns;
+		this.parent.setLayoutData(gd);
+		
 		// Add the label
-		getLabelControl(parent);
+		Label label = getLabelControl(parent);
+		GridData labelData = new GridData();
+		labelData.horizontalSpan = numColumns;
+		label.setLayoutData(labelData);		
 
 		// Create the multi-line, read-only field
 		summary = new Text(parent, SWT.MULTI|SWT.READ_ONLY|SWT.WRAP);
-		GridData data = new GridData();
-		data.horizontalSpan = numColumns - 1;
-		data.horizontalAlignment = GridData.FILL;
-		data.grabExcessHorizontalSpace = true;
-		data.verticalAlignment = GridData.CENTER;
-		data.grabExcessVerticalSpace = true;
-		summary.setLayoutData(data);
+		GridData summaryData = new GridData(GridData.FILL_BOTH);
+		summaryData.horizontalSpan = numColumns;
+		summary.setLayoutData(summaryData);
 	}
 
 	/* (non-Javadoc)
@@ -72,21 +78,21 @@
 	 */
 	protected void doLoad() {
 		// Look at the data store for every option defined for the tool
-		IOption[] options = tool.getOptions();
-		for (int index = 0; index < options.length; ++index) {
-			IOption option = options[index];
-			String command = option.getCommand();
-			if (command == null) {
-				command = "";
-			}
-			String id = option.getId();
-			String values = getPreferenceStore().getString(id);
-			String[] valuesList = BuildToolsSettingsStore.parseString(values);
-			for (int j = 0; j < valuesList.length; ++j) {
-				String entry = valuesList[j];
-				summary.append(command + entry + WHITESPACE);
-			}
-		}
+//		IOption[] options = tool.getOptions();
+//		for (int index = 0; index < options.length; ++index) {
+//			IOption option = options[index];
+//			String command = option.getCommand();
+//			if (command == null) {
+//				command = "";
+//			}
+//			String id = option.getId();
+//			String values = getPreferenceStore().getString(id);
+//			String[] valuesList = BuildToolsSettingsStore.parseString(values);
+//			for (int j = 0; j < valuesList.length; ++j) {
+//				String entry = valuesList[j];
+//				summary.append(command + entry + WHITESPACE);
+//			}
+//		}
 	}
 
 	/* (non-Javadoc)
Index: build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java,v
retrieving revision 1.1
diff -u -r1.1 ToolListLabelProvider.java
--- build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java	9 Jun 2003 19:22:19 -0000	1.1
+++ build/org/eclipse/cdt/ui/build/properties/ToolListLabelProvider.java	11 Aug 2003 15:41:11 -0000
@@ -11,30 +11,25 @@
  * IBM Rational Software - Initial API and implementation
  * **********************************************************************/
 
-import org.eclipse.cdt.core.build.managed.IConfiguration;
 import org.eclipse.cdt.core.build.managed.IOptionCategory;
 import org.eclipse.cdt.internal.ui.CPluginImages;
-import org.eclipse.cdt.ui.CUIPlugin;
 import org.eclipse.jface.viewers.LabelProvider;
 import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.ISharedImages;
-
+ 
 class ToolListLabelProvider extends LabelProvider {
-	private final Image IMG_FOLDER = CUIPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);
 	private final Image IMG_TOOL = CPluginImages.get(CPluginImages.IMG_BUILD_TOOL);
+	private final Image IMG_CAT = CPluginImages.get(CPluginImages.IMG_BUILD_CAT);
 	private static final String TREE_LABEL = "BuildPropertyPage.label.ToolTree";	//$NON-NLS-1$
 
 	public Image getImage(Object element) {
 		// If the element is a configuration, return the folder image
-		if (element instanceof IConfiguration) {
-			return IMG_FOLDER;
-		} else if (element instanceof IOptionCategory) {
+		if (element instanceof IOptionCategory) {
 			IOptionCategory cat = (IOptionCategory)element;
 			IOptionCategory [] children = cat.getChildCategories();
 			if (children.length > 0){
-				return IMG_FOLDER;
-			} else {
 				return IMG_TOOL;
+			} else {
+				return IMG_CAT;
 			}
 		} else {
 			throw unknownElement(element);
@@ -46,11 +41,7 @@
 	 * @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
 	 */
 	public String getText(Object element) {
-		if (element instanceof IConfiguration) {
-			IConfiguration config = (IConfiguration)element;
-			return CUIPlugin.getResourceString(TREE_LABEL);
-		}
-		else if (element instanceof IOptionCategory) {
+		if (element instanceof IOptionCategory) {
 			IOptionCategory cat = (IOptionCategory)element;
 			return cat.getName();
 		}
Index: icons/full/build16/config-category.gif
===================================================================
RCS file: icons/full/build16/config-category.gif
diff -N icons/full/build16/config-category.gif
Binary files /dev/null and config-category.gif differ
Index: src/org/eclipse/cdt/internal/ui/CPluginImages.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/CPluginImages.java,v
retrieving revision 1.18
diff -u -r1.18 CPluginImages.java
--- src/org/eclipse/cdt/internal/ui/CPluginImages.java	28 Jun 2003 19:56:52 -0000	1.18
+++ src/org/eclipse/cdt/internal/ui/CPluginImages.java	11 Aug 2003 15:41:11 -0000
@@ -163,6 +163,8 @@
 	public static final ImageDescriptor DESC_BUILD_PREPROCESSOR = createManaged(T_BUILD, IMG_BUILD_PREPROCESSOR);
 	public static final String IMG_BUILD_TOOL = NAME_PREFIX + "config-tool.gif";
 	public static final ImageDescriptor DESC_BUILD_TOOL = createManaged(T_BUILD, IMG_BUILD_TOOL);
+	public static final String IMG_BUILD_CAT = NAME_PREFIX + "config-category.gif";
+	public static final ImageDescriptor DESC_BUILD_CAT = createManaged(T_BUILD, IMG_BUILD_CAT);
 
 	//for search
 	public static final String IMG_OBJS_SEARCH_REF  = NAME_PREFIX + "search_ref_obj.gif";

Attachment: org.eclipse.cdt.ui.zip
Description: Zip archive


Back to the top