trace/tracebuilder/com.nokia.tracebuilder.view/src/com/nokia/tracebuilder/view/PropertyDialogComposite.java
changeset 10 ed1c9f64298a
equal deleted inserted replaced
9:14dc2103a631 10:ed1c9f64298a
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:
       
    15 *
       
    16 * Composite, which wraps a text field / combo box and a button
       
    17 *
       
    18 */
       
    19 package com.nokia.tracebuilder.view;
       
    20 
       
    21 import org.eclipse.swt.SWT;
       
    22 import org.eclipse.swt.layout.GridData;
       
    23 import org.eclipse.swt.layout.GridLayout;
       
    24 import org.eclipse.swt.widgets.Composite;
       
    25 import org.eclipse.swt.widgets.Control;
       
    26 
       
    27 /**
       
    28  * Composite, which wraps a text field / combo box and a button
       
    29  * 
       
    30  */
       
    31 class PropertyDialogComposite {
       
    32 
       
    33 	/**
       
    34 	 * Number of columns in sub-composites
       
    35 	 */
       
    36 	private static final int SUB_COMPOSITE_COLUMNS = 2; // CodForChk_Dis_Magic
       
    37 
       
    38 	/**
       
    39 	 * Button width
       
    40 	 */
       
    41 	private static final int BUTTON_WIDTH = 75; // CodForChk_Dis_Magic
       
    42 
       
    43 	/**
       
    44 	 * Field width
       
    45 	 */
       
    46 	private final static int FIELD_WIDTH = 350; // CodForChk_Dis_Magic
       
    47 
       
    48 	/**
       
    49 	 * The parent composite
       
    50 	 */
       
    51 	private Composite parent;
       
    52 
       
    53 	/**
       
    54 	 * Constructor
       
    55 	 * 
       
    56 	 * @param parent
       
    57 	 *            the parent composite
       
    58 	 */
       
    59 	PropertyDialogComposite(Composite parent) {
       
    60 		this.parent = parent;
       
    61 	}
       
    62 
       
    63 	/**
       
    64 	 * Creates a composite with two columns and grid layout
       
    65 	 * 
       
    66 	 * @return the composite
       
    67 	 */
       
    68 	protected Composite createFieldButtonComposite() {
       
    69 		GridLayout layout = new GridLayout();
       
    70 		layout.numColumns = SUB_COMPOSITE_COLUMNS;
       
    71 		layout.marginLeft = 0;
       
    72 		layout.marginRight = 0;
       
    73 		layout.marginTop = 0;
       
    74 		layout.marginBottom = 0;
       
    75 		layout.marginWidth = 0;
       
    76 		layout.marginHeight = 0;
       
    77 		Composite composite = new Composite(parent, SWT.NONE);
       
    78 		composite.setLayout(layout);
       
    79 		GridData gridData = new GridData();
       
    80 		gridData.horizontalAlignment = GridData.FILL;
       
    81 		composite.setLayoutData(gridData);
       
    82 		return composite;
       
    83 	}
       
    84 
       
    85 	/**
       
    86 	 * Sets the layout data of the controls in field-button composite
       
    87 	 * 
       
    88 	 * @param field
       
    89 	 *            the field
       
    90 	 * @param button
       
    91 	 *            the button
       
    92 	 */
       
    93 	protected void setFieldButtonLayoutData(Control field, Control button) {
       
    94 		GridData fieldData = new GridData();
       
    95 		fieldData.horizontalAlignment = GridData.FILL;
       
    96 		fieldData.widthHint = FIELD_WIDTH;
       
    97 		field.setLayoutData(fieldData);
       
    98 		if (button != null) {
       
    99 			GridData buttonData = new GridData();
       
   100 			buttonData.widthHint = BUTTON_WIDTH;
       
   101 			button.setLayoutData(buttonData);
       
   102 		}
       
   103 	}
       
   104 
       
   105 	/**
       
   106 	 * Gets the parent composite
       
   107 	 * 
       
   108 	 * @return the parent composite
       
   109 	 */
       
   110 	protected Composite getParent() {
       
   111 		return parent;
       
   112 	}
       
   113 
       
   114 }