trace/traceviewer/com.nokia.traceviewer/src/com/nokia/traceviewer/engine/preferences/LabelFieldEditor.java
changeset 11 5b9d4d8641ce
equal deleted inserted replaced
10:ed1c9f64298a 11:5b9d4d8641ce
       
     1 /*
       
     2  * Copyright (c) 2007-2010 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  * Label Field Editor
       
    17  *
       
    18  */
       
    19 package com.nokia.traceviewer.engine.preferences;
       
    20 
       
    21 import org.eclipse.jface.preference.FieldEditor;
       
    22 import org.eclipse.swt.layout.GridData;
       
    23 import org.eclipse.swt.widgets.Composite;
       
    24 import org.eclipse.swt.widgets.Label;
       
    25 
       
    26 /**
       
    27  * Label Field Editor
       
    28  * 
       
    29  */
       
    30 class LabelFieldEditor extends FieldEditor {
       
    31 
       
    32 	/**
       
    33 	 * Label
       
    34 	 */
       
    35 	private Label label;
       
    36 
       
    37 	/**
       
    38 	 * Constructor
       
    39 	 * 
       
    40 	 * @param value
       
    41 	 *            value for the label
       
    42 	 * @param parent
       
    43 	 *            parent composite
       
    44 	 */
       
    45 	public LabelFieldEditor(String value, Composite parent) {
       
    46 		super("label", value, parent); //$NON-NLS-1$
       
    47 	}
       
    48 
       
    49 	/*
       
    50 	 * (non-Javadoc)
       
    51 	 * 
       
    52 	 * @see org.eclipse.jface.preference.FieldEditor#adjustForNumColumns(int)
       
    53 	 */
       
    54 	@Override
       
    55 	protected void adjustForNumColumns(int numColumns) {
       
    56 		((GridData) label.getLayoutData()).horizontalSpan = numColumns;
       
    57 	}
       
    58 
       
    59 	/*
       
    60 	 * (non-Javadoc)
       
    61 	 * 
       
    62 	 * @see
       
    63 	 * org.eclipse.jface.preference.FieldEditor#doFillIntoGrid(org.eclipse.swt
       
    64 	 * .widgets.Composite, int)
       
    65 	 */
       
    66 	@Override
       
    67 	protected void doFillIntoGrid(Composite parent, int numColumns) {
       
    68 		label = getLabelControl(parent);
       
    69 
       
    70 		GridData gridData = new GridData();
       
    71 		gridData.horizontalSpan = numColumns;
       
    72 		gridData.horizontalAlignment = GridData.FILL;
       
    73 		gridData.grabExcessHorizontalSpace = false;
       
    74 		gridData.verticalAlignment = GridData.CENTER;
       
    75 		gridData.grabExcessVerticalSpace = false;
       
    76 
       
    77 		label.setLayoutData(gridData);
       
    78 	}
       
    79 
       
    80 	/*
       
    81 	 * (non-Javadoc)
       
    82 	 * 
       
    83 	 * @see org.eclipse.jface.preference.FieldEditor#getNumberOfControls()
       
    84 	 */
       
    85 	@Override
       
    86 	public int getNumberOfControls() {
       
    87 		return 1;
       
    88 	}
       
    89 
       
    90 	/*
       
    91 	 * (non-Javadoc)
       
    92 	 * 
       
    93 	 * @see org.eclipse.jface.preference.FieldEditor#doLoad()
       
    94 	 */
       
    95 	@Override
       
    96 	protected void doLoad() {
       
    97 	}
       
    98 
       
    99 	/*
       
   100 	 * (non-Javadoc)
       
   101 	 * 
       
   102 	 * @see org.eclipse.jface.preference.FieldEditor#doLoadDefault()
       
   103 	 */
       
   104 	@Override
       
   105 	protected void doLoadDefault() {
       
   106 	}
       
   107 
       
   108 	/*
       
   109 	 * (non-Javadoc)
       
   110 	 * 
       
   111 	 * @see org.eclipse.jface.preference.FieldEditor#doStore()
       
   112 	 */
       
   113 	@Override
       
   114 	protected void doStore() {
       
   115 	}
       
   116 }