X-Git-Url: http://secure.phpeclipse.com diff --git a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java index 5a9de70..f528485 100644 --- a/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java +++ b/net.sourceforge.phpeclipse.externaltools/src/net/sourceforge/phpdt/externaltools/internal/dialog/ExternalToolVariableForm.java @@ -1,13 +1,13 @@ package net.sourceforge.phpdt.externaltools.internal.dialog; /********************************************************************** -Copyright (c) 2002 IBM Corp. and others. All rights reserved. -This file is made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html -� -Contributors: -**********************************************************************/ + Copyright (c) 2002 IBM Corp. and others. All rights reserved. + This file is made available under the terms of the Common Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/cpl-v10.html + � + Contributors: + **********************************************************************/ import net.sourceforge.phpdt.externaltools.group.IGroupDialogPage; import net.sourceforge.phpdt.externaltools.internal.registry.ExternalToolVariable; @@ -28,31 +28,40 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.List; /** - * Visual grouping of controls that allows the user to - * select a variable and configure it with extra - * information. + * Visual grouping of controls that allows the user to select a variable and + * configure it with extra information. */ public class ExternalToolVariableForm { private static final int VISIBLE_ITEM_COUNT = 9; - + private String variableListLabelText; + private ExternalToolVariable[] variables; + private IVariableComponent[] components; + private IGroupDialogPage page; - + private Label variableListLabel; + private List variableList; + private Composite variableComposite; + private StackLayout variableLayout; + private int activeComponentIndex = -1; - + /** * Creates the visual grouping * - * @param variableListLabelText the label text to use for identifying the list of variables - * @param variables the collection of variables to display to the user + * @param variableListLabelText + * the label text to use for identifying the list of variables + * @param variables + * the collection of variables to display to the user */ - public ExternalToolVariableForm(String variableListLabelText, ExternalToolVariable[] variables) { + public ExternalToolVariableForm(String variableListLabelText, + ExternalToolVariable[] variables) { super(); this.variableListLabelText = variableListLabelText; this.variables = variables; @@ -61,9 +70,9 @@ public class ExternalToolVariableForm { public Composite createContents(Composite parent, IGroupDialogPage page) { Font font = parent.getFont(); - + this.page = page; - + Composite mainComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginWidth = 0; @@ -79,8 +88,9 @@ public class ExternalToolVariableForm { data.horizontalSpan = 1; variableListLabel.setLayoutData(data); variableListLabel.setFont(font); - - variableList = new List(mainComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); + + variableList = new List(mainComposite, SWT.SINGLE | SWT.BORDER + | SWT.H_SCROLL | SWT.V_SCROLL); data = new GridData(GridData.FILL_HORIZONTAL); data.heightHint = variableList.getItemHeight() * VISIBLE_ITEM_COUNT; variableList.setLayoutData(data); @@ -94,25 +104,24 @@ public class ExternalToolVariableForm { variableComposite.setLayout(variableLayout); variableComposite.setLayoutData(data); variableComposite.setFont(font); - + createVariableComponents(data); - + populateVariableList(); - + variableList.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { updateVariableComposite(null, false); } }); - + setEnabled(true); return mainComposite; } - + /** - * Creates the visual component for each variable - * and determine the initial size so the form - * can be layout properly. + * Creates the visual component for each variable and determine the initial + * size so the form can be layout properly. */ private void createVariableComponents(GridData data) { for (int i = 0; i < variables.length; i++) { @@ -121,34 +130,36 @@ public class ExternalToolVariableForm { components[i].createContents(variableComposite, var.getTag(), page); Control control = components[i].getControl(); if (control != null) { - Point newSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); + Point newSize = control.computeSize(SWT.DEFAULT, SWT.DEFAULT, + true); data.widthHint = Math.max(newSize.x, data.widthHint); data.heightHint = Math.max(newSize.y, data.heightHint); } } } - + /** - * Returns the formatted variable or null if - * none selected. + * Returns the formatted variable or null if none selected. */ public String getSelectedVariable() { if (activeComponentIndex != -1) { - String varValue = components[activeComponentIndex].getVariableValue(); - return ToolUtil.buildVariableTag(variables[activeComponentIndex].getTag(), varValue); + String varValue = components[activeComponentIndex] + .getVariableValue(); + return ToolUtil.buildVariableTag(variables[activeComponentIndex] + .getTag(), varValue); } return null; } /** - * Returns whether the current variable selection is - * valid, including the selected variable value. + * Returns whether the current variable selection is valid, including the + * selected variable value. */ public boolean isValid() { if (activeComponentIndex != -1) return components[activeComponentIndex].isValid(); - + return true; } @@ -165,7 +176,7 @@ public class ExternalToolVariableForm { variableList.setItems(items); } - public void selectVariable(String varName, String varValue) { + public void selectVariable(String varName, String varValue) { if (varName != null && varName.length() > 0) { for (int i = 0; i < variables.length; i++) { if (varName.equals(variables[i].getTag())) { @@ -175,11 +186,11 @@ public class ExternalToolVariableForm { } } } - + variableList.deselectAll(); updateVariableComposite(varValue, false); } - + private void setComponentVisible(int index) { if (index == -1) variableLayout.topControl = null; @@ -187,7 +198,7 @@ public class ExternalToolVariableForm { variableLayout.topControl = components[index].getControl(); variableComposite.layout(); } - + /** * Enables or disables the variable form controls. */ @@ -197,12 +208,12 @@ public class ExternalToolVariableForm { if (enabled && variableList.getSelection().length == 0) { if (variableList.getItemCount() > 0) { variableList.select(0); - activeComponentIndex= 0; + activeComponentIndex = 0; } } variableComposite.setVisible(enabled); } - + private void updateVariableComposite(String value, boolean setValue) { activeComponentIndex = variableList.getSelectionIndex(); setComponentVisible(activeComponentIndex); @@ -211,8 +222,7 @@ public class ExternalToolVariableForm { } /** - * Validates the current variable selection is and - * its value are acceptable. + * Validates the current variable selection is and its value are acceptable. */ public void validate() { if (activeComponentIndex != -1)