private void AddFileTypeRow(ActionFileTypeObject fileType)
        {
            //TODO: we shouldn't have our own file type enumeration in the policy designer!
            try
            {
                ListViewItem item = new ListViewItem(FileTypeBridge.GetFileType(fileType.Filetype));
                item.Tag = fileType.Identifier;
                fileTypesListView.Items.Add(item);
            }
            catch(ArgumentException ex)
            {
                ErrorMessage errorMessage = new ErrorMessage(
                    "FILETYPE_UNSUPPORTED", "Workshare.PolicyDesigner.Properties.Resources", 
                    Assembly.GetExecutingAssembly());
				Logger.LogError(errorMessage.LogString);
				throw new PolicyDesignerException(errorMessage.DisplayString, ex);
            }
        }
 private void AddBaseFileTypes(ref ActionObjectDefinition aoDef)
 {
     ISupportedFilesSet fileTypes = GetSupportedFileCollectionSettingFromResourceActionForType(aoDef.Type);
     if (fileTypes != null)
     {
         foreach (string type in fileTypes.SupportedFiles())
         {
             ActionFileTypeObject aft = new ActionFileTypeObject();
             aft.Identifier = Guid.NewGuid();
             aft.Filetype = FileTypeBridge.GetFileType(type);
             aft.Apply = true;
             aoDef.FileTypes[type] = aft;
         }
     }
 }
        private void LoadForEdit()
        {
            try
            {
                IResourceAction resourceAction = AddActionState.GetResourcesForAction(m_resourceManager, InitialAction);
                string type = InitialAction[LanguageItemKeys.TYPE].Value;
				if ( (null == resourceAction) || (string.IsNullOrEmpty(type)) )
				{
					ShowEditActionNotInstalledMessageBox(InitialAction.Name.Value);
					ExitForm();
					return;
				}

				ActionObjectDefinition aoDef = new ActionObjectDefinition(type);
                aoDef.AssemblyName = InitialAction.Assembly;
                aoDef.ClassName = InitialAction.Class;
				aoDef.ActionName = InitialAction.Name.Value;
                aoDef.Precedence = InitialAction.Precedence;
                aoDef.RunAt = InitialAction.RunAt;
                //TODO: we shouldn't be reading from the resourceAction as this may have changed since the action was created.
                //However, Steve C says do it this way for now.
                aoDef.AllowTransparent =  m_allowTransparent && resourceAction.AllowTransparent;
                aoDef.PropertySetLayout = resourceAction.PropertySetLayout;
                aoDef.CustomDataTypeUIHandler = resourceAction.CustomDataTypeUI;

                bool updateCheckBoxAtStart = ActionHasSelectAllCheckBox(aoDef);
                bool resetValueSelectAll = true;
                bool resetOverrideSelectAll = true;
                bool resetVisibleSelectAll = true;

                foreach (IDataElement property in InitialAction.DataElements)
                {
                    // Supported File Types is added in as a property but we don't
                    // want to retrieve it here as one. The same applies to 'Transparent'
                    if (property.Name.Value == "SupportedFileTypes" ||
                        property.Name.Value == "NonSupportedFileTypes" ||
                        property.Name.Value == LanguageItemKeys.TRANSPARENT)
                        continue;

                    if (0 == string.Compare("EXECUTE", property.Name.Value, StringComparison.InvariantCultureIgnoreCase))
                    {
                        bool executePropValue = (bool)((IDataItem)property.Data).Value;
                        bool allowOverride = property["allowoverride"].Value.ToLower(CultureInfo.InvariantCulture) == "true";

                        if (allowOverride)
                        {
                            aoDef.ExecutionOption = executePropValue ? ExecutionOption.OverridableDefaultTrue : ExecutionOption.OverridableDefaultFalse;
                        }
                        else
                        {
                            aoDef.ExecutionOption = ExecutionOption.AlwaysExecute;
                        }
                        continue;
                    }

                    ActionDataElement ade = new ActionDataElement();
                   
                    ade.ShowInUI = ShowPropertyInUIForType(aoDef.Type, property.Name.Value);

                    if (property["icustomdatatypehandler"].Value.ToString() != "")
                    {
                        ade.IsCustomDisplayType = true;
                    }
                    if (property["allowoverride"].Value.ToLower(CultureInfo.InvariantCulture) == "true")
                    {
                        ade.Override = true;
                    }
                    else
                    {
                        ade.Override = false;
                        if (ade.ShowInUI)
                            resetOverrideSelectAll = false;
                    }

                    if (property["visible"].Value.ToLower(CultureInfo.InvariantCulture) == "true")
                    {
                        ade.Visible = true;
                    }
                    else
                    {
                        ade.Visible = false;
                        if (ade.ShowInUI)
                            resetVisibleSelectAll = false;
                    }

                    if (property["iscustomproperty"].Value.ToLower(CultureInfo.InvariantCulture) == "true")
                    {
                        ade.IsCustomProperty = true;
                    }


                    // If the property is a data source then it is assumed to be
                    // a system property
                    if (property.Data is IDataSource)
                    {
                        IDataSource dataSource = property.Data as IDataSource;
                        ade.IsSystemProperty = true;
                        ade.IsDataSource = true;
                        ISystemProperty systemProperty = ResourceManagerFactory.CreateSystemProperty(dataSource.Assembly,
                                                                            typeof(object),
                                                                            dataSource.Class,
                                                                            dataSource.Method.Name.Value,
                                                                            String.Empty // Description - not being populated yet
                                                                            );

                        ade.MappedSystemProperty = systemProperty;
                    }

                    switch (property.Type)
                    {
                        case DataType.String:
                            foreach (IResourceActionProperty rap in resourceAction.Properties)
                            {
                                if (rap.Name == property.Name.Value)
                                    ade.IsCustomDisplayType = rap.DisplayType == PropertyDisplayType.CustomUI;
                            }
                            ade.Value = ((IDataItem)property.Data).Value;
                            break;
                        case DataType.Boolean:
                            {
                                ade.Value = (bool)((IDataItem)property.Data).Value;
                                if ((bool)ade.Value == false && ade.ShowInUI)
                                    resetValueSelectAll = false;
                            }
                            break;
                        case DataType.DateTime:
                            {
                                ade.Value = (DateTime)((IDataItem)property.Data).Value;
                                break;
                            }
                        case DataType.Object:
                            ade.Value = property.Data;
                            break;
                        case DataType.StringArray:
                            ade.Value = ConversionUtils.PolicyObjectModelStringArrayToStringArray(property.Data as IPolicyObjectCollection<IDataItem>);
                            break;
                        default:
                            ShowUnsupportedTypeMessageBox();
                            throw new PolicyDesignerException("Unsupported data element type");
                    }
                    ade.Identifier = property.Identifier;
                    ade.Name = property.Name.Value;
                    ade.DisplayName = property.DisplayName.Value;
                    aoDef.ActionProperties[property.Identifier] = ade;
                }

                if (InitialAction.Filetypes.Count == 0)
                    AddBaseFileTypes(ref aoDef);
                else
                {
                    foreach (IActionFiletype ftype in InitialAction.Filetypes)
                    {
                        ActionFileTypeObject aft = new ActionFileTypeObject();
                        aft.Apply = ftype.Apply;
                        aft.Filetype = ftype.Type;
                        aft.Identifier = ftype.Identifier;
                        aoDef.FileTypes[FileTypeBridge.GetFileType(aft.Filetype)] = aft;
                    }
                }

				m_baseAction = aoDef.Type;
                m_actions[m_baseAction] = aoDef;
                
                comboBoxActions.Items.Add(new ActionUIItem(GetResourceActionForType(m_baseAction)));
                comboBoxActions.SelectedIndex = 0;

                InitMyNameControl(InitialAction.Name.Value);
                m_override = InitialAction.Override;
                
                Text = Properties.Resources.ACTION_EDIT;
                cbProcessTransparently.Checked = Transparent;
                //cbAutoExpand.Checked = AutoExpand;
                PopulateExecutionOptionControl();

                if (updateCheckBoxAtStart)
                {
                    SetSelectAllCheckBox(actionOptionsListView.Columns.IndexOf(columnValue), resetValueSelectAll);
                    SetSelectAllCheckBox(actionOptionsListView.Columns.IndexOf(columnOverride), resetOverrideSelectAll);
                    SetSelectAllCheckBox(actionOptionsListView.Columns.IndexOf(columnVisible), resetVisibleSelectAll);
                }
            }
            catch (PolicyDesignerException)
            {
                DialogResult = DialogResult.Cancel;
                Close();
            }
        }