How can I create a special character shortcut for an IntelliJ plugin? - intellij-idea

I would like to attach the shortcut ctrl + [ to an action in an IntelliJ plugin I'm writing.
For ctrl plus any letter, this works. However, for a square bracket, this doesn't seem to work. I have tried escpaing using \[.
For example, this doesn't work:
<action id="DoTheThingAction" class="DoTheThingAction" text="Do It" description="Does The Thing">
<keyboard-shortcut first-keystroke="ctrl \[" keymap="$default" />
</action>
While this works:
<action id="DoTheThingAction" class="DoTheThingAction" text="Do It" description="Does The Thing">
<keyboard-shortcut first-keystroke="ctrl w" keymap="$default" />
</action>
Do I need to do anything special to create a shortcut for a special character like "["?

You can't use [ or \[ directly. You need to use OPEN_BRACKET.
For example, this works:
<action id="DoTheThingAction" class="DoTheThingAction" text="Do It" description="Does The Thing">
<keyboard-shortcut first-keystroke="ctrl OPEN_BRACKET" keymap="$default" />
</action>

Related

How to define animations for all transitions at one spot?

I wanna use the same animations for different actions. Is there any way to define them at one spot like a stylesheet?
At the moment my nav_graph.xml looks like this:
<fragment
android:id="#+id/questionnaireFragment"
android:name="de.fragdichselbst.view.ui.QuestionnaireFragment"
android:label="fragment_questionnaire"
tools:layout="#layout/fragment_questionnaire" >
<action
android:id="#+id/action_questionnaireFragment_to_subjectFragment"
app:destination="#id/subjectFragment"
app:enterAnim="#anim/slide_in_right"
app:exitAnim="#anim/slide_out_left"
app:popEnterAnim="#anim/slide_in_left"
app:popExitAnim="#anim/slide_out_right" />
</fragment>
<fragment
android:id="#+id/subjectFragment"
android:name="de.fragdichselbst.view.ui.SubjectFragment"
android:label="fragment_subject"
tools:layout="#layout/fragment_subject" >
<argument
android:name="questionnaire_id"
app:argType="integer" />
<action
android:id="#+id/action_subjectFragment_to_quizSettingsFragment"
app:destination="#id/quizSettingsFragment"
app:enterAnim="#anim/slide_in_right"
app:exitAnim="#anim/slide_out_left"
app:popEnterAnim="#anim/slide_in_left"
app:popExitAnim="#anim/slide_out_right" />
<action
android:id="#+id/action_subjectFragment_to_savedQuizFragment"
app:destination="#id/savedQuizFragment" />
</fragment>
As you can see I use the same animations for each action. But what if I have multiple fragments and I wanna change the animations? I would have to change a lot of code lines. So I would like to have one spot where I define the animation for all transitions.

How to create sub menuitem in intellij plugin

I have create a Menu item under the Main menu however I want to create a submenu item like this image
I have used this xml tag in the plugin.xml for menu. I want to create a submenuitem like the red marking on the image.
<actions>
<!-- Add your actions here -->
<group id="MyPlugin.test" text="_" description="test">
<add-to-group group-id="MainMenu" anchor="last" />
<!--<action id="Myplugin.Textboxes" class="Mypackage.TextBoxes" text="Text _Boxes" description="A menu item" />
<action id="Myplugin.Dialogs" class="Mypackage.MyShowDialog" text="Show _Dialog" description="A menu item" />-->
<action id="testAndroidPlugin.MyAction" class="com.test.bijesh.MyActionClass" text="Create String"
description="The action implemented by MyActionClass class">
<!--<add-to-group group-id="MainMenu" anchor="after" relative-to-action="WindowMenu"/>-->
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt S"/>
</action>
<action id="testAndroidPlugin.ManageResources" class="com.test.bijesh.actions.ColorActions" text="Create Color"
description="The action implemented by ColorAction class">
<!--<add-to-group group-id="MainMenu" anchor="after" relative-to-action="WindowMenu"/>-->
<keyboard-shortcut keymap="$default" first-keystroke="ctrl alt C"/>
</action>
</group>
</actions>
Here's how we do it in Ceylon IDE:
<actions>
<group text="Ceylon" icon="/icons/ceylon.png" popup="true">
<action> ...</action>
<add-to-group group-id="ToolsMenu" anchor="last"/>
</group>
</actions>
This results in Tools > Ceylon > .... I think your version does not work because text="_" generates an empty text (_ is used for keyboard shortcuts).
A nested action:
<actions>
<group id="YourCompany.All" popup="true" class="com.company.CompanyActionGroup">
<add-to-group group-id="MainMenu" anchor="before" relative-to-action="HelpMenu"/>
</group>
<group id="YourCompany.All.Foo" popup="true" class="com.company.FooActionGroup">
<add-to-group group-id="YourCompany.All" anchor="first"/>
<action
id="some.action"
text="Do Action"
description="This will do the action."
class="com.yourcompany.FooAction"
icon="/icons/foo.svg"
/>
</group>
</actions>
This gives
Menu: A > B > Do Action
(Where the text for A & B are defined in the class's referenced).

path attribute of forward tag in struts-config.xml file

<action-mappings>
<action name="loginAction" path="/loginAction"
type="com.xx.yy.actions.LoginAction" scope="request"
validate="false">
<forward name="landingPage" path="landingpage" />
<forward name="error" path="errorpage" />
</action>
<action name="admin" path="/adminAction"
type="com.xx.yy.actions.AdminHome" scope="request"
validate="true" input="/jsp/login.jsp">
<forward name="success" path="/jsp/admin/admin.jsp" />
<forward name="failure" path="/jsp/admin/admin.jsp" />
</action>
</action-mappings>
In the above code path attribute of forward tag is landingpage for action loginAction .
So in this case control takes to which page or action?In this context what is landingpage?Is it a jsp or another action?
In admin action path attribute of forward tags are jsps so its clear that control will be directed to jsp depending on logic in action class.
In that line...
<forward name="landingPage" path="landingpage" />
...the path attribute may be an Apache Tiles configuration name.

does not change the locale with using LocaleAction

i use struts 1.3 and want to make localization.
that's what I'm doing:
in struts-config.xml:
<form-bean name="English" type="org.apache.struts.action.DynaActionForm">
<form-property name="language" type="String" initial="en" />
</form-bean>
<form-bean name="Russian" type="org.apache.struts.action.DynaActionForm">
<form-property name="language" type="String" initial="ru" />
</form-bean>
<action-mappings>
<action path="/English" name="English"
type="org.apache.struts.actions.LocaleAction">
<forward name="success" path="/index.jsp" />
</action>
<action path="/Russian" name="Russian"
type="org.apache.struts.actions.LocaleAction">
<forward name="success" path="/index.jsp" />
</action>
<controller processorClass="org.apache.struts.tiles.TilesRequestProcessor" />
on jsp.page
<html:link action="/Russian">
<bean:message key="jsp.header.russian"/>
</html:link>
<html:link action="/English">
<bean:message key="jsp.header.english"/>
</html:link>
maybe i do something wrong? any ideas?
P.S. yes, i have messages_ru.properties and messages_en.properties.
Oh, I found the reason, struts do not know of this type as a String.
<form-property name="language" type="java.lang.String" initial="en" />

mutiple button in HTML in struts framework

I have five buttons in my HTML code each doing differnt task . I have written one form bean and five different action classes since on click of submit button all five buttons do completely different business operation altoghether.
Am I doing it right . If so how to capture this scenarion in my struts.xml
Generally, I like to have 1 Action class for every action a user can take. So if they are executing different business logic, then I think you are right to have just 5 different Action classes.
1 form bean also probably makes sense, if all the buttons correspond to the same form.
As far as how to capture this in the struts.xml, I don't think you need to do anything special. Just configure the 5 actions as you would normally, and specify 5 different actions, all using the same form bean.
<!--This example is not tested, it is just to give you an idea-->
<form-beans>
<form-bean
name="form1"
type="app.Form1"/>
</form-beans>
<action-mappings>
<action
path="/Action1"
type="app.Action1"
name="form1"
input="/pages/input.jsp">
<forward
name="success"
path="/pages/success.jsp"/>
<forward
name="failure"
path="/pages/input.jsp"/>
</action>
<action
path="/Action2"
type="app.Action2"
name="form1"
input="/pages/input.jsp">
<forward
name="success"
path="/pages/success.jsp"/>
<forward
name="failure"
path="/pages/input.jsp"/>
</action>
<action
path="/Action3"
type="app.Action3"
name="form1"
input="/pages/input.jsp">
<forward
name="success"
path="/pages/success.jsp"/>
<forward
name="failure"
path="/pages/input.jsp"/>
</action>
<action
path="/Action4"
type="app.Action4"
name="form1"
input="/pages/input.jsp">
<forward
name="success"
path="/pages/success.jsp"/>
<forward
name="failure"
path="/pages/input.jsp"/>
</action>
<action
path="/Action5"
type="app.Action5"
name="form1"
input="/pages/input.jsp">
<forward
name="success"
path="/pages/success.jsp"/>
<forward
name="failure"
path="/pages/input.jsp"/>
</action>
</action-mappings>