trace/tracebuilder/com.nokia.tracebuilder.view/src/com/nokia/tracebuilder/view/PropertyWrapper.java
changeset 10 ed1c9f64298a
equal deleted inserted replaced
9:14dc2103a631 10:ed1c9f64298a
       
     1 /*
       
     2 * Copyright (c) 2008 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 * UI for property dialogs
       
    17 *
       
    18 */
       
    19 package com.nokia.tracebuilder.view;
       
    20 
       
    21 import com.nokia.tracebuilder.engine.TraceBuilderGlobals;
       
    22 
       
    23 /**
       
    24  * Wrapper for a trace object property
       
    25  * 
       
    26  */
       
    27 final class PropertyWrapper extends WrapperBase {
       
    28 
       
    29 	/**
       
    30 	 * The property
       
    31 	 */
       
    32 	private String property;
       
    33 
       
    34 	/**
       
    35 	 * Type of the property
       
    36 	 */
       
    37 	private String type;
       
    38 
       
    39 	/**
       
    40 	 * Creates a new property wrapper
       
    41 	 * 
       
    42 	 * @param type
       
    43 	 *            the property type
       
    44 	 * @param property
       
    45 	 *            the property
       
    46 	 * @param parent
       
    47 	 *            tree view parent
       
    48 	 * @param updater
       
    49 	 *            the update notifier
       
    50 	 */
       
    51 	PropertyWrapper(String type, String property, WrapperBase parent,
       
    52 			WrapperUpdater updater) {
       
    53 		super(parent, updater);
       
    54 		this.type = type;
       
    55 		this.property = property;
       
    56 	}
       
    57 
       
    58 	/**
       
    59 	 * Sets the property
       
    60 	 * 
       
    61 	 * @param property
       
    62 	 *            the new property
       
    63 	 */
       
    64 	void setProperty(String property) {
       
    65 		this.property = property;
       
    66 	}
       
    67 
       
    68 	/**
       
    69 	 * Sets the type
       
    70 	 * 
       
    71 	 * @param type
       
    72 	 *            the type
       
    73 	 */
       
    74 	void setType(String type) {
       
    75 		this.type = type;
       
    76 	}
       
    77 
       
    78 	/*
       
    79 	 * (non-Javadoc)
       
    80 	 * 
       
    81 	 * @see com.nokia.tracebuilder.view.WrapperBase#getChildren()
       
    82 	 */
       
    83 	@Override
       
    84 	public Object[] getChildren() {
       
    85 		return new Object[0];
       
    86 	}
       
    87 
       
    88 	/*
       
    89 	 * (non-Javadoc)
       
    90 	 * 
       
    91 	 * @see com.nokia.tracebuilder.view.WrapperBase#hasChildren()
       
    92 	 */
       
    93 	@Override
       
    94 	public boolean hasChildren() {
       
    95 		return false;
       
    96 	}
       
    97 
       
    98 	/**
       
    99 	 * Returns the type. This never returns null
       
   100 	 * 
       
   101 	 * @return the property type
       
   102 	 */
       
   103 	String getType() {
       
   104 		String ret;
       
   105 		if (type == null) {
       
   106 			ret = ""; //$NON-NLS-1$
       
   107 		} else {
       
   108 			ret = type;
       
   109 		}
       
   110 		return ret;
       
   111 	}
       
   112 
       
   113 	/**
       
   114 	 * Returns the property. This never returns null
       
   115 	 * 
       
   116 	 * @return the property
       
   117 	 */
       
   118 	String getProperty() {
       
   119 		String ret;
       
   120 
       
   121 		if (type.equals(Messages.getString("TraceObjectWrapper.ModelID"))) { //$NON-NLS-1$
       
   122 			if (property == null || property.length() == 0
       
   123 					|| property.equals("0")) { //$NON-NLS-1$
       
   124 				if (TraceBuilderGlobals.getTraceModel().getName() == null
       
   125 						|| TraceBuilderGlobals.getTraceModel().getName()
       
   126 								.length() == 0) {
       
   127 					// TraceBuilder project is not open, show None as Project ID
       
   128 					// value.
       
   129 					String noProperty = Messages
       
   130 							.getString("PropertyWrapper.NoProperty"); //$NON-NLS-1$
       
   131 					ret = noProperty;
       
   132 				} else {
       
   133 					// If TraceBuilder project is open, but Project ID is, show
       
   134 					// Not available as Project ID value.
       
   135 					String notAvailable = Messages
       
   136 							.getString("PropertyWrapper.NotAvailable"); //$NON-NLS-1$
       
   137 					ret = notAvailable;
       
   138 				}
       
   139 
       
   140 			} else {
       
   141 				ret = property;
       
   142 			}
       
   143 		} else {
       
   144 			if (property == null || property.length() == 0) {
       
   145 				ret = Messages.getString("PropertyWrapper.NoProperty"); //$NON-NLS-1$
       
   146 			} else {
       
   147 				ret = property;
       
   148 			}
       
   149 		}
       
   150 
       
   151 		return ret;
       
   152 	}
       
   153 }