Ejemplo n.º 1
0
        public override void Execute(object parameter)
        {
            if (CanExecute(parameter))
            {
                ChangesDetector detector = new ChangesDetector();

                PSMDiagram diagramNewVersion = (PSMDiagram)ActiveDiagramView.Diagram;

                PSMDiagram diagramOldVersion = null;

                if (previousVersions.Count == 1)
                {
                    diagramOldVersion = (PSMDiagram)diagramNewVersion.GetInVersion(previousVersions.First());
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.ShortMessage    = "Select previous version of the diagram. ";
                    d.Title           = "Select version";
                    d.UseRadioButtons = true;
                    d.SetItems(previousVersions);
                    d.SelectItem(previousVersions.FirstOrDefault(v => v.Number == previousVersions.Max(vm => vm.Number)));
                    if (d.ShowDialog() == true && d.selectedObjects.Count == 1)
                    {
                        diagramOldVersion = (PSMDiagram)d.selectedObjects[0];
                    }
                }

                if (diagramOldVersion != null)
                {
                    List <EvolutionChange> evolutionChanges = detector.Translate(diagramOldVersion, diagramNewVersion);
                    EvolutionChangesWindow.Show(evolutionChanges, MainWindow, diagramOldVersion, diagramNewVersion);
                }
            }
        }
Ejemplo n.º 2
0
        public void GoToPimClass(PIMClass pimClass)
        {
            ElementDiagramDependencies dependentDiagrams = ElementDiagramDependencies.FindElementDiagramDependencies(MainWindow.CurrentProject, new[] { pimClass }, null);

            if (dependentDiagrams.Count == 1)
            {
                if (dependentDiagrams[pimClass].Count == 1)
                {
                    ActivateDiagramWithElement(dependentDiagrams[pimClass][0], pimClass);
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.ToStringAction = diagram => ((Diagram)diagram).Caption;
                    d.SetItems(dependentDiagrams[pimClass]);
                    if (d.ShowDialog() == true)
                    {
                        foreach (Diagram diagram in d.selectedObjects.Cast <Diagram>())
                        {
                            ActivateDiagramWithElement(diagram, pimClass);
                        }
                    }
                }
            }
            else if (dependentDiagrams.Count == 0)
            {
                XCaseYesNoBox.ShowOK("PIM class not used in diagrams", "PIM class is not used in any diagram. You can edit it via Navigator window. ");
            }
        }
Ejemplo n.º 3
0
        public override void Execute(object parameter)
        {
            IEnumerable <ExolutioVersionedObject> openedVersions = Current.MainWindow.DiagramTabManager.AnotherOpenedVersions(Current.ActiveDiagram);

            if (openedVersions != null && openedVersions.Count() == 1)
            {
                FindAndDisplayChanges(((PSMDiagram)openedVersions.First()).PSMSchema, ((PSMDiagram)Current.ActiveDiagram).PSMSchema);
            }
            else
            {
                IEnumerable <PSMSchema> versionedItems =
                    Current.Project.VersionManager.GetAllVersionsOfItem(Current.ActiveDiagram.Schema).Cast <PSMSchema>();
                SelectItemsDialog dialog = new SelectItemsDialog();
                dialog.UseRadioButtons = true;
                List <PSMSchema> psmSchemata = versionedItems.ToList();
                psmSchemata.Remove((PSMSchema)Current.ActiveDiagram.Schema);
                dialog.SetItems(psmSchemata);
                dialog.ShortMessage = "Select version";
                dialog.LongMessage  = "Select version of the schema you wish to compare";
                dialog.ShowDialog();

                if (dialog.DialogResult == true && dialog.selectedObjects.Count == 1)
                {
                    FindAndDisplayChanges((PSMSchema)dialog.selectedObjects.First(), ((PSMDiagram)Current.ActiveDiagram).PSMSchema);
                }
            }
        }
Ejemplo n.º 4
0
        private void downloadItemsClick(object sender, RoutedEventArgs e)
        {
            var innovator = getInnovator();

            if (innovator != null)
            {
                var selectItemTypeDialog = new SelectItemTypeDialog
                {
                    Owner     = this,
                    ItemTypes = _project.ItemTypes,
                };
                if (selectItemTypeDialog.ShowDialog() == true)
                {
                    var itemType = selectItemTypeDialog.SelectedItemType;

                    var itemsRequest = innovator.newItem(itemType.Name, "get");
                    itemsRequest.setAttribute("select", "*");
                    var itemsItem = itemsRequest.apply();

                    var items = new List <Aras.IOM.Item>();
                    for (int i = 0, count = itemsItem.getItemCount(); i < count; i++)
                    {
                        items.Add(itemsItem.getItemByIndex(i));
                    }

                    var selectDialog = new SelectItemsDialog
                    {
                        Owner      = this,
                        Properties = itemType.Properties.Select(property => property.Name).ToList(),
                        Items      = items,
                    };
                    if (selectDialog.ShowDialog() == true)
                    {
                        double x = _project.Items.Max(item => item.Left + _allItemControls[item].ActualWidth);
                        double y = _project.Items.Max(item => item.Top + _allItemControls[item].ActualHeight);

                        const int xOffset = 100;
                        const int yOffset = 50;

                        foreach (var item in selectDialog.SelectedItems)
                        {
                            x += xOffset;
                            y += yOffset;
                            var newItem = new Item(itemType, x, y);
                            foreach (var property in newItem.Properties)
                            {
                                property.Value = item.getProperty(property.Name);
                            }
                            _project.Items.Add(newItem);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        public override void Execute(object parameter)
        {
            Version currentVersion = CurrentProject.Version;

            SelectItemsDialog selectVersion = new SelectItemsDialog();
            List <Version>    _versions     = FindLowerVersions(CurrentProject);

            if (_versions.Count == 0)
            {
                XCaseYesNoBox.ShowOK("No previous version", "No previous version of the diagram");
                return;
            }
            Version v;

            if (_versions.Count > 1)
            {
                selectVersion.UseRadioButtons = true;
                selectVersion.SetItems(_versions);
                selectVersion.ShortMessage = "Select version";
                selectVersion.LongMessage  = "Select version to map to.";
                selectVersion.Title        = "Select version";

                if (selectVersion.ShowDialog() != true || selectVersion.selectedObjects.Count != 1)
                {
                    return;
                }
                v = (Version)selectVersion.selectedObjects[0];
            }
            else
            {
                v = _versions.First();
            }

            Diagram diagramOldVersion = (Diagram)ActiveDiagramView.Diagram.GetInVersion(v);

            if (diagramOldVersion == null)
            {
                XCaseYesNoBox.ShowOK("Diagram not present", "Diagram does not exist in this version. ");
                return;
            }

            mappingDialog = new MappingDialog();
            mappingDialog.DiagramNewVersion     = ActiveDiagramView.Diagram;
            mappingDialog.DiagramOldVersion     = diagramOldVersion;
            mappingDialog.DiagramView           = ActiveDiagramView;
            mappingDialog.DiagramViewOldVersion = MainWindow.DiagramTabManager.GetDiagramView(diagramOldVersion);
            mappingDialog.Closed += new System.EventHandler(mappingDialog_Closed);
            mappingDialog.Show();
        }
Ejemplo n.º 6
0
        public override void Execute(object parameter)
        {
            Diagram diagram        = ActiveDiagramView.Diagram;
            Version currentVersion = CurrentProject.Version;

            SelectItemsDialog selectVersion = new SelectItemsDialog();
            List <Version>    _versions     = new List <Version>(CurrentProject.VersionManager.Versions.Where(ver => ver.Number < currentVersion.Number));

            selectVersion.UseRadioButtons = true;
            selectVersion.SetItems(_versions);
            selectVersion.ShortMessage = "Select version";
            selectVersion.LongMessage  = "Select version to map to.";
            selectVersion.Title        = "Select version";

            if (selectVersion.ShowDialog() != true || selectVersion.selectedObjects.Count != 1)
            {
                return;
            }

            Version v = (Version)selectVersion.selectedObjects[0];

            List <Diagram> _candidates = CurrentProject.VersionManager.VersionedProjects[v].Diagrams.ToList();

            SelectItemsDialog selectDiagram = new SelectItemsDialog();

            selectDiagram.UseRadioButtons = true;
            selectDiagram.ToStringAction  = o => ((Diagram)o).Caption;
            selectDiagram.SetItems(_candidates);
            selectDiagram.ShortMessage = "Select diagram";
            selectDiagram.LongMessage  = "Select diagram to map to.";
            selectDiagram.Title        = "Select diagram";

            if (selectDiagram.ShowDialog() != true || selectDiagram.selectedObjects.Count != 1)
            {
                return;
            }

            Diagram diagramToMapTo = (Diagram)selectDiagram.selectedObjects[0];

            CurrentProject.VersionManager.RegisterBranch(diagramToMapTo, diagram, currentVersion, true, v);
        }
Ejemplo n.º 7
0
        public void InitializeCommand(IEnumerable <PSMAttribute> attributes, PSMClass parentClass, PSMAttributeContainer attributeContainer)
        {
            if (attributes.Count() == 0)
            {
                return;
            }

            if (attributeContainer == null)
            {
                List <PSMAttributeContainer> candidates = new List <PSMAttributeContainer>();
                FindACRecursive(parentClass, candidates);

                bool createNew = false;
                if (candidates.Count() == 0)
                {
                    createNew = true;
                }
                else
                {
                    SelectItemsDialog d = new SelectItemsDialog();
                    d.Title           = "Select attribute container";
                    d.ShortMessage    = "Select attribute container";
                    d.LongMessage     = String.Empty;
                    d.UseRadioButtons = true;
                    ArrayList    _c     = new ArrayList(candidates.ToList());
                    const string _newAC = "<< new attribute container >>";
                    _c.Add(_newAC);
                    d.SetItems(_c);

                    if (d.ShowDialog() == true)
                    {
                        if (d.selectedObjects.FirstOrDefault().Equals(_newAC))
                        {
                            createNew = true;
                        }
                        else
                        {
                            AttributeContainer = d.selectedObjects.FirstOrDefault() as PSMAttributeContainer;
                        }
                    }
                }

                if (createNew)
                {
                    NewPSMAttributeContainerCommand createACcommand = (NewPSMAttributeContainerCommand)NewPSMAttributeContainerCommandFactory.Factory().Create(Controller);
                    createACcommand.PSMClass = parentClass;
                    createACcommand.PSMAttributes.AddRange(attributes);
                    Commands.Add(createACcommand);
                    return;
                }
            }
            else
            {
                AttributeContainer = attributeContainer;
            }

            if (AttributeContainer != null)
            {
                MoveAttributesFromClassToAttributeContainerCommand moveCommand =
                    (MoveAttributesFromClassToAttributeContainerCommand)
                    MoveAttributesFromClassToAttributeContainerCommandFactory.Factory().Create(Controller);
                moveCommand.AttributeContainer = AttributeContainer;
                moveCommand.Attributes.AddRange(attributes);
                Commands.Add(moveCommand);
            }
        }
        public void InitializeCommand(IEnumerable <PSMSubordinateComponent> components, SUPERORDINATE_TYPE container)
        {
            if (components.Count() == 0)
            {
                return;
            }

            if (container == null)
            {
                PSMClass parentClass;
                if (
                    !MoveSubordinateToSuperordinateCommand <SUPERORDINATE_TYPE> .CheckCommonParentClass(components,
                                                                                                        out parentClass))
                {
                    return;
                }

                List <SUPERORDINATE_TYPE> candidates = new List <SUPERORDINATE_TYPE>();
                FindContainerRecursive(parentClass, candidates);

                bool createNew = false;

                SelectItemsDialog d = new SelectItemsDialog();
                d.Title           = "Select container";
                d.ShortMessage    = "Select container";
                d.LongMessage     = String.Empty;
                d.UseRadioButtons = true;
                ArrayList    _c     = new ArrayList(candidates.ToList());
                const string _newAC = "<< new container >>";
                _c.Add(_newAC);
                d.SetItems(_c);

                if (d.ShowDialog() == true)
                {
                    if (d.selectedObjects.FirstOrDefault().Equals(_newAC))
                    {
                        createNew = true;
                    }
                    else
                    {
                        Container = d.selectedObjects.FirstOrDefault() as SUPERORDINATE_TYPE;
                    }
                }

                if (createNew)
                {
                    if (typeof(PSMContentContainer).IsAssignableFrom(typeof(SUPERORDINATE_TYPE)))
                    {
                        NewPSMContentContainerCommand createCCcommand =
                            (NewPSMContentContainerCommand)
                            NewPSMContentContainerCommandFactory.Factory().Create(Controller);
                        createCCcommand.Parent = components.First().Parent;
                        createCCcommand.ContainedComponents.AddRange(components);
                        Commands.Add(createCCcommand);
                    }
                    else if (typeof(PSMContentChoice).IsAssignableFrom(typeof(SUPERORDINATE_TYPE)))
                    {
                        NewPSMContentChoiceCommand createCCcommand =
                            (NewPSMContentChoiceCommand)
                            NewPSMContentChoiceCommandFactory.Factory().Create(Controller);
                        createCCcommand.Parent = components.First().Parent;
                        createCCcommand.ContainedComponents.AddRange(components);
                        Commands.Add(createCCcommand);
                    }
                    else
                    {
                        throw new NotImplementedException();
                    }
                    return;
                }
            }
            else
            {
                Container = container;
            }

            if (Container != null)
            {
                MoveSubordinateToSuperordinateCommand <SUPERORDINATE_TYPE> moveCommand =
                    (MoveSubordinateToSuperordinateCommand <SUPERORDINATE_TYPE>)
                    MoveSubordinateToSuperordinateCommandFactory <SUPERORDINATE_TYPE> .Factory().Create(Controller);

                moveCommand.Container = Container;
                moveCommand.Components.AddRange(components);
                Commands.Add(moveCommand);
            }
        }
Ejemplo n.º 9
0
        private void downloadItemTypesClick(object sender, RoutedEventArgs e)
        {
            var innovator = getInnovator();

            if (innovator != null)
            {
                var itemTypesRequest = innovator.newItem("ItemType", "get");
                itemTypesRequest.setAttribute("select", "name,is_relationship");
                var propertyRequest = innovator.newItem("Property", "get");
                propertyRequest.setAttribute("select", "name,label,data_type");
                propertyRequest.setProperty("is_hidden", "0");
                itemTypesRequest.addRelationship(propertyRequest);

                var itemTypesItem = itemTypesRequest.apply();
                var itemTypes     = new List <Aras.IOM.Item>();
                for (int i = 0, count = itemTypesItem.getItemCount(); i < count; i++)
                {
                    itemTypes.Add(itemTypesItem.getItemByIndex(i));
                }

                var selectDialog = new SelectItemsDialog
                {
                    Owner      = this,
                    Properties = new List <string> {
                        "name", "is_relationship"
                    },
                    Items = itemTypes,
                };
                if (selectDialog.ShowDialog() == true)
                {
                    var itemTypesCache = _project.ItemTypes.ToDictionary(
                        itemType => itemType.Name,
                        itemType => itemType);
                    var itemTypeProperties = new Dictionary <string, Dictionary <string, string> >();

                    foreach (var itemType in selectDialog.SelectedItems)
                    {
                        var properties     = new List <Property>();
                        var itemProperties = new Dictionary <string, string>();
                        var propertiesItem = itemType.getRelationships("Property");
                        for (int i = 0, count = propertiesItem.getItemCount(); i < count; i++)
                        {
                            var propertyItem = propertiesItem.getItemByIndex(i);
                            properties.Add(new Property {
                                Name = propertyItem.getProperty("name")
                            });
                        }
                        var newItemType = new ItemType(
                            itemType.getProperty("name"),
                            itemType.getProperty("is_relationship") == "1",
                            properties,
                            new ItemType[0]);
                        _project.ItemTypes.Add(newItemType);
                        itemTypesCache[newItemType.Name] = newItemType;
                        if (itemProperties.Count > 0)
                        {
                            itemTypeProperties[newItemType.Name] = itemProperties;
                        }
                    }

                    foreach (var itemType in itemTypeProperties)
                    {
                        foreach (var property in itemType.Value)
                        {
                            ItemType pointingType;
                            if (itemTypesCache.TryGetValue(property.Value, out pointingType))
                            {
                                itemTypesCache[itemType.Key].Properties.First(p => p.Name == property.Key).DataSourceType = pointingType;
                            }
                        }
                    }
                }
            }
        }
        public void InitializeCommand(IEnumerable <PSMAssociation> associations, PSMClassUnion container)
        {
            if (associations.Count() == 0)
            {
                return;
            }

            if (container == null)
            {
                PSMSuperordinateComponent parentClass;
                if (!PSMTree.AreComponentsOfCommonParent(associations))
                {
                    return;
                }
                parentClass = associations.First().Parent;

                List <PSMClassUnion> candidates = new List <PSMClassUnion>();
                FindCURecursive(parentClass, candidates);

                bool createNew = false;

                SelectItemsDialog d = new SelectItemsDialog();
                d.Title           = "Select class union";
                d.ShortMessage    = "Select class union";
                d.LongMessage     = String.Empty;
                d.UseRadioButtons = true;
                ArrayList    _c     = new ArrayList(candidates.ToList());
                const string _newAC = "<< new class union >>";
                _c.Add(_newAC);
                d.SetItems(_c);

                if (d.ShowDialog() == true)
                {
                    if (d.selectedObjects.FirstOrDefault().Equals(_newAC))
                    {
                        createNew = true;
                    }
                    else
                    {
                        ClassUnion = d.selectedObjects.FirstOrDefault() as PSMClassUnion;
                    }
                }

                if (createNew)
                {
                    JoinAssociationsToClassUnionMacroCommand createCUcommand =
                        (JoinAssociationsToClassUnionMacroCommand)
                        JoinAssociationsToClassUnionMacroCommandFactory.Factory().Create(Controller);
                    createCUcommand.Set(parentClass, associations);

                    Commands.Add(createCUcommand);
                    return;
                }
            }
            else
            {
                ClassUnion = container;
            }

            if (ClassUnion != null)
            {
                MoveClassToExistingClassUnionMacroCommand moveCommand =
                    (MoveClassToExistingClassUnionMacroCommand)
                    MoveClassToExistingClassUnionMacroCommandFactory.Factory().Create(Controller);
                moveCommand.Set(ClassUnion, associations);
                Commands.Add(moveCommand);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Initializes PSM Classes Context Menus
        /// </summary>
        private void InitContextMenu()
        {
            //txtClassName.ResetContextMenu();
            txtClassName.ContextMenuOpening    += ContextMenu_ContextMenuOpening;
            txtRepresentedClassName.ContextMenu = null;
            ContextMenuItem miRemove = new ContextMenuItem("Remove");

            miRemove.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            miRemove.Click += delegate { ClassController.Remove(); };
            txtClassName.ContextMenu.Items.Add(miRemove);
            txtClassName.ContextMenu.Items.Add(new Separator());

            ContextMenuItem miDeriveNew = new ContextMenuItem("Derive another class as root");

            miDeriveNew.Icon   = ContextMenuIcon.GetContextIcon("class");
            miDeriveNew.Click += delegate { ClassController.DeriveNewRootPSMClass(); };
            txtClassName.ContextMenu.Items.Add(miDeriveNew);

            ContextMenuItem miLocatePimClass = new ContextMenuItem("Find represented PIM class");

            miLocatePimClass.Icon   = ContextMenuIcon.GetContextIcon("magnifier");
            miLocatePimClass.Click += delegate {
                ClassController.FindRepresentedClass();
            };
            txtClassName.ContextMenu.Items.Add(miLocatePimClass);

            miLocateRepresentedPSMClass           = new ContextMenuItem("Find represented PSM class");
            miLocateRepresentedPSMClass.Icon      = ContextMenuIcon.GetContextIcon("magnifier");
            miLocateRepresentedPSMClass.IsEnabled = false;
            miLocateRepresentedPSMClass.Click    += delegate
            {
                if (PSMClass.IsStructuralRepresentative)
                {
                    if (PSMClass.RepresentedPSMClass.Diagram == PSMClass.Diagram)
                    {
                        XCaseCanvas.SelectElement(PSMClass.RepresentedPSMClass);
                    }
                    else
                    {
                        ClassController.FindRepresentedPSMClass();
                    }
                }
            };

            txtClassName.ContextMenu.Items.Add(miLocateRepresentedPSMClass);

            miFindStructuralRepresentatives           = new ContextMenuItem("Find Structural Representatives");
            miFindStructuralRepresentatives.Icon      = ContextMenuIcon.GetContextIcon("magnifier");
            miFindStructuralRepresentatives.IsEnabled = true;
            miFindStructuralRepresentatives.Click    += delegate
            {
                if (PSMClass.IsReferencedFromStructuralRepresentative())
                {
                    SelectItemsDialog d     = new SelectItemsDialog();
                    List <PSMClass>   items = new List <Model.PSMClass>();
                    foreach (PSMClass r in PSMClass.RepresentedClassRepresentants)
                    {
                        if (r.RepresentedPSMClass == PSMClass)
                        {
                            items.Add(r);
                        }
                    }
                    d.SetItems(items);
                    if (d.ShowDialog() == true && d.selectedObjects.Count > 0)
                    {
                        XCaseCanvas.SelectElement((PSMElement)d.selectedObjects.First());
                    }
                }
            };
            txtClassName.ContextMenu.Items.Add(miFindStructuralRepresentatives);

            miConvertToRegular        = new ContextMenuItem("Convert to regular PSM class");
            miConvertToRegular.Icon   = ContextMenuIcon.GetContextIcon("class");
            miConvertToRegular.Click +=
                delegate
            {
                SetRepresentedHighlight(false);
                ClassController.SetPSMRepresentedClass(true);
            };

            miConvertToRepresentant        = new ContextMenuItem("Convert to PSM Structural Representative");
            miConvertToRepresentant.Icon   = ContextMenuIcon.GetContextIcon("class");
            miConvertToRepresentant.Click += delegate { ClassController.SetPSMRepresentedClass(false); };

            txtClassName.ContextMenu.Items.Add(miConvertToRepresentant);
            txtClassName.ContextMenu.Items.Add(miConvertToRegular);

            txtClassName.ContextMenu.Items.Add(new Separator());

            miAbstract             = new ContextMenuItem("Abstract class");
            miAbstract.IsCheckable = true;
            miAbstract.Click      += delegate { ClassController.ChangeAbstract(!PSMClass.IsAbstract); };
            txtClassName.ContextMenu.Items.Add(miAbstract);

            miAllowAnyAttribute             = new ContextMenuItem("Allow any attribute");
            miAllowAnyAttribute.IsCheckable = true;
            miAllowAnyAttribute.Click      += delegate { ClassController.ChangeAllowAnyAttributeDefinition(!PSMClass.AllowAnyAttribute); };
            txtClassName.ContextMenu.Items.Add(miAllowAnyAttribute);

            ContextMenuItem miAutosize = new ContextMenuItem("Autosize");

            miAutosize.Click += delegate { ViewController.ResizeElement(double.NaN, double.NaN, ViewHelper, XCaseCanvas.Controller); };
            txtClassName.ContextMenu.Items.Add(miAutosize);
            txtClassName.ContextMenu.Items.Add(new Separator());

            miCollapseAttributes = new ContextMenuItem("Hide attributes")
            {
                IsCheckable = true
            };
            txtClassName.ContextMenu.Items.Add(miCollapseAttributes);
            miCollapseAttributes.Checked +=
                delegate
            {
                if (!AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseAttributes, XCaseCanvas.Controller);
                }
            };
            miCollapseAttributes.Unchecked +=
                delegate
            {
                if (AttributesCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowAttributes, XCaseCanvas.Controller);
                }
            };

            miCollapseElementNameLabel = new ContextMenuItem("Hide element name")
            {
                IsCheckable = true
            };
            miCollapseElementNameLabel.Checked +=
                delegate
            {
                if (!ElementNameLabelCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.CollapseElementNameLabel, XCaseCanvas.Controller);
                }
            };
            miCollapseElementNameLabel.Unchecked +=
                delegate
            {
                if (ElementNameLabelCollapsed)
                {
                    ViewController.ChangeSectionVisibility(ViewHelper, SectionVisibilityCommand.ESectionVisibilityAction.ShowElementNameLabel, XCaseCanvas.Controller);
                }
            };
            txtClassName.ContextMenu.Items.Add(miCollapseElementNameLabel);
            txtClassName.ContextMenu.Items.Add(new Separator());

            miElementNameLabelAlignRight = new ContextMenuItem("Aligned to right")
            {
                IsCheckable = true
            };
            miElementNameLabelAlignRight.Checked +=
                delegate
            {
                if (!ElementNameLabelAlignedRight)
                {
                    ViewController.ChangeElementNameLabelAlignment(ViewHelper, true, XCaseCanvas.Controller);
                }
            };

            miElementNameLabelAlignRight.Unchecked +=
                delegate
            {
                if (ElementNameLabelAlignedRight)
                {
                    ViewController.ChangeElementNameLabelAlignment(ViewHelper, false, XCaseCanvas.Controller);
                }
            };
            //txtElementNameLabel.ResetContextMenu();
            txtElementNameLabel.ContextMenu.Items.Add(miElementNameLabelAlignRight);

            txtElementNameLabel.mi_Rename.Header = "Change XML Element name...";

            ContextMenuItem miDeleteElementName = new ContextMenuItem("Delete element name");

            miDeleteElementName.Icon   = ContextMenuIcon.GetContextIcon("delete2");
            miDeleteElementName.Click += delegate { ClassController.ChangeElementName(string.Empty); };
            txtElementNameLabel.ContextMenu.Items.Add(miDeleteElementName);


            foreach (ContextMenuItem item in classAttributes.PropertiesMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }
            foreach (ContextMenuItem item in ContextMenuItems)
            {
                txtClassName.ContextMenu.Items.Add(item);
            }

            txtClassName.ContextMenu.Items.Add(new Separator());

            miGroupBy        = new ContextMenuItem("Group by...");
            miGroupBy.Click += delegate { ClassController.GroupBy(); };
            txtClassName.ContextMenu.Items.Add(miGroupBy);

            ContextMenuItem miAddChildren = new ContextMenuItem("Add children...");

            miAddChildren.Icon   = ContextMenuIcon.GetContextIcon("AddChildren");
            miAddChildren.Click += delegate { ClassController.AddChildren(); };
            txtClassName.ContextMenu.Items.Add(miAddChildren);

            ContextMenuItem miAddAttributes = new ContextMenuItem("Attributes...");

            miAddAttributes.Icon   = ContextMenuIcon.GetContextIcon("AddAttributes");
            miAddAttributes.Click += delegate { ClassController.ShowClassDialog(); };
            txtClassName.ContextMenu.Items.Add(miAddAttributes);

            txtClassName.ContextMenu.Items.Add(new Separator());

            ContextMenuItem miProperties = new ContextMenuItem("Properties...");

            miProperties.Icon   = ContextMenuIcon.GetContextIcon("props");
            miProperties.Click += delegate { ClassController.ShowClassDialog(); };
            txtClassName.ContextMenu.Items.Add(miProperties);
        }
Ejemplo n.º 12
0
        public override void Execute(object parameter)
        {
            IHasPSMAttributes hasAttributes = (IHasPSMAttributes)GetElement();

            SelectItemsDialog selectVersion = new SelectItemsDialog();
            List <Version>    _versions     = new List <Version>(CurrentProject.VersionManager.Versions.Where(ver => ver.Number < hasAttributes.Version.Number));
            Version           v;

            if (_versions.Count > 1)
            {
                selectVersion.UseRadioButtons = true;
                selectVersion.SetItems(_versions);
                selectVersion.ShortMessage = "Select version";
                selectVersion.LongMessage  = "Select version to map to.";
                selectVersion.Title        = "Select version";

                if (selectVersion.ShowDialog() != true || selectVersion.selectedObjects.Count != 1)
                {
                    return;
                }
                v = (Version)selectVersion.selectedObjects[0];
            }
            else
            {
                v = _versions[0];
            }

            SelectItemsDialog selectAttributes = new SelectItemsDialog();

            selectAttributes.UseRadioButtons = true;
            selectAttributes.SetItems(hasAttributes.PSMAttributes);
            selectAttributes.ShortMessage = "Select attribute";
            selectAttributes.LongMessage  = "Select attribute for mapping.";
            selectAttributes.Title        = "Select attribute";
            selectAttributes.SelectItem(hasAttributes.PSMAttributes.FirstOrDefault(a => a.GetInVersion(v) == null));
            if (selectAttributes.ShowDialog() != true || selectAttributes.selectedObjects.Count != 1)
            {
                return;
            }

            IVersionedElement selectedAttribute = (IVersionedElement)selectAttributes.selectedObjects[0];
            Version           currentVersion    = selectedAttribute.Version;

            Diagram diagram = (Diagram)ActiveDiagramView.Diagram.GetInVersion(v);

            if (diagram == null)
            {
                XCaseYesNoBox.ShowOK("Diagram not present", "Diagram does not exist in this version. ");
                return;
            }


            List <Element> _candidates = new List <Element>();

            foreach (var element in ((IHasPSMAttributes)hasAttributes.GetInVersion(v)).PSMAttributes.Where
                         (e => e.GetType() == selectedAttribute.GetType() && e.IsFirstVersion && e.GetInVersion(currentVersion) == null))
            {
                _candidates.Add(element);
            }

            if (_candidates.Count == 0)
            {
                XCaseYesNoBox.ShowOK("Not found", "No possible elements found for this item. ");
                return;
            }

            SelectItemsDialog selectElement = new SelectItemsDialog();

            selectElement.UseRadioButtons = true;
            selectElement.SetItems(_candidates);
            Element guess = _candidates.FirstOrDefault(c => c.ToString() == selectedAttribute.ToString());

            selectElement.SelectItem(guess);
            selectElement.ShortMessage = "Select element";
            selectElement.LongMessage  = "Select element to map to.";
            selectElement.Title        = "Select element";

            if (selectElement.ShowDialog() != true || selectElement.selectedObjects.Count != 1)
            {
                return;
            }

            Element el = (Element)selectElement.selectedObjects[0];

            CurrentProject.VersionManager.RegisterBranch(el, selectedAttribute, currentVersion, true, el.Version);
        }