Resolved issues and concerns found during overall functionality testing.
[platform/upstream/iotivity.git] / service / simulator / java / eclipse-plugin / ClientControllerPlugin / src / oic / simulator / clientcontroller / view / dialogs / PutRequestDialog.java
1 /*
2  * Copyright 2015 Samsung Electronics All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 package oic.simulator.clientcontroller.view.dialogs;
18
19 import org.eclipse.jface.dialogs.IDialogConstants;
20 import org.eclipse.jface.dialogs.MessageDialog;
21 import org.eclipse.jface.dialogs.TitleAreaDialog;
22 import org.eclipse.jface.viewers.ILabelProviderListener;
23 import org.eclipse.jface.viewers.IStructuredSelection;
24 import org.eclipse.jface.viewers.ITableLabelProvider;
25 import org.eclipse.jface.viewers.ITreeContentProvider;
26 import org.eclipse.jface.viewers.TreeViewer;
27 import org.eclipse.jface.viewers.TreeViewerColumn;
28 import org.eclipse.jface.viewers.Viewer;
29 import org.eclipse.jface.window.Window;
30 import org.eclipse.swt.SWT;
31 import org.eclipse.swt.events.MenuAdapter;
32 import org.eclipse.swt.events.MenuEvent;
33 import org.eclipse.swt.events.ModifyEvent;
34 import org.eclipse.swt.events.ModifyListener;
35 import org.eclipse.swt.events.SelectionAdapter;
36 import org.eclipse.swt.events.SelectionEvent;
37 import org.eclipse.swt.graphics.Image;
38 import org.eclipse.swt.layout.GridData;
39 import org.eclipse.swt.layout.GridLayout;
40 import org.eclipse.swt.widgets.Button;
41 import org.eclipse.swt.widgets.Combo;
42 import org.eclipse.swt.widgets.Composite;
43 import org.eclipse.swt.widgets.Control;
44 import org.eclipse.swt.widgets.Display;
45 import org.eclipse.swt.widgets.Group;
46 import org.eclipse.swt.widgets.Label;
47 import org.eclipse.swt.widgets.Menu;
48 import org.eclipse.swt.widgets.MenuItem;
49 import org.eclipse.swt.widgets.MessageBox;
50 import org.eclipse.swt.widgets.Shell;
51 import org.eclipse.swt.widgets.Tree;
52 import org.eclipse.swt.widgets.TreeColumn;
53 import org.eclipse.swt.widgets.TreeItem;
54
55 import java.util.ArrayList;
56 import java.util.Collections;
57 import java.util.HashMap;
58 import java.util.Iterator;
59 import java.util.List;
60 import java.util.Map;
61 import java.util.Vector;
62
63 import org.oic.simulator.ArrayProperty;
64 import org.oic.simulator.AttributeProperty;
65 import org.oic.simulator.AttributeValue;
66 import org.oic.simulator.AttributeValue.TypeInfo;
67 import org.oic.simulator.AttributeValue.ValueType;
68 import org.oic.simulator.ModelProperty;
69 import org.oic.simulator.SimulatorResourceAttribute;
70 import org.oic.simulator.SimulatorResourceModel;
71 import org.oic.simulator.client.SimulatorRemoteResource.RequestType;
72
73 import oic.simulator.clientcontroller.Activator;
74 import oic.simulator.clientcontroller.remoteresource.AttributeElement;
75 import oic.simulator.clientcontroller.remoteresource.RemoteResource;
76 import oic.simulator.clientcontroller.remoteresource.ResourceRepresentation;
77 import oic.simulator.clientcontroller.utils.Constants;
78 import oic.simulator.clientcontroller.utils.Utility;
79 import oic.simulator.clientcontroller.view.AttributeEditingSupport;
80
81 /**
82  * This dialog is used for generating a PUT request.
83  */
84 public class PutRequestDialog extends TitleAreaDialog {
85
86     private TreeViewer              attViewer;
87     private Combo                   ifTypesCmb;
88
89     private String                  ifType;
90
91     private Map<String, String>     ifTypes;
92
93     private AttributeEditingSupport attributeEditor;
94
95     private ResourceRepresentation  updatedRepresentation;
96
97     private final String[]          attTblHeaders  = { "Name", "Value" };
98     private final Integer[]         attTblColWidth = { 200, 200 };
99
100     public PutRequestDialog(Shell parentShell) {
101         super(parentShell);
102     }
103
104     @Override
105     public void create() {
106         super.create();
107         setTitle("Generate PUT Request");
108         setMessage("Dialog which takes input and generates a put request.");
109     }
110
111     @Override
112     protected Control createDialogArea(Composite parent) {
113         Composite compLayout = (Composite) super.createDialogArea(parent);
114
115         Composite rootContainer = new Composite(compLayout, SWT.NONE);
116         GridLayout layout = new GridLayout();
117         rootContainer.setLayout(layout);
118         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
119         rootContainer.setLayoutData(gd);
120
121         Group paramsGrp = new Group(rootContainer, SWT.NONE);
122         gd = new GridData();
123         gd.horizontalAlignment = SWT.FILL;
124         gd.grabExcessHorizontalSpace = true;
125         gd.minimumHeight = 50;
126         paramsGrp.setLayoutData(gd);
127         layout = new GridLayout(2, false);
128         layout.verticalSpacing = 10;
129         layout.marginTop = 10;
130         paramsGrp.setLayout(layout);
131
132         Label ifTypeLbl = new Label(paramsGrp, SWT.NONE);
133         ifTypeLbl.setText("Interface Type");
134
135         ifTypesCmb = new Combo(paramsGrp, SWT.NULL);
136         gd = new GridData();
137         gd.grabExcessHorizontalSpace = true;
138         gd.horizontalAlignment = SWT.FILL;
139         ifTypesCmb.setLayoutData(gd);
140         ifTypesCmb.addModifyListener(new ModifyListener() {
141             @Override
142             public void modifyText(ModifyEvent e) {
143                 ifType = ifTypesCmb.getText();
144             }
145         });
146
147         RemoteResource resource = Activator.getDefault().getResourceManager()
148                 .getCurrentResourceInSelection();
149
150         // Set the interface types in combo box.
151         Map<String, String> ifTypes = Utility.getResourceInterfaces();
152         this.ifTypes = new HashMap<String, String>();
153         String key;
154         for (Map.Entry<String, String> entry : ifTypes.entrySet()) {
155             key = entry.getValue() + " (" + entry.getKey() + ")";
156             this.ifTypes.put(key, entry.getKey());
157             ifTypesCmb.add(key);
158         }
159
160         // Select the default value to be shown in the interface types combo.
161         Vector<String> ifTypesSupportedByResource = resource
162                 .getRemoteResourceRef().getResourceInterfaces();
163         if (null != ifTypesSupportedByResource) {
164             int index = -1;
165             if (ifTypesSupportedByResource
166                     .contains(Constants.BASELINE_INTERFACE)
167                     && ifTypes.containsKey(Constants.BASELINE_INTERFACE)) {
168                 // Baseline interface is given preference to be shown in the if
169                 // types combo.
170                 String value = ifTypes.get(Constants.BASELINE_INTERFACE);
171                 index = ifTypesCmb.indexOf(value + " ("
172                         + Constants.BASELINE_INTERFACE + ")");
173                 if (index != -1)
174                     ifTypesCmb.select(index);
175             }
176             if (index == -1) {
177                 // Baseline interface is not selected so selecting some other
178                 // interface supported by the resource.
179                 Iterator<String> itr = ifTypesSupportedByResource.iterator();
180                 while (itr.hasNext() && index == -1) {
181                     key = itr.next();
182                     if (ifTypes.containsKey(key)) {
183                         String value = ifTypes.get(key);
184                         index = ifTypesCmb.indexOf(value + " (" + key + ")");
185                         if (index != -1) {
186                             ifTypesCmb.select(index);
187                             break;
188                         }
189                     }
190                 }
191                 if (index == -1 && !ifTypesSupportedByResource.isEmpty()) {
192                     // Resource has custom interfaces.
193                     ifTypesCmb.setText(ifTypesSupportedByResource.get(0));
194                 }
195             }
196         }
197
198         Composite container = new Composite(rootContainer, SWT.NONE);
199         gd = new GridData(SWT.FILL, SWT.FILL, true, true);
200         container.setLayoutData(gd);
201         layout = new GridLayout(1, false);
202         layout.verticalSpacing = 10;
203         layout.marginTop = 10;
204         container.setLayout(layout);
205
206         createTreeViewer(container);
207
208         // Clone the resource model for maintaining a local copy of attributes
209         // for PUT requests.
210         SimulatorResourceModel resourceModel = null;
211         try {
212             resourceModel = (SimulatorResourceModel) Utility
213                     .cloneAttributeValue(
214                             new AttributeValue(resource.getResourceModelRef()))
215                     .get();
216         } catch (Exception e2) {
217         }
218
219         if (null == resourceModel) {
220             // Failed to clone. So taking the base copy and continuing the
221             // operation.
222             resourceModel = resource.getResourceModelRef();
223         }
224
225         updatedRepresentation = new ResourceRepresentation(resourceModel);
226
227         if (resource.isConfigUploaded()) {
228             try {
229                 // Request Type needs to be changed to PUT.
230                 updatedRepresentation.updateAttributeProperties(resource
231                         .getRequestModels().get(RequestType.POST),
232                         resourceModel);
233             } catch (Exception e1) {
234             }
235         }
236
237         attViewer.setInput(updatedRepresentation);
238
239         attViewer.expandAll();
240
241         return compLayout;
242     }
243
244     private void createTreeViewer(Composite parent) {
245         Tree addressTree = new Tree(parent, SWT.SINGLE | SWT.BORDER
246                 | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
247         addressTree.setHeaderVisible(true);
248
249         attViewer = new TreeViewer(addressTree);
250
251         createAttributeColumns(attViewer);
252
253         // make lines and header visible
254         Tree tree = attViewer.getTree();
255         GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true);
256         tree.setLayoutData(gd);
257         tree.setHeaderVisible(true);
258         tree.setLinesVisible(true);
259
260         attViewer.setContentProvider(new AttributeContentProvider());
261         attViewer.setLabelProvider(new AttributeLabelProvider());
262     }
263
264     public void createAttributeColumns(TreeViewer viewer) {
265         Tree tree = viewer.getTree();
266
267         attributeEditor = new AttributeEditingSupport();
268
269         TreeColumn attName = new TreeColumn(tree, SWT.NONE);
270         attName.setWidth(attTblColWidth[0]);
271         attName.setText(attTblHeaders[0]);
272
273         TreeColumn attValue = new TreeColumn(tree, SWT.NONE);
274         attValue.setWidth(attTblColWidth[1]);
275         attValue.setText(attTblHeaders[1]);
276         TreeViewerColumn attValueVwrCol = new TreeViewerColumn(attViewer,
277                 attValue);
278         attValueVwrCol.setEditingSupport(attributeEditor
279                 .createAttributeValueEditor(attViewer, this));
280
281         addMenuItems();
282     }
283
284     private void addMenuItems() {
285         if (null != attViewer) {
286             final Tree resourceTreeHead = attViewer.getTree();
287             if (null != resourceTreeHead) {
288                 // Below code creates menu entries and shows them on right
289                 // clicking a resource
290                 final Menu menu = new Menu(resourceTreeHead);
291                 resourceTreeHead.setMenu(menu);
292                 menu.addMenuListener(new MenuAdapter() {
293                     @Override
294                     public void menuShown(MenuEvent e) {
295                         // Clear existing menu items
296                         MenuItem[] items = menu.getItems();
297                         for (int index = 0; index < items.length; index++) {
298                             items[index].dispose();
299                         }
300
301                         IStructuredSelection selection = ((IStructuredSelection) attViewer
302                                 .getSelection());
303                         final AttributeElement attElement = (AttributeElement) selection
304                                 .getFirstElement();
305                         if (null == attElement) {
306                             return;
307                         }
308
309                         // Check the type of attribute.
310                         SimulatorResourceAttribute attribute = attElement
311                                 .getSimulatorResourceAttribute();
312                         if (null == attribute) {
313                             return;
314                         }
315
316                         AttributeValue value = attribute.value();
317                         if (null == value || null == value.get()) {
318                             return;
319                         }
320
321                         TypeInfo type = value.typeInfo();
322
323                         final Object parent = attElement.getParent();
324
325                         if ((type.mType == ValueType.ARRAY
326                                 && type.mBaseType == ValueType.RESOURCEMODEL && type.mDepth == 1)
327                                 && (null == parent || parent instanceof ResourceRepresentation)) {
328                             addMenuToOneDimensionalTopLevelModelAttributes(menu);
329                             return;
330                         }
331
332                         if (null != parent
333                                 && !(parent instanceof ResourceRepresentation)) {
334                             Object grandParent = ((AttributeElement) parent)
335                                     .getParent();
336                             if (null == grandParent
337                                     || grandParent instanceof ResourceRepresentation) {
338                                 AttributeElement parentElement = (AttributeElement) parent;
339
340                                 // Check the type of attribute.
341                                 SimulatorResourceAttribute parentAttribute = parentElement
342                                         .getSimulatorResourceAttribute();
343                                 if (null != parentAttribute
344                                         && null != parentAttribute.value()
345                                         && null != parentAttribute.value()
346                                                 .get()) {
347                                     AttributeValue parentValue = parentAttribute
348                                             .value();
349
350                                     TypeInfo parentType = parentValue
351                                             .typeInfo();
352                                     if (parentType.mType == ValueType.ARRAY
353                                             && parentType.mBaseType == ValueType.RESOURCEMODEL
354                                             && parentType.mDepth == 1) {
355                                         addDeleteMenuToArrayItemsOfOneDimensionalModelAttribute(
356                                                 menu, attElement, parentElement);
357                                         return;
358                                     }
359                                 }
360                             }
361                         }
362                     }
363                 });
364             }
365         }
366     }
367
368     private void addMenuToOneDimensionalTopLevelModelAttributes(Menu menu) {
369         // Menu to add items to the array.
370         MenuItem addItems = new MenuItem(menu, SWT.NONE);
371         addItems.setText("Add Items");
372         addItems.addSelectionListener(new SelectionAdapter() {
373             @Override
374             public void widgetSelected(SelectionEvent e) {
375                 // Get the attributes.
376                 ResourceRepresentation representation;
377                 representation = getRepresentationForOneDimensionTopLevelAttribute();
378                 if (null == representation) {
379                     MessageDialog
380                             .openError(Display.getDefault().getActiveShell(),
381                                     "Unable to perform the operation.",
382                                     "Failed to obtain the required data. Operation cannot be performed.");
383                 } else {
384                     ModelArrayAddItemDialog dialog = new ModelArrayAddItemDialog(
385                             Display.getDefault().getActiveShell(),
386                             PutRequestDialog.this, representation);
387                     if (Window.OK == dialog.open()) {
388                         // Add the new item to the local resource
389                         // representation.
390                         AttributeElement newElement = (AttributeElement) representation
391                                 .getAttributes().values().toArray()[0];
392                         SimulatorResourceAttribute newAttribute = newElement
393                                 .getSimulatorResourceAttribute();
394                         SimulatorResourceModel newModel = (SimulatorResourceModel) newAttribute
395                                 .value().get();
396
397                         AttributeElement attElement = getSelectedElement();
398                         SimulatorResourceAttribute attribute = attElement
399                                 .getSimulatorResourceAttribute();
400                         SimulatorResourceModel[] modelArray = (SimulatorResourceModel[]) attribute
401                                 .value().get();
402                         SimulatorResourceModel[] newModelArray = new SimulatorResourceModel[modelArray.length + 1];
403
404                         int i;
405                         for (i = 0; i < modelArray.length; i++) {
406                             newModelArray[i] = modelArray[i];
407                         }
408                         newModelArray[i] = newModel;
409
410                         AttributeValue newValue = new AttributeValue(
411                                 newModelArray);
412
413                         newAttribute.setValue(newValue);
414
415                         newAttribute.setProperty(attribute.property());
416
417                         attribute.setValue(newValue);
418
419                         attElement.update(newAttribute);
420
421                         attViewer.refresh(attElement);
422
423                         attViewer.expandAll();
424                     }
425                 }
426             }
427         });
428     }
429
430     private void addDeleteMenuToArrayItemsOfOneDimensionalModelAttribute(
431             final Menu menu, final AttributeElement elementToDelete,
432             final AttributeElement parentElement) {
433         // Menu to add items to the array.
434         MenuItem addItems = new MenuItem(menu, SWT.NONE);
435         addItems.setText("Delete Item");
436         addItems.addSelectionListener(new SelectionAdapter() {
437             @Override
438             public void widgetSelected(SelectionEvent e) {
439                 MessageBox dialog = new MessageBox(menu.getShell(),
440                         SWT.ICON_QUESTION | SWT.OK | SWT.CANCEL);
441                 dialog.setText("Confirm action");
442                 dialog.setMessage("Do you want to delete this item from the array?");
443                 int retval = dialog.open();
444                 if (retval != SWT.OK) {
445                     return;
446                 }
447
448                 // Removing the element from the attribute value.
449                 SimulatorResourceAttribute parentSRA = parentElement
450                         .getSimulatorResourceAttribute();
451                 AttributeValue value = parentSRA.value();
452                 SimulatorResourceModel[] modelArray = (SimulatorResourceModel[]) value
453                         .get();
454
455                 String elementIndexName = elementToDelete
456                         .getSimulatorResourceAttribute().name();
457                 int elementIndex = Integer.parseInt(elementIndexName.substring(
458                         elementIndexName.indexOf('[') + 1,
459                         elementIndexName.indexOf(']')));
460
461                 SimulatorResourceModel[] newModelArray = new SimulatorResourceModel[modelArray.length - 1];
462                 int sIndex = 0, dIndex = 0;
463                 for (SimulatorResourceModel model : modelArray) {
464                     if (sIndex != elementIndex)
465                         newModelArray[dIndex++] = model;
466                     sIndex++;
467                 }
468
469                 // Setting the new model array in the attribute.
470                 AttributeValue newValue = new AttributeValue(newModelArray);
471                 parentSRA.setValue(newValue);
472
473                 // Removing the element from the child map.
474                 Map<String, AttributeElement> elements = parentElement
475                         .getChildren();
476                 List<AttributeElement> attElementList = new ArrayList<AttributeElement>();
477                 attElementList.addAll(elements.values());
478                 Collections.sort(attElementList, Utility.attributeComparator);
479
480                 // Renaming the index of the elements.
481                 AttributeElement[] attElementArray = attElementList
482                         .toArray(new AttributeElement[0]);
483                 boolean deleted = false;
484                 int index, newIndex;
485                 for (index = 0, newIndex = 0; index < attElementArray.length; index++) {
486                     if (index == elementIndex) {
487                         elements.remove(elementIndexName);
488                         deleted = true;
489                     } else {
490                         if (deleted) {
491                             AttributeElement element = attElementArray[index];
492                             String curIndexStr = "[" + index + "]";
493                             String newIndexStr = "[" + newIndex + "]";
494
495                             element.getSimulatorResourceAttribute().setName(
496                                     newIndexStr);
497
498                             elements.remove(curIndexStr);
499                             elements.put(newIndexStr, element);
500                         }
501                         newIndex++;
502                     }
503                 }
504
505                 attViewer.refresh(parentElement);
506             }
507         });
508     }
509
510     private ResourceRepresentation getRepresentationForOneDimensionTopLevelAttribute() {
511         ResourceRepresentation representation = null;
512
513         AttributeValue value = null;
514         ModelProperty property = null;
515
516         AttributeElement element = getSelectedElement();
517         if (null == element)
518             return null;
519
520         SimulatorResourceAttribute modelArrayAtt = element
521                 .getSimulatorResourceAttribute();
522         if (null == modelArrayAtt) {
523             return null;
524         }
525
526         AttributeValue attValue = modelArrayAtt.value();
527         if (null == attValue) {
528             return null;
529         }
530
531         TypeInfo type = attValue.typeInfo();
532
533         if (!(type.mType == ValueType.ARRAY
534                 && type.mBaseType == ValueType.RESOURCEMODEL && type.mDepth == 1)) {
535             return null;
536         }
537
538         SimulatorResourceModel[] modelValue = (SimulatorResourceModel[]) attValue
539                 .get();
540         if (null == modelValue || modelValue.length < 0) {
541             return null;
542         }
543
544         // Clone an instance of model value.
545         try {
546             value = Utility.cloneAttributeValue(new AttributeValue(
547                     modelValue[0]));
548         } catch (Exception e) {
549             return null;
550         }
551
552         if (null == value) {
553             return null;
554         }
555
556         // Get the model property of the model value instance.
557         AttributeProperty attProperty = modelArrayAtt.property();
558         if (null != attProperty && attProperty instanceof ArrayProperty) {
559             ArrayProperty prop = attProperty.asArray();
560             if (null != prop) {
561                 AttributeProperty elementProperty = prop.getElementProperty();
562                 if (null != elementProperty && elementProperty.isModel()) {
563                     property = elementProperty.asModel();
564                 }
565             }
566         }
567
568         SimulatorResourceAttribute attribute = new SimulatorResourceAttribute(
569                 modelArrayAtt.name(), value, property);
570         Map<String, SimulatorResourceAttribute> attributes = new HashMap<String, SimulatorResourceAttribute>();
571         attributes.put(modelArrayAtt.name(), attribute);
572         representation = new ResourceRepresentation(attributes, false);
573
574         return representation;
575     }
576
577     private AttributeElement getSelectedElement() {
578         IStructuredSelection selection = (IStructuredSelection) attViewer
579                 .getSelection();
580         if (null == selection) {
581             return null;
582         }
583
584         Object obj = selection.getFirstElement();
585         if (null == obj) {
586             return null;
587         }
588
589         Tree t = attViewer.getTree();
590         TreeItem item = t.getSelection()[0];
591         if (null == item) {
592             return null;
593         }
594
595         if (!(item.getData() instanceof AttributeElement)) {
596             return null;
597         }
598
599         return (AttributeElement) item.getData();
600     }
601
602     class AttributeContentProvider implements ITreeContentProvider {
603
604         @Override
605         public void dispose() {
606         }
607
608         @Override
609         public void inputChanged(Viewer viewer, Object oldAttribute,
610                 Object newAttribute) {
611         }
612
613         @Override
614         public Object[] getChildren(Object attribute) {
615             if (attribute instanceof AttributeElement) {
616                 List<AttributeElement> attElementList = new ArrayList<AttributeElement>();
617                 attElementList.addAll(((AttributeElement) attribute)
618                         .getChildren().values());
619                 Collections.sort(attElementList, Utility.attributeComparator);
620                 return attElementList.toArray();
621             }
622
623             return new Object[0];
624         }
625
626         @Override
627         public Object getParent(Object attribute) {
628             if (attribute instanceof AttributeElement)
629                 return ((AttributeElement) attribute).getParent();
630             return null;
631         }
632
633         @Override
634         public boolean hasChildren(Object attribute) {
635             if (attribute instanceof AttributeElement)
636                 return ((AttributeElement) attribute).hasChildren();
637             return false;
638         }
639
640         @Override
641         public Object[] getElements(Object resourceModel) {
642             if (resourceModel instanceof ResourceRepresentation) {
643                 return ((ResourceRepresentation) resourceModel).getAttributes()
644                         .values().toArray();
645             }
646
647             return new Object[0];
648         }
649     }
650
651     class AttributeLabelProvider implements ITableLabelProvider {
652
653         @Override
654         public void addListener(ILabelProviderListener arg0) {
655         }
656
657         @Override
658         public void dispose() {
659         }
660
661         @Override
662         public boolean isLabelProperty(Object arg0, String arg1) {
663             return false;
664         }
665
666         @Override
667         public void removeListener(ILabelProviderListener arg0) {
668
669         }
670
671         @Override
672         public Image getColumnImage(Object element, int col) {
673             return null;
674         }
675
676         @Override
677         public String getColumnText(Object element, int column) {
678             if (element instanceof AttributeElement) {
679                 AttributeElement attrElement = (AttributeElement) element;
680                 switch (column) {
681                     case 0: // Attribute name column
682                     {
683                         SimulatorResourceAttribute attribute = attrElement
684                                 .getSimulatorResourceAttribute();
685                         return attribute.name();
686                     }
687
688                     case 1: // Attribute value column
689                     {
690                         SimulatorResourceAttribute attribute = attrElement
691                                 .getSimulatorResourceAttribute();
692
693                         if (attribute.value().typeInfo().mBaseType != ValueType.RESOURCEMODEL) {
694                             String value = Utility
695                                     .getAttributeValueAsString(attribute
696                                             .value());
697                             if (null == value) {
698                                 value = "";
699                             }
700                             return value;
701                         }
702                         return null;
703                     }
704                 }
705             }
706             return null;
707         }
708     }
709
710     @Override
711     protected boolean isResizable() {
712         return true;
713     }
714
715     @Override
716     public boolean isHelpAvailable() {
717         return false;
718     }
719
720     @Override
721     protected Button createButton(Composite parent, int id, String label,
722             boolean defaultButton) {
723         if (id == IDialogConstants.OK_ID) {
724             label = "PUT";
725         }
726         return super.createButton(parent, id, label, defaultButton);
727     }
728
729     public ResourceRepresentation getUpdatedRepresentation() {
730         return updatedRepresentation;
731     }
732
733     public String getIfType() {
734         if (ifTypes.containsKey(ifType)) {
735             return ifTypes.get(ifType);
736         }
737         return ifType;
738     }
739
740 }