Пример #1
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="args"></param>
		private void CreatePolicySetFromDocument( object sender, EventArgs args )
		{
			PolicyDocument policyDocumentNode = (PolicyDocument)mainTree.SelectedNode;
			pol.PolicyDocumentReadWrite policyDoc = policyDocumentNode.PolicyDocumentDefinition;

			// Create a new policy
			pol.PolicySetElementReadWrite newPolicySet = new pol.PolicySetElementReadWrite( 
				"urn:newpolicy", "[TODO: add a description]", 
				null, 
				new ArrayList(), 
				PolicyCombiningAlgorithms.FirstApplicable, 
				new pol.ObligationReadWriteCollection(), 
				null,
				XacmlVersion.Version11 ); //TODO: check version

			policyDoc.PolicySet = newPolicySet;

			// Create a new node.
			PolicySet newPolicySetNode = new PolicySet( newPolicySet );

			// Add the tree node.
			policyDocumentNode.Nodes.Add( newPolicySetNode );

			// Set the font so the user knows the item was changed
			newPolicySetNode.NodeFont = new Font( mainTree.Font, FontStyle.Bold );
		}
Пример #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void mainTree_BeforeSelect(object sender, TreeViewCancelEventArgs e)
		{
			// Check if the control have been modified
			if( mainPanel.Controls.Count != 0 )
			{
				if( !(mainPanel.Controls[0] is XmlViewer) )
				{
					BaseControl baseControl = mainPanel.Controls[0] as BaseControl;

					mainTree.SelectedNode.NodeFont = new Font( mainTree.Font, FontStyle.Regular );
					NoBoldNode oNode = null;
					if( baseControl is CustomControls.PolicySet )
					{
						oNode = new PolicySet(((CustomControls.PolicySet)baseControl).PolicySetElement);
					}
					else if( baseControl is CustomControls.PolicySet )
					{
						oNode = new Policy(((CustomControls.Policy)baseControl).PolicyElement);
					}
					else if( baseControl is CustomControls.Rule )
					{
						oNode = new Rule(((CustomControls.Rule)baseControl).RuleElement);
					}
					else if( baseControl is CustomControls.TargetItem )
					{
						pol.TargetItemBaseReadWrite element = ((CustomControls.TargetItem)baseControl).TargetItemBaseElement;
						oNode = new TargetItem(element);
					}
					else if( baseControl is CustomControls.Obligations )
					{
						oNode = new Obligations(((CustomControls.Obligations)baseControl).ObligationsElement);
					}
					else if( baseControl is ContextCustomControls.Attribute )
					{
						oNode = new Attribute( ((ContextCustomControls.Attribute)baseControl).AttributeElement );
					}
					else if( baseControl is ContextCustomControls.Resource )
					{
						oNode = new Resource( ((ContextCustomControls.Resource)baseControl).ResourceElement );
					}
				
					if( oNode != null )
					{
						mainTree.SelectedNode = oNode;
						mainTree.SelectedNode.Text = oNode.Text;
					}
				}
			}
		}