public void Init(DocObject[] path, DocProject docProject)
{
TabPage tabpageExist = this.tabControl.SelectedTab;
this.tabControl.TabPages.Clear();
this.panelIdentityIcon.Visible = false;
this.m_path = path;
if (this.m_path == null)
{
return;
}
this.m_loadall = true;
try
{
this.m_target = path[path.Length - 1];
if (path.Length > 1)
{
this.m_parent = path[path.Length - 2];
}
this.m_project = docProject;
this.m_map = new Dictionary<string, DocObject>();
DocObject docObject = this.m_target;
this.toolStripButtonTranslationRemove.Enabled = false;
// build map
foreach (DocSection docSection in this.m_project.Sections)
{
foreach (DocSchema docSchema in docSection.Schemas)
{
foreach (DocEntity docEntity in docSchema.Entities)
{
if (!this.m_map.ContainsKey(docEntity.Name))
{
this.m_map.Add(docEntity.Name, docEntity);
}
}
foreach (DocType docType in docSchema.Types)
{
if (!this.m_map.ContainsKey(docType.Name))
{
this.m_map.Add(docType.Name, docType);
}
}
}
}
// General pages applies to all definitions
this.tabControl.TabPages.Add(this.tabPageGeneral);
this.textBoxGeneralName.Enabled = false;
this.textBoxGeneralName.Text = docObject.Name;
this.textBoxGeneralDescription.Text = docObject.Documentation;
this.listViewLocale.Items.Clear();
foreach (DocLocalization docLocal in docObject.Localization)
{
ListViewItem lvi = new ListViewItem();
lvi.Tag = docLocal;
lvi.Text = docLocal.Locale;
lvi.SubItems.Add(docLocal.Name);
lvi.SubItems.Add(docLocal.Documentation);
this.listViewLocale.Items.Add(lvi);
}
this.tabControl.TabPages.Add(this.tabPageIdentity);
this.textBoxIdentityUuid.Text = docObject.Uuid.ToString();
this.textBoxIdentityCode.Text = docObject.Code;
this.textBoxIdentityVersion.Text = docObject.Version;
this.comboBoxIdentityStatus.Text = docObject.Status;
this.textBoxIdentityAuthor.Text = docObject.Author;
this.textBoxIdentityOwner.Text = docObject.Owner;
this.textBoxIdentityCopyright.Text = docObject.Copyright;
if (docObject is DocModelView)
{
this.tabControl.TabPages.Add(this.tabPageView);
DocModelView docView = (DocModelView)docObject;
this.checkBoxViewIncludeAll.Checked = docView.IncludeAllDefinitions;
this.textBoxViewRoot.Text = docView.RootEntity;
if (docView.BaseView != null)
{
this.textBoxViewBase.Text = docView.BaseView;
try
{
Guid guidView = new Guid(docView.BaseView);
DocModelView docViewBase = this.m_project.GetView(guidView);
if (docViewBase != null)
{
this.textBoxViewBase.Text = docViewBase.Name;
}
}
catch
{
}
}
else
{
this.textBoxViewBase.Text = string.Empty;
}
this.textBoxViewXsdNamespace.Text = docView.XsdUri;
if (docView.XsdFormats != null)
{
foreach (DocXsdFormat docFormat in docView.XsdFormats)
{
ListViewItem lvi = new ListViewItem();
lvi.Tag = docFormat;
lvi.Text = docFormat.Entity;
lvi.SubItems.Add(docFormat.Attribute);
lvi.SubItems.Add(docFormat.XsdFormat.ToString());
lvi.SubItems.Add(docFormat.XsdTagless.ToString());
this.listViewViewXsd.Items.Add(lvi);
}
}
this.panelIdentityIcon.Visible = true;
if (docView.Icon != null)
{
try
{
this.panelIcon.BackgroundImage = Image.FromStream(new System.IO.MemoryStream(docView.Icon));
}
catch
{
}
}
else
{
this.panelIcon.BackgroundImage = null;
}
}
else if (docObject is DocExchangeDefinition)
{
this.tabControl.TabPages.Add(this.tabPageExchange);
DocExchangeDefinition docExchange = (DocExchangeDefinition)docObject;
this.checkBoxExchangeImport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Import) != 0);
this.checkBoxExchangeExport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Export) != 0);
this.panelIdentityIcon.Visible = true;
if (docExchange.Icon != null)
{
try
{
this.panelIcon.BackgroundImage = Image.FromStream(new System.IO.MemoryStream(docExchange.Icon));
}
catch
{
}
}
else
{
this.panelIcon.BackgroundImage = null;
}
this.comboBoxExchangeClassProcess.Text = docExchange.ExchangeClass;
this.comboBoxExchangeClassSender.Text = docExchange.SenderClass;
this.comboBoxExchangeClassReceiver.Text = docExchange.ReceiverClass;
}
else if (docObject is DocTemplateDefinition)
{
this.tabControl.TabPages.Add(this.tabPageTemplate);
DocTemplateDefinition docTemplate = (DocTemplateDefinition)docObject;
this.tabControl.TabPages.Add(this.tabPageOperations);
this.tabControl.TabPages.Add(this.tabPageUsage);
this.listViewUsage.Items.Clear();
// usage from other templates
foreach (DocTemplateDefinition docTemp in this.m_project.Templates)
{
InitUsageFromTemplate(docTemp, docTemplate);
}
// usage from model views
foreach (DocModelView docView in this.m_project.ModelViews)
{
foreach (DocConceptRoot docRoot in docView.ConceptRoots)
{
foreach (DocTemplateUsage docUsage in docRoot.Concepts)
{
if (docUsage.Definition == docTemplate)
{
DocObject[] usagepath = new DocObject[] { docRoot.ApplicableEntity, docRoot, docUsage };
ListViewItem lvi = new ListViewItem();
lvi.Tag = usagepath;
lvi.Text = docView.Name;
lvi.SubItems.Add(docRoot.ApplicableEntity.Name);
this.listViewUsage.Items.Add(lvi);
}
}
}
}
this.ctlRules.Project = this.m_project;
this.ctlRules.BaseTemplate = this.m_parent as DocTemplateDefinition;
this.ctlRules.Template = docTemplate;
this.ctlOperators.Project = this.m_project;
this.ctlOperators.Template = docTemplate;
this.ctlOperators.Rule = null;
}
else if (docObject is DocConceptRoot)
{
this.tabPageConcept.Text = "Applicability";
this.tabControl.TabPages.Add(this.tabPageConcept);
this.tabControl.TabPages.Add(this.tabPageConceptRoot);
DocConceptRoot docRoot = (DocConceptRoot)docObject;
this.ctlParameters.Project = this.m_project;
this.ctlParameters.ConceptRoot = docRoot;
this.ctlParameters.ConceptItem = this.ctlParameters.ConceptRoot;
this.ctlParameters.ConceptLeaf = null;
//DocEntity docEntity = (DocEntity)this.m_parent;
DocEntity docEntity = docRoot.ApplicableEntity;
DocModelView docView = null;
foreach (DocModelView docViewEach in this.m_project.ModelViews)
{
if (docViewEach.ConceptRoots.Contains(docRoot))
{
docView = docViewEach;
break;
}
}
DocModelView[] listViews = docProject.GetViewInheritance(docView); ;
// find all inherited concepts
List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>();
Dictionary<DocTemplateDefinition, DocEntity> mapTemplate = new Dictionary<DocTemplateDefinition, DocEntity>();
Dictionary<DocTemplateDefinition, DocModelView> mapView = new Dictionary<DocTemplateDefinition, DocModelView>();
while (docEntity != null)
{
foreach (DocModelView docSuperView in listViews)
{
foreach (DocConceptRoot docRootEach in docSuperView.ConceptRoots)
{
if (docRootEach.ApplicableEntity == docEntity)
{
foreach (DocTemplateUsage docConcept in docRootEach.Concepts)
{
if (docConcept.Definition != null)
{
if (listTemplate.Contains(docConcept.Definition))
{
listTemplate.Remove(docConcept.Definition);
}
listTemplate.Insert(0, docConcept.Definition);
mapTemplate[docConcept.Definition] = docEntity;
mapView[docConcept.Definition] = docSuperView;
}
}
}
}
}
// recurse upwards
docEntity = this.m_project.GetDefinition(docEntity.BaseDefinition) as DocEntity;
}
this.listViewConceptRoot.Items.Clear();
foreach (DocTemplateDefinition dtd in listTemplate)
{
ListViewItem lvi = new ListViewItem();
lvi.Tag = dtd;
lvi.Text = dtd.Name;
DocEntity docTemplateEntity = mapTemplate[dtd];
lvi.SubItems.Add(docTemplateEntity.Name);
DocModelView docTemplateView = mapView[dtd];
lvi.SubItems.Add(docTemplateView.Name);
// find local override if any
lvi.ImageIndex = 3;
foreach (DocTemplateUsage docConcept in docRoot.Concepts)
{
if (docConcept.Definition == dtd)
{
UpdateConceptInheritance(lvi, docConcept);
break;
}
}
this.listViewConceptRoot.Items.Add(lvi);
}
}
else if (docObject is DocTemplateUsage)
{
this.tabPageConcept.Text = "Concept";
this.tabControl.TabPages.Add(this.tabPageConcept);
this.tabControl.TabPages.Add(this.tabPageRequirements);
DocTemplateUsage docUsage = (DocTemplateUsage)docObject;
this.ctlParameters.Project = this.m_project;
this.ctlParameters.ConceptRoot = this.m_path[3] as DocConceptRoot;
this.ctlParameters.ConceptItem = this.ctlParameters.ConceptRoot;
this.ctlParameters.ConceptLeaf = docUsage;
this.LoadModelView();
}
else if (docObject is DocSchema)
{
DocSchema docSchema = (DocSchema)docObject;
}
else if (docObject is DocEntity)
{
DocEntity docEntity = (DocEntity)docObject;
this.tabControl.TabPages.Add(this.tabPageEntity);
this.textBoxEntityBase.Text = docEntity.BaseDefinition;
this.checkBoxEntityAbstract.Checked = docEntity.IsAbstract();
}
else if (docObject is DocDefined)
{
DocDefined docDefined = (DocDefined)docObject;
this.textBoxAttributeType.Text = docDefined.DefinedType;
this.tabControl.TabPages.Add(this.tabPageAttribute);
this.labelAttributeInverse.Visible = false;
this.textBoxAttributeInverse.Visible = false;
this.buttonAttributeInverse.Visible = false;
this.checkBoxAttributeOptional.Visible = false;
this.checkBoxXsdTagless.Visible = false;
this.labelAttributeXsdFormat.Visible = false;
this.comboBoxAttributeXsdFormat.Visible = false;
this.LoadAttributeCardinality();
}
else if (docObject is DocAttribute)
{
DocAttribute docAttribute = (DocAttribute)docObject;
this.tabControl.TabPages.Add(this.tabPageAttribute);
this.textBoxAttributeType.Text = docAttribute.DefinedType;
this.textBoxAttributeInverse.Text = docAttribute.Inverse;
this.textBoxAttributeDerived.Text = docAttribute.Derived;
this.checkBoxAttributeOptional.Checked = docAttribute.IsOptional;
if (docAttribute.XsdTagless != null)
{
if (docAttribute.XsdTagless == true)
{
this.checkBoxXsdTagless.CheckState = CheckState.Checked;
}
else
{
this.checkBoxXsdTagless.CheckState = CheckState.Unchecked;
}
}
else
{
this.checkBoxXsdTagless.CheckState = CheckState.Indeterminate;
}
this.comboBoxAttributeXsdFormat.SelectedItem = docAttribute.XsdFormat.ToString();
this.LoadAttributeCardinality();
}
else if (docObject is DocConstraint)
{
DocConstraint docConstraint = (DocConstraint)docObject;
this.tabControl.TabPages.Add(this.tabPageExpression);
this.textBoxExpression.Text = docConstraint.Expression;
}
else if (docObject is DocPropertySet)
{
this.tabControl.TabPages.Add(this.tabPagePropertySet);
DocPropertySet docPset = (DocPropertySet)docObject;
this.LoadApplicability();
this.comboBoxPsetType.Text = docPset.PropertySetType;
}
else if (docObject is DocProperty)
{
this.tabControl.TabPages.Add(this.tabPageProperty);
DocProperty docProp = (DocProperty)docObject;
// backward compatibility:
string secondary = docProp.SecondaryDataType;
if (!String.IsNullOrEmpty(secondary))
{
string[] enumhost = secondary.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (enumhost.Length == 2)
{
secondary = enumhost[0];
docProp.SecondaryDataType = secondary; // update data underneath for future consistency
}
}
this.comboBoxPropertyType.Text = docProp.PropertyType.ToString();
this.LoadPropertyType();
}
else if (docObject is DocQuantitySet)
{
this.tabControl.TabPages.Add(this.tabPagePropertySet);
this.LoadApplicability();
this.comboBoxPsetType.Enabled = false;
}
else if (docObject is DocQuantity)
{
this.tabControl.TabPages.Add(this.tabPageQuantity);
DocQuantity docProp = (DocQuantity)docObject;
this.comboBoxQuantityType.Text = docProp.QuantityType.ToString();
}
else if (docObject is DocExample)
{
this.tabControl.TabPages.Add(this.tabPageExample); //
this.tabControl.TabPages.Add(this.tabPageViews); // applicable views
this.tabControl.TabPages.Add(this.tabPagePropertySet); // applicable entities
this.LoadApplicability();
this.comboBoxPsetType.Enabled = false;
this.buttonApplicabilityAddTemplate.Visible = true;
DocExample docExample = (DocExample)docObject;
if (docExample.File != null)
{
this.textBoxExample.Text = Encoding.ASCII.GetString(docExample.File);
this.toolStripButtonExampleClear.Enabled = true;
this.textBoxExample.ReadOnly = false;
this.textBoxExample.Focus();
}
else
{
this.textBoxExample.Text = String.Empty;
this.toolStripButtonExampleClear.Enabled = false;
this.textBoxExample.ReadOnly = true;
}
this.LoadReferencedViews();
}
else if (docObject is DocPublication)
{
DocPublication docPublication = (DocPublication)docObject;
this.tabControl.TabPages.Add(this.tabPagePublication);
this.tabControl.TabPages.Add(this.tabPageViews);
this.tabControl.TabPages.Add(this.tabPageFormats);
this.LoadReferencedViews();
this.textBoxHeader.Text = docPublication.Header;
this.textBoxFooter.Text = docPublication.Footer;
this.checkBoxPublishHideHistory.Checked = docPublication.HideHistory;
this.checkBoxPublishISO.Checked = docPublication.ISO;
this.checkBoxPublishUML.Checked = docPublication.UML;
//this.checkBoxPublishComparison.Checked = docPublication.Comparison;
this.checkBoxPublishExchangeTables.Checked = docPublication.Exchanges;
this.listViewFormats.Items.Clear();
foreach (DocFormat docFormat in docPublication.Formats)
{
ListViewItem lvi = new ListViewItem();
lvi.ImageIndex = 0;
lvi.Tag = docFormat;
lvi.Text = docFormat.FormatType.ToString();
lvi.SubItems.Add(docFormat.FormatOptions.ToString());
this.listViewFormats.Items.Add(lvi);
}
UpdateFormatOption();
}
else if (docObject is DocChangeAction)
{
this.tabControl.TabPages.Add(this.tabPageChange);
DocChangeAction docChange = (DocChangeAction)docObject;
this.toolStripButtonChangeSPF.Checked = docChange.ImpactSPF;
this.toolStripButtonChangeXML.Checked = docChange.ImpactXML;
switch (docChange.Action)
{
case DocChangeActionEnum.NOCHANGE:
this.toolStripComboBoxChange.SelectedIndex = 0;
break;
case DocChangeActionEnum.ADDED:
this.toolStripComboBoxChange.SelectedIndex = 1;
break;
case DocChangeActionEnum.DELETED:
this.toolStripComboBoxChange.SelectedIndex = 2;
break;
case DocChangeActionEnum.MODIFIED:
this.toolStripComboBoxChange.SelectedIndex = 3;
break;
case DocChangeActionEnum.MOVED:
this.toolStripComboBoxChange.SelectedIndex = 4;
break;
}
this.listViewChange.Items.Clear();
foreach (DocChangeAspect docAspect in docChange.Aspects)
{
ListViewItem lvi = new ListViewItem();
lvi.Text = docAspect.Aspect.ToString();
lvi.SubItems.Add(docAspect.OldValue);
lvi.SubItems.Add(docAspect.NewValue);
this.listViewChange.Items.Add(lvi);
}
}
if (tabpageExist != null && this.tabControl.TabPages.Contains(tabpageExist))
{
this.tabControl.SelectedTab = tabpageExist;
}
}
finally
{
this.m_loadall = false;
}
}