javafx: how to close unknown child stages/windows - javafx

I use this code to convert a video with xuggler:
http://www.jochenhebbrecht.be/site/2010-10-12/java/converting-resizing-videos-in-java-xuggler
The convertion works fine and the line:
reader.addListener(ToolFactory.makeViewer(true));
let me view two windows with video and statistics.The problem is, after converting the windows don't close automatically and I don't know how to do it.
I changed the above line into
IMediaListener imL=ToolFactory.makeViewer(IMediaViewer.Mode.FAST_VIDEO_ONLY,true);
reader.addListener(imL);
and after the while I insert
reader.removeListener(imL);
reader.close();
But the windows don't disappear after converting/ task finished.So I want to know how I can get access to this windows to achieve a simple stage.close().
EDIT: I'm using Java 8
EDIT2:
I now tried
StageHelper.getStages().size(); //-> 1
and
Iterator<Window> windows=Window.impl_getWindows();
String window_String="";
while(windows.hasNext()){
window_String+=" |-> "+
}
System.out.println("WINDOWS: ---->"+Window.impl_getWindows());
Both shows that there is just ONE window.It seems, that the windows from
"reader.addListener(ToolFactory.makeViewer(true));" are not in the list.

The Problem is that Xuggler uses Swing and not JavaFX so Window.impl_getWindows() and StageHelper.getStages() wont return the windows that are create with ToolFactory.makeViewer(true).
So the correct way is java.awt.Window.getWindows().

Related

xcb: how to launch an application and show it into a window

I'm trying to implement a basic window manager using xcb library.
I managed to connect with X server, and grab some events, but i cannot figure how to launch an application and show it inside the current X session.
I'm trying to follow the xcb tutorial:
http://xcb.freedesktop.org/tutorial/
Basically i thought (and probaly i'm wrong) that once the session is started, with my "windowmanager", if i want to launch an application i just have to fork it, and launch the application, so for example:
int child = fork();
if(child==0) {
printf("Child");
execve("/usr/bin/xterm", NULL, NULL);
}
But it seems that didn't work.
I have no much code to show, since i'm trying just to modify che code in the tutorial pasted above (i added an infinite loop, and few other thing).
So how to launch an x application like xterm, pcmanfm and show it on the current x session?
And how i can draw an application inside a new window?
And a last question:
i tried to copy and paste the hello world window example of X tutorial, but it doesn't seem to load any window. The code is here:
http://www.x.org/releases/X11R7.7/doc/libxcb/tutorial/index.html#helloworld
You don't "draw an application inside a new window" - you just launch a process and it creates a window for itself. Check that DISPLAY variable is set correctly for your process.
To manage windows, you set SubstructureRedirect mask on a root window and respond to substructure/map request notifications from (new) application windows.

Websphere & Tivoli: NPE while trying to create PDAuthorizationContext

I am getting the following error when I try to start my Application...
[java.lang.IllegalStateException: java.lang.NullPointerException^M
at com.tivoli.pd.jutil.kb$1.run(kb$1.java:41)^M
at java.security.AccessController.doPrivileged(AccessController.java:229
)^M
at com.tivoli.pd.jutil.kb.c(kb.java:141)^M
at com.tivoli.pd.jutil.kb.(kb.java:56)^M
at com.tivoli.pd.jutil.PDContext.(PDContext.java:76)^M
at com.tivoli.pd.jazn.PDAuthorizationContext.(PDAuthorizationConte
xt.java:66)^M
I double checked the config file was accessible and I could read it. The code I am using looks as follows...
aC = new PDAuthorizationContext(cFile);
Is there a way to get more information on what is causing the NPE?
More information!!!
After debuging a bit, it appears the issue comes from this code (they use progaurd so it is a little hard to be 100% confident)...
Certificate[] arrayOfCertificate1 = ((KeyStore)???).getCertificateChain("DefaultID");
//Throws Null pointer (presumably because array is null)
Certificate localCertificate1 = arrayOfCertificate1[0];
EVEN MORE INFO
This appears to be some kind of dependency conflict (guess), because if I just create a sample App using PDAuthorizationContext it works fine.
Problem was related to the PD.jar version that I was using. Although I thought I was using one version I was using another. This was because on version was registered in my WebSphere library (under build path in eclipse). Once the proper library was introduced everything worked.

How to Right click of File in Windows Explorer by AutoIt

I wish to simulate a right click on a file. This is done by opening a Windows Explorer window and then right clicking on it.
The main issue is finding the location of the file in Windows Explorer. I am currently using Autoit v3.3.8.1.
My code 's first line:
RunWait (EXPLORER.EXE /n,/e,/select,<filepath>)
The next step is the problem. Finding the coordinates of the file.
After that, right clicking at that coordinates (it seems to me at this time) is not a problem....
Some background:
OS: Windows 7 64-bit
Software Languages: C#, Autoit (for scripting)
The Autoit script is called by a code similar to that below:
Process p = new Process();
p.StartInfo.FileName = "AutoItScript.exe";
p.StartInfo.UseShellExecute = false;
p.Start();
The code is compiled into a console class file which is run at startup. The autoit script runs as the explorer window opens up.
It seems as though you are taking the wrong approach to the problem, so I'll answer what you are asking and what you should be asking.
First up though, that line of code is not valid, and is not what you want either. You want to automate the explorer window, and RunWait waits for the program to finish. Furthermore you want those items to be strings, that code would never work.
Finding the item in explorer
The explorer window is just a listview, and so you can use normal listview messages to find the coordinates of an item. This is done most simply by AutoIt's GUIListView library:
#include<GUIListView.au3>
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Local $hList = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32; INSTANCE:1]")
Local $aClient = WinGetPos($hList)
Local $aPos = _GUICtrlListView_GetItemPosition($hList, _GUICtrlListView_GetSelectedIndices($hList))
MouseClick("Right", $aClient[0] + $aPos[0] + 4, $aClient[1] + $aPos[1] + 4)
As has already been mentioned, sending the menu key is definitely a better way than having to move the mouse.
Executing a subitem directly
This is how it should be done. Ideally you should never need an explorer window open at all, and everything can be automated in the background. This should always be what you aim to achieve, as AutoIt is more than capable in most cases. It all depends on what item you want to click. If it is one of the first few items for opening the file in various programs, then it is as simple as either:
Using ShellExecute, setting the verb parameter to whatever it is you want to do.
Checking the registry to find the exact command line used by the program. For this you will need to look under HKCR\.ext where ext is the file extension, the default value will be the name of another key in HKCR which has the actions and icon associated with the filetype. This is pretty well documented online, so google it.
If the action is not one of the program actions (so is built into explorer) then it is a little more complex. Usually the best way will be to look at task manager when you start the program and see what it runs. Other things can be found online, for example (un)zipping. Actions like copy, delete, rename, create shortcut, send to... They can all be done directly from AutoIt with the various File* functions.
With more information, it would be possible to give you more specific help.
First, you might want to look at the Microsoft Active Accessibility SDK. In particular look at this interface...
http://msdn.microsoft.com/en-us/library/accessibility.iaccessible.aspx
You can use this to walk the items in the control and find the one with the file name you are looking for and its screen location.
From there, maybe try something like this for simulating the right click.
How can I use automation to right-click with a mouse in Windows 7?
Once you have done the right click, use accessibility again to find the right option on the context menu.
Maybe there's an easier way, you should be able to cobble something together like this if you don't find one. Good luck!
Suppose I have a file named test.txt on D drive. It needs to right click for opening Context Menu. To do this, the following code should work:
Local $filepath = "D:\test.txt"
Local $iPid = Run("explorer.exe /n,/e,/select," & $filepath)
ProcessWait($iPid)
Sleep(1000)
Send('+{F10}')

browseForOpenMultiple - crashing

I am trying to work with browseForOpenMultiple function inside Flex, sdk 3.5, I am trying to figure out a bug. The browseForOpenMultiple does not crash everytime, but it seems as though I can upload a file once, but when I go to upload a second file, it crashes when the browseForOpenMultiple function is called. Anyone have any ideas about possible causes?
Update:
private function browseForFiles():void
{
fileBrowser = new File();
fileBrowser.addEventListener(FileListEvent.SELECT_MULTIPLE, filesSelected);
fileBrowser.addEventListener(Event.CANCEL, fileSelectionCancelled);
fileBrowser.browseForOpenMultiple("Select Desired Media File(s)", [(mode == "Media")? MediaTypes.getFileFilter() : MediaTypes.getVideoFilter()]);
}
So the code in our array of file extensions was crashing when there were over 60 items listed in an array that gets converted into a string for the FileFilter. This may not be an Adobe limit, but I wanted to make mention that the crash is fixed, so that others who may be encountering issues with browseForOpenMultiple will know what the issue was for this problem. This is not code that I originally wrote, so I will check into it for more clues, but for the time being, too many array items being joined together into a string for FileFilter object caused the crash.
It could be how it's construct the File, without a real file reference.
Try something like this :
var fileBrowser = File.desktopDirectory

How to view Session Variables in Visual Studio 2008 Debugger?

Usually using Visual Studio's debugger is a breeze. Scanning through Locals quickly shows the values of variables, etc. However, I'm at a loss how to find out the values contained in session state variables? Can anyone give me a hand?
Let's say I put a breakpoint right after:
Session["first_name"] = "Rob Roy";
How do I view the value contained in Session["first_name"] from locals?
It's pretty simple to inspect the session during debug. Just put a breakpoint in your code and just highlight your Session code (eg. highlight: Session["first_name"]) then right click and select QuickWatch....
This will setup up a watch on your Session for the value you had defined. You can also inspect other Session elements by adjusting the Expression field in the QuickWatch window and clicking the Reevaluate button.
In VS you can just put 'Session["first_name"]' in the Immediate Window and execute while the code is running. That will return the value that it holds.
If you can't find it go to: View > Other Windows > Command Window, or press Ctrl+W, A
It will look like this:
I know its a bit of a late reply but for anyone else who is interested, I hope this helps!
Isn't it HttpContext.Current.Session("..."), I ask as I haven't used ASP.NET for a long time.

Resources