Visual Studio Extension with custom command and subcommands - visual-studio-extensions

I'm trying to create a simple Visual Studio Extension using Visual Studio 2017 that adds commands to the project context menu in the Solution Explorer. I'd like to add my commands grouped together in a main option and then from that main option I would like my commands to be accessible, just like how the Add->New item, Add->Existing item, Add->Class etc. works for in the context menu of the project.
After going through the documentation here's what I have come up with so far for my vsct file:
<Commands package="guidMainItemPackage">
<Groups>
<Group guid="guidMainItemPackageCmdSet" id="MyMenuGroup" priority="0x0600" />
<Group guid="guidMainItemPackageCmdSet" id="SubMenuGroup" priority="0x0601" />
</Groups>
<Buttons>
<Button guid="guidMainItemPackageCmdSet" id="MainItemId" priority="0x0100" type="Button">
<Parent guid="guidMainItemPackageCmdSet" id="MyMenuGroup" />
<Icon guid="guidImages" id="bmpPic1" />
<Strings>
<ButtonText>Invoke MainItem</ButtonText>
</Strings>
</Button>
<Button guid="guidMainItemPackageCmdSet" id="cmdidSubItem" priority="0x0101" type="Button">
<Parent guid="guidMainItemPackageCmdSet" id="SubMenuGroup" />
<Icon guid="guidImages1" id="bmpPic1" />
<Strings>
<ButtonText>Invoke SubItem</ButtonText>
</Strings>
</Button>
</Buttons>
<Bitmaps>
<Bitmap guid="guidImages" href="Resources\MainItem.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough" />
<Bitmap guid="guidImages1" href="Resources\SubItem.png" usedList="bmpPic1, bmpPic2, bmpPicSearch, bmpPicX, bmpPicArrows, bmpPicStrikethrough" />
</Bitmaps>
</Commands>
<CommandPlacements>
<CommandPlacement guid="guidMainItemPackageCmdSet" id="MyMenuGroup" priority="0xFFFF">
<Parent guid="guidSHLMainMenu" id="IDM_VS_CTXT_PROJNODE" />
</CommandPlacement>
<CommandPlacement guid="guidMainItemPackageCmdSet" id="SubMenuGroup" priority="0xFFFE">
<Parent guid="guidMainItemPackageCmdSet" id="MyMenuGroup" />
</CommandPlacement>
</CommandPlacements>
<Symbols>
<GuidSymbol name="guidMainItemPackage" value="{30f66380-eeeb-48bf-8554-0d63d87194af}" />
<GuidSymbol name="guidMainItemPackageCmdSet" value="{98ee7e8f-c421-4f0e-a9e9-86eab5141563}">
<IDSymbol name="MyMenuGroup" value="0x1020" />
<IDSymbol name="SubMenuGroup" value="0x1028" />
<IDSymbol name="MainItemId" value="0x0100" />
<IDSymbol value="4129" name="cmdidSubItem" />
</GuidSymbol>
<GuidSymbol name="guidImages" value="{b3c2dfad-df35-4e6b-880e-8018ce6c3d0f}">
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
<GuidSymbol value="{93d3ad22-fe33-40da-b85f-a926952e3914}" name="guidImages1">
<IDSymbol name="bmpPic1" value="1" />
<IDSymbol name="bmpPic2" value="2" />
<IDSymbol name="bmpPicSearch" value="3" />
<IDSymbol name="bmpPicX" value="4" />
<IDSymbol name="bmpPicArrows" value="5" />
<IDSymbol name="bmpPicStrikethrough" value="6" />
</GuidSymbol>
</Symbols>
So basically I have created added two Custom commands to my project, a button for each of the commands, a group for each of the buttons and a commandplacement for each of the groups (everything else is just the default generated vsct template).
My problem is that using the code above, on the first command is displayed and it has no subitems. What would be the correct vsct content to achieve the desired layout?

After some more trial and error (mostly error), I decided to go through the command definitions of Visual Studio itself to find a similar group of commands, and I've finally came up with the answer. Here's the steps you need to take to realize this structure:
Create a group and set the parent of this group to the Visual Studio projects context menu.
Create a menu, whose parent is the group created in step 1.
Create a second group, whose parent is the menu created in step 2.
Create buttons for only the subitems.
Create commandplacements for the subitems created in step 4 where you place each button in the group created in step 3.

Related

Removing parent nodes from xml file in r

I have xml output below. I am trying to remove parents using XML or xml2 library from R. I found a similar post here but those functions somehow gave me an error. I am trying to remove those parents until analysisdata parent. That is what I am going to parse.
<assessment>
<itembank />
<instrument id="797393 ">
<form id="Math G3">
<formitem id="8243" position="0" />
</form>
</instrument>
<admin id="797393 " instrument="797393 ">
<genatt name="adminperiod" value="SP19" />
<responseanalyses>
<responsebankref id="3M" />
<analysisdefs>
<analysisoption name="mark" value="no" />
<analysisoption name="notreached" value="ASNOTPRESENTED" />
<statentity type="item" id="8243" varname="I_8243">
<genatt name="type" value="CR" />
<genatt name="codestart" value="0" />
<genatt name="validcodes" value="2" />
<genatt name="omitcode" value="9" />
<genatt name="notpresentedcode" value="8" />
<statentity code="0.000000" id="0.000000" type="itemscorept" />
<statentity code="1.000000" id="1.000000" type="itemscorept" />
<statentity code="9" id="omit" type="itemscorept" />
</statentity>
<genatt name="type" value="CR" />
<genatt name="codestart" value="0" />
<genatt name="validcodes" value="2" />
<genatt name="omitcode" value="9" />
<genatt name="notpresentedcode" value="8" />
<statentity code="0.000000" id="0.000000" type="itemscorept" />
<statentity code="1.000000" id="1.000000" type="itemscorept" />
<statentity code="9" id="omit" type="itemscorept" />
</statentity>
<statentity id="DIFGROUP_TTS" varname="DIFGROUP_TTS" type="popgroup" description="DIFGROUP_TTS">
<statentity code="0.000000" id="0.000000" description="0.000000" samplesize="40501" type="popsubgroup" />
<statentity code="1.000000" id="1.000000" description="1.000000" samplesize="5532" type="popsubgroup" />
</statentity>
</analysisdefs>
<genatt name="xmloutputfile" value="J:\out.xml" />
<analysis creator="ST" description="" level="form" type="classical">
<analysisdata formid="Math G3">
<statentityref id="8243" type="item">
<statval type="OmitCount" value="0.000000" />
<statval type="NotReachedCount" value="43.000000" />
<statval type="PolyserialCorrelation" value="0.644181" />
<statval type="AdjustedPolyserial" value="0.644181" />
<statval type="AverageScore" value="0.223074" se="0.011957" />
<statval type="NCount" value="2609.000000" />
<statval type="StdevItemScore" value="0.416308" />
</statentityref>
</statentityref>
</statentityref>
</analysisdata>
</analysis>
</responseanalyses>
<responsebank findin="J:\outAM.am" sourcetype="AM" id="3M" />
</admin>
</assessment>
I tried
library(xml2)
library(XML)
newdoc <- xpathApply(doc, "/assessment/admin/responseanalyses") I get this error after running this: Error in UseMethod("xpathApply") :
no applicable method for 'xpathApply' applied to an object of class "c('xml_document', 'xml_node')". THis solution was suggested here.
After removing those parent nodes, I would like to have analysisdata node only after removing the assessment/admin/responseanalyses parent node. Desired out is like this below:
<analysisdata formid="Math G3">
<statentityref id="8243" type="item">
<statval type="OmitCount" value="0.000000" />
<statval type="NotReachedCount" value="43.000000" />
<statval type="PolyserialCorrelation" value="0.644181" />
<statval type="AdjustedPolyserial" value="0.644181" />
<statval type="AverageScore" value="0.223074" se="0.011957" />
<statval type="NCount" value="2609.000000" />
<statval type="StdevItemScore" value="0.416308" />
</statentityref>
</statentityref>
</statentityref>
</analysisdata>
Any thoughts?
Thanks!
You could use html_node from rvest library
rvest::html_node(doc, 'analysisdata')

Spring webflow Value of second parameter is not passed to subflow

Hi, I am using spring webflow2.4.4 with spring4.1.3.
I am trying to pass values between two flows as below.
sending value from flow first xml
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<set name="flowScope.value1" value="form.value1" />
<set name="flowScope.value2" value="form.value2" />
<transition on="success" to="view" />
</action-state>
<subflow-state id="view" subflow="flow/path/view">
<input name="value1" value="value1" />
<input name="value2" value="value2" />
...
</subflow-state>
reeving data in flow second view xml
<input name="value1" type="string" />
<input name="value2" type="string" />
now in view xml I am able to receive value for "value1" what I passed from first flow but getting value for 'value2' is null.
I tried switching the position in first flow as below
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
<transition on="success" to="view" />
</action-state>
<subflow-state id="view" subflow="flow/path/view">
<input name="value2" value="value2" />
<input name="value1" value="value1" />
...
</subflow-state>
Now I am able to see value of 'value2' but value for 'value1' receiving is null.
What is wrong here? see below debug logs for both example
1st trial
DEBUG SubflowState - Calling subflow 'flow/path/view' with input map['value1' -> 'ABCDF', 'value2' -> [null]]
2nd trial
DEBUG SubflowState - Calling subflow 'flow/path/view' with input map['value2' -> 'ABCDF', 'value1' -> [null]]
I want to pass both thew values to second flow but it second parameter is getting skipped somehow.
this is a very common mistake. the action state is transitioning when it gets a success and stops evaluating the rest of the commands.
you need to use <on-entry> to separate the two:
the commands you want to set or evaluate (value1 & value2)
the command that will be evaluated for the transition, here someMethod(form))
use this instead:
<action-state id="submit">
<on-entry>
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
</on-entry>
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<transition on="success" to="view" />
</action-state>
Thanks rptmat57, below code worked for me.
<action-state id="submit">
<evaluate expression="someMethod(form)" result="flowScope.saveStatus" />
<transition on="success" to="view" >
<set name="flowScope.value2" value="form.value2" />
<set name="flowScope.value1" value="form.value1" />
</transition>
</action-state>

Highlighting tab in p:tabview when I click a corresponding button

I am using multiple tabs in p:tabview. On top of this I have a series of static image (like progress bar) so that when I click the first image it move on to highlight the first tab and so on.
<h:form>
<h:commandLink action="#tab1">
<h:graphicImage src="image1"/>
</h:commandLink>
<p:tabView>
<p:tab title="tab1" id="tab1">
<ui:include src="some.xhtml></ui:include>
</p:tab>
.
.
.
.
</p:tabview>
<h:form>
If you want to avoid ajax requests you should be able to change tabs using jQuery. In order to do that you will need to specify a widgetVar to you tabView.
<p:tabView id="tabView" widgetVar="tabViewVar">
....
</p:tabView>
With this approach you can use only the image
<h:graphicImage value="image1" onclick="jQuery(jQuery(tabViewVar.jqId + " li[role=tab] a").get(0)).trigger("click");" />
<h:graphicImage value="image2" onclick="jQuery(jQuery(tabViewVar.jqId + " li[role=tab] a").get(1)).trigger("click");" />
<h:graphicImage value="image3" onclick="jQuery(jQuery(tabViewVar.jqId + " li[role=tab] a").get(2)).trigger("click");" />
...
In case you don't mind extra ajax requests, you can do that as follows:
<p:commandLink action="#{tabViewBean.submit}" process="#this" update="tabView">
<h:graphicImage value="image1" />
<f:setPropertyActionListener value="0" target="#{tabViewBean.activeIndex}" />
</p:commandLink>
<p:commandLink action="#{tabViewBean.submit}" process="#this" update="tabView">
<h:graphicImage value="image2" />
<f:setPropertyActionListener value="1" target="#{tabViewBean.activeIndex}" />
</p:commandLink>
<p:commandLink action="#{tabViewBean.submit}" process="#this" update="tabView">
<h:graphicImage value="image3" />
<f:setPropertyActionListener value="2" target="#{tabViewBean.activeIndex}" />
</p:commandLink>

Alfresco's activiti add html file element in form

I want to add a file upload html element in my process definition's start even in form.
<startEvent id="start" name="Start">
<extensionElements>
<activiti:formProperty id="name" name="Name"
type="string" required="true" />
<activiti:formProperty id="emailAddress" name="Email Address"
type="string" required="true" />
<activiti:formProperty id="income" name="Income"
type="long" required="true" />
<activiti:formProperty id="loanAmount" name="Loan Amount"
type="long" required="true" />
</extensionElements>
</startEvent>
I want to add a file uploader at the end to take file from user and process it further. I tried using file data type but of no use. Please guide as to how can I add a file element here.
Thanks
Append this for an upload field:
<activiti:formProperty id="attachfile" name="Atatch File"
type="upload" required="true" />

Spring Webflow : how do I pass an attribute from one flow to another during a transition?

I have an action-state that evaluates an expression and then transitions to various other states depending on the result. One of the result states is a subflow-state that hands control to another flow, example;
<action-state id="doWork">
<evaluate expression="someAction.doWork(someInput)" />
<transition on="WORKSUCCESS" to="workSuccess" />
<transition on="WORKFAIL" to="fixFail" />
</action-state>
<subflow-state id="fixFail" subflow="someOtherPlace/someOtherWorkToFixFail">
<input name="someNumber" value="1" type="java.lang.Integer" />
<transition on="finish" to="workSuccess" />
</subflow-state>
As you can see I can pass an input into the subflow via the input tag but my question is how can I specify and pass additional inputs that I want present if and only if the subflow-state is being called from the transition WORKFAIL? Assume the subflow-state "fixFail" can be called from other action-states.
I've tried things similar to the following with no effect;
<action-state id="doWork">
<evaluate expression="someAction.doWork(someInput)" />
<transition on="WORKSUCCESS" to="workSuccess" />
<transition on="WORKFAIL" to="fixFail">
<attribute name="newInput" value="3000" type="java.lang.Integer" />
</transition>
</action-state>
<subflow-state id="fixFail" subflow="someOtherPlace/someOtherWorkToFixFail">
<input name="someNumber" value="1" type="java.lang.Integer" />
<input name="someNumber2" value="flowScope.newInput" type="java.lang.Integer" />
<transition on="finish" to="workSuccess" />
</subflow-state>
There are three ways you can do this. You can do it through the conversation, session or as attributes passed in.
ConversationScope: If a field is in the conversationScope the field is visible anywhere in that specific flow as well as that flow's subflows (and their transitions)
SessionScope: (Probably not what you
want) Is visible to all flows and
their subflows
Finally you can pass the field as an attribute into the subflow state for example
<subflow-state id="fixFail" subflow="someOtherPlace/someOtherWorkToFixFail">
<input name="someNumber" value="1" type="java.lang.Integer" />
<input name="someNumber2" value="flowScope.newInput" type="java.lang.Integer" />
<transition on="finish" to="workSuccess" />
</subflow-state>
In your subflow's xml
<?xml version="1.0" encoding="UTF-8"?>
<flow>
<input name="someNumber"/>
<input name="someNumber2"/>
...
</flow>
In this example someNumber and someNumber two are passed in as attributes to your subflow. In which you can evaluate them as ${someNumber}
Edit:
This is to address your comment question. If you wanted to set a variable in the conversation scope on a specific transition you can do:
<transition on="WORKFAIL" to="fixFail" >
<set name="conversationScope.someVariable" value="Hello World"/>
</transition>
Then in your jsp
${someVariable} <!-- This will print out 'Hello World' -->

Resources