Smart GWT: localization of context menu in listgrid with dynamic title - gwt

Im localizing my GWT app, and I want to localize the context menu in my listgrid (SmartGWT). According to the doc, I can set the title of group/ungroup by:
http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/grid/ListGrid.html#setGroupByText(java.lang.String)
public void setGroupByText(String groupByText)
This is a dynamic string - text within \${...} will be evaluated as JS code when the message is displayed, with title available as a variable containing the field title. Default value returns "Group by " + the field's summary title.
I want to put "Group by XXX" (in different languages), where XXX is the column title, and I should be able to do that with a dynamic string, which evaluates the JS title variable. But how? I need a concrete example, such as:
list.setGroupByText("GROUP BY \\${title}"); // DOES NOT WORK!!!
list.setGroupByText("GRUPPÉR MED \\${title}"); // DOES NOT WORK!!!
Any suggestions?

Ok, I might be very stupid. Here's the answer:
list.setGroupByText("Group by ${title}");
So, in danish that would be:
list.setGroupByText("Gruppér efter ${title}");

Related

Can I get the style object and Get the property of it?

I wanted to use javascript addin's to get the style object and get some proerties of it for example maybe paragraph property and get the indentation of this specific style but I cant get to the style object and get the property of it. I know that there is a collection of every style in document but I cant get any properties of those. There is way to change style in selected range but it could be very fine if I could get style from the range maybe and like i said erlier get some properties of it.
This is code in Word VBA that is example of property i want to see value of:
documents("[file_name]").Styles([index]).ParagraphFormat.LeftIndent
We can set the value to any variable:
Dim var As Integer/Long
Let var = documents("[file_name]").Styles([index]).ParagraphFormat.LeftIndent
As far as I know the office.js API for Word does not currently (v. 1.4) provide any Style objects with the kind of properties that you are used to seeing via the Object Model that VBA uses. All it lets you do is get the style names (localized and built-in) associated with another object such as a range, a paragraph, or various style properties associated with a table.
i.e. at the moment, the only way you would be able to get detailed style information would probably be to retrieve the document's XML and interpret that. Hard, I suspect.
I think that probably answers your question but in case you were looking for code to retrieve a style, to get the style name of a range, say, is straightforward, e.g. in Script Lab you can start with one of the basic JavaScript samples and modify its run function so it looks like this:
function run() {
return Word.run(function(context) {
var range = context.document.getSelection();
range.load("style");
return context.sync().then(function() {
console.log('The selected style was "' + range.style + '".');
});
});
}
Precisely which style name you get depends on the range - if you select two paragraphs with different styles, the style name will be "", and so on.

Reaching the referenced text from a Word interop field object

I am using Word interop to build a Word plugin. In this plugin I have a case where I want to examine all
Field objects in the document and when that field is a cross-reference to another place in the same document I need to be able to capture the text in the paragraph that the field is referring to.
I was able to get the name of the field object but there were no bookmarks defined in the Document although in Word I could click on the field to get to the other location.
Example field
Example field as code
referenced text I need to get
No Bookmark objects are defined
I tried to simulate the user clicking on the field by invoking DoClick() on it and then I accessed V_V_Scalar_Document_Generic.Application.Selection.Range.Text
but it gave nothing. I also tried the GoTo approach below but still didn't reach the referenced text.
System.Collections.Generic.List<string> L_V_List_String_Fields = new System.Collections.Generic.List<string>();
foreach (Field L_V_Scalar_Field_Item in V_V_Scalar_Document_Generic.Range.Fields)
{
try
{
if (L_V_Scalar_Field_Item.Type == WdFieldType.wdFieldRef)
// L_V_Scalar_Field_Item.Data --> gives COM exception
// L_V_Scalar_Field_Item.Code.ID --> blanks
// L_V_Scalar_Field_Item.DoClick() 'will not help because fields are not always hyperlinks
// L_V_Scalar_Field_Item.Result.Text --> gives the text of the field itself
// all variations I tried for the target parameter in the line below (last param) are not working
// V_V_Scalar_Document_Generic.[GoTo](Microsoft.Office.Interop.Word.WdGoToItem.wdGoToField, System.Type.Missing, System.Type.Missing, "_Ref28680085")
// Dim L_V_Scalar_String_Source as string = V_V_Scalar_Document_Generic.Application.Selection.Range.Text
L_V_List_String_Fields.Add($"CodeText:{L_V_Scalar_Field_Item.Code.Text} |FieldType:{L_V_Scalar_Field_Item.Type} |FieldKind:{L_V_Scalar_Field_Item.Kind} |SourceText:{"source text ??"}");
}
catch (Exception L_V_Scalar_Exception_Generic)
{
}
}
The bookmarks are not listed because Word has a convention that bookmarks with names starting with an underscore ("_") are "hidden". In the Insert->Links->Bookmark dialog box, you can see them if you check the "Hidden Bookmarks" box, but in the Find and Replace box, you have to enter the name manually.
Even when Bookmarks are hidden, you can reference them. So for example you should be able to do something like this (this is VBA syntax):
Dim TargetText As String
TargetText = ActiveDocument.Bookmarks("_Ref28680085").Range.Text
to get the text "covered" by the bookmark. In theory, you could use Goto, by using wdGotoBookmark instead of wdGotoField, except that I think it will only have a chance of working with the Selection object, not a Range object.
Depending on what type of cross-reference the user inserts, Word "covers" different parts of the referenced material. So you may need to construct the Range you really need, e.g. using the Bookmark's Range.Start to tell you which paragraph the reference is pointing at.

How to dynamically change dialog with select field

I'm new to Magnolia, and I'm making my own module.
I have a dialog box when adding a component and I want to change next fields below dynamically using a select field.
Example:
Select field with {"type 1", "type 2", ...}
IF "type 1" is selected
->show a text field below
ELSE
->show a basicUpload field below
Thanks in advance.
I believe same was already discussed here and few other places if you look over questions tagged "magnolia".
Long story short, fields are atomic, independent entities. They do not know about each other. So the only way to create such dynamic connection is over "parent" form. You need to extend form presenter and field factory (if you want select that would be SelectFieldFactory) and in there, when field is created, attach value changed or similar listener to it so when value is changed in the field, you can inform presenter to make some other field visible or hide it.
IIRC you can see example of that done in External Forms module (if you have access to enterprise code). Not sure if any of the community modules show the same.

properties file, {0} behind text is also displayed

I just created a properties file where I store my text.
In this SAP Walkthrough
for SAPUI5 the wrote the code like this
showHelloButtonText=Say Hallo
helloMsg=Hello {0}
The {0} is for the case that I want to set more parameters. But now the pop-up also displays the {0}. So the output is:
Hello {0}
The properties file is just a "File" in eclipse with the suffix ".properties", if this could help.
Thanks for any hints :)
Final result can be seen here: http://plnkr.co/edit/OGmJimjF2YZ46mv6DsF2?p=preview
What I did was the following:
When you want to bind a String with placeholders to a control in a view, you have to provide a formatter.
The formatter takes the placeholder String (Hello {0}) and the filler String and combines them
formatMsg: function(sMsg, sValue) {
return jQuery.sap.formatMessage(sMsg, sValue);
}
This formatter has to be called when your element is rendered, so you have to add it to your binding
<Label text="{
parts:[
{path:'i18n>helloMsg'},
{path:'/recipient/name'}
], formatter:'.formatMsg'}"
/>
The formatter takes two arguments, so we have to provide two values: The placeholder String and the value of the model.
The example in SAPs Walkthrough shows you both ways how to set the text of your message.
The first would be a static text, defined by:
helloMsg = Hello
The second option would be to use the {} brackets. This is a reference to different language options saved within a file in your workspace.
When you change the language of your browser it will then display different languages as set in your file.

Word forms - display a form value in text below the form

how to display a value from MS Word Form.
Eg:
I have a form with one dropdown list with following values:
DropDown1: a, b, c
When I select value a, I want to display the value in plain text. Eg:
Value of the selected field is: a.
I would prefere not to use vba.
You can use the (assuming DropDown1 is a ComboBox control) ComboBox's Change routine.
Private Sub DropDown1_Change()
Selection.TypeText DropDown1.Value
End Sub
If it is a "legacy form" (not a form with ActiveX controls or content controls, then
a. set the properties of the dropdown to calculate on exit, and the "bookmark" to (say) dropdown1.
b. put a { REF dropdown1 } field in the document where you want the value
c. protect the form in the usual way.
The value will only appear when the user tabs out of the dropdown.
It's not exactly "plain text", but it's not a form field either. If you need "genuine plain text", you would need code.
If it is a content control, then you would need to set up a Custom XML part and link the dropdown to it, then insert a plain text content control that was also linked to the same element/attribute in that part. That requires code at design time (or a third party add-in, or Word 2013) but not at run time.