gt:         layout = new GridLayout();
context: /*
   * Copyright (c) 2006 Stiftung Deutsches Elektronen-Synchroton,
   * Member of the Helmholtz Association, (DESY), HAMBURG, GERMANY.
   *
   * THIS SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN "../AS IS" BASIS.
   * WITHOUT WARRANTY OF ANY KIND, EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
   * TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR PARTICULAR PURPOSE AND
   * NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
   * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
   * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
   * THE USE OR OTHER DEALINGS IN THE SOFTWARE. SHOULD THE SOFTWARE PROVE DEFECTIVE
   * IN ANY RESPECT, THE USER ASSUMES THE COST OF ANY NECESSARY SERVICING, REPAIR OR
   * CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE.
   * NO USE OF ANY SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
   * DESY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS,
   * OR MODIFICATIONS.
   * THE FULL LICENSE SPECIFYING FOR THE SOFTWARE THE REDISTRIBUTION, MODIFICATION,
   * USAGE AND OTHER RIGHTS AND OBLIGATIONS IS INCLUDED WITH THE DISTRIBUTION OF THIS
   * PROJECT IN THE FILE LICENSE.HTML. IF THE LICENSE IS NOT INCLUDED YOU MAY FIND A COPY
   * AT HTTP://WWW.DESY.DE/LEGAL/LICENSE.HTM
   */
  package org.csstudio.platform.ui.composites.resourcefilter;
  
  import org.csstudio.ui.util.composites.ResourceSelectionGroup;
  import org.csstudio.ui.util.internal.localization.Messages;
  import org.eclipse.core.resources.IContainer;
  import org.eclipse.core.resources.IResource;
  import org.eclipse.core.resources.IWorkspace;
  import org.eclipse.core.resources.IWorkspaceRoot;
  import org.eclipse.core.resources.ResourcesPlugin;
  import org.eclipse.core.runtime.IPath;
  import org.eclipse.core.runtime.IStatus;
  import org.eclipse.core.runtime.Path;
  import org.eclipse.jface.fieldassist.FieldAssistColors;
  import org.eclipse.osgi.util.NLS;
  import org.eclipse.swt.SWT;
  import org.eclipse.swt.layout.GridData;
  import org.eclipse.swt.layout.GridLayout;
  import org.eclipse.swt.widgets.Composite;
  import org.eclipse.swt.widgets.Event;
  import org.eclipse.swt.widgets.Label;
  import org.eclipse.swt.widgets.Listener;
  import org.eclipse.swt.widgets.Text;
  
  /**
   * Workbench-level composite for resource and container specification by the
   * user. Services such as field validation are performed by the group. The group
   * can be configured to accept existing resources, or only new resources.
   *
   * <p>
   * <b>Code is based upon
   * <code>org.eclipse.ui.internal.ide.misc.ResourceAndContainerGroup</code> in
   * plugin <code>org.eclipse.ui.ide</code>.</b>
   * </p>
   *
   * @author Alexander Will
   * @version $Revision$
   */
  // TODO: Copied from org.csstudio.platform.ui.
  @SuppressWarnings("deprecation")
  public final class ResourceAndContainerGroup implements Listener {
      /**
       * Problem identifier: No problem.
       */
      public static final int PROBLEM_NONE = 0;
  
      /**
       * Problem identifier: Empty resource.
       */
      public static final int PROBLEM_RESOURCE_EMPTY = 1;
  
      /**
       * Problem identifier: Resource already exists.
       */
      public static final int PROBLEM_RESOURCE_EXIST = 2;
  
      /**
       * Problem identifier: Path is invalid.
       */
      public static final int PROBLEM_PATH_INVALID = 4;
  
      /**
       * Problem identifier: Container is empty.
       */
      public static final int PROBLEM_CONTAINER_EMPTY = 5;
  
      /**
       * Problem identifier: Project does not exist.
       */
      public static final int PROBLEM_PROJECT_DOES_NOT_EXIST = 6;
  
      /**
       * Problem identifier: Invalid resource name.
       */
      public static final int PROBLEM_NAME_INVALID = 7;
  
      /**
       * Problem identifier: Path os occupied.
       */
      public static final int PROBLEM_PATH_OCCUPIED = 8;
  
      /**
       * The client to notify of changes.
       */
      private Listener _client;
  
      /**
       * Whether to allow existing resources.
       */
      private boolean _allowExistingResources = false;
  
      /**
       * Resource type (file, folder, project).
       */
      private String _resourceType = "resource"; //$NON-NLS-1$
  
      /**
       * Show closed projects in the tree, by default.
       */
      private boolean _showClosedProjects = true;
  
      /**
       * Problem indicator.
       */
      private String _problemMessage = "";//$NON-NLS-1$
  
      /**
       * The default file extension.
       */
      private String _fileExtension = ""; //$NON-NLS-1$
  
      /**
       * Problem type.
       */
      private int _problemType = PROBLEM_NONE;
  
      /**
       * The container selection group.
       */
      private ResourceSelectionGroup _containerGroup;
  
      /**
       * The name of the resource.
       */
      private Text _resourceNameField;
  
      /**
       * The full path to the resource.
       */
      private Label _fullPathLabel;
  
      /**
       * Sizing constand for the text field width.
       */
      private static final int SIZING_TEXT_FIELD_WIDTH = 250;
  
      /**
       * Create an instance of the group to allow the user to enter/select a
       * container and specify a resource name.
       *
       * @param parent
       *            composite widget to parent the group
       * @param client
       *            object interested in changes to the group's fields value
       * @param resourceFieldLabel
       *            label to use in front of the resource name field
       * @param resourceType
       *            one word, in lowercase, to describe the resource to the user
       *            (file, folder, project) height hint for the container
       *            selection widget group
       */
      public ResourceAndContainerGroup(final Composite parent,
              final Listener client, final String resourceFieldLabel,
              final String resourceType) {
          this(parent, client, resourceFieldLabel, resourceType, true);
      }
  
      /**
       * Create an instance of the group to allow the user to enter/select a
       * container and specify a resource name.
       *
       * @param parent
       *            composite widget to parent the group
       * @param client
       *            object interested in changes to the group's fields value
       * @param resourceFieldLabel
       *            label to use in front of the resource name field
       * @param resourceType
       *            one word, in lowercase, to describe the resource to the user
       *            (file, folder, project)
       * @param showClosedProjects
       *            whether or not to show closed projects height hint for the
       *            container selection widget group
       */
      public ResourceAndContainerGroup(final Composite parent,
              final Listener client, final String resourceFieldLabel,
              final String resourceType, final boolean showClosedProjects) {
          this(parent, client, resourceFieldLabel, resourceType,
                  showClosedProjects, SWT.DEFAULT);
      }
  
      /**
       * Create an instance of the group to allow the user to enter/select a
       * container and specify a resource name.
       *
       * @param parent
       *            composite widget to parent the group
       * @param client
       *            object interested in changes to the group's fields value
       * @param resourceFieldLabel
       *            label to use in front of the resource name field
       * @param resourceType
       *            one word, in lowercase, to describe the resource to the user
       *            (file, folder, project)
       * @param showClosedProjects
       *            whether or not to show closed projects
       * @param heightHint
       *            height hint for the container selection widget group
       */
      public ResourceAndContainerGroup(final Composite parent,
              final Listener client, final String resourceFieldLabel,
              final String resourceType, final boolean showClosedProjects,
              final int heightHint) {
          super();
          _resourceType = resourceType;
          _showClosedProjects = showClosedProjects;
          createContents(parent, resourceFieldLabel, heightHint);
          _client = client;
      }
  
      /**
       * Returns a boolean indicating whether all controls in this group contain
       * valid values.
       *
       * @return boolean
       */
      public boolean areAllValuesValid() {
          return _problemType == PROBLEM_NONE;
      }
  
      /**
       * Creates this object's visual components.
       *
       * @param parent
       *            org.eclipse.swt.widgets.Composite
       * @param heightHint
       *            height hint for the container selection widget group
       * @param resourceLabelString
       *            resource label text.
       */
      private void createContents(final Composite parent,
              final String resourceLabelString, final int heightHint) {
  
          // Font font = parent.getFont();
          // server name group
          Composite composite = new Composite(parent, SWT.NONE);
          GridLayout layout = new GridLayout();
          layout.marginWidth = 0;
          layout.marginHeight = 0;
          composite.setLayout(layout);
          composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
          // composite.setFont(font);
  
          // container group
          if (heightHint == SWT.DEFAULT) {
              _containerGroup = new ResourceSelectionGroup(composite, this, null,
                      null, _showClosedProjects);
          } else {
              _containerGroup = new ResourceSelectionGroup(composite, this, null,
                      null, _showClosedProjects, true, heightHint,
                      SIZING_TEXT_FIELD_WIDTH);
          }
  
          // resource name group
          Composite nameGroup = new Composite(composite, SWT.NONE);
  