cdt/cdt_6_0_x/org.eclipse.cdt.dsf.ui/src/org/eclipse/cdt/dsf/debug/ui/viewmodel/variable/VariableVMNode.java
author Steve Sobek <steve.sobek@nokia.com>
Fri, 30 Oct 2009 10:27:11 -0500
changeset 105 fbceb3d6fb44
parent 37 c2bce6dd59e7
child 129 723898599d35
permissions -rw-r--r--
let expression getAddress() return a string, such as register name or invalid access message
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     1
/*******************************************************************************
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2006, 2008 Wind River Systems and others.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     3
 * All rights reserved. This program and the accompanying materials
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     4
 * are made available under the terms of the Eclipse Public License v1.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     5
 * which accompanies this distribution, and is available at
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     6
 * http://www.eclipse.org/legal/epl-v10.html
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     7
 * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     8
 * Contributors:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
     9
 *     Wind River Systems - initial API and implementation
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    10
 *******************************************************************************/
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    11
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    12
package org.eclipse.cdt.dsf.debug.ui.viewmodel.variable;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    13
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    14
import java.util.ArrayList;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    15
import java.util.Arrays;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    16
import java.util.List;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    17
import java.util.Map;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    18
import java.util.concurrent.RejectedExecutionException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    19
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    20
import org.eclipse.cdt.core.IAddress;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    21
import org.eclipse.cdt.debug.internal.ui.CDebugImages;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    22
import org.eclipse.cdt.dsf.concurrent.ConfinedToDsfExecutor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    23
import org.eclipse.cdt.dsf.concurrent.CountingRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    24
import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    25
import org.eclipse.cdt.dsf.concurrent.DsfExecutor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    26
import org.eclipse.cdt.dsf.concurrent.DsfRunnable;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    27
import org.eclipse.cdt.dsf.concurrent.IDsfStatusConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    28
import org.eclipse.cdt.dsf.concurrent.ImmediateExecutor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    29
import org.eclipse.cdt.dsf.concurrent.MultiRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    30
import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    31
import org.eclipse.cdt.dsf.datamodel.DMContexts;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    32
import org.eclipse.cdt.dsf.datamodel.IDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    33
import org.eclipse.cdt.dsf.debug.service.IExpressions;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    34
import org.eclipse.cdt.dsf.debug.service.IFormattedValues;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    35
import org.eclipse.cdt.dsf.debug.service.IStack;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    36
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionChangedDMEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    37
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMAddress;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    38
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    39
import org.eclipse.cdt.dsf.debug.service.IExpressions.IExpressionDMData;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    40
import org.eclipse.cdt.dsf.debug.service.IMemory.IMemoryChangedEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    41
import org.eclipse.cdt.dsf.debug.service.IRunControl.ISuspendedDMEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    42
import org.eclipse.cdt.dsf.debug.service.IStack.IFrameDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    43
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    44
import org.eclipse.cdt.dsf.debug.service.IStack.IVariableDMData;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    45
import org.eclipse.cdt.dsf.debug.ui.viewmodel.ErrorLabelText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    46
import org.eclipse.cdt.dsf.debug.ui.viewmodel.IDebugVMConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    47
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.AbstractExpressionVMNode;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    48
import org.eclipse.cdt.dsf.debug.ui.viewmodel.expression.IExpressionUpdate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    49
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueLabelText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    50
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.FormattedValueVMUtil;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    51
import org.eclipse.cdt.dsf.debug.ui.viewmodel.numberformat.IFormattedValueVMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    52
import org.eclipse.cdt.dsf.internal.ui.DsfUIPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    53
import org.eclipse.cdt.dsf.service.DsfSession;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    54
import org.eclipse.cdt.dsf.ui.concurrent.ViewerDataRequestMonitor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    55
import org.eclipse.cdt.dsf.ui.viewmodel.VMDelta;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    56
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.AbstractDMVMProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    57
import org.eclipse.cdt.dsf.ui.viewmodel.datamodel.IDMVMContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    58
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IElementPropertiesProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    59
import org.eclipse.cdt.dsf.ui.viewmodel.properties.IPropertiesUpdate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    60
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelAttribute;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    61
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelBackground;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    62
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelColumnInfo;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    63
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelForeground;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    64
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelImage;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    65
import org.eclipse.cdt.dsf.ui.viewmodel.properties.LabelText;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    66
import org.eclipse.cdt.dsf.ui.viewmodel.properties.PropertiesBasedLabelProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    67
import org.eclipse.cdt.dsf.ui.viewmodel.update.ICachingVMProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    68
import org.eclipse.cdt.dsf.ui.viewmodel.update.StaleDataLabelBackground;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    69
import org.eclipse.cdt.dsf.ui.viewmodel.update.StaleDataLabelForeground;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    70
import org.eclipse.core.runtime.CoreException;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    71
import org.eclipse.core.runtime.IStatus;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    72
import org.eclipse.core.runtime.Status;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    73
import org.eclipse.debug.core.DebugPlugin;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    74
import org.eclipse.debug.core.model.IExpression;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    75
import org.eclipse.debug.internal.ui.viewers.model.provisional.IChildrenUpdate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    76
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementCompareRequest;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    77
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    78
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementLabelProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    79
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    80
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementMementoRequest;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    81
import org.eclipse.debug.internal.ui.viewers.model.provisional.ILabelUpdate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    82
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    83
import org.eclipse.debug.internal.ui.viewers.model.provisional.IPresentationContext;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    84
import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewerUpdate;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    85
import org.eclipse.debug.ui.DebugUITools;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    86
import org.eclipse.debug.ui.IDebugModelPresentation;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    87
import org.eclipse.debug.ui.IDebugUIConstants;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    88
import org.eclipse.debug.ui.actions.IWatchExpressionFactoryAdapter2;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    89
import org.eclipse.jface.util.PropertyChangeEvent;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    90
import org.eclipse.jface.viewers.CellEditor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    91
import org.eclipse.jface.viewers.ICellModifier;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    92
import org.eclipse.jface.viewers.TextCellEditor;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    93
import org.eclipse.jface.viewers.TreePath;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    94
import org.eclipse.swt.graphics.RGB;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    95
import org.eclipse.swt.widgets.Composite;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    96
import org.eclipse.ui.IMemento;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    97
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    98
@SuppressWarnings("restriction")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
    99
public class VariableVMNode extends AbstractExpressionVMNode 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   100
                            implements IElementEditor, IElementLabelProvider, IElementPropertiesProvider, IElementMementoProvider 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   101
{
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   102
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   103
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   104
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   105
    private static final String PROP_VARIABLE_TYPE_NAME = "variable_type_name";  //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   106
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   107
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   108
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   109
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   110
    private static final String PROP_VARIABLE_BASIC_TYPE = "variable_basic_type";  //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   111
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   112
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   113
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   114
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   115
    private static final String PROP_VARIABLE_ADDRESS = "variable_address";  //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   116
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   117
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   118
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   119
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   120
    private static final String PROP_VARIABLE_SHOW_TYPE_NAMES = "variable_show_type_names"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   121
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   122
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   123
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   124
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   125
    private static final String PROP_VARIABLE_ADDRESS_CHANGED = ICachingVMProvider.PROP_IS_CHANGED_PREFIX + PROP_VARIABLE_ADDRESS;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   126
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   127
    private final SyncVariableDataAccess fSyncVariableDataAccess;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   128
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   129
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   130
     * The label provider delegate.  This VM node will delegate label updates to this provider
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   131
     * which can be created by sub-classes. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   132
     *  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   133
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   134
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   135
    private IElementLabelProvider fLabelProvider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   136
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   137
    public class VariableExpressionVMC extends DMVMContext implements IFormattedValueVMContext  {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   138
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   139
        private IExpression fExpression;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   140
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   141
        public VariableExpressionVMC(IDMContext dmc) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   142
            super(dmc);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   143
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   144
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   145
        public void setExpression(IExpression expression) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   146
            fExpression = expression;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   147
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   148
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   149
        @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   150
        @SuppressWarnings("unchecked") 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   151
        public Object getAdapter(Class adapter) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   152
            if (fExpression != null && adapter.isAssignableFrom(fExpression.getClass())) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   153
                return fExpression;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   154
            } else if (adapter.isAssignableFrom(IWatchExpressionFactoryAdapter2.class)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   155
                return fVariableExpressionFactory;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   156
            } else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   157
                return super.getAdapter(adapter);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   158
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   159
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   160
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   161
        @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   162
        public boolean equals(Object other) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   163
            if (other instanceof VariableExpressionVMC && super.equals(other)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   164
                VariableExpressionVMC otherGroup = (VariableExpressionVMC)other;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   165
                return (otherGroup.fExpression == null && fExpression == null) ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   166
                       (otherGroup.fExpression != null && otherGroup.fExpression.equals(fExpression));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   167
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   168
            return false;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   169
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   170
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   171
        @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   172
        public int hashCode() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   173
            return super.hashCode() + (fExpression != null ? fExpression.hashCode() : 0);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   174
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   175
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   176
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   177
    protected class VariableExpressionFactory implements IWatchExpressionFactoryAdapter2 {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   178
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   179
        public boolean canCreateWatchExpression(Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   180
            return element instanceof VariableExpressionVMC;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   181
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   182
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   183
        public String createWatchExpression(Object element) throws CoreException {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   184
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   185
            VariableExpressionVMC exprVmc = (VariableExpressionVMC) element;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   186
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   187
            IExpressionDMContext exprDmc = DMContexts.getAncestorOfType(exprVmc.getDMContext(), IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   188
            if (exprDmc != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   189
                return exprDmc.getExpression();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   190
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   191
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   192
            return null;     
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   193
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   194
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   195
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   196
    final protected VariableExpressionFactory fVariableExpressionFactory = new VariableExpressionFactory();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   197
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   198
    public VariableVMNode(AbstractDMVMProvider provider, DsfSession session, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   199
        SyncVariableDataAccess syncVariableDataAccess) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   200
    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   201
        super(provider, session, IExpressions.IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   202
        fSyncVariableDataAccess = syncVariableDataAccess;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   203
        fLabelProvider = createLabelProvider();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   204
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   205
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   206
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   207
     * Creates the label provider delegate.  This VM node will delegate label 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   208
     * updates to this provider which can be created by sub-classes.   
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   209
     *  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   210
     * @return Returns the label provider for this node. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   211
     *  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   212
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   213
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   214
    protected IElementLabelProvider createLabelProvider() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   215
        PropertiesBasedLabelProvider provider = new PropertiesBasedLabelProvider();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   216
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   217
        // 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   218
        // Create label image objects which are used in more than one column. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   219
        //
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   220
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   221
        // Pointer image is used for variable and function pointers.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   222
        LabelImage pointerLabelImage = new LabelImage(CDebugImages.DESC_OBJS_VARIABLE_POINTER) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   223
            { setPropertyNames(new String[] { PROP_VARIABLE_BASIC_TYPE }); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   224
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   225
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   226
            public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   227
                String type = (String)properties.get(PROP_VARIABLE_BASIC_TYPE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   228
                return IExpressionDMData.BasicType.pointer.name().equals(type) ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   229
                    IExpressionDMData.BasicType.function.name().equals(type);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   230
            };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   231
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   232
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   233
        // Aggregate image is used for array, struct, etc.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   234
        LabelImage aggregateLabelImage = new LabelImage(CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   235
            { setPropertyNames(new String[] { PROP_VARIABLE_BASIC_TYPE }); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   236
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   237
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   238
            public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   239
                String type = (String)properties.get(PROP_VARIABLE_BASIC_TYPE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   240
                return IExpressionDMData.BasicType.array.name().equals(type) ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   241
                    IExpressionDMData.BasicType.composite.name().equals(type);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   242
            };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   243
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   244
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   245
        // Simple variable image is used for all other types, except when there is no type specified.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   246
        LabelImage simpleLabelImage = new LabelImage(CDebugImages.DESC_OBJS_VARIABLE_SIMPLE) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   247
            { setPropertyNames(new String[] { PROP_VARIABLE_BASIC_TYPE }); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   248
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   249
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   250
            public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   251
                String type = (String)properties.get(PROP_VARIABLE_BASIC_TYPE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   252
                return type != null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   253
            };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   254
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   255
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   256
        // The name column consists of the expression name.  The name column image depends on the variable type. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   257
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   258
            IDebugVMConstants.COLUMN_ID__NAME,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   259
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   260
                new LabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   261
                    MessagesForVariablesVM.VariableVMNode_Name_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   262
                    new String[] { PROP_NAME }),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   263
                pointerLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   264
                aggregateLabelImage, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   265
                simpleLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   266
                new StaleDataLabelForeground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   267
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   268
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   269
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   270
        // Expression column is visible only in the expressions view.  It shows the expression string that the user 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   271
        // entered.  Expression column images are the same as for the name column.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   272
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   273
            IDebugVMConstants.COLUMN_ID__EXPRESSION,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   274
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   275
                new LabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   276
                    MessagesForVariablesVM.VariableVMNode_Expression_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   277
                    new String[] { PROP_ELEMENT_EXPRESSION }),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   278
                pointerLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   279
                aggregateLabelImage, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   280
                simpleLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   281
                new StaleDataLabelForeground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   282
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   283
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   284
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   285
        // Type column only contains the type name.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   286
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   287
            IDebugVMConstants.COLUMN_ID__TYPE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   288
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   289
                new LabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   290
                    MessagesForVariablesVM.VariableVMNode_Type_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   291
                    new String[] { PROP_VARIABLE_TYPE_NAME }),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   292
                new LabelText( MessagesForVariablesVM.VariableVMNode_Type_column__Error__text_format, new String[] {}),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   293
                new StaleDataLabelForeground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   294
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   295
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   296
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   297
        // Value column is more complicated:
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   298
        // - If a STRING value format is supported.  Then the value label consists of the active format label followed 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   299
        //   by the string format.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   300
        // - If the STRIGN value format is not supported.  Then only show the active value format.  The GDB reference
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   301
        //   implementation currently does not support the string format, but by default it does append extra 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   302
        //   information to the value label itself.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   303
        // 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   304
        // In case of error, show the error message in the value column (instead of the usual "...".  This is needed 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   305
        // for the expressions view, where an invalid expression entered by the user is a normal use case.  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   306
        // 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   307
        // For changed value high-lighting check both the string value and the value in the active format.  But,  
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   308
        // ignore the active format value change if the format itself has changed.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   309
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   310
            IDebugVMConstants.COLUMN_ID__VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   311
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   312
                new FormattedValueLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   313
                    MessagesForVariablesVM.VariableVMNode_Value_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   314
                    new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   315
                        IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   316
                        FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   317
                        IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS})
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   318
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   319
                    @Override                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   320
                    public boolean isEnabled(IStatus status, Map<String, Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   321
                        String[] formatIds = 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   322
                            (String[])properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   323
                        String activeFormat = (String)properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   324
                        return 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   325
                            !IFormattedValues.STRING_FORMAT.equals(activeFormat) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   326
                            formatIds != null &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   327
                            Arrays.asList(formatIds).contains(IFormattedValues.STRING_FORMAT) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   328
                            super.isEnabled(status, properties);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   329
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   330
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   331
                new FormattedValueLabelText(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   332
                new ErrorLabelText(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   333
                new LabelForeground(new RGB(255, 0, 0)) // TODO: replace with preference error color
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   334
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   335
                    { setPropertyNames(new String[] { PROP_NAME }); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   336
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   337
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   338
                    public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   339
                        return !status.isOK();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   340
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   341
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   342
                // 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   343
                new LabelBackground(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   344
                    DebugUITools.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB()) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   345
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   346
                    { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   347
                        setPropertyNames(new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   348
                            FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   349
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   350
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   351
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   352
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   353
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT}); 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   354
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   355
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   356
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   357
                    public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   358
                        Boolean activeFormatChanged = (Boolean)properties.get(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   359
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   360
                        Boolean activeChanged = (Boolean)properties.get(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   361
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   362
                        Boolean stringChanged = (Boolean)properties.get(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   363
                            ICachingVMProvider.PROP_IS_CHANGED_PREFIX + FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   364
                        return Boolean.TRUE.equals(stringChanged) || 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   365
                            ( Boolean.TRUE.equals(activeChanged) && !Boolean.TRUE.equals(activeFormatChanged));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   366
                    };                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   367
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   368
                new StaleDataLabelForeground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   369
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   370
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   371
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   372
        // Address column shows the variable's address.  It is highlighted with the change background color when the 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   373
        // address value changes. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   374
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   375
            IDebugVMConstants.COLUMN_ID__ADDRESS,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   376
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   377
                new LabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   378
                    MessagesForVariablesVM.VariableVMNode_Address_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   379
                    new String[] { PROP_VARIABLE_ADDRESS }),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   380
                new LabelText(MessagesForVariablesVM.VariableVMNode_Address_column__Error__text_format, new String[] {}), 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   381
                new LabelBackground(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   382
                    DebugUITools.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_VALUE_BACKGROUND).getRGB()) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   383
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   384
                    { setPropertyNames(new String[] { PROP_VARIABLE_ADDRESS, PROP_VARIABLE_ADDRESS_CHANGED}); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   385
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   386
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   387
                    public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   388
                        Boolean changed = (Boolean)properties.get(PROP_VARIABLE_ADDRESS_CHANGED);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   389
                        return Boolean.TRUE.equals(changed);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   390
                    };                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   391
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   392
                new StaleDataLabelForeground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   393
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   394
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   395
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   396
        // Description column is shown in the expression view, but is not supported for variables. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   397
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   398
            IDebugVMConstants.COLUMN_ID__DESCRIPTION,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   399
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   400
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   401
                new LabelText(MessagesForVariablesVM.VariableVMNode_Description_column__text_format, new String[] {}),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   402
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   403
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   404
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   405
        // Configure the case where there are no columns visible.  It basically combines the name and the value columns only.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   406
        provider.setColumnInfo(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   407
            PropertiesBasedLabelProvider.ID_COLUMN_NO_COLUMNS,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   408
            new LabelColumnInfo(new LabelAttribute[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   409
                new FormattedValueLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   410
                    MessagesForVariablesVM.VariableVMNode_NoColumns_column__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   411
                    new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   412
                        PROP_NAME, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   413
                        IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   414
                        FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   415
                        IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   416
                        IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   417
                        IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   418
                        PROP_VARIABLE_SHOW_TYPE_NAMES}) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   419
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   420
					@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   421
                    public boolean isEnabled(IStatus status, Map<String, Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   422
                        Boolean showTypeNames = (Boolean) properties.get(PROP_VARIABLE_SHOW_TYPE_NAMES);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   423
                        String[] formatIds = (String[]) properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   424
                        String activeFormat = (String) properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   425
                        return 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   426
                            showTypeNames != null && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   427
                           !showTypeNames.booleanValue() &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   428
                           !IFormattedValues.STRING_FORMAT.equals(activeFormat) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   429
                            formatIds != null &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   430
                            Arrays.asList(formatIds).contains(IFormattedValues.STRING_FORMAT) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   431
                            super.isEnabled(status, properties);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   432
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   433
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   434
                new FormattedValueLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   435
                    MessagesForVariablesVM.VariableVMNode_NoColumns_column__No_string__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   436
                    new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   437
                        PROP_NAME, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   438
                        IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   439
                        IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   440
                        IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   441
                        IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   442
                        PROP_VARIABLE_SHOW_TYPE_NAMES})
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   443
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   444
                	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   445
                	public boolean isEnabled(IStatus status, Map<String, Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   446
                		Boolean showTypeNames = (Boolean) properties.get(PROP_VARIABLE_SHOW_TYPE_NAMES);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   447
                		return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   448
                		     showTypeNames != null && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   449
                		    !showTypeNames.booleanValue() &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   450
                             super.isEnabled(status, properties);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   451
                	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   452
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   453
                new FormattedValueLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   454
                        MessagesForVariablesVM.VariableVMNode_NoColumns_column__text_format_with_type, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   455
                        new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   456
                            PROP_NAME, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   457
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   458
                            FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   459
                            PROP_VARIABLE_TYPE_NAME,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   460
                            IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   461
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   462
                            IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   463
                            PROP_VARIABLE_SHOW_TYPE_NAMES}) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   464
                    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   465
    					@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   466
                        public boolean isEnabled(IStatus status, Map<String, Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   467
                            Boolean showTypeNames = (Boolean) properties.get(PROP_VARIABLE_SHOW_TYPE_NAMES);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   468
                            String[] formatIds = (String[]) properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   469
                            String activeFormat = (String) properties.get(IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   470
                            return 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   471
                                showTypeNames != null && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   472
                                showTypeNames.booleanValue() &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   473
                               !IFormattedValues.STRING_FORMAT.equals(activeFormat) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   474
                                formatIds != null &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   475
                                Arrays.asList(formatIds).contains(IFormattedValues.STRING_FORMAT) &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   476
                                super.isEnabled(status, properties);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   477
                        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   478
                    },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   479
                    new FormattedValueLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   480
                        MessagesForVariablesVM.VariableVMNode_NoColumns_column__No_string__text_format_with_type, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   481
                        new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   482
                            PROP_NAME, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   483
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT_VALUE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   484
                            PROP_VARIABLE_TYPE_NAME,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   485
                            IDebugVMConstants.PROP_FORMATTED_VALUE_AVAILABLE_FORMATS,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   486
                            IDebugVMConstants.PROP_FORMATTED_VALUE_ACTIVE_FORMAT,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   487
                            IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   488
                            PROP_VARIABLE_SHOW_TYPE_NAMES})
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   489
                    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   490
                    	@Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   491
                    	public boolean isEnabled(IStatus status, Map<String, Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   492
                    		Boolean showTypeNames = (Boolean) properties.get(PROP_VARIABLE_SHOW_TYPE_NAMES);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   493
                    		return
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   494
               		            showTypeNames != null && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   495
               		            showTypeNames.booleanValue() &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   496
                                super.isEnabled(status, properties);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   497
                    	}
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   498
                    },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   499
                new ErrorLabelText(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   500
                    MessagesForVariablesVM.VariableVMNode_NoColumns_column__Error__text_format, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   501
                    new String[] { PROP_NAME }),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   502
                pointerLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   503
                aggregateLabelImage, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   504
                simpleLabelImage,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   505
                new LabelForeground(new RGB(255, 0, 0)) // TODO: replace with preference error color
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   506
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   507
                    { setPropertyNames(new String[] { PROP_NAME }); }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   508
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   509
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   510
                    public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   511
                        return !status.isOK();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   512
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   513
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   514
                new LabelForeground(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   515
                    DebugUITools.getPreferenceColor(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR).getRGB())
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   516
                {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   517
                    { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   518
                        setPropertyNames(new String[] { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   519
                            FormattedValueVMUtil.getPropertyForFormatId(IFormattedValues.STRING_FORMAT), 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   520
                            IDebugVMConstants.PROP_IS_STRING_FORMAT_VALUE_CHANGED, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   521
                            IDebugVMConstants.PROP_IS_ACTIVE_FORMATTED_VALUE_CHANGED}); 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   522
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   523
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   524
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   525
                    public boolean isEnabled(IStatus status, java.util.Map<String,Object> properties) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   526
                        Boolean stringChanged = 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   527
                            (Boolean)properties.get(IDebugVMConstants.PROP_IS_STRING_FORMAT_VALUE_CHANGED);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   528
                        Boolean activeChanged = 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   529
                            (Boolean)properties.get(IDebugVMConstants.PROP_IS_ACTIVE_FORMATTED_VALUE_CHANGED);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   530
                        return Boolean.TRUE.equals(stringChanged) || Boolean.TRUE.equals(activeChanged);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   531
                    };                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   532
                },
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   533
                new StaleDataLabelBackground(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   534
                new VariableLabelFont(),
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   535
            }));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   536
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   537
        return provider;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   538
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   539
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   540
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   541
    public String toString() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   542
        return "VariableVMNode(" + getSession().getId() + ")";  //$NON-NLS-1$ //$NON-NLS-2$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   543
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   544
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   545
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   546
    protected IDMVMContext createVMContext(IDMContext dmc) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   547
        return new VariableExpressionVMC(dmc);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   548
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   549
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   550
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   551
    public void update(final ILabelUpdate[] updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   552
        fLabelProvider.update(updates);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   553
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   554
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   555
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   556
     * @see IElementPropertiesProvider#update(IPropertiesUpdate[])
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   557
     * 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   558
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   559
     */    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   560
    public void update(final IPropertiesUpdate[] updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   561
        try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   562
            getSession().getExecutor().execute(new DsfRunnable() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   563
                public void run() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   564
                    updatePropertiesInSessionThread(updates);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   565
                }});
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   566
        } catch (RejectedExecutionException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   567
            for (IPropertiesUpdate update : updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   568
                handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   569
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   570
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   571
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   572
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   573
    //
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   574
    //  @param return-value Boolean.TRUE  --> Show Types ICON is     selected/depressed
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   575
    //  @param return-value Boolean.FALSE --> Show Types ICON is not selected/depressed
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   576
    //
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   577
	private Boolean getShowTypeNamesState( IPresentationContext context ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   578
      Boolean attribute = (Boolean) context.getProperty(IDebugModelPresentation.DISPLAY_VARIABLE_TYPE_NAMES);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   579
      
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   580
      if (attribute != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   581
    	  return attribute;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   582
      }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   583
      
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   584
      return Boolean.FALSE;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   585
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   586
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   587
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   588
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   589
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   590
    @ConfinedToDsfExecutor("getSession().getExecutor()")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   591
    protected void updatePropertiesInSessionThread(final IPropertiesUpdate[] updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   592
        IExpressions service = getServicesTracker().getService(IExpressions.class, null);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   593
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   594
        final CountingRequestMonitor countingRm = new CountingRequestMonitor(ImmediateExecutor.getInstance(), null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   595
            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   596
            protected void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   597
                for (final IPropertiesUpdate update : updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   598
                    update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   599
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   600
            };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   601
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   602
        int count = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   603
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   604
        if (service != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   605
            FormattedValueVMUtil.updateFormattedValues(updates, service, IExpressionDMContext.class, countingRm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   606
            count++;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   607
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   608
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   609
        for (final IPropertiesUpdate update : updates) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   610
            IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   611
            if (expression != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   612
            	update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, expression.getExpressionText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   613
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   614
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   615
            // Capture the current "Show Type Names" ICON state in case there are no columns.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   616
            if (update.getProperties().contains(PROP_VARIABLE_SHOW_TYPE_NAMES)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   617
            	update.setProperty(PROP_VARIABLE_SHOW_TYPE_NAMES, getShowTypeNamesState(update.getPresentationContext()));
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   618
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   619
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   620
            IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   621
            if ( dmc == null || service == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   622
                update.setStatus(DsfUIPlugin.newErrorStatus(IDsfStatusConstants.INVALID_STATE,  "Invalid context or service not available.", null)); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   623
                continue;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   624
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   625
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   626
            if (update.getProperties().contains(PROP_NAME) ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   627
                update.getProperties().contains(PROP_VARIABLE_TYPE_NAME) || 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   628
                update.getProperties().contains(PROP_VARIABLE_BASIC_TYPE)) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   629
            {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   630
                service.getExpressionData(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   631
                    dmc, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   632
                    // Use the ViewerDataRequestMonitor in order to propagate the update's cancel request. Use an immediate 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   633
                    // executor to avoid the possibility of a rejected execution exception.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   634
                    new ViewerDataRequestMonitor<IExpressionDMData>(ImmediateExecutor.getInstance(), update) { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   635
                        @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   636
                        protected void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   637
                            if (isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   638
                                fillExpressionDataProperties(update, getData());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   639
                            } else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   640
                                // In case of an error fill in the expression next in the name column.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   641
                                IExpressionDMContext dmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressions.IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   642
                                if (dmc != null && dmc.getExpression() != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   643
                                    update.setProperty(PROP_NAME, dmc.getExpression());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   644
                                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   645
                                update.setStatus(getStatus());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   646
                            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   647
                            countingRm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   648
                        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   649
                    });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   650
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   651
                count++;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   652
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   653
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   654
            if (update.getProperties().contains(PROP_VARIABLE_ADDRESS)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   655
                service.getExpressionAddressData(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   656
                    dmc,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   657
                    // Use the ViewerDataRequestMonitor in order to propagate the update's cancel request. Use an immediate 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   658
                    // executor to avoid the possibility of a rejected execution exception.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   659
                    new ViewerDataRequestMonitor<IExpressionDMAddress>(ImmediateExecutor.getInstance(), update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   660
                        @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   661
                        protected void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   662
                            if (isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   663
                                fillAddressDataProperties(update, getData());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   664
                            } else if (getStatus().getCode() != IDsfStatusConstants.NOT_SUPPORTED &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   665
                                       getStatus().getCode() != IDsfStatusConstants.INVALID_STATE) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   666
                            {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   667
                                update.setStatus(getStatus());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   668
                            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   669
                            countingRm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   670
                        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   671
                    });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   672
                count++;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   673
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   674
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   675
        countingRm.setDoneCount(count);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   676
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   677
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   678
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   679
     * @since 2.0
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   680
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   681
    @ConfinedToDsfExecutor("getSession().getExecutor()")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   682
    protected void fillExpressionDataProperties(IPropertiesUpdate update, IExpressionDMData data) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   683
    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   684
        update.setProperty(PROP_NAME, data.getName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   685
        update.setProperty(PROP_VARIABLE_TYPE_NAME, data.getTypeName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   686
        IExpressionDMData.BasicType type = data.getBasicType();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   687
        if (type != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   688
            update.setProperty(PROP_VARIABLE_BASIC_TYPE, type.name());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   689
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   690
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   691
        //
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   692
        // If this node has an expression then it has already been filled in by the higher
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   693
        // level logic. If not then we need to supply something.  In the  previous version
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   694
        // ( pre-property based ) we supplied the name. So we will do that here also.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   695
        //
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   696
        IExpression expression = (IExpression)DebugPlugin.getAdapter(update.getElement(), IExpression.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   697
        if (expression == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   698
            update.setProperty(AbstractExpressionVMNode.PROP_ELEMENT_EXPRESSION, data.getName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   699
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   700
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   701
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   702
    /**
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   703
     *  Private data access routine which performs the extra level of data access needed to
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   704
     *  get the formatted data value for a specific register.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   705
     */
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   706
    @ConfinedToDsfExecutor("getSession().getExecutor()")
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   707
    protected void fillAddressDataProperties(IPropertiesUpdate update, IExpressionDMAddress address)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   708
    { 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   709
	    IExpressionDMAddress expression = address;
105
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   710
	    Object expAddress = expression.getAddress();
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   711
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   712
	    String addrString = ""; //$NON-NLS-1$
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   713
	    if (expAddress instanceof IAddress)
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   714
	    	addrString = "0x" + ((IAddress)expAddress).toString(16); //$NON-NLS-1$
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   715
	    else if (expAddress instanceof String)
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   716
	    	addrString = (String)expAddress;
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   717
fbceb3d6fb44 let expression getAddress() return a string, such as register name or invalid access message
Steve Sobek <steve.sobek@nokia.com>
parents: 37
diff changeset
   718
	    update.setProperty(PROP_VARIABLE_ADDRESS, addrString);
37
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   719
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   720
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   721
    public CellEditor getCellEditor(IPresentationContext context, String columnId, Object element, Composite parent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   722
        if (IDebugVMConstants.COLUMN_ID__VALUE.equals(columnId)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   723
            return new TextCellEditor(parent);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   724
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   725
        else if (IDebugVMConstants.COLUMN_ID__EXPRESSION.equals(columnId)) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   726
            return new TextCellEditor(parent);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   727
        } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   728
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   729
        return null;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   730
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   731
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   732
    public ICellModifier getCellModifier(IPresentationContext context, Object element) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   733
        return new VariableCellModifier(getDMVMProvider(), fSyncVariableDataAccess);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   734
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   735
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   736
    public boolean canParseExpression(IExpression expression) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   737
    	// At this point we are going to say we will allow anything as an expression.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   738
    	// Since the evaluation  of VM Node implementations searches  in the order of
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   739
    	// registration  and we always make sure we register the VariableVMNode last,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   740
    	// we know that the other possible handlers have passed the expression by. So
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   741
    	// we are going to say OK and let the expression evaluation of whatever debug
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   742
    	// backend is connected to decide. This does not allow us to put up any  good
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   743
    	// diagnostic error message ( instead the error will come from the backend ).
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   744
    	// But it does allow for the most flexibility
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   745
    	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   746
    	return true;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   747
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   748
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   749
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   750
    public void update(final IExpressionUpdate update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   751
        try {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   752
            getSession().getExecutor().execute(new Runnable() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   753
                public void run() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   754
                    final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   755
                    if (expressionService != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   756
                        IExpressionDMContext expressionDMC = expressionService.createExpression(
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   757
                            createCompositeDMVMContext(update), 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   758
                            update.getExpression().getExpressionText());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   759
                        VariableExpressionVMC variableVmc = new VariableExpressionVMC(expressionDMC);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   760
                        variableVmc.setExpression(update.getExpression());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   761
                        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   762
                        update.setExpressionElement(variableVmc);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   763
                        update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   764
                    } else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   765
                        handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   766
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   767
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   768
            });
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   769
        } catch (RejectedExecutionException e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   770
            handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   771
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   772
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   773
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   774
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   775
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   776
    protected void handleFailedUpdate(IViewerUpdate update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   777
        if (update instanceof IExpressionUpdate) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   778
            update.setStatus(new Status(IStatus.ERROR, DsfUIPlugin.PLUGIN_ID, IDsfStatusConstants.INVALID_STATE, "Update failed", null)); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   779
            update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   780
        } else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   781
            super.handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   782
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   783
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   784
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   785
    protected void associateExpression(Object element, IExpression expression) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   786
        if (element instanceof VariableExpressionVMC) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   787
            ((VariableExpressionVMC)element).setExpression(expression);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   788
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   789
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   790
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   791
    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   792
    protected void updateElementsInSessionThread(final IChildrenUpdate update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   793
        // Get the data model context object for the current node in the hierarchy.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   794
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   795
        final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   796
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   797
        if ( expressionDMC != null ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   798
            getSubexpressionsUpdateElementsInSessionThread( update );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   799
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   800
        else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   801
            getLocalsUpdateElementsInSessionThread( update );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   802
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   803
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   804
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   805
    private void getSubexpressionsUpdateElementsInSessionThread(final IChildrenUpdate update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   806
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   807
        final IExpressionDMContext expressionDMC = findDmcInPath(update.getViewerInput(), update.getElementPath(), IExpressionDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   808
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   809
        if ( expressionDMC != null ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   810
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   811
            // Get the services we need to use.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   812
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   813
            final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   814
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   815
            if (expressionService == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   816
                handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   817
                return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   818
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   819
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   820
            final DsfExecutor dsfExecutor = getSession().getExecutor();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   821
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   822
            // Call IExpressions.getSubExpressions() to get an Iterable of IExpressionDMContext objects representing
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   823
            // the sub-expressions of the expression represented by the current expression node.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   824
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   825
            final DataRequestMonitor<IExpressionDMContext[]> rm =
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   826
                new ViewerDataRequestMonitor<IExpressionDMContext[]>(dsfExecutor, update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   827
                    @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   828
                    public void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   829
                        if (!isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   830
                            handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   831
                            return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   832
                        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   833
                        fillUpdateWithVMCs(update, getData());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   834
                        update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   835
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   836
            };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   837
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   838
            // Make the asynchronous call to IExpressions.getSubExpressions().  The results are processed in the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   839
            // DataRequestMonitor.handleCompleted() above.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   840
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   841
            expressionService.getSubExpressions(expressionDMC, rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   842
        } else {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   843
            handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   844
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   845
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   846
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   847
    private void getLocalsUpdateElementsInSessionThread(final IChildrenUpdate update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   848
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   849
        final IFrameDMContext frameDmc = findDmcInPath(update.getViewerInput(), update.getElementPath(), IFrameDMContext.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   850
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   851
        // Get the services we need to use.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   852
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   853
        final IExpressions expressionService = getServicesTracker().getService(IExpressions.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   854
        final IStack stackFrameService = getServicesTracker().getService(IStack.class);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   855
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   856
        if ( frameDmc == null || expressionService == null || stackFrameService == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   857
            handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   858
            return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   859
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   860
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   861
        final DsfExecutor dsfExecutor = getSession().getExecutor();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   862
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   863
        // Call IStack.getLocals() to get an array of IVariableDMContext objects representing the local
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   864
        // variables in the stack frame represented by frameDmc.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   865
         
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   866
        final DataRequestMonitor<IVariableDMContext[]> rm =
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   867
            new ViewerDataRequestMonitor<IVariableDMContext[]>(dsfExecutor, update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   868
                @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   869
                public void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   870
                    if (!isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   871
                        handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   872
                        return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   873
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   874
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   875
                    // For each IVariableDMContext object returned by IStack.getLocals(), call
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   876
                    // MIStackFrameService.getModelData() to get the IVariableDMData object.  This requires
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   877
                    // a MultiRequestMonitor object.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   878
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   879
                    // First, get the data model context objects for the local variables.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   880
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   881
                    IVariableDMContext[] localsDMCs = getData();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   882
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   883
                    if (localsDMCs == null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   884
                        handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   885
                        return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   886
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   887
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   888
                    if ( localsDMCs.length == 0 ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   889
                        // There are no locals so just complete the request
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   890
                        update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   891
                        return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   892
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   893
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   894
                    // Create a List in which we store the DM data objects for the local variables.  This is
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   895
                    // necessary because there is no MultiDataRequestMonitor. :)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   896
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   897
                    final List<IVariableDMData> localsDMData = new ArrayList<IVariableDMData>();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   898
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   899
                    // Create the MultiRequestMonitor to handle completion of the set of getModelData() calls.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   900
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   901
                    final MultiRequestMonitor<DataRequestMonitor<IVariableDMData>> mrm =
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   902
                        new MultiRequestMonitor<DataRequestMonitor<IVariableDMData>>(dsfExecutor, null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   903
                            @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   904
                            public void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   905
                                // Now that all the calls to getModelData() are complete, we create an
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   906
                                // IExpressionDMContext object for each local variable name, saving them all
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   907
                                // in an array.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   908
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   909
                                if (!isSuccess()) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   910
                                    handleFailedUpdate(update);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   911
                                    return;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   912
                                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   913
         
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   914
                                IExpressionDMContext[] expressionDMCs = new IExpressionDMContext[localsDMData.size()];
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   915
                                
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   916
                                int i = 0;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   917
                                
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   918
                                for (IVariableDMData localDMData : localsDMData) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   919
                                    expressionDMCs[i++] = expressionService.createExpression(frameDmc, localDMData.getName());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   920
                                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   921
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   922
                                // Lastly, we fill the update from the array of view model context objects
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   923
                                // that reference the ExpressionDMC objects for the local variables.  This is
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   924
                                // the last code to run for a given call to updateElementsInSessionThread().
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   925
                                // We can now leave anonymous-inner-class hell.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   926
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   927
                                fillUpdateWithVMCs(update, expressionDMCs);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   928
                                update.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   929
                            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   930
                    };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   931
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   932
                    // Perform a set of getModelData() calls, one for each local variable's data model
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   933
                    // context object.  In the handleCompleted() method of the DataRequestMonitor, add the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   934
                    // IVariableDMData object to the localsDMData List for later processing (see above).
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   935
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   936
                    for (IVariableDMContext localDMC : localsDMCs) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   937
                        DataRequestMonitor<IVariableDMData> rm =
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   938
                            new ViewerDataRequestMonitor<IVariableDMData>(dsfExecutor, update) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   939
                                @Override
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   940
                                public void handleCompleted() {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   941
                                    localsDMData.add(getData());
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   942
                                    mrm.requestMonitorDone(this);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   943
                                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   944
                        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   945
                        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   946
                        mrm.add(rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   947
                        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   948
                        stackFrameService.getVariableData(localDMC, rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   949
                    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   950
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   951
        };
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   952
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   953
        // Make the asynchronous call to IStack.getLocals().  The results are processed in the
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   954
        // DataRequestMonitor.handleCompleted() above.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   955
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   956
        stackFrameService.getLocals(frameDmc, rm);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   957
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   958
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   959
    public int getDeltaFlags(Object e) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   960
        if ( e instanceof ISuspendedDMEvent || 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   961
             e instanceof IMemoryChangedEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   962
             e instanceof IExpressionChangedDMEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   963
             (e instanceof PropertyChangeEvent &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   964
              ((PropertyChangeEvent)e).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   965
        {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   966
            // Create a delta that the whole register group has changed.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   967
            return IModelDelta.CONTENT;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   968
        } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   969
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   970
        return IModelDelta.NO_CHANGE;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   971
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   972
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   973
    public void buildDelta(final Object e, final VMDelta parentDelta, final int nodeOffset, final RequestMonitor requestMonitor) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   974
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   975
        // The following events can affect any expression's values, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   976
        // refresh the contents of the parent element (i.e. all the expressions). 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   977
        if ( e instanceof ISuspendedDMEvent || 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   978
             e instanceof IMemoryChangedEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   979
             e instanceof IExpressionChangedDMEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   980
             (e instanceof PropertyChangeEvent &&
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   981
              ((PropertyChangeEvent)e).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) ) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   982
        {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   983
            // Create a delta that the whole register group has changed.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   984
            parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   985
        } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   986
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   987
        requestMonitor.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   988
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   989
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   990
    public int getDeltaFlagsForExpression(IExpression expression, Object event) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   991
        if ( event instanceof IExpressionChangedDMEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   992
             event instanceof IMemoryChangedEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   993
             (event instanceof PropertyChangeEvent && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   994
              ((PropertyChangeEvent)event).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) )
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   995
        {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   996
            return IModelDelta.CONTENT;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   997
        } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   998
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
   999
        if (event instanceof ISuspendedDMEvent)
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1000
        {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1001
            return IModelDelta.CONTENT;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1002
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1003
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1004
        return IModelDelta.NO_CHANGE;
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1005
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1006
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1007
    public void buildDeltaForExpression(IExpression expression, int elementIdx, Object event, VMDelta parentDelta, 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1008
        TreePath path, RequestMonitor rm) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1009
    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1010
        // Always refresh the contents of the view upon suspended event.
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1011
        if (event instanceof ISuspendedDMEvent) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1012
            parentDelta.setFlags(parentDelta.getFlags() | IModelDelta.CONTENT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1013
        }         
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1014
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1015
        rm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1016
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1017
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1018
    public void buildDeltaForExpressionElement(Object element, int elementIdx, Object event, VMDelta parentDelta,
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1019
        RequestMonitor rm) 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1020
    {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1021
        // The following events can affect expression values, refresh the state 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1022
        // of the expression. 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1023
        if ( event instanceof IExpressionChangedDMEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1024
             event instanceof IMemoryChangedEvent ||
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1025
             (event instanceof PropertyChangeEvent && 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1026
                ((PropertyChangeEvent)event).getProperty() == IDebugVMConstants.PROP_FORMATTED_VALUE_FORMAT_PREFERENCE) )
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1027
        {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1028
            parentDelta.addNode(element, IModelDelta.CONTENT);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1029
        } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1030
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1031
        rm.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1032
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1033
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1034
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1035
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1036
    private String produceExpressionElementName( String viewName , IExpressionDMContext expression ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1037
    	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1038
    	return "Variable." + expression.getExpression(); //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1039
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1040
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1041
    private final String MEMENTO_NAME = "VARIABLE_MEMENTO_NAME"; //$NON-NLS-1$
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1042
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1043
    public void compareElements(IElementCompareRequest[] requests) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1044
        
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1045
        for ( IElementCompareRequest request : requests ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1046
        	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1047
            Object element = request.getElement();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1048
            IMemento memento = request.getMemento();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1049
            String mementoName = memento.getString(MEMENTO_NAME);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1050
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1051
            if (mementoName != null) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1052
                if (element instanceof IDMVMContext) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1053
                	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1054
                    IDMContext dmc = ((IDMVMContext)element).getDMContext();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1055
                    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1056
                    if ( dmc instanceof IExpressionDMContext) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1057
                    	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1058
                    	String elementName = produceExpressionElementName( request.getPresentationContext().getId(), (IExpressionDMContext) dmc );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1059
                    	request.setEqual( elementName.equals( mementoName ) );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1060
                    } 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1061
                }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1062
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1063
            request.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1064
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1065
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1066
    
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1067
    public void encodeElements(IElementMementoRequest[] requests) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1068
    	
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1069
    	for ( IElementMementoRequest request : requests ) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1070
    		
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1071
            Object element = request.getElement();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1072
            IMemento memento = request.getMemento();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1073
            
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1074
            if (element instanceof IDMVMContext) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1075
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1076
            	IDMContext dmc = ((IDMVMContext)element).getDMContext();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1077
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1078
            	if ( dmc instanceof IExpressionDMContext) {
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1079
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1080
            		String elementName = produceExpressionElementName( request.getPresentationContext().getId(), (IExpressionDMContext) dmc );
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1081
            		memento.putString(MEMENTO_NAME, elementName);
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1082
            	} 
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1083
            }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1084
            request.done();
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1085
        }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1086
    }
c2bce6dd59e7 add cdt_6_0_x
cawthron
parents:
diff changeset
  1087
}