Set TextArea text dynamically by script - install4j

This a follow-up question to Console output on Installation screen?
I've configured a screen that contains a Text area component ("log.display") that should display what happened during my installation. The installation runs in a script that is attached to this screen. After finishing an installation step I do something like this (displayLog is initialized before):
displayLog = displayLog + currentStep + " done. \n";
context.setVariable("log.display",displayLog);
Unfortunatelly the Text area component is not updated by this. What can (must) I do to update the Text area dynamically from my script?
EDIT:
I found:
formPanelContainer = (FormPanelContainer)context.getScreenById(<screenID>);
formPanelContainer.getFormEnvironment().reinitializeFormComponents();
this seems to work, but there is one problem with that: If the "log" displayed with this solution contains more lines than the Text area can display, it shows the vertical scrollbar but doesn't scroll to the last line automatically. Is there a way to let the Text area do that?
And another question: Is it possible to ask context for the current screen without specifying a screenID (what can change)?
thanks!
Frank

The solution for my problem seems to be: get the ConfigurationObject of the TextArea component:
FormPanelContainer formPanelContainer = (FormPanelContainer)context.getScreenById(<ScreenID>);
FormEnvironment formEnvironment = formPanelContainer.getFormEnvironment();
FormComponent logComponent = formEnvironment.getFormComponentById(<TextAreaComponentID>);
JTextArea logComponentObject = (JTextArea)logComponent.getConfigurationObject();
and each time, something has to be logged:
logComponentObject.append("Text to log" + "\n");
logComponentObject.setCaretPosition(logComponentObject.getDocument().getLength());
This works fine in my setup.

Related

Unity editor - How to stop field from turning blue when its edited

I am making a tool in Unity to build your project for muliple platforms when you press a button.
I started with the preferences window for the tool, and came up with an anoying thing. Whenever I change the enum value of the EnumPopup field, the field turns blue in the editor window. Is there a way to disable this?
See how in the 2nd picture the field is not blue, and in the 3rd picture the field has changed to blue? How do I prevent this from happening?
Thanks in advance!
Difficult to help without having the rest of your code.
This is Unity built-in behaviour. I tried a lot of stuff see here to disable / overwrite the built-in coloring of prefix labels but had no luck so far.
A workarround however might be to instead use an independent EditorGUI.LabelField which will not be affected by the EnumPopup together with the EditorGUIUtility.labelWidth:
var LabelRect = new Rect(
FILEMANAGEMENT_ENUMFIELD_RECT.x,
FILEMANAGEMENT_ENUMFIELD_RECT.y,
// use the current label width
EditorGUIUtility.labelWidth,
FILEMANAGEMENT_ENUMFIELD_RECT.height
);
var EnumRect = new Rect(
FILEMANAGEMENT_ENUMFIELD_RECT.x + EditorGUIUtility.labelWidth,
FILEMANAGEMENT_ENUMFIELD_RECT.y,
FILEMANAGEMENT_ENUMFIELD_RECT.width - EditorGUIUtility.labelWidth,
FILEMANAGEMENT_ENUMFIELD_RECT.height
);
EditorGUI.LabelField(LabelRect, "File relative to");
QuickBuilder.Settings.Relation = (QuickBuilder.Settings.PathRelation)EditorGUI.EnumPopup(EnumRect, QuickBuilder.Settings.Relation);
As you can see the label is not turned blue while the width keeps being flexible
Sidenotes
Instead of setting values via edito scripts directly like
QuickBuilder.Settings.Relation = you should always try and use the proper SerializedProperty. It handles things like Undo/Redo and also marks the according objects and scenes as dirty.
Is there also a special reason why you use EditorGUI instead of EditorGUILayout? In the latter you don't need to setup Rects.
EditorGUILayout.BeginHorizontal();
{
EditorGUILayout.LabelField("File relative to", GUILayout.Width(EditorGUIUtility.labelWidth));
QuickBuilder.Settings.Relation = (QuickBuilder.Settings.PathRelation)EditorGUILayout.EnumPopup(QuickBuilder.Settings.Relation);
}
EditorGUILayout.EndHorizontal();

How To Position a Picture on A Second Page Of A Word Document VB6

I am making a program that repeatedly creates pages of an undefined quantity, and on the top of all the pages is a logo that is in a certain position. If I have everything in a for loop and at the end I include these commands to make a page break:
Set oRng = oDoc.Bookmarks("\EndOfDoc").Range
oRng.InsertBreak
The second time (and subsequent times) the table I make goes on the the next page, but the image does not. I have tried setting the "top" property to
distFromTop + pageLength * pageNumber.
I would assume it might have to do with the anchor property, but I have no idea what data type that even gets or how it affects the placement
I insert the image using:
oDoc.Shapes.AddPicture "C:\Users\name\Desktop\file.jpg", , , CentimetersToPoints(1.3), CentimetersToPoints(0.9 + pageLength * j), CentimetersToPoints(6.1), CentimetersToPoints(2.9)
The picture adds multiple times, but both to .9 from the top on the first page and 1.3 from the left, on the first page.
How can I make the pic go .9 from the top of a certain page
EDIT: I would like to avoid putting it in a header because that would mess up the alignment of the other elements of the doc
Ok, So what worked for me was this:
Set oRng = oDoc.Bookmarks("\EndOfDoc").Range
oRng.InsertBreak
oDoc.Shapes.AddPicture "C:\Users\me\Desktop\file.jpg", , , CentimetersToPoints(1.3),
CentimetersToPoints(0.9), CentimetersToPoints(6.1), CentimetersToPoints(2.9),
oDoc.Bookmarks("\EndOfDoc").Range
I still don't quite understand why it works, because the documentation for a range objects / anchors was fairly hard for me to understand... I tried this out and this worked. For my purposes that worked, but if anyone knows why that works I would love to know
Thanks for your answers

RHEL - zenity: needing to use options with only one button and scrollbars at same time

I need to show a text and by using "zenity --text-info" I guess it is the best approach. But I don't realize why zenity thinks I would need two buttons just to show a paragraph <= Actually, I don't ! => Then I tried with "--warning" or "--info" options because they only show one button ... now my problen is when the paragraph is pretty long, those options don't show scrollbars. Is there a way using zenity to get "only one button" + "scrollbars" at the same time?
By now I'm using "--text-info" and "--cancel-label="" " to clear the unused button label ... but it is not stethic at all.
I'm running on RHEL 7.3.
Thanks in advance.

How can I wrap contents of a textbox that's next to a picture control?

I have the following defined in Active Reports 8 (a picture control with a border--shape--next to textbox fields):
I have more textbox fields below the two defined here, but this is just to illustrate my issue.
Anyway, how do I get the first textbox to wrap without overlapping the second textbox like below?
When I get rid of the picture and shape on the left, everything wraps as expected.
This is actually a known issue and is caused when controls are placed adjacent to each other and one side of the control has a larger height as compared to the ones on the other. Considering your example, let's say the top textbox is TextBox1 and the bottom one is TextBox2. You can handle the BeforePrint event of the Detail section and resolve this issue. For example take a look at the code below:
public void Detail_BeforePrint()
{
TextBox2.Top = TextBox1.Top + TextBox1.Height;
}
Hope this helps.

tinyMCE - I need to limit width/height of text entered

I have a tinyMCE textarea in which I want to limit how large, in pixels, whatever the user enters. Really, I do. I know this is not how most people use tinyMCE, but we are allowing clients to enter and format their own ad text for an ad that is a specific size (407px by 670px). So I want to limit what they can enter to that particular size. I can't limit the number of characters, because that would vary depending on font style/size. I actually want the input to fit within a particular sized box.
I have successfully sized the editor area and turned off the resizing of the editor and the scrollbars (in Firefox anyway), but it will still let the user continue typing past the edges of the box. Is there ANY way to prohibit this?
http://www.retailpromoinc.com/RestaurantAdvertising.php
Thank you for your consideration, I have been wrestling with this for HOURS!
Its a complicated one, as far as i know is there no feature from the TinyMCE Api to do so. What you could try to do is to configure the iFrame that is created by TineMCE.
By:
function iFrameConfig() {
var iFrame = document.getElementById('textareaid_ifr');
iFrame.setAttribute('scrolling', 'no');
iFrame.style.width = '300px';
iFrame.style.height = '600px';
}
Looks like you will have to write an own plugin for this. I will show you the steps necessary for this.
Here is a tutorial on howto write an own plugin, this is not difficult.
You will have to check for the editor content heigth for each of the users actions (keyup, paste, aso.). Use the predefined tinymce event handlers for this.
If the size of 670px is smaller than the real size you will have to undo the last user action automatically using the following line tinymce.get('my_editor_id').undoManager.undo();
I based my solution on Thariama's idea with undo (THX).
setup : function(ed) {
ed.wps = {}; // my namespace container
ed.wps.limitMceContent = function(ed) {
if ((ed.wps.$textcanvas.height() + ed.wps.textcanvasDummyHeight) > ed.wps.iframeHeight) {
ed.undoManager.undo();
}
};
ed.onKeyDown.add(ed.wps.limitMceContent);
ed.onChange.add(ed.wps.limitMceContent); // change is fired after paste too
ed.onInit.add(function(ed) {
// cache selectors and dimensions into namespace container
ed.wps.$iframe = $("textarea.tinymce").next().find("iframe");
ed.wps.iframeHeight = ed.wps.$iframe.height();
ed.wps.$textcanvas = $(ed.wps.$iframe[0].contentDocument.body);
ed.wps.textcanvasDummyHeight = parseInt(ed.wps.$textcanvas.css("marginTop"), 10) + parseInt(ed.wps.$textcanvas.css("marginBottom"), 10);
});
}
Working demo. Works on keyDown and paste. Tested only in FF 12 and Chrome.