I'm trying to create custom element for CallStudio. Something along the lines of built-in math element. It has to have some parameters and a button to open simple editor where I can enter multiple lines of text.
Dealing with parameters is easy, but I couldn't find any examples how to do this "button to open additional editor window". Can anyone point me to any samples?
Thank you!
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you are trying to pass Text as parameter to your Custom Configurable element, you could declare the field as TextField under setting configuration,
settingArray[n] = new Setting("TextEditor", "Enter Text Content",
"This setting is for large text content",
false, // It is not required
true, // It appears only once
true, // It allows substitution
Setting.TEXTFIELD);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Vinod,
Thank you for your suggestion.
At the moment I went with this suggestion. All is looking more or less fine but I have hit another problem - substitutions.
Textfield editor has substitutions enabled regardless if they are disabled for this parameter when Setting is created.
I couldn't find any way how to prevent substitution analysis happening on text field and data format I'm using involves {}.
I could replace curly brackets with some pattern and then replace them back in element logic itself, but then it looks like the way Hemal suggested - I have to create my own editor to modify textfield before saving..
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I assume you are looking for an editor similar to expression in Math element. Check for Math related classes in elements.jar. For example on CVP 8.5, it will be under:
C:\Cisco\CallStudio\eclipse\plugins\com.audiumcorp.studio.elements.core_8.5.1
You can look at the code for the same.
Hemal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hemal,
Thank you for suggestion.
In folder you mention contains only class files - pre-compiled java bytecode. Are those the files you were thinking about?
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Yes, you can decompile them.
Regards,
Hemal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hemal,
I decompiled class files - they use the same approach as Vinod suggested.
The problem with that is I need to disable substitution process in order to use curly brackets in text itself. Any ideas?
Thank you!
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Are you saying that you do not need the substitution functionality where the system will interpret what is there in the { } ? Could you give more details on what you are trying to accomplish ?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The real question is whether the updateApp.bat will allow you to use { }
for something other than specifying studio variable names! My guess is
that it won't.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can disable substitution when you define the setting for the TextField.
Just set the 2nd boolean to false.
Setting constructor:
string real-name, string display-name, string description, boolean is
setting required?, boolean is substitution allowed?, boolean is the
setting single?, typeOfSetting
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Janine,
I already tried setting false for "substitution allowed". Result is - on main settings tab substitution button is grayed out, but on dialog where I can enter text it is available and usable. It looks like text entry dialog is ignoring setting setup parameters.
I'm creating text field setting like this:
Setting tp = new Setting("matrix", "matrix", "Logic martix",
Setting.REQUIRED, Setting.SINGLE,
Setting.SUBSTITUTION_NOT_ALLOWED, Setting.TEXTFIELD);
At the moment I get exception while loading custom element if I leave {} in place. As far as I can tell I have only 2 options:
1. Leave {} as they are in text field. Catch java exception when I try to get setting value and in exception handler get original pre-substituted value. Problem is, I couldn't find function to get pre-substituted value.
2. Avoid {} in original textfield. I don't have control how data are entered, so solution would be mangle input data (search&replace {}, URL encode, MIME encode or just plain zip input text) before saving setting in CallStudio. Then, in element doAction, get mangled data and un-mangle them. Problem with this is - I have to have a way to create my own GUI for entering text or at least intervene with "Save" button on text entry dialog. And I couldn't find a way how to do it.
... and maybe 3rd option - use dynamic configuration class to do the mangling. But I don't know if dynamic config class gets access to pre-substituted vaues or post-substituted values. Couldn't find that info in docs as-well.
Any ideas I'm missing or suggestions on the ones I mentioned?
Thanks for looking at this! I know I'm still a newbie.
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If you set the boolean to false, then the {} button should be greyed out
from the Text box - that's a bug.
I can't think of anything else other than using a different character
instead of then replacing it using regular expressions in the
java code.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Since I cannot fix the bug, I agree that changing text content looks like easier way to proceed. Problem with this is - I don't have that many points where I can make changes.
1. create my own GUI for text field.
2. use dynamic configuration - if that has access to pre-substituted element data.
I don't have any experience with both points. GUI would be more cleaner solution, I think. But I have not seen any documentation how to do that.
I'll try with dynamic config class but I don't think it has access to pre-substituted element data.
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Why can't you just modify your doAction?
retrieve the Setting Value then do a string replacement?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I do not see why this cannot be done by replacing the value of the Setting to the appropriate one in your action class.
Hemal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Janine, Hemal,
I think I'm not clear enough in explaining the problem.
If I leave orignal textfield in CallStudio containing {} then I get exception when my application is run. Even in debugger. It validates fine, loads fine, just is not able to start.
For example. I have "matrix" setting like this: { some, text, in, curly, crackets }
When I try to run my app, I get this exception in the global error log:
04/08/2015 17:00:42.542, SERVER ERROR: An error occurred while loading application 'VMXLTest'.
com.audium.server.xml.ElementConfigException: There was an error evaluating substitution for the setting named 'JavaScript'.
...
...
Caused by: com.audium.server.xml.SubstitutionException: The substitute index specified does not match any subtitute elements in the XML file. The index specified was some, text, in, curly, crackets .
at com.audium.server.xml.SubstitutionConfig.parseSubstitution(SubstitutionConfig.java:126)
at com.audium.server.xml.ElementConfig.addSettingValue(ElementConfig.java:277)
So, the solution would be to replace {} with some other text like <<< and >>>, for example.
OK. In my doAction I can just do replacement of <<< >>> to { } like:
String matrixString = (String) conf.getSettingValue(MX_STRING, data);
matrixString = matrixString.replaceAll("<<<", "{");
matrixString = matrixString.replaceAll(">>>", "}");
This far is fine, but where do i do replacement from {} to <<<>>> ?
I would like this replacement to be dome automatically. Like, user enters text with {} in textfield in CallStudio interface, but it is saved as text containing <<<>>>. Then I can just do my doAction stuff and all is fine.
Hopefully I got the situation explained clear enough. Sorry for long post.
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
No, the idea is that the user doesn't enter { } - that they learn to use
a different key for that (maybe square brackets instead).
Then in the doAction you convert square brackets into braces.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All of this can built in the logic in the action class using java regex, string replacement etc. What exactly is the application business wise that you are trying to build ?
Hemal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Hemal,
The element I'm trying to build is for self-service application.
Customer will generate a martix of data using their in-house application and copy/paste it into CallStudio. Add some more parameters and using this matrix some menu options and voice prompts will be generated.
I doubt that they will change in-house app for me as the output is used elsewhere as well. The output actually is several hundred lines, so I would prefer not adding extra manipulations (like replacing {} before copy/pasting. That's why I'm trying to do input preparation in CallStudio, in input dialog.
To be honest, my plan is to actually not replace {} with something in CallStudio, but do some kind of encoding of the whole input string - URLencode, uuencode or something. And in doAction do decode. This will guarantee, that if in future additional data crops up input, I don't get surprises from substtitution.
Ervins
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.