Install4j - combo box component configuration conditions - java

We are using Installer 6.1.6.
Today we support SQL server authentication and I wish to add a new ability of Windows authentication mode.
Our database configuration is set as configuration form and I want to add a new combo-box form component which will include the 2 server authentications options.
Is it possible to define the combo-box's Windows Authentication option with a condition expression for Windows OS only? (it doesn't make sense to display it for Linux users)
Some of the form components are "username" & "password". In case the user chooses the windows authentication mode these fields aren't relevant anymore. Is it possible to conceal them in that case?
Is the combo-box option could lead to a conflict when running the installer with a quite mode? Is it set the 1st option as a default?

Is it possible to define the combo-box's Windows Authentication option
with a condition expression for Windows OS only? (it doesn't make
sense to display it for Linux users)
You can set the "Drop-down list entries" property of the "Drop-down list" form component to an installer variable that contains a string array:
${installer:authenticationOptions}
In the pre-activation script of the form, you can set the variable with code like:
List<String> options = new ArrayList<>();
options.add("One");
options.add("Two");
if (Util.isWindows()) {
options.add("Three");
}
context.setVariable("authenticationOptions", options.toArray(new String[0]));
Some of the form components are "username" & "password". In case the
user chooses the windows authentication mode these fields aren't
relevant anymore. Is it possible to conceal them in that case?
Yes, by disabling the components in the "Selection change script" property with code like this:
// to disable
formEnvironment.getFormComponentById("123").setEnabled(!selectedItem.equals("Windows authentication"));
// or to hide
formEnvironment.getFormComponentById("123").setVisible(!selectedItem.equals("Windows authentication"));
Is the combo-box option could lead to a conflict when running the installer
with a quite mode?
By default, the first index is selected. This is configurable with the "Initially selected index" property of the "Drop-down list" form component.
Alternative solution:
I would consider using "Single radio button" form components for your authentication options. They are all bound to the same variable name in order to form a group and have the same effect as a drop-down list. With the "Visibility script" property you can hide some options depending on the OS, for example with
Util.isWindows()
and option is only visible on Windows. With the "Coupled form components" tab in the configuration area, you can select other form components that are disabled or enabled depending on the selection.

Related

Appium: autoAcceptAlert doesn't work to allow access to all photos on IOS 14

The problem is that in IOS 14 there is a third option of permission of photos and autoAcceptAlerts is clicking 'don't allow' in case of any passed argument.
Resolved with adding acceptAlertButtonSelector to the desired caps:
Java
driver.setSetting("acceptAlertButtonSelector", "**/XCUIElementTypeButton[label == 'Allow While Using App']");
Python
"acceptAlertButtonSelector": "**/XCUIElementTypeButton[label == 'Allow While Using App']"
Check Appium Settings API: for iOS it has acceptAlertButtonSelector parameter you need to set via API call and then you can try to find the button with required label:
Allows to customize accept alert button selector.
It helps you to handle an arbitrary element as accept button in accept alert
command. The selector should be a valid class chain expression, where the
search root is the alert element itself.
The default button location algorithm is used if the provided selector is wrong
or does not match any element. e.g.,
**/XCUIElementTypeButton[`label CONTAINS[c] 'accept'`]

How to disable the Tab key in ZK?

How to disable the Tab key in ZK?
Or, how can I make an event of a Tab key strike?
Situation needs that nothing should happen when user press the Tab key, i. e. the default Tab key functionality must be disabled.
I don't fully like the idea to change established keyboard conventions such as TAB focussing the next input in the tab-order.
However if a special case requires this behavior you can simply add an event listener to capture and prevent the default action for the tab key (keycode 9):
<script>
window.addEventListener(
'keydown',
function(event) {
if(event.keyCode == 9) event.preventDefault();
},
{capture: true}
);
</script>
Tested on Windows 10: Chrome/FF/Edge
This is not ZK specific and the script can be used on any other html/JS page.
As you were asking "how to do this in ZK" I wonder if you had any ZK problem that makes you want to disable the TAB key.
Robert
We have replaced the default behavior of Tab in our application as well, because we wanted more control:
disabling the focus tabbing for textfields which allow tab stops to be inserted.
excluding "unnecessary" fields from the focus tabbing: readonly fields, readonly comboboxes with hidden combobutton, every radio button of a radiogroup except one (saves the user clicks).
custom focus tabbing order (using the tabindex attribute was not sufficient, as our UI is quite dynamic and can hence have multiple components with the same index across different windows/panels/popups... Hence, we have to treat tabindex only in the scope of the closest container parent).
We started with a listener similar to Robert's answer:
$(document).ready(function() {
$(document).keydown(function(event) {
if(event.which === 9) {
var current = getCurrentlyFocusedComponent();
if (current.attr('tabindex') && new Number(current.attr('tabindex')) == -1) {
doNonFocusStuff(current[0], event.shiftKey);
event.preventDefault();
} else {
// default focus tabbing
// or
// custom focus tabbing with:
event.preventDefault();
}
}
});
});
If you want to completly disable Tab for your page, a simple event.preventDefault() will be enough. In the example above you can see that we disable the key only for certain components by setting the the tabindex = -1.
Let me know if you are interested in more details of how we do the focus manually or add tab stops, I can share the code.
As for sending an event when tab is pressed, you can use this line in the listener I showed above:
zAu.send(new zk.Event(zk.$(current), "onTab", {foo: 'some data'}, {toServer: true}));
and attach normal listener on the server side:
tabbedComponent.addEventListener("onTab", e -> Clients.showNotification("tabbed!"));
Read this article for more information on sending custom events to the server: https://www.zkoss.org/wiki/ZK_Client-side_Reference/Communication/AU_Requests/Client-side_Firing#Fire_Event_to_Widget:

Winium - how to access tool bar item if that bar doesn't have child

I am using Winium + Java for automation testing of Windows application, and trying to access tool bar menu.
When I tried to detect elements using UI Automation Verify, I couldn't see child elements under tool bar element like below screenshot.
enter image description here
But my tool bar definitely has sub menu items like screenshot and I need to access them.
enter image description here
I tried below java code, but it didn't work
WebElement el = driver.findElement(By.id('59398'));
el.click();
WebElement child = el.findElement(By.name('Start'));
child.click();
when I tried
driver.findElement(By.name"Start').click();
it clicked my windows start menu, not my application's menu.
Is there any way to access items under this tool bar?
You can try use another UI Inspector
eg. UI SPY or Inspector.exe
Probably your ID is not a AutomationID (process id?)
You should find a main window (parent of your app) (Example for calc) and get a parameter like AutomationId, ClassName or Name
I see this is MFC application, and this is an app side MFC library problem. If you hover mouse over toolbar button using Inspect.exe, the info is available but you can't reach this button from the hierarchy (the buttons have no parent somehow). Possible workaround involves combined Win32 API and UI Automation approach:
get button rectangle using Win32 API (but there is no text).
use ElementFromPoint method of UI Automation API and get actual texts to choose the right button.
P.S. My suggestion is applicable for Java + Winium in theory. But I can't estimate the complexity because I'm not a Java expert. So below is Python solution.
We have plans to implemented this mixed way in pywinauto. See issue #413. It contains Python code sample how to do that. We've had no chance to integrate it yet.
from ctypes.wintypes import tagPOINT
import pywinauto
app = pywinauto.Application().start(r'.\apps\MFC_samples\RebarTest.exe')
menu_bar = app.RebarTest.MenuBar.wrapper_object()
point = menu_bar.button(0).rectangle().mid_point()
point = menu_bar.client_to_screen(point)
elem = pywinauto.uia_defines.IUIA().iuia.ElementFromPoint(tagPOINT(point[0], point[1]))
element = pywinauto.uia_element_info.UIAElementInfo(elem)
print(element.name)

Eclipse editor - detect tab switch on another document

I have an Eclipse Editor plugin associated with .xxx filetype, how can I detect when the user switches from a document to another?
I mean when a user switches from a tab with graph1.xxx to another opened tab with graph2.xxx
I would add an IPartListener (or IPartListener2) event listener to the PartService of the Active Workbench Window, and listen for the various changes. Something similar to the following code could be used (if you register the listener inside your editor code, you should get the workbench window through the inherited methods):
Workbench.getInstance().getActiveWorkbenchWindow()
.getPartService().addPartListener(new IPartListener2() { ... }
Be careful, that both Editors and Views are parts, so some notification will be unnecessary for your job.

How do I open a new workbench window (with its own WorkbenchWindowAdvisor) from an existing workbench window?

I have a RCP applicaton from which I need to show a GEF Editor in a modal "dialog". But since the editor framework seems to be tightly coupled to the use of a workbench window etc I need to find a why to open a new workbench window (with its own WorkbenchWindowAdvisor etc) so that I can open my GEF editor within this workbench window. Once I get this workbenchWindow opened I will set the style of the WorkbenchWindow's shell to be application modal.
I have done this in a customer project using the following components:
A static class with a method openNewWindow(String type, ...). This is the method you call to open a new window. The type argument specifies the wanted type of window.
The class looks up the specified type via a new extension point to get an ILocalWorkbenchWindowAdvisor and the initial perspective ID.
It then saves the information in global variables and calls IWorkbench.openWorkbenchWindow(perspectiveID, ...)
In ApplicationWorkbenchAdvisor.createWorkbenchWindowAdvisor(...) a new advisor is create based on the saved ILocalWorkbenchWindowAdvisor - the returned advisor basically delegates all the postWindowCreate(...), etc to the same methods in ILocalWorkbenchWindowAdvisor...
If no ILocalWorkbenchWindowAdvisor is saved - which is the case for the very first window to be opened - the type "mainWindow" is looked up and used...
It works pretty well and let all parts of the project add new windows as needed.
Use the command "org.eclipse.ui.window.newWindow" to open a new window. In your WorkbenchWindowAdvisor.preWindowOpen(), set the shell style on the IWorkbenchWindowConfigurer to be application modal. You can also hide the coolbar, menu and status bars, so it looks more like a dialog than a window.

Categories

Resources