public void MergeTo(VDWidget targetWidget, ElementGroup elementGroup) { targetWidget.Children.Add(this); VDCodeSnippetBody body = this.Store.ElementFactory.CreateElement(VDCodeSnippetBody.DomainClassId) as VDCodeSnippetBody; this.Body = body; }
// targetWidget = sourceWidget.Selector() public static Selector FromWidgets(VDWidget sourceWidget, VDWidget targetWidget) { string identifierSelector = string.Empty; // if (string.IsNullOrEmpty(widget.WidgetName)) // { // // todo: if use as id identifier // //return "#" + widget.WidgetName; // // todo: if use as class identifier // //return "." + widget.WidgetName; // // todo: if use as normal class // } // if (widget.Parent != null) // { // string parentIdentifier = GetIdentifierSelector(widget.Parent); // if (!string.IsNullOrEmpty(parentIdentifier)) // { // } // } // // get selecctor relative to prev widget/prev of prev/ prev of prev of prev // // get selector relative to next widget/next of next/next of next // // get selector relative to children //return identifierSelector; return(null); }
protected override void OnDeleted() { base.OnDeleted(); if (this.Store.TransactionManager.InTransaction) { // delete widget value if (m_widgetValueToDel != null) { m_widgetValueToDel.Delete(); m_widgetValueToDel = null; } if (m_deleteWithoutPropagating) { return; } if (PropagateDeletingToParent && m_parentToDel != null) { onPropagateDeletingParent(m_parentToDel); m_parentToDel = null; } } }
// traverse according to layout positions public IEnumerator <VDWidget> GetEnumerator() { List <NodeShape> childShapeList = new List <NodeShape>(); var shapes = PresentationViewsSubject.GetPresentation(m_rootWidget); if (shapes != null && shapes.Count > 0) { NodeShape parentShape = shapes[0] as NodeShape; if (parentShape != null) { foreach (var shape in parentShape.NestedChildShapes) { NodeShape childShape = shape as NodeShape; if (childShape != null) { childShapeList.Add(childShape); } } } } // traverse according to position, row first childShapeList.Sort((a, b) => { if (a.Location.Y - b.Location.Y > Utility.NumberHelper.DOUBLE_DIFFERENCE) { return(1); } else if (b.Location.Y - a.Location.Y > Utility.NumberHelper.DOUBLE_DIFFERENCE) { return(-1); } else if (a.Location.X - b.Location.X > Utility.NumberHelper.DOUBLE_DIFFERENCE) { return(1); } else if (b.Location.X - a.Location.X > Utility.NumberHelper.DOUBLE_DIFFERENCE) { return(-1); } else { return(0); } }); // List <VDWidget> childWidgets = new List <VDWidget>(); foreach (NodeShape shape in childShapeList) { VDWidget widget = shape.ModelElement as VDWidget; if (widget != null) { childWidgets.Add(widget); } } return(childWidgets.GetEnumerator()); }
/// <summary> Get client event list supported by specified source widget </summary> /// <param name="sourceWidget"></param> /// <returns></returns> public List <string> GetClientEventList(VDWidget sourceWidget) { return(new List <string>() { "click", "change", "onSuccess", }); }
protected override void OnSelectionChanged(EventArgs e) { base.OnSelectionChanged(e); ShapeElement shape = this.PrimarySelection as ShapeElement; if (shape != null && shape.ModelElement != null) { // set active widget for code snippet VDWidget widget = shape.ModelElement as VDWidget; if (widget != null && !(widget is VDCodeSnippet) && (widget.CodeSnippetEditor != null)) { using (Transaction trans = this.DocData.Store.TransactionManager.BeginTransaction("Set Active Linked Widget")) { if (widget.CodeSnippetEditor != null) { widget.CodeSnippetEditor.ActiveLinkedWidget = widget; } trans.Commit(); } return; } // update Model Tool Window ModelToolWindow win = this.ModelToolWindow; if (win != null) { win.ShowNoActivate(); if (widget != null) { if (widget is VDView) { win.ShowViewModel((VDView)widget); } else if (widget is VDActionBase) { win.ShowActionModel((VDActionBase)widget); } else { win.ShowWidgetModel(widget); } } else { // avoid tool window blink if (shape.ModelElement is VDWidgetTitle) { return; } win.HideWindow(); } } } }
/// <summary> Get client action list supported by specified target widget </summary> /// <param name="targetWidget"></param> /// <returns></returns> public List <string> GetClientActionList(VDWidget targetWidget) { return(new List <string>() { "Delete", "Replace", "AjaxGet", "AjaxPost" }); }
private ModelElement GetParentForVDWidgetTitle(VDWidgetTitle childElement) { VDWidget parent = childElement.Widget; if (parent != null && parent.WidgetType != WidgetType.View) { return(parent); } return(null); }
private static void setAnchor(VDWidgetShape parentShape, VDContainer thisMEL, VDContainerShape thisPEL, bool setAnchor, VDWidget sibling, AnchoringBehavior.Edge edge) { if (!setAnchor) { return; } if (sibling != null) // anchor to sibling { VDWidgetShape siblingShape = parentShape.GetChildShape <VDWidgetShape>(sibling); if (siblingShape != null) { switch (edge) { case AnchoringBehavior.Edge.Bottom: thisPEL.Anchoring.SetBottomAnchor(siblingShape, AnchoringBehavior.Edge.Top, thisMEL.BottomMargin); break; case AnchoringBehavior.Edge.Left: thisPEL.Anchoring.SetLeftAnchor(siblingShape, AnchoringBehavior.Edge.Right, thisMEL.LeftMargin); break; case AnchoringBehavior.Edge.Right: thisPEL.Anchoring.SetRightAnchor(siblingShape, AnchoringBehavior.Edge.Left, thisMEL.RightMargin); break; case AnchoringBehavior.Edge.Top: thisPEL.Anchoring.SetTopAnchor(siblingShape, AnchoringBehavior.Edge.Bottom, thisMEL.TopMargin); break; } } } else // anchor to parent { switch (edge) { case AnchoringBehavior.Edge.Bottom: thisPEL.Anchoring.SetBottomAnchor(edge, thisMEL.BottomMargin); break; case AnchoringBehavior.Edge.Left: thisPEL.Anchoring.SetLeftAnchor(edge, thisMEL.LeftMargin); break; case AnchoringBehavior.Edge.Right: thisPEL.Anchoring.SetRightAnchor(edge, thisMEL.RightMargin); break; case AnchoringBehavior.Edge.Top: thisPEL.Anchoring.SetTopAnchor(edge, thisMEL.TopMargin); break; } } }
public void ShowWidgetModel(VDWidget widget) { m_selectedWidget = widget; setToolWindowTitle(string.Format("Widget Value - {0} [{1}]", widget.WidgetName, widget.WidgetType.ToString())); if (this.Window != null) { ModelToolWindowForm.WidgetValueHandler.Show(widget); } }
private string getWidgetString(VDWidget widget) { if (string.IsNullOrEmpty(widget.WidgetName)) { return(string.Format("[{0}]", widget.WidgetType)); } else { return(string.Format("{0} [{1}]", widget.WidgetName, widget.WidgetType)); } }
/// <summary>Get a child shape which ModelElemnt is childMEL</summary> public T GetChildShape <T>(VDWidget childMEL) where T : ShapeElement { foreach (var s in this.NestedChildShapes) { if (s.ModelElement == childMEL) { return((T)s); } } return(null); }
public void Init(VDWidget anchorWidget, string selector, string resolvedWidget) { m_anchorWidget = anchorWidget; m_selector = selector; m_resolvedWidget = resolvedWidget; if (anchorWidget != null) { this.cmbAnchorWidget.Text = anchorWidget.WidgetName + "[" + anchorWidget.WidgetType.ToString() + "]"; } this.txtSelectorFunction.Text = selector; this.lblResolvedWidget.Text = resolvedWidget; }
public NewActionHandler SetSourceEvent(VDEventBase evt) { if (evt != null) { VDWidget source = evt.Widget; SetSource(source); } else { SetSource(null); } m_cmbEvent.Enabled = false; return(this); }
internal virtual bool internalCanMerge(VDWidget origianlTargetWidget, ProtoElementBase sourceRootElement, ElementGroupPrototype elementGroupPrototype) { if (elementGroupPrototype == null) { throw new ArgumentNullException("elementGroupPrototype"); } if (sourceRootElement != null) { DomainClassInfo rootElementDomainInfo = this.Partition.DomainDataDirectory.GetDomainClass(sourceRootElement.DomainClassId); if (rootElementDomainInfo.IsDerivedFrom(VDWidget.DomainClassId)) { return(MergeManager.Instance.CanMerge(rootElementDomainInfo.Id, this.GetDomainClass().Id)); } } return(base.CanMerge(sourceRootElement, elementGroupPrototype)); }
protected override void OnDeleting() { m_deleting = true; try { m_parentToDel = this.Parent; m_widgetValueToDel = this.WidgetValue; if (m_widgetValueToDel != null && m_widgetValueToDel.HasExternalReference) { m_widgetValueToDel = null; } base.OnDeleting(); } finally { m_deleting = false; } }
public static VDWidget GetCommonParent(VDWidget w1, VDWidget w2) { int len1 = 0, len2 = 0; VDWidget parent1 = w1.Parent; while (parent1 != null) { parent1 = parent1.Parent; len1++; } VDWidget parent2 = w2.Parent; while (parent2 != null) { parent2 = parent2.Parent; len2++; } parent1 = w1.Parent; parent2 = w2.Parent; if (len1 > len2) { while (len1-- > len2) { parent1 = parent1.Parent; } } else { while (len2-- > len1) { parent2 = parent2.Parent; } } while (!object.ReferenceEquals(parent1, parent2) && !(parent1 is VDInternalUtility)) { parent1 = parent1.Parent; parent2 = parent2.Parent; } return(parent1); }
protected override void MergeRelate(ModelElement sourceElement, ElementGroup elementGroup) { // setup title if (sourceElement != null && sourceElement is VDWidget && ((VDWidget)sourceElement).WidgetType != WidgetType.View) { VDWidget widget = (VDWidget)sourceElement; if (widget.HasWidgetTitle && widget.Title == null) { widget.Title = this.Store.ElementFactory.CreateElement(VDWidgetTitle.DomainClassId) as VDWidgetTitle; } } // custom merge relate if (sourceElement != null && sourceElement is ICustomMerge) { ((ICustomMerge)sourceElement).MergeTo(this, elementGroup); return; } base.MergeRelate(sourceElement, elementGroup); }
public void MergeTo(VDWidget targetWidget, ElementGroup elementGroup) { targetWidget.Children.Add(this); // the order of creating children is import, why?? // first children, then grand-children??? VDHoriContainer headContainer = this.Store.ElementFactory.CreateElement(VDHoriContainer.DomainClassId, new PropertyAssignment(VDContainer.TagDomainPropertyId, HEADS_CONTAINER_TAG), new PropertyAssignment(VDContainer.HasLeftAnchorDomainPropertyId, true), new PropertyAssignment(VDContainer.HasRightAnchorDomainPropertyId, true), new PropertyAssignment(VDContainer.HasTopAnchorDomainPropertyId, true)) as VDHoriContainer; VDFullFilledContainer bodyContainer = this.Store.ElementFactory.CreateElement(VDFullFilledContainer.DomainClassId, new PropertyAssignment(VDContainer.TagDomainPropertyId, BODYS_CONTAINER_TAG), new PropertyAssignment(VDContainer.HasLeftAnchorDomainPropertyId, true), new PropertyAssignment(VDContainer.HasRightAnchorDomainPropertyId, true), new PropertyAssignment(VDContainer.HasBottomAnchorDomainPropertyId, true)) as VDFullFilledContainer; VDHoriSeparator hSeparator = this.Store.ElementFactory.CreateElement(VDHoriSeparator.DomainClassId, new PropertyAssignment(VDHoriSeparator.DefaultYDomainPropertyId, 0.5)) as VDHoriSeparator; hSeparator.TopWidget = headContainer; hSeparator.BottomWidget = bodyContainer; this.Children.Add(headContainer); this.Children.Add(bodyContainer); this.Children.Add(hSeparator); VDTabHead head = this.Store.ElementFactory.CreateElement( VDTabHead.DomainClassId, new PropertyAssignment(VDTabHead.TabTitleDomainPropertyId, "New Tab")) as VDTabHead; VDTabBody body = this.Store.ElementFactory.CreateElement(VDTabBody.DomainClassId) as VDTabBody; this.ActiveHead = head; head.Body = body; headContainer.Children.Add(head); bodyContainer.Children.Add(body); }
public NewActionHandler SetSource(VDWidget source) { m_cmbEvent.Items.Clear(); if (source != null) { m_txtSource.Text = string.Format("[{1}] {0}", source.WidgetName, source.WidgetType.ToString()); if (source.SupportedEvents != null) { m_cmbEvent.Items.AddRange(source.SupportedEvents.ToArray()); if (m_cmbEvent.Items.Count > 0) { m_cmbEvent.SelectedIndex = 0; } } } else { m_txtSource.Text = string.Empty; } m_cmbEvent.Enabled = true; return(this); }
public abstract VDWidget Resolve(VDWidget sourceWidget);
// when a widget lost its focus, reset the ActiveLinkedWidget of its CodeSnippetEditor protected override void OnSelectionChanging(EventArgs e) { base.OnSelectionChanging(e); ShapeElement shape = this.PrimarySelection as ShapeElement; if (shape == null || shape.ModelElement == null) { return; } VDWidget widgetLosingSelection = shape.ModelElement as VDWidget; if (widgetLosingSelection == null) { return; } VDCodeSnippet codeEditor2Reset = null; if (widgetLosingSelection is VDCodeSnippet) // reference mode codesnippet editor is losting selection { // if new selected shape is Title of code snippet, don't reset it var primaryItem = this.CurrentDesigner.Selection.PrimaryItem; if (primaryItem != null && primaryItem.Shape != null && primaryItem.Shape is VDWidgetTitlePort && primaryItem.Shape.ModelElement != null && ((VDWidgetTitle)primaryItem.Shape.ModelElement).Widget == widgetLosingSelection) { // ... } else if (((VDCodeSnippet)widgetLosingSelection)._Mode.HasFlag(E_CodeSnippetMode.Reference)) { codeEditor2Reset = widgetLosingSelection as VDCodeSnippet; } } else if (widgetLosingSelection.CodeSnippetEditor != null) { VDCodeSnippet newSelectedCodeSnippet = null; // check if the new selected element is EVAACodeSnippet or EVAARawSnippet if (this.CurrentDesigner.Selection != null) { var primaryItem = this.CurrentDesigner.Selection.PrimaryItem; if (primaryItem != null && primaryItem.Shape != null) { if (primaryItem.Shape is VDCodeSnippetShape) { newSelectedCodeSnippet = primaryItem.Shape.ModelElement as VDCodeSnippet; } else if (primaryItem.Shape is VDWidgetTitlePort) // new selection is the Title of code snippet widget { VDWidgetTitle title = primaryItem.Shape.ModelElement as VDWidgetTitle; if (title != null && title.Widget is VDCodeSnippet) { newSelectedCodeSnippet = title.Widget as VDCodeSnippet; } } } } // new selection is the code editor of previously selected widget, // in this case, don't reset the ActiveLinkedWidget of the code viewer if (newSelectedCodeSnippet == null || widgetLosingSelection.CodeSnippetEditor != newSelectedCodeSnippet) { codeEditor2Reset = widgetLosingSelection.CodeSnippetEditor; } } if (codeEditor2Reset != null) { using (Transaction trans = this.DocData.Store.TransactionManager.BeginTransaction("Clear Active Linked Widget")) { codeEditor2Reset.ActiveLinkedWidget = null; trans.Commit(); } } }
/// <summary> /// for some actions, maybe there are some predefined model members /// </summary> /// <param name="sourceWidget"></param> /// <param name="targetWidget"></param> /// <param name="action"></param> /// <returns></returns> public List <ActionModelMemberInfo> GetActionModelCandidateMemberList(VDWidget sourceWidget, VDWidget targetWidget, VDClientAction action) { return(new List <ActionModelMemberInfo>()); }
public List <WidgetClientMember> GetWidgetClientMemberList(VDWidget widget) { return(new List <WidgetClientMember>()); }
public WidgetTreeWalker(VDWidget rootWidget) { m_rootWidget = rootWidget; }
public IWidgetTreeWalker CreateWalker(VDWidget rootWidget) { return(new WidgetTreeWalker(rootWidget)); }
public LayoutWalker(VDWidget rootWidget) { m_rootWidget = rootWidget; }
protected virtual bool onPropagateDeletingParent(VDWidget parentWidget) { parentWidget.Delete(); return(true); }
private static ElementLink ConnectSourceToTarget(ModelElement source, ModelElement target) { if (source is VDEventBase && target is VDActionBase) { VDEventBase evt = source as VDEventBase; VDActionBase act = target as VDActionBase; evt.TargetComponents.Add(act); return(R_Event2Component.GetLink(evt, act)); } else if (source is VDActionJoint && target is VDViewComponent) { VDActionJoint joint = source as VDActionJoint; VDViewComponent tgt = target as VDViewComponent; joint.TargetComponents.Add(tgt); return(R_ActionJoint2Component.GetLink(joint, tgt)); } else if (source is VDViewComponent && target is VDActionBase) { VDViewComponent srcComponent = source as VDViewComponent; VDActionBase targetAction = target as VDActionBase; Component2ActionDialog dlg = new Component2ActionDialog(); dlg.SetComponentAndAction(srcComponent, targetAction); dlg.ShowDialog(); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { IEventInfo evtInfo = dlg.SelectedEvent; VDEventBase newEvent = evtInfo.CreateEvent(srcComponent); newEvent.Widget = srcComponent; newEvent.TargetComponents.Add(targetAction); return(R_Event2Component.GetLink(newEvent, targetAction)); } } else if (source is VDEventBase && target is VDViewComponent) // create new action { VDEventBase sourceEvent = source as VDEventBase; VDViewComponent targetComponent = target as VDViewComponent; Component2ComponentDialog dlg = new Component2ComponentDialog(false); dlg.NewAction.SetSourceEvent(sourceEvent).SetTarget(targetComponent); dlg.ShowDialog(); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { IActionInfo actInfo = dlg.NewAction.SelectedAction; VDActionBase newAct = actInfo.CreateAction(sourceEvent.Partition); VDWidget.GetCommonParent(sourceEvent.Widget, targetComponent).Children.Add(newAct); //sourceEvent.Widget.Parent.Children.Add(newAct); sourceEvent.TargetComponents.Add(newAct); IActionJointInfo jointInfo = dlg.NewAction.SelectedJoint; VDActionJoint newJoint = jointInfo.CreateActionJoint(newAct, targetComponent); newJoint.Widget = newAct; newJoint.TargetComponents.Add(targetComponent); return(R_ActionJoint2Component.GetLink(newJoint, targetComponent)); } } else if (source is VDViewComponent && target is VDViewComponent) // create new action or target { VDViewComponent srcComponent = source as VDViewComponent; VDViewComponent tgtComponent = target as VDViewComponent; Component2ComponentDialog dlg = new Component2ComponentDialog(); dlg.NewAction.SetSource(srcComponent).SetTarget(tgtComponent); dlg.NewTarget.SetSource(srcComponent).SetTarget(tgtComponent); dlg.ShowDialog(); if (dlg.DialogResult == System.Windows.Forms.DialogResult.OK) { if (dlg.IfCreateNewAction) { IEventInfo evtInfo = dlg.NewAction.SelectedEvent; VDEventBase newEvent = evtInfo.CreateEvent(srcComponent); newEvent.Widget = srcComponent; IActionInfo actInfo = dlg.NewAction.SelectedAction; VDActionBase newAct = actInfo.CreateAction(srcComponent.Partition); VDWidget.GetCommonParent(srcComponent, tgtComponent).Children.Add(newAct); //srcComponent.Parent.Children.Add(newAct); newEvent.TargetComponents.Add(newAct); IActionJointInfo jointInfo = dlg.NewAction.SelectedJoint; VDActionJoint newJoint = jointInfo.CreateActionJoint(newAct, tgtComponent); newJoint.Widget = newAct; newJoint.TargetComponents.Add(tgtComponent); return(R_ActionJoint2Component.GetLink(newJoint, tgtComponent)); } else { IActionJointInfo jointInfo = dlg.NewTarget.SelectedJoint; VDActionJoint joint = jointInfo.CreateActionJoint(srcComponent, tgtComponent); joint.Widget = srcComponent; joint.TargetComponents.Add(tgtComponent); return(R_ActionJoint2Component.GetLink(joint, tgtComponent)); } } } return(null); }